gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r29042 - in gnunet-gtk: contrib src/fs


From: gnunet
Subject: [GNUnet-SVN] r29042 - in gnunet-gtk: contrib src/fs
Date: Thu, 5 Sep 2013 18:36:01 +0200

Author: grothoff
Date: 2013-09-05 18:36:00 +0200 (Thu, 05 Sep 2013)
New Revision: 29042

Removed:
   gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
Modified:
   gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade
   gnunet-gtk/src/fs/Makefile.am
   gnunet-gtk/src/fs/gnunet-fs-gtk.c
   gnunet-gtk/src/fs/gnunet-fs-gtk.h
   gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-search.c
Log:
-towards fixing #1952 with GNS/FS integration

Modified: gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade  2013-09-05 16:27:22 UTC 
(rev 29041)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade  2013-09-05 16:36:00 UTC 
(rev 29042)
@@ -289,7 +289,6 @@
             <property name="spacing">4</property>
             <child>
               <object class="GtkLabel" id="main_window_search_namespace_label">
-                <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="label" translatable="yes">Namespace:</property>
               </object>
@@ -301,7 +300,6 @@
             </child>
             <child>
               <object class="GtkComboBox" 
id="main_window_search_namespace_combobox">
-                <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="model">namespace_label_liststore</property>
                 <property name="button_sensitivity">off</property>

Modified: gnunet-gtk/src/fs/Makefile.am
===================================================================
--- gnunet-gtk/src/fs/Makefile.am       2013-09-05 16:27:22 UTC (rev 29041)
+++ gnunet-gtk/src/fs/Makefile.am       2013-09-05 16:36:00 UTC (rev 29042)
@@ -20,7 +20,6 @@
   gnunet-fs-gtk_download-save-as.c gnunet-fs-gtk_download-save-as.h \
   gnunet-fs-gtk_event-handler.c gnunet-fs-gtk_event-handler.h \
   gnunet-fs-gtk_main-window-connection.c \
-  gnunet-fs-gtk_main-window-meta-data-context-menu.c \
   gnunet-fs-gtk_main-window-namespace-dropdown.c \
   gnunet-fs-gtk_main-window-search.c \
   gnunet-fs-gtk_main-window-view-toggles.c \
@@ -38,6 +37,8 @@
   -lgnunetutil \
   -lgnunetarm \
   -lgnunetfs \
+  -lgnunetgns \
+  -lgnunetnamestore \
   -lgnunetidentity \
   $(INTLLIBS) 
 gnunet_fs_gtk_LDFLAGS = \

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.c   2013-09-05 16:27:22 UTC (rev 29041)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.c   2013-09-05 16:36:00 UTC (rev 29042)
@@ -81,6 +81,7 @@
 static UniqueApp *unique_app;
 #endif
 
+
 struct GNUNET_GTK_MainWindowContext *
 GNUNET_FS_GTK_get_main_context ()
 {
@@ -230,6 +231,8 @@
 static void
 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {  
+  struct SearchLookup *sl;
+
   GNUNET_GTK_tray_icon_destroy ();
   if (fs != NULL)
   {
@@ -248,8 +251,37 @@
   }
   GNUNET_FS_GTK_close_uri_tab_ ();
   if (NULL != ml)
+  {
     GNUNET_GTK_main_loop_quit (ml);
-  ml = NULL;
+    ml = NULL;
+  }
+  if (NULL != main_context.id_op)
+  {
+    GNUNET_IDENTITY_cancel (main_context.id_op);
+    main_context.id_op = NULL;
+  }
+  if (NULL != main_context.identity)
+  {
+    GNUNET_IDENTITY_disconnect (main_context.identity);
+    main_context.identity = NULL;
+  }
+  while (NULL != (sl = main_context.sl_head)) 
+    abort_search_lookup (sl);  
+  if (NULL != main_context.zm)
+  {
+    GNUNET_NAMESTORE_zone_monitor_stop (main_context.zm);
+    main_context.zm = NULL;
+  }
+  if (NULL != main_context.gns)
+  {
+    GNUNET_GNS_disconnect (main_context.gns);
+    main_context.gns = NULL;
+  }
+  if (NULL != main_context.sks_zone)
+  {
+    GNUNET_free (main_context.sks_zone);
+    main_context.sks_zone = NULL;
+  }
 }
 
 
@@ -408,6 +440,7 @@
 }
 #endif
 
