[telepathy-gabble/master] gabble_connection_advertise_capabilities: operate in terms of namespace sets as much as possible
Simon McVittie
simon.mcvittie at collabora.co.uk
Mon Aug 24 09:16:26 PDT 2009
This means that we don't touch namespaces that the old Capabilities
interface cannot comprehend, like particular Tube services; as a result,
one of the tests changes its behaviour slightly (caps get removed a bit
at a time).
---
src/connection.c | 35 ++++++++++++-------------------
tests/twisted/caps/advertise-draft1.py | 7 +++--
2 files changed, 18 insertions(+), 24 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index b00d1e7..008fdf4 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -2453,7 +2453,6 @@ gabble_connection_advertise_capabilities (TpSvcConnectionInterfaceCapabilities *
TpBaseConnection *base = (TpBaseConnection *) self;
guint i;
GabblePresence *pres = self->self_presence;
- GabblePresenceCapabilities add_caps = 0, remove_caps = 0, caps, save_caps;
GabbleConnectionPrivate *priv = self->priv;
const CapabilityConversionData *ccd;
GPtrArray *ret;
@@ -2497,29 +2496,24 @@ gabble_connection_advertise_capabilities (TpSvcConnectionInterfaceCapabilities *
ccd->tf2c_fn (~0, remove_set);
}
- add_caps = capabilities_parse (add_set);
- remove_caps = capabilities_parse (remove_set);
-
- gabble_capability_set_free (add_set);
- gabble_capability_set_free (remove_set);
-
- save_caps = caps = pres->caps;
save_set = gabble_presence_dup_caps (pres);
+ cap_set = gabble_capability_set_copy (save_set);
- caps |= add_caps;
- caps ^= (caps & remove_caps);
+ gabble_capability_set_update (cap_set, add_set);
+ gabble_capability_set_exclude (cap_set, remove_set);
- DEBUG ("caps to add: %x", add_caps);
- DEBUG ("caps to remove: %x", remove_caps);
- DEBUG ("caps after: %x", caps);
+ DEBUG ("caps to add: %x", capabilities_parse (add_set));
+ DEBUG ("caps to remove: %x", capabilities_parse (remove_set));
+ DEBUG ("caps after: %x", capabilities_parse (cap_set));
- if (caps ^ save_caps)
+ gabble_capability_set_free (add_set);
+ gabble_capability_set_free (remove_set);
+
+ if (!gabble_capability_set_equals (save_set, cap_set))
{
DEBUG ("before != after, changing");
- cap_set = gabble_capability_set_new_from_flags (caps);
- gabble_presence_set_capabilities (pres, priv->resource, cap_set, caps,
- priv->caps_serial++);
- gabble_capability_set_free (cap_set);
+ gabble_presence_set_capabilities (pres, priv->resource, cap_set,
+ capabilities_parse (cap_set), priv->caps_serial++);
DEBUG ("set caps: %x", pres->caps);
}
@@ -2547,7 +2541,7 @@ gabble_connection_advertise_capabilities (TpSvcConnectionInterfaceCapabilities *
}
}
- if (caps ^ save_caps)
+ if (!gabble_capability_set_equals (save_set, cap_set))
{
if (!_gabble_connection_signal_own_presence (self, &error))
{
@@ -2555,11 +2549,10 @@ gabble_connection_advertise_capabilities (TpSvcConnectionInterfaceCapabilities *
return;
}
- cap_set = gabble_capability_set_new_from_flags (caps);
_emit_capabilities_changed (self, base->self_handle, save_set, cap_set);
- gabble_capability_set_free (cap_set);
}
+ gabble_capability_set_free (cap_set);
gabble_capability_set_free (save_set);
tp_svc_connection_interface_capabilities_return_from_advertise_capabilities (
diff --git a/tests/twisted/caps/advertise-draft1.py b/tests/twisted/caps/advertise-draft1.py
index 817bc60..c6befc8 100644
--- a/tests/twisted/caps/advertise-draft1.py
+++ b/tests/twisted/caps/advertise-draft1.py
@@ -63,10 +63,11 @@ def run_test(q, bus, conn, stream):
caps = conn.Capabilities.AdvertiseCapabilities(add, remove)
(disco_response, namespaces, _) = receive_presence_and_ask_caps(q, stream,
False)
- check_caps(namespaces, [])
- # the call to SSC has no effect here
+ check_caps(namespaces, [ns.TUBES + '/stream#x-abiword'])
conn.ContactCapabilities.SetSelfCapabilities([])
- noop_presence_update(q, stream)
+ (disco_response, namespaces, _) = receive_presence_and_ask_caps(q, stream,
+ False)
+ check_caps(namespaces, [])
# Add caps selectively (i.e. what a client that actually understood the
# old Capabilities interface would do). With AUDIO and GTALK_P2P, we're
--
1.5.6.5
More information about the telepathy-commits
mailing list