[vino] Add VinoTubeServersManager



commit 50af44c97cfae540861c71bc2f5f1ede58403fb2
Author: Arnaud Maillet <arnaud maillet collabora co uk>
Date:   Thu May 14 14:32:40 2009 +0200

    Add VinoTubeServersManager
---
 server/vino-tube-servers-manager.c |  147 ++++++++++++++++++++++++++++++++++++
 server/vino-tube-servers-manager.h |   69 +++++++++++++++++
 2 files changed, 216 insertions(+), 0 deletions(-)

diff --git a/server/vino-tube-servers-manager.c b/server/vino-tube-servers-manager.c
new file mode 100644
index 0000000..36ef440
--- /dev/null
+++ b/server/vino-tube-servers-manager.c
@@ -0,0 +1,147 @@
+/*
+ * © 2009, Collabora Ltd
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors:
+ *      Arnaud Maillet <arnaud maillet collabora co uk>
+ */
+
+#include <glib-object.h>
+#include <gdk/gdk.h>
+#include <dbus/dbus-glib.h>
+
+#include "vino-tube-servers-manager.h"
+#include "vino-tube-server.h"
+#include "vino-dbus-error.h"
+
+G_DEFINE_TYPE (VinoTubeServersManager, vino_tube_servers_manager,
+    G_TYPE_OBJECT);
+
+#define VINO_TUBE_SERVERS_MANAGER_GET_PRIVATE(obj)\
+    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), VINO_TYPE_TUBE_SERVERS_MANAGER,\
+    VinoTubeServersManagerPrivate))
+
+struct _VinoTubeServersManagerPrivate
+{
+  GSList *vino_tube_servers;
+  guint alternative_port;
+};
+
+static void
+vino_tube_servers_manager_dispose (GObject *object)
+{
+  VinoTubeServersManager *self = VINO_TUBE_SERVERS_MANAGER (object);
+  GSList *l;
+
+  for (l = self->priv->vino_tube_servers; l; l = l->next)
+    g_object_unref (l->data);
+
+  g_slist_free (self->priv->vino_tube_servers);
+  self->priv->vino_tube_servers = NULL;
+
+  g_debug ("Destruction of the VinoTubeServersManager\n");
+
+  if (G_OBJECT_CLASS (vino_tube_servers_manager_parent_class)->dispose)
+    G_OBJECT_CLASS (vino_tube_servers_manager_parent_class)->dispose (object);
+}
+
+static void
+vino_tube_servers_manager_class_init (VinoTubeServersManagerClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  g_debug ("Creation of the VinoTubeServersManager\n");
+
+  gobject_class->dispose = vino_tube_servers_manager_dispose;
+
+  g_type_class_add_private (klass, sizeof (VinoTubeServersManagerPrivate));
+}
+
+static void
+vino_tube_servers_manager_init (VinoTubeServersManager *self)
+{
+  self->priv = VINO_TUBE_SERVERS_MANAGER_GET_PRIVATE (self);
+  self->priv->vino_tube_servers = NULL;
+  self->priv->alternative_port = 26570;
+}
+
+static void
+vino_tube_servers_manager_disconnected_cb (VinoTubeServer *server,
+    gpointer object)
+{
+  VinoTubeServersManager *self = VINO_TUBE_SERVERS_MANAGER (object);
+  self->priv->vino_tube_servers = g_slist_remove
+      (self->priv->vino_tube_servers, server);
+  g_object_unref (server);
+}
+
+gboolean
+vino_tube_servers_manager_share_with_tube
+    (VinoTubeServersManager * object, const gchar *connection_path,
+    const gchar *tube_path, GHashTable *channel_properties, GError **error)
+{
+  VinoTubeServersManager *self = VINO_TUBE_SERVERS_MANAGER (object);
+  VinoTubeServer *server;
+  GdkDisplay *display;
+  GdkScreen *screen;
+  VinoStatusIcon *icon;
+  /* the server is listenning only on lo as only the tube is supposed to
+  connect to it */
+  gchar * network_interface = "lo";
+
+  display = gdk_display_get_default ();
+  screen = gdk_display_get_default_screen (display);
+
+  server = g_object_new (VINO_TYPE_TUBE_SERVER,
+      "use-dbus-listener",    0,
+      "prompt-enabled",       0,
+      "view-only",            0,
+      "network-interface",    network_interface,
+      "use-alternative-port", 1,
+      "alternative-port",     self->priv->alternative_port,
+      "auth-methods",         1,
+      "require-encryption",   0,
+      "vnc-password",         NULL,
+      "on-hold",              0,
+      "screen",               screen,
+      "lock-screen",          0,
+      "disable-background",   0,
+      "use-upnp",             0,
+      "connection-path",      connection_path,
+      "tube-path",            tube_path,
+      "channel-properties",   channel_properties,
+      NULL);
+
+  self->priv->vino_tube_servers = g_slist_prepend
+      (self->priv->vino_tube_servers, server);
+
+  g_signal_connect (G_OBJECT (server), "disconnected", G_CALLBACK
+      (vino_tube_servers_manager_disconnected_cb), self);
+
+  icon = vino_server_get_status_icon (VINO_SERVER(server));
+  vino_status_icon_set_visibility (icon, VINO_STATUS_ICON_VISIBILITY_CLIENT);
+
+  self->priv->alternative_port++;
+
+  return vino_tube_server_share_with_tube (server, error);
+}
+
+VinoTubeServersManager *
+vino_tube_servers_manager_new (void)
+{
+  return g_object_new (VINO_TYPE_TUBE_SERVERS_MANAGER, NULL);
+}
diff --git a/server/vino-tube-servers-manager.h b/server/vino-tube-servers-manager.h
new file mode 100644
index 0000000..afcca7f
--- /dev/null
+++ b/server/vino-tube-servers-manager.h
@@ -0,0 +1,69 @@
+/*
+ * © 2009, Collabora Ltd
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors:
+ *      Arnaud Maillet <arnaud maillet collabora co uk>
+ */
+
+#ifndef __VINAGRE_TUBE_SERVERS_MANAGER_H__
+#define __VINAGRE_TUBE_SERVERS_MANAGER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define VINO_TYPE_TUBE_SERVERS_MANAGER (vino_tube_servers_manager_get_type())
+#define VINO_TUBE_SERVERS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
+    VINO_TYPE_TUBE_SERVERS_MANAGER, VinoTubeServersManager))
+#define VINO_IS_TUBE_SERVERS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
+    VINO_TYPE_TUBE_SERVERS_MANAGER))
+#define VINO_TUBE_SERVERS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST\
+    ((klass), VINO_TYPE_TUBE_SERVERS_MANAGER, VinoTubeServersManagerClass))
+#define VINO_IS_TUBE_SERVERS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE \
+    ((klass), VINO_TYPE_TUBE_SERVERS_MANAGER))
+#define VINO_TUBE_SERVERS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+    ((obj), VINO_TYPE_TUBE_SERVERS_MANAGER, VinoTubeServersManagerClass))
+
+typedef struct _VinoTubeServersManager VinoTubeServersManager;
+typedef struct _VinoTubeServersManagerClass VinoTubeServersManagerClass;
+typedef struct _VinoTubeServersManagerPrivate VinoTubeServersManagerPrivate;
+
+struct _VinoTubeServersManager
+{
+  GObject parent_instance;
+  VinoTubeServersManagerPrivate *priv;
+};
+
+struct _VinoTubeServersManagerClass
+{
+  GObjectClass parent_class;
+};
+
+GType vino_tube_servers_manager_get_type (void) G_GNUC_CONST;
+VinoTubeServersManager* vino_tube_servers_manager_new (void);
+
+gboolean vino_tube_servers_manager_share_with_tube
+    (VinoTubeServersManager * object,
+    const gchar *connection_path,
+    const gchar *tube_path,
+    GHashTable *channel_properties,
+    GError **error);
+
+G_END_DECLS
+
+#endif
\ No newline at end of file



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