[empathy] Inform the chatroom mgr when we are handling a new room



commit b07f3a5c948066219cb57bb113a48d0981106f23
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Mon Jul 5 10:58:55 2010 +0200

    Inform the chatroom mgr when we are handling a new room
    
    It can't rely on the internal dispatcher any more.

 libempathy/empathy-chatroom-manager.c |   45 ++++++---------------------------
 libempathy/empathy-chatroom-manager.h |    6 +++-
 src/empathy-chat-manager.c            |   10 +++++++
 src/empathy.c                         |    1 -
 4 files changed, 22 insertions(+), 40 deletions(-)
---
diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c
index be91657..115e415 100644
--- a/libempathy/empathy-chatroom-manager.c
+++ b/libempathy/empathy-chatroom-manager.c
@@ -754,46 +754,25 @@ chatroom_manager_chat_destroyed_cb (EmpathyTpChat *chat,
     }
 }
 
-static void
-chatroom_manager_observe_channel_cb (EmpathyDispatcher *dispatcher,
-  EmpathyDispatchOperation *operation, gpointer manager)
+/* Called by EmpathyChatManager when we are handling a new group chat */
+void
+empathy_chatroom_manager_chat_handled (EmpathyChatroomManager *self,
+    EmpathyTpChat *chat,
+    TpAccount *account)
 {
   EmpathyChatroom *chatroom;
-  TpChannel *channel;
-  EmpathyTpChat *chat;
   const gchar *roomname;
-  GQuark channel_type;
-  TpHandleType handle_type;
-  TpAccount *account;
-  TpConnection *connection;
-
-  channel_type = empathy_dispatch_operation_get_channel_type_id (operation);
-
-  /* Observe Text channels to rooms only */
-  if (channel_type != TP_IFACE_QUARK_CHANNEL_TYPE_TEXT)
-    return;
-
-  channel = empathy_dispatch_operation_get_channel (operation);
-  tp_channel_get_handle (channel, &handle_type);
-
-  if (handle_type != TP_HANDLE_TYPE_ROOM)
-    return;
-
-  chat = EMPATHY_TP_CHAT (
-    empathy_dispatch_operation_get_channel_wrapper (operation));
-  connection = empathy_tp_chat_get_connection (chat);
-  account = empathy_get_account_for_connection (connection);
 
   roomname = empathy_tp_chat_get_id (chat);
 
-  chatroom = empathy_chatroom_manager_find (manager, account, roomname);
+  chatroom = empathy_chatroom_manager_find (self, account, roomname);
 
   if (chatroom == NULL)
     {
       chatroom = empathy_chatroom_new_full (account, roomname, roomname,
         FALSE);
       empathy_chatroom_set_tp_chat (chatroom, chat);
-      empathy_chatroom_manager_add (manager, chatroom);
+      empathy_chatroom_manager_add (self, chatroom);
       g_object_unref (chatroom);
     }
   else
@@ -805,13 +784,5 @@ chatroom_manager_observe_channel_cb (EmpathyDispatcher *dispatcher,
    * has been invalidated in the dispatcher..  */
   g_signal_connect (chat, "destroy",
     G_CALLBACK (chatroom_manager_chat_destroyed_cb),
-    manager);
-}
-
-void
-empathy_chatroom_manager_observe (EmpathyChatroomManager *manager,
-  EmpathyDispatcher *dispatcher)
-{
-  g_signal_connect (dispatcher, "observe",
-    G_CALLBACK (chatroom_manager_observe_channel_cb), manager);
+    self);
 }
diff --git a/libempathy/empathy-chatroom-manager.h b/libempathy/empathy-chatroom-manager.h
index 9a1de18..692a8e4 100644
--- a/libempathy/empathy-chatroom-manager.h
+++ b/libempathy/empathy-chatroom-manager.h
@@ -70,8 +70,10 @@ GList *                empathy_chatroom_manager_get_chatrooms (EmpathyChatroomMa
 							      TpAccount               *account);
 guint                  empathy_chatroom_manager_get_count     (EmpathyChatroomManager *manager,
 							      TpAccount               *account);
-void                   empathy_chatroom_manager_observe       (EmpathyChatroomManager *manager,
-							      EmpathyDispatcher *dispatcher);
+
+void		       empathy_chatroom_manager_chat_handled  (EmpathyChatroomManager *self,
+							       EmpathyTpChat *chat,
+							       TpAccount *account);
 
 G_END_DECLS
 
diff --git a/src/empathy-chat-manager.c b/src/empathy-chat-manager.c
index aceaa5e..c8d5891 100644
--- a/src/empathy-chat-manager.c
+++ b/src/empathy-chat-manager.c
@@ -19,6 +19,7 @@
 
 #include <telepathy-glib/telepathy-glib.h>
 
+#include <libempathy/empathy-chatroom-manager.h>
 #include <libempathy/empathy-dispatcher.h>
 
 #include "empathy-chat-window.h"
@@ -128,6 +129,15 @@ process_tp_chat (EmpathyTpChat *tp_chat,
       empathy_tp_chat_join (tp_chat);
     }
 
+  if (empathy_chat_is_room (chat))
+    {
+      EmpathyChatroomManager *chatroom_mgr;
+
+      chatroom_mgr = empathy_chatroom_manager_dup_singleton (NULL);
+      empathy_chatroom_manager_chat_handled (chatroom_mgr, tp_chat, account);
+      g_object_unref (chatroom_mgr);
+    }
+
   g_object_unref (tp_chat);
 }
 
diff --git a/src/empathy.c b/src/empathy.c
index a148c97..81ff77c 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -574,7 +574,6 @@ main (int argc, char *argv[])
   log_manager = tpl_log_manager_dup_singleton ();
 
   chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
-  empathy_chatroom_manager_observe (chatroom_manager, dispatcher);
 
   g_object_get (chatroom_manager, "ready", &chatroom_manager_ready, NULL);
   if (!chatroom_manager_ready)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]