aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-chat.c
diff options
context:
space:
mode:
authorChandni Verma <chandniverma2112@gmail.com>2011-02-23 14:25:25 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-02-25 17:25:01 +0800
commit667cae90a298a8f9a0004431fd3ce494b3c15f26 (patch)
tree740795605e38f79a2ae2ce4997bd38f02199cc58 /libempathy-gtk/empathy-chat.c
parent9a5d1c52d41aab250ca5bfff3373b11d876bdf1f (diff)
downloadgsoc2013-empathy-667cae90a298a8f9a0004431fd3ce494b3c15f26.tar
gsoc2013-empathy-667cae90a298a8f9a0004431fd3ce494b3c15f26.tar.gz
gsoc2013-empathy-667cae90a298a8f9a0004431fd3ce494b3c15f26.tar.bz2
gsoc2013-empathy-667cae90a298a8f9a0004431fd3ce494b3c15f26.tar.lz
gsoc2013-empathy-667cae90a298a8f9a0004431fd3ce494b3c15f26.tar.xz
gsoc2013-empathy-667cae90a298a8f9a0004431fd3ce494b3c15f26.tar.zst
gsoc2013-empathy-667cae90a298a8f9a0004431fd3ce494b3c15f26.zip
Implementation of /PART command for MUCs
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=604348
Diffstat (limited to 'libempathy-gtk/empathy-chat.c')
-rw-r--r--libempathy-gtk/empathy-chat.c62
1 files changed, 56 insertions, 6 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index fbe2425b6..2aa94af06 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -44,6 +44,8 @@
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-dispatcher.h>
#include <libempathy/empathy-marshal.h>
+#include <libempathy/empathy-chatroom-manager.h>
+#include <src/empathy-chat-window.h>
#include "empathy-chat.h"
#include "empathy-spell.h"
@@ -684,6 +686,17 @@ nick_command_supported (EmpathyChat *chat)
EMP_IFACE_QUARK_CONNECTION_INTERFACE_RENAMING);
}
+static gboolean
+part_command_supported (EmpathyChat *chat)
+{
+ EmpathyChatPriv * priv = GET_PRIV (chat);
+ TpChannel *channel;
+
+ channel = empathy_tp_chat_get_channel (priv->tp_chat);
+ return tp_proxy_has_interface_by_id (channel,
+ TP_IFACE_QUARK_CHANNEL_INTERFACE_GROUP);
+}
+
static void
chat_command_clear (EmpathyChat *chat,
GStrv strv)
@@ -718,12 +731,21 @@ chat_command_topic (EmpathyChat *chat,
g_value_unset (&value);
}
+void
+empathy_chat_join_muc (EmpathyChat *chat,
+ const gchar *room)
+{
+ EmpathyChatPriv *priv = GET_PRIV (chat);
+
+ empathy_dispatcher_join_muc (priv->account, room,
+ gtk_get_current_event_time ());
+}
+
static void
chat_command_join (EmpathyChat *chat,
GStrv strv)
{
guint i = 0;
- EmpathyChatPriv *priv = GET_PRIV (chat);
GStrv rooms = g_strsplit_set (strv[1], ", ", -1);
@@ -733,17 +755,41 @@ chat_command_join (EmpathyChat *chat,
while (rooms[i] != NULL) {
/* ignore empty strings */
if (!EMP_STR_EMPTY (rooms[i])) {
- TpConnection *connection;
-
- connection = empathy_tp_chat_get_connection (priv->tp_chat);
- empathy_dispatcher_join_muc (priv->account, rooms[i],
- gtk_get_current_event_time ());
+ empathy_chat_join_muc (chat, rooms[i]);
}
i++;
}
g_strfreev (rooms);
}
+void
+empathy_chat_leave_chat (EmpathyChat *chat)
+{
+ EmpathyChatPriv *priv = GET_PRIV (chat);
+
+ empathy_tp_chat_leave (priv->tp_chat, "");
+}
+
+static void
+chat_command_part (EmpathyChat *chat,
+ GStrv strv)
+{
+ EmpathyChatPriv *priv = GET_PRIV (chat);
+ EmpathyChat *chat_to_be_parted;
+
+ if (strv[1] == NULL) {
+ empathy_tp_chat_leave (priv->tp_chat, "");
+ return;
+ }
+ chat_to_be_parted = empathy_chat_window_find_chat (priv->account, strv[1]);
+
+ if (chat_to_be_parted != NULL) {
+ empathy_tp_chat_leave (empathy_chat_get_tp_chat (chat_to_be_parted), strv[2]);
+ } else {
+ empathy_tp_chat_leave (priv->tp_chat, strv[1]);
+ }
+}
+
static void
chat_command_msg_internal (EmpathyChat *chat,
const gchar *contact_id,
@@ -867,6 +913,10 @@ static ChatCommandItem commands[] = {
{"j", 2, 2, chat_command_join, NULL,
N_("/j <chat room ID>: join a new chat room")},
+ {"part", 1, 3, chat_command_part, part_command_supported,
+ N_("/part [<chat room ID>] [<reason>]: leave the chat room, "
+ "by default the current one")},
+
{"query", 2, 3, chat_command_query, NULL,
N_("/query <contact ID> [<message>]: open a private chat")},