diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-04-18 19:25:39 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-04-18 20:40:30 +0800 |
commit | 1f28f03c2d9765928df41bd5309ac58cfca45229 (patch) | |
tree | cff39c62c589cac1d7189039c25b43e0840378c6 /libempathy | |
parent | 4cda099c0f5715355829e7ead5b272eb2465a3c0 (diff) | |
download | gsoc2013-empathy-1f28f03c2d9765928df41bd5309ac58cfca45229.tar gsoc2013-empathy-1f28f03c2d9765928df41bd5309ac58cfca45229.tar.gz gsoc2013-empathy-1f28f03c2d9765928df41bd5309ac58cfca45229.tar.bz2 gsoc2013-empathy-1f28f03c2d9765928df41bd5309ac58cfca45229.tar.lz gsoc2013-empathy-1f28f03c2d9765928df41bd5309ac58cfca45229.tar.xz gsoc2013-empathy-1f28f03c2d9765928df41bd5309ac58cfca45229.tar.zst gsoc2013-empathy-1f28f03c2d9765928df41bd5309ac58cfca45229.zip |
factor out handle_incoming_message()
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-tp-chat.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 44c4eab26..114ad47da 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -309,17 +309,18 @@ tp_chat_build_message (EmpathyTpChat *chat, } static void -message_received_cb (TpTextChannel *channel, - TpMessage *message, - EmpathyTpChat *chat) +handle_incoming_message (EmpathyTpChat *self, + TpMessage *message, + gboolean pending) { - EmpathyTpChatPriv *priv = GET_PRIV (chat); + EmpathyTpChatPriv *priv = GET_PRIV (self); gchar *message_body; message_body = tp_message_to_text (message, NULL); - DEBUG ("Message received from channel %s: %s", - tp_proxy_get_object_path (channel), message_body); + DEBUG ("Message %s (channel %s): %s", + pending ? "pending" : "received", + tp_proxy_get_object_path (priv->channel), message_body); if (message_body == NULL) { DEBUG ("Empty message with NonTextContent, ignoring and acking."); @@ -329,12 +330,20 @@ message_received_cb (TpTextChannel *channel, return; } - tp_chat_build_message (chat, message, TRUE); + tp_chat_build_message (self, message, TRUE); g_free (message_body); } static void +message_received_cb (TpTextChannel *channel, + TpMessage *message, + EmpathyTpChat *chat) +{ + handle_incoming_message (chat, message, FALSE); +} + +static void message_sent_cb (TpTextChannel *channel, TpMessage *message, TpMessageSendingFlags flags, @@ -468,23 +477,8 @@ list_pending_messages (EmpathyTpChat *self) for (l = messages; l != NULL; l = g_list_next (l)) { TpMessage *message = l->data; - gchar *message_body; - - message_body = tp_message_to_text (message, NULL); - - DEBUG ("Message pending: %s", message_body); - - if (message_body == NULL) { - DEBUG ("Empty message with NonTextContent, ignoring and acking."); - - tp_text_channel_ack_message_async (TP_TEXT_CHANNEL (priv->channel), - message, NULL, NULL); - continue; - } - - tp_chat_build_message (self, message, TRUE); - g_free (message_body); + handle_incoming_message (self, message, FALSE); } g_list_free (messages); |