]> git.0d.be Git - empathy.git/commitdiff
Chandler and Filter only dispatch ready TpChannel
authorXavier Claessens <xclaesse@src.gnome.org>
Fri, 11 Apr 2008 13:10:54 +0000 (13:10 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 11 Apr 2008 13:10:54 +0000 (13:10 +0000)
svn path=/trunk/; revision=902

libempathy/empathy-chandler.c
libempathy/empathy-filter.c
libempathy/empathy-filter.h

index 9dd6bfdb050bec953e0f8639c718c7be6f7a3d0a..8e263771803e4edbaed084d5d2ec15196f7f6484 100644 (file)
@@ -24,8 +24,8 @@
 #include <dbus/dbus-glib.h>
 
 #include <telepathy-glib/dbus.h>
-#include <libtelepathy/tp-conn.h>
-#include <libtelepathy/tp-chan.h>
+#include <telepathy-glib/connection.h>
+#include <telepathy-glib/channel.h>
 
 #include "empathy-chandler.h"
 #include "empathy-debug.h"
@@ -62,9 +62,9 @@ empathy_chandler_class_init (EmpathyChandlerClass *klass)
                              G_SIGNAL_RUN_LAST,
                              0,
                              NULL, NULL,
-                             _empathy_marshal_VOID__OBJECT_OBJECT,
+                             g_cclosure_marshal_VOID__OBJECT,
                              G_TYPE_NONE,
-                             2, TELEPATHY_CONN_TYPE, TELEPATHY_CHAN_TYPE);
+                             1, TP_TYPE_CHANNEL);
 }
 
 static void
