aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-05-09 01:30:40 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-05-09 01:30:40 +0800
commit64030b865ce54a5e2442e98a4724b8f2099d2809 (patch)
tree2784f531dd981623eabaeb53787951e009579d39 /src/empathy.c
parent5567b074722bf1243a52086d34a80e04c2e11867 (diff)
downloadgsoc2013-empathy-64030b865ce54a5e2442e98a4724b8f2099d2809.tar
gsoc2013-empathy-64030b865ce54a5e2442e98a4724b8f2099d2809.tar.gz
gsoc2013-empathy-64030b865ce54a5e2442e98a4724b8f2099d2809.tar.bz2
gsoc2013-empathy-64030b865ce54a5e2442e98a4724b8f2099d2809.tar.lz
gsoc2013-empathy-64030b865ce54a5e2442e98a4724b8f2099d2809.tar.xz
gsoc2013-empathy-64030b865ce54a5e2442e98a4724b8f2099d2809.tar.zst
gsoc2013-empathy-64030b865ce54a5e2442e98a4724b8f2099d2809.zip
Move non-gtk parts of EmpathyFilter to EmpathyDispatcher in libempathy, gtk parts are now in EmpathyStatusIcon
svn path=/trunk/; revision=1093
Diffstat (limited to 'src/empathy.c')
-rw-r--r--src/empathy.c64
1 files changed, 64 insertions, 0 deletions
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 <libempathy/empathy-idle.h>
#include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-dispatcher.h>
+#include <libempathy/empathy-tp-chat.h>
+#include <libempathy/empathy-tp-call.h>
#include <libempathy-gtk/empathy-conf.h>
#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
@@ -51,6 +56,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;
}