diff options
author | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2012-07-04 12:27:43 +0200 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2012-07-04 17:25:15 +0200 |
commit | 2c616a30adc38d7d0768f476ed973dc8070c2e80 (patch) | |
tree | ee28ef013bada637bd166de2282d79a07e08aa22 | |
parent | 22322c1922e2e13c193eafd55e52311e676c2caa (diff) | |
download | telepathy-logger-2c616a30adc38d7d0768f476ed973dc8070c2e80.tar.gz |
TplTextChannel, TplCallChannel: Use TpProxyFeature
-rw-r--r-- | telepathy-logger/call-channel-internal.h | 4 | ||||
-rw-r--r-- | telepathy-logger/call-channel.c | 67 | ||||
-rw-r--r-- | telepathy-logger/text-channel-internal.h | 4 | ||||
-rw-r--r-- | telepathy-logger/text-channel.c | 81 |
4 files changed, 131 insertions, 25 deletions
diff --git a/telepathy-logger/call-channel-internal.h b/telepathy-logger/call-channel-internal.h index e86ce05..439b3af 100644 --- a/telepathy-logger/call-channel-internal.h +++ b/telepathy-logger/call-channel-internal.h @@ -44,6 +44,10 @@ typedef enum TPL_CALL_CHANNEL_ERROR_MISSING_TARGET_CONTACT, } TplCallChannelError; +#define TPL_CALL_CHANNEL_FEATURE_CORE \ + _tpl_call_channel_get_feature_quark_core () +GQuark _tpl_call_channel_get_feature_quark_core (void) G_GNUC_CONST; + typedef struct _TplCallChannelPriv TplCallChannelPriv; typedef struct { diff --git a/telepathy-logger/call-channel.c b/telepathy-logger/call-channel.c index ba27b87..2b09bbb 100644 --- a/telepathy-logger/call-channel.c +++ b/telepathy-logger/call-channel.c @@ -310,7 +310,6 @@ proxy_prepared_cb (GObject *source, GAsyncResult *result, gpointer user_data) { - TplCallChannel *self = (TplCallChannel *) source; GSimpleAsyncResult *my_result = user_data; GError *error = NULL; @@ -318,10 +317,6 @@ proxy_prepared_cb (GObject *source, { g_simple_async_result_take_error (my_result, error); } - else if (!get_contacts (self, &error)) - { - g_simple_async_result_take_error (my_result, error); - } g_simple_async_result_complete (my_result); g_object_unref (my_result); @@ -335,13 +330,15 @@ tpl_call_channel_prepare_async (TplChannel *chan, { TplCallChannel *self = (TplCallChannel *) chan; GSimpleAsyncResult *result; + GQuark chan_features[] = { + TPL_CALL_CHANNEL_FEATURE_CORE, + 0 + }; result = g_simple_async_result_new ((GObject *) self, cb, user_data, tpl_call_channel_prepare_async); - connect_signals (self); - - tp_proxy_prepare_async (self, NULL, proxy_prepared_cb, result); + tp_proxy_prepare_async (self, chan_features, proxy_prepared_cb, result); } @@ -364,6 +361,57 @@ tpl_call_channel_prepare_finish (TplChannel *chan, static void +_tpl_call_channel_prepare_core_async (TpProxy *proxy, + const TpProxyFeature *feature, + GAsyncReadyCallback callback, + gpointer user_data) +{ + TplCallChannel *self = (TplCallChannel *) proxy; + GError *error = NULL; + + connect_signals (self); + + if (!get_contacts (self, &error)) + { + g_simple_async_report_take_gerror_in_idle ((GObject *) self, callback, + user_data, error); + return; + } + + tp_simple_async_report_success_in_idle ((GObject *) self, callback, user_data, + _tpl_call_channel_prepare_core_async); +} + +GQuark +_tpl_call_channel_get_feature_quark_core (void) +{ + return g_quark_from_static_string ("tpl-call-channel-feature-core"); +} + +enum { + FEAT_CORE, + N_FEAT +}; + +static const TpProxyFeature * +tpl_call_channel_list_features (TpProxyClass *cls G_GNUC_UNUSED) +{ + static TpProxyFeature features[N_FEAT + 1] = { { 0 } }; + + if (G_LIKELY (features[0].name != 0)) + return features; + + features[FEAT_CORE].name = TPL_CALL_CHANNEL_FEATURE_CORE; + features[FEAT_CORE].prepare_async = _tpl_call_channel_prepare_core_async; + + /* assert that the terminator at the end is there */ + g_assert (features[N_FEAT].name == 0); + + return features; +} + + +static void tpl_call_channel_dispose (GObject *obj) { TplCallChannelPriv *priv = TPL_CALL_CHANNEL (obj)->priv; @@ -394,10 +442,13 @@ static void _tpl_call_channel_class_init (TplCallChannelClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + TpProxyClass *proxy_class = (TpProxyClass *) klass; object_class->dispose = tpl_call_channel_dispose; object_class->finalize = tpl_call_channel_finalize; + proxy_class->list_features = tpl_call_channel_list_features; + g_type_class_add_private (object_class, sizeof (TplCallChannelPriv)); dbus_g_object_register_marshaller (tpl_marshal_VOID__UINT_UINT_BOXED_BOXED, diff --git a/telepathy-logger/text-channel-internal.h b/telepathy-logger/text-channel-internal.h index d74c9bf..6107b59 100644 --- a/telepathy-logger/text-channel-internal.h +++ b/telepathy-logger/text-channel-internal.h @@ -50,6 +50,10 @@ typedef enum TPL_TEXT_CHANNEL_ERROR_NEED_MESSAGE_INTERFACE, } TplTextChannelError; +#define TPL_TEXT_CHANNEL_FEATURE_CORE \ + _tpl_text_channel_get_feature_quark_core () +GQuark _tpl_text_channel_get_feature_quark_core (void) G_GNUC_CONST; + typedef struct _TplTextChannelPriv TplTextChannelPriv; typedef struct { diff --git a/telepathy-logger/text-channel.c b/telepathy-logger/text-channel.c index 2e83a9e..d2560fb 100644 --- a/telepathy-logger/text-channel.c +++ b/telepathy-logger/text-channel.c @@ -565,7 +565,6 @@ channel_prepared_cb (GObject *source, GAsyncResult *result, gpointer user_data) { - TplTextChannel *self = (TplTextChannel *) source; GSimpleAsyncResult *my_result = user_data; GError *error = NULL; @@ -573,18 +572,6 @@ channel_prepared_cb (GObject *source, { g_simple_async_result_take_error (my_result, error); } - else if (!tp_proxy_has_interface_by_id (self, - TP_IFACE_QUARK_CHANNEL_INTERFACE_MESSAGES)) - { - g_simple_async_result_set_error (my_result, TPL_TEXT_CHANNEL_ERROR, - TPL_TEXT_CHANNEL_ERROR_NEED_MESSAGE_INTERFACE, - "The text channel does not implement Message interface."); - } - - get_my_contact (self); - get_remote_contact (self); - store_pending_messages (self); - connect_message_signals (self); g_simple_async_result_complete (my_result); g_object_unref (my_result); @@ -599,10 +586,7 @@ tpl_text_channel_prepare_async (TplChannel *chan, TplTextChannel *self = (TplTextChannel *) chan; GSimpleAsyncResult *result; GQuark chan_features[] = { - TP_CHANNEL_FEATURE_CORE, - TP_CHANNEL_FEATURE_GROUP, - TP_CHANNEL_FEATURE_CONTACTS, - TP_TEXT_CHANNEL_FEATURE_INCOMING_MESSAGES, + TPL_TEXT_CHANNEL_FEATURE_CORE, 0 }; @@ -632,6 +616,66 @@ tpl_text_channel_prepare_finish (TplChannel *chan, static void +_tpl_text_channel_prepare_core_async (TpProxy *proxy, + const TpProxyFeature *feature, + GAsyncReadyCallback callback, + gpointer user_data) +{ + TplTextChannel *self = (TplTextChannel *) proxy; + + if (!tp_proxy_has_interface_by_id (self, + TP_IFACE_QUARK_CHANNEL_INTERFACE_MESSAGES)) + { + g_simple_async_report_error_in_idle ((GObject *) self, + callback, user_data, TPL_TEXT_CHANNEL_ERROR, + TPL_TEXT_CHANNEL_ERROR_NEED_MESSAGE_INTERFACE, + "The text channel does not implement Message interface."); + return; + } + + get_my_contact (self); + get_remote_contact (self); + store_pending_messages (self); + connect_message_signals (self); + + tp_simple_async_report_success_in_idle ((GObject *) self, callback, user_data, + _tpl_text_channel_prepare_core_async); +} + + +GQuark +_tpl_text_channel_get_feature_quark_core (void) +{ + return g_quark_from_static_string ("tpl-text-channel-feature-core"); +} + +enum { + FEAT_CORE, + N_FEAT +}; + +static const TpProxyFeature * +tpl_text_channel_list_features (TpProxyClass *cls G_GNUC_UNUSED) +{ + static TpProxyFeature features[N_FEAT + 1] = { { 0 } }; + static GQuark depends_on[3] = { 0, 0, 0 }; + + if (G_LIKELY (features[0].name != 0)) + return features; + + features[FEAT_CORE].name = TPL_TEXT_CHANNEL_FEATURE_CORE; + features[FEAT_CORE].prepare_async = _tpl_text_channel_prepare_core_async; + depends_on[0] = TP_TEXT_CHANNEL_FEATURE_INCOMING_MESSAGES; + depends_on[1] = TP_CHANNEL_FEATURE_CONTACTS; + features[FEAT_CORE].depends_on = depends_on; + + /* assert that the terminator at the end is there */ + g_assert (features[N_FEAT].name == 0); + + return features; +} + +static void tpl_text_channel_dispose (GObject *obj) { TplTextChannelPriv *priv = TPL_TEXT_CHANNEL (obj)->priv; @@ -656,10 +700,13 @@ static void _tpl_text_channel_class_init (TplTextChannelClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + TpProxyClass *proxy_class = (TpProxyClass *) klass; object_class->dispose = tpl_text_channel_dispose; object_class->finalize = tpl_text_channel_finalize; + proxy_class->list_features = tpl_text_channel_list_features; + g_type_class_add_private (object_class, sizeof (TplTextChannelPriv)); } |