]> git.0d.be Git - empathy.git/commitdiff
Add MSN setting UI. Fixes bug #443162 (Cosimo Cecchi).
authorXavier Claessens <xclaesse@gmail.com>
Mon, 9 Jul 2007 15:44:58 +0000 (15:44 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Mon, 9 Jul 2007 15:44:58 +0000 (15:44 +0000)
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

ChangeLog
libempathy-gtk/Makefile.am
libempathy-gtk/empathy-account-widget-msn.c [new file with mode: 0644]
libempathy-gtk/empathy-account-widget-msn.glade [new file with mode: 0644]
libempathy-gtk/empathy-account-widget-msn.h [new file with mode: 0644]
libempathy-gtk/empathy-accounts-dialog.c
libempathy-gtk/empathy-chat-view.c
libempathy/empathy-log-manager.c
libempathy/empathy-log-manager.h

index 01cb9ee9ef104d6611d7e3df10fa1d9219ace4c2..0823abdbb6b1c22e488ee9c17b1fdae90b05ea63 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,21 @@
+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.
+
 2007-07-07 Xavier Claessens  <xclaesse@gmail.com>
 
        * libempathy-gtk/empathy-account-widget-generic.c: Workaround to fix a 
-       commonly reported crash.
+       commonly reported crash. Fixes bug #454277
        * libempathy/empathy-tp-group.c: Add a missing check.
 
 2007-06-30 Xavier Claessens  <xclaesse@gmail.com>
index 8e7ef602fcf87a9ec01c043f2fe7961bf41ade04..653c26811d1f11ba93fed9e1fc03e0fee7e503ac 100644 (file)
@@ -39,7 +39,8 @@ libempathy_gtk_la_SOURCES =                   \
        empathy-new-chatroom-dialog.c           \
        empathy-chatrooms-window.c              \
        empathy-log-window.c                    \
-       empathy-ui-utils.c
+       empathy-ui-utils.c                     \
+       empathy-account-widget-msn.c
 
 libempathy_gtk_la_LIBADD =                     \
        $(EMPATHY_LIBS)                         \
@@ -95,7 +96,8 @@ glade_DATA =                                  \
        empathy-chatrooms-window.glade          \
        empathy-spell-dialog.glade              \
        empathy-log-window.glade                \
-       empathy-chat.glade
+       empathy-chat.glade                     \
+       empathy-account-widget-msn.glade
 
 dtddir = $(datadir)/empathy
 dtd_DATA =                                     \
diff --git a/libempathy-gtk/empathy-account-widget-msn.c b/libempathy-gtk/empathy-account-widget-msn.c
new file mode 100644 (file)
index 0000000..9e58843
--- /dev/null
@@ -0,0 +1,223 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ * 
+ * Authors: Cosimo Cecchi <anarki@lilik.it>
+ */
+
+#include "config.h"
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+
+#include <libmissioncontrol/mc-profile.h>
+
+#include <libempathy/empathy-utils.h>
+
+#include "empathy-account-widget-msn.h"
+#include "empathy-ui-utils.h"
+
+typedef struct {
+       McAccount *account;
+
+       GtkWidget *vbox_settings;
+       GtkWidget *button_forget;
+       GtkWidget *entry_id;
+       GtkWidget *entry_password;
+       GtkWidget *entry_server;
+       GtkWidget *spinbutton_port;
+} EmpathyAccountWidgetMSN;
+
+static gboolean account_widget_msn_entry_focus_cb            (GtkWidget               *widget,
+                                                             GdkEventFocus           *event,
+                                                             EmpathyAccountWidgetMSN *settings);
+static void     account_widget_msn_entry_changed_cb          (GtkWidget               *widget,
+                                                             EmpathyAccountWidgetMSN *settings);
+static void    account_widget_msn_value_changed_cb          (GtkWidget               *spinbutton,
+                                                             EmpathyAccountWidgetMSN *settings);
+static void     account_widget_msn_button_forget_clicked_cb  (GtkWidget               *button,
+                                                             EmpathyAccountWidgetMSN *settings);
+static void     account_widget_msn_destroy_cb                (GtkWidget               *widget,
+                                                             EmpathyAccountWidgetMSN *settings);
+static void     account_widget_msn_setup                     (EmpathyAccountWidgetMSN *settings);
+
+static gboolean
+account_widget_msn_entry_focus_cb (GtkWidget               *widget,
+                                  GdkEventFocus           *event,
+                                  EmpathyAccountWidgetMSN *settings)
+{
+       const gchar *param;
+       const gchar *str;
+       
+       if (widget == settings->entry_password) {
+               param = "password";
+       }
+       else if (widget == settings->entry_server) {
+               param = "server";
+       }
+       else if (widget == settings->entry_id) {
+               param = "account";
+       } else {
+               return FALSE;
+       }
+       
+       str = gtk_entry_get_text (GTK_ENTRY (widget));
+       
+       if (G_STR_EMPTY (str)) {
+               gchar *value = NULL;
+
+               mc_account_get_param_string (settings->account, param, &value);
+               gtk_entry_set_text (GTK_ENTRY (widget), value ? value : "");
+               g_free (value);
+       } else {
+               mc_account_set_param_string (settings->account, param, str);
+       }
+
+       return FALSE;
+}
+
+static void
+account_widget_msn_entry_changed_cb (GtkWidget               *widget,
+                                    EmpathyAccountWidgetMSN *settings)
+{
+       if (widget == settings->entry_password) {
+               const gchar *str;
+
+               str = gtk_entry_get_text (GTK_ENTRY (widget));
+               gtk_widget_set_sensitive (settings->button_forget, !G_STR_EMPTY (str));
+       }
+}
+
+static void
+account_widget_msn_value_changed_cb (GtkWidget                 *spinbutton,
+                                    EmpathyAccountWidgetMSN    *settings)
+{
+       if (spinbutton == settings->spinbutton_port) {
+               gdouble value;
+
+               value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton));
+               mc_account_set_param_int (settings->account, "port", (gint) value);
+       }
+}
+
+static void
+account_widget_msn_button_forget_clicked_cb (GtkWidget               *button,
+                                            EmpathyAccountWidgetMSN *settings)
+{
+       mc_account_set_param_string (settings->account, "password", "");
+       gtk_entry_set_text (GTK_ENTRY (settings->entry_password), "");
+}
+
+static void
+account_widget_msn_destroy_cb (GtkWidget               *widget,
+                              EmpathyAccountWidgetMSN *settings)
+{
+       g_object_unref (settings->account);
+       g_free (settings);
+}
+
+static void
+account_widget_msn_setup (EmpathyAccountWidgetMSN *settings)
+{
+       guint  port = 0;
+       gchar *id = NULL;
+       gchar *server = NULL;
+       gchar *password = NULL;
+
+       mc_account_get_param_int (settings->account, "port", &port);
+       mc_account_get_param_string (settings->account, "account", &id);
+       mc_account_get_param_string (settings->account, "server", &server);
+       mc_account_get_param_string (settings->account, "password", &password);
+
+       gtk_entry_set_text (GTK_ENTRY (settings->entry_id), id ? id : "");
+       gtk_entry_set_text (GTK_ENTRY (settings->entry_password), password ? password : "");
+       gtk_entry_set_text (GTK_ENTRY (settings->entry_server), server ? server : "");
+       gtk_spin_button_set_value (GTK_SPIN_BUTTON (settings->spinbutton_port), port);
+
+       gtk_widget_set_sensitive (settings->button_forget, !G_STR_EMPTY (password));
+
+       g_free (id);
+       g_free (server);
+       g_free (password);
+}
+
+GtkWidget *
+empathy_account_widget_msn_new (McAccount *account)
+{
+       EmpathyAccountWidgetMSN *settings;
+       GladeXML                *glade;
+       GtkSizeGroup            *size_group;
+       GtkWidget               *label_id;
+       GtkWidget               *label_password;
+       GtkWidget               *label_server;
+       GtkWidget               *label_port; 
+
+       settings = g_new0 (EmpathyAccountWidgetMSN, 1);
+       settings->account = g_object_ref (account);
+
+       glade = empathy_glade_get_file ("empathy-account-widget-msn.glade",
+                                      "vbox_msn_settings",
+                                      NULL,
+                                      "vbox_msn_settings", &settings->vbox_settings,
+                                      "button_forget", &settings->button_forget,
+                                      "label_id", &label_id,
+                                      "label_password", &label_password,
+                                      "label_server", &label_server,
+                                      "label_port", &label_port,
+                                      "entry_id", &settings->entry_id,
+                                      "entry_password", &settings->entry_password,
+                                      "entry_server", &settings->entry_server,
+                                      "spinbutton_port", &settings->spinbutton_port,
+                                      NULL);
+
+       account_widget_msn_setup (settings);
+
+       empathy_glade_connect (glade, 
+                             settings,
+                             "vbox_msn_settings", "destroy", account_widget_msn_destroy_cb,
+                             "button_forget", "clicked", account_widget_msn_button_forget_clicked_cb,
+                             "entry_id", "changed", account_widget_msn_entry_changed_cb,
+                             "entry_password", "changed", account_widget_msn_entry_changed_cb,
+                             "entry_server", "changed", account_widget_msn_entry_changed_cb,
+                             "entry_id", "focus-out-event", account_widget_msn_entry_focus_cb,
+                             "entry_password", "focus-out-event", account_widget_msn_entry_focus_cb,
+                             "entry_server", "focus-out-event", account_widget_msn_entry_focus_cb,
+                             "spinbutton_port", "value-changed", account_widget_msn_value_changed_cb,
+                             NULL);
+
+       g_object_unref (glade);
+
+       /* Set up remaining widgets */
+       size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+       gtk_size_group_add_widget (size_group, label_id);
+       gtk_size_group_add_widget (size_group, label_password);
+       gtk_size_group_add_widget (size_group, label_server);
+       gtk_size_group_add_widget (size_group, label_port);
+
+       g_object_unref (size_group);
+
+       gtk_widget_show (settings->vbox_settings);
+
+       return settings->vbox_settings;
+}
diff --git a/libempathy-gtk/empathy-account-widget-msn.glade b/libempathy-gtk/empathy-account-widget-msn.glade
new file mode 100644 (file)
index 0000000..a1ab76f
--- /dev/null
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+  <widget class="GtkWindow" id="account_msn_settings">
+    <property name="visible">True</property>
+    <property name="title" translatable="yes">msn account settings</property>
+    <property name="resizable">False</property>
+    <child>
+      <widget class="GtkTable" id="vbox_msn_settings">
+        <property name="visible">True</property>
+        <property name="n_rows">4</property>
+        <property name="n_columns">2</property>
+        <property name="column_spacing">12</property>
+        <property name="row_spacing">6</property>
+        <child>
+          <widget class="GtkSpinButton" id="spinbutton_port">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="adjustment">0 0 65536 1 10 10</property>
+            <property name="climb_rate">1</property>
+            <property name="numeric">True</property>
+          </widget>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="right_attach">2</property>
+            <property name="top_attach">3</property>
+            <property name="bottom_attach">4</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkLabel" id="label_id">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">Login I_D:</property>
+            <property name="use_underline">True</property>
+            <property name="mnemonic_widget">entry_id</property>
+          </widget>
+          <packing>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkLabel" id="label_password">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">Pass_word:</property>
+            <property name="use_underline">True</property>
+            <property name="mnemonic_widget">entry_password</property>
+          </widget>
+          <packing>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkHBox" id="hbox182">
+            <property name="visible">True</property>
+            <property name="spacing">2</property>
+            <child>
+              <widget class="GtkEntry" id="entry_password">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="visibility">False</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="button_forget">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="tooltip" translatable="yes">Forget password and clear the entry.</property>
+                <property name="response_id">0</property>
+                <child>
+                  <widget class="GtkImage" id="image839">
+                    <property name="visible">True</property>
+                    <property name="stock">gtk-clear</property>
+                    <property name="icon_size">1</property>
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="right_attach">2</property>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options">GTK_FILL</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkEntry" id="entry_id">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+          </widget>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="right_attach">2</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkLabel" id="label_server">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">_Server:</property>
+            <property name="use_underline">True</property>
+            <property name="mnemonic_widget">entry_server</property>
+          </widget>
+          <packing>
+            <property name="top_attach">2</property>
+            <property name="bottom_attach">3</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkEntry" id="entry_server">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+          </widget>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="right_attach">2</property>
+            <property name="top_attach">2</property>
+            <property name="bottom_attach">3</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkLabel" id="label_port">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">_Port:</property>
+            <property name="use_underline">True</property>
+          </widget>
+          <packing>
+            <property name="top_attach">3</property>
+            <property name="bottom_attach">4</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>
diff --git a/libempathy-gtk/empathy-account-widget-msn.h b/libempathy-gtk/empathy-account-widget-msn.h
new file mode 100644 (file)
index 0000000..a613316
--- /dev/null
@@ -0,0 +1,34 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ * 
+ * Authors: Cosimo Cecchi <anarki@lilik.it>
+ */
+
+#ifndef __EMPATHY_ACCOUNT_WIDGET_MSN_H__
+#define __EMPATHY_ACCOUNT_WIDGET_MSN_H__
+
+#include <libmissioncontrol/mc-account.h>
+
+G_BEGIN_DECLS
+
+GtkWidget *empathy_account_widget_msn_new (McAccount *account);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_ACCOUNT_WIDGET_MSN_H__ */
index 0e5f909c1a13d5b1297e7b27edac05dad6edf3f6..8f6a281e89ff16127f2ee7d4bf382701db179f6d 100644 (file)
@@ -46,6 +46,7 @@
 #include "empathy-profile-chooser.h"
 #include "empathy-account-widget-generic.h"
 #include "empathy-account-widget-jabber.h"
