~ubuntu-branches/ubuntu/trusty/vino/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/12_app-indicators-only.patch/server/vino-tube-servers-manager.c

  • Committer: Package Import Robot
  • Author(s): Ken VanDine
  • Date: 2012-05-10 14:43:03 UTC
  • Revision ID: package-import@ubuntu.com-20120510144303-qdt97nysl2s6wql4
Tags: 3.4.1-0ubuntu2
* debian/patches/12_app-indicators-only.patch
  - Removed non-existing property which was only set if using 
    the appindicator (LP: #997699)
* debian/control.in
  - use latest standards version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * © 2009, Collabora Ltd
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or
5
 
 * modify it under the terms of the GNU General Public License as
6
 
 * published by the Free Software Foundation; either version 2 of the
7
 
 * License, or (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful, but
10
 
 * WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
 * General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17
 
 * 02111-1307, USA.
18
 
 *
19
 
 * Authors:
20
 
 *      Arnaud Maillet <arnaud.maillet@collabora.co.uk>
21
 
 */
22
 
 
23
 
#include <glib-object.h>
24
 
#include <gdk/gdk.h>
25
 
#include <dbus/dbus-glib.h>
26
 
 
27
 
#include <telepathy-glib/telepathy-glib.h>
28
 
 
29
 
#include "vino-tube-servers-manager.h"
30
 
#include "vino-server.h"
31
 
#include "vino-tube-server.h"
32
 
#include "vino-dbus-error.h"
33
 
#include "vino-status-tube-icon.h"
34
 
#include "vino-util.h"
35
 
 
36
 
G_DEFINE_TYPE (VinoTubeServersManager, vino_tube_servers_manager,
37
 
    G_TYPE_OBJECT);
38
 
 
39
 
#define VINO_TUBE_SERVERS_MANAGER_GET_PRIVATE(obj)\
40
 
    (G_TYPE_INSTANCE_GET_PRIVATE ((obj), VINO_TYPE_TUBE_SERVERS_MANAGER,\
41
 
    VinoTubeServersManagerPrivate))
42
 
 
43
 
static void handle_channels_cb (TpSimpleHandler *handler,
44
 
    TpAccount *account,
45
 
    TpConnection *connection,
46
 
    GList *channels,
47
 
    GList *requests_satisfied,
48
 
    gint64 user_action_time,
49
 
    TpHandleChannelsContext *context,
50
 
    gpointer user_data);
51
 
 
52
 
struct _VinoTubeServersManagerPrivate
53
 
{
54
 
  GSList *vino_tube_servers;
55
 
  guint alternative_port;
56
 
 
57
 
  TpBaseClient *handler;
58
 
};
59
 
 
60
 
static void
61
 
vino_tube_servers_manager_dispose (GObject *object)
62
 
{
63
 
  VinoTubeServersManager *self = VINO_TUBE_SERVERS_MANAGER (object);
64
 
  GSList *l;
65
 
 
66
 
  for (l = self->priv->vino_tube_servers; l; l = l->next)
67
 
    g_object_unref (l->data);
68
 
 
69
 
  g_slist_free (self->priv->vino_tube_servers);
70
 
  self->priv->vino_tube_servers = NULL;
71
 
 
72
 
  dprintf (TUBE, "Destruction of the VinoTubeServersManager\n");
73
 
 
74
 
  if (G_OBJECT_CLASS (vino_tube_servers_manager_parent_class)->dispose)
75
 
    G_OBJECT_CLASS (vino_tube_servers_manager_parent_class)->dispose (object);
76
 
}
77
 
 
78
 
static void
79
 
vino_tube_servers_manager_class_init (VinoTubeServersManagerClass *klass)
80
 
{
81
 
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
82
 
 
83
 
  dprintf (TUBE, "Creation of the VinoTubeServersManager\n");
84
 
 
85
 
  gobject_class->dispose = vino_tube_servers_manager_dispose;
86
 
 
87
 
  g_type_class_add_private (klass, sizeof (VinoTubeServersManagerPrivate));
88
 
}
89
 
 
90
 
static void
91
 
vino_tube_servers_manager_init (VinoTubeServersManager *self)
92
 
{
93
 
  TpDBusDaemon *dbus;
94
 
  GError *error = NULL;
95
 
 
96
 
  self->priv = VINO_TUBE_SERVERS_MANAGER_GET_PRIVATE (self);
97
 
  self->priv->vino_tube_servers = NULL;
98
 
  self->priv->alternative_port = 26570;
99
 
 
100
 
  dbus = tp_dbus_daemon_dup (NULL);
101
 
 
102
 
  self->priv->handler = tp_simple_handler_new (dbus, FALSE, FALSE, "Vino",
103
 
      FALSE, handle_channels_cb, self, NULL);
104
 
 
105
 
  g_object_unref (dbus);
106
 
 
107
 
  tp_base_client_take_handler_filter (self->priv->handler, tp_asv_new (
108
 
        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
109
 
          TP_IFACE_CHANNEL_TYPE_STREAM_TUBE,
110
 
        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
111
 
          TP_HANDLE_TYPE_CONTACT,
112
 
        TP_PROP_CHANNEL_REQUESTED, G_TYPE_BOOLEAN,
113
 
          TRUE,
114
 
        TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING,
115
 
          "rfb",
116
 
        NULL));
117
 
 
118
 
  if (!tp_base_client_register (self->priv->handler, &error))
119
 
    {
120
 
      dprintf (TUBE, "Failed to register Handler: %s\n", error->message);
121
 
      g_error_free (error);
122
 
    }
123
 
}
124
 
 
125
 
static void
126
 
vino_tube_servers_manager_disconnected_cb (VinoTubeServer *server,
127
 
    gpointer object)
128
 
{
129
 
  VinoTubeServersManager *self = VINO_TUBE_SERVERS_MANAGER (object);
130
 
  self->priv->vino_tube_servers = g_slist_remove
131
 
      (self->priv->vino_tube_servers, server);
132
 
  g_object_unref (server);
133
 
}
134
 
 
135
 
VinoTubeServersManager *
136
 
vino_tube_servers_manager_new (void)
137
 
{
138
 
  return g_object_new (VINO_TYPE_TUBE_SERVERS_MANAGER, NULL);
139
 
}
140
 
 
141
 
static void
142
 
handle_channels_cb (TpSimpleHandler *handler,
143
 
    TpAccount *account,
144
 
    TpConnection *connection,
145
 
    GList *channels,
146
 
    GList *requests_satisfied,
147
 
    gint64 user_action_time,
148
 
    TpHandleChannelsContext *context,
149
 
    gpointer user_data)
150
 
{
151
 
  VinoTubeServersManager *self = user_data;
152
 
  VinoTubeServer *server;
153
 
  GdkDisplay *display;
154
 
  GdkScreen *screen;
155
 
  /* the server is listenning only on lo as only the tube is supposed to
156
 
  connect to it */
157
 
  gchar * network_interface = "lo";
158
 
  GList *l;
159
 
  TpChannel *channel = NULL;
160
 
 
161
 
  for (l = channels; l != NULL; l = g_list_next (l))
162
 
    {
163
 
      TpChannel *chan = l->data;
164
 
      const gchar *service;
165
 
 
166
 
      if (tp_channel_get_channel_type_id (chan) !=
167
 
          TP_IFACE_QUARK_CHANNEL_TYPE_STREAM_TUBE)
168
 
        continue;
169
 
 
170
 
      if (tp_proxy_get_invalidated (chan) != NULL)
171
 
        continue;
172
 
 
173
 
      service = tp_asv_get_string (
174
 
          tp_channel_borrow_immutable_properties (chan),
175
 
          TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE);
176
 
 
177
 
      if (tp_strdiff (service, "rfb"))
178
 
        continue;
179
 
 
180
 
      channel = chan;
181
 
      break;
182
 
    }
183
 
 
184
 
  if (channel == NULL)
185
 
    {
186
 
      /* No stream tube channel ?! */
187
 
      GError error = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
188
 
          "No stream tube channel" };
189
 
 
190
 
      tp_handle_channels_context_fail (context, &error);
191
 
      return;
192
 
    }
193
 
 
194
 
  display = gdk_display_get_default ();
195
 
  screen = gdk_display_get_default_screen (display);
196
 
 
197
 
  server = g_object_new (VINO_TYPE_TUBE_SERVER,
198
 
      "display-status-icon",  0,
199
 
      "prompt-enabled",       0,
200
 
      "view-only",            0,
201
 
      "network-interface",    network_interface,
202
 
      "use-alternative-port", 1,
203
 
      "alternative-port",     self->priv->alternative_port,
204
 
      "auth-methods",         1,
205
 
      "require-encryption",   0,
206
 
      "vnc-password",         NULL,
207
 
      "on-hold",              0,
208
 
      "screen",               screen,
209
 
      "lock-screen",          0,
210
 
      "disable-background",   0,
211
 
      "use-upnp",             0,
212
 
      "connection",           connection,
213
 
      "tube",                 channel,
214
 
      NULL);
215
 
 
216
 
  self->priv->vino_tube_servers = g_slist_prepend
217
 
      (self->priv->vino_tube_servers, server);
218
 
 
219
 
  g_signal_connect (G_OBJECT (server), "disconnected", G_CALLBACK
220
 
      (vino_tube_servers_manager_disconnected_cb), self);
221
 
 
222
 
  self->priv->alternative_port++;
223
 
 
224
 
  vino_tube_server_share_with_tube (server, NULL);
225
 
 
226
 
  tp_handle_channels_context_accept (context);
227
 
}