empathy-share-my-desktop.c 2.54 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * © 2009, Collabora Ltd
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Authors: Arnaud Maillet <arnaud.maillet@collabora.co.uk>
 */

#include <gtk/gtk.h>

#include <dbus/dbus-glib.h>
24
#include <telepathy-glib/account-channel-request.h>
25 26
#include <telepathy-glib/util.h>
#include <telepathy-glib/contact.h>
27 28
#include <telepathy-glib/channel.h>
#include <telepathy-glib/interfaces.h>
29

30 31 32 33 34
#define DEBUG_FLAG EMPATHY_DEBUG_SHARE_DESKTOP
#include <libempathy/empathy-debug.h>

#include "empathy-share-my-desktop.h"

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
static void
create_tube_channel_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  GError *error = NULL;

  if (!tp_account_channel_request_create_channel_finish (
        TP_ACCOUNT_CHANNEL_REQUEST (source), result, &error))
    {
      DEBUG ("Failed to create tube channel: %s", error->message);
      g_error_free (error);
    }
}

50 51 52
void
empathy_share_my_desktop_share_with_contact (EmpathyContact *contact)
{
53
  TpAccountChannelRequest *req;
54 55 56 57
  GHashTable *request;
  TpContact *tp_contact;

  tp_contact = empathy_contact_get_tp_contact (contact);
58 59 60

  DEBUG ("Creation of ShareMyDesktop");

61
  if (!TP_IS_CONTACT (tp_contact))
62 63 64 65 66
    {
      DEBUG ("It's not a tp contact");
      return;
    }

67 68 69 70 71 72 73 74 75 76
  request = tp_asv_new (
      TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
        TP_IFACE_CHANNEL_TYPE_STREAM_TUBE,
      TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
        TP_HANDLE_TYPE_CONTACT,
      TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT,
        tp_contact_get_handle (tp_contact),
      TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING, "rfb",
      NULL);

77
  req = tp_account_channel_request_new (empathy_contact_get_account (contact),
78
      request, TP_USER_ACTION_TIME_CURRENT_TIME);
79 80 81

  tp_account_channel_request_create_channel_async (req, NULL, NULL,
      create_tube_channel_cb, NULL);
82

83 84
  g_object_unref (req);
  g_hash_table_unref (request);
85
}