diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk.c | 102 |
1 files changed, 100 insertions, 2 deletions
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c index a05486e8..ee64b05f 100644 --- a/src/fs/gnunet-fs-gtk.c +++ b/src/fs/gnunet-fs-gtk.c | |||
@@ -81,6 +81,7 @@ static struct GNUNET_GTK_MainWindowContext main_context; | |||
81 | static UniqueApp *unique_app; | 81 | static UniqueApp *unique_app; |
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | |||
84 | struct GNUNET_GTK_MainWindowContext * | 85 | struct GNUNET_GTK_MainWindowContext * |
85 | GNUNET_FS_GTK_get_main_context () | 86 | GNUNET_FS_GTK_get_main_context () |
86 | { | 87 | { |
@@ -230,6 +231,8 @@ GNUNET_GTK_main_window_configure_event_cb (GtkWidget *main_window, | |||
230 | static void | 231 | static void |
231 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 232 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
232 | { | 233 | { |
234 | struct SearchLookup *sl; | ||
235 | |||
233 | GNUNET_GTK_tray_icon_destroy (); | 236 | GNUNET_GTK_tray_icon_destroy (); |
234 | if (fs != NULL) | 237 | if (fs != NULL) |
235 | { | 238 | { |
@@ -248,8 +251,37 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
248 | } | 251 | } |
249 | GNUNET_FS_GTK_close_uri_tab_ (); | 252 | GNUNET_FS_GTK_close_uri_tab_ (); |
250 | if (NULL != ml) | 253 | if (NULL != ml) |
254 | { | ||
251 | GNUNET_GTK_main_loop_quit (ml); | 255 | GNUNET_GTK_main_loop_quit (ml); |
252 | ml = NULL; | 256 | ml = NULL; |
257 | } | ||
258 | if (NULL != main_context.id_op) | ||
259 | { | ||
260 | GNUNET_IDENTITY_cancel (main_context.id_op); | ||
261 | main_context.id_op = NULL; | ||
262 | } | ||
263 | if (NULL != main_context.identity) | ||
264 | { | ||
265 | GNUNET_IDENTITY_disconnect (main_context.identity); | ||
266 | main_context.identity = NULL; | ||
267 | } | ||
268 | while (NULL != (sl = main_context.sl_head)) | ||
269 | abort_search_lookup (sl); | ||
270 | if (NULL != main_context.zm) | ||
271 | { | ||
272 | GNUNET_NAMESTORE_zone_monitor_stop (main_context.zm); | ||
273 | main_context.zm = NULL; | ||
274 | } | ||
275 | if (NULL != main_context.gns) | ||
276 | { | ||
277 | GNUNET_GNS_disconnect (main_context.gns); | ||
278 | main_context.gns = NULL; | ||
279 | } | ||
280 | if (NULL != main_context.sks_zone) | ||
281 | { | ||
282 | GNUNET_free (main_context.sks_zone); | ||
283 | main_context.sks_zone = NULL; | ||
284 | } | ||
253 | } | 285 | } |
254 | 286 | ||
255 | 287 | ||
@@ -408,6 +440,7 @@ unique_app_message_cb (UniqueApp *app, | |||
408 | } | 440 | } |
409 | #endif | 441 | #endif |
410 | 442 | ||
443 | |||
411 | static char * | 444 | static char * |
412 | format_service_list (unsigned int count, const char *const*list) | 445 | format_service_list (unsigned int count, const char *const*list) |
413 | { | 446 | { |
@@ -514,6 +547,67 @@ service_status_change (void *cls, | |||
514 | 547 | ||
515 | 548 | ||
516 | /** | 549 | /** |
550 | * Process a record that was stored in the namestore in the | ||
551 | * "sks_zone". Adds (or removes) the respective label to the | ||
552 | * drop-down menu for the SKS search by manipulating the | ||
553 | * "namespace_label_liststore". | ||
554 | * | ||
555 | * @param cls closure | ||
556 | * @param zone private key of the zone | ||
557 | * @param label label of the records | ||
558 | * @param rd_count number of entries in @a rd array | ||
559 | * @param rd array of records with data to store | ||
560 | */ | ||
561 | static void | ||
562 | monitor_zone_records (void *cls, | ||
563 | const struct GNUNET_CRYPTO_EccPrivateKey *zone, | ||
564 | const char *label, | ||
565 | unsigned int rd_count, | ||
566 | const struct GNUNET_NAMESTORE_RecordData *rd) | ||
567 | { | ||
568 | GNUNET_break (0); // not implemented | ||
569 | } | ||
570 | |||
571 | |||
572 | /** | ||
573 | * The identity service has given us the ego we should use for resolving | ||
574 | * namepace names. | ||
575 | * | ||
576 | * @param cls closure | ||
577 | * @param ego ego handle, NULL for none | ||
578 | * @param ctx context for application to store data for this ego | ||
579 | * (during the lifetime of this process, initially NULL) | ||
580 | * @param name name assigned by the user for this ego, | ||
581 | * NULL if the user just deleted the ego and it | ||
582 | * must thus no longer be used | ||
583 | */ | ||
584 | static void | ||
585 | handle_sks_zone_identity (void *cls, | ||
586 | struct GNUNET_IDENTITY_Ego *ego, | ||
587 | void **ctx, | ||
588 | const char *name) | ||
589 | { | ||
590 | main_context.id_op = NULL; | ||
591 | |||
592 | if (NULL == ego) | ||
593 | { | ||
594 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
595 | _("No default ego specified for `fs-sks` service, will not enable namespace search.\n")); | ||
596 | return; | ||
597 | } | ||
598 | main_context.sks_zone = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey); | ||
599 | *main_context.sks_zone = *GNUNET_IDENTITY_ego_get_private_key (ego); | ||
600 | gtk_widget_show (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_label"))); | ||
601 | gtk_widget_show (GTK_WIDGET (GNUNET_FS_GTK_get_main_window_object ("main_window_search_namespace_combobox"))); | ||
602 | main_context.zm = GNUNET_NAMESTORE_zone_monitor_start (main_context.cfg, | ||
603 | main_context.sks_zone, | ||
604 | &monitor_zone_records, | ||
605 | NULL, | ||
606 | NULL); | ||
607 | } | ||
608 | |||
609 | |||
610 | /** | ||
517 | * Actual main function run right after GNUnet's scheduler | 611 | * Actual main function run right after GNUnet's scheduler |
518 | * is initialized. Initializes up GTK and Glade. | 612 | * is initialized. Initializes up GTK and Glade. |
519 | * | 613 | * |
@@ -635,7 +729,11 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
635 | } | 729 | } |
636 | arm = GNUNET_ARM_connect (main_context.cfg, &arm_connection_state_change, &main_context); | 730 | arm = GNUNET_ARM_connect (main_context.cfg, &arm_connection_state_change, &main_context); |
637 | armon = GNUNET_ARM_monitor (main_context.cfg, service_status_change, &main_context); | 731 | armon = GNUNET_ARM_monitor (main_context.cfg, service_status_change, &main_context); |
638 | 732 | main_context.identity = GNUNET_IDENTITY_connect (main_context.cfg, NULL, NULL); | |
733 | main_context.id_op = GNUNET_IDENTITY_get (main_context.identity, | ||
734 | "fs-sks", | ||
735 | &handle_sks_zone_identity, | ||
736 | NULL); | ||
639 | GNUNET_GTK_main_window_refresh_ns_list (&main_context); | 737 | GNUNET_GTK_main_window_refresh_ns_list (&main_context); |
640 | #if HAVE_LIBUNIQUE | 738 | #if HAVE_LIBUNIQUE |
641 | unique_app_watch_window (unique_app, GTK_WINDOW (main_context.main_window)); | 739 | unique_app_watch_window (unique_app, GTK_WINDOW (main_context.main_window)); |