]> git.0d.be Git - empathy.git/blobdiff - src/empathy-chat-main.c
Fix warning when selecting all accounts.
[empathy.git] / src / empathy-chat-main.c
index fedc9066ae3df5dbb51b3b80f5a5bef0f5c4f8a5..fb09649344913e511cde55a2be9c73f86b2e431d 100644 (file)
 #include <libempathy/gossip-debug.h>
 #include <libempathy/gossip-utils.h>
 #include <libempathy/empathy-chandler.h>
-#include <libempathy/empathy-contact-manager.h>
-#include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-tp-chat.h>
 #include <libempathy/gossip-paths.h>
 #include <libempathy-gtk/gossip-private-chat.h>
+#include <libempathy-gtk/gossip-group-chat.h>
 
 #define DEBUG_DOMAIN "ChatMain"
 
@@ -114,9 +113,12 @@ new_channel_cb (EmpathyChandler *chandler,
 
        mc = gossip_mission_control_new ();
        account = mission_control_get_account_for_connection (mc, tp_conn, NULL);
-       id = empathy_tp_chat_build_id (account, tp_chan);
+       id = gossip_get_channel_id (account, tp_chan);
+       chat = gossip_chat_window_find_chat (account, id);
+
+       g_free (id);
+       g_object_unref (mc);
 
-       chat = gossip_chat_window_find_chat_by_id (id);
        if (chat) {
                /* The chat already exists */
                if (!gossip_chat_is_connected (chat)) {
@@ -129,39 +131,31 @@ new_channel_cb (EmpathyChandler *chandler,
                }
                gossip_chat_present (chat);
 
-               goto OUT;
+               g_object_unref (account);
+               return;
        }
 
        if (tp_chan->handle_type == TP_HANDLE_TYPE_CONTACT) {
-               EmpathyContactManager *manager;
-               EmpathyContactList    *list;
-               GossipContact         *contact;
-               GossipPrivateChat     *chat;
-
                /* We have a new private chat channel */
-               manager = empathy_contact_manager_new ();
-               list = empathy_contact_manager_get_list (manager, account);
-               contact = empathy_contact_list_get_from_handle (list, tp_chan->handle);
-
-               chat = gossip_private_chat_new_with_channel (contact, tp_chan);
-               g_object_weak_ref (G_OBJECT (chat),
-                                  (GWeakNotify) chat_finalized_cb,
-                                  NULL);
+               chat = GOSSIP_CHAT (gossip_private_chat_new (account, tp_chan));
+       }
+       else if (tp_chan->handle_type == TP_HANDLE_TYPE_ROOM) {
+               /* We have a new group chat channel */
+               chat = GOSSIP_CHAT (gossip_group_chat_new (account, tp_chan));
+       }
 
-               exit_timeout_stop ();
-               chat_count++;
+       g_object_weak_ref (G_OBJECT (chat),
+                          (GWeakNotify) chat_finalized_cb,
+                          NULL);
 
-               gossip_chat_present (GOSSIP_CHAT (chat));
+       exit_timeout_stop ();
+       chat_count++;
 
-               g_object_unref (contact);
-               g_object_unref (chat);
-               g_object_unref (manager);
-       }
+       gossip_chat_present (GOSSIP_CHAT (chat));
 
-OUT:
-       g_free (id);
+       g_object_unref (chat);
        g_object_unref (account);
-       g_object_unref (mc);
+
 }
 
 int
@@ -185,11 +179,13 @@ main (int argc, char *argv[])
                                      GNOME_PARAM_HUMAN_READABLE_NAME, PACKAGE_NAME,
                                      NULL);
 
+       gtk_window_set_default_icon_name ("empathy");
+
        if (g_getenv ("EMPATHY_DEBUG")) {
                debug_mode = TRUE;
        }
 
-       exit_timeout_start ();
+       //sexit_timeout_start ();
        chandler = empathy_chandler_new (BUS_NAME, OBJECT_PATH);
 
        g_signal_connect (chandler, "new-channel",