[Telepathy-commits] [telepathy-gabble/master] Implement request signalling in a less awkward way, with a separate signal

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Aug 20 09:38:25 PDT 2008


20080725145704-53eee-13df484a3db363338aa18d64b7a329b967e5e6bd.gz
---
 src/channel-manager.c |   19 ++++++++++++++++---
 src/im-factory.c      |   23 ++++-------------------
 2 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/src/channel-manager.c b/src/channel-manager.c
index d95b37f..0dddd98 100644
--- a/src/channel-manager.c
+++ b/src/channel-manager.c
@@ -23,11 +23,13 @@
 #include "config.h"
 #include "channel-manager.h"
 
+#include "exportable-channel.h"
 #include "gabble-signals-marshal.h"
 
 enum {
     NEW_CHANNELS,
     CHANNEL_CLOSED,
+    REQUEST_SATISFIED,
     N_SIGNALS
 };
 
@@ -44,15 +46,26 @@ channel_manager_base_init (gpointer klass)
       initialized = TRUE;
 
       /* FIXME: should probably have a better GType for a GPtrArray of
-       * ExportableChannel, and for a GPtrArray of request tokens */
+       * ExportableChannel */
+      /* New channels have been created */
       signals[NEW_CHANNELS] = g_signal_new ("new-channels",
           G_OBJECT_CLASS_TYPE (klass),
           G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
           0,
           NULL, NULL,
-          gabble_marshal_VOID__POINTER_POINTER,
-          G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
+          g_cclosure_marshal_VOID__POINTER,
+          G_TYPE_NONE, 1, G_TYPE_POINTER);
 
+      /* A QUEUED request has been satisfied by a channel */
+      signals[REQUEST_SATISFIED] = g_signal_new ("request-satisfied",
+          G_OBJECT_CLASS_TYPE (klass),
+          G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+          0,
+          NULL, NULL,
+          gabble_marshal_VOID__POINTER_OBJECT,
+          G_TYPE_NONE, 1, G_TYPE_POINTER, GABBLE_TYPE_EXPORTABLE_CHANNEL);
+
+      /* A channel has been closed */
       signals[CHANNEL_CLOSED] = g_signal_new ("channel-closed",
           G_OBJECT_CLASS_TYPE (klass),
           G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
diff --git a/src/im-factory.c b/src/im-factory.c
index be67118..8d50281 100644
--- a/src/im-factory.c
+++ b/src/im-factory.c
@@ -334,7 +334,7 @@ im_channel_closed_cb (GabbleIMChannel *chan, gpointer user_data)
           tp_channel_factory_iface_emit_new_channel (self,
               (TpChannelIface *) chan, NULL);
           g_ptr_array_add (array, chan);
-          g_signal_emit_by_name (self, "new-channels", array, NULL);
+          g_signal_emit_by_name (self, "new-channels", array);
           g_ptr_array_free (array, TRUE);
         }
     }
@@ -355,7 +355,7 @@ new_im_channel (GabbleImFactory *fac,
   TpBaseConnection *conn;
   GabbleIMChannel *chan;
   char *object_path;
-  GPtrArray *channels, *requests, *request_lists;
+  GPtrArray *channels;
 
   g_return_val_if_fail (GABBLE_IS_IM_FACTORY (fac), NULL);
   g_return_val_if_fail (handle != 0, NULL);
@@ -385,28 +385,13 @@ new_im_channel (GabbleImFactory *fac,
 
   g_free (object_path);
 
-  if (request_token != NULL)
-    {
-      requests = g_ptr_array_sized_new (1);
-      request_lists = g_ptr_array_sized_new (1);
-      g_ptr_array_add (requests, request_token);
-      g_ptr_array_add (request_lists, requests);
-    }
-  else
-    {
-      request_lists = NULL;
-    }
-
   channels = g_ptr_array_sized_new (1);
   g_ptr_array_add (channels, chan);
-  g_signal_emit_by_name (fac, "new-channels", channels, request_lists);
+  g_signal_emit_by_name (fac, "new-channels", channels);
   g_ptr_array_free (channels, TRUE);
 
   if (request_token != NULL)
-    {
-      g_ptr_array_free (requests, TRUE);
-      g_ptr_array_free (request_lists, TRUE);
-    }
+    g_signal_emit_by_name (fac, "request-satisfied", request_token, chan);
 
   return chan;
 }
-- 
1.5.6.3




More information about the Telepathy-commits mailing list