コード例 #1
0
static void
contact_constructed (GObject *object)
{
  EmpathyContact *contact = (EmpathyContact *) object;
  EmpathyContactPriv *priv = GET_PRIV (contact);
  GHashTable *location;
  TpHandle self_handle;
  TpHandle handle;

  if (priv->tp_contact == NULL)
    return;

  priv->presence = empathy_contact_get_presence (contact);

  location = tp_contact_get_location (priv->tp_contact);
  if (location != NULL)
    empathy_contact_set_location (contact, location);

  set_capabilities_from_tp_caps (contact,
      tp_contact_get_capabilities (priv->tp_contact));

  contact_set_avatar_from_tp_contact (contact);

  /* Set is-user property. Note that it could still be the handle is
   * different from the connection's self handle, in the case the handle
   * comes from a group interface. */
  self_handle = tp_connection_get_self_handle (
      tp_contact_get_connection (priv->tp_contact));
  handle = tp_contact_get_handle (priv->tp_contact);
  empathy_contact_set_is_user (contact, self_handle == handle);

  g_signal_connect (priv->tp_contact, "notify",
    G_CALLBACK (tp_contact_notify_cb), contact);
}
/**
 * tp_yts_client_request_channel_async:
 * @self: The client object
 * @target_contact: The contact to open the channel to
 * @target_service: The Ytstenut service to open the channel to
 * @request_type: The type of request to send
 * @request_attributes: A table of Ytstenut attributes, or %NULL
 * @request_body: A UTF-8 encoded XML Ytstenut message, or %NULL
 * @cancellable: Used to cancel this operation
 * @callback: Called when the operation completes
 * @user_data: Data to pass to the callback
 *
 * Start an operation to request a new Ytstenut channel.
 *
 * The new channel will have a Ytstenut request message ready to send. The
 * message is assembled from the arguments specified here.
 */
void
tp_yts_client_request_channel_async (TpYtsClient *self,
    TpContact *target_contact,
    const gchar *target_service,
    TpYtsRequestType request_type,
    GHashTable *request_attributes,
    const gchar *request_body,
    GCancellable *cancellable,
    GAsyncReadyCallback callback,
    gpointer user_data)
{
  TpAccountChannelRequest *channel_request;
  GSimpleAsyncResult *res;
  GHashTable *request_properties;
  TpHandle target_handle;

  g_return_if_fail (TP_IS_YTS_CLIENT (self));
  g_return_if_fail (TP_IS_CONTACT (target_contact));
  g_return_if_fail (tp_dbus_check_valid_interface_name (target_service, NULL));

  if (!request_body)
    request_body = "";

  g_return_if_fail (g_utf8_validate (request_body, -1, NULL));

  target_handle = tp_contact_get_handle (target_contact);
  g_return_if_fail (target_handle);

  res = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
      tp_yts_client_request_channel_async);

  request_properties = tp_asv_new (
      TP_IFACE_CHANNEL ".ChannelType", G_TYPE_STRING, TP_YTS_IFACE_CHANNEL,
      TP_IFACE_CHANNEL ".TargetHandleType", G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
      TP_IFACE_CHANNEL ".TargetHandle", G_TYPE_UINT, target_handle,
      TP_YTS_IFACE_CHANNEL ".TargetService", G_TYPE_STRING, target_service,
      TP_YTS_IFACE_CHANNEL ".InitiatorService", G_TYPE_STRING,
          self->priv->service_name,
      TP_YTS_IFACE_CHANNEL ".RequestType", G_TYPE_UINT, request_type,
      TP_YTS_IFACE_CHANNEL ".RequestBody", G_TYPE_STRING, request_body,
      NULL);

  if (request_attributes)
    tp_asv_set_boxed (request_properties,
        TP_YTS_IFACE_CHANNEL ".RequestAttributes",
        TP_HASH_TYPE_STRING_STRING_MAP, request_attributes);

  channel_request = tp_account_channel_request_new (self->priv->account,
      request_properties, 0);

  tp_account_channel_request_create_and_handle_channel_async (channel_request,
      cancellable, on_channel_request_create_and_handle_channel_returned, res);

  g_hash_table_unref (request_properties);
}
コード例 #3
0
static void
set_hat_cb (TpConnection *conn,
    const GError *error,
    gpointer user_data,
    GObject *weak_object)
{
  ContactPair *pair = user_data;
  GArray *handles = NULL;
  TpHandle handle;

  if (die_if (error, "SetHat()"))
    return;

  handles = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), 2);
  handle = tp_contact_get_handle (pair->contacts[0]);
  g_array_append_val (handles, handle);
  handle = tp_contact_get_handle (pair->contacts[1]);
  g_array_append_val (handles, handle);

  example_cli_connection_interface_hats_call_get_hats (conn, -1,
      handles, got_hats_cb, NULL, NULL, NULL);
}
コード例 #4
0
ファイル: polari-room.c プロジェクト: jwendell/polari
void
polari_room_remove_member (PolariRoom *room,
                           TpContact  *member)
{
  TpChannel *channel;

  g_return_if_fail (POLARI_IS_ROOM (room));

  channel = room->priv->channel;

  if (!tp_proxy_has_interface_by_id (TP_PROXY (channel),
                                     TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP))
    return;

  {
    TpHandle handle = tp_contact_get_handle (member);
    GArray handles = { (char *)&handle, 1 };

    tp_cli_channel_interface_group_call_remove_members (channel,
                                   -1, &handles, NULL, NULL, NULL, NULL, NULL);
  }
}
void
empathy_share_my_desktop_share_with_contact (EmpathyContact *contact)
{
  TpAccountChannelRequest *req;
  GHashTable *request;
  TpContact *tp_contact;

  tp_contact = empathy_contact_get_tp_contact (contact);

  DEBUG ("Creation of ShareMyDesktop");

  if (!TP_IS_CONTACT (tp_contact))
    {
      DEBUG ("It's not a tp contact");
      return;
    }

  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);

  req = tp_account_channel_request_new (empathy_contact_get_account (contact),
      request, TP_USER_ACTION_TIME_CURRENT_TIME);

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

  g_object_unref (req);
  g_hash_table_unref (request);
}
コード例 #6
0
ファイル: file-transfer-helper.c プロジェクト: cjapes/core
static void
ft_handler_populate_outgoing_request (EmpathyFTHandler *handler)
{
  guint contact_handle;
  EmpathyFTHandlerPriv *priv = handler->priv;
  gchar *uri;

  contact_handle = tp_contact_get_handle (priv->contact);
  uri = g_file_get_uri (priv->gfile);

  priv->request = tp_asv_new (
      TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
        TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER,
      TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
        TP_HANDLE_TYPE_CONTACT,
      TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT,
        contact_handle,
      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_TYPE, G_TYPE_STRING,
        priv->content_type,
      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_FILENAME, G_TYPE_STRING,
        priv->filename,
      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_SIZE, G_TYPE_UINT64,
        priv->total_bytes,
      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_DATE, G_TYPE_UINT64,
        priv->mtime,
      TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_URI, G_TYPE_STRING, uri,
      NULL);

  if (priv->service_name != NULL)
    tp_asv_set_string (priv->request, TP_PROP_CHANNEL_INTERFACE_FILE_TRANSFER_METADATA_SERVICE_NAME, priv->service_name);

  if (priv->description != NULL)
    tp_asv_set_string (priv->request, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_DESCRIPTION, priv->description);

  g_free (uri);
}