[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24580 - gnunet-gtk/src/setup
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24580 - gnunet-gtk/src/setup |
Date: |
Sun, 28 Oct 2012 17:46:27 +0100 |
Author: grothoff
Date: 2012-10-28 17:46:27 +0100 (Sun, 28 Oct 2012)
New Revision: 24580
Modified:
gnunet-gtk/src/setup/gnunet-setup-gns.c
Log:
-actually do support asynchronous zone key generation (2490)
Modified: gnunet-gtk/src/setup/gnunet-setup-gns.c
===================================================================
--- gnunet-gtk/src/setup/gnunet-setup-gns.c 2012-10-28 16:45:40 UTC (rev
24579)
+++ gnunet-gtk/src/setup/gnunet-setup-gns.c 2012-10-28 16:46:27 UTC (rev
24580)
@@ -56,11 +56,6 @@
#define EXPIRE_INVALID_STRING gettext_noop ("invalid")
/**
- * Text we use for values that have not been set.
- */
-#define PSEU_EMPTY_STR gettext_noop ("<not set>")
-
-/**
* Height and width of the QR code we display
*/
#define QRCODE_IMAGE_SIZE 64
@@ -169,6 +164,54 @@
/**
+ * 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;
+
+ /**
+ * Name of the zone (pseudonym). FIXME: rename...
+ */
+ char *label;
+};
+
+
+/**
+ * Head of linked list of active zone operations.
+ */
+static struct ZoneIteration_Context *zc_head;
+
+/**
+ * Tail of linked list of active zone operations.
+ */
+static struct ZoneIteration_Context *zc_tail;
+
+/**
* Name of our zone as a string.
*/
static char *zone_as_string;
@@ -194,24 +237,24 @@
static GtkTreeView *tv;
/**
- * FIXME: not good for multi-zone system we have right now...
+ * Private key of the zone we are currently editing.
*/
static struct GNUNET_CRYPTO_RsaPrivateKey *pkey;
/**
- * FIXME: not good for multi-zone system we have right now...
+ * Public key of the zone we are currently editing.
*/
static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
/**
- * FIXME: not good for multi-zone system we have right now...
+ * Short hash of the public key of the zone we are currently editing.
*/
static struct GNUNET_CRYPTO_ShortHashCode zone;
/**
- * FIXME...
+ * Pseudonym of the current zone we are editing.
*/
-static int iteration;
+static char *current_pseudonym;
#if HAVE_QRENCODE_H
@@ -551,7 +594,6 @@
entry = GTK_ENTRY (GNUNET_SETUP_get_object
("GNUNET_setup_gns_pseu_entry"));
pseu = gtk_entry_get_text (GTK_ENTRY(entry));
if ( (NULL == pseu) ||
- (0 == strcmp (PSEU_EMPTY_STR, pseu)) ||
(0 == strcmp ("", pseu)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -684,7 +726,7 @@
{
/* Removing a single record */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Removing single record for name `%s'\n", name);
+ "Removing single record for name `%s'\n", name);
gtk_tree_model_get(tm, &it,
GNS_TREESTORE_COL_NAME, &n_name,
@@ -1021,6 +1063,16 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New text for `%s' is `%s'\n", path,
new_text);
if ((0 == strcmp (new_text, NEW_NAME_STR)) || (0 == strcmp (new_text, "")))
return;
+ if (GNUNET_OK !=
+ GNUNET_NAMESTORE_check_name (new_text))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Name `%s' invalid for GADS/DNS (too long for a DNS
label?)\n"),
+ new_text);
+ gdk_beep ();
+ return;
+ }
+
gtk_tree_model_get_iter_from_string(tm, &it, path);
gtk_tree_model_get(tm, &it,
@@ -1432,7 +1484,7 @@
*/
gboolean
GNUNET_setup_gns_main_treeview_key_press_event_cb (GtkWidget *widget,
- GdkEventKey *event,
+ GdkEventKey *event,
gpointer user_data)
{
/* Check for delete key */
@@ -1527,32 +1579,138 @@
/**
- * Closure for 'zone_iteration_proc'.
+ *
*/
-struct ZoneIteration_Context
+static void
+pseu_change_cont (void *cls,
+ int32_t success,
+ const char *emsg)
{
+ GtkWidget *dialog;
- /**
- *
- */
- struct GNUNET_CRYPTO_ShortHashCode zone;
+ if (GNUNET_SYSERR == success)
+ {
+ GtkWindow *main_window;
+
+ main_window = GTK_WINDOW (GNUNET_SETUP_get_object ("GNUNET_setup_dialog"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("New Pseudonym could not be set:
`%s'\n"), emsg);
+ dialog = gtk_message_dialog_new (main_window,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("New Pseudonym could not be set:
`%s'\n"),
+ emsg);
+ g_signal_connect_swapped (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy),
+ dialog);
+ gtk_widget_show_all (dialog);
+ }
+}
- /**
- *
- */
- struct GNUNET_NAMESTORE_ZoneIterator * it;
- /**
- *
- */
- char *label;
-};
+/**
+ * The user edited the preferred name (PSEU) of this namespace.
+ * Push the update to the namestore.
+ *
+ * @param editable the edited widget
+ * @param user_data unused
+ */
+void
+GNUNET_setup_gns_pseu_entry_changed_cb (GtkEditable *editable,
+ gpointer user_data)
+{
+ struct GNUNET_NAMESTORE_RecordData rd;
+ const gchar *pseu;
+ pseu = gtk_entry_get_text (GTK_ENTRY (editable));
+ if (GNUNET_OK !=
+ GNUNET_NAMESTORE_check_name (pseu))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Name `%s' invalid for GADS/DNS (too long for a DNS
label?)\n"),
+ pseu);
+ gdk_beep ();
+ gtk_entry_set_text (GTK_ENTRY (editable),
+ current_pseudonym);
+ return;
+ }
+ if ( (pseu != NULL) &&
+ (0 != strcmp ("", pseu)) )
+ {
+ rd.record_type = GNUNET_NAMESTORE_TYPE_PSEU;
+ rd.expiration_time = UINT64_MAX;
+ rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
+ rd.data_size = strlen (pseu) + 1;
+ rd.data = pseu;
+ // FIXME: need to keep 'struct GNUNET_NAMESTORE_QueueEntry' around (to
cancel on disconnect...)
+ GNUNET_NAMESTORE_record_create (namestore, pkey, "+",
+ &rd,
+ &pseu_change_cont, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "New Pseudonym is `%s' %u\n",
+ (char *) rd.data, rd.data_size);
+ GNUNET_free_non_null (current_pseudonym);
+ current_pseudonym = GNUNET_strdup (pseu);
+ }
+ else if (NULL != current_pseudonym)
+ {
+ rd.record_type = GNUNET_NAMESTORE_TYPE_PSEU;
+ rd.expiration_time = UINT64_MAX;
+ rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
+ rd.data_size = strlen (current_pseudonym) + 1;
+ rd.data = current_pseudonym;
+ // FIXME: need to keep 'struct GNUNET_NAMESTORE_QueueEntry' around (to
cancel on disconnect...)
+ GNUNET_NAMESTORE_record_remove (namestore, pkey, "+",
+ &rd,
+ &pseu_change_cont, NULL);
+ gtk_entry_set_text (GTK_ENTRY(editable), "");
+ GNUNET_free_non_null (current_pseudonym);
+ current_pseudonym = NULL;
+ }
+#if HAVE_QRENCODE_H
+ setup_qrcode ();
+#endif
+}
/**
+ * The user clicked on the 'copy' button. Copy the full string
+ * with the hash of our public key to the clipboard.
*
+ * @param button the button that was clicked
+ * @param user_data unused
*/
+void
+GNUNET_setup_gns_public_key_copy_button_clicked_cb (GtkButton *button,
+ gpointer user_data)
+{
+ GtkClipboard *cb;
+
+ if (NULL == zone_as_string)
+ return;
+ cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+ gtk_clipboard_set_text (cb, zone_as_string, -1);
+}
+
+
+/**
+ * Function called for each record in the current zone. Update the
+ * widgets accordingly. Once the zone iteration is done, unfreeze
+ * the editing functions.
+ *
+ * @param cls the 'strucct ZoneIteration_Context'
+ * @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)?;
+ * GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type
in the namestore,
+ * or the expiration time of the block in the namestore (even if
there are zero
+ * records matching the desired record type)
+ * @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)
+ */
static void
zone_iteration_proc (void *cls,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
*zone_key,
@@ -1570,7 +1728,7 @@
struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc;
const char *exp;
char *val;
- char * type_str;
+ char *type_str;
gboolean time_is_relative;
gboolean public;
guint64 exp_t;
@@ -1579,13 +1737,21 @@
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);
+ 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 (NULL == zc_ctx->label)
- zc_ctx->label = GNUNET_strdup (gettext (PSEU_EMPTY_STR));
+ zc_ctx->label = GNUNET_strdup (gettext (""));
gtk_entry_set_text (pseu_entry, zc_ctx->label);
- iteration = GNUNET_NO;
- GNUNET_free (zc_ctx->label);
+ gtk_widget_show (GTK_WIDGET (pseu_entry));
+ GNUNET_free_non_null (current_pseudonym);
+ current_pseudonym = zc_ctx->label;
+ 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 ();
@@ -1599,12 +1765,14 @@
#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")));
return;
}
GNUNET_CRYPTO_short_hash_to_enc (&zc_ctx->zone, &shenc);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone `%s' iteration result `%s', %u
records\n",
- &shenc, name, rd_count);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Zone `%s' iteration result `%s', %u records\n",
+ &shenc, name, rd_count);
gtk_tree_store_append (ts, &iter_name, NULL);
gtk_tree_store_set (ts, &iter_name,
GNS_TREESTORE_COL_NAME, name,
@@ -1624,8 +1792,10 @@
/* Append elements for records */
for (c = 0; c < rd_count; c ++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Record %u: type %u flags %u
expiration %llu data_size %u\n",
- c, rd[c].record_type, rd[c].flags, rd[c].expiration_time,
rd[c].data_size);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Record %u: type %u flags %u expiration %llu data_size %u\n",
+ c, rd[c].record_type, rd[c].flags,
+ rd[c].expiration_time, rd[c].data_size);
/* Set public toggle */
public = ((rd[c].flags & GNUNET_NAMESTORE_RF_PRIVATE) !=
GNUNET_NAMESTORE_RF_PRIVATE);
@@ -1654,15 +1824,16 @@
if (NULL == val)
GNUNET_asprintf (&val, "%s", EXPIRE_INVALID_STRING);
- if (NULL != GNUNET_NAMESTORE_number_to_typename(rd[c].record_type))
- type_str = strdup
(GNUNET_NAMESTORE_number_to_typename(rd[c].record_type));
+ if (NULL != GNUNET_NAMESTORE_number_to_typename (rd[c].record_type))
+ type_str = strdup (GNUNET_NAMESTORE_number_to_typename
(rd[c].record_type));
else
GNUNET_asprintf(&type_str, "%s", EXPIRE_INVALID_STRING);
- if ((0 == strcmp (name, ROOT_STR)) && (GNUNET_NAMESTORE_TYPE_PSEU ==
rd[c].record_type))
+ if ( (0 == strcmp (name, ROOT_STR)) &&
+ (GNUNET_NAMESTORE_TYPE_PSEU == rd[c].record_type) )
{
- zc_ctx->label = strdup(val);
- iteration = GNUNET_YES;
+ GNUNET_free_non_null (zc_ctx->label);
+ zc_ctx->label = strdup (val);
}
else
{
@@ -1689,86 +1860,65 @@
/**
+ * 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.
*
+ * @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
*/
-static void
-pseu_change_cont (void *cls,
- int32_t success,
- const char *emsg)
+static void
+zone_key_loaded_callback (void *cls,
+ struct GNUNET_CRYPTO_RsaPrivateKey *pk,
+ const char *emsg)
{
- GtkWidget *dialog;
- if (GNUNET_SYSERR == success)
- {
- GtkWindow *main_window;
-
- main_window = GTK_WINDOW (GNUNET_SETUP_get_object ("GNUNET_setup_dialog"));
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("New Pseudonym could not be set:
`%s'\n"), emsg);
- dialog = gtk_message_dialog_new (main_window,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("New Pseudonym could not be set:
`%s'\n"),
- emsg);
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
- dialog);
- gtk_widget_show_all (dialog);
- }
-}
+ struct ZoneIteration_Context *zc_ctx = cls;
+ struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc;
+ char *label;
+ GtkTreeIter toplevel;
-
-/**
- * The user edited the preferred name (PSEU) of this namespace.
- * Push the update to the namestore.
- *
- * @param editable the edited widget
- * @param user_data unused
- */
-void
-GNUNET_setup_gns_pseu_entry_changed_cb (GtkEditable *editable,
- gpointer user_data)
-{
- struct GNUNET_NAMESTORE_RecordData rd;
- const gchar * pseu;
-
- pseu = gtk_entry_get_text (GTK_ENTRY(editable));
- if ((pseu != NULL) && (0 != strcmp (pseu, PSEU_EMPTY_STR)) && (0 != strcmp
("", pseu)) && (GNUNET_NO == iteration))
+ zc_ctx->rkgc = NULL;
+ if (NULL == pk)
{
-
- rd.record_type = GNUNET_NAMESTORE_TYPE_PSEU;
- rd.expiration_time = UINT64_MAX;
- rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY;
- rd.data_size = strlen (pseu) + 1;
- rd.data = strdup (pseu);
- // FIXME: need to keep 'struct GNUNET_NAMESTORE_QueueEntry' around (to
cancel on disconnect...)
- GNUNET_NAMESTORE_record_create (namestore, pkey, "+", &rd,
&pseu_change_cont, NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New Pseudonym is `%s' %u\n", (char
*) rd.data, rd.data_size);
+ GNUNET_CONTAINER_DLL_remove (zc_head,
+ zc_tail,
+ zc_ctx);
+ GNUNET_free_non_null (zc_ctx->label);
+ GNUNET_free (zc_ctx);
+ show_error_message (_("Failed to load zone"),
+ gettext(emsg));
+ gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object
("GNUNET_setup_gns_zone_selection_hbuttonbox")));
+ return;
}
- else if ((0 != strcmp (pseu, PSEU_EMPTY_STR)) && ((pseu == NULL) || (0 ==
strcmp ("", pseu))))
- {
- gtk_entry_set_text (GTK_ENTRY(editable), PSEU_EMPTY_STR);
- }
-#if HAVE_QRENCODE_H
- setup_qrcode ();
-#endif
-}
+ pkey = pk;
+ GNUNET_CRYPTO_rsa_key_get_public (pkey, &pubkey);
+ GNUNET_CRYPTO_short_hash (&pubkey,
+ sizeof (struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+ &zone);
+ GNUNET_CRYPTO_short_hash_to_enc(&zone, &shenc);
-
-/**
- * The user clicked on the 'copy' button. Copy the full string
- * with the hash of our public key to the clipboard.
- *
- * @param button the button that was clicked
- * @param user_data unused
- */
-void
-GNUNET_setup_gns_public_key_copy_button_clicked_cb (GtkButton *button,
- gpointer user_data)
-{
- GtkClipboard *cb;
-
- cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
- gtk_clipboard_set_text (cb, zone_as_string, -1);
+ zone_as_string = GNUNET_strdup ((char *) &shenc);
+ label = g_markup_printf_escaped (_("<b>Editing zone %s</b>"),
+ zone_as_string);
+ gtk_label_set_markup (GTK_LABEL (GNUNET_SETUP_get_object
("GNUNET_setup_gns_zone_label")),
+ label);
+ g_free (label);
+ /* Load zone from namestore! */
+ /* Append a top level row and leave it empty */
+ gtk_tree_store_insert_with_values (ts, &toplevel, NULL, 0,
+ GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR),
+ GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE,
+ GNS_TREESTORE_COL_RECORD_TYPE,
GNUNET_DNSPARSER_TYPE_A,
+ GNS_TREESTORE_COL_IS_RECORD_ROW, FALSE,
+ GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE,
+ -1);
+ 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);
}
@@ -1778,22 +1928,24 @@
* @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
+ * @param default_pseu default pseudonym to use
*/
static void
-load_zone (const char *zonename)
+load_zone (const char *zonename,
+ const char *default_pseu)
{
- struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc;
- char *label;
char *keyfile;
struct ZoneIteration_Context *zc_ctx;
- GtkTreeIter toplevel;
+ char *emsg;
/* clear previous zone */
+ 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_entry")));
gtk_tree_store_clear (ts);
/* setup crypto keys */
@@ -1802,54 +1954,25 @@
zonename,
&keyfile))
{
- GNUNET_asprintf (&label,
+ GNUNET_asprintf (&emsg,
_("Option `%s' missing in section `%s'\n"),
zonename, "gns");
show_error_message (_("Failed to load zone"),
- label);
- GNUNET_free (label);
+ 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);
- pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
+ zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context));
+ GNUNET_CONTAINER_DLL_insert (zc_head,
+ zc_tail,
+ zc_ctx);
+ zc_ctx->label = GNUNET_strdup (default_pseu);
+ zc_ctx->rkgc = GNUNET_CRYPTO_rsa_key_create_start (keyfile,
+ &zone_key_loaded_callback,
+ zc_ctx);
GNUNET_free (keyfile);
- keyfile = NULL;
- if (NULL == pkey)
- {
- show_error_message (_("Failed to load zone"),
- _("Failed to read or create private zone key"));
- return;
- }
- GNUNET_CRYPTO_rsa_key_get_public (pkey, &pubkey);
- GNUNET_CRYPTO_short_hash (&pubkey,
- sizeof (struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
- &zone);
- GNUNET_CRYPTO_short_hash_to_enc(&zone, &shenc);
-
- zone_as_string = GNUNET_strdup ((char *) &shenc);
- label = g_markup_printf_escaped (_("<b>Editing zone %s</b>"),
- zone_as_string);
- gtk_label_set_markup (GTK_LABEL (GNUNET_SETUP_get_object
("GNUNET_setup_gns_zone_label")),
- label);
- g_free (label);
- /* Load zone from namestore! */
- /* Append a top level row and leave it empty */
- gtk_tree_store_insert_with_values (ts, &toplevel, NULL, 0,
- GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR),
- GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE,
- GNS_TREESTORE_COL_RECORD_TYPE,
GNUNET_DNSPARSER_TYPE_A,
- GNS_TREESTORE_COL_IS_RECORD_ROW, FALSE,
- GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE,
- -1);
-
- // FIXME: need to keep this handle for 'GNUNET_SETUP_gns_done' around!
- zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context));
- 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);
}
@@ -1865,7 +1988,7 @@
gpointer
user_data)
{
if (gtk_toggle_button_get_active (togglebutton))
- load_zone ("SHORTEN_ZONEKEY");
+ load_zone ("SHORTEN_ZONEKEY", _("short"));
}
@@ -1881,7 +2004,7 @@
gpointer
user_data)
{
if (gtk_toggle_button_get_active (togglebutton))
- load_zone ("PRIVATE_ZONEKEY");
+ load_zone ("PRIVATE_ZONEKEY", _("private"));
}
@@ -1897,7 +2020,7 @@
gpointer
user_data)
{
if (gtk_toggle_button_get_active (togglebutton))
- load_zone ("ZONEKEY");
+ load_zone ("ZONEKEY", "");
}
@@ -1920,10 +2043,10 @@
g_free (label);
return;
}
- ts = GTK_TREE_STORE (GNUNET_SETUP_get_object
("GNUNET_setup_gns_treestore"));
- tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object
("GNUNET_setup_gns_main_treeview"));
+ ts = GTK_TREE_STORE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_treestore"));
+ tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object
("GNUNET_setup_gns_main_treeview"));
tm = GTK_TREE_MODEL(ts);
- load_zone ("ZONEKEY");
+ load_zone ("ZONEKEY", "");
}
@@ -1934,10 +2057,23 @@
void
GNUNET_SETUP_gns_done ()
{
+ struct ZoneIteration_Context *zc_ctx;
+
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);
- // FIXME: need to abort any pending zone iteration!
+ while (NULL != (zc_ctx = zc_head))
+ {
+ 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_free_non_null (zc_ctx->label);
+ GNUNET_CONTAINER_DLL_remove (zc_head,
+ zc_tail,
+ zc_ctx);
+ GNUNET_free (zc_ctx);
+ }
// FIXME: need to cancel pending record operations!
if (NULL != namestore)
{
@@ -1949,6 +2085,11 @@
GNUNET_CRYPTO_rsa_key_free (pkey);
pkey = NULL;
}
+ if (NULL != current_pseudonym)
+ {
+ GNUNET_free (current_pseudonym);
+ current_pseudonym = NULL;
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24580 - gnunet-gtk/src/setup,
gnunet <=