diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-07-09 15:13:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-07-09 15:13:38 +0000 |
commit | 76a93c3449c3227c5f5613fd9f1dca7fb0d714bc (patch) | |
tree | fcbe7b23e709fdd7cfd96fd7faaee4219d6e6613 | |
parent | 73e31317eab3b5e95039a50ddbd5a4358155470b (diff) | |
download | gnunet-gtk-76a93c3449c3227c5f5613fd9f1dca7fb0d714bc.tar.gz gnunet-gtk-76a93c3449c3227c5f5613fd9f1dca7fb0d714bc.zip |
-fixing build, zone editing still broken
-rw-r--r-- | src/setup/gnunet-setup-gns.c | 364 |
1 files changed, 129 insertions, 235 deletions
diff --git a/src/setup/gnunet-setup-gns.c b/src/setup/gnunet-setup-gns.c index 9d7209b6..2cdcb6ba 100644 --- a/src/setup/gnunet-setup-gns.c +++ b/src/setup/gnunet-setup-gns.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2012, 2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -171,41 +171,6 @@ enum LIST_COLUMNS | |||
171 | }; | 171 | }; |
172 | 172 | ||
173 | 173 | ||
174 | /** | ||
175 | * Closure for 'zone_iteration_proc'. | ||
176 | */ | ||
177 | struct ZoneIteration_Context | ||
178 | { | ||
179 | |||
180 | /** | ||
181 | * Kept in a DLL. | ||
182 | */ | ||
183 | struct ZoneIteration_Context *next; | ||
184 | |||
185 | /** | ||
186 | * Kept in a DLL. | ||
187 | */ | ||
188 | struct ZoneIteration_Context *prev; | ||
189 | |||
190 | /** | ||
191 | * Short hash of the public key of the zone. | ||
192 | */ | ||
193 | struct GNUNET_CRYPTO_ShortHashCode zone; | ||
194 | |||
195 | /** | ||
196 | * Iterator for loading the records from the zone. | ||
197 | */ | ||
198 | struct GNUNET_NAMESTORE_ZoneIterator *it; | ||
199 | |||
200 | /** | ||
201 | * Context for loading/generating the zone key for this zone. | ||
202 | */ | ||
203 | struct GNUNET_CRYPTO_RsaKeyGenerationContext *rkgc; | ||
204 | |||
205 | }; | ||
206 | |||
207 | |||
208 | |||
209 | 174 | ||
210 | /** | 175 | /** |
211 | * Context we use for making changes to the namestore. | 176 | * Context we use for making changes to the namestore. |
@@ -306,14 +271,9 @@ struct PseuContext | |||
306 | 271 | ||
307 | 272 | ||
308 | /** | 273 | /** |
309 | * Head of linked list of active zone operations. | 274 | * Our current zone monitor. |
310 | */ | 275 | */ |
311 | static struct ZoneIteration_Context *zc_head; | 276 | static struct GNUNET_NAMESTORE_ZoneMonitor *zmon; |
312 | |||
313 | /** | ||
314 | * Tail of linked list of active zone operations. | ||
315 | */ | ||
316 | static struct ZoneIteration_Context *zc_tail; | ||
317 | 277 | ||
318 | /** | 278 | /** |
319 | * Head of linked list of active update operations. | 279 | * Head of linked list of active update operations. |
@@ -611,6 +571,24 @@ GNUNET_setup_gns_qr_saveas_button_clicked_cb (GtkButton *button, | |||
611 | 571 | ||
612 | 572 | ||
613 | /** | 573 | /** |
574 | * Clear all entries in the zone view and hide the tree view. | ||
575 | */ | ||
576 | static void | ||
577 | clear_zone_view () | ||
578 | { | ||
579 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_selection_hbuttonbox"))); | ||
580 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label"))); | ||
581 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_scrolledwindow"))); | ||
582 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"))); | ||
583 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_saveas_button"))); | ||
584 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_vseparator"))); | ||
585 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_pseu_hbox"))); | ||
586 | gtk_tree_store_clear (ts); | ||
587 | } | ||
588 | |||
589 | |||
590 | |||
591 | /** | ||
614 | * Load a particular zone into the main tree view. | 592 | * Load a particular zone into the main tree view. |
615 | * | 593 | * |
616 | * @param zonename name of the option in the configuration file | 594 | * @param zonename name of the option in the configuration file |
@@ -751,9 +729,12 @@ create_next_record (struct UpdateContext *uc) | |||
751 | free_update_context (uc); | 729 | free_update_context (uc); |
752 | return; | 730 | return; |
753 | } | 731 | } |
732 | #if 0 | ||
733 | /* FIXME: what were we doing here again? */ | ||
754 | uc->qe = GNUNET_NAMESTORE_record_create (namestore, pkey, | 734 | uc->qe = GNUNET_NAMESTORE_record_create (namestore, pkey, |
755 | uc->name, &uc->rd[uc->rd_pos], | 735 | uc->name, &uc->rd[uc->rd_pos], |
756 | &create_more_records, uc); | 736 | &create_more_records, uc); |
737 | #endif | ||
757 | } | 738 | } |
758 | 739 | ||
759 | 740 | ||
@@ -952,7 +933,8 @@ check_name_validity_and_commit (GtkTreeIter *it, | |||
952 | return; | 933 | return; |
953 | } | 934 | } |
954 | 935 | ||
955 | /* Store update information in context and remove old entries */ | 936 | /* FIXME: modify entries! */ |
937 | #if 0 | ||
956 | uc = GNUNET_malloc (sizeof (struct UpdateContext)); | 938 | uc = GNUNET_malloc (sizeof (struct UpdateContext)); |
957 | uc->rd = rd; | 939 | uc->rd = rd; |
958 | uc->rd_count = records; | 940 | uc->rd_count = records; |
@@ -971,6 +953,7 @@ check_name_validity_and_commit (GtkTreeIter *it, | |||
971 | free_update_context (uc); | 953 | free_update_context (uc); |
972 | return; | 954 | return; |
973 | } | 955 | } |
956 | #endif | ||
974 | } | 957 | } |
975 | 958 | ||
976 | 959 | ||
@@ -998,47 +981,6 @@ free_remove_context (struct RemoveContext *rc) | |||
998 | 981 | ||
999 | 982 | ||
1000 | /** | 983 | /** |
1001 | * We tried to remove a record from the namestore, if we were | ||
1002 | * successful, also remove it from the model. | ||
1003 | * | ||
1004 | * @param cls the 'struct RemoveContext' | ||
1005 | * @param success GNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) | ||
1006 | * GNUNET_NO if content was already there or not found | ||
1007 | * GNUNET_YES (or other positive value) on success | ||
1008 | * @param emsg NULL on success, otherwise an error message | ||
1009 | */ | ||
1010 | static void | ||
1011 | update_treemodel_after_remove (void *cls, | ||
1012 | int32_t success, | ||
1013 | const char *emsg) | ||
1014 | { | ||
1015 | struct RemoveContext *rc = cls; | ||
1016 | GtkTreeIter it; | ||
1017 | |||
1018 | rc->qe = NULL; | ||
1019 | switch (success) | ||
1020 | { | ||
1021 | case GNUNET_YES: | ||
1022 | gtk_tree_model_get_iter_from_string(tm, &it, rc->path); | ||
1023 | gtk_tree_store_remove (ts, &it); | ||
1024 | break; | ||
1025 | case GNUNET_NO: | ||
1026 | resync_db (); | ||
1027 | break; | ||
1028 | case GNUNET_SYSERR: | ||
1029 | show_error_message (_("Failed to remove record"), | ||
1030 | emsg); | ||
1031 | resync_db (); | ||
1032 | break; | ||
1033 | default: | ||
1034 | GNUNET_break (0); | ||
1035 | break; | ||
1036 | } | ||
1037 | free_remove_context (rc); | ||
1038 | } | ||
1039 | |||
1040 | |||
1041 | /** | ||
1042 | * Remove a record from the model (and if it is valid, also from | 984 | * Remove a record from the model (and if it is valid, also from |
1043 | * the namestore). If the given path identifies an entire 'name', | 985 | * the namestore). If the given path identifies an entire 'name', |
1044 | * remove all records under that name. | 986 | * remove all records under that name. |
@@ -1100,24 +1042,15 @@ remove_records_by_path (const gchar *path) | |||
1100 | g_free (n_value); | 1042 | g_free (n_value); |
1101 | return; | 1043 | return; |
1102 | } | 1044 | } |
1103 | 1045 | ||
1104 | rc = GNUNET_malloc (sizeof (struct RemoveContext)); | 1046 | /* FIXME: actually apply changes! */ |
1105 | GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc); | ||
1106 | rc->path = strdup (path); | ||
1107 | rc->qe = GNUNET_NAMESTORE_record_remove (namestore, pkey, name, &rd, | ||
1108 | &update_treemodel_after_remove, rc); | ||
1109 | GNUNET_free ((void *) rd.data); | 1047 | GNUNET_free ((void *) rd.data); |
1110 | g_free (n_name); | 1048 | g_free (n_name); |
1111 | g_free (n_value); | 1049 | g_free (n_value); |
1112 | } | 1050 | } |
1113 | else if (0 != strcmp (name, GNUNET_GNS_MASTERZONE_STR)) | 1051 | else if (0 != strcmp (name, GNUNET_GNS_MASTERZONE_STR)) |
1114 | { | 1052 | { |
1115 | /* Removing the whole name record */ | 1053 | /* FIXME: actually apply changes! */ |
1116 | rc = GNUNET_malloc(sizeof (struct RemoveContext)); | ||
1117 | GNUNET_CONTAINER_DLL_insert (rc_head, rc_tail, rc); | ||
1118 | rc->path = strdup (path); | ||
1119 | rc->qe = GNUNET_NAMESTORE_record_remove (namestore, pkey, name, NULL, | ||
1120 | &update_treemodel_after_remove, rc); | ||
1121 | } | 1054 | } |
1122 | g_free (name); | 1055 | g_free (name); |
1123 | } | 1056 | } |
@@ -1248,10 +1181,13 @@ record_move_continuation (void *cls, | |||
1248 | rd.flags |= GNUNET_NAMESTORE_RF_SHADOW_RECORD; | 1181 | rd.flags |= GNUNET_NAMESTORE_RF_SHADOW_RECORD; |
1249 | rd.data_size = data_size; | 1182 | rd.data_size = data_size; |
1250 | rd.data = data; | 1183 | rd.data = data; |
1184 | #if 0 | ||
1185 | /* FIXME: actually apply changes! */ | ||
1251 | edc->qe = GNUNET_NAMESTORE_record_create (namestore, pk, | 1186 | edc->qe = GNUNET_NAMESTORE_record_create (namestore, pk, |
1252 | edc->n_new_name, | 1187 | edc->n_new_name, |
1253 | &rd, | 1188 | &rd, |
1254 | &record_move_finish, edc); | 1189 | &record_move_finish, edc); |
1190 | #endif | ||
1255 | } | 1191 | } |
1256 | 1192 | ||
1257 | 1193 | ||
@@ -1923,9 +1859,12 @@ GNUNET_setup_gns_pseu_entry_changed_cb (GtkEditable *editable, | |||
1923 | rd.data = pseu; | 1859 | rd.data = pseu; |
1924 | pc = GNUNET_malloc (sizeof (struct PseuContext)); | 1860 | pc = GNUNET_malloc (sizeof (struct PseuContext)); |
1925 | GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc); | 1861 | GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc); |
1862 | #if 0 | ||
1863 | /* FIXME: actually apply changes! */ | ||
1926 | pc->qe = GNUNET_NAMESTORE_record_create (namestore, pkey, "+", | 1864 | pc->qe = GNUNET_NAMESTORE_record_create (namestore, pkey, "+", |
1927 | &rd, | 1865 | &rd, |
1928 | &pseu_change_cont, pc); | 1866 | &pseu_change_cont, pc); |
1867 | #endif | ||
1929 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1868 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1930 | "New Pseudonym is `%s' %u\n", | 1869 | "New Pseudonym is `%s' %u\n", |
1931 | (char *) rd.data, rd.data_size); | 1870 | (char *) rd.data, rd.data_size); |
@@ -1941,9 +1880,12 @@ GNUNET_setup_gns_pseu_entry_changed_cb (GtkEditable *editable, | |||
1941 | rd.data = current_pseudonym; | 1880 | rd.data = current_pseudonym; |
1942 | pc = GNUNET_malloc (sizeof (struct PseuContext)); | 1881 | pc = GNUNET_malloc (sizeof (struct PseuContext)); |
1943 | GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc); | 1882 | GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc); |
1883 | #if 0 | ||
1884 | /* FIXME: actually apply changes! */ | ||
1944 | pc->qe = GNUNET_NAMESTORE_record_remove (namestore, pkey, "+", | 1885 | pc->qe = GNUNET_NAMESTORE_record_remove (namestore, pkey, "+", |
1945 | &rd, | 1886 | &rd, |
1946 | &pseu_change_cont, pc); | 1887 | &pseu_change_cont, pc); |
1888 | #endif | ||
1947 | gtk_entry_set_text (GTK_ENTRY(editable), ""); | 1889 | gtk_entry_set_text (GTK_ENTRY(editable), ""); |
1948 | GNUNET_free_non_null (current_pseudonym); | 1890 | GNUNET_free_non_null (current_pseudonym); |
1949 | current_pseudonym = NULL; | 1891 | current_pseudonym = NULL; |
@@ -1975,11 +1917,45 @@ GNUNET_setup_gns_public_key_copy_button_clicked_cb (GtkButton *button, | |||
1975 | 1917 | ||
1976 | 1918 | ||
1977 | /** | 1919 | /** |
1920 | * Function called once our model should be consistent with | ||
1921 | * the current zone. Makes the view visible. | ||
1922 | * | ||
1923 | * @param cls NULL | ||
1924 | */ | ||
1925 | static void | ||
1926 | zone_sync_proc (void *cls) | ||
1927 | { | ||
1928 | GtkEntry *pseu_entry; | ||
1929 | |||
1930 | pseu_entry = GTK_ENTRY((GNUNET_SETUP_get_object ("GNUNET_setup_gns_pseu_entry"))); | ||
1931 | if (0 == strcmp (current_zone_option, "ZONEKEY")) | ||
1932 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_pseu_hbox"))); | ||
1933 | GNUNET_setup_gns_pseu_entry_changed_cb (GTK_EDITABLE (pseu_entry), | ||
1934 | NULL); | ||
1935 | #if HAVE_QRENCODE_H | ||
1936 | setup_qrcode (); | ||
1937 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"))); | ||
1938 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_saveas_button"))); | ||
1939 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_vseparator"))); | ||
1940 | #else | ||
1941 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"))); | ||
1942 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_saveas_button"))); | ||
1943 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_vseparator"))); | ||
1944 | #endif | ||
1945 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label"))); | ||
1946 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_scrolledwindow"))); | ||
1947 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_selection_hbuttonbox"))); | ||
1948 | } | ||
1949 | |||
1950 | |||
1951 | /** | ||
1978 | * Function called for each record in the current zone. Update the | 1952 | * Function called for each record in the current zone. Update the |
1979 | * widgets accordingly. Once the zone iteration is done, unfreeze | 1953 | * widgets accordingly. |
1980 | * the editing functions. | ||
1981 | * | 1954 | * |
1982 | * @param cls the 'strucct ZoneIteration_Context' | 1955 | * FIXME: we need to UPDATE records if an existing record is changed, |
1956 | * not merely append! | ||
1957 | * | ||
1958 | * @param NULL | ||
1983 | * @param zone_key public key of the zone | 1959 | * @param zone_key public key of the zone |
1984 | * @param freshness when does the corresponding block in the DHT expire (until | 1960 | * @param freshness when does the corresponding block in the DHT expire (until |
1985 | * when should we never do a DHT lookup for the same name again)?; | 1961 | * when should we never do a DHT lookup for the same name again)?; |
@@ -1989,60 +1965,33 @@ GNUNET_setup_gns_public_key_copy_button_clicked_cb (GtkButton *button, | |||
1989 | * @param name name that is being mapped (at most 255 characters long) | 1965 | * @param name name that is being mapped (at most 255 characters long) |
1990 | * @param rd_count number of entries in 'rd' array | 1966 | * @param rd_count number of entries in 'rd' array |
1991 | * @param rd array of records with data to store | 1967 | * @param rd array of records with data to store |
1992 | * @param signature signature of the record block, NULL if signature is unavailable (i.e. | 1968 | * @param signature signature of the record block, NULL as we are monitoring |
1993 | * because the user queried for a particular record type only) | ||
1994 | */ | 1969 | */ |
1995 | static void | 1970 | static void |
1996 | zone_iteration_proc (void *cls, | 1971 | zone_iteration_proc (void *cls, |
1997 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 1972 | const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, |
1998 | struct GNUNET_TIME_Absolute expire, | 1973 | struct GNUNET_TIME_Absolute expire, |
1999 | const char *name, | 1974 | const char *name, |
2000 | unsigned int rd_count, | 1975 | unsigned int rd_count, |
2001 | const struct GNUNET_NAMESTORE_RecordData *rd, | 1976 | const struct GNUNET_NAMESTORE_RecordData *rd, |
2002 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 1977 | const struct GNUNET_CRYPTO_EccSignature *signature) |
2003 | { | 1978 | { |
2004 | struct ZoneIteration_Context * zc_ctx = cls; | ||
2005 | GtkTreeIter iter_name; | 1979 | GtkTreeIter iter_name; |
2006 | GtkTreeIter iter_record; | 1980 | GtkTreeIter iter_record; |
2007 | GtkEntry *pseu_entry; | ||
2008 | int c; | 1981 | int c; |
2009 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; | ||
2010 | const char *exp; | 1982 | const char *exp; |
2011 | char *val; | 1983 | char *val; |
2012 | char *type_str; | 1984 | char *type_str; |
2013 | gboolean time_is_relative; | 1985 | gboolean time_is_relative; |
2014 | gboolean public; | 1986 | gboolean public; |
2015 | guint64 exp_t; | 1987 | guint64 exp_t; |
1988 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; | ||
1989 | GtkEntry *pseu_entry; | ||
2016 | 1990 | ||
2017 | GNUNET_assert (NULL != zc_ctx); | ||
2018 | if ((NULL == zone_key) && (NULL == name)) | 1991 | if ((NULL == zone_key) && (NULL == name)) |
2019 | { | 1992 | { |
2020 | GNUNET_CRYPTO_short_hash_to_enc (&zc_ctx->zone, &shenc); | 1993 | /* disconnect from namestore, clear view */ |
2021 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1994 | clear_zone_view (); |
2022 | "Zone `%s 'iteration done\n", | ||
2023 | &shenc); | ||
2024 | pseu_entry = GTK_ENTRY((GNUNET_SETUP_get_object ("GNUNET_setup_gns_pseu_entry"))); | ||
2025 | if (0 == strcmp (current_zone_option, "ZONEKEY")) | ||
2026 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_pseu_hbox"))); | ||
2027 | GNUNET_setup_gns_pseu_entry_changed_cb (GTK_EDITABLE (pseu_entry), | ||
2028 | NULL); | ||
2029 | GNUNET_CONTAINER_DLL_remove (zc_head, | ||
2030 | zc_tail, | ||
2031 | zc_ctx); | ||
2032 | GNUNET_free (zc_ctx); | ||
2033 | #if HAVE_QRENCODE_H | ||
2034 | setup_qrcode (); | ||
2035 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"))); | ||
2036 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_saveas_button"))); | ||
2037 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_vseparator"))); | ||
2038 | #else | ||
2039 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"))); | ||
2040 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_saveas_button"))); | ||
2041 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_vseparator"))); | ||
2042 | #endif | ||
2043 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label"))); | ||
2044 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_scrolledwindow"))); | ||
2045 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_selection_hbuttonbox"))); | ||
2046 | return; | 1995 | return; |
2047 | } | 1996 | } |
2048 | if ( (GNUNET_SYSERR == GNUNET_DNSPARSER_check_label (name)) && | 1997 | if ( (GNUNET_SYSERR == GNUNET_DNSPARSER_check_label (name)) && |
@@ -2052,10 +2001,9 @@ zone_iteration_proc (void *cls, | |||
2052 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2001 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2053 | _("Got invalid record name `%s' from namestore\n"), | 2002 | _("Got invalid record name `%s' from namestore\n"), |
2054 | name); | 2003 | name); |
2055 | GNUNET_NAMESTORE_zone_iterator_next (zc_ctx->it); | ||
2056 | return; | 2004 | return; |
2057 | } | 2005 | } |
2058 | GNUNET_CRYPTO_short_hash_to_enc (&zc_ctx->zone, &shenc); | 2006 | GNUNET_CRYPTO_short_hash_to_enc (&zone, &shenc); |
2059 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2007 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2060 | "Zone `%s' iteration result `%s', %u records\n", | 2008 | "Zone `%s' iteration result `%s', %u records\n", |
2061 | &shenc, name, rd_count); | 2009 | &shenc, name, rd_count); |
@@ -2137,38 +2085,56 @@ zone_iteration_proc (void *cls, | |||
2137 | GNUNET_free (type_str); | 2085 | GNUNET_free (type_str); |
2138 | GNUNET_free (val); | 2086 | GNUNET_free (val); |
2139 | } | 2087 | } |
2140 | GNUNET_NAMESTORE_zone_iterator_next (zc_ctx->it); | ||
2141 | } | 2088 | } |
2142 | 2089 | ||
2143 | 2090 | ||
2144 | /** | 2091 | /** |
2145 | * Function called upon completion of 'GNUNET_CRYPTO_rsa_key_create_async'. | 2092 | * Load a particular zone into the main tree view. |
2146 | * Displays an error message upon failure, otherwise beings loading the | ||
2147 | * zone's information from the namestore. | ||
2148 | * | 2093 | * |
2149 | * @param cls closure | 2094 | * @param zonename name of the option in the configuration file |
2150 | * @param pk NULL on error, otherwise the private key (which must be free'd by the callee) | 2095 | * with the name of the file with the private key of the |
2151 | * @param emsg NULL on success, otherwise an error message | 2096 | * zone to load |
2152 | */ | 2097 | */ |
2153 | static void | 2098 | static void |
2154 | zone_key_loaded_callback (void *cls, | 2099 | load_zone (const char *zonename) |
2155 | struct GNUNET_CRYPTO_RsaPrivateKey *pk, | ||
2156 | const char *emsg) | ||
2157 | { | 2100 | { |
2158 | struct ZoneIteration_Context *zc_ctx = cls; | 2101 | char *keyfile; |
2102 | struct GNUNET_CRYPTO_RsaPrivateKey *pk; | ||
2103 | char *emsg; | ||
2159 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; | 2104 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; |
2160 | char *label; | 2105 | char *label; |
2161 | GtkTreeIter toplevel; | 2106 | GtkTreeIter toplevel; |
2162 | 2107 | ||
2163 | zc_ctx->rkgc = NULL; | 2108 | /* clear previous zone */ |
2164 | if (NULL == pk) | 2109 | if (NULL != zmon) |
2110 | { | ||
2111 | GNUNET_NAMESTORE_zone_monitor_stop (zmon); | ||
2112 | zmon = NULL; | ||
2113 | } | ||
2114 | clear_zone_view (); | ||
2115 | current_zone_option = zonename; | ||
2116 | |||
2117 | /* setup crypto keys */ | ||
2118 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, | ||
2119 | "gns", | ||
2120 | zonename, | ||
2121 | &keyfile)) | ||
2165 | { | 2122 | { |
2166 | GNUNET_CONTAINER_DLL_remove (zc_head, | 2123 | GNUNET_asprintf (&emsg, |
2167 | zc_tail, | 2124 | _("Option `%s' missing in section `%s'\n"), |
2168 | zc_ctx); | 2125 | zonename, "gns"); |
2169 | GNUNET_free (zc_ctx); | ||
2170 | show_error_message (_("Failed to load zone"), | 2126 | show_error_message (_("Failed to load zone"), |
2171 | gettext(emsg)); | 2127 | emsg); |
2128 | GNUNET_free (emsg); | ||
2129 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_selection_hbuttonbox"))); | ||
2130 | return; | ||
2131 | } | ||
2132 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using `%s'\n", keyfile); | ||
2133 | pk = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | ||
2134 | GNUNET_free (keyfile); | ||
2135 | if (NULL == pk) | ||
2136 | { | ||
2137 | show_error_message (_("Failed to load zone"), NULL); | ||
2172 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_selection_hbuttonbox"))); | 2138 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_selection_hbuttonbox"))); |
2173 | return; | 2139 | return; |
2174 | } | 2140 | } |
@@ -2195,85 +2161,10 @@ zone_key_loaded_callback (void *cls, | |||
2195 | GNS_TREESTORE_COL_TYPE_IS_EDITABLE, TRUE, | 2161 | GNS_TREESTORE_COL_TYPE_IS_EDITABLE, TRUE, |
2196 | -1); | 2162 | -1); |
2197 | /* Load zone from namestore! */ | 2163 | /* Load zone from namestore! */ |
2198 | zc_ctx->zone = zone; | 2164 | zmon = GNUNET_NAMESTORE_zone_monitor_start (cfg, &zone, |
2199 | zc_ctx->it = GNUNET_NAMESTORE_zone_iteration_start (namestore, &zone, | 2165 | &zone_iteration_proc, |
2200 | GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION, | 2166 | &zone_sync_proc, |
2201 | GNUNET_NAMESTORE_RF_NONE, | 2167 | NULL); |
2202 | &zone_iteration_proc, | ||
2203 | zc_ctx); | ||
2204 | } | ||
2205 | |||
2206 | |||
2207 | /** | ||
2208 | * Stop a zone iteration. | ||
2209 | * | ||
2210 | * @param zc_ctx zone iteration to stop. | ||
2211 | */ | ||
2212 | static void | ||
2213 | abort_zone_iteration (struct ZoneIteration_Context *zc_ctx) | ||
2214 | { | ||
2215 | if (NULL != zc_ctx->rkgc) | ||
2216 | GNUNET_CRYPTO_rsa_key_create_stop (zc_ctx->rkgc); | ||
2217 | if (NULL != zc_ctx->it) | ||
2218 | GNUNET_NAMESTORE_zone_iteration_stop (zc_ctx->it); | ||
2219 | GNUNET_CONTAINER_DLL_remove (zc_head, | ||
2220 | zc_tail, | ||
2221 | zc_ctx); | ||
2222 | GNUNET_free (zc_ctx); | ||
2223 | } | ||
2224 | |||
2225 | |||
2226 | /** | ||
2227 | * Load a particular zone into the main tree view. | ||
2228 | * | ||
2229 | * @param zonename name of the option in the configuration file | ||
2230 | * with the name of the file with the private key of the | ||
2231 | * zone to load | ||
2232 | */ | ||
2233 | static void | ||
2234 | load_zone (const char *zonename) | ||
2235 | { | ||
2236 | char *keyfile; | ||
2237 | struct ZoneIteration_Context *zc_ctx; | ||
2238 | char *emsg; | ||
2239 | |||
2240 | /* clear previous zone */ | ||
2241 | current_zone_option = zonename; | ||
2242 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_selection_hbuttonbox"))); | ||
2243 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label"))); | ||
2244 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_scrolledwindow"))); | ||
2245 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"))); | ||
2246 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_saveas_button"))); | ||
2247 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_vseparator"))); | ||
2248 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_pseu_hbox"))); | ||
2249 | gtk_tree_store_clear (ts); | ||
2250 | |||
2251 | /* setup crypto keys */ | ||
2252 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, | ||
2253 | "gns", | ||
2254 | zonename, | ||
2255 | &keyfile)) | ||
2256 | { | ||
2257 | GNUNET_asprintf (&emsg, | ||
2258 | _("Option `%s' missing in section `%s'\n"), | ||
2259 | zonename, "gns"); | ||
2260 | show_error_message (_("Failed to load zone"), | ||
2261 | emsg); | ||
2262 | GNUNET_free (emsg); | ||
2263 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_selection_hbuttonbox"))); | ||
2264 | return; | ||
2265 | } | ||
2266 | while (NULL != (zc_ctx = zc_head)) | ||
2267 | abort_zone_iteration (zc_head); | ||
2268 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using `%s'\n", keyfile); | ||
2269 | zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context)); | ||
2270 | GNUNET_CONTAINER_DLL_insert (zc_head, | ||
2271 | zc_tail, | ||
2272 | zc_ctx); | ||
2273 | zc_ctx->rkgc = GNUNET_CRYPTO_rsa_key_create_start (keyfile, | ||
2274 | &zone_key_loaded_callback, | ||
2275 | zc_ctx); | ||
2276 | GNUNET_free (keyfile); | ||
2277 | } | 2168 | } |
2278 | 2169 | ||
2279 | 2170 | ||
@@ -2363,8 +2254,11 @@ GNUNET_SETUP_gns_done () | |||
2363 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label"))); | 2254 | gtk_widget_show (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_status_label"))); |
2364 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_scrolledwindow"))); | 2255 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_scrolledwindow"))); |
2365 | gtk_tree_store_clear (ts); | 2256 | gtk_tree_store_clear (ts); |
2366 | while (NULL != zc_head) | 2257 | if (NULL != zmon) |
2367 | abort_zone_iteration (zc_head); | 2258 | { |
2259 | GNUNET_NAMESTORE_zone_monitor_stop (zmon); | ||
2260 | zmon = NULL; | ||
2261 | } | ||
2368 | while (NULL != uc_head) | 2262 | while (NULL != uc_head) |
2369 | free_update_context (uc_head); | 2263 | free_update_context (uc_head); |
2370 | while (NULL != rc_head) | 2264 | while (NULL != rc_head) |