[Telepathy-commits] [telepathy-gabble/master] Split GabbleChannelManager in 2 parts: GabbleChannelManager (will become TpChannelManager in tp-glib) and GabbleCapsChannelManager (will stay in tp-gabble)

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


---
 src/Makefile.am             |    2 +
 src/capabilities.c          |   10 ++-
 src/caps-channel-manager.c  |  194 +++++++++++++++++++++++++++++++++++++++++++
 src/caps-channel-manager.h  |  140 +++++++++++++++++++++++++++++++
 src/channel-manager.c       |  130 -----------------------------
 src/channel-manager.h       |   75 -----------------
 src/connection.c            |   23 ++++--
 src/im-factory.c            |   16 +++-
 src/presence-cache.c        |   19 ++--
 src/private-tubes-factory.c |   52 +++++++-----
 10 files changed, 415 insertions(+), 246 deletions(-)
 create mode 100644 src/caps-channel-manager.c
 create mode 100644 src/caps-channel-manager.h

diff --git a/src/Makefile.am b/src/Makefile.am
index da0b4bd..287e872 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,6 +33,8 @@ libgabble_convenience_la_our_sources = \
     capabilities.c \
     caps-hash.h \
     caps-hash.c \
+    caps-channel-manager.h \
+    caps-channel-manager.c \
     channel-manager.h \
     channel-manager.c \
     conn-aliasing.h \
diff --git a/src/capabilities.c b/src/capabilities.c
index 811540c..201a404 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -20,10 +20,13 @@
 
 #include "config.h"
 #include "capabilities.h"
+
+#include <telepathy-glib/interfaces.h>
+
+#include "caps-channel-manager.h"
 #include "channel-manager.h"
 #include "namespaces.h"
 #include "presence-cache.h"
-#include <telepathy-glib/interfaces.h>
 #include "media-channel.h"
 
 static const Feature self_advertised_features[] =