+
 static char *
 format_service_list (unsigned int count, const char *const*list)
 {
@@ -514,6 +547,67 @@
 
 
 /**
+ * Process a record that was stored in the namestore in the
+ * "sks_zone".  Adds (or removes) the respective label to the
+ * drop-down menu for the SKS search by manipulating the
+ * "namespace_label_liststore".
+ *
+ * @param cls closure
+ * @param zone private key of the zone
+ * @param label label of the records
+ * @param rd_count number of entries in @a rd array
+ * @param rd array of records with data to store
+ */
+static void 
+monitor_zone_records (void *cls,
+                     const struct GNUNET_CRYPTO_EccPrivateKey *zone,
+                     const char *label,
+                     unsigned int rd_count,
+                     const struct GNUNET_NAMESTORE_RecordData *rd)
+{
+  GNUNET_break (0); // not implemented
+}
+
+
+/**
+ * The identity service has given us the ego we should use for resolving
+ * namepace names.
+ *
+ * @param cls closure
+ * @param ego ego handle, NULL for none
+ * @param ctx context for application to store data for this ego
+ *                 (during the lifetime of this process, initially NULL)
+ * @param name name assigned by the user for this ego,
+ *                   NULL if the user just deleted the ego and it
+ *                   must thus no longer be used
+ */
+static void
+handle_sks_zone_identity (void *cls,
+                         struct GNUNET_IDENTITY_Ego *ego,
+                         void **ctx,
+                         const char *name)
+{
+  main_context.id_op = NULL;
+  
+  if (NULL == ego)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                 _("No default ego specified for `fs-sks` service, will not 
enable namespace search.\n"));
+      return;
+    }
+  main_context.sks_zone = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
+  *main_context.sks_zone = *GNUNET_IDENTITY_ego_get_private_key (ego);
+  gtk_widget_show (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object 
("main_window_search_namespace_label")));
+  gtk_widget_show (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object 
("main_window_search_namespace_combobox")));
+  main_context.zm = GNUNET_NAMESTORE_zone_monitor_start (main_context.cfg,
+                                                        main_context.sks_zone,
+                                                        &monitor_zone_records,
+                                                        NULL, 
+                                                        NULL);
+}
+
+
+/**
  * Actual main function run right after GNUnet's scheduler
  * is initialized.  Initializes up GTK and Glade.
  *
@@ -635,7 +729,11 @@
   }
   arm = GNUNET_ARM_connect (main_context.cfg, &arm_connection_state_change, 
&main_context);
   armon = GNUNET_ARM_monitor (main_context.cfg, service_status_change, 
&main_context);
-
+  main_context.identity = GNUNET_IDENTITY_connect (main_context.cfg, NULL, 
NULL);
+  main_context.id_op = GNUNET_IDENTITY_get (main_context.identity,
+                                           "fs-sks",
+                                           &handle_sks_zone_identity,
+                                           NULL);
   GNUNET_GTK_main_window_refresh_ns_list (&main_context);
 #if HAVE_LIBUNIQUE
   unique_app_watch_window (unique_app, GTK_WINDOW (main_context.main_window));

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.h   2013-09-05 16:27:22 UTC (rev 29041)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.h   2013-09-05 16:36:00 UTC (rev 29042)
@@ -28,10 +28,68 @@
 
 #include "gnunet_gtk.h"
 #include <gnunet/gnunet_fs_service.h>
+#include <gnunet/gnunet_gns_service.h>
+#include <gnunet/gnunet_identity_service.h>
+#include <gnunet/gnunet_namestore_service.h>
 #include <extractor.h>
 
+
+/**
+ * Context for a GNS lookup for starting a search.
+ */
+struct SearchLookup
+{
+
+  /**
+   * This is a DLL.
+   */
+  struct SearchLookup *prev;
+
+  /**
+   * This is a DLL.
+   */
+  struct SearchLookup *next;
+
+  /**
+   * Our active request with GNS.
+   */
+  struct GNUNET_GNS_LookupRequest *gns;
+
+  /**
+   * Keywords to use.
+   */
+  gchar *keywords;
+
+  /**
+   * Task to trigger timeout.
+   */
+  GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+
+  /**
+   * Desired anonymity level.
+   */
+  guint anonymity_level;
+
+};
+
+
+/**
+ * Abort the given search lookup.
+ *
+ * @param sl lookup to abort.
+ */
+void
+abort_search_lookup (struct SearchLookup *sl);
+
+
+/**
+ * Context for the main window.
+ */
 struct GNUNET_GTK_MainWindowContext
 {
+  /**
+   * Builder that loaded the main window.
+   */
   GtkBuilder *builder;
 
   const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -72,6 +130,43 @@
   GtkNotebook *notebook;
 
   GtkImage *connection_indicator;
+
+  /**
+   * Handle to the GNS service.
+   */
+  struct GNUNET_GNS_Handle *gns;
+
+  /**
+   * Handle to a zone monitor to update the namespace's drop-down list store.
+   * Monitors the @e sks_zone. Can be NULL.
+   */
+  struct GNUNET_NAMESTORE_ZoneMonitor *zm;
+
+  /**
+   * This is a DLL.
+   */
+  struct SearchLookup *sl_head;
+
+  /**
+   * This is a DLL.
+   */
+  struct SearchLookup *sl_tail;
+
+  /**
+   * Handle to identity service.
+   */
+  struct GNUNET_IDENTITY_Handle *identity;
+
+  /**
+   * Operation we use to determine namespace resolution domain.
+   */
+  struct GNUNET_IDENTITY_Operation *id_op;
+
+  /**
+   * Our zone for SKS operations.  Can be NULL.
+   */
+  struct GNUNET_CRYPTO_EccPrivateKey *sks_zone;
+
 };
 
 

