[telepathy-mission-control/master] McdClientProxy: store BypassApproval here instead of in McdClient
Simon McVittie
simon.mcvittie at collabora.co.uk
Mon Sep 21 10:52:07 PDT 2009
---
src/mcd-client-priv.h | 4 ++++
src/mcd-client.c | 17 +++++++++++++++++
src/mcd-dispatcher.c | 32 ++++++++++++++++++--------------
3 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/src/mcd-client-priv.h b/src/mcd-client-priv.h
index a6aa5d6..f712f56 100644
--- a/src/mcd-client-priv.h
+++ b/src/mcd-client-priv.h
@@ -97,6 +97,8 @@ G_GNUC_INTERNAL const GList *_mcd_client_proxy_get_observer_filters
(McdClientProxy *self);
G_GNUC_INTERNAL const GList *_mcd_client_proxy_get_handler_filters
(McdClientProxy *self);
+G_GNUC_INTERNAL gboolean _mcd_client_proxy_get_bypass_approval
+ (McdClientProxy *self);
G_GNUC_INTERNAL void _mcd_client_proxy_take_approver_filters
(McdClientProxy *self, GList *filters);
@@ -104,6 +106,8 @@ G_GNUC_INTERNAL void _mcd_client_proxy_take_observer_filters
(McdClientProxy *self, GList *filters);
G_GNUC_INTERNAL void _mcd_client_proxy_take_handler_filters
(McdClientProxy *self, GList *filters);
+G_GNUC_INTERNAL void _mcd_client_proxy_set_bypass_approval
+ (McdClientProxy *self, gboolean bypass);
#define MC_CLIENT_BUS_NAME_BASE_LEN (sizeof (TP_CLIENT_BUS_NAME_BASE) - 1)
diff --git a/src/mcd-client.c b/src/mcd-client.c
index 8d9d11b..f968ab0 100644
--- a/src/mcd-client.c
+++ b/src/mcd-client.c
@@ -56,6 +56,7 @@ struct _McdClientProxyPrivate
TpHandleRepoIface *string_pool;
gchar *unique_name;
gboolean ready;
+ gboolean bypass_approval;
/* If a client was in the ListActivatableNames list, it must not be
* removed when it disappear from the bus.
@@ -536,3 +537,19 @@ _mcd_client_proxy_take_handler_filters (McdClientProxy *self,
self->priv->handler_filters = filters;
}
+gboolean
+_mcd_client_proxy_get_bypass_approval (McdClientProxy *self)
+{
+ g_return_val_if_fail (MCD_IS_CLIENT_PROXY (self), FALSE);
+
+ return self->priv->bypass_approval;
+}
+
+void
+_mcd_client_proxy_set_bypass_approval (McdClientProxy *self,
+ gboolean bypass)
+{
+ g_return_if_fail (MCD_IS_CLIENT_PROXY (self));
+
+ self->priv->bypass_approval = bypass;
+}
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index fe91350..f0c013b 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -163,7 +163,6 @@ typedef struct _McdClient
{
McdClientProxy *proxy;
McdClientInterface interfaces;
- guint bypass_approver : 1;
/* Handler.Capabilities, represented as handles taken from
* dispatcher->priv->string_pool */
@@ -707,6 +706,7 @@ handle_channels_cb (TpClient *proxy, const GError *error, gpointer user_data,
typedef struct
{
McdClient *client;
+ gboolean bypass;
gsize quality;
} PossibleHandler;
@@ -717,15 +717,15 @@ possible_handler_cmp (gconstpointer a_,
const PossibleHandler *a = a_;
const PossibleHandler *b = b_;
- if (a->client->bypass_approver)
+ if (a->bypass)
{
- if (!b->client->bypass_approver)
+ if (!b->bypass)
{
/* BypassApproval wins, so a is better than b */
return 1;
}
}
- else if (b->client->bypass_approver)
+ else if (b->bypass)
{
/* BypassApproval wins, so b is better than a */
return -1;
@@ -795,6 +795,7 @@ mcd_dispatcher_get_possible_handlers (McdDispatcher *self,
PossibleHandler *ph = g_slice_new0 (PossibleHandler);
ph->client = client;
+ ph->bypass = _mcd_client_proxy_get_bypass_approval (client->proxy);
ph->quality = total_quality;
handlers = g_list_prepend (handlers, ph);
@@ -1341,9 +1342,11 @@ handlers_can_bypass_approval (McdDispatcherContext *context)
* approval, no handler bypasses approval. */
if (handler != NULL)
{
- DEBUG ("%s has BypassApproval=%c", *iter,
- handler->bypass_approver ? 'T' : 'F');
- return handler->bypass_approver;
+ gboolean bypass = _mcd_client_proxy_get_bypass_approval (
+ handler->proxy);
+
+ DEBUG ("%s has BypassApproval=%c", *iter, bypass ? 'T' : 'F');
+ return bypass;
}
}
@@ -2226,6 +2229,7 @@ handler_get_all_cb (TpProxy *proxy,
const gchar *bus_name = tp_proxy_get_bus_name (proxy);
GPtrArray *filters, *channels;
const gchar *unique_name;
+ gboolean bypass;
if (error != NULL)
{
@@ -2260,10 +2264,9 @@ handler_get_all_cb (TpProxy *proxy,
}
/* if wrong type or absent, assuming False is reasonable */
- client->bypass_approver = tp_asv_get_boolean (properties, "BypassApproval",
- NULL);
- DEBUG ("%s has BypassApproval=%c", bus_name,
- client->bypass_approver ? 'T' : 'F');
+ bypass = tp_asv_get_boolean (properties, "BypassApproval", NULL);
+ _mcd_client_proxy_set_bypass_approval (client->proxy, bypass);
+ DEBUG ("%s has BypassApproval=%c", bus_name, bypass ? 'T' : 'F');
mcd_client_add_cap_tokens (client, self->priv->string_pool,
tp_asv_get_boxed (properties, "Capabilities",
@@ -2433,6 +2436,7 @@ parse_client_file (McdClient *client,
GList *approver_filters = NULL;
GList *observer_filters = NULL;
GList *handler_filters = NULL;
+ gboolean bypass;
iface_names = g_key_file_get_string_list (file, TP_IFACE_CLIENT,
"Interfaces", 0, NULL);
@@ -2491,9 +2495,9 @@ parse_client_file (McdClient *client,
handler_filters);
/* Other client options */
- client->bypass_approver =
- g_key_file_get_boolean (file, TP_IFACE_CLIENT_HANDLER,
- "BypassApproval", NULL);
+ bypass = g_key_file_get_boolean (file, TP_IFACE_CLIENT_HANDLER,
+ "BypassApproval", NULL);
+ _mcd_client_proxy_set_bypass_approval (client->proxy, bypass);
cap_tokens = g_key_file_get_keys (file,
TP_IFACE_CLIENT_HANDLER ".Capabilities",
--
1.5.6.5
More information about the telepathy-commits
mailing list