Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/commands.c @ 617:d3a8b43bf9e7
Add "/authorization" command
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 16 Dec 2005 13:34:13 +0100 |
parents | 89f5672eb523 |
children | 97dd14e22b2a |
comparison
equal
deleted
inserted
replaced
616:a61a257ec38b | 617:d3a8b43bf9e7 |
---|---|
51 static void do_bind(char *arg); | 51 static void do_bind(char *arg); |
52 static void do_connect(char *arg); | 52 static void do_connect(char *arg); |
53 static void do_disconnect(char *arg); | 53 static void do_disconnect(char *arg); |
54 static void do_rawxml(char *arg); | 54 static void do_rawxml(char *arg); |
55 static void do_room(char *arg); | 55 static void do_room(char *arg); |
56 static void do_authorization(char *arg); | |
56 | 57 |
57 // Global variable for the commands list | 58 // Global variable for the commands list |
58 static GSList *Commands; | 59 static GSList *Commands; |
59 | 60 |
60 | 61 |
78 // ... | 79 // ... |
79 void cmd_init(void) | 80 void cmd_init(void) |
80 { | 81 { |
81 cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add); | 82 cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add); |
82 cmd_add("alias", "Add an alias", 0, 0, &do_alias); | 83 cmd_add("alias", "Add an alias", 0, 0, &do_alias); |
84 cmd_add("authorization", "Manage subscription authorizations", | |
85 COMPL_AUTH, COMPL_JID, &do_authorization); | |
83 cmd_add("bind", "Add an key binding", 0, 0, &do_bind); | 86 cmd_add("bind", "Add an key binding", 0, 0, &do_bind); |
84 cmd_add("buffer", "Manipulate current buddy's buffer (chat window)", | 87 cmd_add("buffer", "Manipulate current buddy's buffer (chat window)", |
85 COMPL_BUFFER, 0, &do_buffer); | 88 COMPL_BUFFER, 0, &do_buffer); |
86 cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear); | 89 cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear); |
87 cmd_add("connect", "Connect to the server", 0, 0, &do_connect); | 90 cmd_add("connect", "Connect to the server", 0, 0, &do_connect); |
96 COMPL_MULTILINE, 0, &do_msay); | 99 COMPL_MULTILINE, 0, &do_msay); |
97 cmd_add("room", "MUC actions command", COMPL_ROOM, 0, &do_room); | 100 cmd_add("room", "MUC actions command", COMPL_ROOM, 0, &do_room); |
98 cmd_add("quit", "Exit the software", 0, 0, NULL); | 101 cmd_add("quit", "Exit the software", 0, 0, NULL); |
99 cmd_add("rawxml", "Send a raw XML string", 0, 0, &do_rawxml); | 102 cmd_add("rawxml", "Send a raw XML string", 0, 0, &do_rawxml); |
100 cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename); | 103 cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename); |
101 //cmd_add("request_auth"); | |
102 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, | 104 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, |
103 &do_roster); | 105 &do_roster); |
104 cmd_add("say", "Say something to the selected buddy", 0, 0, &do_say); | 106 cmd_add("say", "Say something to the selected buddy", 0, 0, &do_say); |
105 cmd_add("say_to", "Say something to a specific buddy", COMPL_JID, 0, | 107 cmd_add("say_to", "Say something to a specific buddy", COMPL_JID, 0, |
106 &do_say_to); | 108 &do_say_to); |
107 //cmd_add("search"); | 109 //cmd_add("search"); |
108 //cmd_add("send_auth"); | |
109 cmd_add("set", "Set/query an option value", 0, 0, &do_set); | 110 cmd_add("set", "Set/query an option value", 0, 0, &do_set); |
110 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status); | 111 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status); |
111 cmd_add("status_to", "Show or set your status for one recipient", | 112 cmd_add("status_to", "Show or set your status for one recipient", |
112 COMPL_JID, COMPL_STATUS, &do_status_to); | 113 COMPL_JID, COMPL_STATUS, &do_status_to); |
113 | 114 |
169 compl_add_category_word(COMPL_ROOM, "remove"); | 170 compl_add_category_word(COMPL_ROOM, "remove"); |
170 compl_add_category_word(COMPL_ROOM, "role"); | 171 compl_add_category_word(COMPL_ROOM, "role"); |
171 compl_add_category_word(COMPL_ROOM, "topic"); | 172 compl_add_category_word(COMPL_ROOM, "topic"); |
172 compl_add_category_word(COMPL_ROOM, "unlock"); | 173 compl_add_category_word(COMPL_ROOM, "unlock"); |
173 compl_add_category_word(COMPL_ROOM, "whois"); | 174 compl_add_category_word(COMPL_ROOM, "whois"); |
175 | |
176 // Authorization category | |
177 compl_add_category_word(COMPL_AUTH, "allow"); | |
178 compl_add_category_word(COMPL_AUTH, "cancel"); | |
179 compl_add_category_word(COMPL_AUTH, "request"); | |
174 } | 180 } |
175 | 181 |
176 // expandalias(line) | 182 // expandalias(line) |
177 // If there is one, expand the alias in line and returns a new allocated line | 183 // If there is one, expand the alias in line and returns a new allocated line |
178 // If no alias is found, returns line | 184 // If no alias is found, returns line |
1626 } | 1632 } |
1627 | 1633 |
1628 free_arg_lst(paramlst); | 1634 free_arg_lst(paramlst); |
1629 } | 1635 } |
1630 | 1636 |
1637 static void do_authorization(char *arg) | |
1638 { | |
1639 char **paramlst; | |
1640 char *subcmd; | |
1641 | |
1642 if (!jb_getonline()) { | |
1643 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | |
1644 return; | |
1645 } | |
1646 | |
1647 paramlst = split_arg(arg, 2, 0); // subcmd, [jid] | |
1648 subcmd = *paramlst; | |
1649 arg = *(paramlst+1); | |
1650 | |
1651 if (!subcmd || !*subcmd) { | |
1652 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | |
1653 free_arg_lst(paramlst); | |
1654 return; | |
1655 } | |
1656 | |
1657 // Use the provided jid, if it looks valid | |
1658 if (arg) { | |
1659 if (!*arg) { | |
1660 // If no jid is provided, we use the current selected buddy | |
1661 arg = NULL; | |
1662 } else { | |
1663 if (check_jid_syntax(arg)) { | |
1664 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", arg); | |
1665 free_arg_lst(paramlst); | |
1666 return; | |
1667 } | |
1668 } | |
1669 } | |
1670 | |
1671 if (!arg) { // Use the current selected buddy's jid | |
1672 gpointer bud; | |
1673 guint type; | |
1674 | |
1675 if (!current_buddy) return; | |
1676 bud = BUDDATA(current_buddy); | |
1677 | |
1678 arg = (char*)buddy_getjid(bud); | |
1679 type = buddy_gettype(bud); | |
1680 | |
1681 if (!(type & (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT))) { | |
1682 scr_LogPrint(LPRINT_NORMAL, "Invalid buddy"); | |
1683 return; | |
1684 } | |
1685 } | |
1686 | |
1687 if (!strcasecmp(subcmd, "allow")) { | |
1688 jb_subscr_send_auth(arg); | |
1689 scr_LogPrint(LPRINT_LOGNORM, | |
1690 "<%s> is allowed to receive your presence updates", arg); | |
1691 } else if (!strcasecmp(subcmd, "cancel")) { | |
1692 jb_subscr_cancel_auth(arg); | |
1693 scr_LogPrint(LPRINT_LOGNORM, | |
1694 "<%s> is no more allowed to receive your presence updates", | |
1695 arg); | |
1696 } else if (!strcasecmp(subcmd, "request")) { | |
1697 jb_subscr_request_auth(arg); | |
1698 scr_LogPrint(LPRINT_LOGNORM, | |
1699 "Sent presence notification request to <%s>", arg); | |
1700 } else { | |
1701 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); | |
1702 } | |
1703 | |
1704 free_arg_lst(paramlst); | |
1705 } | |
1706 | |
1631 static void do_connect(char *arg) | 1707 static void do_connect(char *arg) |
1632 { | 1708 { |
1633 mcabber_connect(); | 1709 mcabber_connect(); |
1634 } | 1710 } |
1635 | 1711 |