summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonnylamb@gnome.org>2009-10-17 01:48:02 +0100
committerJonny Lamb <jonnylamb@gnome.org>2009-11-29 15:48:15 +0000
commit68cb42685be538aaa96d260ad23fcd6ab324f6df (patch)
treef7798322916c7c80f0a3597bf3ad15c25e14fd06
parentb79f7615fb67058b72f664e0e1712ccb3388466d (diff)
Implemented get_filtered_messages in Pidgin log store.
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
-rw-r--r--libempathy/empathy-log-store-pidgin.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/libempathy/empathy-log-store-pidgin.c b/libempathy/empathy-log-store-pidgin.c
index 0554a9a56..7c79879b0 100644
--- a/libempathy/empathy-log-store-pidgin.c
+++ b/libempathy/empathy-log-store-pidgin.c
@@ -377,6 +377,10 @@ log_store_pidgin_get_messages_for_files (EmpathyLogStore *self,
filename = (gchar *) l->data;
hit = log_store_pidgin_search_hit_new (self, filename);
+
+ if (hit == NULL)
+ continue;
+
account = g_object_ref (hit->account);
empathy_log_manager_search_hit_free (hit);
@@ -683,6 +687,53 @@ log_store_pidgin_get_chats (EmpathyLogStore *self,
return hits;
}
+static GList *
+log_store_pidgin_get_filtered_messages (EmpathyLogStore *self,
+ EmpathyAccount *account,
+ const gchar *chat_id,
+ gboolean chatroom,
+ guint num_messages,
+ EmpathyLogMessageFilter filter,
+ gpointer user_data)
+{
+ GList *dates, *l, *messages = NULL;
+ guint i = 0;
+
+ dates = log_store_pidgin_get_dates (self, account, chat_id, chatroom);
+
+ for (l = g_list_last (dates); l && i < num_messages; l = g_list_previous (l))
+ {
+ GList *new_messages, *n, *next;
+
+ /* FIXME: We should really restrict the message parsing to get only
+ * the newest num_messages. */
+ new_messages = log_store_pidgin_get_messages_for_date (self, account,
+ chat_id, chatroom, l->data);
+
+ n = new_messages;
+ while (n != NULL)
+ {
+ next = g_list_next (n);
+ if (!filter (n->data, user_data))
+ {
+ g_object_unref (n->data);
+ new_messages = g_list_delete_link (new_messages, n);
+ }
+ else
+ {
+ i++;
+ }
+ n = next;
+ }
+ messages = g_list_concat (messages, new_messages);
+ }
+
+ g_list_foreach (dates, (GFunc) g_free, NULL);
+ g_list_free (dates);
+
+ return messages;
+}
+
static void
log_store_iface_init (gpointer g_iface,
gpointer iface_data)
@@ -696,4 +747,5 @@ log_store_iface_init (gpointer g_iface,
iface->get_chats = log_store_pidgin_get_chats;
iface->search_new = log_store_pidgin_search_new;
iface->ack_message = NULL;
+ iface->get_filtered_messages = log_store_pidgin_get_filtered_messages;
}