[Telepathy-commits] [telepathy-gabble/master] src/private-tubes-factory.c: Remove the old "channel factory" code. Now it is a channel manager thanks to TpChannelManager

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


---
 src/private-tubes-factory.c |   56 ++++++++++--------------------------------
 1 files changed, 14 insertions(+), 42 deletions(-)

diff --git a/src/private-tubes-factory.c b/src/private-tubes-factory.c
index 033f320..26cea49 100644
--- a/src/private-tubes-factory.c
+++ b/src/private-tubes-factory.c
@@ -26,9 +26,9 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 #include <loudmouth/loudmouth.h>
-#include <telepathy-glib/channel-factory-iface.h>
 #include <telepathy-glib/channel-manager.h>
 #include <telepathy-glib/dbus.h>
+#include <telepathy-glib/exportable-channel.h>
 #include <telepathy-glib/interfaces.h>
 #include <telepathy-glib/util.h>
 
@@ -57,8 +57,6 @@ static LmHandlerResult private_tubes_factory_msg_tube_cb (
     LmMessageHandler *handler, LmConnection *lmconn, LmMessage *msg,
     gpointer user_data);
 
-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);
 
@@ -68,9 +66,7 @@ G_DEFINE_TYPE_WITH_CODE (GabblePrivateTubesFactory,
     G_IMPLEMENT_INTERFACE (TP_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));
+      caps_channel_manager_iface_init));
 
 /* properties */
 enum
@@ -349,9 +345,6 @@ new_tubes_channel (GabblePrivateTubesFactory *fac,
 
   g_hash_table_insert (priv->channels, GUINT_TO_POINTER (handle), chan);
 
-  tp_channel_factory_iface_emit_new_channel (fac, TP_CHANNEL_IFACE (chan),
-      request_token);
-
   g_free (object_path);
 
   if (request_token != NULL)
@@ -805,9 +798,6 @@ _foreach_slave (gpointer key,
   struct _ForeachData *data = (struct _ForeachData *) user_data;
   TpExportableChannel *chan = TP_EXPORTABLE_CHANNEL (value);
 
-  /* assert that it has both interfaces, for now */
-  g_assert (TP_IS_CHANNEL_IFACE (chan));
-
   /* Add channels of type Channel.Type.Tubes */
   data->foreach (chan, data->user_data);
 
@@ -833,18 +823,6 @@ gabble_private_tubes_factory_foreach_channel (TpChannelManager *manager,
   g_hash_table_foreach (priv->channels, _foreach_slave, &data);
 }
 
-static TpChannelFactoryRequestStatus
-gabble_private_tubes_factory_iface_request (TpChannelFactoryIface *iface,
-                                    const gchar *chan_type,
-                                    TpHandleType handle_type,
-                                    guint handle,
-                                    gpointer request,
-                                    TpChannelIface **ret,
-                                    GError **error)
-{
-  return TP_CHANNEL_FACTORY_REQUEST_STATUS_NOT_IMPLEMENTED;
-}
-
 void
 gabble_private_tubes_factory_handle_si_tube_request (
     GabblePrivateTubesFactory *self,
@@ -978,19 +956,6 @@ gabble_private_tubes_factory_new (GabbleConnection *conn)
       NULL);
 }
 
-static void
-gabble_private_tubes_factory_iface_init (gpointer g_iface,
-                                 gpointer iface_data)
-{
-  TpChannelFactoryIfaceClass *klass = (TpChannelFactoryIfaceClass *) g_iface;
-
-  klass->close_all =
-      (TpChannelFactoryIfaceProc) gabble_private_tubes_factory_close_all;
-  klass->foreach = (TpChannelFactoryIfaceForeachImpl)
-      gabble_private_tubes_factory_foreach_channel;
-  klass->request = gabble_private_tubes_factory_iface_request;
-}
-
 
 static const gchar * const tubes_channel_fixed_properties[] = {
     TP_IFACE_CHANNEL ".ChannelType",
@@ -1141,12 +1106,15 @@ gabble_private_tubes_factory_requestotron (GabblePrivateTubesFactory *self,
     }
   else
     {
+      gboolean channel_was_existing = (channel != NULL);
       GabbleTubeIface *new_channel;
 
       if (channel == NULL)
         {
+          /* Don't give the request_token to new_tubes_channel() because we
+           * must emit NewChannels with 2 channels together */
           channel = new_tubes_channel (self, handle, base_conn->self_handle,
-              request_token);
+              NULL);
         }
       g_assert (channel != NULL);
 
@@ -1154,19 +1122,23 @@ gabble_private_tubes_factory_requestotron (GabblePrivateTubesFactory *self,
           request_properties, require_new);
       if (new_channel != NULL)
         {
+          GHashTable *channels;
           GSList *request_tokens;
 
-          tp_channel_factory_iface_emit_new_channel (self,
-              TP_CHANNEL_IFACE (new_channel), request_token);
+          channels = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+              NULL, NULL);
+          if (!channel_was_existing)
+            g_hash_table_insert (channels, channel, NULL);
 
           if (request_token != NULL)
             request_tokens = g_slist_prepend (NULL, request_token);
           else
             request_tokens = NULL;
 
-          tp_channel_manager_emit_new_channel (self,
-              TP_EXPORTABLE_CHANNEL (new_channel), request_tokens);
+          g_hash_table_insert (channels, new_channel, request_tokens);
+          tp_channel_manager_emit_new_channels (self, channels);
 
+          g_hash_table_destroy (channels);
           g_slist_free (request_tokens);
         }
       else
-- 
1.5.6.5




More information about the Telepathy-commits mailing list