Mercurial > pidgin
changeset 11393:1e756e251dc3
[gaim-migrate @ 13623]
patch from Ken Tossell for jabber chat affiliations
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Wed, 31 Aug 2005 19:08:33 +0000 |
parents | e8890f996cc1 |
children | 54934c165625 |
files | COPYRIGHT src/protocols/jabber/chat.c src/protocols/jabber/chat.h src/protocols/jabber/jabber.c src/protocols/jabber/jabber.h |
diffstat | 5 files changed, 63 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/COPYRIGHT Wed Aug 31 19:00:27 2005 +0000 +++ b/COPYRIGHT Wed Aug 31 19:08:33 2005 +0000 @@ -220,6 +220,7 @@ Stu Tomlinson Bill Tompkins Chris Toshok +Ken Tossell Tom Tromey Todd Troxell Brad Turcotte
--- a/src/protocols/jabber/chat.c Wed Aug 31 19:00:27 2005 +0000 +++ b/src/protocols/jabber/chat.c Wed Aug 31 19:08:33 2005 +0000 @@ -854,6 +854,32 @@ return TRUE; } +gboolean jabber_chat_affiliate_user(JabberChat *chat, const char *who, const char *affiliation) +{ + JabberIq *iq; + JabberChatMember *jcm = g_hash_table_lookup(chat->members, who); + char *to; + xmlnode *query, *item; + + 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, "affiliation", affiliation); + + jabber_iq_send(iq); + + return TRUE; +} gboolean jabber_chat_kick_user(JabberChat *chat, const char *who, const char *why) {
--- a/src/protocols/jabber/chat.h Wed Aug 31 19:00:27 2005 +0000 +++ b/src/protocols/jabber/chat.h Wed Aug 31 19:08:33 2005 +0000 @@ -77,6 +77,8 @@ void jabber_chat_remove_handle(JabberChat *chat, const char *handle); gboolean jabber_chat_ban_user(JabberChat *chat, const char *who, const char *why); +gboolean jabber_chat_affiliate_user(JabberChat *chat, const char *who, + const char *affiliation); gboolean jabber_chat_kick_user(JabberChat *chat, const char *who, const char *why);
--- a/src/protocols/jabber/jabber.c Wed Aug 31 19:00:27 2005 +0000 +++ b/src/protocols/jabber/jabber.c Wed Aug 31 19:08:33 2005 +0000 @@ -1410,6 +1410,33 @@ return GAIM_CMD_RET_OK; } +static GaimCmdRet jabber_cmd_chat_affiliate(GaimConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + JabberChat *chat = jabber_chat_find_by_conv(conv); + + if (!args || !args[0] || !args[1]) + return GAIM_CMD_RET_FAILED; + + if ( + strcmp(args[1], "owner") != 0 && + strcmp(args[1], "admin") != 0 && + strcmp(args[1], "member") != 0 && + strcmp(args[1], "outcast") != 0 && + strcmp(args[1], "none") != 0 + ) { + *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]); + return GAIM_CMD_RET_FAILED; + } + + if (!jabber_chat_affiliate_user(chat, args[0], args[1])) { + *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]); + return GAIM_CMD_RET_FAILED; + } + + return GAIM_CMD_RET_OK; +} + static GaimCmdRet jabber_cmd_chat_invite(GaimConversation *conv, const char *cmd, char **args, char **error, void *data) { @@ -1513,6 +1540,12 @@ jabber_cmd_chat_ban, _("ban <user> [room]: Ban a user from the room."), NULL); + gaim_cmd_register("affiliate", "ws", GAIM_CMD_P_PRPL, + GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | + GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", + jabber_cmd_chat_affiliate, + _("affiliate <user> <owner|admin|member|outcast|none>: Set a user's affiliation with the room."), + NULL); gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL, GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
--- a/src/protocols/jabber/jabber.h Wed Aug 31 19:00:27 2005 +0000 +++ b/src/protocols/jabber/jabber.h Wed Aug 31 19:08:33 2005 +0000 @@ -38,6 +38,7 @@ JABBER_CAP_SI_FILE_XFER = 1 << 3, JABBER_CAP_BYTESTREAMS = 1 << 4, JABBER_CAP_IBB = 1 << 5, + JABBER_CAP_CHAT_STATES = 1 << 6, JABBER_CAP_RETRIEVED = 1 << 31 } JabberCapabilities;