diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-26 12:59:31 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-26 12:59:31 +0000 |
commit | 13f065c004d5c76cbeb6b8d03e604508e1e1c85c (patch) | |
tree | 654bb19151e5aa9d1c22b76df8d6318a50edab93 | |
parent | 968f5cd4682fbb7096e765126d24134fc2de78fd (diff) | |
download | gnunet-gtk-13f065c004d5c76cbeb6b8d03e604508e1e1c85c.tar.gz gnunet-gtk-13f065c004d5c76cbeb6b8d03e604508e1e1c85c.zip |
- pseu fix
-rw-r--r-- | src/gns/gnunet-gns-gtk.c | 4 | ||||
-rw-r--r-- | src/gns/gnunet-gns-gtk.h | 2 | ||||
-rw-r--r-- | src/gns/gnunet-gns-gtk_zone.c | 84 |
3 files changed, 67 insertions, 23 deletions
diff --git a/src/gns/gnunet-gns-gtk.c b/src/gns/gnunet-gns-gtk.c index 252afde2..4ece8faa 100644 --- a/src/gns/gnunet-gns-gtk.c +++ b/src/gns/gnunet-gns-gtk.c | |||
@@ -151,7 +151,7 @@ GNUNET_GNS_GTK_pseu_entry_changed_cb (GtkEditable *editable, | |||
151 | const gchar * pseu; | 151 | const gchar * pseu; |
152 | 152 | ||
153 | pseu = gtk_entry_get_text (GTK_ENTRY(editable)); | 153 | pseu = gtk_entry_get_text (GTK_ENTRY(editable)); |
154 | if ((pseu != NULL) && (0 != strcmp ("", pseu))) | 154 | if ((pseu != NULL) && (0 != strcmp ("", pseu)) && (GNUNET_NO == gns->iteration)) |
155 | { | 155 | { |
156 | 156 | ||
157 | rd.record_type = GNUNET_NAMESTORE_TYPE_PSEU; | 157 | rd.record_type = GNUNET_NAMESTORE_TYPE_PSEU; |
@@ -160,7 +160,7 @@ GNUNET_GNS_GTK_pseu_entry_changed_cb (GtkEditable *editable, | |||
160 | rd.data_size = strlen (pseu) + 1; | 160 | rd.data_size = strlen (pseu) + 1; |
161 | rd.data = strdup (pseu); | 161 | rd.data = strdup (pseu); |
162 | GNUNET_NAMESTORE_record_create(gns->ns, gns->pkey, "+", &rd, pseu_change_cont, gns); | 162 | GNUNET_NAMESTORE_record_create(gns->ns, gns->pkey, "+", &rd, pseu_change_cont, gns); |
163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New Pseudonym is `%s' %u\n", (char *) rd.data, rd.data_size); | 163 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "New Pseudonym is `%s' %u\n", (char *) rd.data, rd.data_size); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
diff --git a/src/gns/gnunet-gns-gtk.h b/src/gns/gnunet-gns-gtk.h index cbc899b4..b9228082 100644 --- a/src/gns/gnunet-gns-gtk.h +++ b/src/gns/gnunet-gns-gtk.h | |||
@@ -49,7 +49,7 @@ struct GNUNET_GNS_Context | |||
49 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 49 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
50 | 50 | ||
51 | struct GNUNET_CRYPTO_ShortHashCode zone; | 51 | struct GNUNET_CRYPTO_ShortHashCode zone; |
52 | 52 | int iteration; | |
53 | }; | 53 | }; |
54 | 54 | ||
55 | 55 | ||
diff --git a/src/gns/gnunet-gns-gtk_zone.c b/src/gns/gnunet-gns-gtk_zone.c index 8cb1605c..e8ea9271 100644 --- a/src/gns/gnunet-gns-gtk_zone.c +++ b/src/gns/gnunet-gns-gtk_zone.c | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | #define NEW_NAME_STR "<new name>" | 29 | #define NEW_NAME_STR "<new name>" |
30 | #define NEW_RECORD_STR "<new record>" | 30 | #define NEW_RECORD_STR "<new record>" |
31 | #define ROOT_STR "+" | ||
31 | #define EXPIRE_NEVER_STRING "never" | 32 | #define EXPIRE_NEVER_STRING "never" |
32 | #define EXPIRE_INVALID_STRING "invalid" | 33 | #define EXPIRE_INVALID_STRING "invalid" |
33 | 34 | ||
@@ -97,17 +98,20 @@ check_name_validity_and_commit_remove_proc (void *cls, | |||
97 | } | 98 | } |
98 | } | 99 | } |
99 | 100 | ||
100 | void | 101 | static void |
101 | check_name_validity_and_commit (struct GNUNET_GNS_Context *gns, gchar *path) | 102 | check_name_validity_and_commit (struct GNUNET_GNS_Context *gns, gchar *path) |
102 | { | 103 | { |
103 | GtkTreeIter it; | 104 | GtkTreeIter it; |
104 | GtkTreeIter parent; | 105 | GtkTreeIter parent; |
106 | int records; | ||
105 | int children; | 107 | int children; |
108 | int append_pseu; | ||
106 | int c; | 109 | int c; |
107 | int valid = GNUNET_YES; | 110 | int valid = GNUNET_YES; |
108 | char * name; | 111 | char * name; |
109 | void * data; | 112 | void * data; |
110 | size_t data_size; | 113 | size_t data_size; |
114 | const gchar * pseu; | ||
111 | 115 | ||
112 | char *n_name; | 116 | char *n_name; |
113 | int n_type; | 117 | int n_type; |
@@ -135,7 +139,19 @@ check_name_validity_and_commit (struct GNUNET_GNS_Context *gns, gchar *path) | |||
135 | TREE_COL_NAME, &name, | 139 | TREE_COL_NAME, &name, |
136 | -1); | 140 | -1); |
137 | 141 | ||
138 | struct GNUNET_NAMESTORE_RecordData *rd = GNUNET_malloc (children * sizeof (struct GNUNET_NAMESTORE_RecordData)); | 142 | if (0 == strcmp (name, ROOT_STR)) |
143 | { | ||
144 | /* We have to append PSEU RECORD */ | ||
145 | append_pseu = GNUNET_YES; | ||
146 | records = children + 1; | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | append_pseu = GNUNET_NO; | ||
151 | records = children; | ||
152 | } | ||
153 | |||
154 | struct GNUNET_NAMESTORE_RecordData *rd = GNUNET_malloc (records * sizeof (struct GNUNET_NAMESTORE_RecordData)); | ||
139 | 155 | ||
140 | if (FALSE == gtk_tree_model_iter_children (gns->tm, &it, &parent)) | 156 | if (FALSE == gtk_tree_model_iter_children (gns->tm, &it, &parent)) |
141 | return; | 157 | return; |
@@ -210,11 +226,34 @@ check_name_validity_and_commit (struct GNUNET_GNS_Context *gns, gchar *path) | |||
210 | } | 226 | } |
211 | else | 227 | else |
212 | { | 228 | { |
229 | |||
230 | if (GNUNET_YES == append_pseu) | ||
231 | { | ||
232 | GNUNET_assert (children == (records -1)); | ||
233 | /* Append PSEU record */ | ||
234 | GtkEntry * entry = GTK_ENTRY (gtk_builder_get_object (gns->builder, "GNUNET_GNS_GTK_pseu_entry")); | ||
235 | void *data; | ||
236 | size_t data_len; | ||
237 | pseu = gtk_entry_get_text (GTK_ENTRY(entry)); | ||
238 | if (GNUNET_OK != GNUNET_NAMESTORE_string_to_value(GNUNET_NAMESTORE_TYPE_PSEU, pseu, &rd[records - 1].data, &rd[records - 1].data_size)) | ||
239 | { | ||
240 | GNUNET_break (0); | ||
241 | for (c = 0; c < records; c++) | ||
242 | GNUNET_free_non_null ((void *) rd[c].data); | ||
243 | GNUNET_free_non_null (rd); | ||
244 | } | ||
245 | rd[records - 1].record_type = GNUNET_NAMESTORE_TYPE_PSEU; | ||
246 | rd[records - 1].expiration = GNUNET_TIME_absolute_get_forever(); | ||
247 | rd[records - 1].flags = GNUNET_NAMESTORE_RF_AUTHORITY | GNUNET_NAMESTORE_RF_NONE; | ||
248 | g_free (pseu); | ||
249 | |||
250 | } | ||
251 | |||
213 | /* Remove old entries */ | 252 | /* Remove old entries */ |
214 | struct UpdateContext * uc = GNUNET_malloc (sizeof (struct UpdateContext)); | 253 | struct UpdateContext * uc = GNUNET_malloc (sizeof (struct UpdateContext)); |
215 | uc->gns = gns; | 254 | uc->gns = gns; |
216 | uc->rd = rd; | 255 | uc->rd = rd; |
217 | uc->rd_count = children; | 256 | uc->rd_count = records; |
218 | uc->name = strdup (name); | 257 | uc->name = strdup (name); |
219 | GNUNET_NAMESTORE_record_remove(gns->ns, gns->pkey, name, NULL, &check_name_validity_and_commit_remove_proc, uc); | 258 | GNUNET_NAMESTORE_record_remove(gns->ns, gns->pkey, name, NULL, &check_name_validity_and_commit_remove_proc, uc); |
220 | g_free (name); | 259 | g_free (name); |
@@ -346,7 +385,7 @@ check_name_validity_and_remove (struct GNUNET_GNS_Context *gns, gchar *path) | |||
346 | g_free (n_value); | 385 | g_free (n_value); |
347 | g_free (n_value_color); | 386 | g_free (n_value_color); |
348 | } | 387 | } |
349 | else if (0 != strcmp (name, "+")) | 388 | else if (0 != strcmp (name, ROOT_STR)) |
350 | { | 389 | { |
351 | /* Removing the whole name record */ | 390 | /* Removing the whole name record */ |
352 | rcc = GNUNET_malloc(sizeof (struct Remove_Context)); | 391 | rcc = GNUNET_malloc(sizeof (struct Remove_Context)); |
@@ -962,8 +1001,8 @@ zone_iteration_proc (void *cls, | |||
962 | pseu_entry = GTK_ENTRY((gtk_builder_get_object (zc_ctx->gns->builder, "GNUNET_GNS_GTK_pseu_entry"))); | 1001 | pseu_entry = GTK_ENTRY((gtk_builder_get_object (zc_ctx->gns->builder, "GNUNET_GNS_GTK_pseu_entry"))); |
963 | if (zc_ctx->label == NULL) | 1002 | if (zc_ctx->label == NULL) |
964 | GNUNET_asprintf(&zc_ctx->label, "%s", EXPIRE_INVALID_STRING); | 1003 | GNUNET_asprintf(&zc_ctx->label, "%s", EXPIRE_INVALID_STRING); |
965 | |||
966 | gtk_entry_set_text (pseu_entry, zc_ctx->label); | 1004 | gtk_entry_set_text (pseu_entry, zc_ctx->label); |
1005 | zc_ctx->gns->iteration = GNUNET_NO; | ||
967 | GNUNET_free (zc_ctx->label); | 1006 | GNUNET_free (zc_ctx->label); |
968 | GNUNET_free (zc_ctx); | 1007 | GNUNET_free (zc_ctx); |
969 | return; | 1008 | return; |
@@ -1033,22 +1072,27 @@ zone_iteration_proc (void *cls, | |||
1033 | if (NULL == type_str) | 1072 | if (NULL == type_str) |
1034 | GNUNET_asprintf(&type_str, "%s", EXPIRE_INVALID_STRING); | 1073 | GNUNET_asprintf(&type_str, "%s", EXPIRE_INVALID_STRING); |
1035 | 1074 | ||
1036 | if (GNUNET_NAMESTORE_TYPE_PSEU == rd[c].record_type) | 1075 | if ((0 ==strcmp (name, ROOT_STR)) && (GNUNET_NAMESTORE_TYPE_PSEU == rd[c].record_type)) |
1076 | { | ||
1037 | zc_ctx->label = strdup(val); | 1077 | zc_ctx->label = strdup(val); |
1038 | 1078 | zc_ctx->gns->iteration = GNUNET_YES; | |
1039 | gtk_tree_store_insert_with_values(zc_ctx->gns->ts, &iter_record , &iter_name, 0, | 1079 | } |
1040 | TREE_COL_NAME, name, | 1080 | else |
1041 | TREE_COL_NAME_IS_VISIBLE, FALSE, | 1081 | { |
1042 | TREE_COL_RECORD_TYPE, rd[c].record_type, | 1082 | gtk_tree_store_insert_with_values(zc_ctx->gns->ts, &iter_record , &iter_name, 0, |
1043 | TREE_COL_RECORD_TYPE_AS_STR, type_str, | 1083 | TREE_COL_NAME, name, |
1044 | TREE_COL_IS_PUBLIC, public, | 1084 | TREE_COL_NAME_IS_VISIBLE, FALSE, |
1045 | TREE_COL_EXP_TIME, exp_t, | 1085 | TREE_COL_RECORD_TYPE, rd[c].record_type, |
1046 | TREE_COL_EXP_TIME_AS_STR, exp, | 1086 | TREE_COL_RECORD_TYPE_AS_STR, type_str, |
1047 | TREE_COL_EXP_TIME_IS_REL, time_is_relative, | 1087 | TREE_COL_IS_PUBLIC, public, |
1048 | TREE_COL_VAL_AS_STR, val, | 1088 | TREE_COL_EXP_TIME, exp_t, |
1049 | TREE_COL_IS_RECORD_ROW, GNUNET_YES, | 1089 | TREE_COL_EXP_TIME_AS_STR, exp, |
1050 | TREE_COL_NOT_DUMMY_ROW, GNUNET_YES, | 1090 | TREE_COL_EXP_TIME_IS_REL, time_is_relative, |
1051 | -1); | 1091 | TREE_COL_VAL_AS_STR, val, |
1092 | TREE_COL_IS_RECORD_ROW, GNUNET_YES, | ||
1093 | TREE_COL_NOT_DUMMY_ROW, GNUNET_YES, | ||
1094 | -1); | ||
1095 | } | ||
1052 | GNUNET_free (type_str); | 1096 | GNUNET_free (type_str); |
1053 | GNUNET_free (exp); | 1097 | GNUNET_free (exp); |
1054 | GNUNET_free (val); | 1098 | GNUNET_free (val); |