gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r20498 - gnunet-gtk/src/gns


From: gnunet
Subject: [GNUnet-SVN] r20498 - gnunet-gtk/src/gns
Date: Wed, 14 Mar 2012 16:28:46 +0100

Author: wachs
Date: 2012-03-14 16:28:46 +0100 (Wed, 14 Mar 2012)
New Revision: 20498

Modified:
   gnunet-gtk/src/gns/gnunet-gns-gtk.c
   gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c
Log:
- adding gns context


Modified: gnunet-gtk/src/gns/gnunet-gns-gtk.c
===================================================================
--- gnunet-gtk/src/gns/gnunet-gns-gtk.c 2012-03-14 15:07:04 UTC (rev 20497)
+++ gnunet-gtk/src/gns/gnunet-gns-gtk.c 2012-03-14 15:28:46 UTC (rev 20498)
@@ -46,11 +46,8 @@
  */
 static struct GNUNET_CRYPTO_RsaPrivateKey *zone_pkey;
 
-/**
- * Handle to the namestore.
- */
-static struct GNUNET_NAMESTORE_Handle *ns;
 
+
 /**
  * Name of our zone as a string.
  */
@@ -63,6 +60,19 @@
 
 static GtkWidget *main_window;
 
+struct GNUNET_GNS_Context
+{
+  /**
+   * Handle to the namestore.
+   */
+  struct GNUNET_NAMESTORE_Handle *ns;
+
+  GtkBuilder builder;
+
+
+};
+
+
 /**
  * Get cfg.
  */
@@ -235,10 +245,12 @@
 static void
 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  if (NULL != ns)
+  struct GNUNET_GNS_Context *gns = cls;
+  GNUNET_assert (gns != NULL);
+  if (NULL != gns->ns)
   {
-    GNUNET_NAMESTORE_disconnect (ns, GNUNET_NO);
-    ns = NULL;
+    GNUNET_NAMESTORE_disconnect (gns->ns, GNUNET_NO);
+    gns->ns = NULL;
   }
   if (NULL != zone_pkey)
   {
@@ -250,6 +262,7 @@
     GNUNET_free (zonekey_directory);
     zonekey_directory = NULL;
   }
+  GNUNET_free (gns);
 }
 
 
@@ -265,7 +278,7 @@
 {
   GNUNET_GTK_tray_icon_destroy ();
   GNUNET_GTK_main_loop_quit (ml);
-  GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+  GNUNET_SCHEDULER_add_now (&shutdown_task, user_data);
 }
 
 
@@ -283,10 +296,35 @@
 {
   GNUNET_GTK_tray_icon_destroy ();
   GNUNET_GTK_main_loop_quit (ml);
-  GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+  GNUNET_SCHEDULER_add_now (&shutdown_task, user_data);
 }
 
+struct ZoneIteration_Context
+{
+  GNUNET_HashCode zone;
+  struct GNUNET_NAMESTORE_ZoneIterator * it;
+};
 
+void zone_iteration_proc (void *cls,
+                          const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 
*zone_key,
+                          struct GNUNET_TIME_Absolute expire,
+                          const char *name,
+                          unsigned int rd_len,
+                          const struct GNUNET_NAMESTORE_RecordData *rd,
+                          const struct GNUNET_CRYPTO_RsaSignature *signature)
+{
+  struct ZoneIteration_Context * zc_ctx = cls;
+  GNUNET_assert (zc_ctx != NULL);
+  if ((NULL == zone_key) && (NULL == name))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Zone iteration done\n");
+    return;
+  }
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Zone iteration dummy\n");
+}
+
+
+
 /**
  * Actual main function run right after GNUnet's scheduler
  * is initialized.  Initializes up GTK and Glade.
@@ -298,7 +336,7 @@
 run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
-
+  struct GNUNET_GNS_Context *gns = GNUNET_malloc (sizeof (struct 
GNUNET_GNS_Context));
   char *keyfile;
   char *label;
 
@@ -333,22 +371,30 @@
                _("Failed to read or create private zone key\n"));
     return;
   }
-  GNUNET_CRYPTO_rsa_key_get_public (zone_pkey,
-                                   &pub);
+  GNUNET_CRYPTO_rsa_key_get_public (zone_pkey, &pub);
   GNUNET_CRYPTO_hash (&pub, sizeof (pub), &zone);
 
-  ns = GNUNET_NAMESTORE_connect (get_configuration ());
-  if (NULL == ns)
+  gns->ns = GNUNET_NAMESTORE_connect (get_configuration ());
+  if (NULL == gns->ns)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                _("Failed to connect to namestore\n"));
-    GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+    GNUNET_SCHEDULER_add_now (&shutdown_task, gns);
     return;
   }
-  if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL))
+
+  struct ZoneIteration_Context * zc_ctx = GNUNET_malloc (sizeof (struct 
ZoneIteration_Context));
+  zc_ctx->zone = zone;
+  GNUNET_NAMESTORE_zone_iteration_start(gns->ns, &zone,
+      GNUNET_NAMESTORE_RF_NONE,
+      GNUNET_NAMESTORE_RF_NONE,
+      &zone_iteration_proc,
+      zc_ctx);
+
+  if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, gns))
   {
     GNUNET_break (0);
-    GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+    GNUNET_SCHEDULER_add_now (&shutdown_task, gns);
     return;
   }
   zone_as_string = GNUNET_strdup (GNUNET_h2s_full (&zone));

Modified: gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c
===================================================================
--- gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c    2012-03-14 15:07:04 UTC (rev 
20497)
+++ gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c    2012-03-14 15:28:46 UTC (rev 
20498)
@@ -24,10 +24,10 @@
  * @brief everything releated to the zone tree view
  */
 #include "gnunet_gtk.h"
+#include "gnunet-gns-gtk.h"
 
 
 
-
 /**
  * The user has selected a new record type.  Update the
  * model, possibly invalidating (marking 'red') the existing
@@ -150,8 +150,21 @@
 void
 GNUNET_GNS_GTK_main_treeview_realize_cb (GtkWidget *widget,
                                         gpointer user_data)
-{  
-  GNUNET_break (0); // FIXME, not implemented
+{
+  /*
+  struct GNUNET_GNS_Context *gns=user_data;
+  GtkBuilder *builder = gns->builder;
+  GNUNET_assert (GTK_IS_BUILDER(user_data));
+
+  GtkTreeModel * tm;
+  tm  = GTK_TREE_MODEL(gtk_builder_get_object (builder, 
"GNUNET_GNS_GTK_treestore"));
+  GNUNET_assert (tm != NULL);
+
+  //gtk_tree
+*/
+  GNUNET_break (0);
+
+
 }
 
 




reply via email to

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