1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007 Xavier Claessens <xclaesse@gmail.com>
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.
29 #include <libtelepathy/tp-conn.h>
30 #include <libtelepathy/tp-chan.h>
31 #include <libmissioncontrol/mc-account.h>
33 #include <libempathy/gossip-contact.h>
34 #include <libempathy/empathy-chandler.h>
35 #include <libempathy/empathy-session.h>
36 #include <libempathy/empathy-contact-manager.h>
37 #include <libempathy/empathy-contact-list.h>
38 #include <libempathy-gtk/gossip-private-chat.h>
39 #include <libempathy-gtk/gossip-stock.h>
41 #define BUS_NAME "org.gnome.Empathy.Chat"
42 #define OBJECT_PATH "/org/freedesktop/Telepathy/ChannelHandler"
45 new_channel_cb (EmpathyChandler *chandler,
50 if (tp_chan->handle_type == TP_HANDLE_TYPE_CONTACT) {
53 EmpathyContactManager *manager;
54 EmpathyContactList *list;
55 GossipContact *contact;
56 GossipPrivateChat *chat;
58 /* We have a private chat channel */
59 mc = empathy_session_get_mission_control ();
60 account = mission_control_get_account_for_connection (mc, tp_conn, NULL);
61 manager = empathy_session_get_contact_manager ();
62 list = empathy_contact_manager_get_list (manager, account);
63 contact = empathy_contact_list_get_from_handle (list, tp_chan->handle);
65 chat = gossip_private_chat_new_with_channel (contact, tp_chan);
66 gossip_chat_present (GOSSIP_CHAT (chat));
68 g_object_unref (account);
69 g_object_unref (contact);
70 g_object_unref (chat);
75 main (int argc, char *argv[])
77 EmpathyChandler *chandler;
79 gtk_init (&argc, &argv);
80 /* FIXME: This is a horrible hack */
81 gossip_stock_init (gtk_window_new (GTK_WINDOW_TOPLEVEL));
83 chandler = empathy_chandler_new (BUS_NAME, OBJECT_PATH);
85 g_signal_connect (chandler, "new-channel",
86 G_CALLBACK (new_channel_cb),