diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-03-06 19:51:58 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2009-03-06 19:51:58 +0800 |
commit | 79697ab1fc4f90646bc3495514d6e30585a2f97f (patch) | |
tree | 1dcea2b1e0d93f5db992084c449635bfcc961876 /libempathy | |
parent | d53b22689f12218cfa3b5f72fb936dd01dd08885 (diff) | |
download | gsoc2013-empathy-79697ab1fc4f90646bc3495514d6e30585a2f97f.tar gsoc2013-empathy-79697ab1fc4f90646bc3495514d6e30585a2f97f.tar.gz gsoc2013-empathy-79697ab1fc4f90646bc3495514d6e30585a2f97f.tar.bz2 gsoc2013-empathy-79697ab1fc4f90646bc3495514d6e30585a2f97f.tar.lz gsoc2013-empathy-79697ab1fc4f90646bc3495514d6e30585a2f97f.tar.xz gsoc2013-empathy-79697ab1fc4f90646bc3495514d6e30585a2f97f.tar.zst gsoc2013-empathy-79697ab1fc4f90646bc3495514d6e30585a2f97f.zip |
Only write messages to one specified log source, hardcoded at the moment.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
svn path=/trunk/; revision=2590
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-log-manager.c | 34 | ||||
-rw-r--r-- | libempathy/empathy-log-manager.h | 5 | ||||
-rw-r--r-- | libempathy/empathy-log-source-empathy.c | 15 | ||||
-rw-r--r-- | libempathy/empathy-log-source.c | 11 | ||||
-rw-r--r-- | libempathy/empathy-log-source.h | 9 |
5 files changed, 50 insertions, 24 deletions
diff --git a/libempathy/empathy-log-manager.c b/libempathy/empathy-log-manager.c index 46463733f..1593ff4d0 100644 --- a/libempathy/empathy-log-manager.c +++ b/libempathy/empathy-log-manager.c @@ -28,6 +28,8 @@ #include <stdlib.h> #include <glib/gstdio.h> +#include <telepathy-glib/util.h> + #include "empathy-log-manager.h" #include "empathy-log-source-empathy.h" #include "empathy-log-source.h" @@ -120,26 +122,44 @@ empathy_log_manager_dup_singleton (void) return g_object_new (EMPATHY_TYPE_LOG_MANAGER, NULL); } -void +gboolean empathy_log_manager_add_message (EmpathyLogManager *manager, const gchar *chat_id, gboolean chatroom, - EmpathyMessage *message) + EmpathyMessage *message, + GError **error) { EmpathyLogManagerPriv *priv; GList *l; + gboolean out = FALSE; + gboolean found = FALSE; - g_return_if_fail (EMPATHY_IS_LOG_MANAGER (manager)); - g_return_if_fail (chat_id != NULL); - g_return_if_fail (EMPATHY_IS_MESSAGE (message)); + /* TODO: When multiple log sources appear with add_message implementations + * make this customisable. */ + const gchar *add_source = "Empathy"; + + g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), FALSE); + g_return_val_if_fail (chat_id != NULL, FALSE); + g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), FALSE); priv = GET_PRIV (manager); for (l = priv->sources; l; l = l->next) { - empathy_log_source_add_message (EMPATHY_LOG_SOURCE (l->data), - chat_id, chatroom, message); + if (!tp_strdiff (empathy_log_source_get_name ( + EMPATHY_LOG_SOURCE (l->data)), add_source)) + { + out = empathy_log_source_add_message (EMPATHY_LOG_SOURCE (l->data), + chat_id, chatroom, message, error); + found = TRUE; + break; + } } + + if (!found) + DEBUG ("Failed to find chosen log source to write to."); + + return out; } gboolean diff --git a/libempathy/empathy-log-manager.h b/libempathy/empathy-log-manager.h index fa9e39b7b..688cb11ff 100644 --- a/libempathy/empathy-log-manager.h +++ b/libempathy/empathy-log-manager.h @@ -73,8 +73,9 @@ struct _EmpathyLogSearchHit GType empathy_log_manager_get_type (void) G_GNUC_CONST; EmpathyLogManager *empathy_log_manager_dup_singleton (void); -void empathy_log_manager_add_message (EmpathyLogManager *manager, - const gchar *chat_id, gboolean chatroom, EmpathyMessage *message); +gboolean empathy_log_manager_add_message (EmpathyLogManager *manager, + const gchar *chat_id, gboolean chatroom, EmpathyMessage *message, + GError **error); gboolean empathy_log_manager_exists (EmpathyLogManager *manager, McAccount *account, const gchar *chat_id, gboolean chatroom); GList *empathy_log_manager_get_dates (EmpathyLogManager *manager, diff --git a/libempathy/empathy-log-source-empathy.c b/libempathy/empathy-log-source-empathy.c index fd744f94b..baad6c965 100644 --- a/libempathy/empathy-log-source-empathy.c +++ b/libempathy/empathy-log-source-empathy.c @@ -172,11 +172,12 @@ log_source_empathy_get_filename (EmpathyLogSource *self, return filename; } -static void +static gboolean log_source_empathy_add_message (EmpathyLogSource *self, const gchar *chat_id, gboolean chatroom, - EmpathyMessage *message) + EmpathyMessage *message, + GError **error) { FILE *file; McAccount *account; @@ -193,9 +194,9 @@ log_source_empathy_add_message (EmpathyLogSource *self, gchar *contact_id; TpChannelTextMessageType msg_type; - g_return_if_fail (EMPATHY_IS_LOG_SOURCE (self)); - g_return_if_fail (chat_id != NULL); - g_return_if_fail (EMPATHY_IS_MESSAGE (message)); + g_return_val_if_fail (EMPATHY_IS_LOG_SOURCE (self), FALSE); + g_return_val_if_fail (chat_id != NULL, FALSE); + g_return_val_if_fail (EMPATHY_IS_MESSAGE (message), FALSE); sender = empathy_message_get_sender (message); account = empathy_contact_get_account (sender); @@ -203,7 +204,7 @@ log_source_empathy_add_message (EmpathyLogSource *self, msg_type = empathy_message_get_tptype (message); if (G_STR_EMPTY (body_str)) - return; + return FALSE; filename = log_source_empathy_get_filename (self, account, chat_id, chatroom); basedir = g_path_get_dirname (filename); @@ -258,6 +259,8 @@ log_source_empathy_add_message (EmpathyLogSource *self, g_free (timestamp); g_free (body); g_free (avatar_token); + + return TRUE; } static gboolean diff --git a/libempathy/empathy-log-source.c b/libempathy/empathy-log-source.c index 4080d5a6c..f1e37fa79 100644 --- a/libempathy/empathy-log-source.c +++ b/libempathy/empathy-log-source.c @@ -68,17 +68,18 @@ empathy_log_source_exists (EmpathyLogSource *self, -void +gboolean empathy_log_source_add_message (EmpathyLogSource *self, const gchar *chat_id, gboolean chatroom, - EmpathyMessage *message) + EmpathyMessage *message, + GError **error) { if (!EMPATHY_LOG_SOURCE_GET_INTERFACE (self)->add_message) - return; + return FALSE; - EMPATHY_LOG_SOURCE_GET_INTERFACE (self)->add_message ( - self, chat_id, chatroom, message); + return EMPATHY_LOG_SOURCE_GET_INTERFACE (self)->add_message ( + self, chat_id, chatroom, message, error); } GList * diff --git a/libempathy/empathy-log-source.h b/libempathy/empathy-log-source.h index c00571813..03d920c28 100644 --- a/libempathy/empathy-log-source.h +++ b/libempathy/empathy-log-source.h @@ -51,8 +51,8 @@ struct _EmpathyLogSourceInterface const gchar * (*get_name) (EmpathyLogSource *self); gboolean (*exists) (EmpathyLogSource *self, McAccount *account, const gchar *chat_id, gboolean chatroom); - void (*add_message) (EmpathyLogSource *self, const gchar *chat_id, - gboolean chatroom, EmpathyMessage *message); + gboolean (*add_message) (EmpathyLogSource *self, const gchar *chat_id, + gboolean chatroom, EmpathyMessage *message, GError **error); GList * (*get_dates) (EmpathyLogSource *self, McAccount *account, const gchar *chat_id, gboolean chatroom); GList * (*get_messages_for_date) (EmpathyLogSource *self, @@ -72,8 +72,9 @@ GType empathy_log_source_get_type (void) G_GNUC_CONST; const gchar *empathy_log_source_get_name (EmpathyLogSource *self); gboolean empathy_log_source_exists (EmpathyLogSource *self, McAccount *account, const gchar *chat_id, gboolean chatroom); -void empathy_log_source_add_message (EmpathyLogSource *self, - const gchar *chat_id, gboolean chatroom, EmpathyMessage *message); +gboolean empathy_log_source_add_message (EmpathyLogSource *self, + const gchar *chat_id, gboolean chatroom, EmpathyMessage *message, + GError **error); GList *empathy_log_source_get_dates (EmpathyLogSource *self, McAccount *account, const gchar *chat_id, gboolean chatroom); GList *empathy_log_source_get_messages_for_date (EmpathyLogSource *self, |