From 20bcca610a3382d95284122443a9139b64bb263a Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Wed, 20 Jan 2010 14:39:58 +0000 Subject: Fixed channel map removal bug * removed all leading \n in g_print family func calls --- TODO | 1 + data/TelepathyLogger.client | 2 -- telepathy-logger/channel-text.c | 29 ++++++++++++++--------------- telepathy-logger/channel.c | 6 ++---- telepathy-logger/contact.c | 17 +++++++++++++++++ telepathy-logger/contact.h | 6 ++++++ telepathy-logger/log-manager.c | 4 ++-- telepathy-logger/log-manager.h | 3 +-- telepathy-logger/log-store-empathy.c | 2 +- telepathy-logger/observer.c | 5 ++--- telepathy-logger/utils.c | 8 ++++++++ telepathy-logger/utils.h | 3 +++ 12 files changed, 57 insertions(+), 29 deletions(-) diff --git a/TODO b/TODO index 6bf28f9..6e10b7f 100644 --- a/TODO +++ b/TODO @@ -4,6 +4,7 @@ trucker as soon as TPL will have one: - TplChannel TplChannelText refactoring - TplLogEntry refactoring - use Private struct +- include Avatar token in logstore - fix dbus_g_method_return_error - fix race condition with connecting signals in observer diff --git a/data/TelepathyLogger.client b/data/TelepathyLogger.client index e22a4f2..0f43922 100644 --- a/data/TelepathyLogger.client +++ b/data/TelepathyLogger.client @@ -4,9 +4,7 @@ Interfaces=org.freedesktop.Telepathy.Client.Observer; [org.freedesktop.Telepathy.Client.Observer.ObserverChannelFilter 0] org.freedesktop.Telepathy.Channel.Type s=org.freedesktop.Telepathy.Channel.Type.Text org.freedesktop.Telepathy.Channel.TargetHandleType u=1 -org.freedesktop.Telepathy.Channel.Requested b=true [org.freedesktop.Telepathy.Client.Observer.ObserverChannelFilter 1] org.freedesktop.Telepathy.Channel.Type s=org.freedesktop.Telepathy.Channel.Type.Text org.freedesktop.Telepathy.Channel.TargetHandleType u=2 -org.freedesktop.Telepathy.Channel.Requested b=true diff --git a/telepathy-logger/channel-text.c b/telepathy-logger/channel-text.c index 66b4e8c..acece74 100644 --- a/telepathy-logger/channel-text.c +++ b/telepathy-logger/channel-text.c @@ -61,7 +61,7 @@ _channel_on_closed_cb (TpChannel * proxy, chan_path = g_strdup (tpl_channel_get_channel_path (tpl_chan)); if (!tpl_channel_unregister_from_observer (tpl_chan)) - g_warning ("Channel %s couldn't be unregistered correctly (BUG?)\n", + g_warning ("Channel %s couldn't be unregistered correctly (BUG?)", chan_path); g_free (chan_path); @@ -71,7 +71,7 @@ static void _channel_on_lost_message_cb (TpChannel * proxy, gpointer user_data, GObject * weak_object) { - g_debug ("lost message signal catched. nothing logged\n"); + g_debug ("lost message signal catched. nothing logged"); // TODO log that the system lost a message } @@ -84,7 +84,7 @@ _channel_on_send_error_cb (TpChannel * proxy, gpointer user_data, GObject * weak_object) { g_error ("unlogged event: " - "TP was unable to send the message: %s.\n", arg_Text); + "TP was unable to send the message: %s", arg_Text); // TODO log that the system was unable to send the message } @@ -106,7 +106,6 @@ _channel_on_sent_signal_cb (TpChannel * proxy, TplLogManager *logmanager; gchar *chat_id; - g_assert (TPL_IS_TEXT_CHANNEL (tpl_text)); g_return_if_fail (TPL_IS_TEXT_CHANNEL (tpl_text)); /* Initialize data for TplContact */ @@ -123,7 +122,7 @@ _channel_on_sent_signal_cb (TpChannel * proxy, tpl_contact_receiver = tpl_contact_from_tp_contact (remote); tpl_contact_set_contact_type (tpl_contact_receiver, TPL_CONTACT_USER); - g_message ("%s (%s): %s\n", + g_message ("%s (%s): %s", tpl_contact_get_identifier (tpl_contact_sender), tpl_contact_get_alias (tpl_contact_sender), arg_Text); @@ -196,7 +195,7 @@ _channel_on_received_signal_with_contact_cb (TpConnection * connection, if (error != NULL) { g_error ("Unrecoverable error retrieving remote contact " - "information: %s\n", error->message); + "information: %s", error->message); g_error ("Not able to log the received message: %s", tpl_log_entry_text_get_message (tlog)); return; @@ -205,7 +204,7 @@ _channel_on_received_signal_with_contact_cb (TpConnection * connection, if (n_failed > 0) { g_error ("%d invalid handle(s) passed to " - "tp_connection_get_contacts_by_handle()\n", n_failed); + "tp_connection_get_contacts_by_handle()", n_failed); g_error ("Not able to log the received message: %s", tpl_log_entry_text_get_message (tlog)); return; @@ -218,7 +217,7 @@ _channel_on_received_signal_with_contact_cb (TpConnection * connection, tpl_contact_set_contact_type (tpl_contact_sender, TPL_CONTACT_USER); tpl_log_entry_text_set_sender (tlog, tpl_contact_sender); - g_message ("%s (%s): %s\n", + g_message ("%s (%s): %s", tpl_contact_get_identifier (tpl_contact_sender), tpl_contact_get_alias (tpl_contact_sender), tpl_log_entry_text_get_message (tlog)); @@ -273,7 +272,7 @@ _channel_on_received_signal_cb (TpChannel * proxy, { g_debug ("Non text content flag set." "Probably a delivery notification for a sent message." - "Ignoring\n"); + "Ignoring"); return; } @@ -477,8 +476,8 @@ _tpl_text_channel_get_contact_cb (TpConnection * connection, break; default: g_error ("retrieving TpContacts: passing invalid value " - "for selector: %d\n" - "Aborting channel %s observation\n", + "for selector: %d" + "Aborting channel %s observation", tpl_text->selector, tpl_channel_get_channel_path (tpl_text_channel_get_tpl_channel (tpl_text))); @@ -612,15 +611,15 @@ tpl_text_channel_new (TplChannel * tpl_channel) /* follows unhandled TpHandleType */ case TP_HANDLE_TYPE_NONE: g_warning ("remote handle: TP_HANDLE_TYPE_NONE: " - "un-handled. It's probably OK.\n"); + "un-handled. It's probably OK."); break; case TP_HANDLE_TYPE_LIST: - g_warning ("remote handle: TP_HANDLE_TYPE_LIST: \n" - "un-handled. It's probably OK.\n"); + g_warning ("remote handle: TP_HANDLE_TYPE_LIST: " + "un-handled. It's probably OK."); break; case TP_HANDLE_TYPE_GROUP: g_warning ("remote handle: TP_HANDLE_TYPE_GROUP: " - "un-handled. It's probably OK.\n"); + "un-handled. It's probably OK."); break; default: g_error ("remote handle type unknown %d.", remote_handle_type); diff --git a/telepathy-logger/channel.c b/telepathy-logger/channel.c index 24d5f9a..33a737f 100644 --- a/telepathy-logger/channel.c +++ b/telepathy-logger/channel.c @@ -287,7 +287,7 @@ tpl_channel_register_to_observer (TplChannel * self) } else { - g_debug ("Channel path not found, registering %s\n", key); + g_debug ("Channel path not found, registering %s", key); } /* Instantiate and delegate channel handling to the right object */ @@ -317,13 +317,11 @@ tpl_channel_unregister_from_observer (TplChannel * self) GHashTable *glob_map = tpl_observer_get_channel_map (obs); const gchar *key; - g_assert (TPL_IS_CHANNEL (self)); - g_assert (glob_map != NULL); g_return_val_if_fail (TPL_IS_CHANNEL (self), FALSE); g_return_val_if_fail (glob_map != NULL, FALSE); key = tpl_channel_get_channel_path (self); - g_debug ("Unregistering channel path %s\n", key); + g_debug ("Unregistering channel path %s", key); /* this will destroy the associated value object: at this point the hash table reference should be the only one for the diff --git a/telepathy-logger/contact.c b/telepathy-logger/contact.c index 3f8aa49..0c77e49 100644 --- a/telepathy-logger/contact.c +++ b/telepathy-logger/contact.c @@ -142,6 +142,14 @@ tpl_contact_get_contact_type (TplContact * self) return self->contact_type; } +const gchar * +tpl_contact_get_avatar_token (TplContact * self) +{ + g_return_val_if_fail (TPL_IS_CONTACT (self), NULL); + + return self->avatar_token; +} + TpAccount * tpl_contact_get_account (TplContact * self) { @@ -218,3 +226,12 @@ tpl_contact_set_contact_type (TplContact * self, TplContactType data) self->contact_type = data; } + +void +tpl_contact_set_avatar_token (TplContact * self, const gchar *data) +{ + g_return_if_fail (TPL_IS_CONTACT (self)); + + g_free (self->avatar_token); + self->avatar_token = g_strdup (data); +} diff --git a/telepathy-logger/contact.h b/telepathy-logger/contact.h index 1f709c8..407a6c0 100644 --- a/telepathy-logger/contact.h +++ b/telepathy-logger/contact.h @@ -51,6 +51,7 @@ typedef struct gchar *identifier; gchar *presence_status; gchar *presence_message; + gchar *avatar_token; TpAccount *account; } TplContact; @@ -80,6 +81,8 @@ const gchar *tpl_contact_get_presence_message (TplContact * self); TplContactType tpl_contact_get_contact_type (TplContact * self); +const gchar * tpl_contact_get_avatar_token (TplContact * self); + TpAccount *tpl_contact_get_account (TplContact * self); void tpl_contact_set_contact (TplContact * self, TpContact * data); @@ -96,5 +99,8 @@ void tpl_contact_set_presence_message (TplContact * self, const gchar * data); void tpl_contact_set_contact_type (TplContact * self, TplContactType data); +void tpl_contact_set_avatar_token (TplContact * self, const gchar *data); + + G_END_DECLS #endif // __TPL_CONTACT_H__ diff --git a/telepathy-logger/log-manager.c b/telepathy-logger/log-manager.c index e66f1b0..e00aea4 100644 --- a/telepathy-logger/log-manager.c +++ b/telepathy-logger/log-manager.c @@ -151,11 +151,11 @@ tpl_log_manager_init (TplLogManager * manager) */ if (!g_thread_supported ()) { - g_debug ("Initializing GThread\n"); + g_debug ("Initializing GThread"); g_thread_init (NULL); } else - g_debug ("GThread already initialized. Brilliant.\n"); + g_debug ("GThread already initialized. Brilliant!"); } TplLogManager * diff --git a/telepathy-logger/log-manager.h b/telepathy-logger/log-manager.h index 0c7110b..e1c8aa4 100644 --- a/telepathy-logger/log-manager.h +++ b/telepathy-logger/log-manager.h @@ -131,8 +131,7 @@ void tpl_log_manager_get_filtered_messages_async (TplLogManager * manager, guint num_messages, TplLogMessageFilter filter, gpointer filter_user_data, - TplLogManagerAsyncCallback - callback, + TplLogManagerAsyncCallback callback, gpointer user_data, GDestroyNotify destroy); diff --git a/telepathy-logger/log-store-empathy.c b/telepathy-logger/log-store-empathy.c index 81c83bf..7b4c714 100644 --- a/telepathy-logger/log-store-empathy.c +++ b/telepathy-logger/log-store-empathy.c @@ -480,7 +480,7 @@ log_store_empathy_exists (TplLogStore * self, gchar *dir; gboolean exists; - g_return_val_if_fail (TPL_IS_LOG_ENTRY (self), FALSE); + g_return_val_if_fail (TPL_IS_LOG_STORE (self), FALSE); g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE); g_return_val_if_fail (!TPL_STR_EMPTY (chat_id), FALSE); diff --git a/telepathy-logger/observer.c b/telepathy-logger/observer.c index 73df43e..ff0f17d 100644 --- a/telepathy-logger/observer.c +++ b/telepathy-logger/observer.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -336,7 +335,7 @@ tpl_observer_init (TplObserver * self) TpDBusDaemon *tp_bus; GError *error = NULL; - self->channel_map = g_hash_table_new_full (g_str_hash, (GEqualFunc) tp_strdiff, + self->channel_map = g_hash_table_new_full (g_str_hash, (GEqualFunc) tpl_strequal, g_free, g_object_unref); logmanager = tpl_log_manager_dup_singleton (); @@ -346,7 +345,7 @@ tpl_observer_init (TplObserver * self) if (tp_dbus_daemon_request_name (tp_bus, TPL_OBSERVER_WELL_KNOWN_BUS_NAME, TRUE, &error)) { - g_debug ("%s DBus well known name registered\n", + g_debug ("%s DBus well known name registered", TPL_OBSERVER_WELL_KNOWN_BUS_NAME); } else diff --git a/telepathy-logger/utils.c b/telepathy-logger/utils.c index 1f51efc..89840c9 100644 --- a/telepathy-logger/utils.c +++ b/telepathy-logger/utils.c @@ -21,6 +21,8 @@ #include "utils.h" +#include + void tpl_object_unref_if_not_null (void *data) { @@ -38,3 +40,9 @@ tpl_object_ref_if_not_null (void *data) g_object_ref (data); } } + +gboolean +tpl_strequal (const gchar *left, const gchar *right) +{ + return ! tp_strdiff(left, right); +} diff --git a/telepathy-logger/utils.h b/telepathy-logger/utils.h index 56fac99..00b6ee0 100644 --- a/telepathy-logger/utils.h +++ b/telepathy-logger/utils.h @@ -37,6 +37,9 @@ void tpl_object_unref_if_not_null (void *data); void tpl_object_ref_if_not_null (void *data); +gboolean tpl_strequal (const gchar *left, const gchar *right); + + #define tpl_call_with_err_if_fail(guard, obj, PREFIX, POSTFIX, msg, func, user_data) \ if (!(guard)) \ { \ -- cgit v1.2.1