static void
contact_widget_change_contact (EmpathyContactWidget *information)
{
  EmpathyTpContactFactory *factory;
  TpConnection *connection;

  connection = empathy_account_chooser_get_connection (
      EMPATHY_ACCOUNT_CHOOSER (information->widget_account));
  if (!connection)
      return;

  factory = empathy_tp_contact_factory_dup_singleton (connection);
  if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
    {
      const gchar *id;

      id = gtk_entry_get_text (GTK_ENTRY (information->widget_id));
      if (!EMP_STR_EMPTY (id))
        {
          empathy_tp_contact_factory_get_from_id (factory, id,
              contact_widget_got_contact_cb, information, NULL,
              G_OBJECT (information->vbox_contact_widget));
        }
    }
  else
    {
      empathy_tp_contact_factory_get_from_handle (factory,
          tp_connection_get_self_handle (connection),
          contact_widget_got_contact_cb, information, NULL,
          G_OBJECT (information->vbox_contact_widget));
    }

  g_object_unref (factory);
}
示例#2
0
static void
tp_chat_build_message (EmpathyTpChat *chat,
		       guint          id,
		       guint          type,
		       guint          timestamp,
		       guint          from_handle,
		       const gchar   *message_body)
{
	EmpathyTpChatPriv *priv;
	EmpathyMessage    *message;

	priv = GET_PRIV (chat);

	message = empathy_message_new (message_body);
	empathy_message_set_tptype (message, type);
	empathy_message_set_receiver (message, priv->user);
	empathy_message_set_timestamp (message, timestamp);
	empathy_message_set_id (message, id);
	g_queue_push_tail (priv->messages_queue, message);

	if (from_handle == 0) {
		empathy_message_set_sender (message, priv->user);
		tp_chat_emit_queued_messages (chat);
	} else {
		empathy_tp_contact_factory_get_from_handle (priv->factory,
			from_handle,
			tp_chat_got_sender_cb,
			message, NULL, G_OBJECT (chat));
	}
}
EmpathyContact *
empathy_contact_factory_get_from_handle (EmpathyContactFactory *factory,
					 McAccount             *account,
					 guint                  handle)
{
	EmpathyTpContactFactory *tp_factory;

	tp_factory = empathy_contact_factory_get_tp_factory (factory, account);

	return empathy_tp_contact_factory_get_from_handle (tp_factory, handle);
}
示例#4
0
static void
tp_chat_state_changed_cb (TpChannel *channel,
			  TpHandle   handle,
			  TpChannelChatState state,
			  gpointer   user_data,
			  GObject   *chat)
{
	EmpathyTpChatPriv *priv = GET_PRIV (chat);

	empathy_tp_contact_factory_get_from_handle (priv->factory, handle,
		tp_chat_state_changed_got_contact_cb, GUINT_TO_POINTER (state),
		NULL, chat);
}
static void
channel_get_all_properties_cb (TpProxy *proxy,
    GHashTable *properties,
    const GError *error,
    gpointer user_data,
    GObject *weak_object)
{
  CallbacksData *cb_data = user_data;
  EmpathyFTHandler *handler = EMPATHY_FT_HANDLER (weak_object);
  EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
  TpHandle c_handle;

  if (error != NULL)
    {
      if (!g_cancellable_is_cancelled (priv->cancellable))
        g_cancellable_cancel (priv->cancellable);

      cb_data->callback (handler, (GError *) error, cb_data->user_data);

      callbacks_data_free (cb_data);
      return;
    }

  priv->total_bytes = g_value_get_uint64 (
      g_hash_table_lookup (properties, "Size"));

  priv->transferred_bytes = g_value_get_uint64 (
      g_hash_table_lookup (properties, "TransferredBytes"));

  priv->filename = g_value_dup_string (
      g_hash_table_lookup (properties, "Filename"));

  priv->content_hash = g_value_dup_string (
      g_hash_table_lookup (properties, "ContentHash"));

  priv->content_hash_type = g_value_get_uint (
      g_hash_table_lookup (properties, "ContentHashType"));

  priv->content_type = g_value_dup_string (
      g_hash_table_lookup (properties, "ContentType"));

  priv->description = g_value_dup_string (
      g_hash_table_lookup (properties, "Description"));

  c_handle = tp_channel_get_handle (TP_CHANNEL (proxy), NULL);
  empathy_tp_contact_factory_get_from_handle (
      tp_channel_borrow_connection (TP_CHANNEL (proxy)), c_handle,
      contact_factory_contact_cb, cb_data, callbacks_data_free,
      G_OBJECT (handler));
}
static GObject *
tp_streamed_media_constructor (GType type,
                     guint n_construct_params,
                     GObjectConstructParam *construct_params)
{
  GObject *object;
  EmpathyTpStreamedMedia *call;
  EmpathyTpStreamedMediaPriv *priv;

  object = G_OBJECT_CLASS (empathy_tp_streamed_media_parent_class)->constructor (type,
      n_construct_params, construct_params);

  call = EMPATHY_TP_STREAMED_MEDIA (object);
  priv = GET_PRIV (call);

  /* Setup streamed media channel */
  g_signal_connect (priv->channel, "invalidated",
      G_CALLBACK (tp_streamed_media_channel_invalidated_cb), call);
  tp_cli_channel_type_streamed_media_connect_to_stream_added (priv->channel,
      tp_streamed_media_stream_added_cb, NULL, NULL, G_OBJECT (call), NULL);
  tp_cli_channel_type_streamed_media_connect_to_stream_removed (priv->channel,
      tp_streamed_media_stream_removed_cb, NULL, NULL, G_OBJECT (call), NULL);
  tp_cli_channel_type_streamed_media_connect_to_stream_state_changed (priv->channel,
      tp_streamed_media_stream_state_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
  tp_cli_channel_type_streamed_media_connect_to_stream_direction_changed (priv->channel,
      tp_streamed_media_stream_direction_changed_cb, NULL, NULL, G_OBJECT (call), NULL);
  tp_cli_channel_type_streamed_media_connect_to_stream_error (priv->channel,
      tp_streamed_media_stream_error_cb, NULL, NULL, G_OBJECT (call), NULL);
  tp_cli_channel_type_streamed_media_call_list_streams (priv->channel, -1,
      tp_streamed_media_request_streams_cb, NULL, NULL, G_OBJECT (call));

  /* Is the call incoming? */
  priv->is_incoming = !tp_channel_get_requested (priv->channel);

  /* Get the remote contact */
  empathy_tp_contact_factory_get_from_handle (
      tp_channel_borrow_connection (priv->channel),
      tp_channel_get_handle (priv->channel, NULL), tp_streamed_media_got_contact_cb,
      NULL, NULL, object);

  /* Update status when members changes */
  tp_streamed_media_update_status (call);
  tp_g_signal_connect_object (priv->channel, "group-members-changed",
      G_CALLBACK (tp_streamed_media_update_status), call, G_CONNECT_SWAPPED);

  return object;
}
示例#7
0
static GObject *
tp_chat_constructor (GType                  type,
		     guint                  n_props,
		     GObjectConstructParam *props)
{
	GObject           *chat;
	EmpathyTpChatPriv *priv;
	TpConnection      *connection;
	TpHandle           handle;

	chat = G_OBJECT_CLASS (empathy_tp_chat_parent_class)->constructor (type, n_props, props);

	priv = GET_PRIV (chat);

	connection = tp_channel_borrow_connection (priv->channel);
	priv->factory = empathy_tp_contact_factory_dup_singleton (connection);
	g_signal_connect (priv->channel, "invalidated",
			  G_CALLBACK (tp_chat_invalidated_cb),
			  chat);

	if (tp_proxy_has_interface_by_id (priv->channel,
					  TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP)) {
		const TpIntSet *members;
		GArray *handles;

		/* Get self contact from the group's self handle */
		handle = tp_channel_group_get_self_handle (priv->channel);
		empathy_tp_contact_factory_get_from_handle (priv->factory,
			handle, tp_chat_got_self_contact_cb,
			NULL, NULL, chat);

		/* Get initial member contacts */
		members = tp_channel_group_get_members (priv->channel);
		handles = tp_intset_to_array (members);
		empathy_tp_contact_factory_get_from_handles (priv->factory,
			handles->len, (TpHandle *) handles->data,
			tp_chat_got_added_contacts_cb, NULL, NULL, chat);

		g_signal_connect (priv->channel, "group-members-changed",
			G_CALLBACK (tp_chat_group_members_changed_cb), chat);
	} else {
		/* Get the self contact from the connection's self handle */
		handle = tp_connection_get_self_handle (connection);
		empathy_tp_contact_factory_get_from_handle (priv->factory,
			handle, tp_chat_got_self_contact_cb,
			NULL, NULL, chat);

		/* Get the remote contact */
		handle = tp_channel_get_handle (priv->channel, NULL);
		empathy_tp_contact_factory_get_from_handle (priv->factory,
			handle, tp_chat_got_remote_contact_cb,
			NULL, NULL, chat);
	}

	if (tp_proxy_has_interface_by_id (priv->channel,
					  TP_IFACE_QUARK_PROPERTIES_INTERFACE)) {
		tp_cli_properties_interface_call_list_properties (priv->channel, -1,
								  tp_chat_list_properties_cb,
								  NULL, NULL,
								  G_OBJECT (chat));
		tp_cli_properties_interface_connect_to_properties_changed (priv->channel,
									   tp_chat_properties_changed_cb,
									   NULL, NULL,
									   G_OBJECT (chat), NULL);
		tp_cli_properties_interface_connect_to_property_flags_changed (priv->channel,
									       tp_chat_property_flags_changed_cb,
									       NULL, NULL,
									       G_OBJECT (chat), NULL);
	}

	return chat;
}