aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-log-manager.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2007-07-09 23:44:58 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-07-09 23:44:58 +0800
commitc1ea2e3b533fea657d90a3b6e263675526f192e5 (patch)
treec5c87fd084b2847170aac010b40268ec663cd5cc /libempathy/empathy-log-manager.c
parent3677c23545f7e549c72096112159eecd895a4270 (diff)
downloadgsoc2013-empathy-c1ea2e3b533fea657d90a3b6e263675526f192e5.tar
gsoc2013-empathy-c1ea2e3b533fea657d90a3b6e263675526f192e5.tar.gz
gsoc2013-empathy-c1ea2e3b533fea657d90a3b6e263675526f192e5.tar.bz2
gsoc2013-empathy-c1ea2e3b533fea657d90a3b6e263675526f192e5.tar.lz
gsoc2013-empathy-c1ea2e3b533fea657d90a3b6e263675526f192e5.tar.xz
gsoc2013-empathy-c1ea2e3b533fea657d90a3b6e263675526f192e5.tar.zst
gsoc2013-empathy-c1ea2e3b533fea657d90a3b6e263675526f192e5.zip
Add MSN setting UI. Fixes bug #443162 (Cosimo Cecchi).
2007-07-09 Xavier Claessens <xclaesse@gmail.com> * libempathy-gtk/empathy-account-widget-msn.glade: * libempathy-gtk/empathy-account-widget-msn.c: * libempathy-gtk/empathy-account-widget-msn.h: * libempathy-gtk/empathy-accounts-dialog.c: * libempathy-gtk/Makefile.am: Add MSN setting UI. Fixes bug #443162 (Cosimo Cecchi). * libempathy-gtk/empathy-chat-view.c: * libempathy/empathy-log-manager.c: * libempathy/empathy-log-manager.h: Add needed API to show chat logs in Tracker. Fixes bug #452536. svn path=/trunk/; revision=178
Diffstat (limited to 'libempathy/empathy-log-manager.c')
-rw-r--r--libempathy/empathy-log-manager.c84
1 files changed, 52 insertions, 32 deletions
diff --git a/libempathy/empathy-log-manager.c b/libempathy/empathy-log-manager.c
index f7e3540fc..4313bc2cf 100644
--- a/libempathy/empathy-log-manager.c
+++ b/libempathy/empathy-log-manager.c
@@ -81,6 +81,7 @@ static gchar * log_manager_get_timestamp_filename (void);
static gchar * log_manager_get_timestamp_from_message (EmpathyMessage *message);
static EmpathyLogSearchHit *log_manager_search_hit_new (EmpathyLogManager *manager,
const gchar *filename);
+static void log_manager_search_hit_free (EmpathyLogSearchHit *hit);
G_DEFINE_TYPE (EmpathyLogManager, empathy_log_manager, G_TYPE_OBJECT);
@@ -270,33 +271,32 @@ empathy_log_manager_get_dates (EmpathyLogManager *manager,
}
GList *
-empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager,
- McAccount *account,
- const gchar *chat_id,
- gboolean chatroom,
- const gchar *date)
+empathy_log_manager_get_messages_for_file (EmpathyLogManager *manager,
+ const gchar *filename)
{
- gchar *filename;
- GList *messages = NULL;
- xmlParserCtxtPtr ctxt;
- xmlDocPtr doc;
- xmlNodePtr log_node;
- xmlNodePtr node;
+ GList *messages = NULL;
+ xmlParserCtxtPtr ctxt;
+ xmlDocPtr doc;
+ xmlNodePtr log_node;
+ xmlNodePtr node;
+ EmpathyLogSearchHit *hit;
+ McAccount *account;
g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL);
- g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
- g_return_val_if_fail (chat_id != NULL, NULL);
-
- filename = log_manager_get_filename_for_date (manager, account, chat_id, chatroom, date);
+ g_return_val_if_fail (filename != NULL, NULL);
empathy_debug (DEBUG_DOMAIN, "Attempting to parse filename:'%s'...", filename);
if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
empathy_debug (DEBUG_DOMAIN, "Filename:'%s' does not exist", filename);
- g_free (filename);
return NULL;
}
+ /* Get the account from the filename */
+ hit = log_manager_search_hit_new (manager, filename);
+ account = g_object_ref (hit->account);
+ log_manager_search_hit_free (hit);
+
/* Create parser. */
ctxt = xmlNewParserCtxt ();
@@ -304,7 +304,6 @@ empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager,
doc = xmlCtxtReadFile (ctxt, filename, NULL, 0);
if (!doc) {
g_warning ("Failed to parse file:'%s'", filename);
- g_free (filename);
xmlFreeParserCtxt (ctxt);
return NULL;
}
@@ -312,7 +311,6 @@ empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager,
/* The root node, presets. */
log_node = xmlDocGetRootElement (doc);
if (!log_node) {
- g_free (filename);
xmlFreeDoc (doc);
xmlFreeParserCtxt (ctxt);
return NULL;
@@ -363,7 +361,6 @@ empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager,
empathy_debug (DEBUG_DOMAIN, "Parsed %d messages", g_list_length (messages));
- g_free (filename);
xmlFreeDoc (doc);
xmlFreeParserCtxt (ctxt);
@@ -371,6 +368,27 @@ empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager,
}
GList *
+empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager,
+ McAccount *account,
+ const gchar *chat_id,
+ gboolean chatroom,
+ const gchar *date)
+{
+ gchar *filename;
+ GList *messages;
+
+ g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL);
+ g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
+ g_return_val_if_fail (chat_id != NULL, NULL);
+
+ filename = log_manager_get_filename_for_date (manager, account, chat_id, chatroom, date);
+ messages = empathy_log_manager_get_messages_for_file (manager, filename);
+ g_free (filename);
+
+ return messages;
+}
+
+GList *
empathy_log_manager_get_last_messages (EmpathyLogManager *manager,
McAccount *account,
const gchar *chat_id,
@@ -479,21 +497,10 @@ empathy_log_manager_search_new (EmpathyLogManager *manager,
void
empathy_log_manager_search_free (GList *hits)
{
- GList *l;
- EmpathyLogSearchHit *hit;
+ GList *l;
for (l = hits; l; l = l->next) {
- hit = l->data;
-
- if (hit->account) {
- g_object_unref (hit->account);
- }
-
- g_free (hit->date);
- g_free (hit->filename);
- g_free (hit->chat_id);
-
- g_slice_free (EmpathyLogSearchHit, hit);
+ log_manager_search_hit_free (l->data);
}
g_list_free (hits);
@@ -741,3 +748,16 @@ log_manager_search_hit_new (EmpathyLogManager *manager,
return hit;
}
+static void
+log_manager_search_hit_free (EmpathyLogSearchHit *hit)
+{
+ if (hit->account) {
+ g_object_unref (hit->account);
+ }
+
+ g_free (hit->date);
+ g_free (hit->filename);
+ g_free (hit->chat_id);
+
+ g_slice_free (EmpathyLogSearchHit, hit);
+}