vinagre-tube-handler.c 16.6 KB
Newer Older
Arnaud Maillet's avatar
Arnaud Maillet committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * vinagre-tube-handler.c
 * This file is part of vinagre
 *
 * © 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, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *      Arnaud Maillet <arnaud.maillet@collabora.co.uk>
 */

#include <glib-object.h>
#include <glib/gi18n.h>

27
28
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <dbus/dbus-glib.h>
Arnaud Maillet's avatar
Arnaud Maillet committed
29
30
#include <telepathy-glib/contact.h>
#include <telepathy-glib/util.h>
31
#include <telepathy-glib/dbus.h>
32
#include <telepathy-glib/interfaces.h>
Arnaud Maillet's avatar
Arnaud Maillet committed
33
34
35
36
37

#include "vinagre-tube-handler.h"
#include "vinagre-commands.h"
#include "vinagre-tab.h"
#include "vinagre-notebook.h"
38
#include "vinagre-debug.h"
39
#include "vinagre-protocol.h"
40
#include "vinagre-plugins-engine.h"
Arnaud Maillet's avatar
Arnaud Maillet committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

G_DEFINE_TYPE (VinagreTubeHandler, vinagre_tube_handler, G_TYPE_OBJECT);

#define VINAGRE_TUBE_HANDLER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE \
    ((obj), VINAGRE_TYPE_TUBE_HANDLER, VinagreTubeHandlerPrivate))

typedef struct _VinagreTubeHandlerPrivate VinagreTubeHandlerPrivate;

struct _VinagreTubeHandlerPrivate
{
  VinagreWindow *window;
  TpChannel *channel;
  VinagreTab *tab;
  VinagreNotebook *nb;
  gulong signal_disconnect_id;
  gulong signal_invalidated_id;
57
58
  gchar *hostname;
  guint port;
Arnaud Maillet's avatar
Arnaud Maillet committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
};

enum
{
  DISCONNECTED,
  LAST_SIGNAL
};

enum
{
  PROP_0,
  PROP_VINAGRE_WINDOW,
  PROP_CHANNEL
};

static guint signals[LAST_SIGNAL] = { 0 };

static void
vinagre_tube_handler_dispose (GObject *object)
{
  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE(object);

81
82
  vinagre_debug_message (DEBUG_TUBE,
      "-- Destruction of a Tube handler --\n");
Arnaud Maillet's avatar
Arnaud Maillet committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

  if (priv->channel != NULL)
    {
      tp_cli_channel_call_close (priv->channel, -1,
          NULL, NULL, NULL, NULL);
      g_object_unref (priv->channel);
      priv->channel = NULL;
    }

  G_OBJECT_CLASS (vinagre_tube_handler_parent_class)->dispose (object);
}

static void
vinagre_tube_handler_set_vinagre_window (VinagreTubeHandler *self,
    gpointer *vinagre_window)
{
  g_return_if_fail (VINAGRE_IS_TUBE_HANDLER (self));

  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE (self);
  priv->window = VINAGRE_WINDOW (vinagre_window);
}

static void
vinagre_tube_handler_set_channel (VinagreTubeHandler *self,
    gpointer *channel)
{
  g_return_if_fail (VINAGRE_IS_TUBE_HANDLER (self));

  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE (self);
  priv->channel = g_object_ref (channel);
}

