changeset 29383:46abe1203e0b

merge of '204f0197379cadffd6cea25efa6e2cdeae1a3bc5' and 'a2a9e1db2545692a99d8d962fd05de135f570cad'
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Thu, 18 Feb 2010 06:20:55 +0000
parents 56b73246e468 (current diff) c8b407fec879 (diff)
children cece09dbb119
files
diffstat 4 files changed, 12 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/chat.c	Thu Feb 18 01:19:10 2010 +0000
+++ b/libpurple/protocols/jabber/chat.c	Thu Feb 18 06:20:55 2010 +0000
@@ -1048,7 +1048,8 @@
 	return TRUE;
 }
 
-gboolean jabber_chat_role_user(JabberChat *chat, const char *who, const char *role)
+gboolean jabber_chat_role_user(JabberChat *chat, const char *who,
+                               const char *role, const char *why)
 {
 	char *to;
 	JabberIq *iq;
@@ -1071,6 +1072,10 @@
 	item = xmlnode_new_child(query, "item");
 	xmlnode_set_attrib(item, "nick", jcm->handle);
 	xmlnode_set_attrib(item, "role", role);
+	if (why) {
+		xmlnode *reason = xmlnode_new_child(item, "reason");
+		xmlnode_insert_data(reason, why, -1);
+	}
 
 	jabber_iq_send(iq);
 
@@ -1138,37 +1143,6 @@
 	return TRUE;
 }
 
-gboolean jabber_chat_kick_user(JabberChat *chat, const char *who, const char *why)
-{
-	JabberIq *iq;
-	JabberChatMember *jcm = g_hash_table_lookup(chat->members, who);
-	char *to;
-	xmlnode *query, *item, *reason;
-
-	if(!jcm || !jcm->jid)
-		return FALSE;
-
-	iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
-			"http://jabber.org/protocol/muc#admin");
-
-	to = g_strdup_printf("%s@%s", chat->room, chat->server);
-	xmlnode_set_attrib(iq->node, "to", to);
-	g_free(to);
-
-	query = xmlnode_get_child(iq->node, "query");
-	item = xmlnode_new_child(query, "item");
-	xmlnode_set_attrib(item, "jid", jcm->jid);
-	xmlnode_set_attrib(item, "role", "none");
-	if(why) {
-		reason = xmlnode_new_child(item, "reason");
-		xmlnode_insert_data(reason, why, -1);
-	}
-
-	jabber_iq_send(iq);
-
-	return TRUE;
-}
-
 static void jabber_chat_disco_traffic_cb(JabberStream *js, const char *from,
                                          JabberIqType type, const char *id,
                                          xmlnode *packet, gpointer data)
--- a/libpurple/protocols/jabber/chat.h	Thu Feb 18 01:19:10 2010 +0000
+++ b/libpurple/protocols/jabber/chat.h	Thu Feb 18 06:20:55 2010 +0000
@@ -100,7 +100,7 @@
 		const char *affiliation);
 gboolean jabber_chat_affiliation_list(JabberChat *chat, const char *affiliation);
 gboolean jabber_chat_role_user(JabberChat *chat, const char *who,
-		const char *role);
+		const char *role, const char *why);
 gboolean jabber_chat_role_list(JabberChat *chat, const char *role);
 gboolean jabber_chat_kick_user(JabberChat *chat, const char *who,
 		const char *why);
--- a/libpurple/protocols/jabber/iq.c	Thu Feb 18 01:19:10 2010 +0000
+++ b/libpurple/protocols/jabber/iq.c	Thu Feb 18 06:20:55 2010 +0000
@@ -43,8 +43,8 @@
 #include "utsname.h"
 #endif
 
-GHashTable *iq_handlers = NULL;
-GHashTable *signal_iq_handlers = NULL;
+static GHashTable *iq_handlers = NULL;
+static GHashTable *signal_iq_handlers = NULL;
 
 JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type)
 {
--- a/libpurple/protocols/jabber/jabber.c	Thu Feb 18 01:19:10 2010 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Thu Feb 18 06:20:55 2010 +0000
@@ -2721,9 +2721,10 @@
 		char **nicks = g_strsplit(args[1], " ", -1);
 
 		for (i = 0; nicks[i]; i++)
-			if (!jabber_chat_role_user(chat, nicks[i], args[0])) {
+			if (!jabber_chat_role_user(chat, nicks[i], args[0], NULL)) {
 				*error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"),
 										 args[0], nicks[i]);
+				g_strfreev(nicks);
 				return PURPLE_CMD_RET_FAILED;
 			}
 
@@ -2778,7 +2779,7 @@
 	if(!chat || !args || !args[0])
 		return PURPLE_CMD_RET_FAILED;
 
-	if(!jabber_chat_kick_user(chat, args[0], args[1])) {
+	if(!jabber_chat_role_user(chat, args[0], "none", args[1])) {
 		*error = g_strdup_printf(_("Unable to kick user %s"), args[0]);
 		return PURPLE_CMD_RET_FAILED;
 	}