+#include "empathy-account-widget-msn.h"
 
 #define DEBUG_DOMAIN "AccountDialog"
 
@@ -287,7 +288,12 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
                if (strcmp (config_ui, "jabber") == 0) {
                        dialog->settings_widget = 
                                empathy_account_widget_jabber_new (account);
-               } else {
+               } 
+               else if (strcmp (config_ui, "msn") == 0) {
+                       dialog ->settings_widget =
+                               empathy_account_widget_msn_new (account);
+               }
+               else {
                        dialog->settings_widget = 
                                empathy_account_widget_generic_new (account,
                                                                   dialog->label_name);
index fda268676d6701c2279b5a3dc1b352203601fcdd..65094bda9a01fd6b06cd1da7e3b84a4355cb7c56 100644 (file)
@@ -2004,7 +2004,7 @@ empathy_chat_view_find_abilities (EmpathyChatView *view,
 
 void
 empathy_chat_view_highlight (EmpathyChatView *view,
-                           const gchar    *text)
+                            const gchar     *text)
 {
        GtkTextBuffer *buffer;
        GtkTextIter    iter;
index f7e3540fc4c3ec370be25bfbb336bab87555cf13..4313bc2cf047de6b0f794d217be79c974718da03 100644 (file)
@@ -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,13 +361,33 @@ 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);
 
        return messages;
 }
 
+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,
@@ -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);
+}
index 67ec19d52c832cc58bdfc2111c5400592392e56d..e881f44cbedb4943420c903e20b2f7c74ace92d9 100644 (file)
@@ -73,6 +73,8 @@ GList *            empathy_log_manager_get_dates             (EmpathyLogManager
                                                              McAccount         *account,
                                                              const gchar       *chat_id,
                                                              gboolean           chatroom);
+GList *            empathy_log_manager_get_messages_for_file (EmpathyLogManager *manager,
+                                                             const gchar       *filename);
 GList *            empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager,
                                                              McAccount         *account,
                                                              const gchar       *chat_id,
@@ -82,6 +84,8 @@ GList *            empathy_log_manager_get_last_messages     (EmpathyLogManager
                                                              McAccount         *account,
                                                              const gchar       *chat_id,
                                                              gboolean           chatroom);
+GList *            empathy_log_manager_get_messages_for_file (EmpathyLogManager *manager,
+                                                             const gchar       *filename);
 GList *            empathy_log_manager_get_chats             (EmpathyLogManager *manager,
                                                              McAccount         *account);
 GList *            empathy_log_manager_search_new            (EmpathyLogManager *manager,