Deleted: gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c        
2013-09-05 16:27:22 UTC (rev 29041)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c        
2013-09-05 16:36:00 UTC (rev 29042)
@@ -1,193 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
- * @brief context menu for the 'meta data' tree view in the main window
- * @author Christian Grothoff
- */
-#include "gnunet-fs-gtk.h"
-#include "gnunet-fs-gtk_download-save-as.h"
-#include "gnunet-fs-gtk_event-handler.h"
-#include <string.h>
-
-
-
-/**
- * Helper function of GNUNET_GTK_FS_metadata_copy_selection_activated
- * which copies the (selected) entries from the tree view to the
- * GList.
- *
- * @param model the tree model with the data
- * @param path unused
- * @param iter position in the model to access
- * @param user_data 'GList**' where we should store the types and values found
- */ 
-static void
-copy_metadata_to_clipboard (GtkTreeModel * model, GtkTreePath * path,
-                            GtkTreeIter * iter, gpointer user_data)
-{
-  GList **l = user_data;
-  gchar *type;
-  gchar *value;
-
-  gtk_tree_model_get (model, iter,
-                      GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE_STRING,
-                      &type,
-                      GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_VALUE,
-                      &value,
-                      -1);
-  *l = g_list_prepend (*l, type);
-  *l = g_list_prepend (*l, value);
-}
-
-
-/**
- * User activated metadata pop up menu "Copy selection" entry.
- *
- * @param menuitem the 'copy selection' menu item
- * @param user_data the GtkBuilder of the main window
- */
-void
-GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem, 
-                                                gpointer user_data)
-{
-  struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
-  GtkTreeView *tree;
-  GtkClipboard *cb;
-  GList *pairs;
-  GList *pos;
-  GList *value;
-  GList *type;
-  guint total_len;
-  gchar *s;
-  gchar *p;
-
-  tree = main_ctx->md_treeview;
-  pairs = NULL;
-  gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (tree),
-                                       &copy_metadata_to_clipboard, &pairs);
-  if (NULL == pairs)
-    return; /* nothing selected */
-  total_len = 0;
-  pairs = g_list_reverse (pairs);
-  for (pos = pairs; NULL != pos; pos = value->next)
-  {
-    type = pos;
-    value = pos->next;
-    GNUNET_assert (NULL != value);
-    total_len +=
-      strlen ((gchar *) type->data) + strlen ((gchar *) value->data) +
-      2 /* ": " */  + ((NULL != value->next) ? 1 : 0) /* "\n" */ ;
-  }
-  GNUNET_assert (total_len > 0);
-  total_len++;             /* "\0" */
-  s = g_new0 (gchar, total_len);
-  if (NULL == s)
-  {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "malloc");
-    return;
-  }
-  p = s;
-  for (pos = pairs; NULL != pos; pos = value->next)
-  {
-    type = pos;
-    value = pos->next;
-    GNUNET_assert (NULL != value);
-    p = g_stpcpy (p, (gchar *) type->data);
-    p = g_stpcpy (p, ": ");
-    p = g_stpcpy (p, (gchar *) value->data);
-    if (NULL != value->next)
-      p = g_stpcpy (p, "\n");        
-  }
-  g_list_foreach (pairs, (GFunc) &g_free, NULL);
-  g_list_free (pairs);
-  cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
-  gtk_clipboard_set_text (cb, s, -1);
-  gtk_clipboard_store (cb);
-  g_free (s);  
-}
-
-
-/**
- * Got asked to pop up the context menu in the metadata treeview in
- * the main window.  Do it.
- *
- * @param button which button caused the event (0 for none)
- * @param event_time time of the event (current time or 'event->time')
- * @param user_data the context of the main window
- */
-static void
-do_metadata_popup_menu (int button,
-                       int event_time,
-                        gpointer user_data)
-{
-  GtkMenu *menu;
-  struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
-
-  menu = GTK_MENU (gtk_builder_get_object (main_ctx->builder, 
"metadata_popup_menu"));
-  gtk_menu_popup (menu, NULL, NULL, NULL, main_ctx, button, event_time);
-}
-
-
-/**
- * Got a button press event on the metadata treeview in the main window.
- * If it was a right click, pop up the context menu.
- *
- * @param widget the tree view widget
- * @param user_data the gtk builder of the main window
- */
-gboolean
-GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget *
-                                                                widget,
-                                                                GdkEventButton 
*
-                                                                event,
-                                                                gpointer
-                                                                user_data)
-{
-  /* Ignore double-clicks and triple-clicks */
-  if ( (event->button != 3) || (event->type != GDK_BUTTON_PRESS) )
-    return FALSE;
-  do_metadata_popup_menu (event->button,
-                         event->time,
-                         user_data);
-  return FALSE;
-}
-
-
-/**
- * Metadata treeview in the main window got the 'popup-menu' signal.
- * Pop up the menu.
- *
- * @param widget the tree view widget
- * @param user_data the gtk builder of the main window
- * @return TRUE we did it
- */
-gboolean
-GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget * widget,
-                                                        gpointer user_data)
-{
-  do_metadata_popup_menu (0 /* no button */,
-                         gtk_get_current_event_time (),
-                         user_data);
-  return TRUE;
-}
-
-/* end of gnunet-fs-gtk_meta-data-context-menu.c */

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-search.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-search.c        2013-09-05 
16:27:22 UTC (rev 29041)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-search.c        2013-09-05 
16:36:00 UTC (rev 29042)
@@ -29,18 +29,132 @@
 
 
 /**
+ * How long until we decide a SKS namespace GNS lookup has failed?
+ */
+#define LOOKUP_TIMEOUT GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_MINUTES, 2)
+
+/**
  * Start a search.
  *
- * @param builder the main window context
+ * @param uri uri to search for, freed in this function
+ * @param anonymity_level degree of anonymity to apply for the search
  */
 static void
