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