Mercurial > pidgin
changeset 29070:c8b407fec879
jabber: Kick by in-room nick, not JID. Reduces code, but is still in-spec (and seems to be the preferred method)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Thu, 18 Feb 2010 04:39:28 +0000 |
parents | f5c00a24bb87 |
children | 46abe1203e0b |
files | libpurple/protocols/jabber/chat.c libpurple/protocols/jabber/chat.h libpurple/protocols/jabber/jabber.c |
diffstat | 3 files changed, 9 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/chat.c Thu Feb 18 04:37:49 2010 +0000 +++ b/libpurple/protocols/jabber/chat.c Thu Feb 18 04:39:28 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 04:37:49 2010 +0000 +++ b/libpurple/protocols/jabber/chat.h Thu Feb 18 04:39:28 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/jabber.c Thu Feb 18 04:37:49 2010 +0000 +++ b/libpurple/protocols/jabber/jabber.c Thu Feb 18 04:39:28 2010 +0000 @@ -2721,7 +2721,7 @@ 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); @@ -2779,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; }