[telepathy-gabble/telepathy-gabble-0.8] gabble_caps_channel_manager_add_capability: rename to gabble_caps_channel_manager_add_self_capability and remove @handle

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Nov 23 10:23:40 PST 2009


This would never really make sense for other contacts: it's used when
we set our own capabilities, and what would it mean to set someone else's
capabilities over D-Bus?
---
 src/caps-channel-manager.c  |    7 +++----
 src/caps-channel-manager.h  |   11 +++++------
 src/connection.c            |    5 ++---
 src/ft-manager.c            |   17 +++--------------
 src/private-tubes-factory.c |   22 ++++++++--------------
 5 files changed, 21 insertions(+), 41 deletions(-)

diff --git a/src/caps-channel-manager.c b/src/caps-channel-manager.c
index 4b345c1..e3039f6 100644
--- a/src/caps-channel-manager.c
+++ b/src/caps-channel-manager.c
@@ -177,19 +177,18 @@ gboolean gabble_caps_channel_manager_capabilities_diff (
 }
 
 void
-gabble_caps_channel_manager_add_capability (
+gabble_caps_channel_manager_add_self_capability (
     GabbleCapsChannelManager *caps_manager,
     GabbleConnection *conn,
-    TpHandle handle,
     GHashTable *cap)
 {
   GabbleCapsChannelManagerIface *iface =
     GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
-  GabbleCapsChannelManagerAddCapFunc method = iface->add_cap;
+  GabbleCapsChannelManagerAddSelfCapFunc method = iface->add_self_capability;
 
   if (method != NULL)
     {
-      method (caps_manager, conn, handle, cap);
+      method (caps_manager, conn, cap);
     }
   /* ... else, nothing to do */
 }
diff --git a/src/caps-channel-manager.h b/src/caps-channel-manager.h
index 6c6edb9..bc4b230 100644
--- a/src/caps-channel-manager.h
+++ b/src/caps-channel-manager.h
@@ -58,8 +58,8 @@ typedef void (*GabbleCapsChannelManagerGetContactCapsFunc) (
     GabbleCapsChannelManager *manager, GabbleConnection *conn, TpHandle handle,
     GPtrArray *arr);
 
-typedef void (*GabbleCapsChannelManagerAddCapFunc) (
-    GabbleCapsChannelManager *manager, GabbleConnection *conn, TpHandle handle,
+typedef void (*GabbleCapsChannelManagerAddSelfCapFunc) (
+    GabbleCapsChannelManager *manager, GabbleConnection *conn,
     GHashTable *cap);
 
 /* Specific to Gabble */
@@ -111,16 +111,15 @@ gboolean gabble_caps_channel_manager_capabilities_diff (
     GabbleCapsChannelManager *manager, TpHandle handle,
     gpointer specific_old_caps, gpointer specific_new_caps);
 
-void gabble_caps_channel_manager_add_capability (
-    GabbleCapsChannelManager *manager, GabbleConnection *conn, TpHandle handle,
+void gabble_caps_channel_manager_add_self_capability (
+    GabbleCapsChannelManager *manager, GabbleConnection *conn,
     GHashTable *cap);
 
-
 struct _GabbleCapsChannelManagerIface {
     GTypeInterface parent;
 
     GabbleCapsChannelManagerGetContactCapsFunc get_contact_caps;
-    GabbleCapsChannelManagerAddCapFunc add_cap;
+    GabbleCapsChannelManagerAddSelfCapFunc add_self_capability;
 
     GabbleCapsChannelManagerGetFeatureListFunc get_feature_list;
     GabbleCapsChannelManagerParseCapsFunc parse_caps;
diff --git a/src/connection.c b/src/connection.c
index ecb48be..d646fb8 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -2709,9 +2709,8 @@ gabble_connection_set_self_capabilities (
           /* all channel managers must implement the capability interface */
           g_assert (GABBLE_IS_CAPS_CHANNEL_MANAGER (manager));
 
-          gabble_caps_channel_manager_add_capability (
-              GABBLE_CAPS_CHANNEL_MANAGER (manager), self,
-              base->self_handle, cap_to_add);
+          gabble_caps_channel_manager_add_self_capability (
+              GABBLE_CAPS_CHANNEL_MANAGER (manager), self, cap_to_add);
         }
     }
 
diff --git a/src/ft-manager.c b/src/ft-manager.c
index e53f4f1..59c3fab 100644
--- a/src/ft-manager.c
+++ b/src/ft-manager.c
@@ -744,12 +744,10 @@ gabble_ft_manager_update_caps (GabbleCapsChannelManager *manager,
 }
 
 static void
-gabble_ft_manager_add_cap (GabbleCapsChannelManager *manager,
+gabble_ft_manager_add_self_capability (GabbleCapsChannelManager *manager,
     GabbleConnection *conn,
-    TpHandle handle,
     GHashTable *channel_class)
 {
-  TpBaseConnection *base = TP_BASE_CONNECTION (conn);
   GabblePresence *presence;
 
   if (tp_strdiff (tp_asv_get_string (channel_class,
@@ -763,16 +761,7 @@ gabble_ft_manager_add_cap (GabbleCapsChannelManager *manager,
       return;
     }
 
-  if (handle == base->self_handle)
-    {
-      presence = conn->self_presence;
-    }
-  else
-    {
-      /* FIXME: why would this ever be needed for others' presences? */
-      presence = gabble_presence_cache_get (conn->presence_cache, handle);
-    }
-
+  presence = conn->self_presence;
   g_assert (presence != NULL);
 
   if (presence->per_channel_manager_caps == NULL)
@@ -796,5 +785,5 @@ caps_channel_manager_iface_init (gpointer g_iface,
   iface->copy_caps = gabble_ft_manager_copy_caps;
   iface->caps_diff = gabble_ft_manager_caps_diff;
   iface->update_caps = gabble_ft_manager_update_caps;
-  iface->add_cap = gabble_ft_manager_add_cap;
+  iface->add_self_capability = gabble_ft_manager_add_self_capability;
 }
diff --git a/src/private-tubes-factory.c b/src/private-tubes-factory.c
index 5d2ed1f..67cf433 100644
--- a/src/private-tubes-factory.c
+++ b/src/private-tubes-factory.c
@@ -845,12 +845,11 @@ gabble_private_tubes_factory_caps_diff (
 }
 
 static void
-gabble_private_tubes_factory_add_cap (GabbleCapsChannelManager *manager,
-                                      GabbleConnection *conn,
-                                      TpHandle handle,
-                                      GHashTable *cap)
+gabble_private_tubes_factory_add_self_capability (
+    GabbleCapsChannelManager *manager,
+    GabbleConnection *conn,
+    GHashTable *cap)
 {
-  TpBaseConnection *base = (TpBaseConnection *) conn;
   GabblePresence *presence;
   TubesCapabilities *caps;
   const gchar *channel_type;
@@ -868,11 +867,7 @@ gabble_private_tubes_factory_add_cap (GabbleCapsChannelManager *manager,
         TP_IFACE_CHANNEL ".TargetHandleType", NULL) != TP_HANDLE_TYPE_CONTACT)
     return;
 
-  if (handle == base->self_handle)
-    presence = conn->self_presence;
-  else
-    presence = gabble_presence_cache_get (conn->presence_cache, handle);
-
+  presence = conn->self_presence;
   g_assert (presence != NULL);
 
   if (presence->per_channel_manager_caps == NULL)
@@ -888,9 +883,8 @@ gabble_private_tubes_factory_add_cap (GabbleCapsChannelManager *manager,
           g_free, gabble_private_tubes_factory_free_feat);
       g_hash_table_insert (presence->per_channel_manager_caps, manager, caps);
 
-      if (handle == base->self_handle)
-        /* We always support generic tubes caps */
-        caps->tubes_supported = TRUE;
+      /* We always support generic tubes caps */
+      caps->tubes_supported = TRUE;
     }
 
   if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE))
@@ -1399,5 +1393,5 @@ caps_channel_manager_iface_init (gpointer g_iface,
   iface->copy_caps = gabble_private_tubes_factory_copy_caps;
   iface->update_caps = gabble_private_tubes_factory_update_caps;
   iface->caps_diff = gabble_private_tubes_factory_caps_diff;
-  iface->add_cap = gabble_private_tubes_factory_add_cap;
+  iface->add_self_capability = gabble_private_tubes_factory_add_self_capability;
 }
-- 
1.5.6.5




More information about the telepathy-commits mailing list