Mercurial > hg
annotate mcabber/src/commands.c @ 1073:253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Fix a few memory leaks after calls to split_arg(), esp. in do_msay().
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 03 Dec 2006 19:29:53 +0100 |
parents | 2a3cfb98bd5e |
children | b2fc694a8228 |
rev | line source |
---|---|
47 | 1 /* |
699 | 2 * commands.c -- user commands handling |
393 | 3 * |
699 | 4 * Copyright (C) 2005, 2006 Mikael Berthe <bmikael@lists.lilotux.net> |
47 | 5 * |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or (at | |
9 * your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
19 * USA | |
20 */ | |
21 | |
95 | 22 #include <string.h> |
23 | |
47 | 24 #include "commands.h" |
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
25 #include "help.h" |
47 | 26 #include "jabglue.h" |
81 | 27 #include "roster.h" |
47 | 28 #include "screen.h" |
95 | 29 #include "compl.h" |
113 | 30 #include "hooks.h" |
191 | 31 #include "hbuf.h" |
47 | 32 #include "utils.h" |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
33 #include "settings.h" |
748 | 34 #include "events.h" |
47 | 35 |
967 | 36 #define IMSTATUS_AWAY "away" |
37 #define IMSTATUS_ONLINE "online" | |
38 #define IMSTATUS_OFFLINE "offline" | |
39 #define IMSTATUS_FREE4CHAT "free" | |
40 #define IMSTATUS_INVISIBLE "invisible" | |
41 #define IMSTATUS_AVAILABLE "avail" | |
42 #define IMSTATUS_NOTAVAILABLE "notavail" | |
43 #define IMSTATUS_DONOTDISTURB "dnd" | |
44 | |
104 | 45 // Commands callbacks |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
46 static void do_roster(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
47 static void do_status(char *arg); |
444 | 48 static void do_status_to(char *arg); |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
49 static void do_add(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
50 static void do_del(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
51 static void do_group(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
52 static void do_say(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
53 static void do_msay(char *arg); |
480 | 54 static void do_say_to(char *arg); |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
55 static void do_buffer(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
56 static void do_clear(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
57 static void do_info(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
58 static void do_rename(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
59 static void do_move(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
60 static void do_set(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
61 static void do_alias(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
62 static void do_bind(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
63 static void do_connect(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
64 static void do_disconnect(char *arg); |
436 | 65 static void do_rawxml(char *arg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
66 static void do_room(char *arg); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
67 static void do_authorization(char *arg); |
622 | 68 static void do_version(char *arg); |
693 | 69 static void do_request(char *arg); |
748 | 70 static void do_event(char *arg); |
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
71 static void do_help(char *arg); |
1066 | 72 static void do_pgp(char *arg); |
47 | 73 |
104 | 74 // Global variable for the commands list |
95 | 75 static GSList *Commands; |
76 | |
104 | 77 |
95 | 78 // cmd_add() |
79 // Adds a command to the commands list and to the CMD completion list | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
80 static void cmd_add(const char *name, const char *help, |
1059 | 81 guint flags_row1, guint flags_row2, void (*f)(char*)) |
95 | 82 { |
83 cmd *n_cmd = g_new0(cmd, 1); | |
84 strncpy(n_cmd->name, name, 32-1); | |
85 n_cmd->help = help; | |
86 n_cmd->completion_flags[0] = flags_row1; | |
87 n_cmd->completion_flags[1] = flags_row2; | |
88 n_cmd->func = f; | |
102 | 89 Commands = g_slist_append(Commands, n_cmd); |
95 | 90 // Add to completion CMD category |
91 compl_add_category_word(COMPL_CMD, name); | |
92 } | |
93 | |
94 // cmd_init() | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
95 // Commands table initialization |
95 | 96 void cmd_init(void) |
97 { | |
124 | 98 cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add); |
285 | 99 cmd_add("alias", "Add an alias", 0, 0, &do_alias); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
100 cmd_add("authorization", "Manage subscription authorizations", |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
101 COMPL_AUTH, COMPL_JID, &do_authorization); |
288 | 102 cmd_add("bind", "Add an key binding", 0, 0, &do_bind); |
187 | 103 cmd_add("buffer", "Manipulate current buddy's buffer (chat window)", |
104 COMPL_BUFFER, 0, &do_buffer); | |
108 | 105 cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear); |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
106 cmd_add("connect", "Connect to the server", 0, 0, &do_connect); |
205 | 107 cmd_add("del", "Delete the current buddy", 0, 0, &do_del); |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
108 cmd_add("disconnect", "Disconnect from server", 0, 0, &do_disconnect); |
757
ae23c8826efb
Improve completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
755
diff
changeset
|
109 cmd_add("event", "Process an event", COMPL_EVENTSID, COMPL_EVENTS, &do_event); |
128 | 110 cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group); |
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
111 cmd_add("help", "Display some help", COMPL_CMD, 0, &do_help); |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
112 cmd_add("info", "Show basic info on current buddy", 0, 0, &do_info); |
225 | 113 cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, |
114 0, &do_move); | |
238 | 115 cmd_add("msay", "Send a multi-lines message to the selected buddy", |
116 COMPL_MULTILINE, 0, &do_msay); | |
1066 | 117 cmd_add("pgp", "Manage PGP settings", COMPL_PGP, COMPL_JID, &do_pgp); |
95 | 118 cmd_add("quit", "Exit the software", 0, 0, NULL); |
436 | 119 cmd_add("rawxml", "Send a raw XML string", 0, 0, &do_rawxml); |
208 | 120 cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename); |
902
2016f52a167f
Sort commands (for the completion system)
Mikael Berthe <mikael@lilotux.net>
parents:
900
diff
changeset
|
121 cmd_add("request", "Send a Jabber IQ request", COMPL_REQUEST, COMPL_JID, |
2016f52a167f
Sort commands (for the completion system)
Mikael Berthe <mikael@lilotux.net>
parents:
900
diff
changeset
|
122 &do_request); |
2016f52a167f
Sort commands (for the completion system)
Mikael Berthe <mikael@lilotux.net>
parents:
900
diff
changeset
|
123 cmd_add("room", "MUC actions command", COMPL_ROOM, 0, &do_room); |
128 | 124 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, |
125 &do_roster); | |
132 | 126 cmd_add("say", "Say something to the selected buddy", 0, 0, &do_say); |
488
9e8519078e00
Enable jid completion for /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
486
diff
changeset
|
127 cmd_add("say_to", "Say something to a specific buddy", COMPL_JID, 0, |
9e8519078e00
Enable jid completion for /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
486
diff
changeset
|
128 &do_say_to); |
95 | 129 //cmd_add("search"); |
310 | 130 cmd_add("set", "Set/query an option value", 0, 0, &do_set); |
116 | 131 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status); |
444 | 132 cmd_add("status_to", "Show or set your status for one recipient", |
133 COMPL_JID, COMPL_STATUS, &do_status_to); | |
622 | 134 cmd_add("version", "Show mcabber version", 0, 0, &do_version); |
95 | 135 |
136 // Status category | |
137 compl_add_category_word(COMPL_STATUS, "online"); | |
138 compl_add_category_word(COMPL_STATUS, "avail"); | |
139 compl_add_category_word(COMPL_STATUS, "invisible"); | |
140 compl_add_category_word(COMPL_STATUS, "free"); | |
141 compl_add_category_word(COMPL_STATUS, "dnd"); | |
142 compl_add_category_word(COMPL_STATUS, "notavail"); | |
143 compl_add_category_word(COMPL_STATUS, "away"); | |
103 | 144 |
145 // Roster category | |
146 compl_add_category_word(COMPL_ROSTER, "bottom"); | |
265 | 147 compl_add_category_word(COMPL_ROSTER, "top"); |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
148 compl_add_category_word(COMPL_ROSTER, "up"); |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
149 compl_add_category_word(COMPL_ROSTER, "down"); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
150 compl_add_category_word(COMPL_ROSTER, "hide"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
151 compl_add_category_word(COMPL_ROSTER, "show"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
152 compl_add_category_word(COMPL_ROSTER, "toggle"); |
103 | 153 compl_add_category_word(COMPL_ROSTER, "hide_offline"); |
154 compl_add_category_word(COMPL_ROSTER, "show_offline"); | |
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
155 compl_add_category_word(COMPL_ROSTER, "toggle_offline"); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
156 compl_add_category_word(COMPL_ROSTER, "item_lock"); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
157 compl_add_category_word(COMPL_ROSTER, "item_unlock"); |
330 | 158 compl_add_category_word(COMPL_ROSTER, "alternate"); |
265 | 159 compl_add_category_word(COMPL_ROSTER, "search"); |
236 | 160 compl_add_category_word(COMPL_ROSTER, "unread_first"); |
161 compl_add_category_word(COMPL_ROSTER, "unread_next"); | |
1016 | 162 compl_add_category_word(COMPL_ROSTER, "note"); |
127 | 163 |
187 | 164 // Roster category |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
165 compl_add_category_word(COMPL_BUFFER, "clear"); |
187 | 166 compl_add_category_word(COMPL_BUFFER, "bottom"); |
167 compl_add_category_word(COMPL_BUFFER, "top"); | |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
168 compl_add_category_word(COMPL_BUFFER, "up"); |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
169 compl_add_category_word(COMPL_BUFFER, "down"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
170 compl_add_category_word(COMPL_BUFFER, "search_backward"); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
171 compl_add_category_word(COMPL_BUFFER, "search_forward"); |
464 | 172 compl_add_category_word(COMPL_BUFFER, "date"); |
462 | 173 compl_add_category_word(COMPL_BUFFER, "%"); |
866 | 174 compl_add_category_word(COMPL_BUFFER, "purge"); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
175 compl_add_category_word(COMPL_BUFFER, "scroll_lock"); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
176 compl_add_category_word(COMPL_BUFFER, "scroll_unlock"); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
177 compl_add_category_word(COMPL_BUFFER, "scroll_toggle"); |
187 | 178 |
127 | 179 // Group category |
240 | 180 compl_add_category_word(COMPL_GROUP, "fold"); |
181 compl_add_category_word(COMPL_GROUP, "unfold"); | |
130 | 182 compl_add_category_word(COMPL_GROUP, "toggle"); |
238 | 183 |
184 // Multi-line (msay) category | |
185 compl_add_category_word(COMPL_MULTILINE, "abort"); | |
186 compl_add_category_word(COMPL_MULTILINE, "begin"); | |
187 compl_add_category_word(COMPL_MULTILINE, "send"); | |
636 | 188 compl_add_category_word(COMPL_MULTILINE, "send_to"); |
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
189 compl_add_category_word(COMPL_MULTILINE, "toggle"); |
838
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
190 compl_add_category_word(COMPL_MULTILINE, "toggle_verbatim"); |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
191 compl_add_category_word(COMPL_MULTILINE, "verbatim"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
192 |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
193 // Room category |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
194 compl_add_category_word(COMPL_ROOM, "affil"); |
571 | 195 compl_add_category_word(COMPL_ROOM, "ban"); |
1009 | 196 compl_add_category_word(COMPL_ROOM, "bookmark"); |
599 | 197 compl_add_category_word(COMPL_ROOM, "destroy"); |
486 | 198 compl_add_category_word(COMPL_ROOM, "invite"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
199 compl_add_category_word(COMPL_ROOM, "join"); |
568 | 200 compl_add_category_word(COMPL_ROOM, "kick"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
201 compl_add_category_word(COMPL_ROOM, "leave"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
202 compl_add_category_word(COMPL_ROOM, "names"); |
470 | 203 compl_add_category_word(COMPL_ROOM, "nick"); |
490 | 204 compl_add_category_word(COMPL_ROOM, "privmsg"); |
448
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
205 compl_add_category_word(COMPL_ROOM, "remove"); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
206 compl_add_category_word(COMPL_ROOM, "role"); |
475
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
207 compl_add_category_word(COMPL_ROOM, "topic"); |
449 | 208 compl_add_category_word(COMPL_ROOM, "unlock"); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
209 compl_add_category_word(COMPL_ROOM, "whois"); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
210 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
211 // Authorization category |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
212 compl_add_category_word(COMPL_AUTH, "allow"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
213 compl_add_category_word(COMPL_AUTH, "cancel"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
214 compl_add_category_word(COMPL_AUTH, "request"); |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
215 compl_add_category_word(COMPL_AUTH, "request_unsubscribe"); |
693 | 216 |
217 // Request (query) category | |
1015 | 218 compl_add_category_word(COMPL_REQUEST, "last"); |
693 | 219 compl_add_category_word(COMPL_REQUEST, "time"); |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
220 compl_add_category_word(COMPL_REQUEST, "vcard"); |
693 | 221 compl_add_category_word(COMPL_REQUEST, "version"); |
750
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
222 |
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
223 // Events category |
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
224 compl_add_category_word(COMPL_EVENTS, "accept"); |
755 | 225 compl_add_category_word(COMPL_EVENTS, "ignore"); |
750
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
226 compl_add_category_word(COMPL_EVENTS, "reject"); |
1066 | 227 |
228 // PGP category | |
229 compl_add_category_word(COMPL_PGP, "disable"); | |
230 compl_add_category_word(COMPL_PGP, "enable"); | |
231 compl_add_category_word(COMPL_PGP, "info"); | |
232 compl_add_category_word(COMPL_PGP, "setkey"); | |
95 | 233 } |
94 | 234 |
285 | 235 // expandalias(line) |
236 // If there is one, expand the alias in line and returns a new allocated line | |
237 // If no alias is found, returns line | |
238 // Note : if the returned pointer is different from line, the caller should | |
239 // g_free() the pointer after use | |
240 char *expandalias(char *line) | |
241 { | |
242 const char *p1, *p2; | |
243 char *word; | |
244 const gchar *value; | |
245 char *newline = line; | |
246 | |
967 | 247 // Ignore leading COMMAND_CHAR |
248 for (p1 = line ; *p1 == COMMAND_CHAR ; p1++) | |
285 | 249 ; |
250 // Locate the end of the word | |
251 for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) | |
252 ; | |
253 // Extract the word | |
254 word = g_strndup(p1, p2-p1); | |
255 | |
256 // Look for an alias in the list | |
257 value = settings_get(SETTINGS_TYPE_ALIAS, (const char*)word); | |
258 if (value) { | |
259 // There is an alias to expand | |
260 newline = g_new(char, strlen(value)+strlen(p2)+2); | |
967 | 261 *newline = COMMAND_CHAR; |
285 | 262 strcpy(newline+1, value); |
263 strcat(newline, p2); | |
264 } | |
265 g_free(word); | |
266 | |
267 return newline; | |
268 } | |
269 | |
102 | 270 // cmd_get |
271 // Finds command in the command list structure. | |
272 // Returns a pointer to the cmd entry, or NULL if command not found. | |
238 | 273 cmd *cmd_get(const char *command) |
102 | 274 { |
238 | 275 const char *p1, *p2; |
102 | 276 char *com; |
277 GSList *sl_com; | |
285 | 278 |
967 | 279 // Ignore leading COMMAND_CHAR |
280 for (p1 = command ; *p1 == COMMAND_CHAR ; p1++) | |
102 | 281 ; |
282 // Locate the end of the command | |
283 for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) | |
284 ; | |
285 // Copy the clean command | |
286 com = g_strndup(p1, p2-p1); | |
287 | |
288 // Look for command in the list | |
289 for (sl_com=Commands; sl_com; sl_com = g_slist_next(sl_com)) { | |
290 if (!strcasecmp(com, ((cmd*)sl_com->data)->name)) | |
291 break; | |
292 } | |
293 g_free(com); | |
294 | |
295 if (sl_com) // Command has been found. | |
296 return (cmd*)sl_com->data; | |
297 return NULL; | |
298 } | |
299 | |
47 | 300 // send_message(msg) |
301 // Write the message in the buddy's window and send the message on | |
302 // the network. | |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
303 static void send_message(const char *msg, const char *subj) |
47 | 304 { |
1058 | 305 const char *bjid; |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
306 guint crypted; |
393 | 307 |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
308 if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
309 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
310 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
311 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
312 |
81 | 313 if (!current_buddy) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
314 scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected."); |
81 | 315 return; |
316 } | |
317 | |
1058 | 318 bjid = CURRENT_JID; |
319 if (!bjid) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
320 scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected."); |
81 | 321 return; |
322 } | |
47 | 323 |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
324 // Network part |
1058 | 325 jb_send_msg(bjid, msg, buddy_gettype(BUDDATA(current_buddy)), subj, NULL, |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
326 &crypted); |
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
327 |
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
328 // Hook |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
329 if (buddy_gettype(BUDDATA(current_buddy)) != ROSTER_TYPE_ROOM) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
330 // local part (UI, logging, etc.) |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
331 gchar *hmsg; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
332 if (subj) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
333 hmsg = g_strdup_printf("[%s]\n%s", subj, msg); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
334 else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
335 hmsg = (char*)msg; |
1058 | 336 hk_message_out(bjid, NULL, 0, hmsg, crypted); |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
337 if (hmsg != msg) g_free(hmsg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
338 } |
47 | 339 } |
340 | |
288 | 341 // process_command(line) |
342 // Process a command line. | |
343 // Return 255 if this is the /quit command, and 0 for the other commands. | |
344 int process_command(char *line) | |
47 | 345 { |
101 | 346 char *p; |
285 | 347 char *xpline; |
104 | 348 cmd *curcmd; |
349 | |
285 | 350 // We do alias expansion here |
288 | 351 if (scr_get_multimode() != 2) |
352 xpline = expandalias(line); | |
353 else | |
354 xpline = line; // No expansion in verbatim multi-line mode | |
285 | 355 |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
356 // We want to have a copy |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
357 if (xpline == line) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
358 xpline = g_strdup(line); |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
359 |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
360 // Remove trailing spaces: |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
361 for (p=xpline ; *p ; p++) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
362 ; |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
363 for (p-- ; p>xpline && (*p == ' ') ; p--) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
364 *p = 0; |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
365 |
101 | 366 // Command "quit"? |
967 | 367 if ((scr_get_multimode() != 2) |
368 && (!strncasecmp(xpline, mkcmdstr("quit"), strlen(mkcmdstr("quit"))))) | |
285 | 369 if (!xpline[5] || xpline[5] == ' ') |
116 | 370 return 255; |
104 | 371 |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
372 // If verbatim multi-line mode, we check if another /msay command is typed |
967 | 373 if ((scr_get_multimode() == 2) |
374 && (strncasecmp(xpline, mkcmdstr("msay "), strlen(mkcmdstr("msay "))))) { | |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
375 // It isn't an /msay command |
285 | 376 scr_append_multiline(xpline); |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
377 g_free(xpline); |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
378 return 0; |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
379 } |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
380 |
47 | 381 // Commands handling |
285 | 382 curcmd = cmd_get(xpline); |
47 | 383 |
104 | 384 if (!curcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
385 scr_LogPrint(LPRINT_NORMAL, "Unrecognized command. " |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
386 "Please see the manual for a list of known commands."); |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
387 g_free(xpline); |
104 | 388 return 0; |
389 } | |
390 if (!curcmd->func) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
391 scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
392 "This functionality is not yet implemented, sorry."); |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
393 g_free(xpline); |
104 | 394 return 0; |
395 } | |
396 // Lets go to the command parameters | |
285 | 397 for (p = xpline+1; *p && (*p != ' ') ; p++) |
104 | 398 ; |
399 // Skip spaces | |
285 | 400 while (*p && (*p == ' ')) |
401 p++; | |
104 | 402 // Call command-specific function |
285 | 403 (*curcmd->func)(p); |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
404 g_free(xpline); |
47 | 405 return 0; |
406 } | |
407 | |
288 | 408 // process_line(line) |
409 // Process a command/message line. | |
410 // If this isn't a command, this is a message and it is sent to the | |
411 // currently selected buddy. | |
412 // Return 255 if the line is the /quit command, or 0. | |
413 int process_line(char *line) | |
414 { | |
415 if (!*line) { // User only pressed enter | |
416 if (scr_get_multimode()) { | |
417 scr_append_multiline(""); | |
418 return 0; | |
419 } | |
420 if (current_buddy) { | |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
421 // Enter chat mode |
288 | 422 scr_set_chatmode(TRUE); |
423 scr_ShowBuddyWindow(); | |
424 } | |
425 return 0; | |
426 } | |
427 | |
967 | 428 if (*line != COMMAND_CHAR) { |
288 | 429 // This isn't a command |
430 if (scr_get_multimode()) | |
431 scr_append_multiline(line); | |
432 else | |
433 do_say(line); | |
434 return 0; | |
435 } | |
436 | |
437 /* It is (probably) a command -- except for verbatim multi-line mode */ | |
438 return process_command(line); | |
439 } | |
440 | |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
441 // Helper routine for buffer item_{lock,unlock} |
1058 | 442 static void roster_buddylock(char *bjid, bool lock) |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
443 { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
444 gpointer bud = NULL; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
445 bool may_need_refresh = FALSE; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
446 |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
447 // Allow special jid "" or "." (current buddy) |
1058 | 448 if (bjid && (!*bjid || !strcmp(bjid, "."))) |
449 bjid = NULL; | |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
450 |
1058 | 451 if (bjid) { |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
452 // The JID has been specified. Quick check... |
1058 | 453 if (check_jid_syntax(bjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
454 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
455 "<%s> is not a valid Jabber ID.", bjid); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
456 } else { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
457 // Find the buddy |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
458 GSList *roster_elt; |
1058 | 459 roster_elt = roster_find(bjid, jidsearch, |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
460 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
461 if (roster_elt) |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
462 bud = roster_elt->data; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
463 else |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
464 scr_LogPrint(LPRINT_NORMAL, "This jid isn't in the roster."); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
465 may_need_refresh = TRUE; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
466 } |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
467 } else { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
468 // Use the current buddy |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
469 if (current_buddy) |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
470 bud = BUDDATA(current_buddy); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
471 } |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
472 |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
473 // Update the ROSTER_FLAG_USRLOCK flag |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
474 if (bud) { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
475 buddy_setflags(bud, ROSTER_FLAG_USRLOCK, lock); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
476 if (may_need_refresh) |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
477 buddylist_build(); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
478 update_roster = TRUE; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
479 } |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
480 } |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
481 |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
482 // display_and_free_note(note, winId) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
483 // Display the note information in the winId buffer, and free note |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
484 // (winId is a bare jid or NULL for the status window, in which case we |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
485 // display the note jid too) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
486 static void display_and_free_note(struct annotation *note, const char *winId) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
487 { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
488 gchar tbuf[128]; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
489 GString *sbuf; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
490 guint msg_flag = HBB_PREFIX_INFO; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
491 /* We use the flag prefix_info for the first line, and prefix_none |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
492 for the other lines, for better readability */ |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
493 |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
494 if (!note) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
495 return; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
496 |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
497 sbuf = g_string_new(""); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
498 |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
499 if (!winId) { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
500 // We're writing to the status window, so let's show the jid too. |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
501 g_string_printf(sbuf, "Annotation on <%s>", note->jid); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
502 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
503 msg_flag = HBB_PREFIX_NONE; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
504 } |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
505 |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
506 // If we have the creation date, display it |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
507 if (note->cdate) { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
508 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
509 localtime(¬e->cdate)); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
510 g_string_printf(sbuf, "Note created %s", tbuf); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
511 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
512 msg_flag = HBB_PREFIX_NONE; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
513 } |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
514 // If we have the modification date, display it |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
515 // unless it's the same as the creation date |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
516 if (note->mdate && note->mdate != note->cdate) { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
517 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
518 localtime(¬e->mdate)); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
519 g_string_printf(sbuf, "Note modified %s", tbuf); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
520 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
521 msg_flag = HBB_PREFIX_NONE; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
522 } |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
523 // Note text |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
524 g_string_printf(sbuf, "Note: %s", note->text); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
525 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
526 |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
527 g_string_free(sbuf, TRUE); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
528 g_free(note->text); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
529 g_free(note->jid); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
530 g_free(note); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
531 } |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
532 |
1059 | 533 static void display_all_annotations(void) |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
534 { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
535 GSList *notes; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
536 notes = jb_get_all_storage_rosternotes(); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
537 // Call display_and_free_note() for each note, |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
538 // with winId = NULL (special window) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
539 g_slist_foreach(notes, (GFunc)&display_and_free_note, NULL); |
1038
f9e8fd9cb58b
Set new_msg flag when listing annotations in the status buffer in non-chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
1037
diff
changeset
|
540 if (notes) { |
f9e8fd9cb58b
Set new_msg flag when listing annotations in the status buffer in non-chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
1037
diff
changeset
|
541 scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
f9e8fd9cb58b
Set new_msg flag when listing annotations in the status buffer in non-chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
1037
diff
changeset
|
542 update_roster = TRUE; |
f9e8fd9cb58b
Set new_msg flag when listing annotations in the status buffer in non-chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
1037
diff
changeset
|
543 } |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
544 g_slist_free(notes); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
545 } |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
546 |
1016 | 547 static void roster_note(char *arg) |
548 { | |
1058 | 549 const char *bjid; |
1016 | 550 guint type; |
551 | |
552 if (!current_buddy) | |
553 return; | |
554 | |
1058 | 555 bjid = buddy_getjid(BUDDATA(current_buddy)); |
1016 | 556 type = buddy_gettype(BUDDATA(current_buddy)); |
557 | |
1058 | 558 if (!bjid && type == ROSTER_TYPE_SPECIAL && !arg) { |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
559 // We're in the status window (the only special buffer currently) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
560 // Let's display all server notes |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
561 display_all_annotations(); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
562 return; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
563 } |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
564 |
1058 | 565 if (!bjid || (type != ROSTER_TYPE_USER && |
1016 | 566 type != ROSTER_TYPE_ROOM && |
567 type != ROSTER_TYPE_AGENT)) { | |
568 scr_LogPrint(LPRINT_NORMAL, "This item can't have a note."); | |
569 return; | |
570 } | |
571 | |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
572 if (arg && *arg) { // Set a note |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
573 gchar *msg, *notetxt; |
1016 | 574 msg = to_utf8(arg); |
575 if (!strcmp(msg, "-")) | |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
576 notetxt = NULL; // delete note |
1016 | 577 else |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
578 notetxt = msg; |
1058 | 579 jb_set_storage_rosternotes(bjid, notetxt); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
580 g_free(msg); |
1016 | 581 } else { // Display a note |
1058 | 582 struct annotation *note = jb_get_storage_rosternotes(bjid, FALSE); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
583 if (note) { |
1058 | 584 display_and_free_note(note, bjid); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
585 } else { |
1058 | 586 scr_WriteIncomingMessage(bjid, "This item doesn't have a note.", 0, |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
587 HBB_PREFIX_INFO); |
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
588 } |
1016 | 589 } |
590 } | |
591 | |
104 | 592 /* Commands callback functions */ |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
593 /* All these do_*() functions will be called with a "arg" parameter */ |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
594 /* (with arg not null) */ |
104 | 595 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
596 static void do_roster(char *arg) |
104 | 597 { |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
598 char **paramlst; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
599 char *subcmd; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
600 |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
601 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
602 subcmd = *paramlst; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
603 arg = *(paramlst+1); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
604 |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
605 if (!subcmd || !*subcmd) { |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
606 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
607 free_arg_lst(paramlst); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
608 return; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
609 } |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
610 |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
611 if (!strcasecmp(subcmd, "top")) { |
104 | 612 scr_RosterTop(); |
128 | 613 update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
614 } else if (!strcasecmp(subcmd, "bottom")) { |
104 | 615 scr_RosterBottom(); |
128 | 616 update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
617 } else if (!strcasecmp(subcmd, "hide")) { |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
618 scr_RosterVisibility(0); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
619 } else if (!strcasecmp(subcmd, "show")) { |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
620 scr_RosterVisibility(1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
621 } else if (!strcasecmp(subcmd, "toggle")) { |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
622 scr_RosterVisibility(-1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
623 } else if (!strcasecmp(subcmd, "hide_offline")) { |
120 | 624 buddylist_set_hide_offline_buddies(TRUE); |
104 | 625 if (current_buddy) |
626 buddylist_build(); | |
128 | 627 update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
628 } else if (!strcasecmp(subcmd, "show_offline")) { |
120 | 629 buddylist_set_hide_offline_buddies(FALSE); |
124 | 630 buddylist_build(); |
128 | 631 update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
632 } else if (!strcasecmp(subcmd, "toggle_offline")) { |
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
633 buddylist_set_hide_offline_buddies(-1); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
634 buddylist_build(); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
635 update_roster = TRUE; |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
636 } else if (!strcasecmp(subcmd, "item_lock")) { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
637 roster_buddylock(arg, TRUE); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
638 } else if (!strcasecmp(subcmd, "item_unlock")) { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
639 roster_buddylock(arg, FALSE); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
640 } else if (!strcasecmp(subcmd, "unread_first")) { |
236 | 641 scr_RosterUnreadMessage(0); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
642 } else if (!strcasecmp(subcmd, "unread_next")) { |
236 | 643 scr_RosterUnreadMessage(1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
644 } else if (!strcasecmp(subcmd, "alternate")) { |
330 | 645 scr_RosterJumpAlternate(); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
646 } else if (!strncasecmp(subcmd, "search", 6)) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
647 strip_arg_special_chars(arg); |
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
648 if (!arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
649 scr_LogPrint(LPRINT_NORMAL, "What name or JID are you looking for?"); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
650 free_arg_lst(paramlst); |
265 | 651 return; |
652 } | |
978 | 653 scr_RosterSearch(arg); |
265 | 654 update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
655 } else if (!strcasecmp(subcmd, "up")) { |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
656 scr_RosterUp(); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
657 } else if (!strcasecmp(subcmd, "down")) { |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
658 scr_RosterDown(); |
1016 | 659 } else if (!strcasecmp(subcmd, "note")) { |
660 roster_note(arg); | |
104 | 661 } else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
662 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
663 free_arg_lst(paramlst); |
104 | 664 } |
108 | 665 |
444 | 666 // setstatus(recipient, arg) |
667 // Set your Jabber status. | |
668 // - if recipient is not NULL, the status is sent to this contact only | |
669 // - arg must be "status message" (message is optional) | |
670 static void setstatus(const char *recipient, const char *arg) | |
116 | 671 { |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
672 char **paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
673 char *status; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
674 char *msg; |
116 | 675 enum imstatus st; |
676 | |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
677 if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
678 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
679 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
680 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
681 |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
682 paramlst = split_arg(arg, 2, 0); // status, message |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
683 status = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
684 msg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
685 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
686 if (!status) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
687 free_arg_lst(paramlst); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
688 return; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
689 } |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
690 |
967 | 691 if (!strcasecmp(status, IMSTATUS_OFFLINE)) st = offline; |
692 else if (!strcasecmp(status, IMSTATUS_ONLINE)) st = available; | |
693 else if (!strcasecmp(status, IMSTATUS_AVAILABLE)) st = available; | |
694 else if (!strcasecmp(status, IMSTATUS_AWAY)) st = away; | |
695 else if (!strcasecmp(status, IMSTATUS_INVISIBLE)) st = invisible; | |
696 else if (!strcasecmp(status, IMSTATUS_DONOTDISTURB)) st = dontdisturb; | |
697 else if (!strcasecmp(status, IMSTATUS_NOTAVAILABLE)) st = notavail; | |
698 else if (!strcasecmp(status, IMSTATUS_FREE4CHAT)) st = freeforchat; | |
116 | 699 else { |
444 | 700 scr_LogPrint(LPRINT_NORMAL, "Unrecognized status!"); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
701 free_arg_lst(paramlst); |
116 | 702 return; |
703 } | |
704 | |
677
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
705 // Use provided message |
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
706 if (msg && !*msg) { |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
707 msg = NULL; |
677
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
708 } |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
709 |
528
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
710 // If a recipient is specified, let's don't use default status messages |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
711 if (recipient && !msg) |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
712 msg = ""; |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
713 |
1050
ea71d31a2607
PGP: Do not sign presence messages to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
1043
diff
changeset
|
714 jb_setstatus(st, recipient, msg, FALSE); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
715 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
716 free_arg_lst(paramlst); |
444 | 717 } |
718 | |
719 static void do_status(char *arg) | |
720 { | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
721 if (!*arg) { |
519
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
722 const char *sm = jb_getstatusmsg(); |
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
723 scr_LogPrint(LPRINT_NORMAL, "Your status is: [%c] %s", |
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
724 imstatus2char[jb_getstatus()], |
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
725 (sm ? sm : "")); |
444 | 726 return; |
727 } | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
728 arg = to_utf8(arg); |
444 | 729 setstatus(NULL, arg); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
730 g_free(arg); |
444 | 731 } |
732 | |
733 static void do_status_to(char *arg) | |
734 { | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
735 char **paramlst; |
1058 | 736 char *fjid, *st, *msg; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
737 char *jid_utf8 = NULL; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
738 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
739 paramlst = split_arg(arg, 3, 1); // jid, status, [message] |
1058 | 740 fjid = *paramlst; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
741 st = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
742 msg = *(paramlst+2); |
444 | 743 |
1058 | 744 if (!fjid || !st) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
745 scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
746 "Please specify both a Jabber ID and a status."); |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
747 free_arg_lst(paramlst); |
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
748 return; |
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
749 } |
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
750 |
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
751 // Allow things like /status_to "" away |
1058 | 752 if (!*fjid || !strcmp(fjid, ".")) |
753 fjid = NULL; | |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
754 |
1058 | 755 if (fjid) { |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
756 // The JID has been specified. Quick check... |
1058 | 757 if (check_jid_syntax(fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
758 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
759 "<%s> is not a valid Jabber ID.", fjid); |
1058 | 760 fjid = NULL; |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
761 } else { |
696
ee06382dfb22
/status_to: Do not convert resource name to lower case
Mikael Berthe <mikael@lilotux.net>
parents:
694
diff
changeset
|
762 // Convert jid to lowercase |
1058 | 763 char *p = fjid; |
977
5b01de4ac5e1
Cosmetic changes
Alexis Hildebrandt <afh [at] 2drop [dot] net>
parents:
974
diff
changeset
|
764 for ( ; *p && *p != JID_RESOURCE_SEPARATOR; p++) |
696
ee06382dfb22
/status_to: Do not convert resource name to lower case
Mikael Berthe <mikael@lilotux.net>
parents:
694
diff
changeset
|
765 *p = tolower(*p); |
1058 | 766 fjid = jid_utf8 = to_utf8(fjid); |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
767 } |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
768 } else { |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
769 // Add the current buddy |
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
770 if (current_buddy) |
1058 | 771 fjid = (char*)buddy_getjid(BUDDATA(current_buddy)); |
772 if (!fjid) | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
773 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
774 } |
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
775 |
1058 | 776 if (fjid) { |
777 char *cmdline; | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
778 if (!msg) |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
779 msg = ""; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
780 msg = to_utf8(msg); |
1058 | 781 cmdline = g_strdup_printf("%s %s", st, msg); |
782 scr_LogPrint(LPRINT_LOGNORM, "Sending to <%s> /status %s", fjid, cmdline); | |
783 setstatus(fjid, cmdline); | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
784 g_free(msg); |
1058 | 785 g_free(cmdline); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
786 g_free(jid_utf8); |
444 | 787 } |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
788 free_arg_lst(paramlst); |
116 | 789 } |
790 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
791 static void do_add(char *arg) |
124 | 792 { |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
793 char **paramlst; |
244 | 794 char *id, *nick; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
795 char *jid_utf8 = NULL; |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
796 |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
797 if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
798 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
799 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
800 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
801 |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
802 paramlst = split_arg(arg, 2, 0); // jid, [nickname] |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
803 id = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
804 nick = *(paramlst+1); |
244 | 805 |
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
806 if (!id) |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
807 nick = NULL; // Allow things like: /add "" nick |
641
62679532ea55
Allow special jid "." in commands /add and /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
640
diff
changeset
|
808 else if (!*id || !strcmp(id, ".")) |
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
809 id = NULL; |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
810 |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
811 if (id) { |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
812 // The JID has been specified. Quick check... |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
813 if (check_jid_syntax(id)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
814 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
815 "<%s> is not a valid Jabber ID.", id); |
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
816 id = NULL; |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
817 } else { |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
818 mc_strtolower(id); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
819 // Actually an UTF-8 id isn't needed because only the bare jid will |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
820 // be used. |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
821 id = jid_utf8 = to_utf8(id); |
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
822 } |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
823 } else { |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
824 // Add the current buddy |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
825 if (current_buddy) |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
826 id = (char*)buddy_getjid(BUDDATA(current_buddy)); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
827 if (!id) |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
828 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
829 } |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
830 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
831 if (nick) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
832 nick = to_utf8(nick); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
833 |
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
834 if (id) { |
452 | 835 // 2nd parameter = optional nickname |
836 jb_addbuddy(id, nick, NULL); | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
837 scr_LogPrint(LPRINT_LOGNORM, "Sent presence notification request to <%s>.", |
452 | 838 id); |
839 } | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
840 |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
841 g_free(jid_utf8); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
842 g_free(nick); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
843 free_arg_lst(paramlst); |
124 | 844 } |
128 | 845 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
846 static void do_del(char *arg) |
206 | 847 { |
1058 | 848 const char *bjid; |
206 | 849 |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
850 if (*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
851 scr_LogPrint(LPRINT_NORMAL, "This action does not require a parameter; " |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
852 "the currently-selected buddy will be deleted."); |
206 | 853 return; |
854 } | |
855 | |
1058 | 856 if (!current_buddy) |
857 return; | |
858 bjid = buddy_getjid(BUDDATA(current_buddy)); | |
859 if (!bjid) | |
860 return; | |
206 | 861 |
540
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
862 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_ROOM) { |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
863 // This is a chatroom |
652
b243d3b3ff1b
We do not need buddy_isresource() anymore
Mikael Berthe <mikael@lilotux.net>
parents:
650
diff
changeset
|
864 if (buddy_getinsideroom(BUDDATA(current_buddy))) { |
540
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
865 scr_LogPrint(LPRINT_NORMAL, "You haven't left this room!"); |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
866 return; |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
867 } |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
868 } |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
869 |
1058 | 870 scr_LogPrint(LPRINT_LOGNORM, "Removing <%s>...", bjid); |
871 jb_delbuddy(bjid); | |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
861
diff
changeset
|
872 scr_UpdateBuddyWindow(); |
206 | 873 } |
874 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
875 static void do_group(char *arg) |
128 | 876 { |
877 gpointer group; | |
958
30b799632653
Cosmetics (change a variable name)
Mikael Berthe <mikael@lilotux.net>
parents:
957
diff
changeset
|
878 guint leave_buddywindow; |
128 | 879 |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
880 if (!*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
881 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
128 | 882 return; |
883 } | |
884 | |
1058 | 885 if (!current_buddy) |
886 return; | |
128 | 887 |
166 | 888 group = buddy_getgroup(BUDDATA(current_buddy)); |
1058 | 889 if (!group) |
890 return; | |
853
bdd526ec62bc
Fix segfault when using /group with the [status] entry
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
891 |
212 | 892 // We'll have to redraw the chat window if we're not currently on the group |
893 // entry itself, because it means we'll have to leave the current buddy | |
894 // chat window. | |
958
30b799632653
Cosmetics (change a variable name)
Mikael Berthe <mikael@lilotux.net>
parents:
957
diff
changeset
|
895 leave_buddywindow = (group != BUDDATA(current_buddy)); |
166 | 896 |
128 | 897 if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
898 scr_LogPrint(LPRINT_NORMAL, "You need to select a group."); |
128 | 899 return; |
900 } | |
166 | 901 |
902 if (!strcasecmp(arg, "expand") || !strcasecmp(arg, "unfold")) { | |
128 | 903 buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE); |
166 | 904 } else if (!strcasecmp(arg, "shrink") || !strcasecmp(arg, "fold")) { |
128 | 905 buddy_setflags(group, ROSTER_FLAG_HIDE, TRUE); |
130 | 906 } else if (!strcasecmp(arg, "toggle")) { |
907 buddy_setflags(group, ROSTER_FLAG_HIDE, | |
908 !(buddy_getflags(group) & ROSTER_FLAG_HIDE)); | |
128 | 909 } else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
910 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
128 | 911 return; |
912 } | |
913 | |
914 buddylist_build(); | |
915 update_roster = TRUE; | |
958
30b799632653
Cosmetics (change a variable name)
Mikael Berthe <mikael@lilotux.net>
parents:
957
diff
changeset
|
916 if (leave_buddywindow) scr_ShowBuddyWindow(); |
128 | 917 } |
918 | |
1058 | 919 static int send_message_to(const char *fjid, const char *msg, const char *subj) |
636 | 920 { |
921 char *bare_jid, *rp; | |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
922 char *hmsg; |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
923 guint crypted; |
636 | 924 |
1058 | 925 if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
926 scr_LogPrint(LPRINT_NORMAL, "You must specify a Jabber ID."); |
636 | 927 return 1; |
928 } | |
929 if (!msg || !*msg) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
930 scr_LogPrint(LPRINT_NORMAL, "You must specify a message."); |
636 | 931 return 1; |
932 } | |
1058 | 933 if (check_jid_syntax((char*)fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
934 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
935 "<%s> is not a valid Jabber ID.", fjid); |
636 | 936 return 1; |
937 } | |
938 | |
939 // We must use the bare jid in hk_message_out() | |
1058 | 940 rp = strchr(fjid, JID_RESOURCE_SEPARATOR); |
941 if (rp) bare_jid = g_strndup(fjid, rp - fjid); | |
942 else bare_jid = (char*)fjid; | |
636 | 943 |
944 // Jump to window, create one if needed | |
945 scr_RosterJumpJid(bare_jid); | |
946 | |
947 // Check if we're sending a message to a conference room | |
948 // If not, we must make sure rp is NULL, for hk_message_out() | |
949 if (rp) { | |
950 if (roster_find(bare_jid, jidsearch, ROSTER_TYPE_ROOM)) rp++; | |
951 else rp = NULL; | |
952 } | |
953 | |
954 // local part (UI, logging, etc.) | |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
955 if (subj) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
956 hmsg = g_strdup_printf("[%s]\n%s", subj, msg); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
957 else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
958 hmsg = (char*)msg; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
959 |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
960 // Network part |
1058 | 961 jb_send_msg(fjid, msg, ROSTER_TYPE_USER, subj, NULL, &crypted); |
636 | 962 |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
963 // Hook |
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
964 hk_message_out(bare_jid, rp, 0, hmsg, crypted); |
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
965 if (hmsg != msg) g_free(hmsg); |
636 | 966 |
967 if (rp) g_free(bare_jid); | |
968 return 0; | |
969 } | |
970 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
971 static void do_say(char *arg) |
132 | 972 { |
164 | 973 gpointer bud; |
132 | 974 |
975 scr_set_chatmode(TRUE); | |
164 | 976 |
977 if (!current_buddy) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
978 scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
979 "Whom are you talking to? Please select a buddy."); |
164 | 980 return; |
132 | 981 } |
164 | 982 |
983 bud = BUDDATA(current_buddy); | |
631
423c24e5875a
Allow sending a message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
626
diff
changeset
|
984 if (!(buddy_gettype(bud) & |
423c24e5875a
Allow sending a message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
626
diff
changeset
|
985 (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM))) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
986 scr_LogPrint(LPRINT_NORMAL, "This is not a user."); |
164 | 987 return; |
988 } | |
989 | |
990 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
991 arg = to_utf8(arg); |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
992 send_message(arg, NULL); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
993 g_free(arg); |
132 | 994 } |
995 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
996 static void do_msay(char *arg) |
238 | 997 { |
636 | 998 /* Parameters: begin verbatim abort send send_to */ |
999 char **paramlst; | |
1000 char *subcmd; | |
1001 | |
1002 paramlst = split_arg(arg, 2, 1); // subcmd, arg | |
1003 subcmd = *paramlst; | |
1004 arg = *(paramlst+1); | |
238 | 1005 |
636 | 1006 if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1007 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
636 | 1008 scr_LogPrint(LPRINT_NORMAL, "Please read the manual before using " |
1009 "the /msay command."); | |
967 | 1010 scr_LogPrint(LPRINT_NORMAL, "(Use \"%s begin\" to enter " |
1011 "multi-line mode...)", mkcmdstr("msay")); | |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1012 goto do_msay_return; |
636 | 1013 } |
1014 | |
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1015 if (!strcasecmp(subcmd, "toggle")) { |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1016 if (scr_get_multimode()) |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1017 subcmd = "send"; |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1018 else |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1019 subcmd = "begin"; |
838
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1020 } else if (!strcasecmp(subcmd, "toggle_verbatim")) { |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1021 if (scr_get_multimode()) |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1022 subcmd = "send"; |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1023 else |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1024 subcmd = "verbatim"; |
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1025 } |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1026 |
636 | 1027 if (!strcasecmp(subcmd, "abort")) { |
315
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
1028 if (scr_get_multimode()) |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1029 scr_LogPrint(LPRINT_NORMAL, "Leaving multi-line message mode."); |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1030 scr_set_multimode(FALSE, NULL); |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1031 goto do_msay_return; |
636 | 1032 } else if ((!strcasecmp(subcmd, "begin")) || |
1033 (!strcasecmp(subcmd, "verbatim"))) { | |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1034 bool verbat; |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1035 gchar *subj_utf8 = to_utf8(arg); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1036 if (!strcasecmp(subcmd, "verbatim")) { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1037 scr_set_multimode(2, subj_utf8); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1038 verbat = TRUE; |
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1039 } else { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1040 scr_set_multimode(1, subj_utf8); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1041 verbat = FALSE; |
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1042 } |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
1043 |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1044 scr_LogPrint(LPRINT_NORMAL, "Entered %smulti-line message mode.", |
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1045 verbat ? "VERBATIM " : ""); |
967 | 1046 scr_LogPrint(LPRINT_NORMAL, "Select a buddy and use \"%s send\" " |
1047 "when your message is ready.", mkcmdstr("msay")); | |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1048 if (verbat) |
967 | 1049 scr_LogPrint(LPRINT_NORMAL, "Use \"%s abort\" to abort this mode.", |
1050 mkcmdstr("msay")); | |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1051 g_free(subj_utf8); |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1052 goto do_msay_return; |
636 | 1053 } else if (strcasecmp(subcmd, "send") && strcasecmp(subcmd, "send_to")) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1054 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1055 goto do_msay_return; |
238 | 1056 } |
1057 | |
636 | 1058 /* send/send_to command */ |
238 | 1059 |
1060 if (!scr_get_multimode()) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1061 scr_LogPrint(LPRINT_NORMAL, "No message to send. " |
967 | 1062 "Use \"%s begin\" first.", mkcmdstr("msay")); |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1063 goto do_msay_return; |
238 | 1064 } |
1065 | |
1066 scr_set_chatmode(TRUE); | |
1067 | |
636 | 1068 if (!strcasecmp(subcmd, "send_to")) { |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1069 int err = FALSE; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1070 gchar *msg_utf8; |
636 | 1071 // Let's send to the specified JID. We leave now if there |
1072 // has been an error (so we don't leave multi-line mode). | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1073 arg = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1074 msg_utf8 = to_utf8(scr_get_multiline()); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1075 if (msg_utf8) { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1076 err = send_message_to(arg, msg_utf8, scr_get_multimode_subj()); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1077 g_free(msg_utf8); |
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1078 } |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1079 g_free(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1080 if (err) |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1081 goto do_msay_return; |
636 | 1082 } else { // Send to currently selected buddy |
1083 gpointer bud; | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1084 gchar *msg_utf8; |
238 | 1085 |
636 | 1086 if (!current_buddy) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1087 scr_LogPrint(LPRINT_NORMAL, "Whom are you talking to?"); |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1088 goto do_msay_return; |
636 | 1089 } |
1090 | |
1091 bud = BUDDATA(current_buddy); | |
1092 if (!(buddy_gettype(bud) & (ROSTER_TYPE_USER|ROSTER_TYPE_ROOM))) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1093 scr_LogPrint(LPRINT_NORMAL, "This is not a user."); |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1094 goto do_msay_return; |
636 | 1095 } |
1096 | |
1097 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1098 msg_utf8 = to_utf8(scr_get_multiline()); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1099 if (msg_utf8) { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1100 send_message(msg_utf8, scr_get_multimode_subj()); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1101 g_free(msg_utf8); |
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1102 } |
238 | 1103 } |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1104 scr_set_multimode(FALSE, NULL); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1105 scr_LogPrint(LPRINT_NORMAL, "You have left multi-line message mode."); |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1106 do_msay_return: |
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1107 free_arg_lst(paramlst); |
238 | 1108 } |
1109 | |
480 | 1110 static void do_say_to(char *arg) |
1111 { | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1112 char **paramlst; |
1058 | 1113 char *fjid, *msg; |
480 | 1114 |
1115 if (!jb_getonline()) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1116 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
480 | 1117 return; |
1118 } | |
1119 | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1120 paramlst = split_arg(arg, 2, 1); // jid, message |
1058 | 1121 fjid = *paramlst; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1122 msg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1123 |
1058 | 1124 if (!fjid || !strcmp(fjid, ".")) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1125 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1126 free_arg_lst(paramlst); |
480 | 1127 return; |
1128 } | |
1129 | |
1058 | 1130 fjid = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1131 msg = to_utf8(msg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1132 |
1058 | 1133 send_message_to(fjid, msg, NULL); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1134 |
1058 | 1135 g_free(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1136 g_free(msg); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1137 free_arg_lst(paramlst); |
480 | 1138 } |
1139 | |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1140 // buffer_updown(updown, nblines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1141 // updown: -1=up, +1=down |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1142 inline static void buffer_updown(int updown, char *nlines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1143 { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1144 int nblines; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1145 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1146 if (!nlines || !*nlines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1147 nblines = 0; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1148 else |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1149 nblines = atoi(nlines); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1150 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1151 if (nblines >= 0) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1152 scr_BufferScrollUpDown(updown, nblines); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1153 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1154 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1155 static void buffer_search(int direction, char *arg) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1156 { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1157 if (!arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1158 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1159 return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1160 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1161 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1162 scr_BufferSearch(direction, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1163 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1164 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1165 static void buffer_date(char *date) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1166 { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1167 time_t t; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1168 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1169 if (!date || !*date) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1170 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1171 return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1172 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1173 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1174 strip_arg_special_chars(date); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1175 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1176 t = from_iso8601(date, 0); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1177 if (t) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1178 scr_BufferDate(t); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1179 else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1180 scr_LogPrint(LPRINT_NORMAL, "The date you specified is " |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1181 "not correctly formatted or invalid."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1182 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1183 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1184 static void buffer_percent(char *arg1, char *arg2) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1185 { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1186 // Basically, user has typed "%arg1 arg2" |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1187 // "%50" -> arg1 = 50, arg2 null pointer |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1188 // "% 50" -> arg1 = \0, arg2 = 50 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1189 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1190 if (!*arg1 && (!arg2 || !*arg2)) { // No value |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1191 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1192 return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1193 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1194 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1195 if (*arg1 && arg2 && *arg2) { // Two values |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1196 scr_LogPrint(LPRINT_NORMAL, "Wrong parameters."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1197 return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1198 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1199 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1200 scr_BufferPercent(atoi((*arg1 ? arg1 : arg2))); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1201 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1202 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1203 static void do_buffer(char *arg) |
187 | 1204 { |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1205 char **paramlst; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1206 char *subcmd; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1207 |
1058 | 1208 if (!current_buddy) |
1209 return; | |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1210 |
446 | 1211 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1212 scr_LogPrint(LPRINT_NORMAL, "Groups have no buffer."); |
446 | 1213 return; |
1214 } | |
1215 | |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1216 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1217 subcmd = *paramlst; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1218 arg = *(paramlst+1); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1219 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1220 if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1221 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1222 free_arg_lst(paramlst); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1223 return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1224 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1225 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1226 if (!strcasecmp(subcmd, "top")) { |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
336
diff
changeset
|
1227 scr_BufferTopBottom(-1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1228 } else if (!strcasecmp(subcmd, "bottom")) { |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
336
diff
changeset
|
1229 scr_BufferTopBottom(1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1230 } else if (!strcasecmp(subcmd, "clear")) { |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
1231 scr_BufferClear(); |
866 | 1232 } else if (!strcasecmp(subcmd, "purge")) { |
1233 scr_BufferPurge(); | |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1234 } else if (!strcasecmp(subcmd, "scroll_lock")) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1235 scr_BufferScrollLock(1); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1236 } else if (!strcasecmp(subcmd, "scroll_unlock")) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1237 scr_BufferScrollLock(0); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1238 } else if (!strcasecmp(subcmd, "scroll_toggle")) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1239 scr_BufferScrollLock(-1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1240 } else if (!strcasecmp(subcmd, "up")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1241 buffer_updown(-1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1242 } else if (!strcasecmp(subcmd, "down")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1243 buffer_updown(1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1244 } else if (!strcasecmp(subcmd, "search_backward")) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
1245 strip_arg_special_chars(arg); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1246 buffer_search(-1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1247 } else if (!strcasecmp(subcmd, "search_forward")) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
1248 strip_arg_special_chars(arg); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1249 buffer_search(1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1250 } else if (!strcasecmp(subcmd, "date")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1251 buffer_date(arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1252 } else if (*subcmd == '%') { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1253 buffer_percent(subcmd+1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1254 } else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1255 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1256 } |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1257 |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1258 free_arg_lst(paramlst); |
187 | 1259 } |
1260 | |
967 | 1261 static void do_clear(char *arg) // Alias for "buffer clear" |
187 | 1262 { |
1263 do_buffer("clear"); | |
1264 } | |
1265 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1266 static void do_info(char *arg) |
191 | 1267 { |
1268 gpointer bud; | |
1058 | 1269 const char *bjid, *name; |
191 | 1270 guint type; |
1271 char *buffer; | |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1272 enum subscr esub; |
191 | 1273 |
1058 | 1274 if (!current_buddy) |
1275 return; | |
191 | 1276 bud = BUDDATA(current_buddy); |
1277 | |
1058 | 1278 bjid = buddy_getjid(bud); |
191 | 1279 name = buddy_getname(bud); |
1280 type = buddy_gettype(bud); | |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1281 esub = buddy_getsubscription(bud); |
191 | 1282 |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1283 buffer = g_new(char, 4096); |
191 | 1284 |
1058 | 1285 if (bjid) { |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1286 GSList *resources, *p_res; |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1287 char *bstr = "unknown"; |
191 | 1288 |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1289 // Enter chat mode |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1290 scr_set_chatmode(TRUE); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1291 scr_ShowBuddyWindow(); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1292 |
1058 | 1293 snprintf(buffer, 4095, "jid: <%s>", bjid); |
1294 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); | |
191 | 1295 if (name) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1296 snprintf(buffer, 4095, "Name: %s", name); |
1058 | 1297 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
191 | 1298 } |
1299 | |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1300 if (type == ROSTER_TYPE_USER) bstr = "user"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1301 else if (type == ROSTER_TYPE_ROOM) bstr = "chatroom"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1302 else if (type == ROSTER_TYPE_AGENT) bstr = "agent"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1303 snprintf(buffer, 127, "Type: %s", bstr); |
1058 | 1304 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1305 |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1306 if (esub == sub_both) bstr = "both"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1307 else if (esub & sub_from) bstr = "from"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1308 else if (esub & sub_to) bstr = "to"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1309 else bstr = "none"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1310 snprintf(buffer, 64, "Subscription: %s", bstr); |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1311 if (esub & sub_pending) |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1312 strcat(buffer, " (pending)"); |
1058 | 1313 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1314 |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1315 resources = buddy_getresources(bud); |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1316 if (!resources && type == ROSTER_TYPE_USER) { |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1317 // No resource; display last status message, if any. |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1318 const char *rst_msg = buddy_getstatusmsg(bud, ""); |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1319 if (rst_msg) { |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1320 snprintf(buffer, 4095, "Last status message: %s", rst_msg); |
1058 | 1321 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1322 } |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1323 } |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1324 for (p_res = resources ; p_res ; p_res = g_slist_next(p_res)) { |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1325 gchar rprio; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1326 enum imstatus rstatus; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1327 const char *rst_msg; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1328 time_t rst_time; |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1329 struct pgp_data *rpgp; |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1330 |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1331 rprio = buddy_getresourceprio(bud, p_res->data); |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1332 rstatus = buddy_getstatus(bud, p_res->data); |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1333 rst_msg = buddy_getstatusmsg(bud, p_res->data); |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1334 rst_time = buddy_getstatustime(bud, p_res->data); |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1335 rpgp = buddy_resource_pgp(bud, p_res->data); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1336 |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1337 snprintf(buffer, 4095, "Resource: [%c] (%d) %s", imstatus2char[rstatus], |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1338 rprio, (char*)p_res->data); |
1058 | 1339 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1340 if (rst_msg) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1341 snprintf(buffer, 4095, "Status message: %s", rst_msg); |
1058 | 1342 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1343 } |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1344 if (rst_time) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1345 char tbuf[128]; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1346 |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1347 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time)); |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1348 snprintf(buffer, 127, "Status timestamp: %s", tbuf); |
1058 | 1349 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1350 } |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1351 #ifdef HAVE_GPGME |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1352 if (rpgp && rpgp->sign_keyid) { |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1353 snprintf(buffer, 4095, "PGP key id: %s", rpgp->sign_keyid); |
1058 | 1354 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1355 if (rpgp->last_sigsum) { |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1356 gpgme_sigsum_t ss = rpgp->last_sigsum; |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1357 snprintf(buffer, 4095, "Last PGP signature: %s", |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1358 (ss & GPGME_SIGSUM_GREEN ? "good": |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1359 (ss & GPGME_SIGSUM_RED ? "bad" : "unknown"))); |
1058 | 1360 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1361 } |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1362 } |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1363 #endif |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1364 g_free(p_res->data); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1365 } |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1366 g_slist_free(resources); |
191 | 1367 } else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1368 if (name) scr_LogPrint(LPRINT_NORMAL, "Name: %s", name); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1369 scr_LogPrint(LPRINT_NORMAL, "Type: %s", |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1370 type == ROSTER_TYPE_GROUP ? "group" : |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1371 (type == ROSTER_TYPE_SPECIAL ? "special" : "unknown")); |
191 | 1372 } |
1373 g_free(buffer); | |
1374 | |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1375 // Tell the user if this item has an annotation. |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1376 if (type == ROSTER_TYPE_USER || |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1377 type == ROSTER_TYPE_ROOM || |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1378 type == ROSTER_TYPE_AGENT) { |
1058 | 1379 struct annotation *note = jb_get_storage_rosternotes(bjid, TRUE); |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1380 if (note) { |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1381 // We do not display the note, we just tell the user. |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1382 g_free(note->text); |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
1383 g_free(note->jid); |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1384 g_free(note); |
1058 | 1385 scr_WriteIncomingMessage(bjid, "(This item has an annotation)", 0, |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1386 HBB_PREFIX_INFO); |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1387 } |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1388 } |
191 | 1389 } |
1390 | |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1391 // room_names() is a variation of do_info(), for chatrooms only |
552 | 1392 static void room_names(gpointer bud, char *arg) |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1393 { |
1058 | 1394 const char *bjid; |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1395 char *buffer; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1396 GSList *resources, *p_res; |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1397 |
552 | 1398 if (*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1399 scr_LogPrint(LPRINT_NORMAL, "This action does not require a parameter."); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1400 return; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1401 } |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1402 |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1403 // Enter chat mode |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1404 scr_set_chatmode(TRUE); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1405 scr_ShowBuddyWindow(); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1406 |
1058 | 1407 bjid = buddy_getjid(bud); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1408 |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1409 buffer = g_new(char, 4096); |
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1410 strncpy(buffer, "Room members:", 127); |
1058 | 1411 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1412 |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1413 resources = buddy_getresources(bud); |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1414 for (p_res = resources ; p_res ; p_res = g_slist_next(p_res)) { |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1415 enum imstatus rstatus; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1416 const char *rst_msg; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1417 |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1418 rstatus = buddy_getstatus(bud, p_res->data); |
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1419 rst_msg = buddy_getstatusmsg(bud, p_res->data); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1420 |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1421 snprintf(buffer, 4095, "[%c] %s", imstatus2char[rstatus], |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1422 (char*)p_res->data); |
1058 | 1423 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1424 if (rst_msg) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1425 snprintf(buffer, 4095, "Status message: %s", rst_msg); |
1058 | 1426 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1427 } |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1428 g_free(p_res->data); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1429 } |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1430 g_slist_free(resources); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1431 g_free(buffer); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1432 } |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1433 |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1434 static void move_group_member(gpointer bud, void *groupnamedata) |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1435 { |
1058 | 1436 const char *bjid, *name, *groupname; |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1437 |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1438 groupname = (char *)groupnamedata; |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1439 |
1058 | 1440 bjid = buddy_getjid(bud); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1441 name = buddy_getname(bud); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1442 |
1058 | 1443 jb_updatebuddy(bjid, name, *groupname ? groupname : NULL); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1444 } |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1445 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1446 static void do_rename(char *arg) |
208 | 1447 { |
1448 gpointer bud; | |
1058 | 1449 const char *bjid, *group; |
208 | 1450 guint type; |
1451 char *newname, *p; | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1452 char *name_utf8; |
208 | 1453 |
1058 | 1454 if (!current_buddy) |
1455 return; | |
208 | 1456 bud = BUDDATA(current_buddy); |
1457 | |
1058 | 1458 bjid = buddy_getjid(bud); |
208 | 1459 group = buddy_getgroupname(bud); |
1460 type = buddy_gettype(bud); | |
1461 | |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1462 if (type & ROSTER_TYPE_SPECIAL) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1463 scr_LogPrint(LPRINT_NORMAL, "You can't rename this item."); |
208 | 1464 return; |
1465 } | |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1466 |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1467 if (!*arg && !(type & ROSTER_TYPE_GROUP)) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1468 scr_LogPrint(LPRINT_NORMAL, "Please specify a new name."); |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1469 return; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1470 } |
208 | 1471 |
1472 newname = g_strdup(arg); | |
1473 // Remove trailing space | |
1474 for (p = newname; *p; p++) ; | |
1475 while (p > newname && *p == ' ') *p = 0; | |
1476 | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1477 strip_arg_special_chars(newname); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1478 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1479 name_utf8 = to_utf8(newname); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1480 |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1481 if (type & ROSTER_TYPE_GROUP) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1482 // Rename a whole group |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1483 foreach_group_member(bud, &move_group_member, name_utf8); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1484 // Let's jump to the previous buddy, because this group name should |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1485 // disappear when we receive the server answer. |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1486 scr_RosterUp(); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1487 } else { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1488 // Rename a single buddy |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1489 buddy_setname(bud, name_utf8); |
1058 | 1490 jb_updatebuddy(bjid, name_utf8, group); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1491 } |
208 | 1492 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1493 g_free(name_utf8); |
208 | 1494 g_free(newname); |
1495 update_roster = TRUE; | |
1496 } | |
1497 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1498 static void do_move(char *arg) |
210 | 1499 { |
1500 gpointer bud; | |
1058 | 1501 const char *bjid, *name, *oldgroupname; |
210 | 1502 guint type; |
1503 char *newgroupname, *p; | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1504 char *group_utf8; |
210 | 1505 |
1058 | 1506 if (!current_buddy) |
1507 return; | |
210 | 1508 bud = BUDDATA(current_buddy); |
1509 | |
1058 | 1510 bjid = buddy_getjid(bud); |
210 | 1511 name = buddy_getname(bud); |
1512 type = buddy_gettype(bud); | |
1513 | |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1514 oldgroupname = buddy_getgroupname(bud); |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1515 |
210 | 1516 if (type & ROSTER_TYPE_GROUP) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1517 scr_LogPrint(LPRINT_NORMAL, "You can't move groups!"); |
210 | 1518 return; |
1519 } | |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1520 if (type & ROSTER_TYPE_SPECIAL) { |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1521 scr_LogPrint(LPRINT_NORMAL, "You can't move this item."); |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1522 return; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1523 } |
210 | 1524 |
1525 newgroupname = g_strdup(arg); | |
1526 // Remove trailing space | |
1527 for (p = newgroupname; *p; p++) ; | |
608
89f5672eb523
/move: really strip trailing space, and assign to no group if no group is specified
Mikael Berthe <mikael@lilotux.net>
parents:
604
diff
changeset
|
1528 while (p > newgroupname && *p == ' ') *p-- = 0; |
210 | 1529 |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1530 strip_arg_special_chars(newgroupname); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1531 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1532 group_utf8 = to_utf8(newgroupname); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1533 if (strcmp(oldgroupname, group_utf8)) { |
1058 | 1534 jb_updatebuddy(bjid, name, *group_utf8 ? group_utf8 : NULL); |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1535 scr_RosterUp(); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1536 buddy_setgroup(bud, group_utf8); |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1537 } |
210 | 1538 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1539 g_free(group_utf8); |
210 | 1540 g_free(newgroupname); |
1541 update_roster = TRUE; | |
1542 } | |
1543 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1544 static void do_set(char *arg) |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1545 { |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1546 guint assign; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1547 const gchar *option, *value; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1548 gchar *option_utf8; |
393 | 1549 |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1550 assign = parse_assigment(arg, &option, &value); |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1551 if (!option) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1552 scr_LogPrint(LPRINT_NORMAL, "Set what option?"); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1553 return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1554 } |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1555 option_utf8 = to_utf8(option); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1556 if (!assign) { |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1557 // This is a query |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1558 value = settings_opt_get(option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1559 if (value) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1560 scr_LogPrint(LPRINT_NORMAL, "%s = [%s]", option_utf8, value); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1561 } else |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1562 scr_LogPrint(LPRINT_NORMAL, "Option %s is not set", option_utf8); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1563 g_free(option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1564 return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1565 } |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1566 // Update the option |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1567 // XXX Maybe some options should be protected when user is connected |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1568 // (server, username, etc.). And we should catch some options here, too |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1569 // (hide_offline_buddies for ex.) |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1570 if (!value) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1571 settings_del(SETTINGS_TYPE_OPTION, option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1572 } else { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1573 gchar *value_utf8 = to_utf8(value); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1574 settings_set(SETTINGS_TYPE_OPTION, option_utf8, value_utf8); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1575 g_free(value_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1576 } |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1577 g_free(option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1578 } |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1579 |
1070
9eaacc0ad3a2
Use a hash for settings
Mikael Berthe <mikael@lilotux.net>
parents:
1066
diff
changeset
|
1580 static void dump_alias(char *k, char *v, void *param) |
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1581 { |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1582 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, "Alias %s = %s", k, v); |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1583 } |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1584 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1585 static void do_alias(char *arg) |
285 | 1586 { |
1587 guint assign; | |
1588 const gchar *alias, *value; | |
393 | 1589 |
285 | 1590 assign = parse_assigment(arg, &alias, &value); |
1591 if (!alias) { | |
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1592 settings_foreach(SETTINGS_TYPE_ALIAS, &dump_alias, NULL); |
285 | 1593 return; |
1594 } | |
1595 if (!assign) { | |
1596 // This is a query | |
1597 value = settings_get(SETTINGS_TYPE_ALIAS, alias); | |
1598 if (value) { | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1599 // XXX LPRINT_NOTUTF8 here, see below why it isn't encoded... |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1600 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, "%s = %s", alias, value); |
285 | 1601 } else |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1602 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1603 "Alias '%s' does not exist", alias); |
285 | 1604 return; |
1605 } | |
1606 // Check the alias does not conflict with a registered command | |
1607 if (cmd_get(alias)) { | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1608 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1609 "'%s' is a reserved word!", alias); |
285 | 1610 return; |
1611 } | |
1612 // Update the alias | |
1613 if (!value) { | |
1614 if (settings_get(SETTINGS_TYPE_ALIAS, alias)) { | |
1615 settings_del(SETTINGS_TYPE_ALIAS, alias); | |
1616 // Remove alias from the completion list | |
1617 compl_del_category_word(COMPL_CMD, alias); | |
1618 } | |
1619 } else { | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1620 /* Add alias to the completion list, if not already in. |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1621 XXX We're not UTF8-encoding "alias" and "value" here because UTF-8 is |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1622 not yet supported in the UI... (and we use the values in the completion |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1623 system) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1624 */ |
285 | 1625 if (!settings_get(SETTINGS_TYPE_ALIAS, alias)) |
1626 compl_add_category_word(COMPL_CMD, alias); | |
1627 settings_set(SETTINGS_TYPE_ALIAS, alias, value); | |
1628 } | |
1629 } | |
1630 | |
1070
9eaacc0ad3a2
Use a hash for settings
Mikael Berthe <mikael@lilotux.net>
parents:
1066
diff
changeset
|
1631 static void dump_bind(char *k, char *v, void *param) |
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1632 { |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1633 scr_LogPrint(LPRINT_NORMAL, "Key %4s is bound to: %s", k, v); |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1634 } |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1635 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1636 static void do_bind(char *arg) |
288 | 1637 { |
1638 guint assign; | |
1058 | 1639 const gchar *k_code, *value; |
393 | 1640 |
1058 | 1641 assign = parse_assigment(arg, &k_code, &value); |
1642 if (!k_code) { | |
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1643 settings_foreach(SETTINGS_TYPE_BINDING, &dump_bind, NULL); |
288 | 1644 return; |
1645 } | |
1646 if (!assign) { | |
1647 // This is a query | |
1058 | 1648 value = settings_get(SETTINGS_TYPE_BINDING, k_code); |
288 | 1649 if (value) { |
1058 | 1650 scr_LogPrint(LPRINT_NORMAL, "Key %s is bound to: %s", k_code, value); |
288 | 1651 } else |
1058 | 1652 scr_LogPrint(LPRINT_NORMAL, "Key %s is not bound.", k_code); |
288 | 1653 return; |
1654 } | |
1655 // Update the key binding | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1656 if (!value) { |
1058 | 1657 settings_del(SETTINGS_TYPE_BINDING, k_code); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1658 } else { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1659 gchar *value_utf8 = to_utf8(value); |
1058 | 1660 settings_set(SETTINGS_TYPE_BINDING, k_code, value_utf8); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1661 g_free(value_utf8); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1662 } |
288 | 1663 } |
1664 | |
436 | 1665 static void do_rawxml(char *arg) |
1666 { | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1667 char **paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1668 char *subcmd; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1669 |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1670 if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1671 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1672 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1673 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1674 |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1675 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1676 subcmd = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1677 arg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1678 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1679 if (!subcmd || !*subcmd) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1680 scr_LogPrint(LPRINT_NORMAL, "Please read the manual page" |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1681 " before using /rawxml :-)"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1682 free_arg_lst(paramlst); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1683 return; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1684 } |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1685 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1686 if (!strcasecmp(subcmd, "send")) { |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1687 gchar *buffer; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1688 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1689 if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1690 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1691 free_arg_lst(paramlst); |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1692 return; |
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1693 } |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1694 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1695 // We don't strip_arg_special_chars() here, because it would be a pain for |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1696 // the user to escape quotes in a XML stream... |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1697 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1698 buffer = to_utf8(arg); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1699 if (buffer) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1700 scr_LogPrint(LPRINT_NORMAL, "Sending XML string"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1701 jb_send_raw(buffer); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1702 g_free(buffer); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1703 } else { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1704 scr_LogPrint(LPRINT_NORMAL, "Conversion error in XML string."); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1705 } |
436 | 1706 } else { |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1707 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
436 | 1708 } |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1709 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1710 free_arg_lst(paramlst); |
436 | 1711 } |
1712 | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1713 // check_room_subcommand(arg, param_needed, buddy_must_be_a_room) |
552 | 1714 // - Check if this is a room, if buddy_must_be_a_room is not null |
1715 // - Check there is at least 1 parameter, if param_needed is true | |
1716 // - Return null if one of the checks fails, or a pointer to the first | |
1717 // non-space character. | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1718 static char *check_room_subcommand(char *arg, bool param_needed, |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1719 gpointer buddy_must_be_a_room) |
552 | 1720 { |
1721 if (buddy_must_be_a_room && | |
1722 !(buddy_gettype(buddy_must_be_a_room) & ROSTER_TYPE_ROOM)) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1723 scr_LogPrint(LPRINT_NORMAL, "This isn't a conference room."); |
552 | 1724 return NULL; |
1725 } | |
1726 | |
1727 if (param_needed) { | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1728 if (!arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1729 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
552 | 1730 return NULL; |
1731 } | |
1732 } | |
1733 | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1734 if (arg) |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1735 return arg; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1736 else |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1737 return ""; |
552 | 1738 } |
1739 | |
1740 static void room_join(gpointer bud, char *arg) | |
1741 { | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1742 char **paramlst; |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1743 char *roomname, *nick, *pass; |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1744 char *roomname_tmp = NULL; |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1745 char *pass_utf8; |
552 | 1746 |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1747 paramlst = split_arg(arg, 3, 0); // roomid, nickname, password |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1748 roomname = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1749 nick = *(paramlst+1); |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1750 pass = *(paramlst+2); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1751 |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1752 if (!roomname) |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1753 nick = NULL; |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1754 if (!nick) |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1755 pass = NULL; |
552 | 1756 |
841
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1757 if (!roomname || !strcmp(roomname, ".")) { |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1758 // If the current_buddy is recognized as a room, the room name |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1759 // can be omitted (or "." can be used). |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1760 if (!bud || !(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) { |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1761 scr_LogPrint(LPRINT_NORMAL, "Please specify a room name."); |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1762 free_arg_lst(paramlst); |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1763 return; |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1764 } |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1765 roomname = (char*)buddy_getjid(bud); |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1766 } else if (strchr(roomname, '/')) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1767 scr_LogPrint(LPRINT_NORMAL, "Invalid room name."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1768 free_arg_lst(paramlst); |
552 | 1769 return; |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1770 } else { |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1771 // The room id has been specified. Let's convert it and use it. |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1772 roomname_tmp = to_utf8(roomname); |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1773 mc_strtolower(roomname_tmp); |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1774 roomname = roomname_tmp; |
552 | 1775 } |
1776 | |
659
e61aa455c61b
MUC: Add "nickname" option variable
Mikael Berthe <mikael@lilotux.net>
parents:
653
diff
changeset
|
1777 // If no nickname is provided with the /join command, |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1778 // we try to get a default nickname. |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1779 if (!nick || !*nick) |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1780 nick = default_muc_nickname(); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1781 else |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1782 nick = to_utf8(nick); |
659
e61aa455c61b
MUC: Add "nickname" option variable
Mikael Berthe <mikael@lilotux.net>
parents:
653
diff
changeset
|
1783 // If we still have no nickname, give up |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1784 if (!nick || !*nick) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1785 scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1786 g_free(nick); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1787 free_arg_lst(paramlst); |
552 | 1788 return; |
1789 } | |
1790 | |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1791 pass_utf8 = to_utf8(pass); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1792 |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1793 jb_room_join(roomname, nick, pass_utf8); |
552 | 1794 |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1795 scr_LogPrint(LPRINT_LOGNORM, "Sent a join request to <%s>...", roomname); |
653
d5db5be78eb0
MUC: Be more verbose when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1796 |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1797 g_free(roomname_tmp); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1798 g_free(nick); |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1799 g_free(pass_utf8); |
552 | 1800 buddylist_build(); |
1801 update_roster = TRUE; | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1802 free_arg_lst(paramlst); |
552 | 1803 } |
1804 | |
1805 static void room_invite(gpointer bud, char *arg) | |
1806 { | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1807 char **paramlst; |
552 | 1808 const gchar *roomname; |
1058 | 1809 char* fjid; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1810 gchar *reason_utf8; |
552 | 1811 |
570
29806b0fe830
Some parsing improvements
Mikael Berthe <mikael@lilotux.net>
parents:
568
diff
changeset
|
1812 paramlst = split_arg(arg, 2, 1); // jid, [reason] |
1058 | 1813 fjid = *paramlst; |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1814 arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1815 // An empty reason is no reason... |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1816 if (arg && !*arg) |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1817 arg = NULL; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1818 |
1058 | 1819 if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1820 scr_LogPrint(LPRINT_NORMAL, "Missing or incorrect Jabber ID."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1821 free_arg_lst(paramlst); |
552 | 1822 return; |
1823 } | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1824 |
552 | 1825 roomname = buddy_getjid(bud); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1826 reason_utf8 = to_utf8(arg); |
1058 | 1827 jb_room_invite(roomname, fjid, reason_utf8); |
1828 scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>.", fjid); | |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1829 g_free(reason_utf8); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1830 free_arg_lst(paramlst); |
552 | 1831 } |
1832 | |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1833 static void room_affil(gpointer bud, char *arg) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1834 { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1835 char **paramlst; |
1058 | 1836 gchar *fjid, *rolename; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1837 struct role_affil ra; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1838 const char *roomid = buddy_getjid(bud); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1839 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1840 paramlst = split_arg(arg, 3, 1); // jid, new_affil, [reason] |
1058 | 1841 fjid = *paramlst; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1842 rolename = *(paramlst+1); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1843 arg = *(paramlst+2); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1844 |
1058 | 1845 if (!fjid || !*fjid || !rolename || !*rolename) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1846 scr_LogPrint(LPRINT_NORMAL, "Please specify both a Jabber ID and a role."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1847 free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1848 return; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1849 } |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1850 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1851 ra.type = type_affil; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1852 ra.val.affil = affil_none; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1853 for (; ra.val.affil < imaffiliation_size; ra.val.affil++) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1854 if (!strcasecmp(rolename, straffil[ra.val.affil])) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1855 break; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1856 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1857 if (ra.val.affil < imaffiliation_size) { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1858 gchar *jid_utf8, *reason_utf8; |
1058 | 1859 jid_utf8 = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1860 reason_utf8 = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1861 jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1862 g_free(jid_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1863 g_free(reason_utf8); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1864 } else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1865 scr_LogPrint(LPRINT_NORMAL, "Wrong affiliation parameter."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1866 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1867 free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1868 } |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1869 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1870 static void room_role(gpointer bud, char *arg) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1871 { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1872 char **paramlst; |
1058 | 1873 gchar *fjid, *rolename; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1874 struct role_affil ra; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1875 const char *roomid = buddy_getjid(bud); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1876 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1877 paramlst = split_arg(arg, 3, 1); // jid, new_role, [reason] |
1058 | 1878 fjid = *paramlst; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1879 rolename = *(paramlst+1); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1880 arg = *(paramlst+2); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1881 |
1058 | 1882 if (!fjid || !*fjid || !rolename || !*rolename) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1883 scr_LogPrint(LPRINT_NORMAL, "Please specify both a Jabber ID and a role."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1884 free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1885 return; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1886 } |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1887 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1888 ra.type = type_role; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1889 ra.val.role = role_none; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1890 for (; ra.val.role < imrole_size; ra.val.role++) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1891 if (!strcasecmp(rolename, strrole[ra.val.role])) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1892 break; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1893 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1894 if (ra.val.role < imrole_size) { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1895 gchar *jid_utf8, *reason_utf8; |
1058 | 1896 jid_utf8 = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1897 reason_utf8 = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1898 jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1899 g_free(jid_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1900 g_free(reason_utf8); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1901 } else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1902 scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1903 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1904 free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1905 } |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1906 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1907 |
571 | 1908 // The expected argument is a Jabber id |
1909 static void room_ban(gpointer bud, char *arg) | |
1910 { | |
1911 char **paramlst; | |
1058 | 1912 gchar *fjid; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1913 gchar *jid_utf8, *reason_utf8; |
584 | 1914 struct role_affil ra; |
571 | 1915 const char *roomid = buddy_getjid(bud); |
1916 | |
1917 paramlst = split_arg(arg, 2, 1); // jid, [reason] | |
1058 | 1918 fjid = *paramlst; |
571 | 1919 arg = *(paramlst+1); |
1920 | |
1058 | 1921 if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1922 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
571 | 1923 free_arg_lst(paramlst); |
1924 return; | |
1925 } | |
1926 | |
584 | 1927 ra.type = type_affil; |
1928 ra.val.affil = affil_outcast; | |
1929 | |
1058 | 1930 jid_utf8 = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1931 reason_utf8 = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1932 jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1933 g_free(jid_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1934 g_free(reason_utf8); |
571 | 1935 |
1936 free_arg_lst(paramlst); | |
1937 } | |
1938 | |
1939 // The expected argument is a nickname | |
568 | 1940 static void room_kick(gpointer bud, char *arg) |
1941 { | |
1942 char **paramlst; | |
1943 gchar *nick; | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1944 gchar *nick_utf8, *reason_utf8; |
584 | 1945 struct role_affil ra; |
568 | 1946 const char *roomid = buddy_getjid(bud); |
1947 | |
571 | 1948 paramlst = split_arg(arg, 2, 1); // nickname, [reason] |
568 | 1949 nick = *paramlst; |
1950 arg = *(paramlst+1); | |
1951 | |
1952 if (!nick || !*nick) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1953 scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
568 | 1954 free_arg_lst(paramlst); |
1955 return; | |
1956 } | |
1957 | |
584 | 1958 ra.type = type_role; |
1959 ra.val.affil = role_none; | |
1960 | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1961 nick_utf8 = to_utf8(nick); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1962 reason_utf8 = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1963 jb_room_setattrib(roomid, NULL, nick_utf8, ra, reason_utf8); |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1964 g_free(nick_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1965 g_free(reason_utf8); |
568 | 1966 |
1967 free_arg_lst(paramlst); | |
1968 } | |
1969 | |
552 | 1970 static void room_leave(gpointer bud, char *arg) |
1971 { | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1972 gchar *roomid, *desc; |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1973 const char *nickname; |
552 | 1974 |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1975 nickname = buddy_getnickname(bud); |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1976 if (!nickname) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1977 scr_LogPrint(LPRINT_NORMAL, "You are not in this room."); |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1978 return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1979 } |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1980 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1981 roomid = g_strdup_printf("%s/%s", buddy_getjid(bud), nickname); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1982 desc = to_utf8(arg); |
1050
ea71d31a2607
PGP: Do not sign presence messages to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
1043
diff
changeset
|
1983 jb_setstatus(offline, roomid, desc, TRUE); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1984 g_free(desc); |
552 | 1985 g_free(roomid); |
1986 } | |
1987 | |
1988 static void room_nick(gpointer bud, char *arg) | |
1989 { | |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1990 if (!buddy_getinsideroom(bud)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1991 scr_LogPrint(LPRINT_NORMAL, "You are not in this room."); |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1992 return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1993 } |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1994 |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1995 if (!arg || !*arg) { |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1996 const char *nick = buddy_getnickname(bud); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1997 if (nick) |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1998 scr_LogPrint(LPRINT_NORMAL, "Your nickname is: %s", nick); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1999 else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2000 scr_LogPrint(LPRINT_NORMAL, "You have no nickname in this room."); |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2001 } else { |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2002 gchar *roomname, *roomname_tmp, *nick; |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2003 roomname_tmp = g_strdup(buddy_getjid(bud)); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2004 mc_strtolower(roomname_tmp); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2005 roomname = to_utf8(roomname_tmp); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2006 g_free(roomname_tmp); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2007 nick = to_utf8(arg); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2008 |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2009 jb_room_join(roomname, nick, NULL); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2010 g_free(roomname); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2011 g_free(nick); |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2012 } |
552 | 2013 } |
2014 | |
2015 static void room_privmsg(gpointer bud, char *arg) | |
2016 { | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2017 char **paramlst; |
1058 | 2018 gchar *nick, *cmdline; |
552 | 2019 |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2020 paramlst = split_arg(arg, 2, 0); // nickname, message |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2021 nick = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2022 arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2023 |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2024 if (!nick || !*nick || !arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2025 scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2026 "Please specify both a Jabber ID and a message."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2027 free_arg_lst(paramlst); |
552 | 2028 return; |
2029 } | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2030 |
1058 | 2031 cmdline = g_strdup_printf("%s/%s %s", buddy_getjid(bud), nick, arg); |
2032 do_say_to(cmdline); | |
2033 g_free(cmdline); | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2034 free_arg_lst(paramlst); |
552 | 2035 } |
2036 | |
2037 static void room_remove(gpointer bud, char *arg) | |
2038 { | |
2039 if (*arg) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2040 scr_LogPrint(LPRINT_NORMAL, "This action does not require a parameter; " |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2041 "the currently-selected room will be removed."); |
552 | 2042 return; |
2043 } | |
2044 | |
2045 // Quick check: if there are resources, we haven't left | |
652
b243d3b3ff1b
We do not need buddy_isresource() anymore
Mikael Berthe <mikael@lilotux.net>
parents:
650
diff
changeset
|
2046 if (buddy_getinsideroom(bud)) { |
552 | 2047 scr_LogPrint(LPRINT_NORMAL, "You haven't left this room!"); |
2048 return; | |
2049 } | |
2050 // Delete the room | |
2051 roster_del_user(buddy_getjid(bud)); | |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
861
diff
changeset
|
2052 scr_UpdateBuddyWindow(); |
552 | 2053 buddylist_build(); |
2054 update_roster = TRUE; | |
2055 } | |
2056 | |
2057 static void room_topic(gpointer bud, char *arg) | |
2058 { | |
2059 gchar *msg; | |
2060 | |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2061 if (!buddy_getinsideroom(bud)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2062 scr_LogPrint(LPRINT_NORMAL, "You are not in this room."); |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2063 return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2064 } |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2065 |
552 | 2066 // If no parameter is given, display the current topic |
2067 if (!*arg) { | |
2068 const char *topic = buddy_gettopic(bud); | |
2069 if (topic) | |
2070 scr_LogPrint(LPRINT_NORMAL, "Topic: %s", topic); | |
2071 else | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2072 scr_LogPrint(LPRINT_NORMAL, "No topic has been set."); |
552 | 2073 return; |
2074 } | |
2075 | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2076 arg = to_utf8(arg); |
552 | 2077 // Set the topic |
967 | 2078 msg = g_strdup_printf("%s has set the topic to: %s", mkcmdstr("me"), arg); |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
2079 jb_send_msg(buddy_getjid(bud), msg, ROSTER_TYPE_ROOM, arg, NULL, NULL); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2080 g_free(arg); |
552 | 2081 g_free(msg); |
2082 } | |
2083 | |
599 | 2084 static void room_destroy(gpointer bud, char *arg) |
2085 { | |
2086 gchar *msg; | |
2087 | |
2088 if (arg && *arg) | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2089 msg = to_utf8(arg); |
599 | 2090 else |
2091 msg = NULL; | |
2092 | |
2093 jb_room_destroy(buddy_getjid(bud), NULL, msg); | |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2094 g_free(msg); |
599 | 2095 } |
2096 | |
552 | 2097 static void room_unlock(gpointer bud, char *arg) |
2098 { | |
2099 if (*arg) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2100 scr_LogPrint(LPRINT_NORMAL, "Unknown parameter."); |
552 | 2101 return; |
2102 } | |
2103 | |
2104 jb_room_unlock(buddy_getjid(bud)); | |
2105 } | |
2106 | |
960
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2107 // room_whois(..) |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2108 // If interactive is TRUE, chatmode can be enabled. |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2109 void room_whois(gpointer bud, char *arg, guint interactive) |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2110 { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2111 char **paramlst; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2112 gchar *nick, *buffer; |
1058 | 2113 const char *bjid, *realjid; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2114 const char *rst_msg; |
575 | 2115 gchar rprio; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2116 enum imstatus rstatus; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2117 enum imrole role; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2118 enum imaffiliation affil; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2119 time_t rst_time; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2120 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2121 paramlst = split_arg(arg, 1, 0); // nickname |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2122 nick = *paramlst; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2123 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2124 if (!nick || !*nick) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2125 scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2126 free_arg_lst(paramlst); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2127 return; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2128 } |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2129 |
791
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2130 nick = to_utf8(nick); |
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2131 |
960
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2132 if (interactive) { |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2133 // Enter chat mode |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2134 scr_set_chatmode(TRUE); |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2135 scr_ShowBuddyWindow(); |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2136 } |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
2137 |
1058 | 2138 bjid = buddy_getjid(bud); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2139 rstatus = buddy_getstatus(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2140 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2141 if (rstatus == offline) { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2142 scr_LogPrint(LPRINT_NORMAL, "No such member: %s", nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2143 free_arg_lst(paramlst); |
791
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2144 g_free(nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2145 return; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2146 } |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2147 |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2148 rst_time = buddy_getstatustime(bud, nick); |
575 | 2149 rprio = buddy_getresourceprio(bud, nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2150 rst_msg = buddy_getstatusmsg(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2151 if (!rst_msg) rst_msg = ""; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2152 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2153 role = buddy_getrole(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2154 affil = buddy_getaffil(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2155 realjid = buddy_getrjid(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2156 |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2157 buffer = g_new(char, 4096); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2158 |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2159 snprintf(buffer, 4095, "Whois [%s]", nick); |
1058 | 2160 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2161 snprintf(buffer, 4095, "Status : [%c] %s", imstatus2char[rstatus], |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2162 rst_msg); |
1058 | 2163 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2164 |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2165 if (rst_time) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2166 char tbuf[128]; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2167 |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2168 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time)); |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2169 snprintf(buffer, 127, "Timestamp: %s", tbuf); |
1058 | 2170 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2171 } |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2172 |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2173 if (realjid) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2174 snprintf(buffer, 4095, "JID : <%s>", realjid); |
1058 | 2175 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2176 } |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2177 |
1058 | 2178 snprintf(buffer, 4095, "Role : %s", strrole[role]); |
2179 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2180 snprintf(buffer, 4095, "Affiliat.: %s", straffil[affil]); |
1058 | 2181 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2182 snprintf(buffer, 4095, "Priority : %d", rprio); |
1058 | 2183 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2184 |
1058 | 2185 scr_WriteIncomingMessage(bjid, "End of WHOIS", 0, HBB_PREFIX_INFO); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2186 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2187 g_free(buffer); |
791
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2188 g_free(nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2189 free_arg_lst(paramlst); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2190 } |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2191 |
1009 | 2192 static void room_bookmark(gpointer bud, char *arg) |
2193 { | |
2194 const char *roomid; | |
2195 const char *name = NULL, *nick = NULL; | |
2196 enum { bm_add = 0, bm_del = 1 } action = 0; | |
2197 int autojoin = 0; | |
2198 | |
2199 if (arg && *arg) { | |
2200 // /room bookmark [add|del] [[+|-]autojoin] | |
2201 char **paramlst; | |
2202 char **pp; | |
2203 | |
2204 paramlst = split_arg(arg, 2, 0); // At most 2 parameters | |
2205 for (pp = paramlst; *pp; pp++) { | |
2206 if (!strcasecmp(*pp, "add")) | |
2207 action = bm_add; | |
2208 else if (!strcasecmp(*pp, "del")) | |
2209 action = bm_del; | |
2210 else if (!strcasecmp(*pp, "-autojoin")) | |
2211 autojoin = 0; | |
2212 else if (!strcasecmp(*pp, "+autojoin") || !strcasecmp(*pp, "autojoin")) | |
2213 autojoin = 1; | |
2214 } | |
2215 free_arg_lst(paramlst); | |
2216 } | |
2217 | |
2218 roomid = buddy_getjid(bud); | |
2219 | |
2220 if (action == bm_add) { | |
2221 name = buddy_getname(bud); | |
2222 nick = buddy_getnickname(bud); | |
2223 } | |
2224 | |
2225 jb_set_storage_bookmark(roomid, name, nick, NULL, autojoin); | |
2226 } | |
2227 | |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2228 static void do_room(char *arg) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2229 { |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2230 char **paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2231 char *subcmd; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2232 gpointer bud; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2233 |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2234 if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2235 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2236 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2237 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2238 |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2239 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2240 subcmd = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2241 arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2242 |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2243 if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2244 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2245 free_arg_lst(paramlst); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2246 return; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2247 } |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2248 |
831
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2249 if (current_buddy) { |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2250 bud = BUDDATA(current_buddy); |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2251 } else { |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2252 if (strcasecmp(subcmd, "join")) { |
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2253 free_arg_lst(paramlst); |
831
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2254 return; |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2255 } |
831
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2256 // "room join" is a special case, we don't need to have a valid |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2257 // current_buddy. |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2258 bud = NULL; |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2259 } |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2260 |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2261 if (!strcasecmp(subcmd, "join")) { |
841
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
2262 if ((arg = check_room_subcommand(arg, FALSE, NULL)) != NULL) |
552 | 2263 room_join(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2264 } else if (!strcasecmp(subcmd, "invite")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2265 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
552 | 2266 room_invite(bud, arg); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2267 } else if (!strcasecmp(subcmd, "affil")) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2268 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2269 room_affil(bud, arg); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2270 } else if (!strcasecmp(subcmd, "role")) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2271 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2272 room_role(bud, arg); |
571 | 2273 } else if (!strcasecmp(subcmd, "ban")) { |
2274 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) | |
2275 room_ban(bud, arg); | |
568 | 2276 } else if (!strcasecmp(subcmd, "kick")) { |
2277 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) | |
2278 room_kick(bud, arg); | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2279 } else if (!strcasecmp(subcmd, "leave")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2280 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2281 room_leave(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2282 } else if (!strcasecmp(subcmd, "names")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2283 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2284 room_names(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2285 } else if (!strcasecmp(subcmd, "nick")) { |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2286 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2287 room_nick(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2288 } else if (!strcasecmp(subcmd, "privmsg")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2289 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
552 | 2290 room_privmsg(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2291 } else if (!strcasecmp(subcmd, "remove")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2292 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2293 room_remove(bud, arg); |
599 | 2294 } else if (!strcasecmp(subcmd, "destroy")) { |
2295 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) | |
2296 room_destroy(bud, arg); | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2297 } else if (!strcasecmp(subcmd, "unlock")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2298 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2299 room_unlock(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2300 } else if (!strcasecmp(subcmd, "topic")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2301 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2302 room_topic(bud, arg); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2303 } else if (!strcasecmp(subcmd, "whois")) { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2304 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
960
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2305 room_whois(bud, arg, TRUE); |
1009 | 2306 } else if (!strcasecmp(subcmd, "bookmark")) { |
2307 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) | |
2308 room_bookmark(bud, arg); | |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2309 } else { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2310 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2311 } |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2312 |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2313 free_arg_lst(paramlst); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2314 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2315 |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2316 static void do_authorization(char *arg) |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2317 { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2318 char **paramlst; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2319 char *subcmd; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2320 char *jid_utf8; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2321 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2322 if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2323 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2324 return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2325 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2326 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2327 paramlst = split_arg(arg, 2, 0); // subcmd, [jid] |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2328 subcmd = *paramlst; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2329 arg = *(paramlst+1); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2330 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2331 if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2332 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2333 goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2334 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2335 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2336 // Use the provided jid, if it looks valid |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2337 if (arg) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2338 if (!*arg) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2339 // If no jid is provided, we use the current selected buddy |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2340 arg = NULL; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2341 } else { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2342 if (check_jid_syntax(arg)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2343 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2344 "<%s> is not a valid Jabber ID.", arg); |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2345 goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2346 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2347 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2348 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2349 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2350 if (!arg) { // Use the current selected buddy's jid |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2351 gpointer bud; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2352 guint type; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2353 |
1058 | 2354 if (!current_buddy) |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2355 goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2356 bud = BUDDATA(current_buddy); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2357 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2358 jid_utf8 = arg = (char*)buddy_getjid(bud); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2359 type = buddy_gettype(bud); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2360 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2361 if (!(type & (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT))) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2362 scr_LogPrint(LPRINT_NORMAL, "Invalid buddy."); |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2363 goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2364 } |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2365 } else { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2366 jid_utf8 = to_utf8(arg); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2367 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2368 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2369 if (!strcasecmp(subcmd, "allow")) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2370 jb_subscr_send_auth(jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2371 scr_LogPrint(LPRINT_LOGNORM, |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2372 "<%s> is now allowed to receive your presence updates.", |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2373 jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2374 } else if (!strcasecmp(subcmd, "cancel")) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2375 jb_subscr_cancel_auth(jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2376 scr_LogPrint(LPRINT_LOGNORM, |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2377 "<%s> will no longer receive your presence updates.", |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2378 jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2379 } else if (!strcasecmp(subcmd, "request")) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2380 jb_subscr_request_auth(jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2381 scr_LogPrint(LPRINT_LOGNORM, |
957 | 2382 "Sent presence notification request to <%s>.", jid_utf8); |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2383 } else if (!strcasecmp(subcmd, "request_unsubscribe")) { |
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2384 jb_subscr_request_cancel(jid_utf8); |
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2385 scr_LogPrint(LPRINT_LOGNORM, |
957 | 2386 "Sent presence notification unsubscription request to <%s>.", |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2387 jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2388 } else { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2389 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2390 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2391 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2392 // Only free jid_utf8 if it has been allocated, i.e. if != arg. |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2393 if (jid_utf8 && jid_utf8 != arg) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2394 g_free(jid_utf8); |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2395 do_authorization_return: |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2396 free_arg_lst(paramlst); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2397 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2398 |
622 | 2399 static void do_version(char *arg) |
2400 { | |
777
e6d42f239541
"/version" shows Mercurial changeset (if there's one)
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
2401 gchar *ver = mcabber_version(); |
e6d42f239541
"/version" shows Mercurial changeset (if there's one)
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
2402 scr_LogPrint(LPRINT_NORMAL, "This is mcabber version %s.", ver); |
e6d42f239541
"/version" shows Mercurial changeset (if there's one)
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
2403 g_free(ver); |
622 | 2404 } |
2405 | |
693 | 2406 static void do_request(char *arg) |
2407 { | |
2408 char **paramlst; | |
1058 | 2409 char *fjid, *type; |
740 | 2410 enum iqreq_type numtype = iqreq_none; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2411 char *jid_utf8 = NULL; |
693 | 2412 |
2413 paramlst = split_arg(arg, 2, 0); // type, jid | |
2414 type = *paramlst; | |
1058 | 2415 fjid = *(paramlst+1); |
693 | 2416 |
2417 if (type) { | |
2418 // Quick check... | |
2419 if (!strcasecmp(type, "version")) | |
2420 numtype = iqreq_version; | |
2421 else if (!strcasecmp(type, "time")) | |
2422 numtype = iqreq_time; | |
1015 | 2423 else if (!strcasecmp(type, "last")) |
2424 numtype = iqreq_last; | |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
2425 else if (!strcasecmp(type, "vcard")) |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
2426 numtype = iqreq_vcard; |
694
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2427 else if (!strcasecmp(type, "show_list")) { |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2428 // Undocumented command, for debugging purposes only |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2429 jb_iqs_display_list(); |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2430 free_arg_lst(paramlst); |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2431 return; |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2432 } |
693 | 2433 } |
2434 | |
2435 if (!type || !numtype) { | |
2436 scr_LogPrint(LPRINT_NORMAL, | |
1015 | 2437 "Please specify a query type (version, time...)."); |
693 | 2438 free_arg_lst(paramlst); |
2439 return; | |
2440 } | |
2441 | |
2442 // Allow special jid "" or "." (current buddy) | |
1058 | 2443 if (fjid && (!*fjid || !strcmp(fjid, "."))) |
2444 fjid = NULL; | |
693 | 2445 |
1058 | 2446 if (fjid) { |
693 | 2447 // The JID has been specified. Quick check... |
1058 | 2448 if (check_jid_syntax(fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2449 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2450 "<%s> is not a valid Jabber ID.", fjid); |
1058 | 2451 fjid = NULL; |
693 | 2452 } else { |
2453 // Convert jid to lowercase | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2454 char *p; |
1058 | 2455 for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) |
693 | 2456 *p = tolower(*p); |
1058 | 2457 fjid = jid_utf8 = to_utf8(fjid); |
693 | 2458 } |
2459 } else { | |
2460 // Add the current buddy | |
2461 if (current_buddy) | |
1058 | 2462 fjid = (char*)buddy_getjid(BUDDATA(current_buddy)); |
2463 if (!fjid) | |
693 | 2464 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
2465 } | |
2466 | |
1058 | 2467 if (fjid) { |
693 | 2468 switch (numtype) { |
2469 case iqreq_version: | |
2470 case iqreq_time: | |
1015 | 2471 case iqreq_last: |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
2472 case iqreq_vcard: |
1058 | 2473 jb_request(fjid, numtype); |
693 | 2474 break; |
2475 default: | |
2476 break; | |
2477 } | |
2478 } | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2479 g_free(jid_utf8); |
693 | 2480 free_arg_lst(paramlst); |
2481 } | |
2482 | |
748 | 2483 static void do_event(char *arg) |
2484 { | |
2485 char **paramlst; | |
2486 char *evid, *subcmd; | |
2487 int action = -1; | |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2488 GSList *evidlst; |
748 | 2489 |
2490 paramlst = split_arg(arg, 2, 0); // id, subcmd | |
2491 evid = *paramlst; | |
2492 subcmd = *(paramlst+1); | |
2493 | |
2494 if (!evid || !subcmd) { | |
2495 // Special case: /event list | |
2496 if (evid && !strcasecmp(evid, "list")) | |
2497 evs_display_list(); | |
2498 else | |
2499 scr_LogPrint(LPRINT_NORMAL, | |
2500 "Missing parameter. Usage: /event num action"); | |
2501 free_arg_lst(paramlst); | |
2502 return; | |
2503 } | |
2504 | |
2505 if (!strcasecmp(subcmd, "reject")) | |
2506 action = 0; | |
2507 else if (!strcasecmp(subcmd, "accept")) | |
2508 action = 1; | |
755 | 2509 else if (!strcasecmp(subcmd, "ignore")) |
2510 action = 2; | |
748 | 2511 |
2512 if (action == -1) { | |
2513 scr_LogPrint(LPRINT_NORMAL, "Wrong action parameter."); | |
755 | 2514 } else if (action >= 0 && action <= 2) { |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2515 GSList *p; |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2516 |
755 | 2517 if (action == 2) { |
2518 action = EVS_CONTEXT_CANCEL; | |
2519 } else { | |
2520 action += EVS_CONTEXT_USER; | |
2521 } | |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2522 |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2523 if (!strcmp(evid, "*")) { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2524 // Use completion list |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2525 evidlst = evs_geteventslist(FALSE); |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2526 } else { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2527 // Let's create a slist with the provided event id |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2528 evidlst = g_slist_append(NULL, g_strdup(evid)); |
748 | 2529 } |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2530 for (p = evidlst; p; p = g_slist_next(p)) { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2531 if (evs_callback(p->data, action) == -1) { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2532 scr_LogPrint(LPRINT_NORMAL, "Event %s not found.", p->data); |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2533 } |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2534 g_free(p->data); |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2535 } |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2536 g_slist_free(evidlst); |
748 | 2537 } |
2538 | |
2539 free_arg_lst(paramlst); | |
2540 } | |
2541 | |
1066 | 2542 static void do_pgp(char *arg) |
2543 { | |
2544 char **paramlst; | |
2545 char *fjid, *subcmd, *keyid; | |
2546 enum { | |
2547 pgp_none, | |
2548 pgp_enable, | |
2549 pgp_disable, | |
2550 pgp_setkey, | |
2551 pgp_info | |
2552 } op = 0; | |
2553 | |
2554 paramlst = split_arg(arg, 3, 0); // subcmd, jid, [key] | |
2555 subcmd = *paramlst; | |
2556 fjid = *(paramlst+1); | |
2557 keyid = *(paramlst+2); | |
2558 | |
2559 if (!subcmd) | |
2560 fjid = NULL; | |
2561 if (!fjid) | |
2562 keyid = NULL; | |
2563 | |
2564 if (subcmd) { | |
2565 if (!strcasecmp(subcmd, "enable")) | |
2566 op = pgp_enable; | |
2567 else if (!strcasecmp(subcmd, "disable")) | |
2568 op = pgp_disable; | |
2569 else if (!strcasecmp(subcmd, "setkey")) | |
2570 op = pgp_setkey; | |
2571 else if (!strcasecmp(subcmd, "info")) | |
2572 op = pgp_info; | |
2573 } | |
2574 | |
2575 if (!op) { | |
2576 scr_LogPrint(LPRINT_NORMAL, "Unrecognized or missing parameter!"); | |
2577 free_arg_lst(paramlst); | |
2578 return; | |
2579 } | |
2580 | |
2581 // Allow special jid "" or "." (current buddy) | |
2582 if (fjid && (!*fjid || !strcmp(fjid, "."))) | |
2583 fjid = NULL; | |
2584 | |
2585 if (fjid) { | |
2586 // The JID has been specified. Quick check... | |
2587 if (check_jid_syntax(fjid) || !strchr(fjid, '@')) { | |
2588 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, | |
2589 "<%s> is not a valid Jabber ID.", fjid); | |
2590 fjid = NULL; | |
2591 } else { | |
2592 // Convert jid to lowercase and strip resource | |
2593 char *p; | |
2594 for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) | |
2595 *p = tolower(*p); | |
2596 if (*p == JID_RESOURCE_SEPARATOR) | |
2597 *p = '\0'; | |
2598 } | |
2599 } else { | |
2600 gpointer bud = NULL; | |
2601 if (current_buddy) | |
2602 bud = BUDDATA(current_buddy); | |
2603 if (bud) { | |
2604 guint type = buddy_gettype(bud); | |
2605 if (type & ROSTER_TYPE_USER) // Is it a user? | |
2606 fjid = (char*)buddy_getjid(bud); | |
2607 else | |
2608 scr_LogPrint(LPRINT_NORMAL, "The selected item should be a user."); | |
2609 } | |
2610 } | |
2611 | |
2612 if (fjid) { // fjid is actually a bare jid... | |
2613 GString *sbuf; | |
2614 switch (op) { | |
2615 case pgp_enable: | |
2616 case pgp_disable: | |
2617 settings_pgp_setdisabled(fjid, (op == pgp_disable ? TRUE : FALSE)); | |
2618 break; | |
2619 case pgp_setkey: | |
2620 settings_pgp_setkeyid(fjid, keyid); | |
2621 break; | |
2622 case pgp_info: | |
2623 sbuf = g_string_new(""); | |
2624 if (settings_pgp_getkeyid(fjid)) { | |
2625 g_string_printf(sbuf, "PGP Encryption key id: %s", | |
2626 settings_pgp_getkeyid(fjid)); | |
2627 scr_WriteIncomingMessage(fjid, sbuf->str, 0, HBB_PREFIX_INFO); | |
2628 } | |
2629 g_string_printf(sbuf, "PGP encryption is %s", | |
2630 (settings_pgp_getdisabled(fjid) ? "disabled" : | |
2631 "enabled")); | |
2632 scr_WriteIncomingMessage(fjid, sbuf->str, 0, HBB_PREFIX_INFO); | |
2633 g_string_free(sbuf, TRUE); | |
2634 break; | |
2635 default: | |
2636 break; | |
2637 } | |
2638 } else { | |
2639 scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); | |
2640 } | |
2641 | |
2642 free_arg_lst(paramlst); | |
2643 } | |
2644 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
2645 static void do_connect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2646 { |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2647 mcabber_connect(); |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2648 } |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2649 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
2650 static void do_disconnect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2651 { |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2652 jb_disconnect(); |
1014
99c5278bf6b8
Keep the status and status messages when we're disconnected
Mikael Berthe <mikael@lilotux.net>
parents:
1012
diff
changeset
|
2653 AutoConnection = false; |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2654 } |
576 | 2655 |
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
2656 static void do_help(char *arg) |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
2657 { |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
2658 help_process(arg); |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
2659 } |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
2660 |
580 | 2661 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |