comparison src/protocols/jabber/jabber.c @ 13237:b0d020a66144

[gaim-migrate @ 15603] SF patch 1411796 by Andrej Krivul????k It adds a /role command to jabber chat rooms. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Sun, 12 Feb 2006 04:35:35 +0000
parents 33bef17125c2
children cdd107258f11
comparison
equal deleted inserted replaced
13236:0fa8153beebf 13237:b0d020a66144
1601 JabberChat *chat = jabber_chat_find_by_conv(conv); 1601 JabberChat *chat = jabber_chat_find_by_conv(conv);
1602 1602
1603 if (!args || !args[0] || !args[1]) 1603 if (!args || !args[0] || !args[1])
1604 return GAIM_CMD_RET_FAILED; 1604 return GAIM_CMD_RET_FAILED;
1605 1605
1606 if ( 1606 if (strcmp(args[1], "owner") != 0 &&
1607 strcmp(args[1], "owner") != 0 && 1607 strcmp(args[1], "admin") != 0 &&
1608 strcmp(args[1], "admin") != 0 && 1608 strcmp(args[1], "member") != 0 &&
1609 strcmp(args[1], "member") != 0 && 1609 strcmp(args[1], "outcast") != 0 &&
1610 strcmp(args[1], "outcast") != 0 && 1610 strcmp(args[1], "none") != 0) {
1611 strcmp(args[1], "none") != 0
1612 ) {
1613 *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]); 1611 *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]);
1614 return GAIM_CMD_RET_FAILED; 1612 return GAIM_CMD_RET_FAILED;
1615 } 1613 }
1616 1614
1617 if (!jabber_chat_affiliate_user(chat, args[0], args[1])) { 1615 if (!jabber_chat_affiliate_user(chat, args[0], args[1])) {
1618 *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]); 1616 *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]);
1617 return GAIM_CMD_RET_FAILED;
1618 }
1619
1620 return GAIM_CMD_RET_OK;
1621 }
1622
1623 static GaimCmdRet jabber_cmd_chat_role(GaimConversation *conv,
1624 const char *cmd, char **args, char **error, void *data)
1625 {
1626 JabberChat *chat;
1627
1628 if (!args || !args[0] || !args[1])
1629 return GAIM_CMD_RET_FAILED;
1630
1631 if (strcmp(args[1], "moderator") != 0 &&
1632 strcmp(args[1], "participant") != 0 &&
1633 strcmp(args[1], "visitor") != 0 &&
1634 strcmp(args[1], "none") != 0) {
1635 *error = g_strdup_printf(_("Unknown role: \"%s\""), args[1]);
1636 return GAIM_CMD_RET_FAILED;
1637 }
1638
1639 chat = jabber_chat_find_by_conv(conv);
1640
1641 if (!jabber_chat_role_user(chat, args[0], args[1])) {
1642 *error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"),
1643 args[1], args[0]);
1619 return GAIM_CMD_RET_FAILED; 1644 return GAIM_CMD_RET_FAILED;
1620 } 1645 }
1621 1646
1622 return GAIM_CMD_RET_OK; 1647 return GAIM_CMD_RET_OK;
1623 } 1648 }
1729 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", 1754 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1730 jabber_cmd_chat_ban, 1755 jabber_cmd_chat_ban,
1731 _("ban &lt;user&gt; [room]: Ban a user from the room."), 1756 _("ban &lt;user&gt; [room]: Ban a user from the room."),
1732 NULL); 1757 NULL);
1733 gaim_cmd_register("affiliate", "ws", GAIM_CMD_P_PRPL, 1758 gaim_cmd_register("affiliate", "ws", GAIM_CMD_P_PRPL,
1734 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | 1759 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
1735 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", 1760 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1736 jabber_cmd_chat_affiliate, 1761 jabber_cmd_chat_affiliate,
1737 _("affiliate &lt;user&gt; &lt;owner|admin|member|outcast|none&gt;: Set a user's affiliation with the room."), 1762 _("affiliate &lt;user&gt; &lt;owner|admin|member|outcast|none&gt;: Set a user's affiliation with the room."),
1738 NULL); 1763 NULL);
1764 gaim_cmd_register("role", "ws", GAIM_CMD_P_PRPL,
1765 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
1766 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1767 jabber_cmd_chat_role,
1768 _("role &lt;user&gt; &lt;moderator|participant|visitor|none&gt;: Set a user's role in the room."),
1769 NULL);
1739 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL, 1770 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL,
1740 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | 1771 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
1741 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", 1772 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1742 jabber_cmd_chat_invite, 1773 jabber_cmd_chat_invite,
1743 _("invite &lt;user&gt; [message]: Invite a user to the room."), 1774 _("invite &lt;user&gt; [message]: Invite a user to the room."),