[telepathy-mission-control/master] _mcd_client_proxy_set_handler_properties: factor out most of McdDispatcher's handler_get_all_cb
Simon McVittie
simon.mcvittie at collabora.co.uk
Tue Sep 22 07:48:07 PDT 2009
---
src/mcd-client-priv.h | 4 ++++
src/mcd-client.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
src/mcd-dispatcher.c | 37 +++++--------------------------------
3 files changed, 57 insertions(+), 32 deletions(-)
diff --git a/src/mcd-client-priv.h b/src/mcd-client-priv.h
index 2b71eb4..5aa5d9e 100644
--- a/src/mcd-client-priv.h
+++ b/src/mcd-client-priv.h
@@ -123,6 +123,10 @@ typedef enum
G_GNUC_INTERNAL void _mcd_client_proxy_set_filters (McdClientProxy *client,
McdClientInterface interface, GPtrArray *filters);
+G_GNUC_INTERNAL gboolean _mcd_client_proxy_set_handler_properties (
+ McdClientProxy *client, GHashTable *properties, const GError *error,
+ const GPtrArray **handled_channels);
+
#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 d5f6488..50160ce 100644
--- a/src/mcd-client.c
+++ b/src/mcd-client.c
@@ -543,6 +543,54 @@ mcd_client_proxy_emit_ready (McdClientProxy *self)
}
gboolean
+_mcd_client_proxy_set_handler_properties (McdClientProxy *self,
+ GHashTable *properties,
+ const GError *error,
+ const GPtrArray **handled_channels)
+{
+ const gchar *bus_name = tp_proxy_get_bus_name (self);
+ GPtrArray *filters;
+ gboolean bypass;
+
+ if (error != NULL)
+ {
+ DEBUG ("GetAll(Handler) for client %s failed: %s #%d: %s",
+ bus_name, g_quark_to_string (error->domain), error->code,
+ error->message);
+ return FALSE;
+ }
+
+ filters = tp_asv_get_boxed (properties, "HandlerChannelFilter",
+ TP_ARRAY_TYPE_STRING_VARIANT_MAP_LIST);
+
+ if (filters != NULL)
+ {
+ DEBUG ("%s has %u HandlerChannelFilter entries", bus_name,
+ filters->len);
+ _mcd_client_proxy_set_filters (self, MCD_CLIENT_HANDLER, filters);
+ }
+ else
+ {
+ DEBUG ("%s HandlerChannelFilter absent or wrong type, assuming "
+ "no channels can match", bus_name);
+ }
+
+ /* if wrong type or absent, assuming False is reasonable */
+ bypass = tp_asv_get_boolean (properties, "BypassApproval", NULL);
+ _mcd_client_proxy_set_bypass_approval (self, bypass);
+ DEBUG ("%s has BypassApproval=%c", bus_name, bypass ? 'T' : 'F');
+
+ _mcd_client_proxy_add_cap_tokens (self,
+ tp_asv_get_boxed (properties, "Capabilities", G_TYPE_STRV));
+
+ if (handled_channels != NULL)
+ *handled_channels = tp_asv_get_boxed (properties, "HandledChannels",
+ TP_ARRAY_TYPE_OBJECT_PATH_LIST);
+
+ return TRUE;
+}
+
+gboolean
_mcd_client_proxy_parse_client_file (McdClientProxy *self)
{
gboolean file_found = FALSE;
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 21b7880..427444a 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -1858,15 +1858,14 @@ handler_get_all_cb (TpProxy *proxy,
McdDispatcher *self = MCD_DISPATCHER (weak_object);
McdClientProxy *client;
const gchar *bus_name = tp_proxy_get_bus_name (proxy);
- GPtrArray *filters, *channels;
+ const GPtrArray *channels = NULL;
const gchar *unique_name;
- gboolean bypass;
- if (error != NULL)
+ if (!_mcd_client_proxy_set_handler_properties (client_proxy,
+ properties,
+ error,
+ &channels))
{
- DEBUG ("GetAll(Handler) for client %s failed: %s #%d: %s",
- bus_name, g_quark_to_string (error->domain), error->code,
- error->message);
goto finally;
}
@@ -1879,32 +1878,6 @@ handler_get_all_cb (TpProxy *proxy,
goto finally;
}
- filters = tp_asv_get_boxed (properties, "HandlerChannelFilter",
- TP_ARRAY_TYPE_STRING_VARIANT_MAP_LIST);
-
- if (filters != NULL)
- {
- DEBUG ("%s has %u HandlerChannelFilter entries", bus_name,
- filters->len);
- _mcd_client_proxy_set_filters (client, MCD_CLIENT_HANDLER, filters);
- }
- else
- {
- DEBUG ("%s HandlerChannelFilter absent or wrong type, assuming "
- "no channels can match", bus_name);
- }
-
- /* if wrong type or absent, assuming False is reasonable */
- bypass = tp_asv_get_boolean (properties, "BypassApproval", NULL);
- _mcd_client_proxy_set_bypass_approval (client, bypass);
- DEBUG ("%s has BypassApproval=%c", bus_name, bypass ? 'T' : 'F');
-
- _mcd_client_proxy_add_cap_tokens (client,
- tp_asv_get_boxed (properties, "Capabilities", G_TYPE_STRV));
-
- channels = tp_asv_get_boxed (properties, "HandledChannels",
- TP_ARRAY_TYPE_OBJECT_PATH_LIST);
-
unique_name = _mcd_client_proxy_get_unique_name (client_proxy);
/* This function is only called in response to the McdClientProxy
--
1.5.6.5
More information about the telepathy-commits
mailing list