]> git.0d.be Git - empathy.git/commitdiff
Do not create log directory for a chat if there is no messages to put in.
authorXavier Claessens <xclaesse@gmail.com>
Thu, 14 Jun 2007 10:45:38 +0000 (10:45 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Thu, 14 Jun 2007 10:45:38 +0000 (10:45 +0000)
2007-06-13 Xavier Claessens  <xclaesse@gmail.com>

* libempathy-gtk/gossip-log-window.c:
* libempathy-gtk/gossip-chat-window.c:
* libempathy/empathy-log-manager.c:
* libempathy/empathy-log-manager.h: Do not create log directory for a
chat if there is no messages to put in. Show logs and information for
the contact we are speaking with in the chat window menu.

svn path=/trunk/; revision=150

ChangeLog
libempathy-gtk/gossip-chat-window.c
libempathy-gtk/gossip-log-window.c
libempathy/empathy-log-manager.c
libempathy/empathy-log-manager.h

index 98ca5b05a8c7817514ffc3bd92012204d3b100c5..67d91eae699500a657d502ee7cd5798ad38fe811 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-06-13 Xavier Claessens  <xclaesse@gmail.com>
+
+       * libempathy-gtk/gossip-log-window.c:
+       * libempathy-gtk/gossip-chat-window.c:
+       * libempathy/empathy-log-manager.c:
+       * libempathy/empathy-log-manager.h: Do not create log directory for a
+       chat if there is no messages to put in. Show logs and information for
+       the contact we are speaking with in the chat window menu.
+
 2007-06-13 Xavier Claessens  <xclaesse@gmail.com>
 
        * libempathy-gtk/Makefile.am:
index aef972cff18d100bbf8a8e452979259de861453e..39639b7dcee602d0dfe272323a856e2994743e6c 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-contact-list.h>
+#include <libempathy/empathy-log-manager.h>
 #include <libempathy/gossip-chatroom-manager.h>
 #include <libempathy/gossip-contact.h>
 #include <libempathy/gossip-debug.h>
 
 #include "gossip-chat-window.h"
 #include "empathy-images.h"
-//#include "gossip-add-contact-dialog.h"
 //#include "gossip-chat-invite.h"
-//#include "gossip-contact-info-dialog.h"
-//#include "gossip-log-window.h"
+#include "empathy-contact-dialogs.h"
+#include "gossip-log-window.h"
 #include "gossip-new-chatroom-dialog.h"
 #include "gossip-preferences.h"
 #include "gossip-private-chat.h"
@@ -897,25 +897,14 @@ static void
 chat_window_log_activate_cb (GtkWidget        *menuitem,
                             GossipChatWindow *window)
 {
-/* FIXME:
        GossipChatWindowPriv *priv;
 
        priv = GET_PRIV (window);
 
-       if (gossip_chat_is_group_chat (priv->current_chat)) {
-               GossipGroupChat *group_chat;
-               GossipChatroom  *chatroom;
-
-               group_chat = GOSSIP_GROUP_CHAT (priv->current_chat);
-               chatroom = gossip_group_chat_get_chatroom (group_chat);
-               gossip_log_window_show (NULL, chatroom);
-       } else {
-               GossipContact *contact;
-
-               contact = gossip_chat_get_contact (priv->current_chat);
-               gossip_log_window_show (contact, NULL);
-       }
-*/
+       gossip_log_window_show (priv->current_chat->account,
+                               gossip_chat_get_id (priv->current_chat),
+                               gossip_chat_is_group_chat (priv->current_chat),
+                               GTK_WINDOW (priv->dialog));
 }
 
 static void
@@ -923,14 +912,15 @@ chat_window_info_activate_cb (GtkWidget        *menuitem,
                              GossipChatWindow *window)
 {
        GossipChatWindowPriv *priv;
-       //GossipContact        *contact;
+       GossipContact        *contact;
 
        priv = GET_PRIV (window);
-/*FIXME:
-       contact = gossip_chat_get_contact (priv->current_chat);
 
-       gossip_contact_info_dialog_show (contact,
-                                        GTK_WINDOW (priv->dialog));*/
+       contact = gossip_private_chat_get_contact (GOSSIP_PRIVATE_CHAT (priv->current_chat));
+
+       empathy_contact_information_dialog_show (contact,
+                                                GTK_WINDOW (priv->dialog),
+                                                FALSE);
 }
 
 static gboolean
@@ -982,28 +972,18 @@ chat_window_conv_activate_cb (GtkWidget        *menuitem,
                              GossipChatWindow *window)
 {
        GossipChatWindowPriv *priv;
+       EmpathyLogManager    *manager;
        gboolean              log_exists = FALSE;
 
        priv = GET_PRIV (window);
-/* FIXME:
-       if (gossip_chat_is_group_chat (priv->current_chat)) {
-               GossipGroupChat *group_chat;
-               GossipChatroom  *chatroom;
 
-               group_chat = GOSSIP_GROUP_CHAT (priv->current_chat);
-               chatroom = gossip_group_chat_get_chatroom (group_chat);
-               if (chatroom) {
-                       log_exists = gossip_log_exists_for_chatroom (chatroom);
-               }
-       } else {
-               GossipContact *contact;
+       manager = empathy_log_manager_new ();
+       log_exists = empathy_log_manager_exists (manager,
+                                                priv->current_chat->account,
+                                                gossip_chat_get_id (priv->current_chat),
+                                                gossip_chat_is_group_chat (priv->current_chat));
+       g_object_unref (manager);
 
-               contact = gossip_chat_get_contact (priv->current_chat);
-               if (contact) {
-                       log_exists = gossip_log_exists_for_contact (contact);
-               }
-       }
-*/
        gtk_widget_set_sensitive (priv->menu_conv_log, log_exists);
 }
 
index 3ec7cdb1d6b7ea57aac0cf49fe6ddd74567d3c71..dae8b79a9a52d0d142f7f48b196c4d419f35decd 100644 (file)
@@ -109,8 +109,6 @@ static void
 log_window_chats_new_message_cb (GossipContact   *own_contact,
                                 GossipMessage   *message,
                                 GossipLogWindow *window);
-//static gboolean
-//log_window_chats_is_today_selected (GossipLogWindow *window);
 static void
 log_window_chats_set_selected  (GossipLogWindow *window,
                                McAccount       *account,
@@ -666,7 +664,7 @@ log_window_chats_populate (GossipLogWindow *window)
 
                gtk_list_store_append (store, &iter);
                gtk_list_store_set (store, &iter,
-                                   COL_CHAT_ICON, "empathy-available",
+                                   COL_CHAT_ICON, "empathy-available", /* FIXME */
                                    COL_CHAT_NAME, hit->chat_id,                                
                                    COL_CHAT_ACCOUNT, account,
                                    COL_CHAT_ID, hit->chat_id,
@@ -769,55 +767,22 @@ log_window_chats_new_message_cb (GossipContact   *own_contact,
        gossip_chat_view_scroll_down (window->chatview_chats);
 }
 
-#if 0
-static gboolean
-log_window_chats_is_today_selected (GossipLogWindow *window)
-{
-       GossipTime  t;
-       gchar      *timestamp;
-       guint       year_selected;
-       guint       year;
-       guint       month;
-       guint       month_selected;
-       guint       day;
-       guint       day_selected;
-       gboolean    selected;
-
-       t = gossip_time_get_current ();
-       timestamp = gossip_time_to_string_local (t, "%Y%m%d");
-
-       sscanf (timestamp, "%4d%2d%2d", &year, &month, &day);
-
-       gtk_calendar_get_date (GTK_CALENDAR (window->calendar_chats),
-                              &year_selected,
-                              &month_selected,
-                              &day_selected);
-
-       /* Hack since this starts at 0 */
-       month_selected++;
-
-       selected = (day_selected == day &&
-                   month_selected == month &&
-                   year_selected == year);
-
-       g_free (timestamp);
-
-       return selected;
-}
-#endif
-
 static void
 log_window_chats_set_selected  (GossipLogWindow *window,
                                McAccount       *account,
                                const gchar     *chat_id,
                                gboolean         is_chatroom)
 {
-       GtkTreeView      *view;
-       GtkTreeModel     *model;
-       GtkTreeSelection *selection;
-       GtkTreeIter       iter;
-       GtkTreePath      *path;
-       gboolean          ok;
+       GossipAccountChooser *account_chooser;
+       GtkTreeView          *view;
+       GtkTreeModel         *model;
+       GtkTreeSelection     *selection;
+       GtkTreeIter           iter;
+       GtkTreePath          *path;
+       gboolean              ok;
+
+       account_chooser = GOSSIP_ACCOUNT_CHOOSER (window->account_chooser_chats);
+       gossip_account_chooser_set_account (account_chooser, account);
 
        view = GTK_TREE_VIEW (window->treeview_chats);
        model = gtk_tree_view_get_model (view);
index 49c67ec4e86f6ea4ff925690e546472f5f96f499..afb40a533b109bdff4113dd2aa8caec9fa7697bf 100644 (file)
@@ -136,6 +136,7 @@ empathy_log_manager_add_message (EmpathyLogManager *manager,
        const gchar   *body_str;
        const gchar   *str;
        gchar         *filename;
+       gchar         *basedir;
        gchar         *body;
        gchar         *timestamp;
        gchar         *contact_name;
@@ -154,6 +155,13 @@ empathy_log_manager_add_message (EmpathyLogManager *manager,
        }
 
        filename = log_manager_get_filename (manager, account, chat_id, chatroom);
+       basedir = g_path_get_dirname (filename);
+       if (!g_file_test (basedir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+               gossip_debug (DEBUG_DOMAIN, "Creating directory:'%s'", basedir);
+
+               g_mkdir_with_parents (basedir, LOG_DIR_CREATE_MODE);
+       }
+       g_free (basedir);
 
        gossip_debug (DEBUG_DOMAIN, "Adding message: '%s' to file: '%s'",
                      body_str, filename);
@@ -196,6 +204,22 @@ empathy_log_manager_add_message (EmpathyLogManager *manager,
        g_free (body);
 }
 
+gboolean
+empathy_log_manager_exists (EmpathyLogManager *manager,
+                           McAccount         *account,
+                           const gchar       *chat_id,
+                           gboolean           chatroom)
+{
+       gchar    *dir;
+       gboolean  exists;
+
+       dir = log_manager_get_dir (manager, account, chat_id, chatroom);
+       exists = g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR);
+       g_free (dir);
+
+       return exists;
+}
+
 GList *
 empathy_log_manager_get_dates (EmpathyLogManager *manager,
                               McAccount         *account,
@@ -214,10 +238,6 @@ empathy_log_manager_get_dates (EmpathyLogManager *manager,
        g_return_val_if_fail (chat_id != NULL, NULL);
 
        directory = log_manager_get_dir (manager, account, chat_id, chatroom);
-       if (!directory) {
-               return NULL;
-       }
-
        dir = g_dir_open (directory, 0, NULL);
        if (!dir) {
                gossip_debug (DEBUG_DOMAIN, "Could not open directory:'%s'", directory);
@@ -614,12 +634,6 @@ log_manager_get_dir (EmpathyLogManager *manager,
                basedir = str;
        }
 
-       if (!g_file_test (basedir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
-               gossip_debug (DEBUG_DOMAIN, "Creating directory:'%s'", basedir);
-
-               g_mkdir_with_parents (basedir, LOG_DIR_CREATE_MODE);
-       }
-
        return basedir;
 }
 
index 9a163fd368d897c2ef704466e3f2a3334577eaba..d1a5f431d60708db612a38a8021b0fc49158e68d 100644 (file)
@@ -65,6 +65,10 @@ void               empathy_log_manager_add_message           (EmpathyLogManager
                                                              const gchar       *chat_id,
                                                              gboolean           chatroom,
                                                              GossipMessage     *message);
+gboolean           empathy_log_manager_exists                (EmpathyLogManager *manager,
+                                                             McAccount         *account,
+                                                             const gchar       *chat_id,
+                                                             gboolean           chatroom);
 GList *            empathy_log_manager_get_dates             (EmpathyLogManager *manager,
                                                              McAccount         *account,
                                                              const gchar       *chat_id,