[telepathy-gabble/telepathy-gabble-0.8] restore per-channel-manager caps from the cache

Dafydd Harries dafydd.harries at collabora.co.uk
Tue Jan 12 17:25:01 PST 2010


---
 src/presence-cache.c                        |    9 +++++++--
 tests/twisted/caps/caps-persistent-cache.py |    9 +++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/presence-cache.c b/src/presence-cache.c
index 283bdd2..b60f5b1 100644
--- a/src/presence-cache.c
+++ b/src/presence-cache.c
@@ -1316,6 +1316,7 @@ _process_caps_uri (GabblePresenceCache *cache,
   CapabilityInfo *info;
   gboolean caps_in_cache = FALSE;
   GabblePresenceCapabilities cached_caps = 0;
+  GHashTable *cached_pcm_caps = NULL;
   GabblePresenceCachePrivate *priv;
   TpHandleRepoIface *contact_repo;
   GabbleCapsCache *caps_cache;
@@ -1339,6 +1340,8 @@ _process_caps_uri (GabblePresenceCache *cache,
           cached_caps |= capabilities_from_ns (*i);
         }
 
+      cached_pcm_caps =
+          parse_contact_caps ((TpBaseConnection *) priv->conn, uris);
       g_strfreev (uris);
     }
 
@@ -1352,14 +1355,16 @@ _process_caps_uri (GabblePresenceCache *cache,
       GabblePresence *presence = gabble_presence_cache_get (cache, handle);
       GabblePresenceCapabilities caps =
           caps_in_cache ? cached_caps : info->caps;
+      GHashTable *per_channel_manager_caps =
+          caps_in_cache ? cached_pcm_caps : info->per_channel_manager_caps;
 
       DEBUG ("enough trust for URI %s, setting caps for %u (%s) to %u",
           uri, handle, from, caps);
 
       if (presence)
         {
-          gabble_presence_set_capabilities (presence, resource,
-              caps, info->per_channel_manager_caps, serial);
+          gabble_presence_set_capabilities (
+              presence, resource, caps, per_channel_manager_caps, serial);
           DEBUG ("caps for %d (%s) now %d", handle, from, presence->caps);
         }
       else
diff --git a/tests/twisted/caps/caps-persistent-cache.py b/tests/twisted/caps/caps-persistent-cache.py
index 4750330..8060cd4 100644
--- a/tests/twisted/caps/caps-persistent-cache.py
+++ b/tests/twisted/caps/caps-persistent-cache.py
@@ -17,7 +17,13 @@ features = [
     ns.JINGLE_015_AUDIO,
     ns.JINGLE_015_VIDEO,
     ns.GOOGLE_P2P,
+    ns.TUBES + '/dbus#com.example.Xiangqi',
     ]
+xiangqi_tube_cap = (
+    {cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_DBUS_TUBE,
+      cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+      cs.DBUS_TUBE_SERVICE_NAME: u'com.example.Xiangqi'},
+    [cs.TARGET_HANDLE, cs.TARGET_ID])
 
 def connect(q, conn):
     conn.Connect()
@@ -43,6 +49,9 @@ def capabilities_changed(q, contact_handle):
         0, 3, 0, cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_VIDEO)
     e = q.expect('dbus-signal', signal='CapabilitiesChanged')
     assertContains(streamed_media_caps, e.args[0])
+    e = q.expect('dbus-signal', signal='ContactCapabilitiesChanged')
+    assertContains(contact_handle, e.args[0])
+    assertContains(xiangqi_tube_cap, e.args[0][contact_handle])
 
 def test1(q, bus, conn, stream):
     connect(q, conn)
-- 
1.5.6.5




More information about the telepathy-commits mailing list