diff options
author | Louis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk> | 2010-10-22 14:34:13 -0400 |
---|---|---|
committer | Louis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk> | 2010-12-03 10:55:43 -0500 |
commit | 0a4df5c173d77b5aa98858a0d0cc2d9ea275e541 (patch) | |
tree | 3fe9805d4b2d35a3d08ef7315e692171a0ecf0df | |
parent | c50895db2082c47bd12fcc3dc7316eb7c785bbae (diff) |
Add helper function to diff capabilities
-rw-r--r-- | src/server/conn.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/server/conn.py b/src/server/conn.py index a3bd598..9192829 100644 --- a/src/server/conn.py +++ b/src/server/conn.py @@ -401,6 +401,31 @@ class ConnectionInterfaceCapabilities(_ConnectionInterfaceCapabilities): # return all my capabilities return [(ctype, caps[1]) for ctype, caps in my_caps.iteritems()] + def _diff_capabilities(self, handle, ctype, new_gen=None, + new_spec=None, added_gen=None, added_spec=None): + """Helper function to diff new caps with actual capabilities.""" + + if handle in self._caps and ctype in self._caps[handle]: + old_gen, old_spec = self._caps[handle][ctype] + else: + old_gen = 0 + old_spec = 0 + + if new_gen is None: + new_gen = old_gen + if new_spec is None: + new_spec = old_spec + if added_gen: + new_gen |= added_gen + if added_spec: + new_spec |= new_spec + + if old_gen != new_gen or old_spec != new_spec: + diff = (int(handle), ctype, old_gen, new_gen, old_spec, new_spec) + return diff + + return None + from telepathy._generated.Connection_Interface_Contact_Capabilities \ import ConnectionInterfaceContactCapabilities \ as _ConnectionInterfaceContactCapabilities |