=?utf-8?q?=5Bvino=5D_Add_--tube_arg_to_launch_Vino_in_=E2=80=98tube_only?= =?utf-8?b?4oCZIG1vZGU=?=



commit be8bc1d91cad4635a7558cf34a48ae369c9ec830
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Tue Apr 24 10:58:56 2012 +0200

    Add --tube arg to launch Vino in âtube onlyâ mode
    
    This fixes the âShare my Desktopâ feature when screen sharing has been
    disabled in the preferences.
    
    This regression was introduced when Vino switched to GSettings, as it
    started exiting on startup when desktop sharing was disabled.
    
    Fixes bug 651960.

 ...rg.freedesktop.Telepathy.Client.Vino.service.in |    2 +-
 server/vino-main.c                                 |   90 +++++++++++++++++++-
 2 files changed, 89 insertions(+), 3 deletions(-)
---
diff --git a/server/org.freedesktop.Telepathy.Client.Vino.service.in b/server/org.freedesktop.Telepathy.Client.Vino.service.in
index a61b7b4..9720906 100644
--- a/server/org.freedesktop.Telepathy.Client.Vino.service.in
+++ b/server/org.freedesktop.Telepathy.Client.Vino.service.in
@@ -1,3 +1,3 @@
 [D-BUS Service]
 Name=org.freedesktop.Telepathy.Client.Vino
-Exec= libexecdir@/vino-server
+Exec= libexecdir@/vino-server --tube
diff --git a/server/vino-main.c b/server/vino-main.c
index ced20ea..1f79775 100644
--- a/server/vino-main.c
+++ b/server/vino-main.c
@@ -39,6 +39,10 @@
 #ifdef VINO_HAVE_GNUTLS
 #include <gnutls/gnutls.h>
 
+#ifdef VINO_HAVE_TELEPATHY_GLIB
+static gboolean tube = FALSE;
+#endif
+
 # ifdef GNOME_ENABLE_DEBUG
 static void
 vino_debug_gnutls (int         level,
@@ -59,14 +63,76 @@ typedef struct
   GMainLoop         *main_loop;
 } VinoApplication;
 
+typedef enum
+{
+  /* Screen sharing enabled, Vino should always be running */
+  RUN_MODE_ALL,
+  /* Screen sharing disabled but Vino started with --tube;
+   * should exit once the tube has been handled */
+  RUN_MODE_TUBE,
+  /* Screen sharing disabled and Vino started without --tube;
+   * should exit right away */
+  RUN_MODE_EXIT,
+} RunMode;
+
+static RunMode
+get_run_mode (VinoApplication *vino)
+{
+  if (g_settings_get_boolean (vino->settings, "enabled"))
+    return RUN_MODE_ALL;
+
+#ifdef VINO_HAVE_TELEPATHY_GLIB
+  if (tube)
+    return RUN_MODE_TUBE;
+#endif
+
+  return RUN_MODE_EXIT;
+}
+
+static void
+set_all_servers_reject(VinoApplication *vino,
+    gboolean reject)
+{
+  guint i;
+
+  for (i = 0; i < vino->n_screens; i++)
+    {
+      VinoServer *server;
+
+      server = vino_dbus_listener_get_server (vino->listeners[i]);
+
+      vino_server_set_reject_incoming (server, reject);
+    }
+}
+
 static void
 enabled_changed (VinoApplication *vino)
 {
-  if (!g_settings_get_boolean (vino->settings, "enabled"))
+  RunMode mode;
+  gboolean reject;
+
+  mode = get_run_mode (vino);
+  if (mode == RUN_MODE_EXIT)
     {
       g_message ("The desktop sharing service has been disabled, exiting.");
       g_main_loop_quit (vino->main_loop);
+      return;
+    }
+
+  if (mode == RUN_MODE_TUBE)
+    {
+      g_message ("The desktop sharing service has been disabled, "
+          "reject network connections");
+      reject = TRUE;
+    }
+  else
+    {
+      g_message ("The desktop sharing service has been enabled, "
+          "accept network connections");
+      reject = FALSE;
     }
+
+  set_all_servers_reject (vino, reject);
 }
 
 static void
@@ -100,6 +166,13 @@ name_acquired (GDBusConnection *connection,
   VinoApplication *vino = user_data;
   gboolean view_only;
   gint i;
+  gboolean reject = FALSE;
+
+  if (get_run_mode (vino) == RUN_MODE_TUBE)
+    {
+      g_message ("Started in tube mode; reject network connections");
+      reject = TRUE;
+    }
 
   /* Name is acquired.  Start up the servers and register them with the
    * listeners.
@@ -155,6 +228,7 @@ name_acquired (GDBusConnection *connection,
 
       vino_dbus_listener_set_server (vino->listeners[i], server);
       vino_server_set_on_hold (server, FALSE);
+      vino_server_set_reject_incoming (server, reject);
 
       if (g_settings_get_boolean (vino->settings, "enabled"))
         {
@@ -196,10 +270,21 @@ main (int argc, char **argv)
   {
     GOptionContext *context;
     GError *error = NULL;
+    GOptionEntry options[] = {
+#ifdef VINO_HAVE_TELEPATHY_GLIB
+      { "tube", 't',
+        0, G_OPTION_ARG_NONE, &tube,
+        N_("Start in tube mode, for the âShare my Desktopâ feature"),
+        NULL },
+#endif
+      { NULL }
+    };
 
     context = g_option_context_new (_("- VNC Server for GNOME"));
     g_option_context_add_group (context, gtk_get_option_group (TRUE));
     g_option_context_add_group (context, egg_sm_client_get_option_group ());
+    g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+
     if (!g_option_context_parse (context, &argc, &argv, &error))
       {
         g_print ("%s\n%s\n", error->message,
@@ -215,7 +300,8 @@ main (int argc, char **argv)
   vino.settings = g_settings_new ("org.gnome.Vino");
   g_signal_connect_swapped (vino.settings, "changed::enabled",
                             G_CALLBACK (enabled_changed), &vino);
-  if (!g_settings_get_boolean (vino.settings, "enabled"))
+
+  if (get_run_mode (&vino) == RUN_MODE_EXIT)
     {
       g_warning ("The desktop sharing service is not "
                  "enabled, so it should not be run.");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]