/* This file is part of GNUnet (C) 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/setup/gnunet-setup-gns.c * @author Christian Grothoff * @brief everything releated to the main GNS zone tree view */ #include "gnunet_gtk.h" #include "gnunet-setup-gns.h" #include #include /** * Text we use for the 'name' entry for the user to select * for creating a new name. */ #define NEW_NAME_STR gettext_noop ("") /** * Text we use for the 'type' selection for the user to * select when adding a new record. */ #define NEW_RECORD_STR gettext_noop ("") /** * Text we use for 'our own zone'. FIXME: define as constant in GNS? */ #define ROOT_STR "+" /** * Text we use for the expiration to mean 'never expires'. */ #define EXPIRE_NEVER_STRING gettext_noop ("never") /** * Text we use for invalid values. */ #define EXPIRE_INVALID_STRING gettext_noop ("invalid") /** * Text we use for values that have not been set. */ #define PSEU_EMPTY_STR gettext_noop ("") /** * Columns in the gns model. */ enum GNSTreestoreColumn { /** * A gchararray with the value for the 'name' column. */ GNS_TREESTORE_COL_NAME = 0, /** * A gboolean, TRUE if the record is public, FALSE if it is private. */ GNS_TREESTORE_COL_IS_PUBLIC, /** * A guint with the record type (numeric value) */ GNS_TREESTORE_COL_RECORD_TYPE, /** * A gchararray with the record type (human-readable string) */ GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, /** * A guint64 with the expiration time (relative or absolute) */ GNS_TREESTORE_COL_EXP_TIME, /** * A gboolean, TRUE if the expiration time is relative. */ GNS_TREESTORE_COL_EXP_TIME_IS_REL, /** * A gchararray with the expiration time as a human-readable string. */ GNS_TREESTORE_COL_EXP_TIME_AS_STR, /** * A gchararray with the value of the record as a human-readable string. */ GNS_TREESTORE_COL_VAL_AS_STR, /** * A gchararray with the background color to use for the value. */ GNS_TREESTORE_COL_VAL_COLOR, /** * A gboolean; TRUE if the 'name' column should be shown, * FALSE for the lines with the individual records under a name. */ GNS_TREESTORE_COL_NAME_IS_VISIBLE, /** * A gboolean, TRUE if this row is for editing a record, * FALSE if the 'public', 'type', 'expiration' and 'value' * columns should be hidden. */ GNS_TREESTORE_COL_IS_RECORD_ROW, /** * A gboolean, FALSE if this is one of our 'dummy' rows that * is used to create a new name or record, TRUE if this is * a normal row with either a name or a record. */ GNS_TREESTORE_COL_NOT_DUMMY_ROW, /** * A gchararray with the name of the color to use for the * expiration column. */ GNS_TREESTORE_COL_EXP_TIME_COLOR, /** * A gchararray with the name of the color to use for the * name column. */ GNS_TREESTORE_COL_NAME_COLOR }; /** * Columns in the gns type model. */ enum LIST_COLUMNS { /** * A guint */ GNS_TYPE_TO_NAME_LISTSTORE_COLUMN_TYPE = 0, /** * A gchararray */ GNS_TYPE_TO_NAME_LISTSTORE_COLUMN_TYPENAME }; /** * Name of our zone as a string. */ static char *zone_as_string; /** * Default directory of zone files as a string. */ static char *zonekey_directory; /** * Handle to the namestore. */ static struct GNUNET_NAMESTORE_Handle *namestore; /** * FIXME... */ static GtkTreeStore *ts; /** * FIXME... */ static GtkListStore *ls; /** * FIXME... */ static GtkTreeModel *tm; /** * FIXME... */ static GtkTreeView *tv; /** * FIXME: not good for multi-zone system we have right now... */ static struct GNUNET_CRYPTO_RsaPrivateKey *pkey; /** * FIXME: not good for multi-zone system we have right now... */ static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; /** * FIXME: not good for multi-zone system we have right now... */ static struct GNUNET_CRYPTO_ShortHashCode zone; /** * FIXME... */ static int iteration; /** * Context we use for making changes to the namestore. * (closure for 'add_new_records_after_removing_old_records'). */ struct UpdateContext { /** * Array of records to add. */ struct GNUNET_NAMESTORE_RecordData *rd; /** * Name under which we should add the records. */ char * name; /** * Size of the 'rd' array. */ unsigned int rd_count; }; /** * Display an error message for the user. * * @param title title of the error message * @param emsg error message to show */ static void show_error_message (const char *title, const char *emsg) { GtkWindow *main_window; GtkDialog *dialog; /* FIXME: consider replacing with widget in the main window */ main_window = GTK_WINDOW (GNUNET_SETUP_get_object ("GNUNET_setup_dialog")); dialog = GTK_DIALOG(gtk_message_dialog_new (main_window, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("%s\n%s\n"), title, emsg)); g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show_all (GTK_WIDGET(dialog)); } /** * Function called after we removed the old record. If the * removal was successful, add the new records from the * update context. * * @param cls the 'struct UpdateContext' * @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 add_new_records_after_removing_old_records (void *cls, int32_t success, const char *emsg) { struct UpdateContext * uc = cls; unsigned int c; switch (success) { case GNUNET_OK: case GNUNET_NO: for (c = 0; c < uc->rd_count; c++) GNUNET_NAMESTORE_record_create (namestore, pkey, uc->name, &uc->rd[c], NULL, NULL); break; case GNUNET_SYSERR: show_error_message (_("Failed to remove record"), emsg); break; default: GNUNET_break (0); break; } for (c = 0; c < uc->rd_count; c++) GNUNET_free ((void *) uc->rd[c].data); GNUNET_free (uc->rd); GNUNET_free (uc->name); GNUNET_free (uc); } /** * Check that the data at the given 'path' (see gtk_tree_model_get_iter_from_string) * is valid and if so commit it after removing the old data. * * @param path path identifying the new record (FIXME: use GtkTreeIter instead!?) * @param oldname name of the old record, NULL if this is a fresh name */ static void check_name_validity_and_commit (const gchar *path, const char * oldname) { GtkTreeIter it; GtkTreeIter parent; /* parent record with the 'name' */ char * name; /* name of the records */ struct GNUNET_NAMESTORE_RecordData *rd; unsigned int records; /* number of records in 'rd' */ int children; /* number of records below 'parent' */ int append_pseu; /* do we need to create a '+' PSEU record? */ struct UpdateContext * uc; int c; gtk_tree_model_get_iter_from_string(tm, &it, path); if (! gtk_tree_model_iter_parent (tm, &parent, &it)) { if (NULL != oldname) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name of existing record `%s' was changed, moving associated records\n", oldname); parent = it; } gtk_tree_model_get (tm, &parent, GNS_TREESTORE_COL_NAME, &name, -1); children = gtk_tree_model_iter_n_children (tm, &parent); if (children < 1) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Changed name `%s' has no associated records, not committing to namestore\n", name); g_free (name); return; } if (0 == strcmp (name, ROOT_STR)) { /* FIXME: only if this is our 'primary' zone (not for private/shorten zones!) */ /* We have to append PSEU RECORD */ append_pseu = GNUNET_YES; records = children + 1; } else { append_pseu = GNUNET_NO; records = children; } rd = GNUNET_malloc (records * sizeof (struct GNUNET_NAMESTORE_RecordData)); GNUNET_assert (gtk_tree_model_iter_children (tm, &it, &parent)); for (c = 0; c < children; c++) { gchar *n_name; gint n_type; gboolean n_public; guint64 n_exp_time; gboolean n_is_relative; gchar *n_value; void * data; size_t data_size; gtk_tree_model_get (tm, &it, GNS_TREESTORE_COL_NAME, &n_name, GNS_TREESTORE_COL_RECORD_TYPE, &n_type, GNS_TREESTORE_COL_IS_PUBLIC, &n_public, GNS_TREESTORE_COL_EXP_TIME, &n_exp_time, GNS_TREESTORE_COL_EXP_TIME_IS_REL, &n_is_relative, GNS_TREESTORE_COL_VAL_AS_STR, &n_value, -1); if ( (NULL == n_name) || (GNUNET_SYSERR == GNUNET_NAMESTORE_check_name (n_name)) || (0 == n_type) || (0 == n_exp_time) || (NULL == n_value) || (GNUNET_OK != GNUNET_NAMESTORE_string_to_value(n_type, n_value, &data, &data_size)) ) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Invalid record, skipping\n"); records--; children--; c--; } else { if (FALSE == n_public) rd[c].flags = GNUNET_NAMESTORE_RF_AUTHORITY | GNUNET_NAMESTORE_RF_PRIVATE; else rd[c].flags = GNUNET_NAMESTORE_RF_AUTHORITY | GNUNET_NAMESTORE_RF_NONE; rd[c].record_type = n_type; rd[c].expiration_time = n_exp_time; rd[c].data_size = data_size; rd[c].data = GNUNET_malloc(data_size); memcpy ((void *) rd[c].data, data, data_size); } g_free (n_name); g_free (n_value); GNUNET_assert (gtk_tree_model_iter_next (tm, &it)); } if (GNUNET_YES == append_pseu) { GtkEntry * entry; const gchar * pseu; /* Append PSEU record */ GNUNET_assert (children == (records -1)); 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, "No zone pseudonym given, not creating PSEU record\n"); records--; } else { if (GNUNET_OK != GNUNET_NAMESTORE_string_to_value (GNUNET_NAMESTORE_TYPE_PSEU, pseu, (void **) &rd[records - 1].data, &rd[records - 1].data_size)) { show_error_message (_("Invalid pseudonym specified for zone"), pseu); records--; } else { rd[records - 1].record_type = GNUNET_NAMESTORE_TYPE_PSEU; rd[records - 1].expiration_time = UINT64_MAX; rd[records - 1].flags = GNUNET_NAMESTORE_RF_AUTHORITY | GNUNET_NAMESTORE_RF_NONE; } } } if (0 == records) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No valid records remaining, not storing to namestore\n"); GNUNET_free (rd); return; } /* Store update information in context and remove old entries */ uc = GNUNET_malloc (sizeof (struct UpdateContext)); uc->rd = rd; uc->rd_count = records; uc->name = name; GNUNET_NAMESTORE_record_remove (namestore, pkey, (NULL != oldname) ? oldname : name, NULL, &add_new_records_after_removing_old_records, uc); } /** * Closure for 'check_name_validity_and_remove_proc'. */ struct RemoveContext { /** * Path for 'gtk_tree_model_get_iter_from_string' for removing * the record from the tree view IF the operation was successful. * FIXME: replace with a 'GtkTreeIter'? */ char *path; }; /** * 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 *rcc = cls; GtkTreeIter it; switch (success) { case GNUNET_YES: case GNUNET_NO: gtk_tree_model_get_iter_from_string(tm, &it, rcc->path); gtk_tree_store_remove (ts, &it); break; case GNUNET_SYSERR: show_error_message (_("Failed to remove record"), emsg); break; default: GNUNET_break (0); break; } GNUNET_free (rcc->path); GNUNET_free (rcc); } /** * FIXME... * * @param path */ static void check_name_validity_and_remove (gchar *path) { GtkTreeIter it; GtkTreeIter parent; char *name; int valid = GNUNET_YES; struct GNUNET_NAMESTORE_RecordData rd; struct RemoveContext *rcc; char *n_name; int n_type; gboolean n_public; char *n_exp_color; guint64 n_exp_time; char *n_exp_str; gboolean n_is_relative; char *n_value; char *n_value_color; gtk_tree_model_get_iter_from_string(tm, &it, path); gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NAME, &name, -1); if (TRUE == gtk_tree_model_iter_parent (tm, &parent, &it)) { /* Removing a single record */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing single record for name `%s'\n", name); gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NAME, &n_name, GNS_TREESTORE_COL_RECORD_TYPE, &n_type, GNS_TREESTORE_COL_IS_PUBLIC, &n_public, GNS_TREESTORE_COL_EXP_TIME_COLOR, &n_exp_color, GNS_TREESTORE_COL_EXP_TIME, &n_exp_time, GNS_TREESTORE_COL_EXP_TIME_IS_REL, &n_is_relative, GNS_TREESTORE_COL_EXP_TIME_AS_STR, &n_exp_str, GNS_TREESTORE_COL_VAL_AS_STR, &n_value, GNS_TREESTORE_COL_VAL_COLOR, &n_value_color, -1); /* valid name */ if (NULL == n_name) valid = GNUNET_NO; /* valid record type */ if (0 == n_type) valid = GNUNET_NO; /* valid expiration */ if ((n_exp_color != NULL) || (NULL == n_exp_str) || (0 == n_exp_time)) valid = GNUNET_NO; /* valid value */ if ((n_value_color != NULL) || (NULL == n_value)) valid = GNUNET_NO; if (GNUNET_YES == valid) { if (FALSE == n_public) rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY | GNUNET_NAMESTORE_RF_PRIVATE; else rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY | GNUNET_NAMESTORE_RF_NONE; rd.record_type = n_type; rd.expiration_time = n_exp_time; rd.data_size = strlen (n_value) + 1; rd.data = GNUNET_malloc(rd.data_size); memcpy ((void *) rd.data, n_value, rd.data_size); rcc = GNUNET_malloc(sizeof (struct RemoveContext)); rcc->path = strdup (path); GNUNET_NAMESTORE_record_remove (namestore, pkey, name, &rd, &update_treemodel_after_remove, rcc); GNUNET_free ((void *) rd.data); } else { gtk_tree_model_get_iter_from_string(tm, &it, path); gtk_tree_store_remove (ts, &it); } g_free (n_name); g_free (n_exp_color); g_free (n_exp_str); g_free (n_value); g_free (n_value_color); } else if (0 != strcmp (name, ROOT_STR)) { /* Removing the whole name record */ rcc = GNUNET_malloc(sizeof (struct RemoveContext)); rcc->path = strdup (path); GNUNET_NAMESTORE_record_remove (namestore, pkey, name, NULL, &update_treemodel_after_remove, rcc); } g_free (name); } /** * The user has selected a new record type. Update the * model, possibly invalidating (marking 'red') the existing * value. * * @param renderer updated renderer * @param path the path identifying the edited cell * @param new_iter selected cell in the combo's model (with the record type) * @param user_data unused */ void GNUNET_setup_gns_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, gchar *path, GtkTreeIter *new_iter, gpointer user_data) { GtkTreeIter it; GtkTreeIter child; guint type; int record_row; char *type_str; char *value_str; char *name_str; void *data; size_t data_size; gtk_tree_model_get(GTK_TREE_MODEL(ls), new_iter, 0, &type, -1); gtk_tree_model_get(GTK_TREE_MODEL(ls), new_iter, GNS_TYPE_TO_NAME_LISTSTORE_COLUMN_TYPENAME, &type_str, -1); /* check if this is a new record */ gtk_tree_model_get_iter_from_string(tm, &it, path); gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_IS_RECORD_ROW, &record_row, -1); gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NAME, &name_str, -1); if (GNUNET_YES == record_row) { /* Updating an existing record */ gtk_tree_store_set(ts, &it, GNS_TREESTORE_COL_RECORD_TYPE, type, GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str, -1); } else if ((NULL != name_str) && (0 != strcmp (NEW_NAME_STR, name_str))) { /* Adding a new record */ gtk_tree_store_insert_with_values(ts, &child , &it, 0, GNS_TREESTORE_COL_NAME, name_str, GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE, GNS_TREESTORE_COL_RECORD_TYPE, type, GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str, GNS_TREESTORE_COL_EXP_TIME_AS_STR, EXPIRE_NEVER_STRING, GNS_TREESTORE_COL_EXP_TIME, GNUNET_TIME_UNIT_FOREVER_ABS, GNS_TREESTORE_COL_EXP_TIME_IS_REL, FALSE, GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE, GNS_TREESTORE_COL_NOT_DUMMY_ROW, TRUE, -1); gtk_tree_view_expand_row (tv, gtk_tree_model_get_path(tm, &it), 0); } GNUNET_free (type_str); /* check if value is still valid */ gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_VAL_AS_STR, &value_str, -1); if (NULL != value_str) { if (GNUNET_OK != GNUNET_NAMESTORE_string_to_value (type, value_str, &data, &data_size)) gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); else gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, NULL, -1); GNUNET_free (value_str); } else if (NULL == value_str) { /* Empty value field */ if (GNUNET_YES == record_row) gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); else gtk_tree_store_set (ts, &child, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); } check_name_validity_and_commit (path, NULL); GNUNET_free_non_null (name_str); } /** * The user has toggled the 'public' checkmark of a cell. Update the * model. * * @param renderer updated renderer * @param path the path identifying the edited cell * @param user_data unused */ void GNUNET_setup_gns_ispublic_cellrenderertoggle_toggled_cb (GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data) { GtkTreeIter it; gboolean value; gtk_tree_model_get_iter_from_string(tm, &it, path); gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_IS_PUBLIC, &value, -1); gtk_tree_store_set(ts, &it, GNS_TREESTORE_COL_IS_PUBLIC, !value, -1); check_name_validity_and_commit (path, NULL); } /** * FIXME: should use routines from gnunet-util (or move this to * gnunet-util if it doesn't exist there!). */ static char * convert_time_to_string (struct GNUNET_TIME_Absolute t) { time_t tt; struct tm *time; char *ret; if (t.abs_value == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value) return GNUNET_strdup (_(EXPIRE_NEVER_STRING)); if (t.abs_value == GNUNET_TIME_UNIT_ZERO_ABS.abs_value) return GNUNET_strdup (_(EXPIRE_INVALID_STRING)); tt = t.abs_value / 1000; time = localtime (&tt); GNUNET_asprintf(&ret, "%02u/%02u/%04u %02u:%02u",time->tm_mon, time->tm_mday, 1900 + time->tm_year, time->tm_hour, time->tm_min); return ret; } /** * */ static int check_time (const char * text) { unsigned int t_mon; unsigned int t_day; unsigned int t_year; unsigned int t_hrs; unsigned int t_min; int count = SSCANF (text, "%02u/%02u/%04u %02u:%02u", &t_mon, &t_day, &t_year, &t_hrs, &t_min); if ((EOF == count) || (5 != count)) { return GNUNET_SYSERR; } if (t_mon > 12) return GNUNET_SYSERR; if (t_day > 31) return GNUNET_SYSERR; if (t_hrs > 24) return GNUNET_SYSERR; if (t_min > 59) return GNUNET_SYSERR; return GNUNET_OK; } /** * */ static const struct GNUNET_TIME_Absolute convert_string_to_abs_time (const char * text) { static struct GNUNET_TIME_Absolute abs_t; struct tm time; time_t t; int t_mon; int t_day; int t_year; int t_hrs; int t_min; GNUNET_assert (NULL != text); if (0 == strcmp(text, EXPIRE_NEVER_STRING)) return GNUNET_TIME_UNIT_FOREVER_ABS; memset (&time, '\0', sizeof (struct tm)); if (GNUNET_SYSERR == check_time(text)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Invalid time `%s'\n"), text); GNUNET_break (0); return GNUNET_TIME_UNIT_ZERO_ABS; } int count = SSCANF (text, "%02d/%02d/%04d %02d:%02d", &t_mon, &t_day, &t_year, &t_hrs, &t_min); if ((EOF == count) || (5 != count)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Invalid time `%s', returning 0\n"), text); return GNUNET_TIME_UNIT_ZERO_ABS; } time.tm_mon = (t_mon - 1); time.tm_mday = t_day; time.tm_year = t_year - 1900; time.tm_hour = (t_hrs); time.tm_min = t_min; t = mktime (&time); if (-1 == t) return GNUNET_TIME_UNIT_ZERO_ABS; abs_t.abs_value = t * 1000; return abs_t; } /** * The user has edited a 'expiration' cell. Update the model. * * @param renderer updated renderer * @param path the path identifying the edited cell * @param new_text the new expiration time * @param user_data unused */ void GNUNET_setup_gns_expiration_cellrenderertext_edited_cb (GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data) { GtkTreeIter it; struct GNUNET_TIME_Absolute abstime; gboolean is_rel; char *old_text; if (NULL == new_text) return; /* can this happen? */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New expiration time: `%s'\n", new_text); gtk_tree_model_get_iter_from_string(tm, &it, path); gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_EXP_TIME_AS_STR, &old_text, GNS_TREESTORE_COL_EXP_TIME_IS_REL, &is_rel, -1); if ( (NULL != old_text) && (0 == strcmp(new_text, old_text)) ) return; if ((0 == strcmp(new_text,"")) || (0 == strcmp(new_text,EXPIRE_NEVER_STRING))) { new_text = EXPIRE_NEVER_STRING; abstime = GNUNET_TIME_UNIT_FOREVER_ABS; } else { if (GNUNET_SYSERR == check_time(new_text)) { gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_EXP_TIME_AS_STR, new_text, GNS_TREESTORE_COL_EXP_TIME_COLOR, "red", GNS_TREESTORE_COL_EXP_TIME, 0, -1); abstime = GNUNET_TIME_UNIT_ZERO_ABS; return; } /* TODO: fix this when we have relative time */ if (TRUE == is_rel) { abstime = convert_string_to_abs_time(new_text); } else { abstime = convert_string_to_abs_time(new_text); } } gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_EXP_TIME_AS_STR, new_text, GNS_TREESTORE_COL_EXP_TIME, abstime.abs_value, GNS_TREESTORE_COL_EXP_TIME_COLOR, NULL, -1); check_name_validity_and_commit (path, NULL); } /** * The user has edited a 'value' cell. Update the model, * including the status on the consistency of the value with * the type. * * @param renderer updated renderer * @param path the path identifying the edited cell * @param new_text the new value * @param user_data unused */ void GNUNET_setup_gns_value_cellrenderertext_edited_cb (GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data) { GtkTreeModel *tm = GTK_TREE_MODEL(ts); GtkTreeIter it; size_t data_size; void * data; int type; gchar * old_value; if (0 != strcmp(new_text,"")) { gtk_tree_model_get_iter_from_string(tm, &it, path); gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_RECORD_TYPE, &type, GNS_TREESTORE_COL_VAL_AS_STR, &old_value, -1); if (old_value != NULL) { if (0 == strcmp(new_text, old_value)) { GNUNET_free (old_value); return; } GNUNET_free (old_value); } if (GNUNET_OK == GNUNET_NAMESTORE_string_to_value (type, new_text, &data, &data_size)) { gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, NULL, -1); gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_AS_STR, new_text, -1); check_name_validity_and_commit (path, NULL); } else { gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_AS_STR, new_text, -1); } } } /** * The user has edited a 'name' cell. Update the model (and if needed * create another fresh line for additional records). * * @param renderer updated renderer * @param path the path identifying the edited cell * @param new_text the new name * @param user_data unused */ void GNUNET_setup_gns_name_cellrenderertext_edited_cb (GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data) { GtkTreeIter it; GtkTreeIter child; GtkTreeModel *tm = GTK_TREE_MODEL(ts); int not_dummy; char *name; 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; gtk_tree_model_get_iter_from_string(tm, &it, path); gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, -1); gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NAME, &name, -1); if (not_dummy == GNUNET_NO) { /* update name */ gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_NAME, new_text, GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE, GNS_TREESTORE_COL_RECORD_TYPE, 0, GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, _(NEW_RECORD_STR), GNS_TREESTORE_COL_NOT_DUMMY_ROW, TRUE, GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE, -1); check_name_validity_and_commit (gtk_tree_model_get_string_from_iter(tm, &it), name); /* add a new dummy line */ gtk_tree_store_insert_with_values (ts, &it,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_NOT_DUMMY_ROW, FALSE, GNS_TREESTORE_COL_IS_RECORD_ROW, FALSE, -1); } else { /* update name */ gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_NAME, new_text, -1); if (TRUE == gtk_tree_model_iter_children (tm, &child, &it)) { do { gtk_tree_store_set (ts, &child, GNS_TREESTORE_COL_NAME, &new_text, -1); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New text for `%s' is `%s'\n", path, new_text); } while (TRUE == gtk_tree_model_iter_next (tm, &child)); } check_name_validity_and_commit (gtk_tree_model_get_string_from_iter(tm, &it), name); } if (GNUNET_SYSERR == GNUNET_NAMESTORE_check_name (new_text)) { gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_NAME_COLOR, "red", -1); } else { gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_NAME_COLOR, NULL, -1); } } /** * Create a context (popup) menu for the zone iteration treeview * (if applicable). * * @return TRUE if a menu was activated */ static gboolean create_popup_menu () { GtkTreeModel *tm; GtkTreeIter it; GtkMenu *popup; GtkTreeSelection * ts; gboolean not_dummy; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Considering creating popup menu...\n"); ts = gtk_tree_view_get_selection(tv); if (! gtk_tree_selection_get_selected (ts, &tm, &it)) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No row selected\n"); return FALSE; } gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, -1); if (! not_dummy) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Dummy row selected\n"); return FALSE; } popup = GTK_MENU (GNUNET_SETUP_get_object ("GNUNET_setup_gns_delete_popup_menu")); gtk_widget_show_all (GTK_WIDGET(popup)); gtk_menu_popup(popup, NULL, NULL, NULL, NULL, 0, 0); return TRUE; } /** * The zone treeview pop up menu is supposed to be created. * (Note: this is not the only method that might need to be * written to handle events to create pop up menus; right-clicks * might need to be managed separately). * * @param widget the widget * @param user_data unused * @return TRUE if a menu was activated */ gboolean GNUNET_setup_gns_main_treeview_popup_menu_cb (GtkWidget *widget, gpointer user_data) { return create_popup_menu (); } /** * Delete the selected row from the GtkTreeView (unless it is a dummy row). */ static void delete_selected_row () { GtkTreeIter it; GtkTreeModel *tm; GtkTreeSelection * ts; int not_dummy; char *path; ts = gtk_tree_view_get_selection(tv); if (! gtk_tree_selection_get_selected (ts, &tm, &it)) return; /* nothing selected */ gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, -1); if (GNUNET_NO == not_dummy) return; /* do not delete the dummy line */ path = gtk_tree_model_get_string_from_iter (tm, &it); check_name_validity_and_remove (path); g_free (path); } /** * User selected 'delete' in the popup menu. Delete the * selected row. */ void GNUNET_setup_gns_popup_delete_button_activate_cb (GtkWidget *widget, gpointer user_data) { delete_selected_row (); } /** * Set the expiration time of the selected row to the given value. * * @param reltime relative expiration time to use */ static void set_relative_expiration_time (struct GNUNET_TIME_Relative reltime) { GtkTreeIter it; GtkTreeIter parent; GtkCellRendererText *renderer; GtkTreeModel *tm; GtkTreeSelection * ts = gtk_tree_view_get_selection(tv); gboolean has_parent; struct GNUNET_TIME_Absolute abstime; char *path; int not_dummy; if (! gtk_tree_selection_get_selected (ts, &tm, &it)) return; gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, -1); if (GNUNET_NO == not_dummy) return; /* Has parent? */ has_parent = gtk_tree_model_iter_parent (tm, &parent, &it); if (FALSE == has_parent) return; /* FIXME: should keep as relative time! */ abstime = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), reltime); /* this is a single record */ renderer = GTK_CELL_RENDERER_TEXT((GNUNET_SETUP_get_object ("GNUNET_setup_gns_name_cellrenderertext"))); path = gtk_tree_model_get_string_from_iter (tm, &it); GNUNET_setup_gns_expiration_cellrenderertext_edited_cb (renderer, path, convert_time_to_string (abstime), NULL); } /** * */ void GNUNET_setup_gns_popup_1d_exp_button_activate_cb (GtkWidget *widget, gpointer user_data) { set_relative_expiration_time (GNUNET_TIME_UNIT_DAYS); } /** * */ void GNUNET_setup_gns_popup_1w_exp_button_activate_cb (GtkWidget *widget, gpointer user_data) { set_relative_expiration_time (GNUNET_TIME_UNIT_WEEKS); } /** * */ void GNUNET_setup_gns_popup_1y_exp_button_activate_cb (GtkWidget *widget, gpointer user_data) { set_relative_expiration_time (GNUNET_TIME_UNIT_YEARS); } /** * */ void GNUNET_setup_gns_popup_forever_exp_button_activate_cb (GtkWidget *widget, gpointer user_data) { set_relative_expiration_time (GNUNET_TIME_UNIT_FOREVER_REL); } /** * A button was pressed in the GtkTreeView, check for right button and * if applicable create the popup menu. * * @param widget the GtkTreeView * @param event the event * @param user_data unused * @return TRUE if a menu was activated (event was handled) */ gboolean GNUNET_setup_gns_main_treeview_button_press_event_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { /* Check for right click*/ if (NULL == widget) return FALSE; if ( (GDK_BUTTON_PRESS == event->type) && (3 == event->button) ) return create_popup_menu (); return FALSE; } /** * User pushed a key in the GtkTreeView. Check for 'del' and if so, delete * the currently selected row. */ gboolean GNUNET_setup_gns_main_treeview_key_press_event_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { /* Check for delete key */ if ((event->type == GDK_KEY_PRESS) && (GDK_KEY_Delete == event->keyval)) { delete_selected_row (); return TRUE; } return FALSE; } /** * User clicked on 'save as' to extract the QR code. Open 'save as' * dialog to get the desired filename and file type. */ void GNUNET_setup_gns_qr_saveas_button_clicked_cb (GtkButton *button, gpointer user_data) { GNUNET_break (0); // FIXME: not implemented } /** * Closure for 'zone_iteration_proc'. */ struct ZoneIteration_Context { struct GNUNET_CRYPTO_ShortHashCode zone; struct GNUNET_NAMESTORE_ZoneIterator * it; char *label; }; /** * */ static void zone_iteration_proc (void *cls, const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *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) { struct ZoneIteration_Context * zc_ctx = cls; GtkTreeIter iter_name; GtkTreeIter iter_record; GtkEntry *pseu_entry; int c; int time_is_relative; struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; char *exp; char *val; char * type_str; int public; guint64 exp_t; 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 (NULL == zc_ctx->label) zc_ctx->label = GNUNET_strdup (gettext (PSEU_EMPTY_STR)); gtk_entry_set_text (pseu_entry, zc_ctx->label); iteration = GNUNET_NO; GNUNET_free (zc_ctx->label); GNUNET_free (zc_ctx); 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"))); 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); gtk_tree_store_append (ts, &iter_name, NULL); gtk_tree_store_set (ts, &iter_name, GNS_TREESTORE_COL_NAME, name, GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE, GNS_TREESTORE_COL_RECORD_TYPE, GNUNET_NAMESTORE_TYPE_ANY, GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, _(NEW_RECORD_STR), GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE, GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE, -1); if (GNUNET_SYSERR == GNUNET_NAMESTORE_check_name (name)) { gtk_tree_store_set (ts, &iter_name, GNS_TREESTORE_COL_NAME_COLOR, "red", -1); } /* 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); /* Set public toggle */ if ((rd[c].flags & GNUNET_NAMESTORE_RF_PRIVATE) == GNUNET_NAMESTORE_RF_PRIVATE) { public = GNUNET_NO; } else { public = GNUNET_YES; } /* Expiration time */ time_is_relative = GNUNET_NO; if (GNUNET_YES == time_is_relative) { /* TODO: FIX THIS WHEN WE HAVE RELATIVE TIME */ struct GNUNET_TIME_Relative rel_time = GNUNET_TIME_UNIT_ZERO; struct GNUNET_TIME_Absolute exp_abs; exp_abs = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), rel_time); exp_t = exp_abs.abs_value; exp = convert_time_to_string (exp_abs); } else { struct GNUNET_TIME_Absolute exp_abs; exp_abs.abs_value = rd[c].expiration_time; exp_t = exp_abs.abs_value; exp = convert_time_to_string (exp_abs); } /* value */ val = GNUNET_NAMESTORE_value_to_string (rd[c].record_type, rd[c].data, rd[c].data_size); 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)); else GNUNET_asprintf(&type_str, "%s", EXPIRE_INVALID_STRING); if ((0 ==strcmp (name, ROOT_STR)) && (GNUNET_NAMESTORE_TYPE_PSEU == rd[c].record_type)) { zc_ctx->label = strdup(val); iteration = GNUNET_YES; } else { gtk_tree_store_insert_with_values (ts, &iter_record , &iter_name, 0, GNS_TREESTORE_COL_NAME, name, GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE, GNS_TREESTORE_COL_RECORD_TYPE, rd[c].record_type, GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str, GNS_TREESTORE_COL_IS_PUBLIC, public, GNS_TREESTORE_COL_EXP_TIME, exp_t, GNS_TREESTORE_COL_EXP_TIME_AS_STR, exp, GNS_TREESTORE_COL_EXP_TIME_IS_REL, time_is_relative, GNS_TREESTORE_COL_VAL_AS_STR, val, GNS_TREESTORE_COL_IS_RECORD_ROW, TRUE, GNS_TREESTORE_COL_NOT_DUMMY_ROW, TRUE, -1); } GNUNET_free (type_str); GNUNET_free (exp); GNUNET_free (val); } GNUNET_NAMESTORE_zone_iterator_next(zc_ctx->it); } /** * */ static void pseu_change_cont (void *cls, int32_t success, 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); } } /** * 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)) { 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); 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); } else if ((0 != strcmp (pseu, PSEU_EMPTY_STR)) && ((pseu == NULL) || (0 == strcmp ("", pseu)))) { gtk_entry_set_text (GTK_ENTRY(editable), PSEU_EMPTY_STR); } } /** * 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); } /** * Connect to the namestore and initialize the main * GNS tree view. */ void GNUNET_SETUP_gns_init () { struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; char *label; char *keyfile; char *servicehome; struct ZoneIteration_Context *zc_ctx; GtkTreeIter toplevel; GtkLabel *status_label; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "PATHS", "SERVICEHOME", &servicehome)) { GNUNET_asprintf (&zonekey_directory, ""); } else { GNUNET_asprintf (&zonekey_directory, "%s%s%s",servicehome, DIR_SEPARATOR_STR, "gns"); GNUNET_free (servicehome); } /* setup crypto keys */ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", "ZONEKEY", &keyfile)) { status_label = GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label")); label = g_markup_printf_escaped (_("Option `%s' missing in section `%s'\n"), "ZONEKEY", "gns"); gtk_label_set_markup (status_label, label); g_free (label); return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using `%s'\n", keyfile); pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); GNUNET_free (keyfile); keyfile = NULL; if (NULL == pkey) { status_label = GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label")); label = g_markup_printf_escaped (_("Failed to read or create private zone key\n")); gtk_label_set_markup (status_label, label); g_free (label); 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); /* connect to namestore */ namestore = GNUNET_NAMESTORE_connect (cfg); if (NULL == namestore) { status_label = GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label")); label = g_markup_printf_escaped (_("Failed to connect to namestore")); gtk_label_set_markup (status_label, label); g_free (label); return; } ts = GTK_TREE_STORE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_treestore")); ls = GTK_LIST_STORE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_type_liststore")); tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_treeview")); tm = GTK_TREE_MODEL(ts); zone_as_string = GNUNET_strdup ((char *) &shenc); label = g_markup_printf_escaped (_("Editing zone %s"), 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 = GNUNET_malloc (sizeof (struct ZoneIteration_Context)); zc_ctx->zone = zone; zc_ctx->it = GNUNET_NAMESTORE_zone_iteration_start (namestore, &zone, GNUNET_NAMESTORE_RF_NONE, GNUNET_NAMESTORE_RF_NONE, &zone_iteration_proc, zc_ctx); } /** * Disconnect from the namestore and clean up the main * GNS tree view. */ void GNUNET_SETUP_gns_done () { 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); if (NULL != namestore) { GNUNET_NAMESTORE_disconnect (namestore); namestore = NULL; } if (NULL != pkey) { GNUNET_CRYPTO_rsa_key_free (pkey); pkey = NULL; } if (NULL != zonekey_directory) { GNUNET_free (zonekey_directory); zonekey_directory = NULL; } } /* end of gnunet-setup-gns.c */