From: Nathan W. <fac...@us...> - 2005-08-31 19:08:44
|
Update of /cvsroot/gaim/gaim/src/protocols/jabber In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5720/src/protocols/jabber Modified Files: chat.c chat.h jabber.c jabber.h Log Message: patch from Ken Tossell for jabber chat affiliations Index: chat.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/jabber/chat.c,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -p -r1.51 -r1.52 --- chat.c 31 Aug 2005 19:00:27 -0000 1.51 +++ chat.c 31 Aug 2005 19:08:33 -0000 1.52 @@ -854,6 +854,32 @@ gboolean jabber_chat_ban_user(JabberChat 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) { Index: chat.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/jabber/chat.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -p -r1.18 -r1.19 --- chat.h 26 May 2005 04:13:03 -0000 1.18 +++ chat.h 31 Aug 2005 19:08:33 -0000 1.19 @@ -77,6 +77,8 @@ void jabber_chat_track_handle(JabberChat 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); Index: jabber.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/jabber/jabber.c,v retrieving revision 1.296 retrieving revision 1.297 diff -u -d -p -r1.296 -r1.297 --- jabber.c 31 Aug 2005 18:28:31 -0000 1.296 +++ jabber.c 31 Aug 2005 19:08:33 -0000 1.297 @@ -1410,6 +1410,33 @@ static GaimCmdRet jabber_cmd_chat_ban(Ga 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 @@ static void jabber_register_commands(voi 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", Index: jabber.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/jabber/jabber.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -p -r1.19 -r1.20 --- jabber.h 26 May 2005 04:13:06 -0000 1.19 +++ jabber.h 31 Aug 2005 19:08:33 -0000 1.20 @@ -38,6 +38,7 @@ typedef enum { 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; |