gchar *message,
EmpathyTpChat *chat)
{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
DEBUG ("Channel invalidated: %s", message);
g_signal_emit (chat, signals[DESTROY], 0);
-
- g_object_unref (priv->channel);
- priv->channel = NULL;
}
static void
static void
tp_chat_got_sender_cb (EmpathyTpContactFactory *factory,
- GList *contacts,
+ EmpathyContact *contact,
+ const GError *error,
gpointer message,
GObject *chat)
{
- empathy_message_set_sender (message, contacts->data);
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ /* Do not block the message queue, just drop this message */
+ g_queue_remove (priv->messages_queue, message);
+ } else {
+ empathy_message_set_sender (message, contact);
+ }
+
tp_chat_emit_queued_messages (EMPATHY_TP_CHAT (chat));
}
empathy_message_set_sender (message, priv->user);
tp_chat_emit_queued_messages (chat);
} else {
- empathy_tp_contact_factory_get_from_handles (priv->factory,
- 1, &from_handle,
+ empathy_tp_contact_factory_get_from_handle (priv->factory,
+ from_handle,
tp_chat_got_sender_cb,
message, NULL, G_OBJECT (chat));
}
static void
tp_chat_state_changed_got_contact_cb (EmpathyTpContactFactory *factory,
- GList *contacts,
+ EmpathyContact *contact,
+ const GError *error,
gpointer user_data,
GObject *chat)
{
- EmpathyContact *contact = contacts->data;
TpChannelChatState state;
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ return;
+ }
+
state = GPOINTER_TO_UINT (user_data);
DEBUG ("Chat state changed for %s (%d): %d",
empathy_contact_get_name (contact),
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
- empathy_tp_contact_factory_get_from_handles (priv->factory, 1, &handle,
+ 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
tp_chat_got_added_contacts_cb (EmpathyTpContactFactory *factory,
- GList *contacts,
+ guint n_contacts,
+ EmpathyContact * const * contacts,
+ guint n_failed,
+ const TpHandle *failed,
+ const GError *error,
gpointer user_data,
GObject *chat)
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
- GList *l;
+ guint i;
const TpIntSet *members;
TpHandle handle;
EmpathyContact *contact;
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ return;
+ }
+
members = tp_channel_group_get_members (priv->channel);
- for (l = contacts; l; l = l->next) {
- contact = l->data;
+ for (i = 0; i < n_contacts; i++) {
+ contact = contacts[i];
handle = empathy_contact_get_handle (contact);
/* Make sure the contact is still member */
if (handle == g_array_index (removed, TpHandle, i)) {
priv->members = g_list_delete_link (priv->members, l);
g_signal_emit_by_name (chat, "members-changed",
- contact, actor, reason,
+ contact, NULL, reason,
message, FALSE);
g_object_unref (contact);
break;
static void
tp_chat_got_remote_contact_cb (EmpathyTpContactFactory *factory,
- GList *contacts,
- gpointer user_data,
- GObject *chat)
+ EmpathyContact *contact,
+ const GError *error,
+ gpointer user_data,
+ GObject *chat)
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
- priv->remote_contact = g_object_ref (contacts->data);
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ empathy_tp_chat_close (EMPATHY_TP_CHAT (chat));
+ return;
+ }
+
+ priv->remote_contact = g_object_ref (contact);
g_object_notify (chat, "remote-contact");
tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
static void
tp_chat_got_self_contact_cb (EmpathyTpContactFactory *factory,
- GList *contacts,
+ EmpathyContact *contact,
+ const GError *error,
gpointer user_data,
GObject *chat)
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
- priv->user = g_object_ref (contacts->data);
- empathy_contact_set_is_user (priv->user, TRUE);
- tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
-}
-
-static void
-tp_chat_get_self_handle_cb (TpConnection *connection,
- TpHandle self_handle,
- const GError *error,
- gpointer user_data,
- GObject *chat)
-{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
-
if (error) {
DEBUG ("Error: %s", error->message);
- tp_cli_channel_call_close (priv->channel, -1,
- NULL, NULL, NULL, NULL);
+ empathy_tp_chat_close (EMPATHY_TP_CHAT (chat));
return;
}
- empathy_tp_contact_factory_get_from_handles (priv->factory,
- 1, &self_handle,
- tp_chat_got_self_contact_cb,
- NULL, NULL, chat);
+ priv->user = g_object_ref (contact);
+ empathy_contact_set_is_user (priv->user, TRUE);
+ tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
}
static GObject *
/* Get self contact from the group's self handle */
handle = tp_channel_group_get_self_handle (priv->channel);
- empathy_tp_contact_factory_get_from_handles (priv->factory,
- 1, &handle,
- tp_chat_got_self_contact_cb,
+ empathy_tp_contact_factory_get_from_handle (priv->factory,
+ handle, tp_chat_got_self_contact_cb,
NULL, NULL, chat);
/* Get initial member contacts */
handles->len, (TpHandle*) handles->data,
tp_chat_got_added_contacts_cb, NULL, NULL, chat);
- g_signal_connect_swapped (priv->channel, "group-members-changed",
+ 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 */
- tp_cli_connection_call_get_self_handle (connection, -1,
- tp_chat_get_self_handle_cb, NULL, NULL, chat);
+ 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_handles (priv->factory,
- 1, &handle, tp_chat_got_remote_contact_cb,
+ empathy_tp_contact_factory_get_from_handle (priv->factory,
+ handle, tp_chat_got_remote_contact_cb,
NULL, NULL, chat);
}
EmpathyTpChatPriv *priv = GET_PRIV (chat);
/* If there are still messages left, it'll come back..
- We loose the ordering of sent messages though */
- g_signal_handlers_disconnect_by_func (priv->channel,
- tp_chat_invalidated_cb, chat);
-
+ * We loose the ordering of sent messages though */
tp_cli_channel_call_close (priv->channel, -1, tp_chat_async_cb,
"closing channel", NULL, NULL);
-
- g_object_unref (priv->channel);
- priv->channel = NULL;
-
- g_signal_emit (chat, signals[DESTROY], 0);
}
const gchar *
return priv->channel;
}
+TpConnection *
+empathy_tp_chat_get_connection (EmpathyTpChat *chat)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ g_return_val_if_fail (EMPATHY_IS_TP_CHAT (chat), NULL);
+
+ return tp_channel_borrow_connection (priv->channel);
+}
+
gboolean
empathy_tp_chat_is_ready (EmpathyTpChat *chat)
{