+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:
#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"
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
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
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);
}
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,
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,
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);
const gchar *body_str;
const gchar *str;
gchar *filename;
+ gchar *basedir;
gchar *body;
gchar *timestamp;
gchar *contact_name;
}
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);
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,
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);
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;
}
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,