gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r29167 - gnunet-gtk/src/fs


From: gnunet
Subject: [GNUnet-SVN] r29167 - gnunet-gtk/src/fs
Date: Tue, 10 Sep 2013 17:08:04 +0200

Author: grothoff
Date: 2013-09-10 17:08:04 +0200 (Tue, 10 Sep 2013)
New Revision: 29167

Modified:
   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 implementing save of namespaces to fs-sks zone

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.c   2013-09-10 14:41:58 UTC (rev 29166)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.c   2013-09-10 15:08:04 UTC (rev 29167)
@@ -233,6 +233,7 @@
 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {  
   struct SearchLookup *sl;
+  struct PseuLookupContext *lctx;
 
   GNUNET_GTK_tray_icon_destroy ();
   if (fs != NULL)
@@ -268,6 +269,8 @@
   }
   while (NULL != (sl = main_context.sl_head)) 
     abort_search_lookup (sl);  
+  while (NULL != (lctx = main_context.lctx_head)) 
+    abort_pseu_lookup (lctx);  
   if (NULL != main_context.zm)
   {
     GNUNET_NAMESTORE_zone_monitor_stop (main_context.zm);

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.h   2013-09-10 14:41:58 UTC (rev 29166)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.h   2013-09-10 15:08:04 UTC (rev 29167)
@@ -74,6 +74,34 @@
 
 
 /**
+ * Context we keep for a pseudonym lookup on 'save'.
+ */
+struct PseuLookupContext
+{
+  
+  /**
+   * Kept in a DLL.
+   */
+  struct PseuLookupContext *next;
+
+  /**
+   * Kept in a DLL.
+   */
+  struct PseuLookupContext *prev;
+
+  /**
+   * Main window context.
+   */
+  struct GNUNET_GTK_MainWindowContext *main_ctx;
+
+  /**
+   * Lookup request with GNS.
+   */
+  struct GNUNET_GNS_LookupRequest *lr;
+};
+
+
+/**
  * Abort the given search lookup.
  *
  * @param sl lookup to abort.
@@ -83,6 +111,15 @@
 
 
 /**
+ * Abort the given PSEU lookup.
+ *
+ * @param lctx lookup to abort.
+ */
+void
+abort_pseu_lookup (struct PseuLookupContext *lctx);
+
+
+/**
  * Context for the main window.
  */
 struct GNUNET_GTK_MainWindowContext
@@ -143,16 +180,26 @@
   struct GNUNET_NAMESTORE_ZoneMonitor *zm;
 
   /**
-   * This is a DLL.
+   * Head of sl DLL.
    */
   struct SearchLookup *sl_head;
 
   /**
-   * This is a DLL.
+   * Tail of sl DLL.
    */
   struct SearchLookup *sl_tail;
 
   /**
+   * Head of lctx DLL.
+   */
+  struct PseuLookupContext *lctx_head;
+
+  /**
+   * Tail of lctx DLL.
+   */
+  struct PseuLookupContext *lctx_tail;
+
+  /**
    * Handle to identity service.
    */
   struct GNUNET_IDENTITY_Handle *identity;

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-10 
14:41:58 UTC (rev 29166)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-search.c        2013-09-10 
15:08:04 UTC (rev 29167)
@@ -298,6 +298,55 @@
 
 
 /**
+ * Abort the given PSEU lookup.
+ *
+ * @param lctx lookup to abort.
+ */
+void
+abort_pseu_lookup (struct PseuLookupContext *lctx)
+{
+  struct GNUNET_GTK_MainWindowContext *main_ctx = lctx->main_ctx;
+
+  if (NULL != lctx->lr)
+  {
+    GNUNET_GNS_lookup_cancel (lctx->lr);
+    lctx->lr = NULL;
+  }
+  GNUNET_CONTAINER_DLL_remove (main_ctx->lctx_head,
+                              main_ctx->lctx_tail,
+                              lctx);
+  GNUNET_free (lctx);
+}
+
+
+/**
+ * Iterator called on obtained result for a GNS lookup for
+ * the PSEU lookup when "saving" a zone.  The actual saving
+ * should already have happened via the shortening of GNS,
+ * so we only need to clean up.
+ *
+ * FIXME: this is a drastic simplification, as shortening
+ * may fail (name used, PSEU record not found); in those
+ * cases, we should _still_ do something here...
+ *
+ * @param cls closure with the `struct PseuLookupContext`
+ * @param rd_count number of records in @a rd
+ * @param rd the records in reply
+ */
+static void
+lookup_finished (void *cls,
+                uint32_t rd_count,
+                const struct GNUNET_NAMESTORE_RecordData *rd)
+{
+  struct PseuLookupContext *lctx = cls;
+
+  /* FIXME: might want to give visual feedback to the user here */
+  lctx->lr = NULL;
+  abort_pseu_lookup (lctx);
+}
+
+
+/**
  * User clicked on the 'save' button in the search line of the main window.
  * Store the selected namespace in the "sks-fs" zone.
  *
@@ -310,9 +359,43 @@
                                      gpointer user_data)
 {
   struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
+  GtkComboBox *widget;
+  const gchar *text;
+  struct GNUNET_CRYPTO_EccPublicKey pkey;
+  int ret;
+  struct PseuLookupContext *lctx;
 
-  GNUNET_break (0);
-  (void) main_ctx;
+  if (NULL == main_ctx->gns)
+  {
+    GNUNET_break (0);
+    return;
+  }
+  widget = GTK_COMBO_BOX (GNUNET_FS_GTK_get_main_window_object
+                      ("main_window_search_namespace_combobox"));
+  text = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget))));
+  ret = GNUNET_NAMESTORE_zkey_to_pkey (text, &pkey);
+  if (GNUNET_OK != ret)
+  {
+    GNUNET_break (0);
+    return;
+  }
+  lctx = GNUNET_new (struct PseuLookupContext);
+  lctx->main_ctx = main_ctx;
+  GNUNET_CONTAINER_DLL_insert (main_ctx->lctx_head,
+                              main_ctx->lctx_tail,
+                              lctx);
+  lctx->lr = GNUNET_GNS_lookup (main_ctx->gns,
+                               GNUNET_GNS_MASTERZONE_STR,
+                               &pkey,
+                               GNUNET_NAMESTORE_TYPE_PSEU,
+                               GNUNET_NO,
+                               main_ctx->sks_zone /* FIXME: may want more 
explicit
+                                                     control than using 
shortening here */,
+                               &lookup_finished,
+                               lctx);
+  /* give visual feedback that something is happening */
+  gtk_widget_set_sensitive (GTK_WIDGET (button),
+                           FALSE);
 }
 
 




reply via email to

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