aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-chat.c
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-01-10 00:12:02 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-10 00:12:02 +0800
commit9d4e38bf73836e75dd4a86b3929317b612236f1f (patch)
tree14f8b52c2cf5d6c28ca4213603b36c48f1f8b654 /libempathy-gtk/empathy-chat.c
parentc55283c50222dd43dd7a088592c7675e7d4a0959 (diff)
downloadgsoc2013-empathy-9d4e38bf73836e75dd4a86b3929317b612236f1f.tar
gsoc2013-empathy-9d4e38bf73836e75dd4a86b3929317b612236f1f.tar.gz
gsoc2013-empathy-9d4e38bf73836e75dd4a86b3929317b612236f1f.tar.bz2
gsoc2013-empathy-9d4e38bf73836e75dd4a86b3929317b612236f1f.tar.lz
gsoc2013-empathy-9d4e38bf73836e75dd4a86b3929317b612236f1f.tar.xz
gsoc2013-empathy-9d4e38bf73836e75dd4a86b3929317b612236f1f.tar.zst
gsoc2013-empathy-9d4e38bf73836e75dd4a86b3929317b612236f1f.zip
Port to the new EmpathyTpChat API
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> svn path=/trunk/; revision=2129
Diffstat (limited to 'libempathy-gtk/empathy-chat.c')
-rw-r--r--libempathy-gtk/empathy-chat.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index ce5f69880..d05c8591d 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -64,6 +64,7 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChat)
typedef struct {
EmpathyTpChat *tp_chat;
+ gulong tp_chat_destroy_handler;
McAccount *account;
gchar *id;
gchar *name;
@@ -452,9 +453,7 @@ chat_state_changed_cb (EmpathyTpChat *tp_chat,
}
static void
-chat_message_received_cb (EmpathyTpChat *tp_chat,
- EmpathyMessage *message,
- EmpathyChat *chat)
+chat_message_received (EmpathyChat *chat, EmpathyMessage *message)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
EmpathyContact *sender;
@@ -476,8 +475,8 @@ chat_message_received_cb (EmpathyTpChat *tp_chat,
empathy_chat_view_append_message (chat->view, message);
- /* We received a message so the contact is no more composing */
- chat_state_changed_cb (tp_chat, sender,
+ /* We received a message so the contact is no longer composing */
+ chat_state_changed_cb (priv->tp_chat, sender,
TP_CHANNEL_CHAT_STATE_ACTIVE,
chat);
@@ -485,6 +484,15 @@ chat_message_received_cb (EmpathyTpChat *tp_chat,
}
static void
+chat_message_received_cb (EmpathyTpChat *tp_chat,
+ EmpathyMessage *message,
+ EmpathyChat *chat)
+{
+ chat_message_received (chat, message);
+ empathy_tp_chat_acknowledge_message (tp_chat, message);
+}
+
+static void
chat_send_error_cb (EmpathyTpChat *tp_chat,
EmpathyMessage *message,
TpChannelTextSendError error_code,
@@ -1242,6 +1250,25 @@ chat_destroy_cb (EmpathyTpChat *tp_chat,
}
static void
+show_pending_messages (EmpathyChat *chat)
+{
+ EmpathyChatPriv *priv = GET_PRIV (chat);
+ const GList *messages, *l;
+
+ if (chat->view == NULL || priv->tp_chat == NULL)
+ return;
+
+ messages = empathy_tp_chat_get_pending_messages (priv->tp_chat);
+
+ for (l = messages; l != NULL ; l = g_list_next (l))
+ {
+ EmpathyMessage *message = EMPATHY_MESSAGE (l->data);
+ chat_message_received (chat, message);
+ }
+ empathy_tp_chat_acknowledge_messages (priv->tp_chat, messages);
+}
+
+static void
chat_create_ui (EmpathyChat *chat)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
@@ -1331,6 +1358,8 @@ chat_create_ui (EmpathyChat *chat)
/* Add the main widget in the chat widget */
gtk_container_add (GTK_CONTAINER (chat), priv->widget);
+
+ show_pending_messages (chat);
}
static void
@@ -1399,6 +1428,8 @@ chat_finalize (GObject *object)
g_object_unref (priv->log_manager);
if (priv->tp_chat) {
+ g_signal_handler_disconnect (priv->tp_chat, priv->tp_chat_destroy_handler);
+ empathy_tp_chat_close (priv->tp_chat);
g_object_unref (priv->tp_chat);
}
if (priv->account) {
@@ -1602,7 +1633,8 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
g_signal_connect_swapped (tp_chat, "notify::remote-contact",
G_CALLBACK (chat_remote_contact_changed_cb),
chat);
- g_signal_connect (tp_chat, "destroy",
+ priv->tp_chat_destroy_handler =
+ g_signal_connect (tp_chat, "destroy",
G_CALLBACK (chat_destroy_cb),
chat);
@@ -1615,12 +1647,11 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
}
}
- empathy_tp_chat_set_acknowledge (priv->tp_chat, TRUE);
- empathy_tp_chat_emit_pendings (priv->tp_chat);
-
g_object_notify (G_OBJECT (chat), "tp-chat");
g_object_notify (G_OBJECT (chat), "id");
g_object_notify (G_OBJECT (chat), "account");
+
+ show_pending_messages (chat);
}
McAccount *