+search_for_uri (struct GNUNET_FS_Uri *uri,
+               guint anonymity_level)
+{
+  /* start search */
+  GNUNET_FS_search_start (GNUNET_FS_GTK_get_fs_handle (), 
+                         uri, anonymity_level,
+                          GNUNET_FS_SEARCH_OPTION_NONE, NULL);
+  GNUNET_FS_uri_destroy (uri);
+}
+
+
+
+
+/**
+ * Abort the given search lookup.
+ *
+ * @param sl lookup to abort.
+ */
+void
+abort_search_lookup (struct SearchLookup *sl)
+{
+  struct GNUNET_GTK_MainWindowContext *main_ctx = 
GNUNET_FS_GTK_get_main_context ();
+
+  GNUNET_CONTAINER_DLL_remove (main_ctx->sl_head,
+                              main_ctx->sl_tail,
+                              sl);
+  if (GNUNET_SCHEDULER_NO_TASK != sl->timeout_task)
+  {
+    GNUNET_SCHEDULER_cancel (sl->timeout_task);
+    sl->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+  }
+  if (NULL != sl->gns)
+  {
+    GNUNET_GNS_lookup_cancel (sl->gns);
+    sl->gns = NULL;
+  }
+  g_free (sl->keywords);
+  GNUNET_free (sl);                           
+}
+
+
+/**
+ * Task run when the GNS timeout during the resolution of
+ * the GNS namespace times out.
+ *
+ * @param cls the 'struct SearchLookup'
+ * @param tc scheduler context
+ */
+static void
+timeout_search_lookup (void *cls,
+                      const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct SearchLookup *sl = cls;
+
+  sl->timeout_task = GNUNET_SCHEDULER_NO_TASK;
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
+             _("Failed to resolve namespace in time\n"));
+  abort_search_lookup (sl);
+}
+
+
+
+/**
+ * Iterator called on obtained result for a GNS lookup for
+ * the public key of a namespace identifier.
+ *
+ * @param cls closure
+ * @param rd_count number of records in @a rd
+ * @param rd the records in reply
+ */
+static void
+handle_gns_result (void *cls,
+                  uint32_t rd_count,
+                  const struct GNUNET_NAMESTORE_RecordData *rd)
+{
+  struct SearchLookup *sl = cls;
+  unsigned int i;
+  struct GNUNET_FS_Uri *uri;
+
+  sl->gns = NULL;
+  for (i=0;i<rd_count;i++)
+    {
+      if (GNUNET_NAMESTORE_TYPE_PKEY != rd[i].record_type)
+       continue;
+      if (sizeof (struct GNUNET_CRYPTO_EccPublicKey) != rd[i].data_size)
+      {
+       GNUNET_break_op (0);
+       continue;
+      }
+      uri = GNUNET_FS_uri_sks_create (rd[i].data, sl->keywords);
+      search_for_uri (uri, sl->anonymity_level);
+      abort_search_lookup (sl);
+      return;      
+    }
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
+             _("Failed to resolve namespace in time\n"));
+  abort_search_lookup (sl);
+}
+
+/**
+ * Start a search.
+ *
+ * @param main_ctx the main window context
+ */
+static void
 start_search (struct GNUNET_GTK_MainWindowContext *main_ctx)
 {
   guint anonymity_level;
   gchar *keywords;
   gchar *mime_keyword;
-  struct GNUNET_CRYPTO_EccPublicKey *nsid;
+  const char *nsid;
   struct GNUNET_FS_Uri *uri;
+  struct GNUNET_CRYPTO_EccPublicKey pub_sks_zone;
+  struct SearchLookup *sl;
+  char *emsg;
 
   /* get anonymity level */
   if (!GNUNET_GTK_get_selected_anonymity_level
@@ -73,28 +187,17 @@
       mime_keyword = NULL;
     }
   }
