diff options
author | Cosimo Alfarano <cosimo.alfarano@collabora.co.uk> | 2010-02-05 18:53:16 +0000 |
---|---|---|
committer | Cosimo Alfarano <cosimo.alfarano@collabora.co.uk> | 2010-02-05 18:53:16 +0000 |
commit | 58d6bab01c5f7d75e4c6e7b9f8c23843de15098a (patch) | |
tree | bc60f59b9374a633acf7d2a10a75d8dd76f04860 | |
parent | 7cd4c1beaaff23982315feb17fbbc024e8b61377 (diff) | |
download | telepathy-logger-58d6bab01c5f7d75e4c6e7b9f8c23843de15098a.tar.gz |
fix lost pending messages
* add support for Pending Messages retrieval on Text channels
* misc TP re-styling
* add properties to TplContact
* add documentation for some methods
-rw-r--r-- | src/dbus-service.c | 2 | ||||
-rw-r--r-- | telepathy-logger/channel-text.c | 177 | ||||
-rw-r--r-- | telepathy-logger/contact.c | 159 | ||||
-rw-r--r-- | telepathy-logger/log-manager.c | 31 | ||||
-rw-r--r-- | telepathy-logger/observer.c | 12 | ||||
-rw-r--r-- | telepathy-logger/util.c | 1 |
6 files changed, 270 insertions, 112 deletions
diff --git a/src/dbus-service.c b/src/dbus-service.c index ddeb23a..7cfdf02 100644 --- a/src/dbus-service.c +++ b/src/dbus-service.c @@ -104,7 +104,7 @@ _pack_last_chats_answer (GList *data, (*array) = g_ptr_array_new_with_free_func ((GDestroyNotify) g_value_array_free); retval = *array; - for(data_idx=0; data_idx<g_list_length(data); ++data_idx) + for(data_idx = 0; data_idx < g_list_length (data); ++data_idx) { TplLogEntry *log = g_list_nth_data (data, data_idx); diff --git a/telepathy-logger/channel-text.c b/telepathy-logger/channel-text.c index f3ab6dd..dc7c70e 100644 --- a/telepathy-logger/channel-text.c +++ b/telepathy-logger/channel-text.c @@ -27,6 +27,7 @@ #include "channel-text.h" +#include <glib.h> #include <telepathy-glib/contact.h> #include <telepathy-glib/enums.h> @@ -60,25 +61,29 @@ static TpContactFeature features[TP_CONTACT_FEATURES_LEN] = { static void call_when_ready_wrapper (TplChannel *tpl_chan, GAsyncReadyCallback cb, gpointer user_data); +void got_pending_messages_cb (TpChannel *proxy, const GPtrArray *result, + const GError *error, gpointer user_data, GObject *weak_object); + static void got_tpl_chan_ready_cb (GObject *obj, GAsyncResult *result, gpointer user_data); -static void _channel_on_closed_cb (TpChannel *proxy, gpointer user_data, +static void on_closed_cb (TpChannel *proxy, gpointer user_data, GObject *weak_object); -static void _channel_on_lost_message_cb (TpChannel *proxy, gpointer user_data, +static void on_lost_message_cb (TpChannel *proxy, gpointer user_data, GObject *weak_object); -static void _channel_on_received_signal_cb (TpChannel *proxy, guint arg_ID, +static void on_received_signal_cb (TpChannel *proxy, guint arg_ID, guint arg_Timestamp, guint arg_Sender, guint arg_Type, guint arg_Flags, const gchar *arg_Text, gpointer user_data, GObject *weak_object); -static void _channel_on_sent_signal_cb (TpChannel *proxy, guint arg_Timestamp, +static void on_sent_signal_cb (TpChannel *proxy, guint arg_Timestamp, guint arg_Type, const gchar *arg_Text, gpointer user_data, GObject *weak_object); -static void _channel_on_send_error_cb (TpChannel *proxy, guint arg_Error, +static void on_send_error_cb (TpChannel *proxy, guint arg_Error, guint arg_Timestamp, guint arg_Type, const gchar *arg_Text, gpointer user_data, GObject *weak_object); -static void pendingproc_prepare_tpl_channel (TplActionChain *ctx); static void pendingproc_connect_signals (TplActionChain *ctx); +static void pendingproc_get_pending_messages (TplActionChain *ctx); +static void pendingproc_prepare_tpl_channel (TplActionChain *ctx); static void pendingproc_get_chatroom_id (TplActionChain *ctx); -static void _tpl_channel_text_get_chatroom_cb (TpConnection *proxy, +static void get_chatroom_id_cb (TpConnection *proxy, const gchar **out_Identifiers, const GError *error, gpointer user_data, GObject *weak_object); static void pendingproc_get_my_contact (TplActionChain *ctx); @@ -142,7 +147,7 @@ _tpl_channel_text_get_contact_cb (TpConnection *connection, break; default: g_object_get (G_OBJECT (tp_chan), "object-path", &chan_path, NULL); - g_error ("retrieving TpContacts: passing invalid value for selector: %d" + g_debug ("retrieving TpContacts: passing invalid value for selector: %d" "Aborting channel %s observation", priv->selector, chan_path); g_free (chan_path); tpl_observer_unregister_channel (observer, TPL_CHANNEL (tpl_text)); @@ -206,12 +211,11 @@ pendingproc_get_remote_handle_type (TplActionChain *ctx) case TP_HANDLE_TYPE_ROOM: tpl_actionchain_append (ctx, pendingproc_get_chatroom_id); break; - - /* follows unhandled TpHandleType */ case TP_HANDLE_TYPE_NONE: - g_warning ("remote handle: TP_HANDLE_TYPE_NONE: " - "un-handled. Check the TelepathyLogger.client file."); + g_debug ("HANDLE_TYPE_NONE received, probably an anonymous chat, like " + "MSN ones. TODO: implement this possibility"); break; + /* follows unhandled TpHandleType */ case TP_HANDLE_TYPE_LIST: g_warning ("remote handle: TP_HANDLE_TYPE_LIST: " "un-handled. Check the TelepathyLogger.client file."); @@ -221,13 +225,12 @@ pendingproc_get_remote_handle_type (TplActionChain *ctx) "un-handled. Check the TelepathyLogger.client file."); break; default: - g_error ("remote handle type unknown %d.", remote_handle_type); + g_debug ("remote handle type unknown %d.", remote_handle_type); break; } tpl_actionchain_continue (ctx); } - /* end of async Callbacks */ G_DEFINE_TYPE (TplChannelText, tpl_channel_text, TPL_TYPE_CHANNEL) @@ -251,6 +254,7 @@ tpl_channel_text_finalize (GObject *obj) TplChannelTextPriv *priv = GET_PRIV(obj); g_free (priv->chatroom_id); + priv->chatroom_id = NULL; G_OBJECT_CLASS (tpl_channel_text_parent_class)->finalize (obj); } @@ -276,6 +280,7 @@ tpl_channel_text_init (TplChannelText *self) { TplChannelTextPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TPL_TYPE_CHANNEL_TEXT, TplChannelTextPriv); + self->priv = priv; } @@ -288,16 +293,21 @@ tpl_channel_text_init (TplChannelText *self) * @error: location of the GError, used in case a problem is raised while * creating the channel * - * Convenience function to create a new TPL Channel Text proxy. The returned - * #TplChannelText is not guaranteed to be ready at the point of return. Use #TpChannel - * methods casting the #TplChannelText instance to a TpChannel + * Convenience function to create a new TPL Channel Text proxy. + * The returned #TplChannelText is not guaranteed to be ready at the point of + * return. * - * TplChannelText instances are subclasses or the abstract TplChannel which is + * TplChannelText is actually a subclass of the abstract TplChannel which is a * subclass of TpChannel. + * Use #TpChannel methods, casting the #TplChannelText instance to a + * TpChannel, to access TpChannel data/methods from it. + * + * TplChannelText is usually created using #tpl_channel_factory_build, from + * within a #TplObserver singleton, when its Observer_Channel method is called + * by the Channel Dispatcher. * * Returns: the TplChannelText instance or %NULL in @object_path is not valid */ - TplChannelText * tpl_channel_text_new (TpConnection *conn, const gchar *object_path, @@ -449,6 +459,7 @@ tpl_channel_text_call_when_ready (TplChannelText *self, tpl_actionchain_append (actions, pendingproc_prepare_tpl_channel); tpl_actionchain_append (actions, pendingproc_get_my_contact); tpl_actionchain_append (actions, pendingproc_get_remote_handle_type); + tpl_actionchain_append (actions, pendingproc_get_pending_messages); /* start the queue consuming */ tpl_actionchain_continue (actions); } @@ -478,6 +489,65 @@ got_tpl_chan_ready_cb (GObject *obj, static void +pendingproc_get_pending_messages (TplActionChain *ctx) +{ + TplChannelText *chan_text = tpl_actionchain_get_object (ctx); + + g_debug ("PENDING MESSAGE: START"); + tp_cli_channel_type_text_call_list_pending_messages (TP_CHANNEL (chan_text), + -1, FALSE, got_pending_messages_cb, ctx, NULL, NULL); + g_debug ("PENDING MESSAGE: PAST"); +} + +void +got_pending_messages_cb (TpChannel *proxy, + const GPtrArray *result, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + TplActionChain *ctx = user_data; + guint i; + + if (error != NULL) + { + g_debug ("retrieving pending messages: %s", error->message); + tpl_actionchain_continue (ctx); + return; + } + + for (i = 0; i < result->len; ++i) + { + GValueArray *message_struct; + const gchar *message_body; + guint message_id; + guint timestamp; + guint from_handle; + guint message_type; + guint message_flags; + + message_struct = g_ptr_array_index (result, i); + + message_id = g_value_get_uint (g_value_array_get_nth (message_struct, 0)); + timestamp = g_value_get_uint (g_value_array_get_nth (message_struct, 1)); + from_handle = g_value_get_uint (g_value_array_get_nth (message_struct, 2)); + message_type = g_value_get_uint (g_value_array_get_nth (message_struct, 3)); + message_flags = g_value_get_uint (g_value_array_get_nth (message_struct, 4)); + message_body = g_value_get_string (g_value_array_get_nth (message_struct, 5)); + + g_debug ("Pending message id %d found (timestamp %d)", message_id, + timestamp); + + /* call the received signal callback to trigger the storing */ + on_received_signal_cb (proxy, message_id, timestamp, from_handle, + message_type, message_flags, message_body, TPL_CHANNEL_TEXT (proxy), + NULL); + } + + tpl_actionchain_continue (ctx); +} + +static void pendingproc_get_chatroom_id (TplActionChain *ctx) { TplChannelText *tpl_text = tpl_actionchain_get_object (ctx); @@ -493,7 +563,7 @@ pendingproc_get_chatroom_id (TplActionChain *ctx) tpl_channel_text_set_chatroom (tpl_text, TRUE); tp_cli_connection_call_inspect_handles (connection, - -1, TP_HANDLE_TYPE_ROOM, handles, _tpl_channel_text_get_chatroom_cb, + -1, TP_HANDLE_TYPE_ROOM, handles, get_chatroom_id_cb, ctx, NULL, NULL); g_array_unref (handles); @@ -501,7 +571,7 @@ pendingproc_get_chatroom_id (TplActionChain *ctx) static void -_tpl_channel_text_get_chatroom_cb (TpConnection *proxy, +get_chatroom_id_cb (TpConnection *proxy, const gchar **out_Identifiers, const GError *error, gpointer user_data, @@ -513,7 +583,7 @@ _tpl_channel_text_get_chatroom_cb (TpConnection *proxy, g_return_if_fail (TPL_IS_CHANNEL_TEXT (tpl_text)); if (error != NULL) - g_error ("retrieving chatroom identifier: %s", error->message); + g_debug ("retrieving chatroom identifier: %s", error->message); g_debug ("Chatroom id: %s", *out_Identifiers); tpl_channel_text_set_chatroom_id (tpl_text, *out_Identifiers); @@ -532,52 +602,46 @@ pendingproc_connect_signals (TplActionChain *ctx) channel = TP_CHANNEL (TPL_CHANNEL (tpl_text)); tp_cli_channel_type_text_connect_to_received (channel, - _channel_on_received_signal_cb, tpl_text, NULL, NULL, &error); + on_received_signal_cb, tpl_text, NULL, NULL, &error); if (error != NULL) { - g_error ("received signal connect: %s", error->message); - g_clear_error (&error); + g_debug ("received signal connect: %s", error->message); g_error_free (error); error = NULL; } tp_cli_channel_type_text_connect_to_sent (channel, - _channel_on_sent_signal_cb, tpl_text, NULL, NULL, &error); + on_sent_signal_cb, tpl_text, NULL, NULL, &error); if (error != NULL) { - g_error ("sent signal connect: %s", error->message); - g_clear_error (&error); + g_debug ("sent signal connect: %s", error->message); g_error_free (error); error = NULL; } tp_cli_channel_type_text_connect_to_send_error (channel, - _channel_on_send_error_cb, tpl_text, NULL, NULL, &error); + on_send_error_cb, tpl_text, NULL, NULL, &error); if (error != NULL) { - g_error ("send error signal connect: %s", error->message); - g_clear_error (&error); + g_debug ("send error signal connect: %s", error->message); g_error_free (error); error = NULL; } tp_cli_channel_type_text_connect_to_lost_message (channel, - _channel_on_lost_message_cb, tpl_text, NULL, NULL, &error); + on_lost_message_cb, tpl_text, NULL, NULL, &error); if (error != NULL) { - g_error ("lost message signal connect: %s", error->message); - g_clear_error (&error); + g_debug ("lost message signal connect: %s", error->message); g_error_free (error); error = NULL; } - tp_cli_channel_connect_to_closed (channel, _channel_on_closed_cb, + tp_cli_channel_connect_to_closed (channel, on_closed_cb, tpl_text, NULL, NULL, &error); - if (error != NULL) { - g_error ("channel closed signal connect: %s", error->message); - g_clear_error (&error); + g_debug ("channel closed signal connect: %s", error->message); g_error_free (error); error = NULL; } @@ -591,7 +655,7 @@ pendingproc_connect_signals (TplActionChain *ctx) /* Signal's Callbacks */ static void -_channel_on_closed_cb (TpChannel *proxy, +on_closed_cb (TpChannel *proxy, gpointer user_data, GObject *weak_object) { @@ -614,7 +678,7 @@ _channel_on_closed_cb (TpChannel *proxy, static void -_channel_on_lost_message_cb (TpChannel *proxy, +on_lost_message_cb (TpChannel *proxy, gpointer user_data, GObject *weak_object) { @@ -622,8 +686,9 @@ _channel_on_lost_message_cb (TpChannel *proxy, /* TODO log that the system lost a message */ } + static void -_channel_on_send_error_cb (TpChannel *proxy, +on_send_error_cb (TpChannel *proxy, guint arg_Error, guint arg_Timestamp, guint arg_Type, @@ -631,14 +696,13 @@ _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", arg_Text); + g_debug ("unlogged event: TP was unable to send the message: %s", arg_Text); /* TODO log that the system was unable to send the message */ } static void -_channel_on_sent_signal_cb (TpChannel *proxy, +on_sent_signal_cb (TpChannel *proxy, guint arg_Timestamp, guint arg_Type, const gchar *arg_Text, @@ -666,7 +730,7 @@ _channel_on_sent_signal_cb (TpChannel *proxy, { remote = tpl_channel_text_get_remote_contact (tpl_text); if (remote == NULL) - g_error ("sending message: Remote TplContact=NULL on 1-1 Chat"); + g_debug ("sending message: Remote TplContact=NULL on 1-1 Chat"); tpl_contact_receiver = tpl_contact_from_tp_contact (remote); tpl_contact_set_contact_type (tpl_contact_receiver, TPL_CONTACT_USER); } @@ -702,8 +766,7 @@ _channel_on_sent_signal_cb (TpChannel *proxy, if (error != NULL) { - g_error ("LogStore: %s", error->message); - g_clear_error (&error); + g_debug ("LogStore: %s", error->message); g_error_free (error); } @@ -715,7 +778,7 @@ _channel_on_sent_signal_cb (TpChannel *proxy, } static void -_channel_on_received_signal_with_contact_cb (TpConnection *connection, +on_received_signal_with_contact_cb (TpConnection *connection, guint n_contacts, TpContact *const *contacts, guint n_failed, @@ -734,9 +797,9 @@ _channel_on_received_signal_with_contact_cb (TpConnection *connection, if (error != NULL) { - g_error ("Unrecoverable error retrieving remote contact " + g_debug ("Unrecoverable error retrieving remote contact " "information: %s", error->message); - g_error ("Not able to log the received message: %s", + g_debug ("Not able to log the received message: %s", tpl_log_entry_text_get_message (log)); g_object_unref (log); return; @@ -744,9 +807,9 @@ _channel_on_received_signal_with_contact_cb (TpConnection *connection, if (n_failed > 0) { - g_error ("%d invalid handle(s) passed to " + g_debug ("%d invalid handle(s) passed to " "tp_connection_get_contacts_by_handle()", n_failed); - g_error ("Not able to log the received message: %s", + g_debug ("Not able to log the received message: %s", tpl_log_entry_text_get_message (log)); g_object_unref (log); return; @@ -797,8 +860,7 @@ keepon (TplLogEntryText *log) tpl_log_manager_add_message (logmanager, TPL_LOG_ENTRY (log), &e); if (e != NULL) { - g_error ("LogStore: %s", e->message); - g_clear_error (&e); + g_debug ("LogStore: %s", e->message); g_error_free (e); } @@ -808,7 +870,7 @@ keepon (TplLogEntryText *log) } static void -_channel_on_received_signal_cb (TpChannel *proxy, +on_received_signal_cb (TpChannel *proxy, guint arg_ID, guint arg_Timestamp, guint arg_Sender, @@ -856,9 +918,8 @@ _channel_on_received_signal_cb (TpChannel *proxy, /* it's a chatroom and no contact has been pre-cached */ if (tpl_channel_text_get_remote_contact (tpl_text) == NULL) tp_connection_get_contacts_by_handle (tp_conn, 1, &remote_handle, - TP_CONTACT_FEATURES_LEN, features, - _channel_on_received_signal_with_contact_cb, log, g_object_unref, - NULL); + TP_CONTACT_FEATURES_LEN, features, on_received_signal_with_contact_cb, + log, g_object_unref, NULL); else keepon (log); diff --git a/telepathy-logger/contact.c b/telepathy-logger/contact.c index a502c6d..055fb93 100644 --- a/telepathy-logger/contact.c +++ b/telepathy-logger/contact.c @@ -31,25 +31,28 @@ G_DEFINE_TYPE (TplContact, tpl_contact, G_TYPE_OBJECT) struct _TplContactPriv { TpContact *contact; + TpAccount *account; + TplContactType contact_type; gchar *alias; gchar *identifier; gchar *presence_status; gchar *presence_message; gchar *avatar_token; - - TpAccount *account; }; enum { PROP0, PROP_IDENTIFIER, - PROP_ALIAS + PROP_ALIAS, + PROP_PRESENCE_STATUS, + PROP_PRESENCE_MESSAGE, + PROP_AVATAR_TOKEN }; static void -tpl_contact_finalize (GObject * obj) +tpl_contact_finalize (GObject *obj) { TplContact *self = TPL_CONTACT (obj); TplContactPriv *priv = GET_PRIV (self); @@ -66,8 +69,9 @@ tpl_contact_finalize (GObject * obj) G_OBJECT_CLASS (tpl_contact_parent_class)->finalize (obj); } + static void -tpl_contact_dispose (GObject * obj) +tpl_contact_dispose (GObject *obj) { TplContact *self = TPL_CONTACT (obj); TplContactPriv *priv = GET_PRIV (self); @@ -78,6 +82,7 @@ tpl_contact_dispose (GObject * obj) G_OBJECT_CLASS (tpl_contact_parent_class)->dispose (obj); } + static void tpl_contact_get_prop (GObject *object, guint param_id, GValue *value, GParamSpec *pspec) @@ -92,6 +97,15 @@ tpl_contact_get_prop (GObject *object, guint param_id, GValue *value, case PROP_ALIAS: g_value_set_string (value, priv->alias); break; + case PROP_PRESENCE_STATUS: + g_value_set_string (value, priv->presence_status); + break; + case PROP_PRESENCE_MESSAGE: + g_value_set_string (value, priv->presence_message); + break; + case PROP_AVATAR_TOKEN: + g_value_set_string (value, priv->avatar_token); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -112,6 +126,16 @@ tpl_contact_set_prop (GObject *object, guint param_id, const GValue *value, case PROP_ALIAS: tpl_contact_set_alias (self, g_value_get_string (value)); break; + case PROP_PRESENCE_STATUS: + tpl_contact_set_presence_status (self, g_value_get_string (value)); + break; + case PROP_PRESENCE_MESSAGE: + tpl_contact_set_presence_message (self, g_value_get_string (value)); + break; + case PROP_AVATAR_TOKEN: + tpl_contact_set_avatar_token (self, g_value_get_string (value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -120,7 +144,7 @@ tpl_contact_set_prop (GObject *object, guint param_id, const GValue *value, } -static void tpl_contact_class_init (TplContactClass * klass) +static void tpl_contact_class_init (TplContactClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GParamSpec *param_spec; @@ -144,21 +168,43 @@ static void tpl_contact_class_init (TplContactClass * klass) G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS); g_object_class_install_property (object_class, PROP_ALIAS, param_spec); + param_spec = g_param_spec_string ("presence-status", + "PresenceStatus", + "The contact's presence status string", + NULL, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (object_class, PROP_ALIAS, param_spec); + + param_spec = g_param_spec_string ("presence-message", + "PresenceMessage", + "The contact's presence message", + NULL, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (object_class, PROP_ALIAS, param_spec); + + param_spec = g_param_spec_string ("avatar-token", + "AvatarToken", + "The contact's avatar's token", + NULL, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (object_class, PROP_ALIAS, param_spec); + g_type_class_add_private (object_class, sizeof (TplContactPriv)); } + static void -tpl_contact_init (TplContact * self) +tpl_contact_init (TplContact *self) { TplContactPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TPL_TYPE_CONTACT, TplContactPriv); - self->priv = priv; + self->priv = priv; } TplContact * -tpl_contact_from_tp_contact (TpContact * contact) +tpl_contact_from_tp_contact (TpContact *contact) { TplContact *ret; @@ -167,26 +213,29 @@ tpl_contact_from_tp_contact (TpContact * contact) ret = tpl_contact_new (tp_contact_get_identifier (contact)); tpl_contact_set_contact (ret, contact); tpl_contact_set_alias (ret, (gchar *) tp_contact_get_alias (contact)); - tpl_contact_set_presence_status (ret, - tp_contact_get_presence_status (contact)); - tpl_contact_set_presence_message (ret, - tp_contact_get_presence_message (contact)); + if (tp_contact_get_presence_status (contact)) + tpl_contact_set_presence_status (ret, + tp_contact_get_presence_status (contact)); + if (tp_contact_get_presence_message (contact) != NULL) + tpl_contact_set_presence_message (ret, + tp_contact_get_presence_message (contact)); return ret; } + TplContact * tpl_contact_new (const gchar *identifier) { g_return_val_if_fail (!TPL_STR_EMPTY (identifier), NULL); return g_object_new (TPL_TYPE_CONTACT, - "identifier", identifier, - NULL); + "identifier", identifier, NULL); } + TpContact * -tpl_contact_get_contact (TplContact * self) +tpl_contact_get_contact (TplContact *self) { TplContactPriv *priv = GET_PRIV (self); @@ -195,8 +244,9 @@ tpl_contact_get_contact (TplContact * self) return priv->contact; } + const gchar * -tpl_contact_get_alias (TplContact * self) +tpl_contact_get_alias (TplContact *self) { TplContactPriv *priv = GET_PRIV (self); @@ -205,8 +255,9 @@ tpl_contact_get_alias (TplContact * self) return priv->alias; } + const gchar * -tpl_contact_get_identifier (TplContact * self) +tpl_contact_get_identifier (TplContact *self) { TplContactPriv *priv = GET_PRIV (self); @@ -215,8 +266,9 @@ tpl_contact_get_identifier (TplContact * self) return priv->identifier; } + const gchar * -tpl_contact_get_presence_status (TplContact * self) +tpl_contact_get_presence_status (TplContact *self) { TplContactPriv *priv = GET_PRIV (self); @@ -225,8 +277,9 @@ tpl_contact_get_presence_status (TplContact * self) return priv->presence_status; } + const gchar * -tpl_contact_get_presence_message (TplContact * self) +tpl_contact_get_presence_message (TplContact *self) { TplContactPriv *priv = GET_PRIV (self); @@ -235,8 +288,9 @@ tpl_contact_get_presence_message (TplContact * self) return priv->presence_message; } + TplContactType -tpl_contact_get_contact_type (TplContact * self) +tpl_contact_get_contact_type (TplContact *self) { TplContactPriv *priv = GET_PRIV (self); @@ -245,8 +299,9 @@ tpl_contact_get_contact_type (TplContact * self) return priv->contact_type; } + const gchar * -tpl_contact_get_avatar_token (TplContact * self) +tpl_contact_get_avatar_token (TplContact *self) { TplContactPriv *priv = GET_PRIV (self); @@ -255,8 +310,9 @@ tpl_contact_get_avatar_token (TplContact * self) return priv->avatar_token; } + TpAccount * -tpl_contact_get_account (TplContact * self) +tpl_contact_get_account (TplContact *self) { TplContactPriv *priv = GET_PRIV (self); @@ -267,78 +323,94 @@ tpl_contact_get_account (TplContact * self) void -tpl_contact_set_contact (TplContact * self, TpContact * data) +tpl_contact_set_contact (TplContact *self, + TpContact *data) { TplContactPriv *priv = GET_PRIV (self); g_return_if_fail (TPL_IS_CONTACT (self)); - g_return_if_fail (TP_IS_CONTACT (data) || data == NULL); + g_return_if_fail (TP_IS_CONTACT (data)); + g_return_if_fail (priv->contact == NULL); - tpl_object_unref_if_not_null (priv->contact); priv->contact = data; - tpl_object_ref_if_not_null (data); + g_object_ref (data); } + void -tpl_contact_set_account (TplContact * self, TpAccount * data) +tpl_contact_set_account (TplContact *self, + TpAccount *data) { TplContactPriv *priv = GET_PRIV (self); g_return_if_fail (TPL_IS_CONTACT (self)); - g_return_if_fail (TP_IS_ACCOUNT (data) || data == NULL); + g_return_if_fail (TP_IS_ACCOUNT (data)); + g_return_if_fail (priv->account == NULL); - tpl_object_unref_if_not_null (priv->account); priv->account = data; - tpl_object_ref_if_not_null (data); + g_object_ref (data); } + void -tpl_contact_set_alias (TplContact * self, const gchar * data) +tpl_contact_set_alias (TplContact *self, + const gchar *data) { TplContactPriv *priv = GET_PRIV (self); g_return_if_fail (TPL_IS_CONTACT (self)); + g_return_if_fail (!TPL_STR_EMPTY (data)); + g_return_if_fail (priv->alias == NULL); - g_free (priv->alias); priv->alias = g_strdup (data); } + void -tpl_contact_set_identifier (TplContact * self, const gchar * data) +tpl_contact_set_identifier (TplContact *self, + const gchar *data) { TplContactPriv *priv = GET_PRIV (self); g_return_if_fail (TPL_IS_CONTACT (self)); + g_return_if_fail (!TPL_STR_EMPTY (data)); + g_return_if_fail (priv->identifier == NULL); - g_free (priv->identifier); priv->identifier = g_strdup (data); } + void -tpl_contact_set_presence_status (TplContact * self, const gchar * data) +tpl_contact_set_presence_status (TplContact *self, + const gchar *data) { TplContactPriv *priv = GET_PRIV (self); g_return_if_fail (TPL_IS_CONTACT (self)); + g_return_if_fail (priv->presence_status == NULL); + /* data can be NULL, if no presence_status is set */ - g_free (priv->presence_status); priv->presence_status = g_strdup (data); } + void -tpl_contact_set_presence_message (TplContact * self, const gchar * data) +tpl_contact_set_presence_message (TplContact *self, + const gchar *data) { TplContactPriv *priv = GET_PRIV (self); g_return_if_fail (TPL_IS_CONTACT (self)); + g_return_if_fail (priv->presence_message == NULL); + /* data can be NULL, if no presence_message is set */ - g_free (priv->presence_message); priv->presence_message = g_strdup (data); } void -tpl_contact_set_contact_type (TplContact * self, TplContactType data) +tpl_contact_set_contact_type (TplContact *self, + TplContactType data) { TplContactPriv *priv = GET_PRIV (self); @@ -347,13 +419,16 @@ tpl_contact_set_contact_type (TplContact * self, TplContactType data) priv->contact_type = data; } + void -tpl_contact_set_avatar_token (TplContact * self, const gchar *data) +tpl_contact_set_avatar_token (TplContact *self, + const gchar *data) { TplContactPriv *priv = GET_PRIV (self); g_return_if_fail (TPL_IS_CONTACT (self)); + g_return_if_fail (!TPL_STR_EMPTY (data)); + g_return_if_fail (priv->avatar_token == NULL); - g_free (priv->avatar_token); priv->avatar_token = g_strdup (data); } diff --git a/telepathy-logger/log-manager.c b/telepathy-logger/log-manager.c index 6c2087c..59ce15d 100644 --- a/telepathy-logger/log-manager.c +++ b/telepathy-logger/log-manager.c @@ -176,12 +176,18 @@ tpl_log_manager_dup_singleton (void) return g_object_new (TPL_TYPE_LOG_MANAGER, NULL); } + /** * tpl_log_manager_add_message * @manager: the log manager * @message: a TplLogEntry subclass's instance * - * Returns: %TRUE if the message has been added successfully, %FALSE else. + * It stores @message, sending it to all the registered TplLogStore which have + * the "writable" property set to %TRUE. + * Every TplLogManager is guaranteed to have at least TplLogStore a readable + * and a writable LogStore regitered. + * + * Returns: %TRUE if the message has been successfully added, %FALSE otherwise. */ gboolean tpl_log_manager_add_message (TplLogManager *manager, @@ -209,11 +215,11 @@ tpl_log_manager_add_message (TplLogManager *manager, * store */ for (l = priv->stores; l; l = g_list_next (l)) { - if (!tp_strdiff - (tpl_log_store_get_name (TPL_LOG_STORE (l->data)), add_store)) + if (!tp_strdiff (tpl_log_store_get_name (TPL_LOG_STORE (l->data)), + add_store)) { - out = tpl_log_store_add_message (TPL_LOG_STORE (l->data), - message, error); + out = tpl_log_store_add_message (TPL_LOG_STORE (l->data), message, + error); found = TRUE; break; } @@ -226,6 +232,21 @@ tpl_log_manager_add_message (TplLogManager *manager, } +/** + * tpl_log_manager_register_logstore + * @manager: the log manager + * @logstore: a TplLogStore interface implementation + * + * It registers @logstore into @manager, the log store has to be an + * implementation of the TplLogStore interface. + * + * @logstore has to properly implement the add_message method if the + * "writable" propertly is set to %TRUE. + * + * @logstore has to properly implement all the search/query methods if the + * "readable" propertly is set to %TRUE. + */ + void tpl_log_manager_register_logstore (TplLogManager *self, TplLogStore *logstore) diff --git a/telepathy-logger/observer.c b/telepathy-logger/observer.c index 05d46d7..4ed145d 100644 --- a/telepathy-logger/observer.c +++ b/telepathy-logger/observer.c @@ -211,15 +211,17 @@ tpl_observer_observe_channels (TpSvcClientObserver *self, { GValueArray *channel = g_ptr_array_index (channels, i); TplChannel *tpl_chan; + GHashTable *prop_map; + gchar *path; - gchar *path = g_value_get_boxed (g_value_array_get_nth (channel, 0)); + path = g_value_get_boxed (g_value_array_get_nth (channel, 0)); /* d.bus.propertyName.str/gvalue hash */ - GHashTable *map = g_value_get_boxed (g_value_array_get_nth (channel, - 1)); + prop_map = g_value_get_boxed (g_value_array_get_nth (channel, 1)); - chan_type = g_value_get_string (g_hash_table_lookup (map, + chan_type = g_value_get_string (g_hash_table_lookup (prop_map, TP_PROP_CHANNEL_CHANNEL_TYPE)); - tpl_chan = chan_factory (chan_type, tp_conn, path, map, tp_acc, &error); + tpl_chan = chan_factory (chan_type, tp_conn, path, prop_map, tp_acc, + &error); if (tpl_chan == NULL) { g_debug ("Creating TplChannel: %s", error->message); diff --git a/telepathy-logger/util.c b/telepathy-logger/util.c index 3ff9f4f..8290b52 100644 --- a/telepathy-logger/util.c +++ b/telepathy-logger/util.c @@ -93,7 +93,6 @@ tpl_actionchain_continue (TplActionChain *self) { if (g_queue_is_empty (self->chain)) { - g_debug ("QUEUE EMPTY"); g_simple_async_result_complete (self->simple); } else |