@@ -57,7 +60,7 @@ capabilities_get_features (GabblePresenceCapabilities caps,
                            GHashTable *per_channel_factory_caps)
 {
   GHashTableIter channel_manager_iter;
-  GabbleChannelManager *manager;
+  GabbleCapsChannelManager *manager;
   gpointer cap;
   GSList *features = NULL;
   const Feature *i;
@@ -72,7 +75,8 @@ capabilities_get_features (GabblePresenceCapabilities caps,
       while (g_hash_table_iter_next (&channel_manager_iter,
                  (gpointer *) &manager, &cap))
         {
-          gabble_channel_manager_get_feature_list (manager, cap, &features);
+          gabble_caps_channel_manager_get_feature_list (manager, cap,
+              &features);
         }
     }
 
diff --git a/src/caps-channel-manager.c b/src/caps-channel-manager.c
new file mode 100644
index 0000000..6fd7c6a
--- /dev/null
+++ b/src/caps-channel-manager.c
@@ -0,0 +1,194 @@
+/*
+ * caps-channel-manager.c - interface holding capabilities functions for
+ * channel managers
+ *
+ * Copyright (C) 2008 Collabora Ltd.
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "caps-channel-manager.h"
+
+#include <telepathy-glib/dbus.h>
+
+#include "channel-manager.h"
+#include "exportable-channel.h"
+
+GType
+gabble_caps_channel_manager_get_type (void)
+{
+  static GType type = 0;
+
+  if (G_UNLIKELY (type == 0))
+    {
+      static const GTypeInfo info = {
+        sizeof (GabbleCapsChannelManagerIface),
+        NULL,   /* base_init */
+        NULL,   /* base_finalize */
+        NULL,   /* class_init */
+        NULL,   /* class_finalize */
+        NULL,   /* class_data */
+        0,
+        0,      /* n_preallocs */
+        NULL    /* instance_init */
+      };
+
+      type = g_type_register_static (G_TYPE_INTERFACE,
+          "GabbleCapsChannelManager", &info, 0);
+
+      g_type_interface_add_prerequisite (type, GABBLE_TYPE_CHANNEL_MANAGER);
+    }
+
+  return type;
+}
+
+/* Virtual-method wrappers */
+
+void gabble_caps_channel_manager_get_contact_capabilities (
+    GabbleCapsChannelManager *caps_manager,
+    GabbleConnection *conn,
+    TpHandle handle,
+    GPtrArray *arr)
+{
+  GabbleCapsChannelManagerIface *iface =
+    GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
+  GabbleCapsChannelManagerGetContactCapsFunc method = iface->get_contact_caps;
+
+  if (method != NULL)
+    {
+      method (caps_manager, conn, handle, arr);
+    }
+  /* ... else assume there is not caps for this kind of channels */
+}
+
+void gabble_caps_channel_manager_get_feature_list (
+    GabbleCapsChannelManager *caps_manager,
+    gpointer specific_caps,
+    GSList **features)
+{
+  GabbleCapsChannelManagerIface *iface =
+    GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
+  GabbleCapsChannelManagerGetFeatureListFunc method = iface->get_feature_list;
+
+  if (method != NULL)
+    {
+      method (caps_manager, specific_caps, features);
+    }
+  /* ... else nothing to do */
+}
+
+gpointer gabble_caps_channel_manager_parse_capabilities (
+    GabbleCapsChannelManager *caps_manager,
+    LmMessageNode *child)
+{
+  GabbleCapsChannelManagerIface *iface =
+    GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
+  GabbleCapsChannelManagerParseCapsFunc method = iface->parse_caps;
+
+  if (method != NULL)
+    {
+      return method (caps_manager, child);
+    }
+  /* ... else assume there is not caps for this kind of channels */
+  return NULL;
+}
+
+void gabble_caps_channel_manager_free_capabilities (
+    GabbleCapsChannelManager *caps_manager,
+    gpointer specific_caps)
+{
+  GabbleCapsChannelManagerIface *iface =
+    GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
+  GabbleCapsChannelManagerFreeCapsFunc method = iface->free_caps;
+
+  if (method != NULL)
+    {
+      method (caps_manager, specific_caps);
+    }
+  /* ... else assume there is no need to free */
+}
+
+void gabble_caps_channel_manager_copy_capabilities (
+    GabbleCapsChannelManager *caps_manager,
+    gpointer *specific_caps_out,
+    gpointer specific_caps_in)
+{
+  GabbleCapsChannelManagerIface *iface =
+    GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
+  GabbleCapsChannelManagerCopyCapsFunc method = iface->copy_caps;
+
+  if (method != NULL)
+    {
+      method (caps_manager, specific_caps_out, specific_caps_in);
+    }
+  else
+    *specific_caps_out = NULL;
+}
+
+void gabble_caps_channel_manager_update_capabilities (
+    GabbleCapsChannelManager *caps_manager,
+    gpointer specific_caps_out,
+    gpointer specific_caps_in)
+{
+  GabbleCapsChannelManagerIface *iface =
+    GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
+  GabbleCapsChannelManagerCopyCapsFunc method = iface->update_caps;
+
+  if (method != NULL)
+    {
+      method (caps_manager, specific_caps_out, specific_caps_in);
+    }
+  /* ... else, do what? */
+}
+
+gboolean gabble_caps_channel_manager_capabilities_diff (
+    GabbleCapsChannelManager *caps_manager,
+    TpHandle handle,
+    gpointer specific_old_caps,
+    gpointer specific_new_caps)
+{
+  GabbleCapsChannelManagerIface *iface =
+    GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE (caps_manager);
+  GabbleCapsChannelManagerCapsDiffFunc method = iface->caps_diff;
+
+  if (method != NULL)
+    {
+      return method (caps_manager, handle, specific_old_caps,
+          specific_new_caps);
+    }
+  /* ... else, nothing to do */
+  return FALSE;
+}
+
+void
+gabble_caps_channel_manager_add_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;
+
+  if (method != NULL)
+    {
+      method (caps_manager, conn, handle, cap);
+    }
+  /* ... else, nothing to do */
+}
+
diff --git a/src/caps-channel-manager.h b/src/caps-channel-manager.h
new file mode 100644
index 0000000..eac7981
--- /dev/null
+++ b/src/caps-channel-manager.h
@@ -0,0 +1,140 @@
+/*
+ * caps-channel-manager.h - interface holding capabilities functions for
+ * channel managers
+ *
+ * Copyright (C) 2008 Collabora Ltd.
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef GABBLE_CAPS_CHANNEL_MANAGER_H
+#define GABBLE_CAPS_CHANNEL_MANAGER_H
+
+#include <glib-object.h>
+#include <loudmouth/loudmouth.h>
+#include <telepathy-glib/handle.h>
+
+#include "exportable-channel.h"
+#include "types.h"
+
+G_BEGIN_DECLS
+
+#define GABBLE_TYPE_CAPS_CHANNEL_MANAGER \
+  (gabble_caps_channel_manager_get_type ())
+
+#define GABBLE_CAPS_CHANNEL_MANAGER(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+  GABBLE_TYPE_CAPS_CHANNEL_MANAGER, GabbleCapsChannelManager))
+
+#define GABBLE_IS_CAPS_CHANNEL_MANAGER(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+  GABBLE_TYPE_CAPS_CHANNEL_MANAGER))
+
+#define GABBLE_CAPS_CHANNEL_MANAGER_GET_INTERFACE(obj) \
+  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \
+  GABBLE_TYPE_CAPS_CHANNEL_MANAGER, GabbleCapsChannelManagerIface))
+
+typedef struct _GabbleCapsChannelManager GabbleCapsChannelManager;
+typedef struct _GabbleCapsChannelManagerIface GabbleCapsChannelManagerIface;
+
+
+/* virtual methods */
+
+/* May be moved to TpChannelManager later */
+typedef void (*GabbleCapsChannelManagerGetContactCapsFunc) (
+    GabbleCapsChannelManager *manager, GabbleConnection *conn, TpHandle handle,
+    GPtrArray *arr);
+
+typedef void (*GabbleCapsChannelManagerAddCapFunc) (
+    GabbleCapsChannelManager *manager, GabbleConnection *conn, TpHandle handle,
+    GHashTable *cap);
+
+/* Specific to Gabble */
+typedef void (*GabbleCapsChannelManagerGetFeatureListFunc) (
+    GabbleCapsChannelManager *manager, gpointer specific_caps,
+    GSList **features);
+
+typedef gpointer (*GabbleCapsChannelManagerParseCapsFunc) (
+    GabbleCapsChannelManager *manager, LmMessageNode *children);
+
+typedef void (*GabbleCapsChannelManagerFreeCapsFunc) (
+    GabbleCapsChannelManager *manager, gpointer specific_caps);
+
+typedef void (*GabbleCapsChannelManagerCopyCapsFunc) (
+    GabbleCapsChannelManager *manager, gpointer *specific_caps_out,
+    gpointer specific_caps_in);
+
+typedef void (*GabbleCapsChannelManagerUpdateCapsFunc) (
+    GabbleCapsChannelManager *manager, gpointer *specific_caps_out,
+    gpointer specific_caps_in);
+
+typedef gboolean (*GabbleCapsChannelManagerCapsDiffFunc) (
+    GabbleCapsChannelManager *manager, TpHandle handle,
+    gpointer specific_old_caps, gpointer specific_new_caps);
+
+
+void gabble_caps_channel_manager_get_contact_capabilities (
+    GabbleCapsChannelManager *manager, GabbleConnection *conn, TpHandle handle,
+    GPtrArray *arr);
+
+void gabble_caps_channel_manager_get_feature_list (
+    GabbleCapsChannelManager *manager, gpointer specific_caps,
+    GSList **features);
+
+gpointer gabble_caps_channel_manager_parse_capabilities (
+    GabbleCapsChannelManager *manager, LmMessageNode *children);
+
+void gabble_caps_channel_manager_free_capabilities (GabbleCapsChannelManager *manager,
+    gpointer specific_caps);
+
+void gabble_caps_channel_manager_copy_capabilities (GabbleCapsChannelManager *manager,
+    gpointer *specific_caps_out, gpointer specific_caps_in);
+
+void gabble_caps_channel_manager_update_capabilities (
+    GabbleCapsChannelManager *manager, gpointer specific_caps_out,
+    gpointer specific_caps_in);
+
+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,
+    GHashTable *cap);
+
+
+struct _GabbleCapsChannelManagerIface {
+    GTypeInterface parent;
+
+    GabbleCapsChannelManagerGetContactCapsFunc get_contact_caps;
+    GabbleCapsChannelManagerAddCapFunc add_cap;
+
+    GabbleCapsChannelManagerGetFeatureListFunc get_feature_list;
+    GabbleCapsChannelManagerParseCapsFunc parse_caps;
+    GabbleCapsChannelManagerFreeCapsFunc free_caps;
+    GabbleCapsChannelManagerCopyCapsFunc copy_caps;
+    GabbleCapsChannelManagerUpdateCapsFunc update_caps;
+    GabbleCapsChannelManagerCapsDiffFunc caps_diff;
+
+    GCallback _future[8];
+    gpointer priv;
+};
+
+GType gabble_caps_channel_manager_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/src/channel-manager.c b/src/channel-manager.c
index 06a504e..30d5bf2 100644
--- a/src/channel-manager.c
+++ b/src/channel-manager.c
@@ -346,136 +346,6 @@ gabble_channel_manager_emit_request_failed_printf (gpointer instance,
 
 /* Virtual-method wrappers */
 
-void gabble_channel_manager_get_contact_capabilities (
-    GabbleChannelManager *manager,
-    GabbleConnection *conn,
-    TpHandle handle,
-    GPtrArray *arr)
-{
-  GabbleChannelManagerIface *iface = GABBLE_CHANNEL_MANAGER_GET_INTERFACE (
-      manager);
-  GabbleChannelManagerGetContactCapsFunc method = iface->get_contact_caps;
-
-  if (method != NULL)
-    {
-      method (manager, conn, handle, arr);
-    }
-  /* ... else assume there is not caps for this kind of channels */
-}
-
-void gabble_channel_manager_get_feature_list (
-    GabbleChannelManager *manager,
-    gpointer specific_caps,
-    GSList **features)
-{
-  GabbleChannelManagerIface *iface = GABBLE_CHANNEL_MANAGER_GET_INTERFACE (
-      manager);
-  GabbleChannelManagerGetFeatureListFunc method = iface->get_feature_list;
-
-  if (method != NULL)
-    {
-      method (manager, specific_caps, features);
-    }
-  /* ... else nothing to do */
-}
-
-gpointer gabble_channel_manager_parse_capabilities (
-    GabbleChannelManager *manager,
-    LmMessageNode *child)
-{
-  GabbleChannelManagerIface *iface = GABBLE_CHANNEL_MANAGER_GET_INTERFACE (
-      manager);
-  GabbleChannelManagerParseCapsFunc method = iface->parse_caps;
-
-  if (method != NULL)
-    {
-      return method (manager, child);
-    }
-  /* ... else assume there is not caps for this kind of channels */
-  return NULL;
-}
-
-void gabble_channel_manager_free_capabilities (GabbleChannelManager *manager,
-                                               gpointer specific_caps)
-{
-  GabbleChannelManagerIface *iface = GABBLE_CHANNEL_MANAGER_GET_INTERFACE (
-      manager);
-  GabbleChannelManagerFreeCapsFunc method = iface->free_caps;
-
-  if (method != NULL)
-    {
-      method (manager, specific_caps);
-    }
-  /* ... else assume there is no need to free */
-}
-
-void gabble_channel_manager_copy_capabilities (GabbleChannelManager *manager,
-                                               gpointer *specific_caps_out,
-                                               gpointer specific_caps_in)
-{
-  GabbleChannelManagerIface *iface = GABBLE_CHANNEL_MANAGER_GET_INTERFACE (
-      manager);
-  GabbleChannelManagerCopyCapsFunc method = iface->copy_caps;
-
-  if (method != NULL)
-    {
-      method (manager, specific_caps_out, specific_caps_in);
-    }
-  else
-    *specific_caps_out = NULL;
-}
-
-void gabble_channel_manager_update_capabilities (
-    GabbleChannelManager *manager,
-    gpointer specific_caps_out,
-    gpointer specific_caps_in)
-{
-  GabbleChannelManagerIface *iface = GABBLE_CHANNEL_MANAGER_GET_INTERFACE (
-      manager);
-  GabbleChannelManagerCopyCapsFunc method = iface->update_caps;
-
-  if (method != NULL)
-    {
-      method (manager, specific_caps_out, specific_caps_in);
-    }
-  /* ... else, do what? */
-}
-
-gboolean gabble_channel_manager_capabilities_diff (
-    GabbleChannelManager *manager,
-    TpHandle handle,
-    gpointer specific_old_caps,
-    gpointer specific_new_caps)
-{
-  GabbleChannelManagerIface *iface = GABBLE_CHANNEL_MANAGER_GET_INTERFACE (
-      manager);
-  GabbleChannelManagerCapsDiffFunc method = iface->caps_diff;
-
-  if (method != NULL)
-    {
-      return method (manager, handle, specific_old_caps, specific_new_caps);
-    }
-  /* ... else, nothing to do */
-  return FALSE;
-}
-
-void
-gabble_channel_manager_add_capability (GabbleChannelManager *manager,
-                                       GabbleConnection *conn,
-                                       TpHandle handle,
-                                       GHashTable *cap)
-{
-  GabbleChannelManagerIface *iface = GABBLE_CHANNEL_MANAGER_GET_INTERFACE (
-      manager);
-  GabbleChannelManagerAddCapFunc method = iface->add_cap;
-
-  if (method != NULL)
-    {
-      method (manager, conn, handle, cap);
-    }
-  /* ... else, nothing to do */
-}
-
 void
 gabble_channel_manager_foreach_channel (GabbleChannelManager *manager,
                                         GabbleExportableChannelFunc func,
diff --git a/src/channel-manager.h b/src/channel-manager.h
index f6cd437..959d10a 100644
--- a/src/channel-manager.h
+++ b/src/channel-manager.h
@@ -52,72 +52,6 @@ typedef struct _GabbleChannelManagerIface GabbleChannelManagerIface;
 
 /* virtual methods */
 
-/* TpChannelManager (GetContactCapabilities) */
-typedef void (*GabbleChannelManagerGetContactCapsFunc) (
-    GabbleChannelManager *manager, GabbleConnection *conn, TpHandle handle,
-    GPtrArray *arr);
-
-/* Gabble specific: send our caps, replying to disco request from contacts */
-typedef void (*GabbleChannelManagerGetFeatureListFunc) (
-    GabbleChannelManager *manager, gpointer specific_caps, GSList **features);
-
-/* Gabble specific: parse caps stanza from contacts */
-typedef gpointer (*GabbleChannelManagerParseCapsFunc) (
-    GabbleChannelManager *manager, LmMessageNode *children);
-
-/* Gabble specific */
-typedef void (*GabbleChannelManagerFreeCapsFunc) (
-    GabbleChannelManager *manager, gpointer specific_caps);
-
-/* Gabble specific */
-typedef void (*GabbleChannelManagerCopyCapsFunc) (
-    GabbleChannelManager *manager, gpointer *specific_caps_out,
-    gpointer specific_caps_in);
-
-/* Gabble specific (merging resource caps) */
-typedef void (*GabbleChannelManagerUpdateCapsFunc) (
-    GabbleChannelManager *manager, gpointer *specific_caps_out, gpointer specific_caps_in);
-
-/* Gabble specific */
-typedef gboolean (*GabbleChannelManagerCapsDiffFunc) (
-    GabbleChannelManager *manager, TpHandle handle, gpointer specific_old_caps,
-    gpointer specific_new_caps);
-
-/* TpChannelManager (SetSelfCapabilities) */
-typedef void (*GabbleChannelManagerAddCapFunc) (
-    GabbleChannelManager *manager, GabbleConnection *conn, TpHandle handle,
-    GHashTable *cap);
-
-
-void gabble_channel_manager_get_contact_capabilities (
-    GabbleChannelManager *manager, GabbleConnection *conn, TpHandle handle,
-    GPtrArray *arr);
-
-void gabble_channel_manager_get_feature_list (
-    GabbleChannelManager *manager, gpointer specific_caps, GSList **features);
-
-gpointer gabble_channel_manager_parse_capabilities (
-    GabbleChannelManager *manager, LmMessageNode *children);
-
-void gabble_channel_manager_free_capabilities (GabbleChannelManager *manager,
-    gpointer specific_caps);
-
-void gabble_channel_manager_copy_capabilities (GabbleChannelManager *manager,
-    gpointer *specific_caps_out, gpointer specific_caps_in);
-
-void gabble_channel_manager_update_capabilities (
-    GabbleChannelManager *manager, gpointer specific_caps_out,
-    gpointer specific_caps_in);
-
-gboolean gabble_channel_manager_capabilities_diff (
-    GabbleChannelManager *manager, TpHandle handle, gpointer specific_old_caps,
-    gpointer specific_new_caps);
-
-void gabble_channel_manager_add_capability (
-    GabbleChannelManager *manager, GabbleConnection *conn, TpHandle handle,
-    GHashTable *cap);
-
-
 typedef void (*GabbleChannelManagerForeachChannelFunc) (
     GabbleChannelManager *manager, GabbleExportableChannelFunc func,
     gpointer user_data);
@@ -156,15 +90,6 @@ gboolean gabble_channel_manager_request_channel (GabbleChannelManager *manager,
 struct _GabbleChannelManagerIface {
     GTypeInterface parent;
 
-    GabbleChannelManagerGetContactCapsFunc get_contact_caps;
-    GabbleChannelManagerGetFeatureListFunc get_feature_list;
-    GabbleChannelManagerParseCapsFunc parse_caps;
-    GabbleChannelManagerFreeCapsFunc free_caps;
-    GabbleChannelManagerCopyCapsFunc copy_caps;
-    GabbleChannelManagerUpdateCapsFunc update_caps;
-    GabbleChannelManagerCapsDiffFunc caps_diff;
-    GabbleChannelManagerAddCapFunc add_cap;
-
     GabbleChannelManagerForeachChannelFunc foreach_channel;
 
     GabbleChannelManagerForeachChannelClassFunc foreach_channel_class;
diff --git a/src/connection.c b/src/connection.c
index 47f2680..ca9cf5f 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -45,6 +45,7 @@
 
 #include "bytestream-factory.h"
 #include "capabilities.h"
+#include "caps-channel-manager.h"
 #include "caps-hash.h"
 #include "channel-manager.h"
 #include "conn-aliasing.h"
@@ -2143,11 +2144,15 @@ gabble_connection_get_handle_contact_capabilities (GabbleConnection *self,
 
   for (i = 0; i < self->channel_managers->len; i++)
     {
-      GabbleChannelManager *manager = GABBLE_CHANNEL_MANAGER (
+      GabbleCapsChannelManager *manager = GABBLE_CAPS_CHANNEL_MANAGER (
           g_ptr_array_index (self->channel_managers, i));
 
-      gabble_channel_manager_get_contact_capabilities (manager, self, handle,
-          arr);
+      /* 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);
     }
 }
 
@@ -2164,17 +2169,21 @@ _emit_contact_capabilities_changed (GabbleConnection *conn,
 
   for (i = 0; i < conn->channel_managers->len; i++)
     {
-      GabbleChannelManager *manager = GABBLE_CHANNEL_MANAGER (
+      GabbleCapsChannelManager *manager = GABBLE_CAPS_CHANNEL_MANAGER (
           g_ptr_array_index (conn->channel_managers, i));
       gpointer per_channel_factory_caps_old = NULL;
       gpointer per_channel_factory_caps_new = NULL;
 
+      /* some channel managers does not implement the capability interface */
+      if (!GABBLE_IS_CAPS_CHANNEL_MANAGER (manager))
+        continue;
+
       if (old_caps != NULL)
         per_channel_factory_caps_old = g_hash_table_lookup (old_caps, manager);
       if (new_caps != NULL)
         per_channel_factory_caps_new = g_hash_table_lookup (new_caps, manager);
 
-      if (gabble_channel_manager_capabilities_diff (manager, handle,
+      if (gabble_caps_channel_manager_capabilities_diff (manager, handle,
           per_channel_factory_caps_old, per_channel_factory_caps_new))
         {
           diff = TRUE;
@@ -2369,10 +2378,10 @@ gabble_connection_set_self_capabilities (
 
       for (j = 0; j < self->channel_managers->len; j++)
         {
-          GabbleChannelManager *manager = GABBLE_CHANNEL_MANAGER (
+          GabbleCapsChannelManager *manager = GABBLE_CAPS_CHANNEL_MANAGER (
               g_ptr_array_index (self->channel_managers, j));
 
-          gabble_channel_manager_add_capability (manager, self,
+          gabble_caps_channel_manager_add_capability (manager, self,
               base->self_handle, cap_to_add);
         }
     }
diff --git a/src/im-factory.c b/src/im-factory.c
index 76b233d..3496615 100644
--- a/src/im-factory.c
+++ b/src/im-factory.c
@@ -34,6 +34,7 @@
 
 #include "extensions/extensions.h"
 
+#include "caps-channel-manager.h"
 #include "channel-manager.h"
 #include "connection.h"
 #include "debug.h"
@@ -42,8 +43,11 @@
 #include "text-mixin.h"
 
 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));
 
@@ -454,7 +458,7 @@ connection_status_changed_cb (GabbleConnection *conn,
 }
 
 static void
-gabble_im_factory_get_contact_caps (GabbleChannelManager *manager,
+gabble_im_factory_get_contact_caps (GabbleCapsChannelManager *manager,
                                     GabbleConnection *conn,
                                     TpHandle handle,
                                     GPtrArray *arr)
@@ -655,9 +659,17 @@ channel_manager_iface_init (gpointer g_iface,
 {
   GabbleChannelManagerIface *iface = g_iface;
 
-  iface->get_contact_caps = gabble_im_factory_get_contact_caps;
   iface->foreach_channel = gabble_im_factory_foreach_channel;
   iface->foreach_channel_class = gabble_im_factory_foreach_channel_class;
   iface->create_channel = gabble_im_factory_create_channel;
   iface->request_channel = gabble_im_factory_request_channel;
 }
+
+static void
+caps_channel_manager_iface_init (gpointer g_iface,
+                                 gpointer iface_data)
+{
+  GabbleCapsChannelManagerIface *iface = g_iface;
+
+  iface->get_contact_caps = gabble_im_factory_get_contact_caps;
+}
diff --git a/src/presence-cache.c b/src/presence-cache.c
index 4618a6e..5248615 100644
--- a/src/presence-cache.c
+++ b/src/presence-cache.c
@@ -37,6 +37,7 @@
 
 #define DEBUG_FLAG GABBLE_DEBUG_PRESENCE
 
+#include "caps-channel-manager.h"
 #include "caps-hash.h"
 #include "channel-manager.h"
 #include "debug.h"
@@ -710,8 +711,8 @@ _parse_cap_bundles (
 static void
 free_specific_caps_helper (gpointer key, gpointer value, gpointer user_data)
 {
-  GabbleChannelManager *manager = GABBLE_CHANNEL_MANAGER (key);
-  gabble_channel_manager_free_capabilities (manager, value);
+  GabbleCapsChannelManager *manager = GABBLE_CAPS_CHANNEL_MANAGER (key);
+  gabble_caps_channel_manager_free_capabilities (manager, value);
 }
 
 void
@@ -730,9 +731,9 @@ static void
 copy_specific_caps_helper (gpointer key, gpointer value, gpointer user_data)
 {
   GHashTable *table_out = user_data;
-  GabbleChannelManager *manager = GABBLE_CHANNEL_MANAGER (key);
+  GabbleCapsChannelManager *manager = GABBLE_CAPS_CHANNEL_MANAGER (key);
   gpointer out;
-  gabble_channel_manager_copy_capabilities (manager, &out, value);
+  gabble_caps_channel_manager_copy_capabilities (manager, &out, value);
   g_hash_table_insert (table_out, key, out);
 }
 
@@ -750,18 +751,18 @@ static void
 update_specific_caps_helper (gpointer key, gpointer value, gpointer user_data)
 {
   GHashTable *table_out = user_data;
-  GabbleChannelManager *manager = GABBLE_CHANNEL_MANAGER (key);
+  GabbleCapsChannelManager *manager = GABBLE_CAPS_CHANNEL_MANAGER (key);
   gpointer out;
 
   out = g_hash_table_lookup (table_out, key);
   if (out == NULL)
     {
-      gabble_channel_manager_copy_capabilities (manager, &out, value);
+      gabble_caps_channel_manager_copy_capabilities (manager, &out, value);
       g_hash_table_insert (table_out, key, out);
     }
   else
     {
-      gabble_channel_manager_update_capabilities (manager, out, value);
+      gabble_caps_channel_manager_update_capabilities (manager, out, value);
     }
 }
 
@@ -858,10 +859,10 @@ _caps_disco_cb (GabbleDisco *disco,
   for (j = 0; j < priv->conn->channel_managers->len; j++)
     {
       gpointer *factory_caps;
-      GabbleChannelManager *manager = GABBLE_CHANNEL_MANAGER (
+      GabbleCapsChannelManager *manager = GABBLE_CAPS_CHANNEL_MANAGER (
           g_ptr_array_index (priv->conn->channel_managers, j));
 
-      factory_caps = gabble_channel_manager_parse_capabilities
+      factory_caps = gabble_caps_channel_manager_parse_capabilities
           (manager, query_result->children);
       if (factory_caps != NULL)
         g_hash_table_insert (per_channel_factory_caps, manager, factory_caps);
diff --git a/src/private-tubes-factory.c b/src/private-tubes-factory.c
index d674cf8..6a186f3 100644
--- a/src/private-tubes-factory.c
+++ b/src/private-tubes-factory.c
@@ -35,6 +35,7 @@
 
 #define DEBUG_FLAG GABBLE_DEBUG_TUBES
 
+#include "caps-channel-manager.h"
 #include "channel-manager.h"
 #include "capabilities.h"
 #include "connection.h"
@@ -59,12 +60,15 @@ static LmHandlerResult private_tubes_factory_msg_tube_cb (
 static void gabble_private_tubes_factory_iface_init (gpointer g_iface,
     gpointer iface_data);
 static void channel_manager_iface_init (gpointer, gpointer);
+static void caps_channel_manager_iface_init (gpointer, gpointer);
 
 G_DEFINE_TYPE_WITH_CODE (GabblePrivateTubesFactory,
     gabble_private_tubes_factory,
     G_TYPE_OBJECT,
     G_IMPLEMENT_INTERFACE (GABBLE_TYPE_CHANNEL_MANAGER,
       channel_manager_iface_init);
+    G_IMPLEMENT_INTERFACE (GABBLE_TYPE_CAPS_CHANNEL_MANAGER,
+      caps_channel_manager_iface_init);
     G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_FACTORY_IFACE,
         gabble_private_tubes_factory_iface_init));
 
@@ -446,10 +450,11 @@ add_service_to_array (gchar *service,
 }
 
 static void
-gabble_private_tubes_factory_get_contact_caps (GabbleChannelManager *manager,
-                                               GabbleConnection *conn,
-                                               TpHandle handle,
-                                               GPtrArray *arr)
+gabble_private_tubes_factory_get_contact_caps (
+    GabbleCapsChannelManager *manager,
+    GabbleConnection *conn,
+    TpHandle handle,
+    GPtrArray *arr)
 {
   TpBaseConnection *base = (TpBaseConnection *) conn;
   TubesCapabilities *caps;
@@ -501,9 +506,10 @@ gabble_private_tubes_factory_get_contact_caps (GabbleChannelManager *manager,
 }
 
 static void
-gabble_private_tubes_factory_get_feature_list (GabbleChannelManager *manager,
-                                               gpointer specific_caps,
-                                               GSList **features)
+gabble_private_tubes_factory_get_feature_list (
+    GabbleCapsChannelManager *manager,
+    gpointer specific_caps,
+    GSList **features)
 {
   TubesCapabilities *caps = specific_caps;
   GHashTableIter iter;
@@ -527,7 +533,7 @@ gabble_private_tubes_factory_get_feature_list (GabbleChannelManager *manager,
 
 static gpointer
 gabble_private_tubes_factory_parse_caps (
-    GabbleChannelManager *manager,
+    GabbleCapsChannelManager *manager,
     LmMessageNode *children)
 {
   LmMessageNode *child;
@@ -577,7 +583,7 @@ gabble_private_tubes_factory_parse_caps (
 
 static void
 gabble_private_tubes_factory_free_caps (
-    GabbleChannelManager *manager,
+    GabbleCapsChannelManager *manager,
     gpointer data)
 {
  TubesCapabilities *caps = data;
@@ -597,7 +603,7 @@ copy_caps_helper (gpointer key, gpointer value, gpointer user_data)
 
 static void
 gabble_private_tubes_factory_copy_caps (
-    GabbleChannelManager *manager,
+    GabbleCapsChannelManager *manager,
     gpointer *specific_caps_out,
     gpointer specific_caps_in)
 {
@@ -619,7 +625,7 @@ gabble_private_tubes_factory_copy_caps (
 
 static void
 gabble_private_tubes_factory_update_caps (
-    GabbleChannelManager *manager,
+    GabbleCapsChannelManager *manager,
     gpointer *specific_caps_out,
     gpointer specific_caps_in)
 {
@@ -637,7 +643,7 @@ gabble_private_tubes_factory_update_caps (
 
 static gboolean
 gabble_private_tubes_factory_caps_diff (
-    GabbleChannelManager *manager,
+    GabbleCapsChannelManager *manager,
     TpHandle handle,
     gpointer specific_old_caps,
     gpointer specific_new_caps)
@@ -706,7 +712,7 @@ gabble_private_tubes_factory_caps_diff (
 }
 
 static void
-gabble_private_tubes_factory_add_cap (GabbleChannelManager *manager,
+gabble_private_tubes_factory_add_cap (GabbleCapsChannelManager *manager,
                                       GabbleConnection *conn,
                                       TpHandle handle,
                                       GHashTable *cap)
@@ -1192,6 +1198,19 @@ channel_manager_iface_init (gpointer g_iface,
 {
   GabbleChannelManagerIface *iface = g_iface;
 
+  iface->foreach_channel = gabble_private_tubes_factory_foreach_channel;
+  iface->foreach_channel_class =
+      gabble_private_tubes_factory_foreach_channel_class;
+  iface->create_channel = gabble_private_tubes_factory_create_channel;
+  iface->request_channel = gabble_private_tubes_factory_request_channel;
+}
+
+static void
+caps_channel_manager_iface_init (gpointer g_iface,
+                                 gpointer iface_data)
+{
+  GabbleCapsChannelManagerIface *iface = g_iface;
+
   iface->get_contact_caps = gabble_private_tubes_factory_get_contact_caps;
   iface->get_feature_list = gabble_private_tubes_factory_get_feature_list;
   iface->parse_caps = gabble_private_tubes_factory_parse_caps;
@@ -1200,11 +1219,4 @@ channel_manager_iface_init (gpointer g_iface,
   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->foreach_channel = gabble_private_tubes_factory_foreach_channel;
-  iface->foreach_channel_class =
-      gabble_private_tubes_factory_foreach_channel_class;
-  iface->create_channel = gabble_private_tubes_factory_create_channel;
-  iface->request_channel = gabble_private_tubes_factory_request_channel;
 }
-- 
1.5.6.5




More information about the Telepathy-commits mailing list