@@ -126,32 +126,25 @@ empathy_chandler_handle_channel (EmpathyChandler  *chandler,
                                 guint             handle,
                                 GError          **error)
 {
-       TpChan *tp_chan;
-       TpConn *tp_conn;
-
-       tp_conn = tp_conn_new_without_connect (tp_get_bus (),
-                                              bus_name,
-                                              connection,
-                                              NULL,
-                                              error);
-       if (!tp_conn) {
-               return FALSE;
+       TpChannel           *chan;
+       TpConnection        *conn;
+       static TpDBusDaemon *daemon = NULL;
+
+       if (!daemon) {
+               daemon = tp_dbus_daemon_new (tp_get_bus ());
        }
 
-       tp_chan = tp_chan_new (tp_get_bus(),
-                              bus_name,
-                              channel,
-                              channel_type,
-                              handle_type,
-                              handle);
+       conn = tp_connection_new (daemon, bus_name, connection, NULL);
+       chan = tp_channel_new (conn, channel, channel_type, handle_type, handle, NULL);
+       tp_channel_run_until_ready (chan, NULL, NULL);
 
        empathy_debug (DEBUG_DOMAIN, "New channel to be handled: "
                                     "type=%s handle=%d",
                                     channel_type, handle);
-       g_signal_emit (chandler, signals[NEW_CHANNEL], 0, tp_conn, tp_chan);
+       g_signal_emit (chandler, signals[NEW_CHANNEL], 0, chan);
 
-       g_object_unref (tp_chan);
-       g_object_unref (tp_conn);
+       g_object_unref (chan);
+       g_object_unref (conn);
 
        return TRUE;
 }
index e5e31235d059f45460ee2a74ff7b3e71ab355a38..84dd4eb66e2c75fbfaa389be660c599bcb206a86 100644 (file)
 
 #include <config.h>
 
-#include <dbus/dbus-glib.h>
-
 #include <telepathy-glib/dbus.h>
-#include <libtelepathy/tp-conn.h>
+#include <telepathy-glib/connection.h>
 
 #include "empathy-filter.h"
 #include "empathy-debug.h"
@@ -78,9 +76,9 @@ empathy_filter_class_init (EmpathyFilterClass *klass)
                              G_SIGNAL_RUN_LAST,
                              0,
                              NULL, NULL,
-                             _empathy_marshal_VOID__OBJECT_OBJECT,
+                             g_cclosure_marshal_VOID__OBJECT,
                              G_TYPE_NONE,
-                             2, TELEPATHY_CONN_TYPE, TELEPATHY_CHAN_TYPE);
+                             1, TP_TYPE_CHANNEL);
 
        signals[PROCESS] =
                g_signal_new ("process",
@@ -177,24 +175,24 @@ empathy_filter_new (const gchar *bus_name,
 
 void
 empathy_filter_process (EmpathyFilter *filter,
-                       TpChan        *tp_chan,
+                       TpChannel     *channel,
                        gboolean       process)
 {
        EmpathyFilterPriv *priv;
        guint              id;
 
        g_return_if_fail (EMPATHY_IS_FILTER (filter));
-       g_return_if_fail (TELEPATHY_IS_CHAN (tp_chan));
+       g_return_if_fail (TP_IS_CHANNEL (channel));
 
        priv = GET_PRIV (filter);
 
-       id = GPOINTER_TO_UINT (g_hash_table_lookup (priv->table, tp_chan));
+       id = GPOINTER_TO_UINT (g_hash_table_lookup (priv->table, channel));
        g_return_if_fail (id != 0);
 
        empathy_debug (DEBUG_DOMAIN, "Processing channel id %d: %s",
                       id, process ? "Yes" : "No");
        g_signal_emit (filter, signals[PROCESS], 0, id, process);
-       g_hash_table_remove (priv->table, tp_chan);
+       g_hash_table_remove (priv->table, channel);
 }
 
 static gboolean
@@ -208,37 +206,30 @@ empathy_filter_filter_channel (EmpathyFilter  *filter,
                               guint           id,
                               GError        **error)
 {
-       EmpathyFilterPriv *priv;
-       TpChan            *tp_chan;
-       TpConn            *tp_conn;
+       EmpathyFilterPriv   *priv;
+       TpChannel           *chan;
+       TpConnection        *conn;
+       static TpDBusDaemon *daemon = NULL;
 
        priv = GET_PRIV (filter);
 
-       tp_conn = tp_conn_new_without_connect (tp_get_bus (),
-                                              bus_name,
-                                              connection,
-                                              NULL,
-                                              error);
-       if (!tp_conn) {
-               return FALSE;
+       if (!daemon) {
+               daemon = tp_dbus_daemon_new (tp_get_bus ());
        }
 
+       conn = tp_connection_new (daemon, bus_name, connection, NULL);
+       chan = tp_channel_new (conn, channel, channel_type, handle_type, handle, NULL);
+       tp_channel_run_until_ready (chan, NULL, NULL);
 
-       tp_chan = tp_chan_new (tp_get_bus(),
-                              bus_name,
-                              channel,
-                              channel_type,
-                              handle_type,
-                              handle);
-
-       g_hash_table_insert (priv->table, tp_chan, GUINT_TO_POINTER (id));
+       g_hash_table_insert (priv->table, chan, GUINT_TO_POINTER (id));
 
        empathy_debug (DEBUG_DOMAIN, "New channel to be filtred: "
                                     "type=%s handle=%d id=%d",
                                     channel_type, handle, id);
-       g_signal_emit (filter, signals[NEW_CHANNEL], 0, tp_conn, tp_chan);
 
-       g_object_unref (tp_conn);
+       g_signal_emit (filter, signals[NEW_CHANNEL], 0, chan);
+
+       g_object_unref (conn);
 
        return TRUE;
 }
index 4156c640fcded4e7ed73ee5cd3b646068870ea10..bfd031e7e56b451f810ab2befb8c4391de43065f 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <glib.h>
 
-#include <libtelepathy/tp-chan.h>
+#include <telepathy-glib/channel.h>
 
 G_BEGIN_DECLS
 
@@ -54,7 +54,7 @@ EmpathyFilter *empathy_filter_new      (const gchar   *bus_name,
                                        guint          priority,
                                        guint          flags);
 void           empathy_filter_process  (EmpathyFilter *filter,
-                                       TpChan        *tp_chan,
+                                       TpChannel     *channel,
                                        gboolean       process);
 
 G_END_DECLS