-
-  /* get selected namespace */
   {
-    GtkTreeRowReference *ref;
-    GtkTreeIter iter;
-
-    nsid = NULL;    
-    ref = main_ctx->selected_ns_row;
-    if (NULL != ref)
-    {
-      GtkTreePath *namespace_treepath;
-      GtkTreeModel *namespace_model;
-      
-      namespace_model = gtk_tree_row_reference_get_model (ref);
-      namespace_treepath = gtk_tree_row_reference_get_path (ref);
-      if ( (NULL != namespace_treepath) &&
-          (gtk_tree_model_get_iter (namespace_model, &iter, 
namespace_treepath)))
-        gtk_tree_model_get (namespace_model, &iter,
-                            GNUNET_GTK_FS_MAIN_WINDOW_SEARCH_MIME_MC_TYPE,
-                            &nsid,
-                            -1);
-    }
+    GtkComboBox *namespace_box;
+    
+    namespace_box = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object 
("main_window_search_namespace_combobox"));
+    nsid = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN 
(namespace_box))));
+    if ( (NULL != nsid) &&
+        ( (0 == strcasecmp (nsid,
+                            "<none>")) ||
+          (0 == strcasecmp (nsid,
+                            _("<none>"))) ) )
+      nsid = NULL;
   }
    
   /* get keywords and compose keyword string */
