diff options
-rw-r--r-- | src/setup/Makefile.am | 3 | ||||
-rw-r--r-- | src/setup/gnunet-setup-gns.c | 763 | ||||
-rw-r--r-- | src/setup/gnunet-setup-gns.h | 47 | ||||
-rw-r--r-- | src/setup/gnunet-setup.c | 16 |
4 files changed, 348 insertions, 481 deletions
diff --git a/src/setup/Makefile.am b/src/setup/Makefile.am index bce82e78..6d483df4 100644 --- a/src/setup/Makefile.am +++ b/src/setup/Makefile.am | |||
@@ -29,13 +29,14 @@ gnunet_setup_SOURCES = \ | |||
29 | gnunet-setup-datacache-config.c \ | 29 | gnunet-setup-datacache-config.c \ |
30 | gnunet-setup-namestore-plugins.c \ | 30 | gnunet-setup-namestore-plugins.c \ |
31 | gnunet-setup-namestore-config.c \ | 31 | gnunet-setup-namestore-config.c \ |
32 | gnunet-setup-gns.c gnunet-setup-gns.h \ | ||
32 | gnunet-setup-hostlist-editing.c \ | 33 | gnunet-setup-hostlist-editing.c \ |
33 | gnunet-setup-hostlist-server.c | 34 | gnunet-setup-hostlist-server.c |
34 | gnunet_setup_LDADD = \ | 35 | gnunet_setup_LDADD = \ |
35 | $(top_builddir)/src/lib/libgnunetgtk.la \ | 36 | $(top_builddir)/src/lib/libgnunetgtk.la \ |
36 | @GTK_LIBS@ @GNUNET_LIBS@ @GLADE_LIBS@ \ | 37 | @GTK_LIBS@ @GNUNET_LIBS@ @GLADE_LIBS@ \ |
37 | $(WINLIBS) \ | 38 | $(WINLIBS) \ |
38 | -lgnunetutil -lgnunetnat \ | 39 | -lgnunetutil -lgnunetnat -lgnunetnamestore \ |
39 | $(INTLLIBS) | 40 | $(INTLLIBS) |
40 | gnunet_setup_LDFLAGS = \ | 41 | gnunet_setup_LDFLAGS = \ |
41 | -export-dynamic | 42 | -export-dynamic |
diff --git a/src/setup/gnunet-setup-gns.c b/src/setup/gnunet-setup-gns.c index 83a49e89..a3feb96b 100644 --- a/src/setup/gnunet-setup-gns.c +++ b/src/setup/gnunet-setup-gns.c | |||
@@ -24,7 +24,39 @@ | |||
24 | * @brief everything releated to the main GNS zone tree view | 24 | * @brief everything releated to the main GNS zone tree view |
25 | */ | 25 | */ |
26 | #include "gnunet_gtk.h" | 26 | #include "gnunet_gtk.h" |
27 | #include "gnunet-gns-gtk.h" | 27 | #include "gnunet-setup-gns.h" |
28 | #include <gnunet/gnunet_namestore_service.h> | ||
29 | |||
30 | /** | ||
31 | * FIXME. Also: i18n? | ||
32 | */ | ||
33 | #define NEW_NAME_STR "<new name>" | ||
34 | |||
35 | /** | ||
36 | * FIXME. Also: i18n? | ||
37 | */ | ||
38 | #define NEW_RECORD_STR "<new record>" | ||
39 | |||
40 | /** | ||
41 | * FIXME. Also: i18n? | ||
42 | */ | ||
43 | #define ROOT_STR "+" | ||
44 | |||
45 | /** | ||
46 | * FIXME. Also: i18n? | ||
47 | */ | ||
48 | #define EXPIRE_NEVER_STRING "never" | ||
49 | |||
50 | /** | ||
51 | * FIXME. Also: i18n? | ||
52 | */ | ||
53 | #define EXPIRE_INVALID_STRING "invalid" | ||
54 | |||
55 | /** | ||
56 | * FIXME. Also: i18n? | ||
57 | */ | ||
58 | #define PSEU_EMPTY_STR "<empty>" | ||
59 | |||
28 | 60 | ||
29 | 61 | ||
30 | /** | 62 | /** |
@@ -128,10 +160,6 @@ enum LIST_COLUMNS | |||
128 | */ | 160 | */ |
129 | struct UpdateContext | 161 | struct UpdateContext |
130 | { | 162 | { |
131 | /** | ||
132 | * | ||
133 | */ | ||
134 | struct GNUNET_GNS_Context *gns; | ||
135 | 163 | ||
136 | /** | 164 | /** |
137 | * | 165 | * |
@@ -160,27 +188,52 @@ static char *zone_as_string; | |||
160 | */ | 188 | */ |
161 | static char *zonekey_directory; | 189 | static char *zonekey_directory; |
162 | 190 | ||
191 | /** | ||
192 | * Handle to the namestore. | ||
193 | */ | ||
194 | static struct GNUNET_NAMESTORE_Handle *namestore; | ||
163 | 195 | ||
164 | struct GNUNET_GNS_Context | 196 | /** |
165 | { | 197 | * FIXME... |
166 | /** | 198 | */ |
167 | * Handle to the namestore. | 199 | static GtkTreeStore *ts; |
168 | */ | 200 | |
169 | struct GNUNET_NAMESTORE_Handle *ns; | 201 | /** |
202 | * FIXME... | ||
203 | */ | ||
204 | static GtkListStore *ls; | ||
170 | 205 | ||
171 | GtkCheckMenuItem *shorten_menu; | 206 | /** |
207 | * FIXME... | ||
208 | */ | ||
209 | static GtkTreeModel *tm; | ||
172 | 210 | ||
173 | GtkTreeStore *ts; | 211 | /** |
174 | GtkListStore *ls; | 212 | * FIXME... |
175 | GtkTreeModel *tm; | 213 | */ |
176 | GtkTreeView *tv; | 214 | static GtkTreeView *tv; |
215 | |||
216 | /** | ||
217 | * FIXME: not good for multi-zone system we have right now... | ||
218 | */ | ||
219 | static struct GNUNET_CRYPTO_RsaPrivateKey *pkey; | ||
220 | |||
221 | /** | ||
222 | * FIXME: not good for multi-zone system we have right now... | ||
223 | */ | ||
224 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | ||
225 | |||
226 | /** | ||
227 | * FIXME: not good for multi-zone system we have right now... | ||
228 | */ | ||
229 | static struct GNUNET_CRYPTO_ShortHashCode zone; | ||
230 | |||
231 | /** | ||
232 | * FIXME... | ||
233 | */ | ||
234 | static int iteration; | ||
177 | 235 | ||
178 | struct GNUNET_CRYPTO_RsaPrivateKey *pkey; | ||
179 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | ||
180 | 236 | ||
181 | struct GNUNET_CRYPTO_ShortHashCode zone; | ||
182 | int iteration; | ||
183 | }; | ||
184 | 237 | ||
185 | 238 | ||
186 | static void | 239 | static void |
@@ -190,11 +243,12 @@ check_name_validity_and_commit_remove_proc (void *cls, | |||
190 | { | 243 | { |
191 | struct UpdateContext * uc = cls; | 244 | struct UpdateContext * uc = cls; |
192 | unsigned int c; | 245 | unsigned int c; |
246 | |||
193 | if ((GNUNET_OK == success) || (GNUNET_NO == success)) | 247 | if ((GNUNET_OK == success) || (GNUNET_NO == success)) |
194 | { | 248 | { |
195 | for (c = 0; c < uc->rd_count; c++) | 249 | for (c = 0; c < uc->rd_count; c++) |
196 | { | 250 | { |
197 | GNUNET_NAMESTORE_record_create(uc->gns->ns, uc->gns->pkey, | 251 | GNUNET_NAMESTORE_record_create(namestore, pkey, |
198 | uc->name, &uc->rd[c],NULL, NULL); | 252 | uc->name, &uc->rd[c],NULL, NULL); |
199 | GNUNET_free ((void *) uc->rd[c].data); | 253 | GNUNET_free ((void *) uc->rd[c].data); |
200 | } | 254 | } |
@@ -219,7 +273,7 @@ check_name_validity_and_commit_remove_proc (void *cls, | |||
219 | 273 | ||
220 | 274 | ||
221 | static void | 275 | static void |
222 | check_name_validity_and_commit (struct GNUNET_GNS_Context *gns, gchar *path, char * oldname) | 276 | check_name_validity_and_commit (gchar *path, char * oldname) |
223 | { | 277 | { |
224 | GtkTreeIter it; | 278 | GtkTreeIter it; |
225 | GtkTreeIter parent; | 279 | GtkTreeIter parent; |
@@ -244,18 +298,18 @@ check_name_validity_and_commit (struct GNUNET_GNS_Context *gns, gchar *path, cha | |||
244 | char *n_value_color; | 298 | char *n_value_color; |
245 | 299 | ||
246 | 300 | ||
247 | gtk_tree_model_get_iter_from_string(gns->tm, &it, path); | 301 | gtk_tree_model_get_iter_from_string(tm, &it, path); |
248 | 302 | ||
249 | if (FALSE == gtk_tree_model_iter_parent (gns->tm, &parent, &it)) | 303 | if (FALSE == gtk_tree_model_iter_parent (tm, &parent, &it)) |
250 | parent = it; | 304 | parent = it; |
251 | 305 | ||
252 | children = gtk_tree_model_iter_n_children (gns->tm, &parent); | 306 | children = gtk_tree_model_iter_n_children (tm, &parent); |
253 | if (children < 1) | 307 | if (children < 1) |
254 | { | 308 | { |
255 | return; | 309 | return; |
256 | } | 310 | } |
257 | 311 | ||
258 | gtk_tree_model_get(gns->tm, &parent, | 312 | gtk_tree_model_get(tm, &parent, |
259 | GNS_TREESTORE_COL_NAME, &name, | 313 | GNS_TREESTORE_COL_NAME, &name, |
260 | -1); | 314 | -1); |
261 | 315 | ||
@@ -273,12 +327,12 @@ check_name_validity_and_commit (struct GNUNET_GNS_Context *gns, gchar *path, cha | |||
273 | 327 | ||
274 | struct GNUNET_NAMESTORE_RecordData *rd = GNUNET_malloc (records * sizeof (struct GNUNET_NAMESTORE_RecordData)); | 328 | struct GNUNET_NAMESTORE_RecordData *rd = GNUNET_malloc (records * sizeof (struct GNUNET_NAMESTORE_RecordData)); |
275 | 329 | ||
276 | if (FALSE == gtk_tree_model_iter_children (gns->tm, &it, &parent)) | 330 | if (FALSE == gtk_tree_model_iter_children (tm, &it, &parent)) |
277 | return; | 331 | return; |
278 | 332 | ||
279 | for (c = 0; c < children; c++) | 333 | for (c = 0; c < children; c++) |
280 | { | 334 | { |
281 | gtk_tree_model_get(gns->tm, &it, | 335 | gtk_tree_model_get(tm, &it, |
282 | GNS_TREESTORE_COL_NAME, &n_name, | 336 | GNS_TREESTORE_COL_NAME, &n_name, |
283 | GNS_TREESTORE_COL_RECORD_TYPE, &n_type, | 337 | GNS_TREESTORE_COL_RECORD_TYPE, &n_type, |
284 | GNS_TREESTORE_COL_IS_PUBLIC, &n_public, | 338 | GNS_TREESTORE_COL_IS_PUBLIC, &n_public, |
@@ -333,7 +387,7 @@ check_name_validity_and_commit (struct GNUNET_GNS_Context *gns, gchar *path, cha | |||
333 | g_free (n_value); | 387 | g_free (n_value); |
334 | g_free (n_value_color); | 388 | g_free (n_value_color); |
335 | 389 | ||
336 | if (FALSE == gtk_tree_model_iter_next (gns->tm, &it)) | 390 | if (FALSE == gtk_tree_model_iter_next (tm, &it)) |
337 | break; | 391 | break; |
338 | } | 392 | } |
339 | 393 | ||
@@ -351,7 +405,7 @@ check_name_validity_and_commit (struct GNUNET_GNS_Context *gns, gchar *path, cha | |||
351 | GNUNET_assert (children == (records -1)); | 405 | GNUNET_assert (children == (records -1)); |
352 | 406 | ||
353 | /* Append PSEU record */ | 407 | /* Append PSEU record */ |
354 | GtkEntry * entry = GTK_ENTRY (gtk_builder_get_object (gns->builder, "GNUNET_GNS_GTK_pseu_entry")); | 408 | GtkEntry * entry = GTK_ENTRY (GNUNET_SETUP_get_object ("GNUNET_SETUP_gns_pseu_entry")); |
355 | pseu = gtk_entry_get_text (GTK_ENTRY(entry)); | 409 | pseu = gtk_entry_get_text (GTK_ENTRY(entry)); |
356 | if ((NULL != pseu) && (0 != strcmp (PSEU_EMPTY_STR, pseu)) && (0 != strcmp ("", pseu))) | 410 | if ((NULL != pseu) && (0 != strcmp (PSEU_EMPTY_STR, pseu)) && (0 != strcmp ("", pseu))) |
357 | { | 411 | { |
@@ -377,14 +431,13 @@ check_name_validity_and_commit (struct GNUNET_GNS_Context *gns, gchar *path, cha | |||
377 | 431 | ||
378 | /* Remove old entries */ | 432 | /* Remove old entries */ |
379 | struct UpdateContext * uc = GNUNET_malloc (sizeof (struct UpdateContext)); | 433 | struct UpdateContext * uc = GNUNET_malloc (sizeof (struct UpdateContext)); |
380 | uc->gns = gns; | ||
381 | uc->rd = rd; | 434 | uc->rd = rd; |
382 | uc->rd_count = records; | 435 | uc->rd_count = records; |
383 | uc->name = strdup (name); | 436 | uc->name = strdup (name); |
384 | if (oldname != NULL) | 437 | if (oldname != NULL) |
385 | GNUNET_NAMESTORE_record_remove(gns->ns, gns->pkey, oldname, NULL, &check_name_validity_and_commit_remove_proc, uc); | 438 | GNUNET_NAMESTORE_record_remove (namestore, pkey, oldname, NULL, &check_name_validity_and_commit_remove_proc, uc); |
386 | else | 439 | else |
387 | GNUNET_NAMESTORE_record_remove(gns->ns, gns->pkey, name, NULL, &check_name_validity_and_commit_remove_proc, uc); | 440 | GNUNET_NAMESTORE_record_remove (namestore, pkey, name, NULL, &check_name_validity_and_commit_remove_proc, uc); |
388 | g_free (name); | 441 | g_free (name); |
389 | } | 442 | } |
390 | } | 443 | } |
@@ -399,11 +452,6 @@ struct Remove_Context | |||
399 | /** | 452 | /** |
400 | * | 453 | * |
401 | */ | 454 | */ |
402 | struct GNUNET_GNS_Context *gns; | ||
403 | |||
404 | /** | ||
405 | * | ||
406 | */ | ||
407 | char *path; | 455 | char *path; |
408 | }; | 456 | }; |
409 | 457 | ||
@@ -416,10 +464,14 @@ check_name_validity_and_remove_proc (void *cls, | |||
416 | struct Remove_Context *rcc = cls; | 464 | struct Remove_Context *rcc = cls; |
417 | GtkDialog *dialog; | 465 | GtkDialog *dialog; |
418 | GtkTreeIter it; | 466 | GtkTreeIter it; |
467 | |||
419 | if (GNUNET_SYSERR == success) | 468 | if (GNUNET_SYSERR == success) |
420 | { | 469 | { |
421 | char * message = _("Record could not be deleted:"); | 470 | const char * message = _("Record could not be deleted:"); |
422 | dialog = GTK_DIALOG(gtk_message_dialog_new (GTK_WINDOW (rcc->gns->main_window), | 471 | GtkWindow *main_window; |
472 | |||
473 | main_window = GTK_WINDOW (GNUNET_SETUP_get_object ("GNUNET_setup_dialog")); | ||
474 | dialog = GTK_DIALOG(gtk_message_dialog_new (main_window, | ||
423 | GTK_DIALOG_DESTROY_WITH_PARENT, | 475 | GTK_DIALOG_DESTROY_WITH_PARENT, |
424 | GTK_MESSAGE_ERROR, | 476 | GTK_MESSAGE_ERROR, |
425 | GTK_BUTTONS_CLOSE, | 477 | GTK_BUTTONS_CLOSE, |
@@ -427,13 +479,13 @@ check_name_validity_and_remove_proc (void *cls, | |||
427 | message, | 479 | message, |
428 | emsg)); | 480 | emsg)); |
429 | 481 | ||
430 | g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), rcc->gns); | 482 | g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); |
431 | gtk_widget_show_all (GTK_WIDGET(dialog)); | 483 | gtk_widget_show_all (GTK_WIDGET(dialog)); |
432 | } | 484 | } |
433 | else | 485 | else |
434 | { | 486 | { |
435 | gtk_tree_model_get_iter_from_string(rcc->gns->tm, &it, rcc->path); | 487 | gtk_tree_model_get_iter_from_string(tm, &it, rcc->path); |
436 | gtk_tree_store_remove (rcc->gns->ts, &it); | 488 | gtk_tree_store_remove (ts, &it); |
437 | } | 489 | } |
438 | GNUNET_free (rcc->path); | 490 | GNUNET_free (rcc->path); |
439 | GNUNET_free (rcc); | 491 | GNUNET_free (rcc); |
@@ -441,7 +493,7 @@ check_name_validity_and_remove_proc (void *cls, | |||
441 | 493 | ||
442 | 494 | ||
443 | static void | 495 | static void |
444 | check_name_validity_and_remove (struct GNUNET_GNS_Context *gns, gchar *path) | 496 | check_name_validity_and_remove (gchar *path) |
445 | { | 497 | { |
446 | GtkTreeIter it; | 498 | GtkTreeIter it; |
447 | GtkTreeIter parent; | 499 | GtkTreeIter parent; |
@@ -460,18 +512,18 @@ check_name_validity_and_remove (struct GNUNET_GNS_Context *gns, gchar *path) | |||
460 | char *n_value; | 512 | char *n_value; |
461 | char *n_value_color; | 513 | char *n_value_color; |
462 | 514 | ||
463 | gtk_tree_model_get_iter_from_string(gns->tm, &it, path); | 515 | gtk_tree_model_get_iter_from_string(tm, &it, path); |
464 | gtk_tree_model_get(gns->tm, &it, | 516 | gtk_tree_model_get(tm, &it, |
465 | GNS_TREESTORE_COL_NAME, &name, | 517 | GNS_TREESTORE_COL_NAME, &name, |
466 | -1); | 518 | -1); |
467 | 519 | ||
468 | if (TRUE == gtk_tree_model_iter_parent (gns->tm, &parent, &it)) | 520 | if (TRUE == gtk_tree_model_iter_parent (tm, &parent, &it)) |
469 | { | 521 | { |
470 | /* Removing a single record */ | 522 | /* Removing a single record */ |
471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 523 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
472 | "Removing single record for name `%s'\n", name); | 524 | "Removing single record for name `%s'\n", name); |
473 | 525 | ||
474 | gtk_tree_model_get(gns->tm, &it, | 526 | gtk_tree_model_get(tm, &it, |
475 | GNS_TREESTORE_COL_NAME, &n_name, | 527 | GNS_TREESTORE_COL_NAME, &n_name, |
476 | GNS_TREESTORE_COL_RECORD_TYPE, &n_type, | 528 | GNS_TREESTORE_COL_RECORD_TYPE, &n_type, |
477 | GNS_TREESTORE_COL_IS_PUBLIC, &n_public, | 529 | GNS_TREESTORE_COL_IS_PUBLIC, &n_public, |
@@ -512,15 +564,14 @@ check_name_validity_and_remove (struct GNUNET_GNS_Context *gns, gchar *path) | |||
512 | memcpy ((void *) rd.data, n_value, rd.data_size); | 564 | memcpy ((void *) rd.data, n_value, rd.data_size); |
513 | 565 | ||
514 | rcc = GNUNET_malloc(sizeof (struct Remove_Context)); | 566 | rcc = GNUNET_malloc(sizeof (struct Remove_Context)); |
515 | rcc->gns = gns; | ||
516 | rcc->path = strdup (path); | 567 | rcc->path = strdup (path); |
517 | GNUNET_NAMESTORE_record_remove(gns->ns, gns->pkey, name, &rd, &check_name_validity_and_remove_proc, rcc); | 568 | GNUNET_NAMESTORE_record_remove (namestore, pkey, name, &rd, &check_name_validity_and_remove_proc, rcc); |
518 | GNUNET_free ((void *) rd.data); | 569 | GNUNET_free ((void *) rd.data); |
519 | } | 570 | } |
520 | else | 571 | else |
521 | { | 572 | { |
522 | gtk_tree_model_get_iter_from_string(gns->tm, &it, path); | 573 | gtk_tree_model_get_iter_from_string(tm, &it, path); |
523 | gtk_tree_store_remove (gns->ts, &it); | 574 | gtk_tree_store_remove (ts, &it); |
524 | } | 575 | } |
525 | g_free (n_name); | 576 | g_free (n_name); |
526 | g_free (n_exp_color); | 577 | g_free (n_exp_color); |
@@ -532,9 +583,8 @@ check_name_validity_and_remove (struct GNUNET_GNS_Context *gns, gchar *path) | |||
532 | { | 583 | { |
533 | /* Removing the whole name record */ | 584 | /* Removing the whole name record */ |
534 | rcc = GNUNET_malloc(sizeof (struct Remove_Context)); | 585 | rcc = GNUNET_malloc(sizeof (struct Remove_Context)); |
535 | rcc->gns = gns; | ||
536 | rcc->path = strdup (path); | 586 | rcc->path = strdup (path); |
537 | GNUNET_NAMESTORE_record_remove(gns->ns, gns->pkey, name, NULL, &check_name_validity_and_remove_proc, rcc); | 587 | GNUNET_NAMESTORE_record_remove (namestore, pkey, name, NULL, &check_name_validity_and_remove_proc, rcc); |
538 | } | 588 | } |
539 | g_free (name); | 589 | g_free (name); |
540 | } | 590 | } |
@@ -551,12 +601,11 @@ check_name_validity_and_remove (struct GNUNET_GNS_Context *gns, gchar *path) | |||
551 | * @param user_data unused | 601 | * @param user_data unused |
552 | */ | 602 | */ |
553 | void | 603 | void |
554 | GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | 604 | GNUNET_SETUP_gns_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, |
555 | gchar *path, | 605 | gchar *path, |
556 | GtkTreeIter *new_iter, | 606 | GtkTreeIter *new_iter, |
557 | gpointer user_data) | 607 | gpointer user_data) |
558 | { | 608 | { |
559 | struct GNUNET_GNS_Context *gns = user_data; | ||
560 | GtkTreeIter it; | 609 | GtkTreeIter it; |
561 | GtkTreeIter child; | 610 | GtkTreeIter child; |
562 | guint type; | 611 | guint type; |
@@ -567,19 +616,19 @@ GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | |||
567 | void *data; | 616 | void *data; |
568 | size_t data_size; | 617 | size_t data_size; |
569 | 618 | ||
570 | gtk_tree_model_get(GTK_TREE_MODEL(gns->ls), new_iter, 0, &type, -1); | 619 | gtk_tree_model_get(GTK_TREE_MODEL(ls), new_iter, 0, &type, -1); |
571 | gtk_tree_model_get(GTK_TREE_MODEL(gns->ls), new_iter, GNS_TYPE_TO_NAME_LISTSTORE_COLUMN_TYPENAME, &type_str, -1); | 620 | gtk_tree_model_get(GTK_TREE_MODEL(ls), new_iter, GNS_TYPE_TO_NAME_LISTSTORE_COLUMN_TYPENAME, &type_str, -1); |
572 | 621 | ||
573 | 622 | ||
574 | /* check if this is a new record */ | 623 | /* check if this is a new record */ |
575 | gtk_tree_model_get_iter_from_string(gns->tm, &it, path); | 624 | gtk_tree_model_get_iter_from_string(tm, &it, path); |
576 | gtk_tree_model_get(gns->tm, &it, GNS_TREESTORE_COL_IS_RECORD_ROW, &record_row, -1); | 625 | gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_IS_RECORD_ROW, &record_row, -1); |
577 | gtk_tree_model_get(gns->tm, &it, GNS_TREESTORE_COL_NAME, &name_str, -1); | 626 | gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NAME, &name_str, -1); |
578 | 627 | ||
579 | if (GNUNET_YES == record_row) | 628 | if (GNUNET_YES == record_row) |
580 | { | 629 | { |
581 | /* Updating an existing record */ | 630 | /* Updating an existing record */ |
582 | gtk_tree_store_set(gns->ts, &it, | 631 | gtk_tree_store_set(ts, &it, |
583 | GNS_TREESTORE_COL_RECORD_TYPE, type, | 632 | GNS_TREESTORE_COL_RECORD_TYPE, type, |
584 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str, | 633 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str, |
585 | -1); | 634 | -1); |
@@ -588,7 +637,7 @@ GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | |||
588 | { | 637 | { |
589 | /* Adding a new record */ | 638 | /* Adding a new record */ |
590 | 639 | ||
591 | gtk_tree_store_insert_with_values(gns->ts, &child , &it, 0, | 640 | gtk_tree_store_insert_with_values(ts, &child , &it, 0, |
592 | GNS_TREESTORE_COL_NAME, name_str, | 641 | GNS_TREESTORE_COL_NAME, name_str, |
593 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE, | 642 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE, |
594 | GNS_TREESTORE_COL_RECORD_TYPE, type, | 643 | GNS_TREESTORE_COL_RECORD_TYPE, type, |
@@ -599,34 +648,34 @@ GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | |||
599 | GNS_TREESTORE_COL_IS_RECORD_ROW, GNUNET_YES, | 648 | GNS_TREESTORE_COL_IS_RECORD_ROW, GNUNET_YES, |
600 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_YES, | 649 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_YES, |
601 | -1); | 650 | -1); |
602 | gtk_tree_view_expand_row (gns->tv, gtk_tree_model_get_path(gns->tm, &it), 0); | 651 | gtk_tree_view_expand_row (tv, gtk_tree_model_get_path(tm, &it), 0); |
603 | 652 | ||
604 | } | 653 | } |
605 | GNUNET_free (type_str); | 654 | GNUNET_free (type_str); |
606 | 655 | ||
607 | /* check if value is still valid */ | 656 | /* check if value is still valid */ |
608 | gtk_tree_model_get(gns->tm, &it, GNS_TREESTORE_COL_VAL_AS_STR, &value_str, -1); | 657 | gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_VAL_AS_STR, &value_str, -1); |
609 | if (NULL != value_str) | 658 | if (NULL != value_str) |
610 | { | 659 | { |
611 | if (GNUNET_OK != GNUNET_NAMESTORE_string_to_value (type, | 660 | if (GNUNET_OK != GNUNET_NAMESTORE_string_to_value (type, |
612 | value_str, | 661 | value_str, |
613 | &data, | 662 | &data, |
614 | &data_size)) | 663 | &data_size)) |
615 | gtk_tree_store_set (gns->ts, &it, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); | 664 | gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); |
616 | else | 665 | else |
617 | gtk_tree_store_set (gns->ts, &it, GNS_TREESTORE_COL_VAL_COLOR, NULL, -1); | 666 | gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, NULL, -1); |
618 | GNUNET_free (value_str); | 667 | GNUNET_free (value_str); |
619 | } | 668 | } |
620 | else if (NULL == value_str) | 669 | else if (NULL == value_str) |
621 | { | 670 | { |
622 | /* Empty value field */ | 671 | /* Empty value field */ |
623 | if (GNUNET_YES == record_row) | 672 | if (GNUNET_YES == record_row) |
624 | gtk_tree_store_set (gns->ts, &it, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); | 673 | gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); |
625 | else | 674 | else |
626 | gtk_tree_store_set (gns->ts, &child, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); | 675 | gtk_tree_store_set (ts, &child, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); |
627 | } | 676 | } |
628 | 677 | ||
629 | check_name_validity_and_commit (gns, path, NULL); | 678 | check_name_validity_and_commit (path, NULL); |
630 | GNUNET_free_non_null (name_str); | 679 | GNUNET_free_non_null (name_str); |
631 | } | 680 | } |
632 | 681 | ||
@@ -640,19 +689,18 @@ GNUNET_GNS_GTK_type_cellrenderercombo_changed_cb (GtkCellRendererCombo *combo, | |||
640 | * @param user_data unused | 689 | * @param user_data unused |
641 | */ | 690 | */ |
642 | void | 691 | void |
643 | GNUNET_GNS_GTK_ispublic_cellrenderertoggle_toggled_cb (GtkCellRendererToggle *cell_renderer, | 692 | GNUNET_SETUP_gns_ispublic_cellrenderertoggle_toggled_cb (GtkCellRendererToggle *cell_renderer, |
644 | gchar *path, | 693 | gchar *path, |
645 | gpointer user_data) | 694 | gpointer user_data) |
646 | { | 695 | { |
647 | struct GNUNET_GNS_Context *gns = user_data; | ||
648 | GtkTreeIter it; | 696 | GtkTreeIter it; |
649 | gboolean value; | 697 | gboolean value; |
650 | 698 | ||
651 | gtk_tree_model_get_iter_from_string(gns->tm, &it, path); | 699 | gtk_tree_model_get_iter_from_string(tm, &it, path); |
652 | gtk_tree_model_get(gns->tm, &it, GNS_TREESTORE_COL_IS_PUBLIC, &value, -1); | 700 | gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_IS_PUBLIC, &value, -1); |
653 | gtk_tree_store_set(gns->ts, &it, GNS_TREESTORE_COL_IS_PUBLIC, !value, -1); | 701 | gtk_tree_store_set(ts, &it, GNS_TREESTORE_COL_IS_PUBLIC, !value, -1); |
654 | 702 | ||
655 | check_name_validity_and_commit (gns, path, NULL); | 703 | check_name_validity_and_commit (path, NULL); |
656 | } | 704 | } |
657 | 705 | ||
658 | 706 | ||
@@ -757,12 +805,11 @@ convert_string_to_abs_time (const char * text) | |||
757 | * @param user_data unused | 805 | * @param user_data unused |
758 | */ | 806 | */ |
759 | void | 807 | void |
760 | GNUNET_GNS_GTK_expiration_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | 808 | GNUNET_SETUP_gns_expiration_cellrenderertext_edited_cb (GtkCellRendererText *renderer, |
761 | gchar *path, | 809 | gchar *path, |
762 | gchar *new_text, | 810 | gchar *new_text, |
763 | gpointer user_data) | 811 | gpointer user_data) |
764 | { | 812 | { |
765 | struct GNUNET_GNS_Context * gns = user_data; | ||
766 | GtkTreeIter it; | 813 | GtkTreeIter it; |
767 | struct GNUNET_TIME_Absolute abstime; | 814 | struct GNUNET_TIME_Absolute abstime; |
768 | gboolean is_rel; | 815 | gboolean is_rel; |
@@ -770,8 +817,8 @@ GNUNET_GNS_GTK_expiration_cellrenderertext_edited_cb (GtkCellRendererText *rende | |||
770 | 817 | ||
771 | if ((NULL != new_text)) | 818 | if ((NULL != new_text)) |
772 | { | 819 | { |
773 | gtk_tree_model_get_iter_from_string(gns->tm, &it, path); | 820 | gtk_tree_model_get_iter_from_string(tm, &it, path); |
774 | gtk_tree_model_get(gns->tm, &it, | 821 | gtk_tree_model_get(tm, &it, |
775 | GNS_TREESTORE_COL_EXP_TIME_AS_STR, &old_text, | 822 | GNS_TREESTORE_COL_EXP_TIME_AS_STR, &old_text, |
776 | GNS_TREESTORE_COL_EXP_TIME_IS_REL, &is_rel, | 823 | GNS_TREESTORE_COL_EXP_TIME_IS_REL, &is_rel, |
777 | -1); | 824 | -1); |
@@ -787,7 +834,7 @@ GNUNET_GNS_GTK_expiration_cellrenderertext_edited_cb (GtkCellRendererText *rende | |||
787 | { | 834 | { |
788 | if (GNUNET_SYSERR == check_time(new_text)) | 835 | if (GNUNET_SYSERR == check_time(new_text)) |
789 | { | 836 | { |
790 | gtk_tree_store_set (gns->ts, &it, | 837 | gtk_tree_store_set (ts, &it, |
791 | GNS_TREESTORE_COL_EXP_TIME_AS_STR, new_text, | 838 | GNS_TREESTORE_COL_EXP_TIME_AS_STR, new_text, |
792 | GNS_TREESTORE_COL_EXP_TIME_COLOR, "red", | 839 | GNS_TREESTORE_COL_EXP_TIME_COLOR, "red", |
793 | GNS_TREESTORE_COL_EXP_TIME, 0, | 840 | GNS_TREESTORE_COL_EXP_TIME, 0, |
@@ -805,12 +852,12 @@ GNUNET_GNS_GTK_expiration_cellrenderertext_edited_cb (GtkCellRendererText *rende | |||
805 | abstime = convert_string_to_abs_time(new_text); | 852 | abstime = convert_string_to_abs_time(new_text); |
806 | } | 853 | } |
807 | } | 854 | } |
808 | gtk_tree_store_set (gns->ts, &it, | 855 | gtk_tree_store_set (ts, &it, |
809 | GNS_TREESTORE_COL_EXP_TIME_AS_STR, new_text, | 856 | GNS_TREESTORE_COL_EXP_TIME_AS_STR, new_text, |
810 | GNS_TREESTORE_COL_EXP_TIME, abstime.abs_value, | 857 | GNS_TREESTORE_COL_EXP_TIME, abstime.abs_value, |
811 | GNS_TREESTORE_COL_EXP_TIME_COLOR, NULL, | 858 | GNS_TREESTORE_COL_EXP_TIME_COLOR, NULL, |
812 | -1); | 859 | -1); |
813 | check_name_validity_and_commit (gns, path, NULL); | 860 | check_name_validity_and_commit (path, NULL); |
814 | } | 861 | } |
815 | } | 862 | } |
816 | 863 | ||
@@ -826,13 +873,12 @@ GNUNET_GNS_GTK_expiration_cellrenderertext_edited_cb (GtkCellRendererText *rende | |||
826 | * @param user_data unused | 873 | * @param user_data unused |
827 | */ | 874 | */ |
828 | void | 875 | void |
829 | GNUNET_GNS_GTK_value_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | 876 | GNUNET_SETUP_gns_value_cellrenderertext_edited_cb (GtkCellRendererText *renderer, |
830 | gchar *path, | 877 | gchar *path, |
831 | gchar *new_text, | 878 | gchar *new_text, |
832 | gpointer user_data) | 879 | gpointer user_data) |
833 | { | 880 | { |
834 | struct GNUNET_GNS_Context *gns = user_data; | 881 | GtkTreeModel *tm = GTK_TREE_MODEL(ts); |
835 | GtkTreeModel *tm = GTK_TREE_MODEL(gns->ts); | ||
836 | GtkTreeIter it; | 882 | GtkTreeIter it; |
837 | size_t data_size; | 883 | size_t data_size; |
838 | void * data; | 884 | void * data; |
@@ -858,18 +904,18 @@ GNUNET_GNS_GTK_value_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | |||
858 | } | 904 | } |
859 | 905 | ||
860 | if (GNUNET_OK == GNUNET_NAMESTORE_string_to_value (type, | 906 | if (GNUNET_OK == GNUNET_NAMESTORE_string_to_value (type, |
861 | new_text, | 907 | new_text, |
862 | &data, | 908 | &data, |
863 | &data_size)) | 909 | &data_size)) |
864 | { | 910 | { |
865 | gtk_tree_store_set (gns->ts, &it, GNS_TREESTORE_COL_VAL_COLOR, NULL, -1); | 911 | gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, NULL, -1); |
866 | gtk_tree_store_set (gns->ts, &it, GNS_TREESTORE_COL_VAL_AS_STR, new_text, -1); | 912 | gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_AS_STR, new_text, -1); |
867 | check_name_validity_and_commit (gns, path, NULL); | 913 | check_name_validity_and_commit (path, NULL); |
868 | } | 914 | } |
869 | else | 915 | else |
870 | { | 916 | { |
871 | gtk_tree_store_set (gns->ts, &it, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); | 917 | gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_COLOR, "red", -1); |
872 | gtk_tree_store_set (gns->ts, &it, GNS_TREESTORE_COL_VAL_AS_STR, new_text, -1); | 918 | gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_VAL_AS_STR, new_text, -1); |
873 | } | 919 | } |
874 | } | 920 | } |
875 | } | 921 | } |
@@ -885,15 +931,14 @@ GNUNET_GNS_GTK_value_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | |||
885 | * @param user_data unused | 931 | * @param user_data unused |
886 | */ | 932 | */ |
887 | void | 933 | void |
888 | GNUNET_GNS_GTK_name_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | 934 | GNUNET_SETUP_gns_name_cellrenderertext_edited_cb (GtkCellRendererText *renderer, |
889 | gchar *path, | 935 | gchar *path, |
890 | gchar *new_text, | 936 | gchar *new_text, |
891 | gpointer user_data) | 937 | gpointer user_data) |
892 | { | 938 | { |
893 | struct GNUNET_GNS_Context *gns = user_data; | ||
894 | GtkTreeIter it; | 939 | GtkTreeIter it; |
895 | GtkTreeIter child; | 940 | GtkTreeIter child; |
896 | GtkTreeModel *tm = GTK_TREE_MODEL(gns->ts); | 941 | GtkTreeModel *tm = GTK_TREE_MODEL(ts); |
897 | int not_dummy; | 942 | int not_dummy; |
898 | char *name; | 943 | char *name; |
899 | 944 | ||
@@ -908,16 +953,16 @@ GNUNET_GNS_GTK_name_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | |||
908 | if (not_dummy == GNUNET_NO) | 953 | if (not_dummy == GNUNET_NO) |
909 | { | 954 | { |
910 | /* update name */ | 955 | /* update name */ |
911 | gtk_tree_store_set (gns->ts, &it, | 956 | gtk_tree_store_set (ts, &it, |
912 | GNS_TREESTORE_COL_NAME, new_text, | 957 | GNS_TREESTORE_COL_NAME, new_text, |
913 | GNS_TREESTORE_COL_RECORD_TYPE, 0, | 958 | GNS_TREESTORE_COL_RECORD_TYPE, 0, |
914 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, _(NEW_RECORD_STR), | 959 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, _(NEW_RECORD_STR), |
915 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_YES, | 960 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_YES, |
916 | -1); | 961 | -1); |
917 | check_name_validity_and_commit (gns, gtk_tree_model_get_string_from_iter(gns->tm, &it), name); | 962 | check_name_validity_and_commit (gtk_tree_model_get_string_from_iter(tm, &it), name); |
918 | 963 | ||
919 | /* add a new dummy line */ | 964 | /* add a new dummy line */ |
920 | gtk_tree_store_insert_with_values (gns->ts, &it,NULL, 0, | 965 | gtk_tree_store_insert_with_values (ts, &it,NULL, 0, |
921 | GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR), | 966 | GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR), |
922 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE, | 967 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE, |
923 | GNS_TREESTORE_COL_RECORD_TYPE, 1, | 968 | GNS_TREESTORE_COL_RECORD_TYPE, 1, |
@@ -928,32 +973,32 @@ GNUNET_GNS_GTK_name_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | |||
928 | else | 973 | else |
929 | { | 974 | { |
930 | /* update name */ | 975 | /* update name */ |
931 | gtk_tree_store_set (gns->ts, &it, GNS_TREESTORE_COL_NAME, new_text, -1); | 976 | gtk_tree_store_set (ts, &it, GNS_TREESTORE_COL_NAME, new_text, -1); |
932 | 977 | ||
933 | if (TRUE == gtk_tree_model_iter_children (gns->tm, &child, &it)) | 978 | if (TRUE == gtk_tree_model_iter_children (tm, &child, &it)) |
934 | { | 979 | { |
935 | do | 980 | do |
936 | { | 981 | { |
937 | gtk_tree_store_set (gns->ts, &child, | 982 | gtk_tree_store_set (ts, &child, |
938 | GNS_TREESTORE_COL_NAME, &new_text, | 983 | GNS_TREESTORE_COL_NAME, &new_text, |
939 | -1); | 984 | -1); |
940 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New text for `%s' is `%s'\n", path, new_text); | 985 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New text for `%s' is `%s'\n", path, new_text); |
941 | } | 986 | } |
942 | while (TRUE == gtk_tree_model_iter_next (gns->tm, &child)); | 987 | while (TRUE == gtk_tree_model_iter_next (tm, &child)); |
943 | } | 988 | } |
944 | 989 | ||
945 | check_name_validity_and_commit (gns, gtk_tree_model_get_string_from_iter(gns->tm, &it), name); | 990 | check_name_validity_and_commit (gtk_tree_model_get_string_from_iter(tm, &it), name); |
946 | } | 991 | } |
947 | 992 | ||
948 | if (GNUNET_SYSERR == GNUNET_NAMESTORE_check_name (new_text)) | 993 | if (GNUNET_SYSERR == GNUNET_NAMESTORE_check_name (new_text)) |
949 | { | 994 | { |
950 | gtk_tree_store_set (gns->ts, &it, | 995 | gtk_tree_store_set (ts, &it, |
951 | GNS_TREESTORE_COL_NAME_COLOR, "red", | 996 | GNS_TREESTORE_COL_NAME_COLOR, "red", |
952 | -1); | 997 | -1); |
953 | } | 998 | } |
954 | else | 999 | else |
955 | { | 1000 | { |
956 | gtk_tree_store_set (gns->ts, &it, | 1001 | gtk_tree_store_set (ts, &it, |
957 | GNS_TREESTORE_COL_NAME_COLOR, NULL, | 1002 | GNS_TREESTORE_COL_NAME_COLOR, NULL, |
958 | -1); | 1003 | -1); |
959 | } | 1004 | } |
@@ -971,24 +1016,23 @@ GNUNET_GNS_GTK_name_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | |||
971 | * @return TRUE if a menu was activated | 1016 | * @return TRUE if a menu was activated |
972 | */ | 1017 | */ |
973 | gboolean | 1018 | gboolean |
974 | GNUNET_GNS_GTK_main_treeview_popup_menu_cb (GtkWidget *widget, | 1019 | GNUNET_SETUP_gns_main_treeview_popup_menu_cb (GtkWidget *widget, |
975 | gpointer user_data) | 1020 | gpointer user_data) |
976 | { | 1021 | { |
977 | struct GNUNET_GNS_Context *gns = user_data; | ||
978 | GtkTreeModel *tm; | 1022 | GtkTreeModel *tm; |
979 | GtkTreeIter it; | 1023 | GtkTreeIter it; |
980 | GtkMenu *popup; | 1024 | GtkMenu *popup; |
981 | GtkTreeSelection * ts; | 1025 | GtkTreeSelection * ts; |
982 | int not_dummy; | 1026 | int not_dummy; |
983 | 1027 | ||
984 | ts = gtk_tree_view_get_selection(gns->tv); | 1028 | ts = gtk_tree_view_get_selection(tv); |
985 | if (! gtk_tree_selection_get_selected (ts, &tm, &it)) | 1029 | if (! gtk_tree_selection_get_selected (ts, &tm, &it)) |
986 | return TRUE; | 1030 | return TRUE; |
987 | gtk_tree_model_get(gns->tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, -1); | 1031 | gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, -1); |
988 | if (GNUNET_NO == not_dummy) | 1032 | if (GNUNET_NO == not_dummy) |
989 | return TRUE; | 1033 | return TRUE; |
990 | 1034 | ||
991 | popup = GTK_MENU(gtk_builder_get_object (gns->builder, "GNUNET_GNS_GTK_delete_popup_menu")); | 1035 | popup = GTK_MENU (GNUNET_SETUP_get_object ("GNUNET_SETUP_gns_delete_popup_menu")); |
992 | gtk_widget_show_all (GTK_WIDGET(popup)); | 1036 | gtk_widget_show_all (GTK_WIDGET(popup)); |
993 | gtk_menu_popup(popup, NULL, NULL, NULL, NULL, 0, 0); | 1037 | gtk_menu_popup(popup, NULL, NULL, NULL, NULL, 0, 0); |
994 | return TRUE; | 1038 | return TRUE; |
@@ -996,13 +1040,13 @@ GNUNET_GNS_GTK_main_treeview_popup_menu_cb (GtkWidget *widget, | |||
996 | 1040 | ||
997 | 1041 | ||
998 | static void | 1042 | static void |
999 | set_relative_expiration_time (struct GNUNET_GNS_Context *gns, struct GNUNET_TIME_Relative reltime) | 1043 | set_relative_expiration_time (struct GNUNET_TIME_Relative reltime) |
1000 | { | 1044 | { |
1001 | GtkTreeIter it; | 1045 | GtkTreeIter it; |
1002 | GtkTreeIter parent; | 1046 | GtkTreeIter parent; |
1003 | GtkCellRendererText *renderer; | 1047 | GtkCellRendererText *renderer; |
1004 | GtkTreeModel *tm; | 1048 | GtkTreeModel *tm; |
1005 | GtkTreeSelection * ts = gtk_tree_view_get_selection(gns->tv); | 1049 | GtkTreeSelection * ts = gtk_tree_view_get_selection(tv); |
1006 | gboolean has_parent; | 1050 | gboolean has_parent; |
1007 | struct GNUNET_TIME_Absolute abstime; | 1051 | struct GNUNET_TIME_Absolute abstime; |
1008 | char *path; | 1052 | char *path; |
@@ -1024,76 +1068,75 @@ set_relative_expiration_time (struct GNUNET_GNS_Context *gns, struct GNUNET_TIME | |||
1024 | abstime = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), reltime); | 1068 | abstime = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), reltime); |
1025 | 1069 | ||
1026 | /* this is a single record */ | 1070 | /* this is a single record */ |
1027 | renderer = GTK_CELL_RENDERER_TEXT((gtk_builder_get_object (gns->builder, "GNUNET_GNS_GTK_name_cellrenderertext"))); | 1071 | renderer = GTK_CELL_RENDERER_TEXT((GNUNET_SETUP_get_object ("GNUNET_SETUP_gns_name_cellrenderertext"))); |
1028 | path = gtk_tree_model_get_string_from_iter (tm, &it); | 1072 | path = gtk_tree_model_get_string_from_iter (tm, &it); |
1029 | GNUNET_GNS_GTK_expiration_cellrenderertext_edited_cb (renderer, | 1073 | GNUNET_SETUP_gns_expiration_cellrenderertext_edited_cb (renderer, |
1030 | path, | 1074 | path, |
1031 | convert_time_to_string (abstime), | 1075 | convert_time_to_string (abstime), |
1032 | gns); | 1076 | NULL); |
1033 | } | 1077 | } |
1034 | 1078 | ||
1035 | 1079 | ||
1036 | gboolean | 1080 | gboolean |
1037 | GNUNET_GNS_GTK_main_treeview_popup_menu_exp1d_cb (GtkWidget *widget, | 1081 | GNUNET_SETUP_gns_main_treeview_popup_menu_exp1d_cb (GtkWidget *widget, |
1038 | gpointer user_data) | 1082 | gpointer user_data) |
1039 | { | 1083 | { |
1040 | set_relative_expiration_time (user_data, GNUNET_TIME_UNIT_DAYS); | 1084 | set_relative_expiration_time (GNUNET_TIME_UNIT_DAYS); |
1041 | return TRUE; | 1085 | return TRUE; |
1042 | } | 1086 | } |
1043 | 1087 | ||
1044 | 1088 | ||
1045 | gboolean | 1089 | gboolean |
1046 | GNUNET_GNS_GTK_main_treeview_popup_menu_exp1w_cb (GtkWidget *widget, | 1090 | GNUNET_SETUP_gns_main_treeview_popup_menu_exp1w_cb (GtkWidget *widget, |
1047 | gpointer user_data) | 1091 | gpointer user_data) |
1048 | { | 1092 | { |
1049 | set_relative_expiration_time (user_data, GNUNET_TIME_UNIT_WEEKS); | 1093 | set_relative_expiration_time (GNUNET_TIME_UNIT_WEEKS); |
1050 | return TRUE; | 1094 | return TRUE; |
1051 | } | 1095 | } |
1052 | 1096 | ||
1053 | 1097 | ||
1054 | gboolean | 1098 | gboolean |
1055 | GNUNET_GNS_GTK_main_treeview_popup_menu_exp1y_cb (GtkWidget *widget, | 1099 | GNUNET_SETUP_gns_main_treeview_popup_menu_exp1y_cb (GtkWidget *widget, |
1056 | gpointer user_data) | 1100 | gpointer user_data) |
1057 | { | 1101 | { |
1058 | set_relative_expiration_time (user_data, GNUNET_TIME_UNIT_YEARS); | 1102 | set_relative_expiration_time (GNUNET_TIME_UNIT_YEARS); |
1059 | return TRUE; | 1103 | return TRUE; |
1060 | } | 1104 | } |
1061 | 1105 | ||
1062 | 1106 | ||
1063 | gboolean | 1107 | gboolean |
1064 | GNUNET_GNS_GTK_main_treeview_popup_menu_expinf_cb (GtkWidget *widget, | 1108 | GNUNET_SETUP_gns_main_treeview_popup_menu_expinf_cb (GtkWidget *widget, |
1065 | gpointer user_data) | 1109 | gpointer user_data) |
1066 | { | 1110 | { |
1067 | set_relative_expiration_time (user_data, GNUNET_TIME_UNIT_FOREVER_REL); | 1111 | set_relative_expiration_time (GNUNET_TIME_UNIT_FOREVER_REL); |
1068 | return TRUE; | 1112 | return TRUE; |
1069 | } | 1113 | } |
1070 | 1114 | ||
1071 | 1115 | ||
1072 | gboolean | 1116 | gboolean |
1073 | GNUNET_GNS_GTK_main_treeview_button_press_popup_menu_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data) | 1117 | GNUNET_SETUP_gns_main_treeview_button_press_popup_menu_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data) |
1074 | { | 1118 | { |
1075 | /* Check for right click*/ | 1119 | /* Check for right click*/ |
1076 | if (NULL == widget) | 1120 | if (NULL == widget) |
1077 | return FALSE; | 1121 | return FALSE; |
1078 | if (event->type == GDK_BUTTON_PRESS && event->button == 3) | 1122 | if (event->type == GDK_BUTTON_PRESS && event->button == 3) |
1079 | GNUNET_GNS_GTK_main_treeview_popup_menu_cb (widget, user_data); | 1123 | GNUNET_SETUP_gns_main_treeview_popup_menu_cb (widget, user_data); |
1080 | return FALSE; | 1124 | return FALSE; |
1081 | } | 1125 | } |
1082 | 1126 | ||
1083 | 1127 | ||
1084 | gboolean | 1128 | gboolean |
1085 | GNUNET_GNS_GTK_main_treeview_key_press_popup_menu_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data) | 1129 | GNUNET_SETUP_gns_main_treeview_key_press_popup_menu_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data) |
1086 | { | 1130 | { |
1087 | /* Check for delete key */ | 1131 | /* Check for delete key */ |
1088 | if ((event->type == GDK_KEY_PRESS) && (GDK_KEY_Delete == event->keyval)) | 1132 | if ((event->type == GDK_KEY_PRESS) && (GDK_KEY_Delete == event->keyval)) |
1089 | GNUNET_GNS_GTK_main_treeview_popup_menu_cb (widget, user_data); | 1133 | GNUNET_SETUP_gns_main_treeview_popup_menu_cb (widget, user_data); |
1090 | return FALSE; | 1134 | return FALSE; |
1091 | } | 1135 | } |
1092 | 1136 | ||
1093 | 1137 | ||
1094 | struct ZoneIteration_Context | 1138 | struct ZoneIteration_Context |
1095 | { | 1139 | { |
1096 | struct GNUNET_GNS_Context *gns; | ||
1097 | struct GNUNET_CRYPTO_ShortHashCode zone; | 1140 | struct GNUNET_CRYPTO_ShortHashCode zone; |
1098 | struct GNUNET_NAMESTORE_ZoneIterator * it; | 1141 | struct GNUNET_NAMESTORE_ZoneIterator * it; |
1099 | char *label; | 1142 | char *label; |
@@ -1101,25 +1144,24 @@ struct ZoneIteration_Context | |||
1101 | 1144 | ||
1102 | 1145 | ||
1103 | void | 1146 | void |
1104 | GNUNET_GNS_GTK_delete_popup_menu_delete_cb (GtkMenuItem *menuitem, | 1147 | GNUNET_SETUP_gns_delete_popup_menu_delete_cb (GtkMenuItem *menuitem, |
1105 | gpointer user_data) | 1148 | gpointer user_data) |
1106 | { | 1149 | { |
1107 | struct GNUNET_GNS_Context *gns = user_data; | ||
1108 | GtkTreeIter it; | 1150 | GtkTreeIter it; |
1109 | GtkTreeModel *tm; | 1151 | GtkTreeModel *tm; |
1110 | GtkTreeSelection * ts; | 1152 | GtkTreeSelection * ts; |
1111 | int not_dummy; | 1153 | int not_dummy; |
1112 | char *path; | 1154 | char *path; |
1113 | 1155 | ||
1114 | ts = gtk_tree_view_get_selection(gns->tv); | 1156 | ts = gtk_tree_view_get_selection(tv); |
1115 | if (gtk_tree_selection_get_selected (ts, &tm, &it)) | 1157 | if (gtk_tree_selection_get_selected (ts, &tm, &it)) |
1116 | { | 1158 | { |
1117 | gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, -1); | 1159 | gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, -1); |
1118 | if (GNUNET_NO == not_dummy) | 1160 | if (GNUNET_NO == not_dummy) |
1119 | return; /* do not delete the dummy line */ | 1161 | return; /* do not delete the dummy line */ |
1120 | 1162 | ||
1121 | path = gtk_tree_model_get_string_from_iter (gns->tm, &it); | 1163 | path = gtk_tree_model_get_string_from_iter (tm, &it); |
1122 | check_name_validity_and_remove(gns, path); | 1164 | check_name_validity_and_remove(path); |
1123 | g_free (path); | 1165 | g_free (path); |
1124 | } | 1166 | } |
1125 | } | 1167 | } |
@@ -1140,7 +1182,7 @@ zone_iteration_proc (void *cls, | |||
1140 | GtkEntry *pseu_entry; | 1182 | GtkEntry *pseu_entry; |
1141 | int c; | 1183 | int c; |
1142 | int time_is_relative; | 1184 | int time_is_relative; |
1143 | 1185 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; | |
1144 | char *exp; | 1186 | char *exp; |
1145 | char *val; | 1187 | char *val; |
1146 | char * type_str; | 1188 | char * type_str; |
@@ -1150,28 +1192,27 @@ zone_iteration_proc (void *cls, | |||
1150 | GNUNET_assert (zc_ctx != NULL); | 1192 | GNUNET_assert (zc_ctx != NULL); |
1151 | if ((NULL == zone_key) && (NULL == name)) | 1193 | if ((NULL == zone_key) && (NULL == name)) |
1152 | { | 1194 | { |
1153 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; | ||
1154 | GNUNET_CRYPTO_short_hash_to_enc(&zc_ctx->zone, &shenc); | 1195 | GNUNET_CRYPTO_short_hash_to_enc(&zc_ctx->zone, &shenc); |
1155 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone `%s 'iteration done\n", &shenc); | 1196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone `%s 'iteration done\n", &shenc); |
1156 | pseu_entry = GTK_ENTRY((gtk_builder_get_object (zc_ctx->gns->builder, "GNUNET_GNS_GTK_pseu_entry"))); | 1197 | pseu_entry = GTK_ENTRY((GNUNET_SETUP_get_object ("GNUNET_SETUP_gns_pseu_entry"))); |
1157 | if (zc_ctx->label == NULL) | 1198 | if (zc_ctx->label == NULL) |
1158 | GNUNET_asprintf(&zc_ctx->label, "%s", PSEU_EMPTY_STR); | 1199 | GNUNET_asprintf(&zc_ctx->label, "%s", PSEU_EMPTY_STR); |
1159 | gtk_entry_set_text (pseu_entry, zc_ctx->label); | 1200 | gtk_entry_set_text (pseu_entry, zc_ctx->label); |
1160 | zc_ctx->gns->iteration = GNUNET_NO; | 1201 | iteration = GNUNET_NO; |
1161 | GNUNET_free (zc_ctx->label); | 1202 | GNUNET_free (zc_ctx->label); |
1162 | GNUNET_free (zc_ctx); | 1203 | GNUNET_free (zc_ctx); |
1204 | |||
1205 | /* FIXME: hide message 'loading' and make tree view visible! */ | ||
1206 | |||
1163 | return; | 1207 | return; |
1164 | } | 1208 | } |
1165 | 1209 | ||
1166 | 1210 | ||
1167 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; | ||
1168 | GNUNET_CRYPTO_short_hash_to_enc(&zc_ctx->zone, &shenc); | 1211 | GNUNET_CRYPTO_short_hash_to_enc(&zc_ctx->zone, &shenc); |
1169 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone `%s' iteration result `%s', %u records\n", | 1212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Zone `%s' iteration result `%s', %u records\n", |
1170 | &shenc, name, rd_count); | 1213 | &shenc, name, rd_count); |
1171 | 1214 | gtk_tree_store_append (ts, &iter_name, NULL); | |
1172 | GNUNET_assert(GTK_IS_TREE_STORE(zc_ctx->gns->ts)); | 1215 | gtk_tree_store_set(ts, &iter_name, |
1173 | gtk_tree_store_append(zc_ctx->gns->ts, &iter_name, NULL); | ||
1174 | gtk_tree_store_set(zc_ctx->gns->ts, &iter_name, | ||
1175 | GNS_TREESTORE_COL_NAME, name, | 1216 | GNS_TREESTORE_COL_NAME, name, |
1176 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE, | 1217 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE, |
1177 | GNS_TREESTORE_COL_RECORD_TYPE, 0, | 1218 | GNS_TREESTORE_COL_RECORD_TYPE, 0, |
@@ -1182,7 +1223,7 @@ zone_iteration_proc (void *cls, | |||
1182 | 1223 | ||
1183 | if (GNUNET_SYSERR == GNUNET_NAMESTORE_check_name (name)) | 1224 | if (GNUNET_SYSERR == GNUNET_NAMESTORE_check_name (name)) |
1184 | { | 1225 | { |
1185 | gtk_tree_store_set (zc_ctx->gns->ts, &iter_name, | 1226 | gtk_tree_store_set (ts, &iter_name, |
1186 | GNS_TREESTORE_COL_NAME_COLOR, "red", | 1227 | GNS_TREESTORE_COL_NAME_COLOR, "red", |
1187 | -1); | 1228 | -1); |
1188 | } | 1229 | } |
@@ -1237,22 +1278,22 @@ zone_iteration_proc (void *cls, | |||
1237 | if ((0 ==strcmp (name, ROOT_STR)) && (GNUNET_NAMESTORE_TYPE_PSEU == rd[c].record_type)) | 1278 | if ((0 ==strcmp (name, ROOT_STR)) && (GNUNET_NAMESTORE_TYPE_PSEU == rd[c].record_type)) |
1238 | { | 1279 | { |
1239 | zc_ctx->label = strdup(val); | 1280 | zc_ctx->label = strdup(val); |
1240 | zc_ctx->gns->iteration = GNUNET_YES; | 1281 | iteration = GNUNET_YES; |
1241 | } | 1282 | } |
1242 | else | 1283 | else |
1243 | { | 1284 | { |
1244 | gtk_tree_store_insert_with_values(zc_ctx->gns->ts, &iter_record , &iter_name, 0, | 1285 | gtk_tree_store_insert_with_values (ts, &iter_record , &iter_name, 0, |
1245 | GNS_TREESTORE_COL_NAME, name, | 1286 | GNS_TREESTORE_COL_NAME, name, |
1246 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE, | 1287 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, FALSE, |
1247 | GNS_TREESTORE_COL_RECORD_TYPE, rd[c].record_type, | 1288 | GNS_TREESTORE_COL_RECORD_TYPE, rd[c].record_type, |
1248 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str, | 1289 | GNS_TREESTORE_COL_RECORD_TYPE_AS_STR, type_str, |
1249 | GNS_TREESTORE_COL_IS_PUBLIC, public, | 1290 | GNS_TREESTORE_COL_IS_PUBLIC, public, |
1250 | GNS_TREESTORE_COL_EXP_TIME, exp_t, | 1291 | GNS_TREESTORE_COL_EXP_TIME, exp_t, |
1251 | GNS_TREESTORE_COL_EXP_TIME_AS_STR, exp, | 1292 | GNS_TREESTORE_COL_EXP_TIME_AS_STR, exp, |
1252 | GNS_TREESTORE_COL_EXP_TIME_IS_REL, time_is_relative, | 1293 | GNS_TREESTORE_COL_EXP_TIME_IS_REL, time_is_relative, |
1253 | GNS_TREESTORE_COL_VAL_AS_STR, val, | 1294 | GNS_TREESTORE_COL_VAL_AS_STR, val, |
1254 | GNS_TREESTORE_COL_IS_RECORD_ROW, GNUNET_YES, | 1295 | GNS_TREESTORE_COL_IS_RECORD_ROW, GNUNET_YES, |
1255 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_YES, | 1296 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_YES, |
1256 | -1); | 1297 | -1); |
1257 | } | 1298 | } |
1258 | GNUNET_free (type_str); | 1299 | GNUNET_free (type_str); |
@@ -1264,57 +1305,24 @@ zone_iteration_proc (void *cls, | |||
1264 | } | 1305 | } |
1265 | 1306 | ||
1266 | 1307 | ||
1267 | /** | ||
1268 | * The zone treeview was realized. Setup the model. | ||
1269 | * | ||
1270 | * @param widget the widget | ||
1271 | * @param user_data unused | ||
1272 | */ | ||
1273 | void | ||
1274 | GNUNET_GNS_GTK_main_treeview_realize_cb (GtkWidget *widget, | ||
1275 | gpointer user_data) | ||
1276 | { | ||
1277 | struct GNUNET_GNS_Context *gns = user_data; | ||
1278 | struct ZoneIteration_Context *zc_ctx; | ||
1279 | GtkTreeIter toplevel; | ||
1280 | |||
1281 | /* Append a top level row and leave it empty */ | ||
1282 | gtk_tree_store_insert_with_values(gns->ts, &toplevel, NULL, 0, | ||
1283 | GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR), | ||
1284 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE, | ||
1285 | GNS_TREESTORE_COL_RECORD_TYPE, 1, | ||
1286 | GNS_TREESTORE_COL_IS_RECORD_ROW, GNUNET_NO, | ||
1287 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_NO, | ||
1288 | -1); | ||
1289 | |||
1290 | zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context)); | ||
1291 | zc_ctx->gns = user_data; | ||
1292 | zc_ctx->zone = gns->zone; | ||
1293 | zc_ctx->it = GNUNET_NAMESTORE_zone_iteration_start(gns->ns, &gns->zone, | ||
1294 | GNUNET_NAMESTORE_RF_NONE, | ||
1295 | GNUNET_NAMESTORE_RF_NONE, | ||
1296 | &zone_iteration_proc, | ||
1297 | zc_ctx); | ||
1298 | } | ||
1299 | |||
1300 | |||
1301 | |||
1302 | static void | 1308 | static void |
1303 | pseu_change_cont (void *cls, | 1309 | pseu_change_cont (void *cls, |
1304 | int32_t success, | 1310 | int32_t success, |
1305 | const char *emsg) | 1311 | const char *emsg) |
1306 | { | 1312 | { |
1307 | struct GNUNET_GNS_Context *gns = cls; | ||
1308 | GtkWidget *dialog; | 1313 | GtkWidget *dialog; |
1309 | if (GNUNET_SYSERR == success) | 1314 | if (GNUNET_SYSERR == success) |
1310 | { | 1315 | { |
1311 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("New Pseudonym could not be set: `%s'\n"), emsg); | 1316 | GtkWindow *main_window; |
1312 | dialog = gtk_message_dialog_new (GTK_WINDOW (gns->main_window), | 1317 | |
1313 | GTK_DIALOG_DESTROY_WITH_PARENT, | 1318 | main_window = GTK_WINDOW (GNUNET_SETUP_get_object ("GNUNET_setup_dialog")); |
1314 | GTK_MESSAGE_ERROR, | 1319 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("New Pseudonym could not be set: `%s'\n"), emsg); |
1315 | GTK_BUTTONS_CLOSE, | 1320 | dialog = gtk_message_dialog_new (main_window, |
1316 | _("New Pseudonym could not be set: `%s'\n"), | 1321 | GTK_DIALOG_DESTROY_WITH_PARENT, |
1317 | emsg); | 1322 | GTK_MESSAGE_ERROR, |
1323 | GTK_BUTTONS_CLOSE, | ||
1324 | _("New Pseudonym could not be set: `%s'\n"), | ||
1325 | emsg); | ||
1318 | g_signal_connect_swapped (dialog, "response", | 1326 | g_signal_connect_swapped (dialog, "response", |
1319 | G_CALLBACK (gtk_widget_destroy), | 1327 | G_CALLBACK (gtk_widget_destroy), |
1320 | dialog); | 1328 | dialog); |
@@ -1323,41 +1331,8 @@ pseu_change_cont (void *cls, | |||
1323 | } | 1331 | } |
1324 | 1332 | ||
1325 | 1333 | ||
1326 | /** | ||
1327 | * Task run on shutdown. | ||
1328 | * | ||
1329 | * @param cls unused | ||
1330 | * @param tc scheduler context, unused | ||
1331 | */ | ||
1332 | static void | ||
1333 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1334 | { | ||
1335 | |||
1336 | struct GNUNET_GNS_Context *gns = cls; | ||
1337 | if (NULL == gns) | ||
1338 | return; | ||
1339 | if (NULL != gns->ns) | ||
1340 | { | ||
1341 | GNUNET_NAMESTORE_disconnect (gns->ns, GNUNET_NO); | ||
1342 | gns->ns = NULL; | ||
1343 | } | ||
1344 | if (NULL != gns->pkey) | ||
1345 | { | ||
1346 | GNUNET_CRYPTO_rsa_key_free (gns->pkey); | ||
1347 | gns->pkey = NULL; | ||
1348 | } | ||
1349 | if (NULL != zonekey_directory) | ||
1350 | { | ||
1351 | GNUNET_free (zonekey_directory); | ||
1352 | zonekey_directory = NULL; | ||
1353 | } | ||
1354 | GNUNET_free (gns); | ||
1355 | } | ||
1356 | |||
1357 | |||
1358 | |||
1359 | gboolean | 1334 | gboolean |
1360 | GNUNET_GNS_GTK_pseu_entry_enter_cb (GtkWidget *widget, | 1335 | GNUNET_SETUP_gns_pseu_entry_enter_cb (GtkWidget *widget, |
1361 | GdkEvent *event, | 1336 | GdkEvent *event, |
1362 | gpointer user_data) | 1337 | gpointer user_data) |
1363 | { | 1338 | { |
@@ -1383,15 +1358,14 @@ GNUNET_GNS_GTK_pseu_entry_enter_cb (GtkWidget *widget, | |||
1383 | * @param user_data unused | 1358 | * @param user_data unused |
1384 | */ | 1359 | */ |
1385 | void | 1360 | void |
1386 | GNUNET_GNS_GTK_pseu_entry_changed_cb (GtkEditable *editable, | 1361 | GNUNET_SETUP_gns_pseu_entry_changed_cb (GtkEditable *editable, |
1387 | gpointer user_data) | 1362 | gpointer user_data) |
1388 | { | 1363 | { |
1389 | struct GNUNET_GNS_Context *gns = user_data; | ||
1390 | struct GNUNET_NAMESTORE_RecordData rd; | 1364 | struct GNUNET_NAMESTORE_RecordData rd; |
1391 | const gchar * pseu; | 1365 | const gchar * pseu; |
1392 | 1366 | ||
1393 | pseu = gtk_entry_get_text (GTK_ENTRY(editable)); | 1367 | pseu = gtk_entry_get_text (GTK_ENTRY(editable)); |
1394 | if ((pseu != NULL) && (0 != strcmp (pseu, PSEU_EMPTY_STR)) && (0 != strcmp ("", pseu)) && (GNUNET_NO == gns->iteration)) | 1368 | if ((pseu != NULL) && (0 != strcmp (pseu, PSEU_EMPTY_STR)) && (0 != strcmp ("", pseu)) && (GNUNET_NO == iteration)) |
1395 | { | 1369 | { |
1396 | 1370 | ||
1397 | rd.record_type = GNUNET_NAMESTORE_TYPE_PSEU; | 1371 | rd.record_type = GNUNET_NAMESTORE_TYPE_PSEU; |
@@ -1399,7 +1373,7 @@ GNUNET_GNS_GTK_pseu_entry_changed_cb (GtkEditable *editable, | |||
1399 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; | 1373 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; |
1400 | rd.data_size = strlen (pseu) + 1; | 1374 | rd.data_size = strlen (pseu) + 1; |
1401 | rd.data = strdup (pseu); | 1375 | rd.data = strdup (pseu); |
1402 | GNUNET_NAMESTORE_record_create(gns->ns, gns->pkey, "+", &rd, pseu_change_cont, gns); | 1376 | GNUNET_NAMESTORE_record_create (namestore, pkey, "+", &rd, &pseu_change_cont, NULL); |
1403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New Pseudonym is `%s' %u\n", (char *) rd.data, rd.data_size); | 1377 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New Pseudonym is `%s' %u\n", (char *) rd.data, rd.data_size); |
1404 | } | 1378 | } |
1405 | else if ((0 != strcmp (pseu, PSEU_EMPTY_STR)) && ((pseu == NULL) || (0 == strcmp ("", pseu)))) | 1379 | else if ((0 != strcmp (pseu, PSEU_EMPTY_STR)) && ((pseu == NULL) || (0 == strcmp ("", pseu)))) |
@@ -1409,136 +1383,6 @@ GNUNET_GNS_GTK_pseu_entry_changed_cb (GtkEditable *editable, | |||
1409 | 1383 | ||
1410 | } | 1384 | } |
1411 | 1385 | ||
1412 | /** | ||
1413 | * The user toggled the 'autoshort' option. Update the configuration. | ||
1414 | * | ||
1415 | * @param checkmenuitem the menu item | ||
1416 | * @param user_data unused | ||
1417 | */ | ||
1418 | void | ||
1419 | GNUNET_GNS_GTK_autoshort_imagemenuitem_toggled_cb (GtkCheckMenuItem *checkmenuitem, | ||
1420 | gpointer user_data) | ||
1421 | { | ||
1422 | struct GNUNET_GNS_Context *gns = user_data; | ||
1423 | GtkWidget *dialog; | ||
1424 | struct GNUNET_CONFIGURATION_Handle *cfg = (struct GNUNET_CONFIGURATION_Handle *) get_configuration(); | ||
1425 | |||
1426 | gboolean state = gtk_check_menu_item_get_active (gns->shorten_menu); | ||
1427 | if (TRUE == state) | ||
1428 | GNUNET_CONFIGURATION_set_value_string(cfg,"gns", "AUTO_IMPORT_PKEY","YES"); | ||
1429 | else | ||
1430 | GNUNET_CONFIGURATION_set_value_string(cfg,"gns", "AUTO_IMPORT_PKEY","NO"); | ||
1431 | |||
1432 | char * cfgfile = strdup (GNUNET_GTK_main_loop_get_configuration_file(ml)); | ||
1433 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_write(cfg, cfgfile)) | ||
1434 | { | ||
1435 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Changes to autoshorten could not be written to configuration file: `%s'\n"), cfgfile); | ||
1436 | dialog = gtk_message_dialog_new (GTK_WINDOW (gns->main_window), | ||
1437 | GTK_DIALOG_DESTROY_WITH_PARENT, | ||
1438 | GTK_MESSAGE_ERROR, | ||
1439 | GTK_BUTTONS_CLOSE, | ||
1440 | _("Changes to autoshorten option could not be written to configuration file: `%s'\n"), | ||
1441 | cfgfile); | ||
1442 | g_signal_connect_swapped (dialog, "response", | ||
1443 | G_CALLBACK (gtk_widget_destroy), | ||
1444 | dialog); | ||
1445 | gtk_widget_show_all (dialog); | ||
1446 | } | ||
1447 | GNUNET_free (cfgfile); | ||
1448 | } | ||
1449 | |||
1450 | |||
1451 | /** | ||
1452 | * The user selected 'NEW' in the menu. Open a dialog to enter a filename | ||
1453 | * to create a new zone (for editing). | ||
1454 | * | ||
1455 | * @param checkmenuitem the menu item | ||
1456 | * @param user_data unused | ||
1457 | */ | ||
1458 | void | ||
1459 | GNUNET_GNS_GTK_new_imagemenuitem_activate_cb (GtkMenuItem *menuitem, | ||
1460 | gpointer user_data) | ||
1461 | { | ||
1462 | GNUNET_break (0); // FIXME, not implemented | ||
1463 | } | ||
1464 | |||
1465 | |||
1466 | /** | ||
1467 | * Function called from the open-directory dialog upon completion. | ||
1468 | * | ||
1469 | * @param dialog the pseudonym selection dialog | ||
1470 | * @param response_id response code from the dialog | ||
1471 | * @param user_data the builder of the dialog | ||
1472 | */ | ||
1473 | void | ||
1474 | GNUNET_GNS_GTK_zone_open_dialog_response_cb (GtkDialog * dialog, | ||
1475 | gint response_id, | ||
1476 | gpointer user_data) | ||
1477 | { | ||
1478 | char *filename; | ||
1479 | |||
1480 | if (GTK_RESPONSE_OK != response_id) | ||
1481 | { | ||
1482 | gtk_widget_destroy (GTK_WIDGET (dialog)); | ||
1483 | g_object_unref (G_OBJECT (dialog)); | ||
1484 | return; | ||
1485 | } | ||
1486 | filename = GNUNET_GTK_filechooser_get_filename_utf8 (GTK_FILE_CHOOSER (dialog)); | ||
1487 | gtk_widget_destroy (GTK_WIDGET (dialog)); | ||
1488 | g_object_unref (G_OBJECT (dialog)); | ||
1489 | |||
1490 | /* FIXME: move to new zone 'filename' */ | ||
1491 | fprintf (stderr, "Got zone `%s'\n", filename); | ||
1492 | GNUNET_free (filename); | ||
1493 | } | ||
1494 | |||
1495 | |||
1496 | /** | ||
1497 | * The user selected 'OPEN' in the menu. Open a dialog to select | ||
1498 | * a different zonefile (for editing). | ||
1499 | * | ||
1500 | * @param checkmenuitem the menu item | ||
1501 | * @param user_data unused | ||
1502 | */ | ||
1503 | void | ||
1504 | GNUNET_GNS_GTK_open_imagemenuitem_activate_cb (GtkMenuItem *menuitem, | ||
1505 | gpointer user_data) | ||
1506 | { | ||
1507 | GtkWidget *ad; | ||
1508 | GtkBuilder *builder; | ||
1509 | GtkWidget *toplevel; | ||
1510 | GtkFileFilter *ff; | ||
1511 | GtkFileChooser *fc; | ||
1512 | |||
1513 | builder = | ||
1514 | GNUNET_GTK_get_new_builder ("gnunet_gns_gtk_zone_open.glade", NULL); | ||
1515 | if (NULL == builder) | ||
1516 | { | ||
1517 | GNUNET_break (0); | ||
1518 | return; | ||
1519 | } | ||
1520 | /* This file filter could be set with glade if we use gtk3 | ||
1521 | * With gtk2 we have to set it manually */ | ||
1522 | ff = GTK_FILE_FILTER (gtk_builder_get_object | ||
1523 | (builder, "GNUNET_GNS_GTK_zone_open_filefilter")); | ||
1524 | gtk_file_filter_add_pattern (ff, "*.zkey"); | ||
1525 | |||
1526 | ad = GTK_WIDGET (gtk_builder_get_object | ||
1527 | (builder, "GNUNET_GNS_GTK_zone_open_filechooserdialog")); | ||
1528 | |||
1529 | if (GTK_IS_FILE_CHOOSER(ad)) | ||
1530 | { | ||
1531 | fc = GTK_FILE_CHOOSER(ad); | ||
1532 | if (NULL != fc) | ||
1533 | gtk_file_chooser_set_current_folder(fc, zonekey_directory); | ||
1534 | } | ||
1535 | |||
1536 | toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menuitem)); | ||
1537 | if (GTK_IS_WINDOW (toplevel)) | ||
1538 | gtk_window_set_transient_for (GTK_WINDOW (ad), GTK_WINDOW (toplevel)); | ||
1539 | gtk_window_present (GTK_WINDOW (ad)); | ||
1540 | } | ||
1541 | |||
1542 | 1386 | ||
1543 | /** | 1387 | /** |
1544 | * The user clicked on the 'copy' button. Copy the full string | 1388 | * The user clicked on the 'copy' button. Copy the full string |
@@ -1548,7 +1392,7 @@ GNUNET_GNS_GTK_open_imagemenuitem_activate_cb (GtkMenuItem *menuitem, | |||
1548 | * @param user_data unused | 1392 | * @param user_data unused |
1549 | */ | 1393 | */ |
1550 | void | 1394 | void |
1551 | GNUNET_GNS_GTK_public_key_copy_button_clicked_cb (GtkButton *button, | 1395 | GNUNET_SETUP_gns_public_key_copy_button_clicked_cb (GtkButton *button, |
1552 | gpointer user_data) | 1396 | gpointer user_data) |
1553 | { | 1397 | { |
1554 | GtkClipboard *cb; | 1398 | GtkClipboard *cb; |
@@ -1558,160 +1402,127 @@ GNUNET_GNS_GTK_public_key_copy_button_clicked_cb (GtkButton *button, | |||
1558 | } | 1402 | } |
1559 | 1403 | ||
1560 | 1404 | ||
1561 | |||
1562 | /** | 1405 | /** |
1563 | * Callback invoked if the application is supposed to exit (via menu). | 1406 | * Connect to the namestore and initialize the main |
1564 | * | 1407 | * GNS tree view. |
1565 | * @param menuitem the quit menu | ||
1566 | * @param user_data unused | ||
1567 | */ | 1408 | */ |
1568 | void | 1409 | void |
1569 | GNUNET_GNS_GTK_quit_imagemenuitem_activate_cb (GtkMenuItem *menuitem, | 1410 | GNUNET_SETUP_gns_init () |
1570 | gpointer user_data) | ||
1571 | { | 1411 | { |
1572 | GNUNET_GTK_tray_icon_destroy (); | ||
1573 | GNUNET_GTK_main_loop_quit (ml); | ||
1574 | GNUNET_SCHEDULER_add_now (&shutdown_task, user_data); | ||
1575 | } | ||
1576 | |||
1577 | |||
1578 | /** | ||
1579 | * Callback invoked if the application is supposed to exit (via window-close). | ||
1580 | * | ||
1581 | * @param widget the main window | ||
1582 | * @param event deletion event | ||
1583 | * @param user_data unused | ||
1584 | */ | ||
1585 | void | ||
1586 | GNUNET_GNS_GTK_main_window_delete_event_cb (GtkWidget *widget, | ||
1587 | GdkEvent *event, | ||
1588 | gpointer user_data) | ||
1589 | { | ||
1590 | GNUNET_GTK_tray_icon_destroy (); | ||
1591 | GNUNET_GTK_main_loop_quit (ml); | ||
1592 | GNUNET_SCHEDULER_add_now (&shutdown_task, user_data); | ||
1593 | } | ||
1594 | |||
1595 | |||
1596 | static void | ||
1597 | close_error_box (GtkDialog *dialog, | ||
1598 | gint response_id, | ||
1599 | gpointer user_data) | ||
1600 | { | ||
1601 | gtk_widget_destroy (GTK_WIDGET(dialog)); | ||
1602 | GNUNET_GNS_GTK_shutdown (user_data); | ||
1603 | } | ||
1604 | |||
1605 | |||
1606 | static void | ||
1607 | namestore_service_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1608 | { | ||
1609 | struct GNUNET_GNS_Context *gns = NULL; | ||
1610 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; | 1412 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded shenc; |
1611 | GtkWidget *dialog; | ||
1612 | char *label; | 1413 | char *label; |
1613 | char *keyfile; | 1414 | char *keyfile; |
1614 | char *servicehome; | 1415 | char *servicehome; |
1416 | struct ZoneIteration_Context *zc_ctx; | ||
1417 | GtkTreeIter toplevel; | ||
1615 | 1418 | ||
1616 | gns = GNUNET_malloc (sizeof (struct GNUNET_GNS_Context)); | 1419 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, |
1617 | |||
1618 | if ((tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0) | ||
1619 | { | ||
1620 | char * message = _("Namestore service is not running!\n"); | ||
1621 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, message); | ||
1622 | dialog = gtk_message_dialog_new (GTK_WINDOW (gns->main_window), | ||
1623 | GTK_DIALOG_DESTROY_WITH_PARENT, | ||
1624 | GTK_MESSAGE_ERROR, | ||
1625 | GTK_BUTTONS_CLOSE, | ||
1626 | "%s", | ||
1627 | message); | ||
1628 | |||
1629 | g_signal_connect (dialog, "response", G_CALLBACK(close_error_box), gns); | ||
1630 | gtk_widget_show_all (dialog); | ||
1631 | return; | ||
1632 | } | ||
1633 | |||
1634 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (get_configuration (), | ||
1635 | "PATHS", | 1420 | "PATHS", |
1636 | "SERVICEHOME", | 1421 | "SERVICEHOME", |
1637 | &servicehome)) | 1422 | &servicehome)) |
1638 | { | 1423 | { |
1639 | GNUNET_asprintf(&zonekey_directory, ""); | 1424 | GNUNET_asprintf (&zonekey_directory, ""); |
1640 | } | 1425 | } |
1641 | else | 1426 | else |
1642 | { | 1427 | { |
1643 | GNUNET_asprintf(&zonekey_directory, "%s%s%s",servicehome, DIR_SEPARATOR_STR, "gns"); | 1428 | GNUNET_asprintf (&zonekey_directory, "%s%s%s",servicehome, DIR_SEPARATOR_STR, "gns"); |
1644 | GNUNET_free (servicehome); | 1429 | GNUNET_free (servicehome); |
1645 | } | 1430 | } |
1646 | 1431 | ||
1647 | /* setup crypto keys */ | 1432 | /* setup crypto keys */ |
1648 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (get_configuration (), | 1433 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, |
1649 | "gns", | 1434 | "gns", |
1650 | "ZONEKEY", | 1435 | "ZONEKEY", |
1651 | &keyfile)) | 1436 | &keyfile)) |
1652 | { | 1437 | { |
1653 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1438 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1654 | _("Option `%s' missing in section `%s'\n"), "ZONEKEY", "gns"); | 1439 | _("Option `%s' missing in section `%s'\n"), "ZONEKEY", "gns"); |
1440 | /* FIXME: display error message in GNS tab! */ | ||
1655 | return; | 1441 | return; |
1656 | } | 1442 | } |
1657 | else | 1443 | else |
1658 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using `%s'\n", keyfile); | 1444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using `%s'\n", keyfile); |
1659 | gns->pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | 1445 | pkey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); |
1660 | GNUNET_free (keyfile); | 1446 | GNUNET_free (keyfile); |
1661 | keyfile = NULL; | 1447 | keyfile = NULL; |
1662 | if (NULL == gns->pkey) | 1448 | if (NULL == pkey) |
1663 | { | 1449 | { |
1664 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1450 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1665 | _("Failed to read or create private zone key\n")); | 1451 | _("Failed to read or create private zone key\n")); |
1452 | /* FIXME: display error message in GNS tab! */ | ||
1666 | return; | 1453 | return; |
1667 | } | 1454 | } |
1668 | GNUNET_CRYPTO_rsa_key_get_public (gns->pkey, &gns->pubkey); | 1455 | GNUNET_CRYPTO_rsa_key_get_public (pkey, &pubkey); |
1669 | GNUNET_CRYPTO_short_hash (&gns->pubkey, | 1456 | GNUNET_CRYPTO_short_hash (&pubkey, |
1670 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 1457 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
1671 | &gns->zone); | 1458 | &zone); |
1672 | GNUNET_CRYPTO_short_hash_to_enc(&gns->zone, &shenc); | 1459 | GNUNET_CRYPTO_short_hash_to_enc(&zone, &shenc); |
1673 | 1460 | ||
1674 | /* connect to namestore */ | 1461 | /* connect to namestore */ |
1675 | gns->ns = GNUNET_NAMESTORE_connect (get_configuration ()); | 1462 | namestore = GNUNET_NAMESTORE_connect (cfg); |
1676 | if (NULL == gns->ns) | 1463 | if (NULL == namestore) |
1677 | { | 1464 | { |
1678 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1465 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1679 | _("Failed to connect to namestore\n")); | 1466 | _("Failed to connect to namestore\n")); |
1467 | /* FIXME: display error message in GNS tab! */ | ||
1680 | return; | 1468 | return; |
1681 | } | 1469 | } |
1682 | 1470 | /* FIXME: adjust names below... */ | |
1683 | /* setup gui */ | 1471 | ts = GTK_TREE_STORE (GNUNET_SETUP_get_object ("GNUNET_SETUP_gns_treestore")); |
1684 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, gns)) | 1472 | ls = GTK_LIST_STORE (GNUNET_SETUP_get_object ("GNUNET_SETUP_gns_type_liststore")); |
1685 | { | 1473 | tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object ("GNUNET_SETUP_gns_main_treeview")); |
1686 | GNUNET_break (0); | 1474 | tm = GTK_TREE_MODEL(ts); |
1687 | GNUNET_SCHEDULER_add_now (&shutdown_task, gns); | ||
1688 | return; | ||
1689 | } | ||
1690 | gns->builder = GNUNET_GTK_main_loop_get_builder(ml); | ||
1691 | gns->main_window = GTK_WIDGET (get_object ("GNUNET_GNS_GTK_main_window")); | ||
1692 | gns->ts = GTK_TREE_STORE (gtk_builder_get_object (gns->builder, "GNUNET_GNS_GTK_treestore")); | ||
1693 | gns->ls = GTK_LIST_STORE (gtk_builder_get_object (gns->builder, "GNUNET_GNS_GTK_type_liststore")); | ||
1694 | gns->tv = GTK_TREE_VIEW (gtk_builder_get_object (gns->builder, "GNUNET_GNS_GTK_main_treeview")); | ||
1695 | gns->tm = GTK_TREE_MODEL(gns->ts); | ||
1696 | gns->shorten_menu = GTK_CHECK_MENU_ITEM(gtk_builder_get_object (gns->builder, "GNUNET_GNS_GTK_autoshort_imagemenuitem")); | ||
1697 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (get_configuration (), | ||
1698 | "gns", | ||
1699 | "AUTO_IMPORT_PKEY")) | ||
1700 | gtk_check_menu_item_set_active (gns->shorten_menu, TRUE); | ||
1701 | else | ||
1702 | gtk_check_menu_item_set_active (gns->shorten_menu, FALSE); | ||
1703 | |||
1704 | /* TODO: implements menus */ | ||
1705 | gtk_widget_set_visible (GTK_WIDGET (gtk_builder_get_object (gns->builder, "GNUNET_GNS_GTK_new_imagemenuitem")), FALSE); | ||
1706 | gtk_widget_set_visible (GTK_WIDGET (gtk_builder_get_object (gns->builder, "GNUNET_GNS_GTK_open_imagemenuitem")), FALSE); | ||
1707 | |||
1708 | zone_as_string = GNUNET_strdup ((char *) &shenc); | 1475 | zone_as_string = GNUNET_strdup ((char *) &shenc); |
1709 | label = g_markup_printf_escaped (_("<b>Editing zone %s</b>"), | 1476 | label = g_markup_printf_escaped (_("<b>Editing zone %s</b>"), |
1710 | zone_as_string); | 1477 | zone_as_string); |
1711 | gtk_label_set_markup (GTK_LABEL (get_object ("GNUNET_GNS_GTK_zone_label")), | 1478 | gtk_label_set_markup (GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_SETUP_gns_zone_label")), |
1712 | label); | 1479 | label); |
1713 | g_free (label); | 1480 | g_free (label); |
1714 | 1481 | ||
1482 | /* Load zone from namestore! */ | ||
1483 | |||
1484 | /* Append a top level row and leave it empty */ | ||
1485 | gtk_tree_store_insert_with_values (ts, &toplevel, NULL, 0, | ||
1486 | GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR), | ||
1487 | GNS_TREESTORE_COL_NAME_IS_VISIBLE, TRUE, | ||
1488 | GNS_TREESTORE_COL_RECORD_TYPE, 1, | ||
1489 | GNS_TREESTORE_COL_IS_RECORD_ROW, GNUNET_NO, | ||
1490 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, GNUNET_NO, | ||
1491 | -1); | ||
1492 | |||
1493 | zc_ctx = GNUNET_malloc (sizeof (struct ZoneIteration_Context)); | ||
1494 | zc_ctx->zone = zone; | ||
1495 | zc_ctx->it = GNUNET_NAMESTORE_zone_iteration_start (namestore, &zone, | ||
1496 | GNUNET_NAMESTORE_RF_NONE, | ||
1497 | GNUNET_NAMESTORE_RF_NONE, | ||
1498 | &zone_iteration_proc, | ||
1499 | zc_ctx); | ||
1500 | /* FIXME: show message 'loading', when done make tree view visible! */ | ||
1501 | } | ||
1502 | |||
1503 | |||
1504 | /** | ||
1505 | * Disconnect from the namestore and clean up the main | ||
1506 | * GNS tree view. | ||
1507 | */ | ||
1508 | void | ||
1509 | GNUNET_SETUP_gns_done () | ||
1510 | { | ||
1511 | if (NULL != namestore) | ||
1512 | { | ||
1513 | GNUNET_NAMESTORE_disconnect (namestore, GNUNET_NO); | ||
1514 | namestore = NULL; | ||
1515 | } | ||
1516 | if (NULL != pkey) | ||
1517 | { | ||
1518 | GNUNET_CRYPTO_rsa_key_free (pkey); | ||
1519 | pkey = NULL; | ||
1520 | } | ||
1521 | if (NULL != zonekey_directory) | ||
1522 | { | ||
1523 | GNUNET_free (zonekey_directory); | ||
1524 | zonekey_directory = NULL; | ||
1525 | } | ||
1715 | } | 1526 | } |
1716 | 1527 | ||
1717 | 1528 | ||
diff --git a/src/setup/gnunet-setup-gns.h b/src/setup/gnunet-setup-gns.h new file mode 100644 index 00000000..8a5a78b2 --- /dev/null +++ b/src/setup/gnunet-setup-gns.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
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 | ||
7 | by the Free Software Foundation; either version 2, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file src/setup/gnunet-setup-gns.h | ||
23 | * @brief gns interaction management | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef GNUNET_SETUP_GNS_H | ||
27 | #define GNUNET_SETUP_GNS_H | ||
28 | |||
29 | #include "gnunet-setup.h" | ||
30 | |||
31 | |||
32 | /** | ||
33 | * Connect to the namestore and initialize the main | ||
34 | * GNS tree view. | ||
35 | */ | ||
36 | void | ||
37 | GNUNET_SETUP_gns_init (void); | ||
38 | |||
39 | |||
40 | /** | ||
41 | * Disconnect from the namestore and clean up the main | ||
42 | * GNS tree view. | ||
43 | */ | ||
44 | void | ||
45 | GNUNET_SETUP_gns_done (void); | ||
46 | |||
47 | #endif | ||
diff --git a/src/setup/gnunet-setup.c b/src/setup/gnunet-setup.c index f93cb853..c425822f 100644 --- a/src/setup/gnunet-setup.c +++ b/src/setup/gnunet-setup.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #endif | 28 | #endif |
29 | #include "gnunet-setup.h" | 29 | #include "gnunet-setup.h" |
30 | #include "gnunet-setup-options.h" | 30 | #include "gnunet-setup-options.h" |
31 | #include "gnunet-setup-gns.h" | ||
31 | #include <regex.h> | 32 | #include <regex.h> |
32 | 33 | ||
33 | /** | 34 | /** |
@@ -317,6 +318,7 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
317 | } | 318 | } |
318 | GNUNET_GTK_main_loop_quit (ml); | 319 | GNUNET_GTK_main_loop_quit (ml); |
319 | ml = NULL; | 320 | ml = NULL; |
321 | GNUNET_SETUP_gns_done (); | ||
320 | if (GNUNET_OK != write_configuration ()) | 322 | if (GNUNET_OK != write_configuration ()) |
321 | gret = 1; | 323 | gret = 1; |
322 | cfg = NULL; | 324 | cfg = NULL; |
@@ -349,15 +351,17 @@ GNUNET_SETUP_restart_namestore (void *cls, | |||
349 | { | 351 | { |
350 | if (GNUNET_OK != write_configuration ()) | 352 | if (GNUNET_OK != write_configuration ()) |
351 | return; /* no point in re-starting namestore ... */ | 353 | return; /* no point in re-starting namestore ... */ |
354 | GNUNET_SETUP_gns_done (); | ||
352 | if (NULL != namestore) | 355 | if (NULL != namestore) |
353 | { | 356 | { |
354 | GNUNET_break (0 == GNUNET_OS_process_kill (namestore, SIGTERM)); | 357 | GNUNET_break (0 == GNUNET_OS_process_kill (namestore, SIGTERM)); |
355 | GNUNET_OS_process_destroy (namestore); | 358 | GNUNET_OS_process_destroy (namestore); |
356 | namestore = NULL; | 359 | namestore = NULL; |
357 | } | 360 | } |
358 | /* FIXME: start namestore */ | 361 | namestore = |
359 | /* FIXME: refresh namestore model! */ | 362 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-namestore", |
360 | GNUNET_break (0); // not implemented... | 363 | "gnunet-service-namestore", NULL); |
364 | GNUNET_SETUP_gns_init (); | ||
361 | } | 365 | } |
362 | 366 | ||
363 | 367 | ||
@@ -396,8 +400,12 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
396 | main_window = GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_dialog")); | 400 | main_window = GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_dialog")); |
397 | resolver = | 401 | resolver = |
398 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-resolver", | 402 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-resolver", |
399 | "gnunet-service-resolver", NULL); | 403 | "gnunet-service-resolver", NULL); |
404 | namestore = | ||
405 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-namestore", | ||
406 | "gnunet-service-namestore", NULL); | ||
400 | load_options (); | 407 | load_options (); |
408 | GNUNET_SETUP_gns_init (); | ||
401 | gtk_widget_show (main_window); | 409 | gtk_widget_show (main_window); |
402 | gtk_window_present (GTK_WINDOW (main_window)); | 410 | gtk_window_present (GTK_WINDOW (main_window)); |
403 | } | 411 | } |