1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007 Collabora Ltd.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Authors: Xavier Claessens <xclaesse@gmail.com>
30 #include <libtelepathy/tp-conn.h>
31 #include <libtelepathy/tp-chan.h>
32 #include <libtelepathy/tp-helpers.h>
33 #include <libmissioncontrol/mc-account.h>
35 #include <libempathy/gossip-contact.h>
36 #include <libempathy/empathy-chandler.h>
37 #include <libempathy/empathy-contact-manager.h>
38 #include <libempathy/empathy-contact-list.h>
39 #include <libempathy-gtk/gossip-private-chat.h>
40 #include <libempathy-gtk/gossip-stock.h>
42 #define BUS_NAME "org.gnome.Empathy.Chat"
43 #define OBJECT_PATH "/org/freedesktop/Telepathy/ChannelHandler"
46 new_channel_cb (EmpathyChandler *chandler,
51 if (tp_chan->handle_type == TP_HANDLE_TYPE_CONTACT) {
54 EmpathyContactManager *manager;
55 EmpathyContactList *list;
56 GossipContact *contact;
57 GossipPrivateChat *chat;
59 /* We have a private chat channel */
60 mc = mission_control_new (tp_get_bus ());
61 account = mission_control_get_account_for_connection (mc, tp_conn, NULL);
62 manager = empathy_contact_manager_new ();
63 list = empathy_contact_manager_get_list (manager, account);
64 contact = empathy_contact_list_get_from_handle (list, tp_chan->handle);
66 chat = gossip_private_chat_new_with_channel (contact, tp_chan);
67 gossip_chat_present (GOSSIP_CHAT (chat));
70 g_object_unref (account);
71 g_object_unref (contact);
72 g_object_unref (chat);
73 g_object_unref (manager);
78 main (int argc, char *argv[])
80 EmpathyChandler *chandler;
82 gtk_init (&argc, &argv);
83 /* FIXME: This is a horrible hack */
84 gossip_stock_init (gtk_window_new (GTK_WINDOW_TOPLEVEL));
86 chandler = empathy_chandler_new (BUS_NAME, OBJECT_PATH);
88 g_signal_connect (chandler, "new-channel",
89 G_CALLBACK (new_channel_cb),