summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Dasmohapatra <vivek@collabora.co.uk>2010-01-28 19:05:50 +0000
committerVivek Dasmohapatra <vivek@collabora.co.uk>2010-02-03 14:53:33 +0000
commit996eeb3c8888bb24fc4654ff536e63bf0e853b5c (patch)
treef310c2eaaef51b8f9f038f5d2c1fb65218464653
parent09c98f395931eb128a24418c2329aaa2d6e89614 (diff)
downloadtelepathy-mission-control-996eeb3c8888bb24fc4654ff536e63bf0e853b5c.tar.gz
fd.o #23651: use preferred handler in two cases
- from requests that caused a channel to be created - when a request approves a pending dispatch operation
-rw-r--r--src/mcd-dispatch-operation.c44
-rw-r--r--src/mcd-dispatch-operation.h2
-rw-r--r--src/mcd-dispatcher.c9
3 files changed, 54 insertions, 1 deletions
diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index c6bfe47b..b55b7d39 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -382,17 +382,38 @@ mcd_dispatch_operation_set_property (GObject *obj, guint prop_id,
break;
case PROP_CHANNELS:
+ /* because this is construct-only, we can assert that: */
g_assert (priv->channels == NULL);
+ g_assert (priv->handler == NULL);
+
priv->channels = g_value_get_pointer (val);
if (G_LIKELY (priv->channels))
{
/* get the connection from the first channel */
McdChannel *channel = MCD_CHANNEL (priv->channels->data);
+ const gchar *preferred_handler;
priv->connection = (McdConnection *)
mcd_mission_get_parent (MCD_MISSION (channel));
if (G_LIKELY (priv->connection))
g_object_ref (priv->connection);
+ /* if the first channel is actually a channel request, get the
+ * preferred handler from it */
+ preferred_handler =
+ _mcd_channel_get_request_preferred_handler (channel);
+
+ if (preferred_handler != NULL &&
+ g_str_has_prefix (preferred_handler, MCD_CLIENT_BASE_NAME) &&
+ tp_dbus_check_valid_bus_name (preferred_handler,
+ TP_DBUS_NAME_TYPE_WELL_KNOWN,
+ NULL))
+ {
+ DEBUG ("Extracted preferred handler: %s",
+ preferred_handler);
+ priv->handler = g_strdup (preferred_handler +
+ MCD_CLIENT_BASE_NAME_LEN);
+ }
+
/* reference the channels */
for (list = priv->channels; list != NULL; list = list->next)
g_object_ref (list->data);
@@ -826,3 +847,26 @@ _mcd_dispatch_operation_unblock_finished (McdDispatchOperation *self)
}
}
}
+
+gboolean
+mcd_dispatch_operation_check_handler (const gchar *handler)
+{
+ /* NULL-safety: treat both NULL and "" as "unspecified" */
+ if (handler == NULL)
+ return FALSE;
+
+ DEBUG ("handler: '%s'", handler);
+
+ if (!g_str_has_prefix (handler, MCD_CLIENT_BASE_NAME) ||
+ !tp_dbus_check_valid_bus_name (handler,
+ TP_DBUS_NAME_TYPE_WELL_KNOWN, NULL))
+ {
+ DEBUG ("handler name '%s' is bad", handler);
+ return FALSE;
+ }
+
+ if (*handler != '\0')
+ return TRUE;
+
+ return FALSE;
+}
diff --git a/src/mcd-dispatch-operation.h b/src/mcd-dispatch-operation.h
index 918afa5e..2c4fe746 100644
--- a/src/mcd-dispatch-operation.h
+++ b/src/mcd-dispatch-operation.h
@@ -67,5 +67,7 @@ void mcd_dispatch_operation_handle_with (McdDispatchOperation *operation,
const gchar *handler_path,
GError **error);
+gboolean mcd_dispatch_operation_check_handler (const gchar *handler);
+
G_END_DECLS
#endif
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 8ed59196..b6132ada 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -3705,6 +3705,12 @@ _mcd_dispatcher_add_channel_request (McdDispatcher *dispatcher,
}
else
{
+ const gchar *preferred_handler =
+ _mcd_channel_get_request_preferred_handler (request);
+
+ if (!mcd_dispatch_operation_check_handler (preferred_handler))
+ preferred_handler = NULL;
+
_mcd_channel_set_request_proxy (request, channel);
if (status == MCD_CHANNEL_STATUS_DISPATCHING)
{
@@ -3719,7 +3725,8 @@ _mcd_dispatcher_add_channel_request (McdDispatcher *dispatcher,
* terminate */
if (G_LIKELY (context->operation))
mcd_dispatch_operation_handle_with (context->operation,
- NULL, NULL);
+ preferred_handler,
+ NULL);
}
else
context->skip_approval = TRUE;