@@ -117,31 +220,41 @@
 
   /* build KSK/SKS URI */
   if (NULL != nsid)
-  {
-    uri = GNUNET_FS_uri_sks_create (nsid, keywords);
-    GNUNET_assert (uri != NULL);
+  {    
+    sl = GNUNET_new (struct SearchLookup);
+    sl->keywords = keywords;
+    sl->anonymity_level = anonymity_level;
+    sl->timeout_task = GNUNET_SCHEDULER_add_delayed (LOOKUP_TIMEOUT,
+                                                    &timeout_search_lookup, 
sl);
+    GNUNET_CRYPTO_ecc_key_get_public (main_ctx->sks_zone,
+                                     &pub_sks_zone);
+    sl->gns = GNUNET_GNS_lookup (main_ctx->gns,
+                                nsid,
+                                &pub_sks_zone,
+                                GNUNET_NAMESTORE_TYPE_PKEY,
+                                GNUNET_NO,
+                                NULL /* no shortening */,
+                                &handle_gns_result,
+                                sl);
+    GNUNET_CONTAINER_DLL_insert (main_ctx->sl_head,
+                                main_ctx->sl_tail,
+                                sl);
+    return;
   }
-  else
+
+  emsg = NULL;
+  uri = GNUNET_FS_uri_ksk_create (keywords, &emsg);
+  if (NULL == uri)
   {
-    char *emsg = NULL;
-
-    uri = GNUNET_FS_uri_ksk_create (keywords, &emsg);
-    if (NULL == uri)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Invalid keyword string `%s': 
%s"),
-                  keywords, emsg);
-      g_free (keywords);
-      GNUNET_free_non_null (emsg);
-      return;
-    }
-  }
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
+               _("Invalid keyword string `%s': %s"),
+               keywords, emsg);
+    g_free (keywords);
+    GNUNET_free_non_null (emsg);
+    return;
+  }  
   g_free (keywords);
-
-  /* start search */
-  GNUNET_FS_search_start (GNUNET_FS_GTK_get_fs_handle (), 
-                         uri, anonymity_level,
-                          GNUNET_FS_SEARCH_OPTION_NONE, NULL);
-  GNUNET_FS_uri_destroy (uri);
+  search_for_uri (uri, anonymity_level);
 }
 
 
@@ -156,6 +269,7 @@
                                      gpointer user_data)
 {
   struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
+
   start_search (main_ctx);
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]