]> git.0d.be Git - empathy.git/commitdiff
Use new dispatcher API to get muc channels
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Fri, 9 Jan 2009 16:13:04 +0000 (16:13 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 9 Jan 2009 16:13:04 +0000 (16:13 +0000)
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
svn path=/trunk/; revision=2145

libempathy-gtk/empathy-chat.c
src/empathy-main-window.c
src/empathy-new-chatroom-dialog.c

index d05c8591d1045a5eb17600072e687c6346b2baaa..a1787189a81475cc8ddd27a7ff09244e334b2b33 100644 (file)
@@ -40,6 +40,7 @@
 #include <libempathy/empathy-log-manager.h>
 #include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-dispatcher.h>
 
 #include "empathy-chat.h"
 #include "empathy-conf.h"
@@ -179,21 +180,21 @@ chat_connection_changed_cb (EmpathyAccountManager *manager,
        if (current == TP_CONNECTION_STATUS_CONNECTED && !priv->tp_chat &&
            empathy_account_equal (account, priv->account) &&
            priv->handle_type != TP_HANDLE_TYPE_NONE) {
-               TpConnection *connection;
-               MissionControl *mc;
-
+               
                DEBUG ("Account reconnected, request a new Text channel");
 
-               mc = empathy_mission_control_new ();
-               connection = mission_control_get_tpconnection (mc, account, NULL);
-               tp_connection_run_until_ready (connection, FALSE, NULL, NULL);
-               empathy_connection_request_channel (connection, -1,
-                                                   TP_IFACE_CHANNEL_TYPE_TEXT,
-                                                   priv->handle_type,
-                                                   priv->id, TRUE,
-                                                   NULL, NULL, NULL, NULL);
-               g_object_unref (connection);
-               g_object_unref (mc);
+               switch (priv->handle_type) {
+                               case TP_HANDLE_TYPE_CONTACT:
+                                       empathy_dispatcher_chat_with_contact_id (account, unique_name,
+                                               NULL, NULL);
+                                       break;
+                               case TP_HANDLE_TYPE_ROOM:
+                                       empathy_dispatcher_join_muc (account, unique_name, NULL, NULL);
+                                       break;
+                               default:
+                                       g_assert_not_reached ();
+                                       break;
+                       }
        }
 }
 
index 4a6c862120b1730b5f3d0241c35105db54536861..a20345e6df1e179179a4b27f239cda164d59c705 100644 (file)
@@ -31,6 +31,7 @@
 #include <libempathy/empathy-contact.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-account-manager.h>
+#include <libempathy/empathy-dispatcher.h>
 #include <libempathy/empathy-chatroom-manager.h>
 #include <libempathy/empathy-chatroom.h>
 #include <libempathy/empathy-contact-list.h>
@@ -49,6 +50,8 @@
 #include <libempathy-gtk/empathy-new-message-dialog.h>
 #include <libempathy-gtk/empathy-gtk-enum-types.h>
 
+#include <libmissioncontrol/mission-control.h>
+
 #include "empathy-accounts-dialog.h"
 #include "empathy-main-window.h"
 #include "ephy-spinner.h"
@@ -843,25 +846,20 @@ main_window_favorite_chatroom_join (EmpathyChatroom *chatroom)
 {
        MissionControl *mc;
        McAccount      *account;
-       TpConnection   *connection;
        const gchar    *room;
 
        mc = empathy_mission_control_new ();
        account = empathy_chatroom_get_account (chatroom);
        room = empathy_chatroom_get_room (chatroom);
 
+        if (mission_control_get_connection_status (mc, account, NULL) !=
+                       TP_CONNECTION_STATUS_CONNECTED) {
+               return;
+       }
+
        DEBUG ("Requesting channel for '%s'", room);
+       empathy_dispatcher_join_muc (account, room, NULL, NULL);
 
-       connection = mission_control_get_tpconnection (mc, account, NULL);
-       if (connection) {
-               tp_connection_run_until_ready (connection, TRUE, NULL, NULL);   
-               empathy_connection_request_channel (connection, -1,
-                                                   TP_IFACE_CHANNEL_TYPE_TEXT,
-                                                   TP_HANDLE_TYPE_ROOM,
-                                                   room, TRUE,
-                                                   NULL, NULL, NULL, NULL);
-               g_object_unref (connection);
-       }
        g_object_unref (mc);
 }
 
index 4a1fb90df6caa346d396989b4bd6ddaa923cd80d..9c9a9a4cd19d0b53cdfe179cdaec14e32a5da4a3 100644 (file)
@@ -39,6 +39,7 @@
 #include <libempathy/empathy-tp-roomlist.h>
 #include <libempathy/empathy-chatroom.h>
 #include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-dispatcher.h>
 
 #include <libempathy-gtk/empathy-account-chooser.h>
 #include <libempathy-gtk/empathy-ui-utils.h>
@@ -489,8 +490,6 @@ new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog)
 {
        EmpathyAccountChooser *account_chooser;
        McAccount             *account;
-       MissionControl        *mc;
-       TpConnection          *connection;
        const gchar           *room;
        const gchar           *server = NULL;
        gchar                 *room_name = NULL;
@@ -508,18 +507,9 @@ new_chatroom_dialog_join (EmpathyNewChatroomDialog *dialog)
        }
 
        DEBUG ("Requesting channel for '%s'", room_name);
+       empathy_dispatcher_join_muc (account, room_name, NULL, NULL);
 
-       mc = empathy_mission_control_new ();
-       connection = mission_control_get_tpconnection (mc, account, NULL);
-       tp_connection_run_until_ready (connection, TRUE, NULL, NULL);   
-       empathy_connection_request_channel (connection, -1,
-                                           TP_IFACE_CHANNEL_TYPE_TEXT,
-                                           TP_HANDLE_TYPE_ROOM,
-                                           room_name, TRUE,
-                                           NULL, NULL, NULL, NULL);
        g_free (room_name);
-       g_object_unref (connection);
-       g_object_unref (mc);
 }
 
 static void