static void
vinagre_tube_handler_set_property (GObject *object,
    guint         prop_id,
    const GValue *value,
    GParamSpec   *pspec)
{
  VinagreTubeHandler *self = VINAGRE_TUBE_HANDLER (object);

  switch (prop_id)
    {
    case PROP_VINAGRE_WINDOW:
      vinagre_tube_handler_set_vinagre_window (self,
          g_value_get_object (value));
      break;
    case PROP_CHANNEL:
      vinagre_tube_handler_set_channel (self,
          g_value_get_object (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void
vinagre_tube_handler_get_property (GObject *object,
    guint prop_id,
    GValue *value,
    GParamSpec *pspec)
{
  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE (object);

  switch (prop_id)
    {
    case PROP_VINAGRE_WINDOW:
      g_value_set_object (value, priv->window);
      break;
    case PROP_CHANNEL:
      g_value_set_object (value, priv->channel);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void
vinagre_tube_handler_fire_disconnected (VinagreTubeHandler *self)
{
  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE (self);

  g_signal_handler_disconnect (G_OBJECT (priv->nb),
      priv->signal_disconnect_id);

  if (priv->channel != NULL)
    g_signal_handler_disconnect (G_OBJECT (priv->channel),
        priv->signal_invalidated_id);

  g_signal_emit (G_OBJECT (self), signals[DISCONNECTED], 0);
}

static void
vinagre_tube_handler_tab_disconnected_cb (GtkNotebook *notebook,
    GtkWidget *child,
    guint page_num,
    gpointer self)
{
  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE (self);
  VinagreTab *tab = VINAGRE_TAB (child);

  if (priv->tab == tab)
    {
187
188
      vinagre_debug_message (DEBUG_TUBE,
          "Tab has been destroyed. Closing the tube handler.\n");
Arnaud Maillet's avatar
Arnaud Maillet committed
189
190
191
192
193
194
195
196
197
198
199
200
201
      vinagre_tube_handler_fire_disconnected (self);
    }
}

static void
vinagre_tube_handler_tube_invalidated (TpProxy *channel,
    guint domain,
    gint code,
    gchar *message,
    gpointer self)
{
  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE (self);

202
  vinagre_debug_message (DEBUG_TUBE, "Tube is invalidated : %s\n", message);
Arnaud Maillet's avatar
Arnaud Maillet committed
203
204
205
206
207
208
209
210

  g_object_unref (priv->channel);
  priv->channel = NULL;

  vinagre_tube_handler_fire_disconnected (self);
}

static void
211
212
vinagre_tube_handler_call_service_cb (TpProxy *channel,
    const GValue *service,
Arnaud Maillet's avatar
Arnaud Maillet committed
213
214
215
216
    const GError *error,
    gpointer self,
    GObject *weak_object)
{
217
  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE (self);
Arnaud Maillet's avatar
Arnaud Maillet committed
218
  gchar *error_msg = NULL;
219
  gchar *error_conn_msg = NULL;
Arnaud Maillet's avatar
Arnaud Maillet committed
220
  VinagreConnection *conn = NULL;
221
222
223
  gchar *port_s;
  gchar *host;
  const gchar *service_s;
224
  VinagreProtocol *plugin;
Arnaud Maillet's avatar
Arnaud Maillet committed
225
226
227

  if (error != NULL)
    {
228
      error_msg = g_strdup_printf
229
          (_("Impossible to get service property: %s"),
Arnaud Maillet's avatar
Arnaud Maillet committed
230
          error->message);
231
232
      vinagre_utils_show_error (NULL, (const gchar *) error_msg,
          GTK_WINDOW (priv->window));
233
      g_free (priv->hostname);
234
      g_free (error_msg);
Arnaud Maillet's avatar
Arnaud Maillet committed
235
      g_signal_emit (G_OBJECT (self), signals[DISCONNECTED], 0);
236
      return;
Arnaud Maillet's avatar
Arnaud Maillet committed
237
238
    }

239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
  service_s = g_value_get_string (service);

  vinagre_debug_message (DEBUG_TUBE, "service name = %s\n",
      service_s);

  if (!g_strcmp0 (service_s, "rfb"))
    service_s = "vnc";

  plugin = vinagre_plugins_engine_get_plugin_by_protocol
      (vinagre_plugins_engine_get_default (), service_s);

  if (plugin == NULL)
    {
      error_msg = g_strdup_printf
          (_("The protocol %s is not supported."), service_s);
      vinagre_utils_show_error (NULL, (const gchar *) error_msg,
          GTK_WINDOW (priv->window));
      g_free (priv->hostname);
      g_free (error_msg);
      g_signal_emit (G_OBJECT (self), signals[DISCONNECTED], 0);
      return;
    }

  priv->signal_invalidated_id = g_signal_connect (G_OBJECT (priv->channel),
Arnaud Maillet's avatar
Arnaud Maillet committed
263
264
265
      "invalidated", G_CALLBACK (vinagre_tube_handler_tube_invalidated),
      self);

266
  port_s = g_strdup_printf ("%u", priv->port);
Arnaud Maillet's avatar
Arnaud Maillet committed
267

268
  host = g_strconcat (vinagre_protocol_get_protocol (plugin), "://",
269
270
      priv->hostname, ":", port_s,
      NULL);
Arnaud Maillet's avatar
Arnaud Maillet committed
271

272
273
  vinagre_debug_message (DEBUG_TUBE, "Host = %s\n",
      host);
Arnaud Maillet's avatar
Arnaud Maillet committed
274
275

  g_free (port_s);
276
277
278
279
280
  g_free (priv->hostname);

  conn = vinagre_connection_new_from_string (host, &error_conn_msg,
      TRUE);

Arnaud Maillet's avatar
Arnaud Maillet committed
281
282
283
284
  g_free (host);

  if (conn == NULL)
    {
285
286
287
288
      error_msg = g_strdup_printf
          (_("Impossible to create the connection: %s"), error_conn_msg);
      vinagre_utils_show_error (NULL, (const gchar *) error_msg,
          GTK_WINDOW (priv->window));
289
290
      g_signal_handler_disconnect (G_OBJECT (priv->channel),
        priv->signal_invalidated_id);
291
      g_free (error_conn_msg);
Arnaud Maillet's avatar
Arnaud Maillet committed
292
      g_free (error_msg);
293
      g_signal_emit (G_OBJECT (self), signals[DISCONNECTED], 0);
294
      return;
Arnaud Maillet's avatar
Arnaud Maillet committed
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
    }

  vinagre_cmd_direct_connect (conn, priv->window);

  priv->tab = vinagre_window_conn_exists (priv->window, conn);

  priv->nb = vinagre_tab_get_notebook (priv->tab);

  g_assert (priv->tab != NULL);

  g_assert (priv->nb != NULL);

  priv->signal_disconnect_id = g_signal_connect (G_OBJECT (priv->nb),
      "page-removed", G_CALLBACK
      (vinagre_tube_handler_tab_disconnected_cb), self);
}

312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
static void
vinagre_tube_handler_accept_stream_tube_cb (TpChannel *channel,
    const GValue *address,
    const GError *error,
    gpointer self,
    GObject *weak_object)
{
  gchar *error_msg = NULL;
  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE (self);

  if (error != NULL)
    {
      error_msg = g_strdup_printf
          (_("Impossible to accept the stream tube: %s"),
          error->message);
      vinagre_utils_show_error (NULL, (const gchar *) error_msg,
          GTK_WINDOW (priv->window));
      g_free (error_msg);
      g_signal_emit (G_OBJECT (self), signals[DISCONNECTED], 0);
      return ;
    }

  dbus_g_type_struct_get (address, 0, &priv->hostname, 1, &priv->port,
      G_MAXUINT);

  tp_cli_dbus_properties_call_get (channel,
      -1, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE, "Service",
      vinagre_tube_handler_call_service_cb,
      self, NULL, NULL);
}

Arnaud Maillet's avatar
Arnaud Maillet committed
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
static void
vinagre_tube_handler_dialog_response_cb (GtkDialog *dialog,
    gint response,
    gpointer self)
{
  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE (self);
  GValue access_control_param = {0,};

  if (response == GTK_RESPONSE_OK)
    {
      g_value_init (&access_control_param, G_TYPE_STRING);
      /* With the Localhost access control method, the access
      control param is unused; set a dummy value */
      g_value_set_static_string (&access_control_param, "");
      tp_cli_channel_type_stream_tube_call_accept (priv->channel, -1,
          TP_SOCKET_ADDRESS_TYPE_IPV4, TP_SOCKET_ACCESS_CONTROL_LOCALHOST,
          &access_control_param, vinagre_tube_handler_accept_stream_tube_cb,
          self, NULL, NULL);
      g_value_unset (&access_control_param);
    }
  else
    {
      g_signal_emit (G_OBJECT (self), signals[DISCONNECTED], 0);
    }

  gtk_widget_destroy (GTK_WIDGET (dialog));
}

371
372
373
374
375
376
377
378
static gchar *
vinagre_tube_handler_contact_get_avatar_filename (TpContact *contact,
    const gchar *token,
    VinagreTubeHandler *self)
{
  gchar *avatar_path;
  gchar *avatar_file;
  gchar *token_escaped;
379
380
381
  TpConnection *connection;
  gchar *cm;
  gchar *protocol;
382

383
384
385
386
  if (contact == NULL)
    return NULL;

  token_escaped = tp_escape_as_identifier (token);
387

388
  connection = tp_contact_get_connection (contact);
389

390
  if (!tp_connection_parse_object_path (connection, &protocol, &cm))
391
    {
392
      vinagre_debug_message (DEBUG_TUBE, "Impossible to parse object path\n");
393
394
395
396
      return NULL;
    }

  avatar_path = g_build_filename (g_get_user_cache_dir (),
397
398
399
400
401
402
      "telepathy",
      "avatars",
      cm,
      protocol,
      NULL);
  g_mkdir_with_parents (avatar_path, 0700);
403
404
405
406
407

  avatar_file = g_build_filename (avatar_path, token_escaped, NULL);

  g_free (token_escaped);
  g_free (avatar_path);
408
409
  g_free (cm);
  g_free (protocol);
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438

  return avatar_file;
}

static GdkPixbuf*
vinagre_tube_handler_pixbuf_scale_down_if_necessary (GdkPixbuf *pixbuf,
    gint max_size)
{
  gint width, height;
  gdouble factor;

  width = gdk_pixbuf_get_width (pixbuf);
  height = gdk_pixbuf_get_height (pixbuf);

  if (width > 0 && (width > max_size || height > max_size))
    {
      factor = (gdouble) max_size / MAX (width, height);

      width = width * factor;
      height = height * factor;

      return gdk_pixbuf_scale_simple (pixbuf,
          width, height,
          GDK_INTERP_HYPER);
    }

  return g_object_ref (pixbuf);
}

Arnaud Maillet's avatar
Arnaud Maillet committed
439
440
441
442
443
444
445
446
447
448
449
static void
vinagre_tube_handler_factory_handle_cb (TpConnection *connection,
    guint n_contacts,
    TpContact * const *contacts,
    guint n_failed,
    const TpHandle *failed,
    const GError *error,
    gpointer self,
    GObject *weak_object)
{
  GtkWidget *dialog;
450
  GdkPixbuf *pixbuf_view;
Arnaud Maillet's avatar
Arnaud Maillet committed
451
  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE (self);
452
453
454
455
456
457
  TpContact *contact;
  const gchar *alias;
  const gchar *token;
  gchar *filename;
  GtkWidget *image;
  GError *error_failed = NULL;
458
  gchar *error_msg = NULL;
Arnaud Maillet's avatar
Arnaud Maillet committed
459
460
461

  if (error != NULL)
    {
462
463
464
465
466
467
      /* Translators: this is an error message when we fail to get the name of an empathy/telepathy buddy. %s will be replaced by the actual error message. */
      error_msg = g_strdup_printf (_("Impossible to get the contact name: %s"),
                                   error->message);
      vinagre_utils_show_error (NULL,
                                (const gchar *) error_msg,
                                GTK_WINDOW (priv->window));
468
      g_free (error_msg);
Arnaud Maillet's avatar
Arnaud Maillet committed
469
470
471
472
473
      g_signal_emit (G_OBJECT (self), signals[DISCONNECTED], 0);
      return;
    }

  contact = contacts[0];
474

Arnaud Maillet's avatar
Arnaud Maillet committed
475
  alias = tp_contact_get_alias (contact);
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
  token = tp_contact_get_avatar_token (contact);

  if (!tp_strdiff (token, ""))
    {
      image = gtk_image_new_from_icon_name ("stock_person",
          GTK_ICON_SIZE_DIALOG);
    }
  else
    {
      filename = vinagre_tube_handler_contact_get_avatar_filename (contact,
          token, self);

      if (filename == NULL)
        {
          image = gtk_image_new_from_icon_name ("stock_person",
              GTK_ICON_SIZE_DIALOG);
        }
      else
        {
          pixbuf_view = gdk_pixbuf_new_from_file (filename, &error_failed);

          if (pixbuf_view == NULL)
            {
499
500
              error_msg = g_strdup_printf
                  (_("Impossible to get the avatar: %s"),
501
                  error_failed->message);
502
503
504
              vinagre_utils_show_error (NULL, (const gchar *) error_msg,
                  GTK_WINDOW (priv->window));
              g_free (error_msg);
505
506
507
508
509
510
511
512
513
514
515
516
517
              image = gtk_image_new_from_icon_name ("stock_person",
                  GTK_ICON_SIZE_DIALOG);
            }
          else
            {
              pixbuf_view = vinagre_tube_handler_pixbuf_scale_down_if_necessary
                 (pixbuf_view, 64);
              image = gtk_image_new_from_pixbuf (pixbuf_view);
              g_object_unref (pixbuf_view);
            }
          g_free (filename);
        }
    }
Arnaud Maillet's avatar
Arnaud Maillet committed
518
519
520

  dialog = gtk_message_dialog_new (GTK_WINDOW (priv->window),
      GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
521
      GTK_BUTTONS_OK_CANCEL, _("%s wants to share their desktop with you."),
Arnaud Maillet's avatar
Arnaud Maillet committed
522
523
      alias);

524
525
  gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image);

Arnaud Maillet's avatar
Arnaud Maillet committed
526
527
528
529
530
531
532
533
534
535
536
537
538
539
  gtk_window_set_title (GTK_WINDOW (dialog), _("Desktop sharing invitation"));

  g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK
      (vinagre_tube_handler_dialog_response_cb), self);

  gtk_widget_show_all (GTK_WIDGET (dialog));
}

static void
vinagre_tube_handler_constructed (GObject *object)
{
  VinagreTubeHandlerPrivate *priv = VINAGRE_TUBE_HANDLER_GET_PRIVATE (object);
  TpConnection *connection;
  TpHandle handle;
540
541
  TpContactFeature features[] = { TP_CONTACT_FEATURE_ALIAS,
      TP_CONTACT_FEATURE_AVATAR_TOKEN };
Arnaud Maillet's avatar
Arnaud Maillet committed
542

543
  vinagre_debug_message (DEBUG_TUBE, "-- New Tube handler --\n");
Arnaud Maillet's avatar
Arnaud Maillet committed
544

545
  connection = tp_channel_borrow_connection (priv->channel);
Arnaud Maillet's avatar
Arnaud Maillet committed
546
547
548

  handle = tp_channel_get_handle (priv->channel, NULL);

549
550
551
  tp_connection_get_contacts_by_handle (connection, 1, &handle,
      G_N_ELEMENTS(features), features,
      vinagre_tube_handler_factory_handle_cb, object, NULL, NULL);
Arnaud Maillet's avatar
Arnaud Maillet committed
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
}

static void
vinagre_tube_handler_class_init (VinagreTubeHandlerClass *klass)
{
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);

  gobject_class->constructed = vinagre_tube_handler_constructed;
  gobject_class->set_property = vinagre_tube_handler_set_property;
  gobject_class->get_property = vinagre_tube_handler_get_property;
  gobject_class->dispose = vinagre_tube_handler_dispose;

  signals[DISCONNECTED] =
      g_signal_new ("disconnected",
      G_OBJECT_CLASS_TYPE (gobject_class),
      G_SIGNAL_RUN_FIRST,
      G_STRUCT_OFFSET (VinagreTubeHandlerClass, disconnected),
      NULL, NULL,
      g_cclosure_marshal_VOID__VOID,
      G_TYPE_NONE,
      0);

  g_object_class_install_property (gobject_class,
      PROP_VINAGRE_WINDOW,
      g_param_spec_object ("vinagre-window",
      "Vinagre window",
      "The Vinagre window",
      VINAGRE_TYPE_WINDOW,
      G_PARAM_READWRITE      |
      G_PARAM_CONSTRUCT_ONLY |
      G_PARAM_STATIC_STRINGS));

  g_object_class_install_property (gobject_class,
      PROP_CHANNEL,
      g_param_spec_object ("channel",
      "Vinagre tp channel",
      "The Vinagre tp channel",
      TP_TYPE_CHANNEL,
      G_PARAM_READWRITE      |
      G_PARAM_CONSTRUCT_ONLY |
      G_PARAM_STATIC_STRINGS));

  g_type_class_add_private (klass, sizeof (VinagreTubeHandlerPrivate));
}

static void
vinagre_tube_handler_init (VinagreTubeHandler *object)
{
}

VinagreTubeHandler *
vinagre_tube_handler_new (VinagreWindow *vinagre_window, TpChannel *channel)
{
  return g_object_new (VINAGRE_TYPE_TUBE_HANDLER,
      "vinagre-window", vinagre_window,
      "channel", channel,
      NULL);
}