[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22086 - in gnunet-gtk: . src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22086 - in gnunet-gtk: . src/fs |
Date: |
Mon, 18 Jun 2012 22:40:17 +0200 |
Author: grothoff
Date: 2012-06-18 22:40:17 +0200 (Mon, 18 Jun 2012)
New Revision: 22086
Modified:
gnunet-gtk/configure.ac
gnunet-gtk/src/fs/Makefile.am
gnunet-gtk/src/fs/gnunet-fs-gtk.c
Log:
adding support for making sure only one instance of gnunet-fs-gtk is running
via libunique (towards implementing #1083)
Modified: gnunet-gtk/configure.ac
===================================================================
--- gnunet-gtk/configure.ac 2012-06-18 20:20:59 UTC (rev 22085)
+++ gnunet-gtk/configure.ac 2012-06-18 20:40:17 UTC (rev 22086)
@@ -174,6 +174,7 @@
AC_MSG_ERROR([gnunet-gtk requires libextractor headers])
fi
+
AC_MSG_CHECKING(for gtk)
check_for_3=3.0.0
check_for_2=false
@@ -200,11 +201,25 @@
if test "x$check_for_3" != "xfalse"
then
AM_PATH_GTK_3_0([$check_for_3],without_gtk=false,)
+ # test for libunique
+ AC_ARG_WITH([libunique], AC_HELP_STRING([--without-libunique], [disable
libunique]))
+ have_libunique=no
+ if test x$with_libunique != xno; then
+ PKG_CHECK_MODULES([unique], [unique-3.0], AC_DEFINE(HAVE_LIBUNIQUE, 1,
[Define if libunique is available]), AC_MSG_WARN([libunique would be nice to
have]))
+ fi
fi
+
if test "x$without_gtk" == "xfalse" -a "x$check_for_2" != "xfalse"
then
AM_PATH_GTK_2_0([$check_for_2],without_gtk=false,)
+ # test for libunique
+ AC_ARG_WITH([libunique], AC_HELP_STRING([--without-libunique], [disable
libunique]))
+ have_libunique=no
+ if test x$with_libunique != xno; then
+ PKG_CHECK_MODULES([unique], [unique-1.0], AC_DEFINE(HAVE_LIBUNIQUE, 1,
[Define if libunique is available]), AC_MSG_WARN([libunique would be nice to
have]))
+ fi
fi
+
AM_CONDITIONAL(HAVE_GTK, test x$without_gtk != xtrue)
if test $without_gtk != true
then
Modified: gnunet-gtk/src/fs/Makefile.am
===================================================================
--- gnunet-gtk/src/fs/Makefile.am 2012-06-18 20:20:59 UTC (rev 22085)
+++ gnunet-gtk/src/fs/Makefile.am 2012-06-18 20:40:17 UTC (rev 22086)
@@ -5,7 +5,8 @@
-I$(top_srcdir)/src/include \
@GTK_CFLAGS@ \
@GNUNET_CFLAGS@ \
- @GLADE_CFLAGS@
+ @GLADE_CFLAGS@ \
+ @unique_CFLAGS@
bin_PROGRAMS = gnunet-fs-gtk
@@ -31,7 +32,7 @@
gnunet_fs_gtk_LDADD = \
$(top_builddir)/src/lib/libgnunetgtk.la \
@GTK_LIBS@ \
- @GLADE_LIBS@ @GNUNET_LIBS@ \
+ @GLADE_LIBS@ @GNUNET_LIBS@ @unique_LIBS@ \
-lextractor \
-lgnunetutil \
-lgnunetfs \
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.c 2012-06-18 20:20:59 UTC (rev 22085)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.c 2012-06-18 20:40:17 UTC (rev 22086)
@@ -28,6 +28,10 @@
#include "gnunet-fs-gtk_event-handler.h"
#include "gnunet-fs-gtk_open-uri.h"
+#if HAVE_LIBUNIQUE
+#include <unique/unique.h>
+#endif
+
/**
* How many block requests can we have outstanding in parallel at a time by
default?
*/
@@ -55,6 +59,11 @@
static struct GNUNET_FS_Handle *fs;
+#if HAVE_LIBUNIQUE
+static UniqueApp *unique_app;
+#endif
+
+
/**
* Return handle for file-sharing operations.
*
@@ -291,7 +300,64 @@
}
+#if HAVE_LIBUNIQUE
+/**
+ * Function called whenever a second gnunet-fs-gtk process is started
+ * with additional arguments for us.
+ *
+ * @param app unique handle
+ * @param command command that was given
+ * @param message_data command line message data
+ * @param time_ timestamp of the event
+ * @param user_data our 'main context'
+ * @return response code for original process
+ */
+static UniqueResponse
+unique_app_message_cb (UniqueApp *app,
+ gint command,
+ UniqueMessageData *message_data,
+ guint time_,
+ gpointer user_data)
+{
+ struct GNUNET_GTK_MainWindowContext *main_context = user_data;
+ /* raise the window */
+ gtk_window_present_with_time (GTK_WINDOW (main_context->main_window), time_);
+
+ switch (command)
+ {
+ case UNIQUE_NEW:
+ /* this is unexpected... */
+ GNUNET_break (0);
+ break;
+ case UNIQUE_OPEN:
+ {
+ gchar **uris;
+ gint n_uris;
+ gint i;
+
+ uris = unique_message_data_get_uris (message_data);
+ n_uris = g_strv_length (uris);
+ for (i = 0; i < n_uris; i++)
+ {
+ if (GNUNET_OK !=
+ GNUNET_FS_GTK_handle_uri_string (uris[i],
+ 1 /* anonymity level */))
+ return UNIQUE_RESPONSE_PASSTHROUGH;
+ }
+ g_strfreev (uris);
+ }
+ break;
+ case UNIQUE_ACTIVATE:
+ break;
+ default:
+ break;
+ }
+ return UNIQUE_RESPONSE_OK;
+}
+#endif
+
+
/**
* Actual main function run right after GNUnet's scheduler
* is initialized. Initializes up GTK and Glade.
@@ -404,7 +470,11 @@
}
GNUNET_GTK_main_window_refresh_ns_list (main_context);
-
+#if HAVE_LIBUNIQUE
+ unique_app_watch_window (unique_app, GTK_WINDOW (main_context->main_window));
+ g_signal_connect (unique_app, "message-received",
+ G_CALLBACK (unique_app_message_cb), main_context);
+#endif
/* make GUI visible */
if (!tray_only)
{
@@ -416,20 +486,54 @@
int
-main (int argc, char *const *argv)
+main (int argc, char **argv)
{
static struct GNUNET_GETOPT_CommandLineOption options[] = {
{'t', "tray", NULL,
gettext_noop ("start in tray mode"), 0,
&GNUNET_GETOPT_set_one, &tray_only},
GNUNET_GETOPT_OPTION_END
- };
+ };
+#if HAVE_LIBUNIQUE
+ int arge;
+ gtk_init (&argc, &argv);
+ unique_app = unique_app_new ("org.gnunet.gnunet-fs-gtk", NULL);
+ if (unique_app_is_running (unique_app))
+ {
+ UniqueResponse response;
+
+ arge = GNUNET_GETOPT_run ("gnunet-fs-gtk",
+ options,
+ argc, argv);
+ response = unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL);
+ while (arge < argc)
+ {
+ UniqueMessageData *msg;
+
+ msg = unique_message_data_new ();
+ unique_message_data_set_text (msg, argv[arge], strlen (argv[arge])+1);
+ if (UNIQUE_RESPONSE_OK == response)
+ response = unique_app_send_message (unique_app,
+ UNIQUE_OPEN,
+ msg);
+ unique_message_data_free (msg);
+ arge++;
+ }
+ g_object_unref (unique_app);
+
+ return (UNIQUE_RESPONSE_OK == response) ? 0 : 1;
+ }
+#endif
if (GNUNET_OK !=
GNUNET_GTK_main_loop_start ("gnunet-fs-gtk", "GTK GUI for GNUnet", argc,
argv, options,
"gnunet_fs_gtk_main_window.glade", &run))
+ {
+ g_object_unref (unique_app);
return 1;
+ }
+ g_object_unref (unique_app);
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22086 - in gnunet-gtk: . src/fs,
gnunet <=