aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-13 22:27:21 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-13 22:27:21 +0800
commitc84e0979d36aa41e7f0d554fbbdad4e82756f8b0 (patch)
tree7a95f067894d7cebdf520fa3155921ba9638badb /src
parent2096980125f9a556b5d92e541927e9cf9b213e20 (diff)
parent34a7a0b348e1cdd3cfc184f135a8371d79741272 (diff)
downloadgsoc2013-empathy-c84e0979d36aa41e7f0d554fbbdad4e82756f8b0.tar
gsoc2013-empathy-c84e0979d36aa41e7f0d554fbbdad4e82756f8b0.tar.gz
gsoc2013-empathy-c84e0979d36aa41e7f0d554fbbdad4e82756f8b0.tar.bz2
gsoc2013-empathy-c84e0979d36aa41e7f0d554fbbdad4e82756f8b0.tar.lz
gsoc2013-empathy-c84e0979d36aa41e7f0d554fbbdad4e82756f8b0.tar.xz
gsoc2013-empathy-c84e0979d36aa41e7f0d554fbbdad4e82756f8b0.tar.zst
gsoc2013-empathy-c84e0979d36aa41e7f0d554fbbdad4e82756f8b0.zip
Merge remote-tracking branch 'glassrose/moving-part-functionality-to-empathy-chat-window-643295'
Diffstat (limited to 'src')
-rw-r--r--src/empathy-chat-window.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index f4a9f7e74..93d9df8d7 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -1532,6 +1532,48 @@ chat_window_new_message_cb (EmpathyChat *chat,
chat_window_icon_update (priv, TRUE);
}
+static void
+chat_window_command_part (EmpathyChat *chat,
+ GStrv strv)
+{
+ EmpathyChat *chat_to_be_parted;
+ EmpathyTpChat *tp_chat = NULL;
+
+ if (strv[1] == NULL) {
+ /* No chatroom ID specified */
+ tp_chat = empathy_chat_get_tp_chat (chat);
+ if (tp_chat)
+ empathy_tp_chat_leave (tp_chat, "");
+ return;
+ }
+ chat_to_be_parted = empathy_chat_window_find_chat (
+ empathy_chat_get_account (chat), strv[1]);
+
+ if (chat_to_be_parted != NULL) {
+ /* Found a chatroom matching the specified ID */
+ tp_chat = empathy_chat_get_tp_chat (chat_to_be_parted);
+ if (tp_chat)
+ empathy_tp_chat_leave (tp_chat, strv[2]);
+ } else {
+ gchar *message;
+
+ /* Going by the syntax of PART command:
+ *
+ * /PART [<chatroom-ID>] [<reason>]
+ *
+ * Chatroom-ID is not a must to specify a reason.
+ * If strv[1] (chatroom-ID) is not a valid identifier for a connected
+ * MUC then the current chatroom should be parted and srtv[1] should
+ * be treated as part of the optional part-message. */
+ message = g_strconcat (strv[1], " ", strv[2], NULL);
+ tp_chat = empathy_chat_get_tp_chat (chat);
+ if (tp_chat)
+ empathy_tp_chat_leave (tp_chat, message);
+
+ g_free (message);
+ }
+}
+
static GtkNotebook *
notebook_create_window_cb (GtkNotebook *source,
GtkWidget *page,
@@ -1617,6 +1659,9 @@ chat_window_page_added_cb (GtkNotebook *notebook,
g_signal_connect (chat, "new-message",
G_CALLBACK (chat_window_new_message_cb),
window);
+ g_signal_connect (chat, "part-command-entered",
+ G_CALLBACK (chat_window_command_part),
+ NULL);
g_signal_connect (chat, "notify::tp-chat",
G_CALLBACK (chat_window_update_chat_tab),
window);