[Telepathy-commits] [telepathy-gabble/master] Proper cast to fix GLib-GObject-WARNING and im-factory.c implements GabbleCapsChannelManager correctly

Alban Crequy alban.crequy at collabora.co.uk
Fri Dec 5 09:42:34 PST 2008


---
 src/connection.c     |   26 +++++++++++++++-----------
 src/im-factory.c     |    6 +++---
 src/presence-cache.c |   12 ++++++++----
 3 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index ca9cf5f..4f886af 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -2144,15 +2144,14 @@ gabble_connection_get_handle_contact_capabilities (GabbleConnection *self,
 
   for (i = 0; i < self->channel_managers->len; i++)
     {
-      GabbleCapsChannelManager *manager = GABBLE_CAPS_CHANNEL_MANAGER (
-          g_ptr_array_index (self->channel_managers, i));
+      gpointer manager = g_ptr_array_index (self->channel_managers, i);
 
       /* some channel managers does not implement the capability interface */
       if (!GABBLE_IS_CAPS_CHANNEL_MANAGER (manager))
         continue;
 
-      gabble_caps_channel_manager_get_contact_capabilities (manager, self,
-          handle, arr);
+      gabble_caps_channel_manager_get_contact_capabilities (
+          GABBLE_CAPS_CHANNEL_MANAGER (manager), self, handle, arr);
     }
 }
 
@@ -2169,8 +2168,7 @@ _emit_contact_capabilities_changed (GabbleConnection *conn,
 
   for (i = 0; i < conn->channel_managers->len; i++)
     {
-      GabbleCapsChannelManager *manager = GABBLE_CAPS_CHANNEL_MANAGER (
-          g_ptr_array_index (conn->channel_managers, i));
+      gpointer manager = g_ptr_array_index (conn->channel_managers, i);
       gpointer per_channel_factory_caps_old = NULL;
       gpointer per_channel_factory_caps_new = NULL;
 
@@ -2183,8 +2181,9 @@ _emit_contact_capabilities_changed (GabbleConnection *conn,
       if (new_caps != NULL)
         per_channel_factory_caps_new = g_hash_table_lookup (new_caps, manager);
 
-      if (gabble_caps_channel_manager_capabilities_diff (manager, handle,
-          per_channel_factory_caps_old, per_channel_factory_caps_new))
+      if (gabble_caps_channel_manager_capabilities_diff (
+            GABBLE_CAPS_CHANNEL_MANAGER (manager), handle,
+            per_channel_factory_caps_old, per_channel_factory_caps_new))
         {
           diff = TRUE;
           break;
@@ -2378,10 +2377,15 @@ gabble_connection_set_self_capabilities (
 
       for (j = 0; j < self->channel_managers->len; j++)
         {
-          GabbleCapsChannelManager *manager = GABBLE_CAPS_CHANNEL_MANAGER (
-              g_ptr_array_index (self->channel_managers, j));
+          gpointer manager = g_ptr_array_index (self->channel_managers, j);
 
-          gabble_caps_channel_manager_add_capability (manager, self,
+          /* some channel managers does not implement the capability interface
+           */
+          if (!GABBLE_IS_CAPS_CHANNEL_MANAGER (manager))
+            continue;
+
+          gabble_caps_channel_manager_add_capability (
+              GABBLE_CAPS_CHANNEL_MANAGER (manager), self,
               base->self_handle, cap_to_add);
         }
     }
diff --git a/src/im-factory.c b/src/im-factory.c
index 3496615..1f9374e 100644
--- a/src/im-factory.c
+++ b/src/im-factory.c
@@ -46,10 +46,10 @@ static void channel_manager_iface_init (gpointer, gpointer);
 static void caps_channel_manager_iface_init (gpointer, gpointer);
 
 G_DEFINE_TYPE_WITH_CODE (GabbleImFactory, gabble_im_factory, G_TYPE_OBJECT,
-    G_IMPLEMENT_INTERFACE (GABBLE_TYPE_CAPS_CHANNEL_MANAGER,
-      caps_channel_manager_iface_init);
     G_IMPLEMENT_INTERFACE (GABBLE_TYPE_CHANNEL_MANAGER,
-      channel_manager_iface_init));
+      channel_manager_iface_init);
+    G_IMPLEMENT_INTERFACE (GABBLE_TYPE_CAPS_CHANNEL_MANAGER,
+      caps_channel_manager_iface_init));
 
 /* properties */
 enum
diff --git a/src/presence-cache.c b/src/presence-cache.c
index 5248615..551e5fb 100644
--- a/src/presence-cache.c
+++ b/src/presence-cache.c
@@ -859,13 +859,17 @@ _caps_disco_cb (GabbleDisco *disco,
   for (j = 0; j < priv->conn->channel_managers->len; j++)
     {
       gpointer *factory_caps;
-      GabbleCapsChannelManager *manager = GABBLE_CAPS_CHANNEL_MANAGER (
-          g_ptr_array_index (priv->conn->channel_managers, j));
+      gpointer manager = g_ptr_array_index (priv->conn->channel_managers, j);
+
+      /* some channel managers does not implement the capability interface */
+      if (!GABBLE_IS_CAPS_CHANNEL_MANAGER (manager))
+        continue;
 
       factory_caps = gabble_caps_channel_manager_parse_capabilities
-          (manager, query_result->children);
+          (GABBLE_CAPS_CHANNEL_MANAGER (manager), query_result->children);
       if (factory_caps != NULL)
-        g_hash_table_insert (per_channel_factory_caps, manager, factory_caps);
+        g_hash_table_insert (per_channel_factory_caps,
+            GABBLE_CAPS_CHANNEL_MANAGER (manager), factory_caps);
     }
 
   /* parsing for Connection.Interface.Capabilities*/
-- 
1.5.6.5




More information about the Telepathy-commits mailing list