[vino/3] more progress...



commit 659db296cb2379285a21da804ff95cfe46fafdf3
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Jul 5 02:59:06 2010 -0400

    more progress...

 capplet/vino-preferences.c  |    2 +-
 common/vino-dbus.c          |   32 +----
 server/Makefile.am          |    2 +
 server/vino-dbus-listener.c |  339 +++++++++++--------------------------------
 server/vino-dbus-listener.h |   31 +----
 server/vino-main.c          |    2 +-
 server/vino-prefs.c         |    4 +-
 server/vino-prefs.h         |    2 +-
 server/vino-server.c        |   63 +++------
 server/vino-server.h        |    3 +-
 10 files changed, 123 insertions(+), 357 deletions(-)
---
diff --git a/capplet/vino-preferences.c b/capplet/vino-preferences.c
index ca613c5..ff49ff4 100644
--- a/capplet/vino-preferences.c
+++ b/capplet/vino-preferences.c
@@ -215,7 +215,7 @@ vino_preferences_update_message (VinoPreferences *app)
           port = internal_port;
         }
 
-      g_string_append_printf (message, "<a href=\"vnc://%s::%d\">%s</a>",
+      g_string_append_printf (url, "<a href=\"vnc://%s::%d\">%s</a>",
                               host, (guint) port, host);
 
       if (avahi_host)
diff --git a/common/vino-dbus.c b/common/vino-dbus.c
index c06275e..735d815 100644
--- a/common/vino-dbus.c
+++ b/common/vino-dbus.c
@@ -21,30 +21,6 @@
 
 #include "vino-dbus.h"
 
-static const GDBusArgInfo org_gnome_VinoScreen_ShareWithTube_connection = {
-  -1, "connection", "o", NULL
-};
-
-static const GDBusArgInfo org_gnome_VinoScreen_ShareWithTube_tube = {
-  -1, "tube", "o", NULL
-};
-
-static const GDBusArgInfo org_gnome_VinoScreen_ShareWithTube_properties = {
-  -1, "properties", "a{sv}", NULL
-};
-
-static const GDBusArgInfo* const org_gnome_VinoScreen_ShareWithTube_args[] = {
-  &org_gnome_VinoScreen_ShareWithTube_connection,
-  &org_gnome_VinoScreen_ShareWithTube_tube,
-  &org_gnome_VinoScreen_ShareWithTube_properties,
-  NULL
-};
-
-static const GDBusMethodInfo org_gnome_VinoScreen_ShareWithTube = {
-  -1, "ShareWithTube",
-  (GDBusArgInfo **) &org_gnome_VinoScreen_ShareWithTube_args
-};
-
 static const GDBusPropertyInfo org_gnome_VinoScreen_ExternalHost = {
   -1, "ExternalHost", "s", G_DBUS_PROPERTY_INFO_FLAGS_READABLE
 };
@@ -65,7 +41,6 @@ static const GDBusPropertyInfo org_gnome_VinoScreen_AvahiHost = {
   -1, "AvahiHost", "s", G_DBUS_PROPERTY_INFO_FLAGS_READABLE
 };
 
-
 static const GDBusPropertyInfo* const org_gnome_VinoScreen_properties[] = {
   &org_gnome_VinoScreen_ExternalHost,
   &org_gnome_VinoScreen_ExternalPort,
@@ -75,15 +50,10 @@ static const GDBusPropertyInfo* const org_gnome_VinoScreen_properties[] = {
   NULL
 };
 
-static const GDBusMethodInfo* const org_gnome_VinoScreen_methods[] = {
-  &org_gnome_VinoScreen_ShareWithTube,
-  NULL
-};
-
 const GDBusInterfaceInfo org_gnome_VinoScreen_interface = {
   -1,
   "org.gnome.VinoScreen",
-  (GDBusMethodInfo **)     org_gnome_VinoScreen_methods,
+  (GDBusMethodInfo **)     NULL,
   (GDBusSignalInfo **)     NULL,
   (GDBusPropertyInfo **)   org_gnome_VinoScreen_properties,
   (GDBusAnnotationInfo **) NULL
diff --git a/server/Makefile.am b/server/Makefile.am
index c37776b..33b0f12 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -3,6 +3,7 @@ NULL =
 SUBDIRS = libvncserver miniupnp smclient
 
 INCLUDES = \
+	-I$(top_srcdir)/common \
 	-I$(top_srcdir)/server/libvncserver \
 	-I$(top_srcdir)/server/miniupnp \
 	-I$(top_srcdir)/server/smclient \
@@ -46,6 +47,7 @@ VINO_HTTP_SRC = \
 endif
 
 vino_server_SOURCES = \
+	../common/vino-dbus.c \
 	vino-cursor.c \
 	vino-cursor.h \
 	vino-enums.c \
diff --git a/server/vino-dbus-listener.c b/server/vino-dbus-listener.c
index 5ac3483..d4d4f11 100644
--- a/server/vino-dbus-listener.c
+++ b/server/vino-dbus-listener.c
@@ -29,6 +29,7 @@
 #include "config.h"
 
 #include "vino-dbus-listener.h"
+#include "vino-dbus.h"
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -66,69 +67,22 @@
 
 #define VINO_DBUS_BUS_NAME  "org.gnome.Vino"
 
-G_DEFINE_TYPE (VinoDBusListener, vino_dbus_listener, G_TYPE_OBJECT)
 
-struct _VinoDBusListenerPrivate
+struct _VinoDBusListener
 {
-  VinoServer *server;
-#ifdef HAVE_TELEPATHY_GLIB
-  VinoTubeServersManager *manager;
-#endif
-};
-
-enum
-{
-  PROP_0,
-  PROP_SERVER
-};
-
-static void
-vino_dbus_listener_method_call (GDBusConnection       *connection,
-                                const gchar           *sender,
-                                const gchar           *object_path,
-                                const gchar           *interface_name,
-                                const gchar           *method_name,
-                                GVariant              *parameters,
-                                GDBusMethodInvocation *invocation,
-                                gpointer               user_data)
-{
-  g_assert_cmpstr (method_name, ==, "ShareWithTube");
-
-
-}
+  GObject  parent_instance;
 
+  GDBusConnection *connection;
+  gchar           *path;
+  gint             screen;
 
-static GVariant *
-vino_dbus_listener_get_property (GDBusConnection  *connection,
-                                 const gchar      *sender,
-                                 const gchar      *object_path,
-                                 const gchar      *interface_name,
-                                 const gchar      *property_name,
-                                 GError          **error,
-                                 gpointer          user_data)
-{
-}
-
-const GDBusInterfaceVTable vtable =
-{
-  vino_dbus_listener_method_call,
-  vino_dbus_listener_get_property,
+  VinoServer      *server;
 };
 
-static gboolean
-vino_dbus_listener_get_external_port (VinoDBusListener *listener,
-                                      gint             *ret,
-                                      GError           **error);
-
-static gboolean
-vino_dbus_listener_get_internal_data (VinoDBusListener *listener,
-                                      char             **hostname,
-                                      char             **avahi_hostname,
-                                      gint             *port,
-                                      GError           **error);
+typedef GObjectClass VinoDBusListenerClass;
 
-static void vino_dbus_listener_set_server (VinoDBusListener *listener,
-                                           VinoServer       *server);
+static GType vino_dbus_listener_get_type (void);
+G_DEFINE_TYPE (VinoDBusListener, vino_dbus_listener, G_TYPE_OBJECT)
 
 static char *
 get_local_hostname (VinoDBusListener *listener)
@@ -142,7 +96,7 @@ get_local_hostname (VinoDBusListener *listener)
   gpointer            key, value;
 
   retval = NULL;
-  server_iface = vino_server_get_network_interface (listener->priv->server);
+  server_iface = vino_server_get_network_interface (listener->server);
   ipv4 = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
   ipv6 = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
 
@@ -213,6 +167,7 @@ get_local_hostname (VinoDBusListener *listener)
 }
 
 #ifdef HAVE_TELEPATHY_GLIB
+
 static void
 vino_dbus_listener_dispose (GObject *object)
 {
@@ -230,246 +185,128 @@ vino_dbus_listener_dispose (GObject *object)
 #endif
 
 static void
-vino_dbus_listener_set_property (GObject       *object,
-                                 guint          prop_id,
-                                 const GValue  *value,
-                                 GParamSpec    *pspec)
-{
-  VinoDBusListener *listener = VINO_DBUS_LISTENER (object);
-
-  switch (prop_id)
-    {
-    case PROP_SERVER:
-      vino_dbus_listener_set_server (listener, g_value_get_object (value));
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-    }
-}
-
-static void
-vino_dbus_listener_get_property (GObject    *object,
-                                 guint       prop_id,
-                                 GValue     *value,
-                                 GParamSpec *pspec)
-{
-  VinoDBusListener *listener = VINO_DBUS_LISTENER (object);
-
-  switch (prop_id)
-    {
-    case PROP_SERVER:
-      g_value_set_object (value, listener->priv->server);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-    }
-}
-
-static void
 vino_dbus_listener_init (VinoDBusListener *listener)
 {
-  listener->priv = G_TYPE_INSTANCE_GET_PRIVATE (listener, VINO_TYPE_DBUS_LISTENER, VinoDBusListenerPrivate);
 #ifdef HAVE_TELEPATHY_GLIB
   listener->priv->manager = vino_tube_servers_manager_new ();
 #endif
 }
 
-static guint signal_server_info_changed = 0;
-
 static void
 vino_dbus_listener_class_init (VinoDBusListenerClass *klass)
 {
+#ifdef HAVE_TELEPATHY_GLIB
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-#ifdef HAVE_TELEPATHY_GLIB
   object_class->dispose = vino_dbus_listener_dispose;
 #endif
-  object_class->get_property = vino_dbus_listener_get_property;
-  object_class->set_property = vino_dbus_listener_set_property;
-
-  signal_server_info_changed = g_signal_new ("server_info_changed", 
-      G_OBJECT_CLASS_TYPE (klass), 
-      (G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED),
-      0,
-      NULL, NULL,
-      g_cclosure_marshal_VOID__VOID,
-      G_TYPE_NONE, 0);
-
-  g_object_class_install_property (object_class,
-				   PROP_SERVER,
-				   g_param_spec_object ("server",
-							"Server",
-							"The server",
-							VINO_TYPE_SERVER,
-							G_PARAM_READWRITE      |
-							G_PARAM_CONSTRUCT_ONLY |
-							G_PARAM_STATIC_NAME    |
-							G_PARAM_STATIC_NICK    |
-							G_PARAM_STATIC_BLURB));
-
-  g_type_class_add_private (klass, sizeof (VinoDBusListenerPrivate));
 }
 
-VinoDBusListener *
-vino_dbus_listener_new (VinoServer *server)
-{
-  g_return_val_if_fail (VINO_IS_SERVER (server), NULL);
-
-  return g_object_new (VINO_TYPE_DBUS_LISTENER,
-                       "server", server,
-                       NULL);
-}
-
-static gboolean
-vino_dbus_listener_get_external_port (VinoDBusListener *listener,
-                                      gint             *ret,
-                                      GError           **error)
-{
-  *ret = vino_server_get_external_port (listener->priv->server);
-
-  return TRUE;
-}
-
-
-static gboolean
-vino_dbus_listener_get_internal_data (VinoDBusListener *listener,
-                                      char             **hostname,
-                                      char             **avahi_hostname,
-                                      gint             *port,
-                                      GError           **error)
+static guint16
+vino_dbus_listener_get_port (VinoDBusListener *listener)
 {
 #ifdef VINO_ENABLE_HTTP_SERVER
-  *port = vino_get_http_server_port (listener->priv->server);
+  return vino_get_http_server_port (listener->server);
 #else
-  *port = vino_server_get_port (listener->priv->server);
+  return vino_server_get_port (listener->server);
 #endif
-
-  *hostname = get_local_hostname (listener);
-  *avahi_hostname = g_strdup (vino_mdns_get_hostname ());
-
-  return TRUE;
 }
 
-static void
-vino_dbus_listener_info_changed (VinoServer *server,
-                                 GParamSpec *property,
-                                 VinoDBusListener *listener)
+static GVariant *
+vino_dbus_listener_get_property (GDBusConnection  *connection,
+                                 const gchar      *sender,
+                                 const gchar      *object_path,
+                                 const gchar      *interface_name,
+                                 const gchar      *property_name,
+                                 GError          **error,
+                                 gpointer          user_data)
 {
-  dprintf (DBUS, "Emitting ServerInfoChanged signal\n");
-  g_signal_emit (listener, signal_server_info_changed, 0);
-}
+  VinoDBusListener *listener = user_data;
 
-static void
-vino_dbus_listener_set_server (VinoDBusListener *listener,
-                               VinoServer       *server)
-{
-  DBusGConnection *conn;
-  GdkScreen       *screen;
-  char            *obj_path;
+  if (strcmp (property_name, "Host") == 0)
+    {
+      gchar *local_hostname;
+      GVariant *result;
 
-  g_assert (listener->priv->server == NULL);
+      local_hostname = get_local_hostname (listener);
+      if (local_hostname)
+        result = g_variant_new_string (local_hostname);
+      else
+        result = g_variant_new_string ("");
+      g_free (local_hostname);
 
-  listener->priv->server = server;
+      return result;
+    }
 
-  if (!(conn = vino_dbus_get_connection ()))
-    return;
+  else if (strcmp (property_name, "Port") == 0)
+    return g_variant_new_uint16 (vino_dbus_listener_get_port (listener));
 
-  screen = vino_server_get_screen (listener->priv->server);
+  else if (strcmp (property_name, "ExternalHost") == 0)
+    {
+      gchar *external_ip;
+      GVariant *result;
 
-  obj_path = g_strdup_printf ("/org/gnome/vino/screens/%d",
-                              gdk_screen_get_number (screen));
+      external_ip = vino_server_get_external_ip (listener->server);
+      if (external_ip)
+        result = g_variant_new_string (external_ip);
+      else
+        result = g_variant_new_string ("");
+      g_free (external_ip);
 
-  dbus_g_connection_register_g_object (conn, obj_path, G_OBJECT (listener));
+      return result;
+    }
 
-  dprintf (DBUS, "Object registered at path '%s'\n", obj_path);
+  else if (strcmp (property_name, "ExternalPort") == 0)
+    return g_variant_new_uint16 (vino_server_get_external_port (listener->server));
 
-  g_signal_connect (server,
-		    "notify::alternative-port",
-		    G_CALLBACK (vino_dbus_listener_info_changed),
-		    listener);
+  else if (strcmp (property_name, "AvahiHost") == 0)
+    return g_variant_new_string ("aaa");
 
-  g_free (obj_path);
+  else
+    g_assert_not_reached ();
 }
 
-VinoServer *
-vino_dbus_listener_get_server (VinoDBusListener *listener)
-{
-  g_return_val_if_fail (VINO_IS_DBUS_LISTENER (listener), NULL);
 
-  return listener->priv->server;
+VinoDBusListener *
+vino_dbus_listener_new (gint screen)
+{
+  static const GDBusInterfaceVTable vtable = {
+    NULL, vino_dbus_listener_get_property
+  };
+  VinoDBusListener *listener;
+
+  listener = g_object_new (vino_dbus_listener_get_type (), NULL);
+  listener->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+  listener->path = g_strdup_printf ("%s%d",
+                                    ORG_GNOME_VINO_SCREEN_PATH_PREFIX,
+                                    screen);
+  listener->screen = screen;
+
+  g_dbus_connection_register_object (listener->connection, listener->path,
+                                     ORG_GNOME_VINO_SCREEN_INTERFACE,
+                                     &vtable, listener, NULL, NULL);
+
+  return listener;
 }
 
-static DBusGConnection *vino_dbus_connection = NULL;
-static gboolean        vino_dbus_failed_to_connect = FALSE;
 
-DBusGConnection *
-vino_dbus_get_connection (void)
+void
+vino_dbus_listener_set_server (VinoDBusListener *listener,
+                               VinoServer       *server)
 {
-  if (vino_dbus_connection == NULL && !vino_dbus_failed_to_connect)
-    {
-      GError *error = NULL;
+  g_assert (listener->server == NULL);
+  g_assert_cmpint (listener->screen, ==,
+                   gdk_screen_get_number (vino_server_get_screen (server)));
 
-      if ((vino_dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error)))
-	{
-	  DBusConnection * dbus_conn;
+  listener->server = server;
 
-	  dprintf (DBUS, "Successfully connected to the message bus\n");
-	  dbus_conn = dbus_g_connection_get_connection (vino_dbus_connection);
-	  dbus_connection_set_exit_on_disconnect (dbus_conn, FALSE);
-	}
-      else
-	{
-	  vino_dbus_failed_to_connect = TRUE;
-	  dprintf (DBUS, "Failed to open connection to bus: %s\n", error->message);
-	  g_error_free (error);
-	}
-    }
-
-  return vino_dbus_connection;
+  /* XXX: emit property change signal, watch for more changes
+   */
 }
 
 gboolean
 vino_dbus_request_name (void)
 {
-
-  DBusGConnection *connection;
-  DBusGProxy      *bus_proxy;
-  guint           request_name_result;
-  GError          *error = NULL;
-
-  if (!(connection = vino_dbus_get_connection ()))
-    return FALSE;
-
-  dbus_g_object_type_install_info (VINO_TYPE_DBUS_LISTENER,
-				   &dbus_glib_vino_dbus_listener_object_info);
-
-  bus_proxy = dbus_g_proxy_new_for_name (connection,
-      "org.freedesktop.DBus",
-      "/org/freedesktop/DBus",
-      "org.freedesktop.DBus");
-
-  if (!dbus_g_proxy_call (bus_proxy,
-			  "RequestName",
-			  &error,
-			  G_TYPE_STRING, VINO_DBUS_BUS_NAME,
-			  G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE,
-			  G_TYPE_INVALID,
-			  G_TYPE_UINT, &request_name_result,
-			  G_TYPE_INVALID))
-    {
-      dprintf (DBUS, "Failed to request DBUS name: %s", error ? error->message : "No error given");
-      g_clear_error (&error);
-      return FALSE;
-    }
-
-  if (request_name_result == DBUS_REQUEST_NAME_REPLY_EXISTS)
-    {
-      g_warning (_("Remote Desktop server already running; exiting ...\n"));
-      return FALSE;
-    }
-
-  dprintf (DBUS, "Successfully acquired D-Bus name '%s'\n", VINO_DBUS_BUS_NAME);
+  g_application_new ("org.gnome.Vino", 0, NULL);
   return TRUE;
 }
diff --git a/server/vino-dbus-listener.h b/server/vino-dbus-listener.h
index e3250ca..7cf9baf 100644
--- a/server/vino-dbus-listener.h
+++ b/server/vino-dbus-listener.h
@@ -31,37 +31,12 @@
 
 #include "vino-server.h"
 
-G_BEGIN_DECLS
-
-#define VINO_TYPE_DBUS_LISTENER         (vino_dbus_listener_get_type ())
-#define VINO_DBUS_LISTENER(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), VINO_TYPE_DBUS_LISTENER, VinoDBusListener))
-#define VINO_DBUS_LISTENER_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), VINO_TYPE_DBUS_LISTENER, VinoDBusListenerClass))
-#define VINO_IS_DBUS_LISTENER(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), VINO_TYPE_DBUS_LISTENER))
-#define VINO_IS_DBUS_LISTENER_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), VINO_TYPE_DBUS_LISTENER))
-#define VINO_DBUS_LISTENER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), VINO_TYPE_DBUS_LISTENER, VinoDBusListenerClass))
-
 typedef struct _VinoDBusListener        VinoDBusListener;
-typedef struct _VinoDBusListenerClass   VinoDBusListenerClass;
-typedef struct _VinoDBusListenerPrivate VinoDBusListenerPrivate;
-
-struct _VinoDBusListener
-{
-  GObject                   base;
 
-  VinoDBusListenerPrivate  *priv;
-};
-
-struct _VinoDBusListenerClass
-{
-  GObjectClass  base_class;
-};
-
-GType              vino_dbus_listener_get_type   (void) G_GNUC_CONST;
-VinoDBusListener * vino_dbus_listener_new        (VinoServer       *server);
-VinoServer        *vino_dbus_listener_get_server (VinoDBusListener *listener);
+VinoDBusListener *      vino_dbus_listener_new          (gint screen);
+void                    vino_dbus_listener_set_server   (VinoDBusListener *listener,
+                                                         VinoServer       *server);
 
 gboolean        vino_dbus_request_name     (void);
 
-G_END_DECLS
-
 #endif /* __VINO_DBUS_LISTENER_H__ */
diff --git a/server/vino-main.c b/server/vino-main.c
index 54d119e..cbf5337 100644
--- a/server/vino-main.c
+++ b/server/vino-main.c
@@ -114,7 +114,7 @@ main (int argc, char **argv)
 
   n_screens = gdk_display_get_n_screens (display);
   for (i = 0; i < n_screens; i++)
-    vino_prefs_create_server (gdk_display_get_screen (display, i));
+    vino_dbus_listener_set_server (vino_dbus_listener_new (i), vino_prefs_create_server (gdk_display_get_screen (display, i)));
 
   gtk_main ();
 
diff --git a/server/vino-prefs.c b/server/vino-prefs.c
index 0c988f4..ccdd825 100644
--- a/server/vino-prefs.c
+++ b/server/vino-prefs.c
@@ -60,7 +60,7 @@ get_inverted_boolean (GValue   *value,
   return TRUE;
 }
 
-void
+VinoServer *
 vino_prefs_create_server (GdkScreen *screen)
 {
   VinoServer     *server;
@@ -116,6 +116,8 @@ vino_prefs_create_server (GdkScreen *screen)
   g_signal_connect (server, "notify::alternative-port", G_CALLBACK (vino_prefs_restart_mdns), NULL);
   g_signal_connect (server, "notify::use-alternative-port", G_CALLBACK(vino_prefs_restart_mdns), NULL);
   g_signal_connect (server, "notify::network-interface", G_CALLBACK (vino_prefs_restart_mdns), NULL);
+
+  return server;
 }
 
 static void
diff --git a/server/vino-prefs.h b/server/vino-prefs.h
index 77374ef..ee1d090 100644
--- a/server/vino-prefs.h
+++ b/server/vino-prefs.h
@@ -29,7 +29,7 @@
 G_BEGIN_DECLS
 
 void vino_prefs_init          (gboolean   view_only);
-void vino_prefs_create_server (GdkScreen *screen);
+VinoServer *vino_prefs_create_server (GdkScreen *screen);
 void vino_prefs_shutdown      (void);
 
 G_END_DECLS
diff --git a/server/vino-server.c b/server/vino-server.c
index 2a76b54..ba26daa 100644
--- a/server/vino-server.c
+++ b/server/vino-server.c
@@ -33,7 +33,6 @@
 #include "vino-input.h"
 #include "vino-cursor.h"
 #include "vino-prompt.h"
-#include "vino-dbus-listener.h"
 #include "vino-util.h"
 #include "vino-upnp.h"
 #include "vino-enums.h"
@@ -61,8 +60,6 @@ struct _VinoServerPrivate
   VinoPrompt       *prompt;
   VinoStatusIcon   *icon;
   gboolean          display_status_icon;
-  VinoDBusListener *listener;
-  gboolean          use_dbus_listener;
   VinoUpnp         *upnp;
 
   GIOChannel       *io_channel[RFB_MAX_SOCKETLISTEN];
@@ -1127,10 +1124,6 @@ vino_server_finalize (GObject *object)
     g_object_unref (server->priv->fb);
   server->priv->fb = NULL;
 
-  if (server->priv->listener)
-    g_object_unref (server->priv->listener);
-  server->priv->listener = NULL;
-
   if (server->priv->icon)
     g_object_unref (server->priv->icon);
   server->priv->icon = NULL;
@@ -1171,9 +1164,6 @@ vino_server_set_property (GObject      *object,
     case PROP_DISPLAY_STATUS_ICON:
       vino_server_set_display_status_icon (server, g_value_get_boolean (value));
       break;
-    case PROP_USE_DBUS_LISTENER:
-      vino_server_set_use_dbus_listener (server, g_value_get_boolean (value));
-      break;
     case PROP_NETWORK_INTERFACE:
       vino_server_set_network_interface (server, g_value_get_string (value));
       break;
@@ -1235,9 +1225,6 @@ vino_server_get_property (GObject    *object,
     case PROP_DISPLAY_STATUS_ICON:
       g_value_set_boolean (value, server->priv->display_status_icon);
       break;
-    case PROP_USE_DBUS_LISTENER:
-      g_value_set_boolean (value, server->priv->use_dbus_listener);
-      break;
     case PROP_NETWORK_INTERFACE:
       g_value_set_string (value, server->priv->network_interface);
       break;
@@ -1282,11 +1269,6 @@ vino_server_constructed (GObject *object)
 {
   VinoServer *server = VINO_SERVER (object);
 
-  if (server->priv->use_dbus_listener)
-    server->priv->listener = vino_dbus_listener_new (server);
-  else
-    server->priv->listener = NULL;
-
   if (server->priv->display_status_icon)
     server->priv->icon = vino_status_icon_new (server, server->priv->screen);
   else
@@ -1370,17 +1352,6 @@ vino_server_class_init (VinoServerClass *klass)
                                                          G_PARAM_CONSTRUCT   |
                                                          G_PARAM_STATIC_STRINGS));
 
-   g_object_class_install_property (gobject_class,
-				   PROP_USE_DBUS_LISTENER,
-				   g_param_spec_boolean ("use-dbus-listener",
-							 "Use the dbus listener",
-							 "Allow to use the dbus listener",
-							 TRUE,
-                                                         G_PARAM_READWRITE   |
-                                                         G_PARAM_CONSTRUCT   |
-                                                         G_PARAM_STATIC_STRINGS));
-
-
   g_object_class_install_property (gobject_class,
 				   PROP_NETWORK_INTERFACE,
 				   g_param_spec_string ("network-interface",
@@ -1573,15 +1544,6 @@ vino_server_set_display_status_icon (VinoServer *server,
   server->priv->display_status_icon = display_status_icon;
 }
 
-void
-vino_server_set_use_dbus_listener (VinoServer *server,
-    gboolean use_dbus_listener)
-{
-  g_return_if_fail (VINO_IS_SERVER (server));
-
-  server->priv->use_dbus_listener = use_dbus_listener;
-}
-
 G_CONST_RETURN char *
 vino_server_get_network_interface (VinoServer *server)
 {
@@ -1872,14 +1834,31 @@ vino_server_get_port (VinoServer *server)
   return server->priv->rfb_screen->rfbPort;
 }
 
-int
+guint16
 vino_server_get_external_port (VinoServer *server)
 {
   g_return_val_if_fail (VINO_IS_SERVER (server), 0);
 
-  return server->priv->use_upnp && VINO_IS_UPNP (server->priv->upnp) ?
-           vino_upnp_get_external_port (server->priv->upnp) :
-           server->priv->rfb_screen->rfbPort;
+  if (server->priv->use_upnp && server->priv->upnp)
+    {
+      gint port = vino_upnp_get_external_port (server->priv->upnp);
+
+      if (port > 0)
+        return port;
+    }
+
+  return 0;
+}
+
+gchar *
+vino_server_get_external_ip (VinoServer *server)
+{
+  g_return_val_if_fail (VINO_IS_SERVER (server), 0);
+
+  if (server->priv->use_upnp && server->priv->upnp)
+    return vino_upnp_get_external_ip (server->priv->upnp);
+
+  return NULL;
 }
 
 gboolean
diff --git a/server/vino-server.h b/server/vino-server.h
index 27b5cd6..21835e3 100644
--- a/server/vino-server.h
+++ b/server/vino-server.h
@@ -90,7 +90,8 @@ int                  vino_server_get_alternative_port     (VinoServer     *serve
 void                 vino_server_set_alternative_port     (VinoServer     *server,
 							   int             alternative_port);
 int                  vino_server_get_port                 (VinoServer     *server);
-int                  vino_server_get_external_port        (VinoServer     *server);
+gchar *              vino_server_get_external_ip          (VinoServer     *server);
+guint16              vino_server_get_external_port        (VinoServer     *server);
 
 void                 vino_server_set_network_interface    (VinoServer     *server,
                                                            const char     *network_interface);



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