aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk.c')
-rw-r--r--src/fs/gnunet-fs-gtk.c110
1 files changed, 107 insertions, 3 deletions
diff --git a/src/fs/gnunet-fs-gtk.c b/src/fs/gnunet-fs-gtk.c
index 248e3f7d..4bd9ac5f 100644
--- a/src/fs/gnunet-fs-gtk.c
+++ b/src/fs/gnunet-fs-gtk.c
@@ -28,6 +28,10 @@
28#include "gnunet-fs-gtk_event-handler.h" 28#include "gnunet-fs-gtk_event-handler.h"
29#include "gnunet-fs-gtk_open-uri.h" 29#include "gnunet-fs-gtk_open-uri.h"
30 30
31#if HAVE_LIBUNIQUE
32#include <unique/unique.h>
33#endif
34
31/** 35/**
32 * How many block requests can we have outstanding in parallel at a time by default? 36 * How many block requests can we have outstanding in parallel at a time by default?
33 */ 37 */
@@ -55,6 +59,11 @@ static struct GNUNET_GTK_MainLoop *ml;
55static struct GNUNET_FS_Handle *fs; 59static struct GNUNET_FS_Handle *fs;
56 60
57 61
62#if HAVE_LIBUNIQUE
63static UniqueApp *unique_app;
64#endif
65
66
58/** 67/**
59 * Return handle for file-sharing operations. 68 * Return handle for file-sharing operations.
60 * 69 *
@@ -291,6 +300,63 @@ GNUNET_FS_GTK_main_window_button_press_event (GtkWidget * widget,
291} 300}
292 301
293 302
303#if HAVE_LIBUNIQUE
304/**
305 * Function called whenever a second gnunet-fs-gtk process is started
306 * with additional arguments for us.
307 *
308 * @param app unique handle
309 * @param command command that was given
310 * @param message_data command line message data
311 * @param time_ timestamp of the event
312 * @param user_data our 'main context'
313 * @return response code for original process
314 */
315static UniqueResponse
316unique_app_message_cb (UniqueApp *app,
317 gint command,
318 UniqueMessageData *message_data,
319 guint time_,
320 gpointer user_data)
321{
322 struct GNUNET_GTK_MainWindowContext *main_context = user_data;
323
324 /* raise the window */
325 gtk_window_present_with_time (GTK_WINDOW (main_context->main_window), time_);
326
327 switch (command)
328 {
329 case UNIQUE_NEW:
330 /* this is unexpected... */
331 GNUNET_break (0);
332 break;
333 case UNIQUE_OPEN:
334 {
335 gchar **uris;
336 gint n_uris;
337 gint i;
338
339 uris = unique_message_data_get_uris (message_data);
340 n_uris = g_strv_length (uris);
341 for (i = 0; i < n_uris; i++)
342 {
343 if (GNUNET_OK !=
344 GNUNET_FS_GTK_handle_uri_string (uris[i],
345 1 /* anonymity level */))
346 return UNIQUE_RESPONSE_PASSTHROUGH;
347 }
348 g_strfreev (uris);
349 }
350 break;
351 case UNIQUE_ACTIVATE:
352 break;
353 default:
354 break;
355 }
356 return UNIQUE_RESPONSE_OK;
357}
358#endif
359
294 360
295/** 361/**
296 * Actual main function run right after GNUnet's scheduler 362 * Actual main function run right after GNUnet's scheduler
@@ -404,7 +470,11 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
404 } 470 }
405 471
406 GNUNET_GTK_main_window_refresh_ns_list (main_context); 472 GNUNET_GTK_main_window_refresh_ns_list (main_context);
407 473#if HAVE_LIBUNIQUE
474 unique_app_watch_window (unique_app, GTK_WINDOW (main_context->main_window));
475 g_signal_connect (unique_app, "message-received",
476 G_CALLBACK (unique_app_message_cb), main_context);
477#endif
408 /* make GUI visible */ 478 /* make GUI visible */
409 if (!tray_only) 479 if (!tray_only)
410 { 480 {
@@ -416,20 +486,54 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
416 486
417 487
418int 488int
419main (int argc, char *const *argv) 489main (int argc, char **argv)
420{ 490{
421 static struct GNUNET_GETOPT_CommandLineOption options[] = { 491 static struct GNUNET_GETOPT_CommandLineOption options[] = {
422 {'t', "tray", NULL, 492 {'t', "tray", NULL,
423 gettext_noop ("start in tray mode"), 0, 493 gettext_noop ("start in tray mode"), 0,
424 &GNUNET_GETOPT_set_one, &tray_only}, 494 &GNUNET_GETOPT_set_one, &tray_only},
425 GNUNET_GETOPT_OPTION_END 495 GNUNET_GETOPT_OPTION_END
426 }; 496 };
497#if HAVE_LIBUNIQUE
498 int arge;
427 499
500 gtk_init (&argc, &argv);
501 unique_app = unique_app_new ("org.gnunet.gnunet-fs-gtk", NULL);
502 if (unique_app_is_running (unique_app))
503 {
504 UniqueResponse response;
505
506 arge = GNUNET_GETOPT_run ("gnunet-fs-gtk",
507 options,
508 argc, argv);
509 response = unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
510 while (arge < argc)
511 {
512 UniqueMessageData *msg;
513
514 msg = unique_message_data_new ();
515 unique_message_data_set_text (msg, argv[arge], strlen (argv[arge])+1);
516 if (UNIQUE_RESPONSE_OK == response)
517 response = unique_app_send_message (unique_app,
518 UNIQUE_OPEN,
519 msg);
520 unique_message_data_free (msg);
521 arge++;
522 }
523 g_object_unref (unique_app);
524
525 return (UNIQUE_RESPONSE_OK == response) ? 0 : 1;
526 }
527#endif
428 if (GNUNET_OK != 528 if (GNUNET_OK !=
429 GNUNET_GTK_main_loop_start ("gnunet-fs-gtk", "GTK GUI for GNUnet", argc, 529 GNUNET_GTK_main_loop_start ("gnunet-fs-gtk", "GTK GUI for GNUnet", argc,
430 argv, options, 530 argv, options,
431 "gnunet_fs_gtk_main_window.glade", &run)) 531 "gnunet_fs_gtk_main_window.glade", &run))
532 {
533 g_object_unref (unique_app);
432 return 1; 534 return 1;
535 }
536 g_object_unref (unique_app);
433 return 0; 537 return 0;
434} 538}
435 539