]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-share-my-desktop.c
5a0737adc0eb23bb0fe8a29e14ff769f45afe328
[empathy.git] / libempathy-gtk / empathy-share-my-desktop.c
1 /*
2  * © 2009, Collabora Ltd
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  * Authors: Arnaud Maillet <arnaud.maillet@collabora.co.uk>
19  */
20
21 #include "config.h"
22
23 #define DEBUG_FLAG EMPATHY_DEBUG_SHARE_DESKTOP
24 #include "libempathy/empathy-debug.h"
25
26 #include "empathy-share-my-desktop.h"
27
28 static void
29 create_tube_channel_cb (GObject *source,
30     GAsyncResult *result,
31     gpointer user_data)
32 {
33   GError *error = NULL;
34
35   if (!tp_account_channel_request_create_channel_finish (
36         TP_ACCOUNT_CHANNEL_REQUEST (source), result, &error))
37     {
38       DEBUG ("Failed to create tube channel: %s", error->message);
39       g_error_free (error);
40     }
41 }
42
43 void
44 empathy_share_my_desktop_share_with_contact (EmpathyContact *contact)
45 {
46   TpAccountChannelRequest *req;
47   GHashTable *request;
48   TpContact *tp_contact;
49
50   tp_contact = empathy_contact_get_tp_contact (contact);
51
52   DEBUG ("Creation of ShareMyDesktop");
53
54   if (!TP_IS_CONTACT (tp_contact))
55     {
56       DEBUG ("It's not a tp contact");
57       return;
58     }
59
60   request = tp_asv_new (
61       TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
62         TP_IFACE_CHANNEL_TYPE_STREAM_TUBE,
63       TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
64         TP_HANDLE_TYPE_CONTACT,
65       TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT,
66         tp_contact_get_handle (tp_contact),
67       TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING, "rfb",
68       NULL);
69
70   req = tp_account_channel_request_new (empathy_contact_get_account (contact),
71       request, TP_USER_ACTION_TIME_CURRENT_TIME);
72
73   tp_account_channel_request_create_channel_async (req, NULL, NULL,
74       create_tube_channel_cb, NULL);
75
76   g_object_unref (req);
77   g_hash_table_unref (request);
78 }