[empathy: 11/19] factor out handle_incoming_message()



commit 1f28f03c2d9765928df41bd5309ac58cfca45229
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Mon Apr 18 13:25:39 2011 +0200

    factor out handle_incoming_message()

 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 44c4eab..114ad47 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]