[telepathy-mission-control/master] McdClient: manage handler capabilities internally
Simon McVittie
simon.mcvittie at collabora.co.uk
Mon Oct 19 07:01:05 PDT 2009
Previously, McdDispatcher dealt with the transition between available
(i.e. active || activatable) and not available.
---
src/mcd-client.c | 32 +++++++++++++++++++++++++-------
src/mcd-dispatcher.c | 14 +-------------
2 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/src/mcd-client.c b/src/mcd-client.c
index 0aca8be..7bd0b86 100644
--- a/src/mcd-client.c
+++ b/src/mcd-client.c
@@ -597,6 +597,9 @@ _mcd_client_proxy_handler_get_all_cb (TpProxy *proxy,
goto finally;
}
+ /* by now, we at least know whether the client is running or not */
+ g_assert (self->priv->unique_name != NULL);
+
filters = tp_asv_get_boxed (properties, "HandlerChannelFilter",
TP_ARRAY_TYPE_STRING_VARIANT_MAP_LIST);
@@ -617,12 +620,15 @@ _mcd_client_proxy_handler_get_all_cb (TpProxy *proxy,
self->priv->bypass_approval = 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));
- g_signal_emit (self, signals[S_HANDLER_CAPABILITIES_CHANGED], 0);
-
- /* by now, we at least know whether the client is running or not */
- g_assert (self->priv->unique_name != NULL);
+ /* don't emit handler-capabilities-changed if we're not actually available
+ * any more - if that's the case, then we already signalled our loss of
+ * any capabilities */
+ if (self->priv->unique_name[0] != '\0' || self->priv->activatable)
+ {
+ _mcd_client_proxy_add_cap_tokens (self,
+ tp_asv_get_boxed (properties, "Capabilities", G_TYPE_STRV));
+ g_signal_emit (self, signals[S_HANDLER_CAPABILITIES_CHANGED], 0);
+ }
/* If our unique name is "", then we're not *really* handling these
* channels - they're the last known information from before the
@@ -832,6 +838,8 @@ mcd_client_proxy_introspect (gpointer data)
}
else
{
+ /* for us to have ever started introspecting, it must be
+ * activatable */
DEBUG ("%s is a Handler but not active", bus_name);
/* FIXME: we emit this even if the capabilities we got from the
@@ -1157,7 +1165,9 @@ _mcd_client_proxy_set_inactive (McdClientProxy *self)
if (!self->priv->activatable)
{
- /* a handler that is neither running nor activatable is useless */
+ /* in ContactCapabilities we indicate the disappearance
+ * of a client by giving it an empty set of capabilities and
+ * filters */
_mcd_client_proxy_become_incapable (self);
}
}
@@ -1258,12 +1268,20 @@ _mcd_client_proxy_get_bypass_approval (McdClientProxy *self)
static void
_mcd_client_proxy_become_incapable (McdClientProxy *self)
{
+ gboolean handler_was_capable = (self->priv->handler_filters != NULL ||
+ tp_handle_set_size (self->priv->capability_tokens) > 0);
+
_mcd_client_proxy_take_approver_filters (self, NULL);
_mcd_client_proxy_take_observer_filters (self, NULL);
_mcd_client_proxy_take_handler_filters (self, NULL);
tp_handle_set_destroy (self->priv->capability_tokens);
self->priv->capability_tokens = tp_handle_set_new (
self->priv->string_pool);
+
+ if (handler_was_capable)
+ {
+ g_signal_emit (self, signals[S_HANDLER_CAPABILITIES_CHANGED], 0);
+ }
}
typedef struct {
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 9eef962..6987e0f 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -1724,14 +1724,7 @@ static void
mcd_dispatcher_client_capabilities_changed_cb (McdClientProxy *client,
McdDispatcher *self)
{
- /* Ignore the last known capabilities of clients that have already exited,
- * unless we can reactivate them. */
-
- if (_mcd_client_proxy_is_activatable (client) ||
- _mcd_client_proxy_is_active (client))
- {
- mcd_dispatcher_update_client_caps (self, client);
- }
+ mcd_dispatcher_update_client_caps (self, client);
}
static void mcd_dispatcher_client_ready_cb (McdClientProxy *client,
@@ -2094,11 +2087,6 @@ name_owner_changed_cb (TpDBusDaemon *proxy,
if (!_mcd_client_proxy_is_activatable (client))
{
- /* in ContactCapabilities we indicate the disappearance
- * of a client by giving it an empty set of capabilities and
- * filters */
- mcd_dispatcher_update_client_caps (self, client);
-
mcd_dispatcher_discard_client (self, client);
_mcd_client_registry_remove (priv->clients, name);
}
--
1.5.6.5
More information about the telepathy-commits
mailing list