diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2010-12-21 16:24:26 +0000 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-03-04 14:28:50 +0100 |
commit | 48414d9a120a2e6b9e67c8557e81a07c6bfd1d70 (patch) | |
tree | 7abf0d26f8d0f9954eb1cabb741ac65759918f6d | |
parent | a34bd41f835987a392c0ece97499c32cb1f9fd0a (diff) |
base-client: add set_observer_delay_approvers function
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r-- | docs/reference/telepathy-glib-sections.txt | 1 | ||||
-rw-r--r-- | telepathy-glib/base-client.c | 50 | ||||
-rw-r--r-- | telepathy-glib/base-client.h | 2 | ||||
-rw-r--r-- | tests/dbus/base-client.c | 9 | ||||
-rw-r--r-- | tests/dbus/simple-observer.c | 7 |
5 files changed, 66 insertions, 3 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index 99c44917d..0fe187be2 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -4706,6 +4706,7 @@ TpBaseClientClass tp_base_client_add_observer_filter tp_base_client_take_observer_filter tp_base_client_set_observer_recover +tp_base_client_set_observer_delay_approvers TpBaseClientClassObserveChannelsImpl tp_base_client_implement_observe_channels tp_base_client_add_approver_filter diff --git a/telepathy-glib/base-client.c b/telepathy-glib/base-client.c index 4a1300233..2c40e33b4 100644 --- a/telepathy-glib/base-client.c +++ b/telepathy-glib/base-client.c @@ -225,6 +225,7 @@ typedef enum { CLIENT_HANDLER_WANTS_REQUESTS = 1 << 3, CLIENT_HANDLER_BYPASSES_APPROVAL = 1 << 4, CLIENT_OBSERVER_RECOVER = 1 << 5, + CLIENT_OBSERVER_DELAYS_APPROVERS = 1 << 6, } ClientFlags; struct _TpBaseClientPrivate @@ -422,6 +423,47 @@ tp_base_client_set_observer_recover (TpBaseClient *self, } /** + * tp_base_client_set_observer_delay_approvers: + * @self: a #TpBaseClient + * @delay: the value of the Observer.DelayApprovers property + * + * Set whether the channel dispatcher should wait for + * tp_observe_channels_context_accept() or tp_observe_channels_context_fail() + * to be called before calling + * #TpBaseClientClass.add_dispatch_operation on appropriate Approvers. + * + * This is implemented by setting the value of the DelayApprovers + * D-Bus property. + * + * This method may only be called before tp_base_client_register() is + * called, and may only be called on objects whose class implements + * #TpBaseClientClass.observe_channels. + * + * Since: 0.13.UNRELEASED + */ +void +tp_base_client_set_observer_delay_approvers (TpBaseClient *self, + gboolean delay) +{ + TpBaseClientClass *cls = TP_BASE_CLIENT_GET_CLASS (self); + + g_return_if_fail (TP_IS_BASE_CLIENT (self)); + g_return_if_fail (!self->priv->registered); + g_return_if_fail (cls->observe_channels != NULL); + + if (delay) + { + self->priv->flags |= (CLIENT_IS_OBSERVER | + CLIENT_OBSERVER_DELAYS_APPROVERS); + } + else + { + self->priv->flags |= CLIENT_IS_OBSERVER; + self->priv->flags &= ~CLIENT_OBSERVER_DELAYS_APPROVERS; + } +} + +/** * tp_base_client_add_approver_filter: * @self: a #TpBaseClient * @filter: (transfer none) (element-type utf8 GObject.Value): @@ -1118,6 +1160,7 @@ typedef enum { DP_HANDLED_CHANNELS, DP_OBSERVER_CHANNEL_FILTER, DP_OBSERVER_RECOVER, + DP_OBSERVER_DELAY_APPROVERS, } ClientDBusProp; static void @@ -1196,6 +1239,11 @@ tp_base_client_get_dbus_properties (GObject *object, (self->priv->flags & CLIENT_OBSERVER_RECOVER) != 0); break; + case DP_OBSERVER_DELAY_APPROVERS: + g_value_set_boolean (value, + (self->priv->flags & CLIENT_OBSERVER_DELAYS_APPROVERS) != 0); + break; + default: g_assert_not_reached (); } @@ -1230,6 +1278,8 @@ tp_base_client_class_init (TpBaseClientClass *cls) GINT_TO_POINTER (DP_OBSERVER_CHANNEL_FILTER) }, { "Recover", GINT_TO_POINTER (DP_OBSERVER_RECOVER) }, + { "DelayApprovers", + GINT_TO_POINTER (DP_OBSERVER_DELAY_APPROVERS) }, { NULL } }; static TpDBusPropertiesMixinIfaceImpl prop_ifaces[] = { diff --git a/telepathy-glib/base-client.h b/telepathy-glib/base-client.h index feaf4bd98..40efce187 100644 --- a/telepathy-glib/base-client.h +++ b/telepathy-glib/base-client.h @@ -110,6 +110,8 @@ void tp_base_client_take_observer_filter (TpBaseClient *self, void tp_base_client_set_observer_recover (TpBaseClient *self, gboolean recover); +void tp_base_client_set_observer_delay_approvers (TpBaseClient *self, + gboolean delay); void tp_base_client_add_approver_filter (TpBaseClient *self, GHashTable *filter); diff --git a/tests/dbus/base-client.c b/tests/dbus/base-client.c index a1c1d06f5..d426bdbf4 100644 --- a/tests/dbus/base-client.c +++ b/tests/dbus/base-client.c @@ -396,7 +396,7 @@ get_observer_prop_cb (TpProxy *proxy, { Test *test = user_data; GPtrArray *filters; - gboolean recover; + gboolean recover, delay; gboolean valid; if (error != NULL) @@ -405,7 +405,7 @@ get_observer_prop_cb (TpProxy *proxy, goto out; } - g_assert_cmpint (g_hash_table_size (properties), == , 2); + g_assert_cmpint (g_hash_table_size (properties), == , 3); filters = tp_asv_get_boxed (properties, "ObserverChannelFilter", TP_ARRAY_TYPE_CHANNEL_CLASS_LIST); @@ -415,6 +415,10 @@ get_observer_prop_cb (TpProxy *proxy, g_assert (valid); g_assert (recover); + delay = tp_asv_get_boolean (properties, "DelayApprovers", &valid); + g_assert (valid); + g_assert (delay); + out: g_main_loop_quit (test->mainloop); } @@ -490,6 +494,7 @@ test_observer (Test *test, NULL)); tp_base_client_set_observer_recover (test->base_client, TRUE); + tp_base_client_set_observer_delay_approvers (test->base_client, TRUE); tp_base_client_register (test->base_client, &test->error); g_assert_no_error (test->error); diff --git a/tests/dbus/simple-observer.c b/tests/dbus/simple-observer.c index 5ba139c87..eac24e4f4 100644 --- a/tests/dbus/simple-observer.c +++ b/tests/dbus/simple-observer.c @@ -220,6 +220,7 @@ get_observer_prop_cb (TpProxy *proxy, GPtrArray *filters; gboolean recover; gboolean valid; + gboolean delay; if (error != NULL) { @@ -227,7 +228,7 @@ get_observer_prop_cb (TpProxy *proxy, goto out; } - g_assert_cmpint (g_hash_table_size (properties), == , 2); + g_assert_cmpint (g_hash_table_size (properties), == , 3); filters = tp_asv_get_boxed (properties, "ObserverChannelFilter", TP_ARRAY_TYPE_CHANNEL_CLASS_LIST); @@ -237,6 +238,10 @@ get_observer_prop_cb (TpProxy *proxy, g_assert (valid); g_assert (recover); + delay = tp_asv_get_boolean (properties, "DelayApprovers", &valid); + g_assert (valid); + g_assert (!delay); + out: g_main_loop_quit (test->mainloop); } |