[telepathy-mission-control/master] McdClientProxy: store capability tokens here instead of in McdClient
Simon McVittie
simon.mcvittie at collabora.co.uk
Tue Sep 22 05:28:02 PDT 2009
---
src/mcd-client-priv.h | 5 +++++
src/mcd-client.c | 30 ++++++++++++++++++++++++++++++
src/mcd-dispatcher.c | 24 ++++++++----------------
3 files changed, 43 insertions(+), 16 deletions(-)
diff --git a/src/mcd-client-priv.h b/src/mcd-client-priv.h
index f712f56..687f5a4 100644
--- a/src/mcd-client-priv.h
+++ b/src/mcd-client-priv.h
@@ -109,6 +109,11 @@ G_GNUC_INTERNAL void _mcd_client_proxy_take_handler_filters
G_GNUC_INTERNAL void _mcd_client_proxy_set_bypass_approval
(McdClientProxy *self, gboolean bypass);
+G_GNUC_INTERNAL void _mcd_client_proxy_clear_capability_tokens
+ (McdClientProxy *self);
+G_GNUC_INTERNAL TpHandleSet *_mcd_client_proxy_peek_capability_tokens
+ (McdClientProxy *self);
+
#define MC_CLIENT_BUS_NAME_BASE_LEN (sizeof (TP_CLIENT_BUS_NAME_BASE) - 1)
G_END_DECLS
diff --git a/src/mcd-client.c b/src/mcd-client.c
index f968ab0..8c03075 100644
--- a/src/mcd-client.c
+++ b/src/mcd-client.c
@@ -54,6 +54,10 @@ static guint signals[N_SIGNALS] = { 0 };
struct _McdClientProxyPrivate
{
TpHandleRepoIface *string_pool;
+ /* Handler.Capabilities, represented as handles taken from
+ * dispatcher->priv->string_pool */
+ TpHandleSet *capability_tokens;
+
gchar *unique_name;
gboolean ready;
gboolean bypass_approval;
@@ -226,6 +230,12 @@ mcd_client_proxy_dispose (GObject *object)
if (self->priv->string_pool != NULL)
{
+ if (self->priv->capability_tokens != NULL)
+ {
+ tp_handle_set_destroy (self->priv->capability_tokens);
+ self->priv->capability_tokens = NULL;
+ }
+
g_object_unref (self->priv->string_pool);
self->priv->string_pool = NULL;
}
@@ -267,6 +277,9 @@ mcd_client_proxy_constructed (GObject *object)
chain_up (object);
}
+ self->priv->capability_tokens = tp_handle_set_new (
+ self->priv->string_pool);
+
if (self->priv->unique_name == NULL)
{
tp_cli_dbus_daemon_call_get_name_owner (tp_proxy_get_dbus_daemon (self),
@@ -553,3 +566,20 @@ _mcd_client_proxy_set_bypass_approval (McdClientProxy *self,
self->priv->bypass_approval = bypass;
}
+
+void
+_mcd_client_proxy_clear_capability_tokens (McdClientProxy *self)
+{
+ g_return_if_fail (MCD_IS_CLIENT_PROXY (self));
+
+ tp_handle_set_destroy (self->priv->capability_tokens);
+ self->priv->capability_tokens = tp_handle_set_new (
+ self->priv->string_pool);
+}
+
+TpHandleSet *
+_mcd_client_proxy_peek_capability_tokens (McdClientProxy *self)
+{
+ g_return_val_if_fail (MCD_IS_CLIENT_PROXY (self), NULL);
+ return self->priv->capability_tokens;
+}
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index f0c013b..c084214 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -163,10 +163,6 @@ typedef struct _McdClient
{
McdClientProxy *proxy;
McdClientInterface interfaces;
-
- /* Handler.Capabilities, represented as handles taken from
- * dispatcher->priv->string_pool */
- TpHandleSet *capability_tokens;
} McdClient;
struct _McdDispatcherPrivate
@@ -316,12 +312,7 @@ mcd_client_become_incapable (McdClient *client)
_mcd_client_proxy_take_approver_filters (client->proxy, NULL);
_mcd_client_proxy_take_observer_filters (client->proxy, NULL);
_mcd_client_proxy_take_handler_filters (client->proxy, NULL);
-
- if (client->capability_tokens != NULL)
- {
- tp_handle_set_destroy (client->capability_tokens);
- client->capability_tokens = NULL;
- }
+ _mcd_client_proxy_clear_capability_tokens (client->proxy);
}
static void
@@ -2022,6 +2013,8 @@ mcd_dispatcher_append_client_caps (McdDispatcher *self,
GPtrArray *cap_tokens;
GValueArray *va;
const GList *list;
+ TpHandleSet *capability_tokens =
+ _mcd_client_proxy_peek_capability_tokens (client->proxy);
for (list = handler_filters; list != NULL; list = list->next)
{
@@ -2034,7 +2027,7 @@ mcd_dispatcher_append_client_caps (McdDispatcher *self,
g_ptr_array_add (filters, copy);
}
- if (client->capability_tokens == NULL)
+ if (capability_tokens == NULL)
{
cap_tokens = g_ptr_array_sized_new (1);
}
@@ -2043,9 +2036,9 @@ mcd_dispatcher_append_client_caps (McdDispatcher *self,
TokenAppendContext context = { self->priv->string_pool, NULL };
cap_tokens = g_ptr_array_sized_new (
- tp_handle_set_size (client->capability_tokens) + 1);
+ tp_handle_set_size (capability_tokens) + 1);
context.array = cap_tokens;
- tp_handle_set_foreach (client->capability_tokens, append_token_to_ptrs,
+ tp_handle_set_foreach (capability_tokens, append_token_to_ptrs,
&context);
}
@@ -2178,7 +2171,8 @@ mcd_client_add_cap_tokens (McdClient *client,
TpHandle handle = tp_handle_ensure (string_pool,
cap_tokens[i], NULL, NULL);
- tp_handle_set_add (client->capability_tokens, handle);
+ tp_handle_set_add (
+ _mcd_client_proxy_peek_capability_tokens (client->proxy), handle);
tp_handle_unref (string_pool, handle);
}
}
@@ -2521,8 +2515,6 @@ create_mcd_client (McdDispatcher *self,
client = g_slice_new0 (McdClient);
- client->capability_tokens = tp_handle_set_new (self->priv->string_pool);
-
client->proxy = _mcd_client_proxy_new (
self->priv->dbus_daemon, self->priv->string_pool,
name + MC_CLIENT_BUS_NAME_BASE_LEN,
--
1.5.6.5
More information about the telepathy-commits
mailing list