From 64030b865ce54a5e2442e98a4724b8f2099d2809 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 8 May 2008 17:30:40 +0000 Subject: Move non-gtk parts of EmpathyFilter to EmpathyDispatcher in libempathy, gtk parts are now in EmpathyStatusIcon svn path=/trunk/; revision=1093 --- src/empathy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'src/empathy.c') diff --git a/src/empathy.c b/src/empathy.c index f28eae959..242f946a1 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -38,11 +38,16 @@ #include #include +#include +#include +#include #include #include "empathy-main-window.h" #include "empathy-status-icon.h" +#include "empathy-call-window.h" +#include "empathy-chat-window.h" #include "bacon-message-connection.h" #define DEBUG_FLAG EMPATHY_DEBUG_OTHER @@ -50,6 +55,57 @@ static BaconMessageConnection *connection = NULL; +static void +dispatch_channel_cb (EmpathyDispatcher *dispatcher, + TpChannel *channel, + gpointer user_data) +{ + gchar *channel_type; + + g_object_get (channel, "channel-type", &channel_type, NULL); + if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TEXT)) { + EmpathyTpChat *tp_chat; + EmpathyChat *chat = NULL; + const gchar *id; + + tp_chat = empathy_tp_chat_new (channel); + empathy_run_until_ready (tp_chat); + + id = empathy_tp_chat_get_id (tp_chat); + if (!id) { + EmpathyContact *contact; + + contact = empathy_tp_chat_get_remote_contact (tp_chat); + if (contact) { + id = empathy_contact_get_id (contact); + } + } + + if (id) { + McAccount *account; + + account = empathy_tp_chat_get_account (tp_chat); + chat = empathy_chat_window_find_chat (account, id); + } + + if (chat) { + empathy_chat_set_tp_chat (chat, tp_chat); + } else { + chat = empathy_chat_new (tp_chat); + } + + empathy_chat_window_present_chat (chat); + g_object_unref (tp_chat); + } + else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA)) { + EmpathyTpCall *tp_call; + + tp_call = empathy_tp_call_new (channel); + empathy_call_window_new (tp_call); + g_object_unref (tp_call); + } +} + static void service_ended_cb (MissionControl *mc, gpointer user_data) @@ -300,6 +356,7 @@ main (int argc, char *argv[]) { guint32 startup_timestamp; EmpathyStatusIcon *icon; + EmpathyDispatcher *dispatcher; GtkWidget *window; MissionControl *mc; EmpathyIdle *idle; @@ -402,6 +459,12 @@ main (int argc, char *argv[]) window); } + /* Handle channels */ + dispatcher = empathy_dispatcher_new (); + g_signal_connect (dispatcher, "dispatch-channel", + G_CALLBACK (dispatch_channel_cb), + NULL); + gtk_main (); empathy_idle_set_state (idle, MC_PRESENCE_OFFLINE); @@ -409,6 +472,7 @@ main (int argc, char *argv[]) g_object_unref (mc); g_object_unref (idle); g_object_unref (icon); + g_object_unref (dispatcher); return EXIT_SUCCESS; } -- cgit v1.2.3