[telepathy-mission-control/master] McdDispatcher: match_filters: when choosing where to call AddRequest, assume that the returned channel will have Requested=TRUE
Simon McVittie
simon.mcvittie at collabora.co.uk
Mon Sep 14 10:45:00 PDT 2009
This makes AddRequest work on clients that only want to handle outgoing
channels (like the VNC-tube server).
---
src/mcd-dispatcher.c | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index cc7665d..f3e911f 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -570,7 +570,9 @@ channel_classes_equals (GHashTable *channel_class1, GHashTable *channel_class2)
* largest filter that matched)
*/
static guint
-match_filters (McdChannel *channel, GList *filters)
+match_filters (McdChannel *channel,
+ GList *filters,
+ gboolean assume_requested)
{
GHashTable *channel_properties;
McdChannelStatus status;
@@ -610,8 +612,18 @@ match_filters (McdChannel *channel, GList *filters)
(gpointer *) &property_name,
(gpointer *) &filter_value))
{
- if (! match_property (channel_properties, property_name,
- filter_value))
+ if (assume_requested &&
+ ! tp_strdiff (property_name, TP_IFACE_CHANNEL ".Requested"))
+ {
+ if (! G_VALUE_HOLDS_BOOLEAN (filter_value) ||
+ ! g_value_get_boolean (filter_value))
+ {
+ filter_matched = FALSE;
+ break;
+ }
+ }
+ else if (! match_property (channel_properties, property_name,
+ filter_value))
{
filter_matched = FALSE;
break;
@@ -634,6 +646,9 @@ mcd_dispatcher_guess_request_handler (McdDispatcher *dispatcher,
GHashTableIter iter;
McdClient *client;
+ /* FIXME: return the "most preferred" handler, not just any handler that
+ * can take it */
+
g_hash_table_iter_init (&iter, dispatcher->priv->clients);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &client))
{
@@ -641,7 +656,7 @@ mcd_dispatcher_guess_request_handler (McdDispatcher *dispatcher,
!(client->interfaces & MCD_CLIENT_HANDLER))
continue;
- if (match_filters (channel, client->handler_filters) > 0)
+ if (match_filters (channel, client->handler_filters, TRUE) > 0)
return client;
}
return NULL;
@@ -815,7 +830,7 @@ mcd_dispatcher_get_possible_handlers (McdDispatcher *self,
McdChannel *channel = MCD_CHANNEL (iter->data);
guint quality;
- quality = match_filters (channel, client->handler_filters);
+ quality = match_filters (channel, client->handler_filters, FALSE);
if (quality == 0)
{
@@ -1173,7 +1188,7 @@ mcd_dispatcher_run_observers (McdDispatcherContext *context)
{
McdChannel *channel = MCD_CHANNEL (cl->data);
- if (match_filters (channel, client->observer_filters))
+ if (match_filters (channel, client->observer_filters, FALSE))
observed = g_list_prepend (observed, channel);
}
if (!observed) continue;
@@ -1327,7 +1342,7 @@ mcd_dispatcher_run_approvers (McdDispatcherContext *context)
{
McdChannel *channel = MCD_CHANNEL (cl->data);
- if (match_filters (channel, client->approver_filters))
+ if (match_filters (channel, client->approver_filters, FALSE))
{
matched = TRUE;
break;
--
1.5.6.5
More information about the telepathy-commits
mailing list