# HG changeset patch # User Nathan Walp # Date 1125515313 0 # Node ID 1e756e251dc3ebd967cd9509c53c0a97382b213b # Parent e8890f996cc1a3582dd4adac7a4b1b275268239d [gaim-migrate @ 13623] patch from Ken Tossell for jabber chat affiliations committer: Tailor Script diff -r e8890f996cc1 -r 1e756e251dc3 COPYRIGHT --- 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 diff -r e8890f996cc1 -r 1e756e251dc3 src/protocols/jabber/chat.c --- 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) { diff -r e8890f996cc1 -r 1e756e251dc3 src/protocols/jabber/chat.h --- 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); diff -r e8890f996cc1 -r 1e756e251dc3 src/protocols/jabber/jabber.c --- 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", diff -r e8890f996cc1 -r 1e756e251dc3 src/protocols/jabber/jabber.h --- 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;