diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | libempathy-gtk/gossip-chat-window.c | 60 | ||||
-rw-r--r-- | libempathy-gtk/gossip-log-window.c | 57 | ||||
-rw-r--r-- | libempathy/empathy-log-manager.c | 34 | ||||
-rw-r--r-- | libempathy/empathy-log-manager.h | 4 |
5 files changed, 68 insertions, 96 deletions
@@ -1,5 +1,14 @@ 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: * libempathy-gtk/gossip-log-window.glade: * libempathy-gtk/gossip-log-window.h: diff --git a/libempathy-gtk/gossip-chat-window.c b/libempathy-gtk/gossip-chat-window.c index aef972cff..39639b7dc 100644 --- a/libempathy-gtk/gossip-chat-window.c +++ b/libempathy-gtk/gossip-chat-window.c @@ -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> @@ -45,10 +46,9 @@ #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); } diff --git a/libempathy-gtk/gossip-log-window.c b/libempathy-gtk/gossip-log-window.c index 3ec7cdb1d..dae8b79a9 100644 --- a/libempathy-gtk/gossip-log-window.c +++ b/libempathy-gtk/gossip-log-window.c @@ -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); diff --git a/libempathy/empathy-log-manager.c b/libempathy/empathy-log-manager.c index 49c67ec4e..afb40a533 100644 --- a/libempathy/empathy-log-manager.c +++ b/libempathy/empathy-log-manager.c @@ -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; } diff --git a/libempathy/empathy-log-manager.h b/libempathy/empathy-log-manager.h index 9a163fd36..d1a5f431d 100644 --- a/libempathy/empathy-log-manager.h +++ b/libempathy/empathy-log-manager.h @@ -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, |