aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2009-03-06 19:52:57 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-03-06 19:52:57 +0800
commit4a05fe382bf1f8eb0c490e511c95f93f85f04b94 (patch)
treed131478a1cb1a9436d6c42114c9854561891c8e2
parent372dfdc6bc54f5005969a944708aee2e0d38b64b (diff)
downloadgsoc2013-empathy-4a05fe382bf1f8eb0c490e511c95f93f85f04b94.tar
gsoc2013-empathy-4a05fe382bf1f8eb0c490e511c95f93f85f04b94.tar.gz
gsoc2013-empathy-4a05fe382bf1f8eb0c490e511c95f93f85f04b94.tar.bz2
gsoc2013-empathy-4a05fe382bf1f8eb0c490e511c95f93f85f04b94.tar.lz
gsoc2013-empathy-4a05fe382bf1f8eb0c490e511c95f93f85f04b94.tar.xz
gsoc2013-empathy-4a05fe382bf1f8eb0c490e511c95f93f85f04b94.tar.zst
gsoc2013-empathy-4a05fe382bf1f8eb0c490e511c95f93f85f04b94.zip
Use get_filtered_messages in EmpathyChat.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk> svn path=/trunk/; revision=2608
-rw-r--r--libempathy-gtk/empathy-chat.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 5fac903a3..652c6651d 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -1026,14 +1026,31 @@ chat_input_populate_popup_cb (GtkTextView *view,
}
}
+static gboolean
+chat_log_filter (EmpathyMessage *message,
+ gpointer user_data)
+{
+ EmpathyChat *chat = (EmpathyChat *) user_data;
+ EmpathyChatPriv *priv = GET_PRIV (chat);
+ const GList *pending;
+
+ pending = empathy_tp_chat_get_pending_messages (priv->tp_chat);
+
+ for (; pending; pending = g_list_next (pending)) {
+ if (empathy_message_equal (message, pending->data)) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
static void
chat_add_logs (EmpathyChat *chat)
{
EmpathyChatPriv *priv = GET_PRIV (chat);
gboolean is_chatroom;
GList *messages, *l;
- guint i = 0;
- const GList *pending_messages, *m;
if (!priv->id) {
return;
@@ -1044,28 +1061,17 @@ chat_add_logs (EmpathyChat *chat)
/* Add messages from last conversation */
is_chatroom = priv->handle_type == TP_HANDLE_TYPE_ROOM;
- messages = empathy_log_manager_get_last_messages (priv->log_manager,
- priv->account,
- priv->id,
- is_chatroom);
-
- pending_messages = empathy_tp_chat_get_pending_messages (priv->tp_chat);
- for (l = g_list_last (messages); l; l = g_list_previous (l)) {
- if (i < 10) {
- gboolean found = FALSE;
+ messages = empathy_log_manager_get_filtered_messages (priv->log_manager,
+ priv->account,
+ priv->id,
+ is_chatroom,
+ 5,
+ chat_log_filter,
+ chat);
- for (m = pending_messages; m; m = g_list_next (m)) {
- if (empathy_message_equal (l->data, m->data)) {
- found = TRUE;
- }
- }
-
- if (!found) {
- empathy_chat_view_append_message (chat->view, l->data);
- i++;
- }
- }
+ for (l = messages; l; l = g_list_next (l)) {
+ empathy_chat_view_append_message (chat->view, l->data);
g_object_unref (l->data);
}