aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2007-06-14 18:45:38 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-06-14 18:45:38 +0800
commit93e7c475bce7aca22c2b073b7c4b564121625b3c (patch)
tree4c826195bb664ea62405412935ce4047dbf31c95 /libempathy
parentc82238798de571010689f3a3f6207f37cba1bb2d (diff)
downloadgsoc2013-empathy-93e7c475bce7aca22c2b073b7c4b564121625b3c.tar
gsoc2013-empathy-93e7c475bce7aca22c2b073b7c4b564121625b3c.tar.gz
gsoc2013-empathy-93e7c475bce7aca22c2b073b7c4b564121625b3c.tar.bz2
gsoc2013-empathy-93e7c475bce7aca22c2b073b7c4b564121625b3c.tar.lz
gsoc2013-empathy-93e7c475bce7aca22c2b073b7c4b564121625b3c.tar.xz
gsoc2013-empathy-93e7c475bce7aca22c2b073b7c4b564121625b3c.tar.zst
gsoc2013-empathy-93e7c475bce7aca22c2b073b7c4b564121625b3c.zip
Do not create log directory for a chat if there is no messages to put in.
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
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-log-manager.c34
-rw-r--r--libempathy/empathy-log-manager.h4
2 files changed, 28 insertions, 10 deletions
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,