[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27835 - gnunet-gtk/src/setup
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27835 - gnunet-gtk/src/setup |
Date: |
Tue, 9 Jul 2013 17:13:38 +0200 |
Author: grothoff
Date: 2013-07-09 17:13:38 +0200 (Tue, 09 Jul 2013)
New Revision: 27835
Modified:
gnunet-gtk/src/setup/gnunet-setup-gns.c
Log:
-fixing build, zone editing still broken
Modified: gnunet-gtk/src/setup/gnunet-setup-gns.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns.c 2013-07-09 14:44:36 UTC (rev
27834)
+++ gnunet-gtk/src/setup/gnunet-setup-gns.c 2013-07-09 15:13:38 UTC (rev
27835)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- (C) 2012 Christian Grothoff (and other contributing authors)
+ (C) 2012, 2013 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
@@ -171,42 +171,7 @@
};
-/**
- * Closure for 'zone_iteration_proc'.
- */
-struct ZoneIteration_Context
-{
-
- /**
- * Kept in a DLL.
- */
- struct ZoneIteration_Context *next;
-
- /**
- * Kept in a DLL.
- */
- struct ZoneIteration_Context *prev;
- /**
- * Short hash of the public key of the zone.
- */
- struct GNUNET_CRYPTO_ShortHashCode zone;
-
- /**
- * Iterator for loading the records from the zone.
- */
- struct GNUNET_NAMESTORE_ZoneIterator *it;
-
- /**
- * Context for loading/generating the zone key for this zone.
- */
- struct GNUNET_CRYPTO_RsaKeyGenerationContext *rkgc;
-
-};
-
-
-
-
/**
* Context we use for making changes to the namestore.
* (closure for 'add_new_records_after_removing_old_records').
@@ -306,16 +271,11 @@
/**
- * Head of linked list of active zone operations.
+ * Our current zone monitor.
*/
-static struct ZoneIteration_Context *zc_head;
+static struct GNUNET_NAMESTORE_ZoneMonitor *zmon;
/**
- * Tail of linked list of active zone operations.
- */
-static struct ZoneIteration_Context *zc_tail;
-
-/**
* Head of linked list of active update operations.
*/
static struct UpdateContext *uc_head;
@@ -611,6 +571,24 @@
/**
+ * Clear all entries in the zone view and hide the tree view.
+ */
+static void
+clear_zone_view ()
+{
+ gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_zone_selection_hbuttonbox")));
+ gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_status_label")));
+ gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_main_scrolledwindow")));
+ gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_image")));
+ gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_saveas_button")));
+ gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_vseparator")));
+ gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_pseu_hbox")));
+ gtk_tree_store_clear (ts);
+}
+
+
+
+/**
* Load a particular zone into the main tree view.
*
* @param zonename name of the option in the configuration file
@@ -751,9 +729,12 @@
free_update_context (uc);
return;
}
+#if 0
+ /* FIXME: what were we doing here again? */
uc->qe = GNUNET_NAMESTORE_record_create (namestore, pkey,
uc->name, &uc->rd[uc->rd_pos],
&create_more_records, uc);
+#endif
}
@@ -952,7 +933,8 @@
return;
}
- /* Store update information in context and remove old entries */
+ /* FIXME: modify entries! */
+#if 0
uc = GNUNET_malloc (sizeof (struct UpdateContext));
uc->rd = rd;
uc->rd_count = records;
@@ -971,6 +953,7 @@
free_update_context (uc);
return;
}
+#endif
}
@@ -998,47 +981,6 @@
/**
- * We tried to remove a record from the namestore, if we were
- * successful, also remove it from the model.
- *
- * @param cls the 'struct RemoveContext'
- * @param success GNUNET_SYSERR on failure (including timeout/queue
drop/failure to validate)
- * GNUNET_NO if content was already there or not found
- * GNUNET_YES (or other positive value) on success
- * @param emsg NULL on success, otherwise an error message
- */
-static void
-update_treemodel_after_remove (void *cls,
- int32_t success,
- const char *emsg)
-{
- struct RemoveContext *rc = cls;
- GtkTreeIter it;
-
- rc->qe = NULL;
- switch (success)
- {
- case GNUNET_YES:
- gtk_tree_model_get_iter_from_string(tm, &it, rc->path);
- gtk_tree_store_remove (ts, &it);
- break;
- case GNUNET_NO:
- resync_db ();
- break;
- case GNUNET_SYSERR:
- show_error_message (_("Failed to remove record"),
- emsg);
- resync_db ();
- break;
- default:
- GNUNET_break (0);
- break;
- }
- free_remove_context (rc);
-}
-
-
-/**
* Remove a record from the model (and if it is valid, also from
* the namestore). If the given path identifies an entire 'name',
* remove all records under that name.
@@ -1100,24 +1042,15 @@
g_free (n_value);
return;
}
-
- rc = GNUNET_malloc (sizeof (struct RemoveContext));
- GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc);
- rc->path = strdup (path);
- rc->qe = GNUNET_NAMESTORE_record_remove (namestore, pkey, name, &rd,
- &update_treemodel_after_remove,
rc);
+
+ /* FIXME: actually apply changes! */
GNUNET_free ((void *) rd.data);
g_free (n_name);
g_free (n_value);
}
else if (0 != strcmp (name, GNUNET_GNS_MASTERZONE_STR))
{
- /* Removing the whole name record */
- rc = GNUNET_malloc(sizeof (struct RemoveContext));
- GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc);
- rc->path = strdup (path);
- rc->qe = GNUNET_NAMESTORE_record_remove (namestore, pkey, name, NULL,
- &update_treemodel_after_remove,
rc);
+ /* FIXME: actually apply changes! */
}
g_free (name);
}
@@ -1248,10 +1181,13 @@
rd.flags |= GNUNET_NAMESTORE_RF_SHADOW_RECORD;
rd.data_size = data_size;
rd.data = data;
+#if 0
+ /* FIXME: actually apply changes! */
edc->qe = GNUNET_NAMESTORE_record_create (namestore, pk,
edc->n_new_name,
&rd,
&record_move_finish, edc);
+#endif
}
@@ -1923,9 +1859,12 @@
rd.data = pseu;
pc = GNUNET_malloc (sizeof (struct PseuContext));
GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc);
+#if 0
+ /* FIXME: actually apply changes! */
pc->qe = GNUNET_NAMESTORE_record_create (namestore, pkey, "+",
&rd,
&pseu_change_cont, pc);
+#endif
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"New Pseudonym is `%s' %u\n",
(char *) rd.data, rd.data_size);
@@ -1941,9 +1880,12 @@
rd.data = current_pseudonym;
pc = GNUNET_malloc (sizeof (struct PseuContext));
GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc);
+#if 0
+ /* FIXME: actually apply changes! */
pc->qe = GNUNET_NAMESTORE_record_remove (namestore, pkey, "+",
&rd,
&pseu_change_cont, pc);
+#endif
gtk_entry_set_text (GTK_ENTRY(editable), "");
GNUNET_free_non_null (current_pseudonym);
current_pseudonym = NULL;
@@ -1975,11 +1917,45 @@
/**
+ * Function called once our model should be consistent with
+ * the current zone. Makes the view visible.
+ *
+ * @param cls NULL
+ */
+static void
+zone_sync_proc (void *cls)
+{
+ GtkEntry *pseu_entry;
+
+ pseu_entry = GTK_ENTRY((GNUNET_SETUP_get_object
("GNUNET_setup_gns_pseu_entry")));
+ if (0 == strcmp (current_zone_option, "ZONEKEY"))
+ gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_pseu_hbox")));
+ GNUNET_setup_gns_pseu_entry_changed_cb (GTK_EDITABLE (pseu_entry),
+ NULL);
+#if HAVE_QRENCODE_H
+ setup_qrcode ();
+ gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_image")));
+ gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_saveas_button")));
+ gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_vseparator")));
+#else
+ gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_image")));
+ gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_saveas_button")));
+ gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_vseparator")));
+#endif
+ gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_status_label")));
+ gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_main_scrolledwindow")));
+ gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_zone_selection_hbuttonbox")));
+}
+
+
+/**
* Function called for each record in the current zone. Update the
- * widgets accordingly. Once the zone iteration is done, unfreeze
- * the editing functions.
+ * widgets accordingly.
*
- * @param cls the 'strucct ZoneIteration_Context'
+ * FIXME: we need to UPDATE records if an existing record is changed,
+ * not merely append!
+ *
+ * @param NULL
* @param zone_key public key of the zone
* @param freshness when does the corresponding block in the DHT expire (until
* when should we never do a DHT lookup for the same name
again)?;
@@ -1989,60 +1965,33 @@
* @param name name that is being mapped (at most 255 characters long)
* @param rd_count number of entries in 'rd' array
* @param rd array of records with data to store
- * @param signature signature of the record block, NULL if signature is
unavailable (i.e.
- * because the user queried for a particular record type only)
+ * @param signature signature of the record block, NULL as we are monitoring
*/
static void
zone_iteration_proc (void *cls,
- const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
*zone_key,
+ const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded
*zone_key,
struct GNUNET_TIME_Absolute expire,
const char *name,
unsigned int rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd,
- const struct GNUNET_CRYPTO_RsaSignature *signature)
+ const struct GNUNET_CRYPTO_EccSignature *signature)
{
- struct ZoneIteration_Context * zc_ctx = cls;
GtkTreeIter iter_name;
GtkTreeIter iter_record;
- GtkEntry *pseu_entry;
int c;
- struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc;
const char *exp;
char *val;
char *type_str;
gboolean time_is_relative;
gboolean public;
guint64 exp_t;
+ struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc;
+ GtkEntry *pseu_entry;
- GNUNET_assert (NULL != zc_ctx);
if ((NULL == zone_key) && (NULL == name))
{
- GNUNET_CRYPTO_short_hash_to_enc (&zc_ctx->zone, &shenc);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Zone `%s 'iteration done\n",
- &shenc);
- pseu_entry = GTK_ENTRY((GNUNET_SETUP_get_object
("GNUNET_setup_gns_pseu_entry")));
- if (0 == strcmp (current_zone_option, "ZONEKEY"))
- gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_pseu_hbox")));
- GNUNET_setup_gns_pseu_entry_changed_cb (GTK_EDITABLE (pseu_entry),
- NULL);
- GNUNET_CONTAINER_DLL_remove (zc_head,
- zc_tail,
- zc_ctx);
- GNUNET_free (zc_ctx);
-#if HAVE_QRENCODE_H
- setup_qrcode ();
- gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_image")));
- gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_saveas_button")));
- gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_vseparator")));
-#else
- gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_image")));
- gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_saveas_button")));
- gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_vseparator")));
-#endif
- gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_status_label")));
- gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_main_scrolledwindow")));
- gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_zone_selection_hbuttonbox")));
+ /* disconnect from namestore, clear view */
+ clear_zone_view ();
return;
}
if ( (GNUNET_SYSERR == GNUNET_DNSPARSER_check_label (name)) &&
@@ -2052,10 +2001,9 @@
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Got invalid record name `%s' from namestore\n"),
name);
- GNUNET_NAMESTORE_zone_iterator_next (zc_ctx->it);
return;
}
- GNUNET_CRYPTO_short_hash_to_enc (&zc_ctx->zone, &shenc);
+ GNUNET_CRYPTO_short_hash_to_enc (&zone, &shenc);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Zone `%s' iteration result `%s', %u records\n",
&shenc, name, rd_count);
@@ -2137,41 +2085,59 @@
GNUNET_free (type_str);
GNUNET_free (val);
}
- GNUNET_NAMESTORE_zone_iterator_next (zc_ctx->it);
}
/**
- * Function called upon completion of 'GNUNET_CRYPTO_rsa_key_create_async'.
- * Displays an error message upon failure, otherwise beings loading the
- * zone's information from the namestore.
+ * Load a particular zone into the main tree view.
*
- * @param cls closure
- * @param pk NULL on error, otherwise the private key (which must be free'd by
the callee)
- * @param emsg NULL on success, otherwise an error message
+ * @param zonename name of the option in the configuration file
+ * with the name of the file with the private key of the
+ * zone to load
*/
static void
-zone_key_loaded_callback (void *cls,
- struct GNUNET_CRYPTO_RsaPrivateKey *pk,
- const char *emsg)
+load_zone (const char *zonename)
{
- struct ZoneIteration_Context *zc_ctx = cls;
+ char *keyfile;
+ struct GNUNET_CRYPTO_RsaPrivateKey *pk;
+ char *emsg;
struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc;
char *label;
GtkTreeIter toplevel;
- zc_ctx->rkgc = NULL;
- if (NULL == pk)
+ /* clear previous zone */
+ if (NULL != zmon)
{
- GNUNET_CONTAINER_DLL_remove (zc_head,
- zc_tail,
- zc_ctx);
- GNUNET_free (zc_ctx);
+ GNUNET_NAMESTORE_zone_monitor_stop (zmon);
+ zmon = NULL;
+ }
+ clear_zone_view ();
+ current_zone_option = zonename;
+
+ /* setup crypto keys */
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+ "gns",
+ zonename,
+ &keyfile))
+ {
+ GNUNET_asprintf (&emsg,
+ _("Option `%s' missing in section `%s'\n"),
+ zonename, "gns");
show_error_message (_("Failed to load zone"),
- gettext(emsg));
+ emsg);
+ GNUNET_free (emsg);
gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_zone_selection_hbuttonbox")));
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using `%s'\n", keyfile);
+ pk = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ GNUNET_free (keyfile);
+ if (NULL == pk)
+ {
+ show_error_message (_("Failed to load zone"), NULL);
+ gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_zone_selection_hbuttonbox")));
+ return;
+ }
pkey = pk;
GNUNET_CRYPTO_rsa_key_get_public (pkey, &pubkey);
GNUNET_CRYPTO_short_hash (&pubkey,
@@ -2195,89 +2161,14 @@
GNS_TREESTORE_COL_TYPE_IS_EDITABLE, TRUE,
-1);
/* Load zone from namestore! */
- zc_ctx->zone = zone;
- zc_ctx->it = GNUNET_NAMESTORE_zone_iteration_start (namestore, &zone,
-
GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION,
- GNUNET_NAMESTORE_RF_NONE,
- &zone_iteration_proc,
- zc_ctx);
+ zmon = GNUNET_NAMESTORE_zone_monitor_start (cfg, &zone,
+ &zone_iteration_proc,
+ &zone_sync_proc,
+ NULL);
}
/**
- * Stop a zone iteration.
- *
- * @param zc_ctx zone iteration to stop.
- */
-static void
-abort_zone_iteration (struct ZoneIteration_Context *zc_ctx)
-{
- if (NULL != zc_ctx->rkgc)
- GNUNET_CRYPTO_rsa_key_create_stop (zc_ctx->rkgc);
- if (NULL != zc_ctx->it)
- GNUNET_NAMESTORE_zone_iteration_stop (zc_ctx->it);
- GNUNET_CONTAINER_DLL_remove (zc_head,
- zc_tail,
- zc_ctx);
- GNUNET_free (zc_ctx);
-}
-
-
-/**
- * Load a particular zone into the main tree view.
- *
- * @param zonename name of the option in the configuration file
- * with the name of the file with the private key of the
- * zone to load
- */
-static void
-load_zone (const char *zonename)
-{
- char *keyfile;
- struct ZoneIteration_Context *zc_ctx;
- char *emsg;
-
- /* clear previous zone */
- current_zone_option = zonename;
- gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_zone_selection_hbuttonbox")));
- gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_status_label")));
- gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_main_scrolledwindow")));
- gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_image")));
- gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_saveas_button")));
- gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_qr_vseparator")));
- gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_pseu_hbox")));
- gtk_tree_store_clear (ts);
-
- /* setup crypto keys */
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
- "gns",
- zonename,
- &keyfile))
- {
- GNUNET_asprintf (&emsg,
- _("Option `%s' missing in section `%s'\n"),
- zonename, "gns");
- show_error_message (_("Failed to load zone"),
- emsg);
- GNUNET_free (emsg);
- gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_zone_selection_hbuttonbox")));
- return;
- }
- while (NULL != (zc_ctx = zc_head))
- abort_zone_iteration (zc_head);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using `%s'\n", keyfile);
- zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context));
- GNUNET_CONTAINER_DLL_insert (zc_head,
- zc_tail,
- zc_ctx);
- zc_ctx->rkgc = GNUNET_CRYPTO_rsa_key_create_start (keyfile,
- &zone_key_loaded_callback,
- zc_ctx);
- GNUNET_free (keyfile);
-}
-
-
-/**
* A different zone was selected in the zone toggle bar. Load the
* appropriate zone.
*
@@ -2363,8 +2254,11 @@
gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_status_label")));
gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_main_scrolledwindow")));
gtk_tree_store_clear (ts);
- while (NULL != zc_head)
- abort_zone_iteration (zc_head);
+ if (NULL != zmon)
+ {
+ GNUNET_NAMESTORE_zone_monitor_stop (zmon);
+ zmon = NULL;
+ }
while (NULL != uc_head)
free_update_context (uc_head);
while (NULL != rc_head)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27835 - gnunet-gtk/src/setup,
gnunet <=