t = empathy_time_parse (time);
- sender = empathy_contact_new_full (account, sender_id, sender_name);
- empathy_contact_set_is_user (sender, is_user);
+ sender = g_object_new (EMPATHY_TYPE_CONTACT,
+ "account", account,
+ "id", sender_id,
+ "name", sender_name,
+ "is-user", is_user,
+ NULL);
if (!EMP_STR_EMPTY (sender_avatar_token))
empathy_contact_load_avatar_cache (sender,
sender_avatar_token);
xmlFree (is_user_str);
xmlFree (msg_type_str);
xmlFree (cm_id_str);
+ xmlFree (sender_avatar_token);
}
DEBUG ("Parsed %d messages", g_list_length (messages));
GDir *gdir;
GList *hits = NULL;
const gchar *name;
+ GError *error = NULL;
- gdir = g_dir_open (dir, 0, NULL);
+ gdir = g_dir_open (dir, 0, &error);
if (!gdir)
- return NULL;
+ {
+ DEBUG ("Failed to open directory: %s, error: %s", dir, error->message);
+ g_error_free (error);
+ return NULL;
+ }
while ((name = g_dir_read_name (gdir)) != NULL)
{
EmpathyLogSearchHit *hit;
- gchar *filename;
- filename = g_build_filename (dir, name, NULL);
- if (strcmp (name, LOG_DIR_CHATROOMS) == 0)
+ if (!is_chatroom && strcmp (name, LOG_DIR_CHATROOMS) == 0)
{
+ gchar *filename = g_build_filename (dir, name, NULL);
hits = g_list_concat (hits, log_store_empathy_get_chats_for_dir (
- self, dir, TRUE));
+ self, filename, TRUE));
g_free (filename);
continue;
}
-
hit = g_slice_new0 (EmpathyLogSearchHit);
hit->chat_id = g_strdup (name);
hit->is_chatroom = is_chatroom;
gpointer user_data)
{
GList *dates, *l, *messages = NULL;
+ guint i = 0;
dates = log_store_empathy_get_dates (self, account, chat_id, chatroom);
- for (l = g_list_last (dates); l && g_list_length (messages) < num_messages; l = g_list_previous (l))
+ 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_empathy_get_messages_for_date (self, account,
chat_id, chatroom, l->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);