aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-10-13 15:53:11 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-10-13 15:53:11 +0800
commit627bef93db1b66f93f90ba0f629e153494be26e9 (patch)
treed2627477d3393a18db27c600d4469c344a3def64 /libempathy
parent0e0658058e4f91befd2747d65e9d6dea492d57ce (diff)
downloadgsoc2013-empathy-627bef93db1b66f93f90ba0f629e153494be26e9.tar
gsoc2013-empathy-627bef93db1b66f93f90ba0f629e153494be26e9.tar.gz
gsoc2013-empathy-627bef93db1b66f93f90ba0f629e153494be26e9.tar.bz2
gsoc2013-empathy-627bef93db1b66f93f90ba0f629e153494be26e9.tar.lz
gsoc2013-empathy-627bef93db1b66f93f90ba0f629e153494be26e9.tar.xz
gsoc2013-empathy-627bef93db1b66f93f90ba0f629e153494be26e9.tar.zst
gsoc2013-empathy-627bef93db1b66f93f90ba0f629e153494be26e9.zip
add joined room to EmpathyChatroomManager. Fixes bug #542176 (Guillaume Desmottes).
svn path=/trunk/; revision=1535
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-dispatcher.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index 1d2b9895d..6d1f2a43e 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -41,6 +41,8 @@
#include "empathy-tube-handler.h"
#include "empathy-contact-factory.h"
#include "empathy-tp-group.h"
+#include "empathy-chatroom-manager.h"
+#include "empathy-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
#include <libempathy/empathy-debug.h>
@@ -389,6 +391,31 @@ dispatcher_connection_invalidated_cb (TpConnection *connection,
}
}
+static void chatroom_invalidated_cb (TpProxy *channel,
+ guint domain,
+ gint code,
+ gchar *message,
+ EmpathyChatroom *chatroom)
+{
+ EmpathyChatroomManager *mgr;
+ mgr = empathy_chatroom_manager_new ();
+ gboolean favorite;
+
+ g_object_get (chatroom, "favorite", &favorite, NULL);
+
+ if (favorite)
+ {
+ /* Chatroom is in favorites so don't remove it from the manager */
+ g_object_set (chatroom, "tp-channel", NULL, NULL);
+ }
+ else
+ {
+ empathy_chatroom_manager_remove (mgr, chatroom);
+ }
+
+ g_object_unref (mgr);
+}
+
static void
dispatcher_connection_new_channel_cb (TpConnection *connection,
const gchar *object_path,
@@ -418,6 +445,54 @@ dispatcher_connection_new_channel_cb (TpConnection *connection,
dispatcher_tubes_handle_channel (dispatcher, channel);
}
+ if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TEXT) &&
+ handle_type == TP_HANDLE_TYPE_ROOM)
+ {
+ /* Add the chatroom to the chatroom manager */
+ EmpathyChatroomManager *mgr;
+ EmpathyChatroom *chatroom;
+ GArray *handles;
+ gchar **room_ids;
+ MissionControl *mc;
+ McAccount *account;
+
+ mgr = empathy_chatroom_manager_new ();
+
+ handles = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), 1);
+ g_array_append_val (handles, handle);
+
+ tp_cli_connection_run_inspect_handles (connection, -1,
+ TP_HANDLE_TYPE_ROOM, handles, &room_ids, NULL, NULL);
+
+ mc = empathy_mission_control_new ();
+ account = mission_control_get_account_for_tpconnection (mc, connection,
+ NULL);
+
+ chatroom = empathy_chatroom_manager_find (mgr, account, room_ids[0]);
+ if (chatroom == NULL)
+ {
+ chatroom = empathy_chatroom_new (account, room_ids[0]);
+ empathy_chatroom_manager_add (mgr, chatroom);
+ }
+ else
+ {
+ g_object_ref (chatroom);
+ }
+
+ g_object_set (chatroom, "tp-channel", channel, NULL);
+
+ g_signal_connect (channel, "invalidated",
+ G_CALLBACK (chatroom_invalidated_cb), chatroom);
+
+ g_free (room_ids[0]);
+ g_free (room_ids);
+ g_array_free (handles, TRUE);
+ g_object_unref (mc);
+ g_object_unref (account);
+ g_object_unref (chatroom);
+ g_object_unref (mgr);
+ }
+
if (suppress_handler) {
g_signal_emit (dispatcher, signals[DISPATCH_CHANNEL], 0, channel);
} else {