aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-06-28 23:50:09 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-06-28 23:55:14 +0800
commitab65204f5cf4788225d96871f42b7fbb08364665 (patch)
treeb97c0bd82e017274cd5032949974109070feb656 /libempathy
parent70f51868d4d8ea7cb8450f6250c3acc33e02ef83 (diff)
downloadgsoc2013-empathy-ab65204f5cf4788225d96871f42b7fbb08364665.tar
gsoc2013-empathy-ab65204f5cf4788225d96871f42b7fbb08364665.tar.gz
gsoc2013-empathy-ab65204f5cf4788225d96871f42b7fbb08364665.tar.bz2
gsoc2013-empathy-ab65204f5cf4788225d96871f42b7fbb08364665.tar.lz
gsoc2013-empathy-ab65204f5cf4788225d96871f42b7fbb08364665.tar.xz
gsoc2013-empathy-ab65204f5cf4788225d96871f42b7fbb08364665.tar.zst
gsoc2013-empathy-ab65204f5cf4788225d96871f42b7fbb08364665.zip
tp-chat: Wait that all the pending messages have been added to the pending queue
EmpathyChat which is using the TpChat should be sure that all the pending messages have been processed so it can rely on empathy_tp_chat_get_pending_messages() to return all the pending messages. If not, it can't check if the message it receives from the logger are actually pending ones and so will display them twice (#622729).
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-tp-chat.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index a9a63f548..be266e66a 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -204,6 +204,23 @@ tp_chat_get_members (EmpathyContactList *list)
}
static void
+check_ready (EmpathyTpChat *chat)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ if (priv->ready)
+ return;
+
+ if (g_queue_get_length (priv->messages_queue) > 0)
+ return;
+
+ DEBUG ("Ready");
+
+ priv->ready = TRUE;
+ g_object_notify (G_OBJECT (chat), "ready");
+}
+
+static void
tp_chat_emit_queued_messages (EmpathyTpChat *chat)
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
@@ -220,6 +237,8 @@ tp_chat_emit_queued_messages (EmpathyTpChat *chat)
g_queue_push_tail (priv->pending_messages_queue, message);
g_signal_emit (chat, signals[MESSAGE_RECEIVED], 0, message);
}
+
+ check_ready (chat);
}
static void
@@ -495,6 +514,8 @@ tp_chat_list_pending_messages_cb (TpChannel *channel,
acknowledge_messages (chat, empty_non_text_content_ids);
g_array_free (empty_non_text_content_ids, TRUE);
}
+
+ check_ready (chat);
}
static void
@@ -797,7 +818,7 @@ tp_chat_finalize (GObject *object)
}
static void
-tp_chat_check_if_ready (EmpathyTpChat *chat)
+check_almost_ready (EmpathyTpChat *chat)
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
@@ -817,13 +838,14 @@ tp_chat_check_if_ready (EmpathyTpChat *chat)
priv->remote_contact == NULL)
return;
- DEBUG ("Ready!");
-
tp_cli_channel_type_text_connect_to_received (priv->channel,
tp_chat_received_cb,
NULL, NULL,
G_OBJECT (chat), NULL);
priv->listing_pending_messages = TRUE;
+
+ /* TpChat will be ready once ListPendingMessages returned and all the messages
+ * have been added to the pending messages queue. */
tp_cli_channel_type_text_call_list_pending_messages (priv->channel, -1,
FALSE,
tp_chat_list_pending_messages_cb,
@@ -842,8 +864,6 @@ tp_chat_check_if_ready (EmpathyTpChat *chat)
tp_chat_state_changed_cb,
NULL, NULL,
G_OBJECT (chat), NULL);
- priv->ready = TRUE;
- g_object_notify (G_OBJECT (chat), "ready");
}
static void
@@ -942,7 +962,7 @@ tp_chat_got_added_contacts_cb (TpConnection *connection,
}
tp_chat_update_remote_contact (EMPATHY_TP_CHAT (chat));
- tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
+ check_almost_ready (EMPATHY_TP_CHAT (chat));
}
static EmpathyContact *
@@ -1052,7 +1072,7 @@ tp_chat_got_renamed_contacts_cb (TpConnection *connection,
}
tp_chat_update_remote_contact (EMPATHY_TP_CHAT (chat));
- tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
+ check_almost_ready (EMPATHY_TP_CHAT (chat));
}
@@ -1148,7 +1168,7 @@ tp_chat_got_remote_contact_cb (TpConnection *connection,
priv->remote_contact = g_object_ref (contact);
g_object_notify (chat, "remote-contact");
- tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
+ check_almost_ready (EMPATHY_TP_CHAT (chat));
}
static void
@@ -1168,7 +1188,7 @@ tp_chat_got_self_contact_cb (TpConnection *connection,
priv->user = g_object_ref (contact);
empathy_contact_set_is_user (priv->user, TRUE);
- tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
+ check_almost_ready (EMPATHY_TP_CHAT (chat));
}
static void
@@ -1206,7 +1226,7 @@ got_password_flags_cb (TpChannel *proxy,
priv->got_password_flags = TRUE;
priv->password_flags = password_flags;
- tp_chat_check_if_ready (EMPATHY_TP_CHAT (self));
+ check_almost_ready (EMPATHY_TP_CHAT (self));
}
static GObject *