Mercurial > hg
annotate mcabber/src/commands.c @ 1399:187985455020
Correctly display PGP-encoded messages with a subject
Minor style change
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Thu, 13 Dec 2007 22:36:04 +0100 |
parents | d431cd75eb53 |
children | 0cb4361c85a7 |
rev | line source |
---|---|
47 | 1 /* |
699 | 2 * commands.c -- user commands handling |
393 | 3 * |
1205 | 4 * Copyright (C) 2005-2007 Mikael Berthe <mikael@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" |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
35 #include "otr.h" |
47 | 36 |
967 | 37 #define IMSTATUS_AWAY "away" |
38 #define IMSTATUS_ONLINE "online" | |
39 #define IMSTATUS_OFFLINE "offline" | |
40 #define IMSTATUS_FREE4CHAT "free" | |
41 #define IMSTATUS_INVISIBLE "invisible" | |
42 #define IMSTATUS_AVAILABLE "avail" | |
43 #define IMSTATUS_NOTAVAILABLE "notavail" | |
44 #define IMSTATUS_DONOTDISTURB "dnd" | |
45 | |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
46 // Return value container for the following functions |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
47 static int retval_for_cmds; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
48 |
104 | 49 // Commands callbacks |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
50 static void do_roster(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
51 static void do_status(char *arg); |
444 | 52 static void do_status_to(char *arg); |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
53 static void do_add(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
54 static void do_del(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
55 static void do_group(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
56 static void do_say(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
57 static void do_msay(char *arg); |
480 | 58 static void do_say_to(char *arg); |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
59 static void do_buffer(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
60 static void do_clear(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
61 static void do_info(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
62 static void do_rename(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
63 static void do_move(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
64 static void do_set(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
65 static void do_alias(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
66 static void do_bind(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
67 static void do_connect(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
68 static void do_disconnect(char *arg); |
436 | 69 static void do_rawxml(char *arg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
70 static void do_room(char *arg); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
71 static void do_authorization(char *arg); |
622 | 72 static void do_version(char *arg); |
693 | 73 static void do_request(char *arg); |
748 | 74 static void do_event(char *arg); |
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
75 static void do_help(char *arg); |
1066 | 76 static void do_pgp(char *arg); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
77 static void do_iline(char *arg); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
78 static void do_screen_refresh(char *arg); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
79 static void do_chat_disable(char *arg); |
1192 | 80 static void do_source(char *arg); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
81 static void do_color(char *arg); |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
82 static void do_otr(char *arg); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
83 static void do_otrpolicy(char *arg); |
47 | 84 |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
85 static void do_say_internal(char *arg, int parse_flags); |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
86 |
104 | 87 // Global variable for the commands list |
95 | 88 static GSList *Commands; |
89 | |
104 | 90 |
95 | 91 // cmd_add() |
92 // 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
|
93 static void cmd_add(const char *name, const char *help, |
1059 | 94 guint flags_row1, guint flags_row2, void (*f)(char*)) |
95 | 95 { |
96 cmd *n_cmd = g_new0(cmd, 1); | |
97 strncpy(n_cmd->name, name, 32-1); | |
98 n_cmd->help = help; | |
99 n_cmd->completion_flags[0] = flags_row1; | |
100 n_cmd->completion_flags[1] = flags_row2; | |
101 n_cmd->func = f; | |
102 | 102 Commands = g_slist_append(Commands, n_cmd); |
95 | 103 // Add to completion CMD category |
104 compl_add_category_word(COMPL_CMD, name); | |
105 } | |
106 | |
107 // cmd_init() | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
108 // Commands table initialization |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
109 // !!! |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
110 // After changing commands names and it arguments names here, you must change |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
111 // ones in init_bindings()! |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
112 // |
95 | 113 void cmd_init(void) |
114 { | |
124 | 115 cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add); |
285 | 116 cmd_add("alias", "Add an alias", 0, 0, &do_alias); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
117 cmd_add("authorization", "Manage subscription authorizations", |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
118 COMPL_AUTH, COMPL_JID, &do_authorization); |
288 | 119 cmd_add("bind", "Add an key binding", 0, 0, &do_bind); |
187 | 120 cmd_add("buffer", "Manipulate current buddy's buffer (chat window)", |
121 COMPL_BUFFER, 0, &do_buffer); | |
1221
0dd5df7eb007
Fix wrong command completion order (reported by Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
122 cmd_add("chat_disable", "Disable chat mode", 0, 0, &do_chat_disable); |
108 | 123 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
|
124 cmd_add("connect", "Connect to the server", 0, 0, &do_connect); |
205 | 125 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
|
126 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
|
127 cmd_add("event", "Process an event", COMPL_EVENTSID, COMPL_EVENTS, &do_event); |
128 | 128 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
|
129 cmd_add("help", "Display some help", COMPL_CMD, 0, &do_help); |
1221
0dd5df7eb007
Fix wrong command completion order (reported by Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
130 cmd_add("iline", "Manipulate input buffer", 0, 0, &do_iline); |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
131 cmd_add("info", "Show basic info on current buddy", 0, 0, &do_info); |
225 | 132 cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, |
133 0, &do_move); | |
238 | 134 cmd_add("msay", "Send a multi-lines message to the selected buddy", |
135 COMPL_MULTILINE, 0, &do_msay); | |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
136 cmd_add("otr", "Manage OTR settings", COMPL_OTR, COMPL_JID, &do_otr); |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
137 cmd_add("otrpolicy", "Manage OTR policies", COMPL_JID, COMPL_OTRPOLICY, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
138 &do_otrpolicy); |
1066 | 139 cmd_add("pgp", "Manage PGP settings", COMPL_PGP, COMPL_JID, &do_pgp); |
95 | 140 cmd_add("quit", "Exit the software", 0, 0, NULL); |
436 | 141 cmd_add("rawxml", "Send a raw XML string", 0, 0, &do_rawxml); |
208 | 142 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
|
143 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
|
144 &do_request); |
2016f52a167f
Sort commands (for the completion system)
Mikael Berthe <mikael@lilotux.net>
parents:
900
diff
changeset
|
145 cmd_add("room", "MUC actions command", COMPL_ROOM, 0, &do_room); |
128 | 146 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, |
147 &do_roster); | |
132 | 148 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
|
149 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
|
150 &do_say_to); |
1221
0dd5df7eb007
Fix wrong command completion order (reported by Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
151 cmd_add("screen_refresh", "Redraw mcabber screen", 0, 0, &do_screen_refresh); |
95 | 152 //cmd_add("search"); |
310 | 153 cmd_add("set", "Set/query an option value", 0, 0, &do_set); |
1192 | 154 cmd_add("source", "Read a configuration file", 0, 0, &do_source); |
116 | 155 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status); |
444 | 156 cmd_add("status_to", "Show or set your status for one recipient", |
157 COMPL_JID, COMPL_STATUS, &do_status_to); | |
622 | 158 cmd_add("version", "Show mcabber version", 0, 0, &do_version); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
159 cmd_add("color", "Set coloring options", COMPL_COLOR, 0, &do_color); |
95 | 160 |
161 // Status category | |
162 compl_add_category_word(COMPL_STATUS, "online"); | |
163 compl_add_category_word(COMPL_STATUS, "avail"); | |
164 compl_add_category_word(COMPL_STATUS, "invisible"); | |
165 compl_add_category_word(COMPL_STATUS, "free"); | |
166 compl_add_category_word(COMPL_STATUS, "dnd"); | |
167 compl_add_category_word(COMPL_STATUS, "notavail"); | |
168 compl_add_category_word(COMPL_STATUS, "away"); | |
1235
58d6e7713164
Complete /status offline
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
169 compl_add_category_word(COMPL_STATUS, "offline"); |
103 | 170 |
171 // Roster category | |
172 compl_add_category_word(COMPL_ROSTER, "bottom"); | |
265 | 173 compl_add_category_word(COMPL_ROSTER, "top"); |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
174 compl_add_category_word(COMPL_ROSTER, "up"); |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
175 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
|
176 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
|
177 compl_add_category_word(COMPL_ROSTER, "group_next"); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
178 compl_add_category_word(COMPL_ROSTER, "hide"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
179 compl_add_category_word(COMPL_ROSTER, "show"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
180 compl_add_category_word(COMPL_ROSTER, "toggle"); |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1305
diff
changeset
|
181 compl_add_category_word(COMPL_ROSTER, "display"); |
103 | 182 compl_add_category_word(COMPL_ROSTER, "hide_offline"); |
183 compl_add_category_word(COMPL_ROSTER, "show_offline"); | |
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
184 compl_add_category_word(COMPL_ROSTER, "toggle_offline"); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
185 compl_add_category_word(COMPL_ROSTER, "item_lock"); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
186 compl_add_category_word(COMPL_ROSTER, "item_unlock"); |
1350
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
187 compl_add_category_word(COMPL_ROSTER, "item_toggle_lock"); |
330 | 188 compl_add_category_word(COMPL_ROSTER, "alternate"); |
265 | 189 compl_add_category_word(COMPL_ROSTER, "search"); |
236 | 190 compl_add_category_word(COMPL_ROSTER, "unread_first"); |
191 compl_add_category_word(COMPL_ROSTER, "unread_next"); | |
1016 | 192 compl_add_category_word(COMPL_ROSTER, "note"); |
127 | 193 |
187 | 194 // Roster category |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
195 compl_add_category_word(COMPL_BUFFER, "clear"); |
187 | 196 compl_add_category_word(COMPL_BUFFER, "bottom"); |
197 compl_add_category_word(COMPL_BUFFER, "top"); | |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
198 compl_add_category_word(COMPL_BUFFER, "up"); |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
199 compl_add_category_word(COMPL_BUFFER, "down"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
200 compl_add_category_word(COMPL_BUFFER, "search_backward"); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
201 compl_add_category_word(COMPL_BUFFER, "search_forward"); |
464 | 202 compl_add_category_word(COMPL_BUFFER, "date"); |
462 | 203 compl_add_category_word(COMPL_BUFFER, "%"); |
866 | 204 compl_add_category_word(COMPL_BUFFER, "purge"); |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1130
diff
changeset
|
205 compl_add_category_word(COMPL_BUFFER, "close"); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
206 compl_add_category_word(COMPL_BUFFER, "close_all"); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
207 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
|
208 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
|
209 compl_add_category_word(COMPL_BUFFER, "scroll_toggle"); |
187 | 210 |
127 | 211 // Group category |
240 | 212 compl_add_category_word(COMPL_GROUP, "fold"); |
213 compl_add_category_word(COMPL_GROUP, "unfold"); | |
130 | 214 compl_add_category_word(COMPL_GROUP, "toggle"); |
238 | 215 |
216 // Multi-line (msay) category | |
217 compl_add_category_word(COMPL_MULTILINE, "abort"); | |
218 compl_add_category_word(COMPL_MULTILINE, "begin"); | |
219 compl_add_category_word(COMPL_MULTILINE, "send"); | |
636 | 220 compl_add_category_word(COMPL_MULTILINE, "send_to"); |
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
221 compl_add_category_word(COMPL_MULTILINE, "toggle"); |
838
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
222 compl_add_category_word(COMPL_MULTILINE, "toggle_verbatim"); |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
223 compl_add_category_word(COMPL_MULTILINE, "verbatim"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
224 |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
225 // Room category |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
226 compl_add_category_word(COMPL_ROOM, "affil"); |
571 | 227 compl_add_category_word(COMPL_ROOM, "ban"); |
1009 | 228 compl_add_category_word(COMPL_ROOM, "bookmark"); |
599 | 229 compl_add_category_word(COMPL_ROOM, "destroy"); |
486 | 230 compl_add_category_word(COMPL_ROOM, "invite"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
231 compl_add_category_word(COMPL_ROOM, "join"); |
568 | 232 compl_add_category_word(COMPL_ROOM, "kick"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
233 compl_add_category_word(COMPL_ROOM, "leave"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
234 compl_add_category_word(COMPL_ROOM, "names"); |
470 | 235 compl_add_category_word(COMPL_ROOM, "nick"); |
490 | 236 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
|
237 compl_add_category_word(COMPL_ROOM, "remove"); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
238 compl_add_category_word(COMPL_ROOM, "role"); |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
239 compl_add_category_word(COMPL_ROOM, "setopt"); |
475
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
240 compl_add_category_word(COMPL_ROOM, "topic"); |
1260
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
241 compl_add_category_word(COMPL_ROOM, "unban"); |
449 | 242 compl_add_category_word(COMPL_ROOM, "unlock"); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
243 compl_add_category_word(COMPL_ROOM, "whois"); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
244 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
245 // Authorization category |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
246 compl_add_category_word(COMPL_AUTH, "allow"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
247 compl_add_category_word(COMPL_AUTH, "cancel"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
248 compl_add_category_word(COMPL_AUTH, "request"); |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
249 compl_add_category_word(COMPL_AUTH, "request_unsubscribe"); |
693 | 250 |
251 // Request (query) category | |
1015 | 252 compl_add_category_word(COMPL_REQUEST, "last"); |
693 | 253 compl_add_category_word(COMPL_REQUEST, "time"); |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
254 compl_add_category_word(COMPL_REQUEST, "vcard"); |
693 | 255 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
|
256 |
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
257 // Events category |
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
258 compl_add_category_word(COMPL_EVENTS, "accept"); |
755 | 259 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
|
260 compl_add_category_word(COMPL_EVENTS, "reject"); |
1066 | 261 |
262 // PGP category | |
263 compl_add_category_word(COMPL_PGP, "disable"); | |
264 compl_add_category_word(COMPL_PGP, "enable"); | |
1197 | 265 compl_add_category_word(COMPL_PGP, "force"); |
1066 | 266 compl_add_category_word(COMPL_PGP, "info"); |
267 compl_add_category_word(COMPL_PGP, "setkey"); | |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
268 |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
269 // OTR category |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
270 compl_add_category_word(COMPL_OTR, "start"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
271 compl_add_category_word(COMPL_OTR, "stop"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
272 compl_add_category_word(COMPL_OTR, "fingerprint"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
273 compl_add_category_word(COMPL_OTR, "smpq"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
274 compl_add_category_word(COMPL_OTR, "smpr"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
275 compl_add_category_word(COMPL_OTR, "smpa"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
276 compl_add_category_word(COMPL_OTR, "info"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
277 compl_add_category_word(COMPL_OTR, "key"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
278 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
279 // OTR Policy category |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
280 compl_add_category_word(COMPL_OTRPOLICY, "plain"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
281 compl_add_category_word(COMPL_OTRPOLICY, "manual"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
282 compl_add_category_word(COMPL_OTRPOLICY, "opportunistic"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
283 compl_add_category_word(COMPL_OTRPOLICY, "always"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
284 |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
285 // Color category |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
286 compl_add_category_word(COMPL_COLOR, "roster"); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
287 compl_add_category_word(COMPL_COLOR, "muc"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
288 compl_add_category_word(COMPL_COLOR, "mucnick"); |
95 | 289 } |
94 | 290 |
285 | 291 // expandalias(line) |
292 // If there is one, expand the alias in line and returns a new allocated line | |
293 // If no alias is found, returns line | |
1356
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
294 // Note: if the returned pointer is different from line, the caller should |
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
295 // g_free() the pointer after use |
1352
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
296 char *expandalias(const char *line) |
285 | 297 { |
298 const char *p1, *p2; | |
299 char *word; | |
300 const gchar *value; | |
1352
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
301 char *newline = (char*)line; |
285 | 302 |
967 | 303 // Ignore leading COMMAND_CHAR |
304 for (p1 = line ; *p1 == COMMAND_CHAR ; p1++) | |
285 | 305 ; |
306 // Locate the end of the word | |
307 for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) | |
308 ; | |
1387 | 309 // Extract the word and look for an alias in the list |
285 | 310 word = g_strndup(p1, p2-p1); |
311 value = settings_get(SETTINGS_TYPE_ALIAS, (const char*)word); | |
312 g_free(word); | |
313 | |
1387 | 314 if (value) |
315 newline = g_strdup_printf("%c%s%s", COMMAND_CHAR, value, p2); | |
316 | |
285 | 317 return newline; |
318 } | |
319 | |
102 | 320 // cmd_get |
321 // Finds command in the command list structure. | |
322 // Returns a pointer to the cmd entry, or NULL if command not found. | |
238 | 323 cmd *cmd_get(const char *command) |
102 | 324 { |
238 | 325 const char *p1, *p2; |
102 | 326 char *com; |
327 GSList *sl_com; | |
285 | 328 |
967 | 329 // Ignore leading COMMAND_CHAR |
330 for (p1 = command ; *p1 == COMMAND_CHAR ; p1++) | |
102 | 331 ; |
332 // Locate the end of the command | |
333 for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) | |
334 ; | |
335 // Copy the clean command | |
336 com = g_strndup(p1, p2-p1); | |
337 | |
338 // Look for command in the list | |
339 for (sl_com=Commands; sl_com; sl_com = g_slist_next(sl_com)) { | |
340 if (!strcasecmp(com, ((cmd*)sl_com->data)->name)) | |
341 break; | |
342 } | |
343 g_free(com); | |
344 | |
345 if (sl_com) // Command has been found. | |
346 return (cmd*)sl_com->data; | |
347 return NULL; | |
348 } | |
349 | |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1181
diff
changeset
|
350 // process_command(line, iscmd) |
288 | 351 // Process a command line. |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1181
diff
changeset
|
352 // If iscmd is TRUE, process the command even if verbatim mmode is set; |
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1181
diff
changeset
|
353 // it is intended to be used for key bindings. |
288 | 354 // Return 255 if this is the /quit command, and 0 for the other commands. |
1352
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
355 int process_command(const char *line, guint iscmd) |
47 | 356 { |
101 | 357 char *p; |
285 | 358 char *xpline; |
104 | 359 cmd *curcmd; |
360 | |
1365 | 361 if (!line) |
362 return 0; | |
363 | |
285 | 364 // We do alias expansion here |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1181
diff
changeset
|
365 if (iscmd || scr_get_multimode() != 2) |
288 | 366 xpline = expandalias(line); |
367 else | |
1352
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
368 xpline = (char*)line; // No expansion in verbatim multi-line mode |
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
369 |
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
370 // We want to use a copy |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
371 if (xpline == line) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
372 xpline = g_strdup(line); |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
373 |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
374 // Remove trailing spaces: |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
375 for (p=xpline ; *p ; p++) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
376 ; |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
377 for (p-- ; p>xpline && (*p == ' ') ; p--) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
378 *p = 0; |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
379 |
101 | 380 // Command "quit"? |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1181
diff
changeset
|
381 if ((iscmd || scr_get_multimode() != 2) |
1126
771eb6aa2d41
Fix another memory leak, spotted by valgrind
misc@mandriva.org
parents:
1100
diff
changeset
|
382 && (!strncasecmp(xpline, mkcmdstr("quit"), strlen(mkcmdstr("quit"))))) { |
771eb6aa2d41
Fix another memory leak, spotted by valgrind
misc@mandriva.org
parents:
1100
diff
changeset
|
383 if (!xpline[5] || xpline[5] == ' ') { |
771eb6aa2d41
Fix another memory leak, spotted by valgrind
misc@mandriva.org
parents:
1100
diff
changeset
|
384 g_free(xpline); |
116 | 385 return 255; |
1126
771eb6aa2d41
Fix another memory leak, spotted by valgrind
misc@mandriva.org
parents:
1100
diff
changeset
|
386 } |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1356
diff
changeset
|
387 } else if (iscmd && !strncasecmp(xpline, "quit", 4) && |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1356
diff
changeset
|
388 (!xpline[4] || xpline[4] == ' ')) { |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1356
diff
changeset
|
389 // If iscmd is true we can have the command without the command prefix |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1356
diff
changeset
|
390 // character (usually '/'). |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1356
diff
changeset
|
391 g_free(xpline); |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1356
diff
changeset
|
392 return 255; |
1126
771eb6aa2d41
Fix another memory leak, spotted by valgrind
misc@mandriva.org
parents:
1100
diff
changeset
|
393 } |
104 | 394 |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
395 // If verbatim multi-line mode, we check if another /msay command is typed |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1181
diff
changeset
|
396 if (!iscmd && scr_get_multimode() == 2 |
967 | 397 && (strncasecmp(xpline, mkcmdstr("msay "), strlen(mkcmdstr("msay "))))) { |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
398 // It isn't an /msay command |
285 | 399 scr_append_multiline(xpline); |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
400 g_free(xpline); |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
401 return 0; |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
402 } |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
403 |
47 | 404 // Commands handling |
285 | 405 curcmd = cmd_get(xpline); |
47 | 406 |
104 | 407 if (!curcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
408 scr_LogPrint(LPRINT_NORMAL, "Unrecognized command. " |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
409 "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
|
410 g_free(xpline); |
104 | 411 return 0; |
412 } | |
413 if (!curcmd->func) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
414 scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
415 "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
|
416 g_free(xpline); |
104 | 417 return 0; |
418 } | |
419 // Lets go to the command parameters | |
285 | 420 for (p = xpline+1; *p && (*p != ' ') ; p++) |
104 | 421 ; |
422 // Skip spaces | |
285 | 423 while (*p && (*p == ' ')) |
424 p++; | |
104 | 425 // Call command-specific function |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
426 retval_for_cmds = 0; |
285 | 427 (*curcmd->func)(p); |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
428 g_free(xpline); |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
429 return retval_for_cmds; |
47 | 430 } |
431 | |
288 | 432 // process_line(line) |
433 // Process a command/message line. | |
434 // If this isn't a command, this is a message and it is sent to the | |
435 // currently selected buddy. | |
436 // Return 255 if the line is the /quit command, or 0. | |
1352
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
437 int process_line(const char *line) |
288 | 438 { |
439 if (!*line) { // User only pressed enter | |
440 if (scr_get_multimode()) { | |
441 scr_append_multiline(""); | |
442 return 0; | |
443 } | |
444 if (current_buddy) { | |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
445 // Enter chat mode |
288 | 446 scr_set_chatmode(TRUE); |
447 scr_ShowBuddyWindow(); | |
448 } | |
449 return 0; | |
450 } | |
451 | |
967 | 452 if (*line != COMMAND_CHAR) { |
288 | 453 // This isn't a command |
454 if (scr_get_multimode()) | |
455 scr_append_multiline(line); | |
456 else | |
1352
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
457 do_say_internal((char*)line, 0); |
288 | 458 return 0; |
459 } | |
460 | |
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1181
diff
changeset
|
461 /* It is _probably_ a command -- except for verbatim multi-line mode */ |
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1181
diff
changeset
|
462 return process_command(line, FALSE); |
288 | 463 } |
464 | |
1350
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
465 // Helper routine for buffer item_{lock,unlock,toggle_lock} |
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
466 // "lock" values: 1=lock 0=unlock -1=invert |
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
467 static void roster_buddylock(char *bjid, int lock) |
974
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 gpointer bud = NULL; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
470 bool may_need_refresh = FALSE; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
471 |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
472 // Allow special jid "" or "." (current buddy) |
1058 | 473 if (bjid && (!*bjid || !strcmp(bjid, "."))) |
474 bjid = NULL; | |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
475 |
1058 | 476 if (bjid) { |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
477 // The JID has been specified. Quick check... |
1058 | 478 if (check_jid_syntax(bjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
479 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
480 "<%s> is not a valid Jabber ID.", bjid); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
481 } else { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
482 // Find the buddy |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
483 GSList *roster_elt; |
1058 | 484 roster_elt = roster_find(bjid, jidsearch, |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
485 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
486 if (roster_elt) |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
487 bud = roster_elt->data; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
488 else |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
489 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
|
490 may_need_refresh = TRUE; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
491 } |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
492 } else { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
493 // Use the current buddy |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
494 if (current_buddy) |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
495 bud = BUDDATA(current_buddy); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
496 } |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
497 |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
498 // Update the ROSTER_FLAG_USRLOCK flag |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
499 if (bud) { |
1350
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
500 if (lock == -1) |
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
501 lock = !(buddy_getflags(bud) & ROSTER_FLAG_USRLOCK); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
502 buddy_setflags(bud, ROSTER_FLAG_USRLOCK, lock); |
1350
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
503 if (may_need_refresh) { |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
504 buddylist_build(); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
505 update_roster = TRUE; |
1350
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
506 } |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
507 } |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
508 } |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
509 |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
510 // display_and_free_note(note, winId) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
511 // 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
|
512 // (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
|
513 // display the note jid too) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
514 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
|
515 { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
516 gchar tbuf[128]; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
517 GString *sbuf; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
518 guint msg_flag = HBB_PREFIX_INFO; |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
519 /* We use the flag prefix_info for the first line, and prefix_cont |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
520 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
|
521 |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
522 if (!note) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
523 return; |
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 sbuf = g_string_new(""); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
526 |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
527 if (!winId) { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
528 // 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
|
529 g_string_printf(sbuf, "Annotation on <%s>", note->jid); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
530 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag, 0); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
531 msg_flag = HBB_PREFIX_INFO | HBB_PREFIX_CONT; |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
532 } |
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 // 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
|
535 if (note->cdate) { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
536 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
|
537 localtime(¬e->cdate)); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
538 g_string_printf(sbuf, "Note created %s", tbuf); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
539 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag, 0); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
540 msg_flag = HBB_PREFIX_INFO | HBB_PREFIX_CONT; |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
541 } |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
542 // 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
|
543 // 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
|
544 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
|
545 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
|
546 localtime(¬e->mdate)); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
547 g_string_printf(sbuf, "Note modified %s", tbuf); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
548 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag, 0); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
549 msg_flag = HBB_PREFIX_INFO | HBB_PREFIX_CONT; |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
550 } |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
551 // Note text |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
552 g_string_printf(sbuf, "Note: %s", note->text); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
553 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag, 0); |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
554 |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
555 g_string_free(sbuf, TRUE); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
556 g_free(note->text); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
557 g_free(note->jid); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
558 g_free(note); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
559 } |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
560 |
1059 | 561 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
|
562 { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
563 GSList *notes; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
564 notes = jb_get_all_storage_rosternotes(); |
1163
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
565 |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
566 if (!notes) |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
567 return; |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
568 |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
569 // 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
|
570 // with winId = NULL (special window) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
571 g_slist_foreach(notes, (GFunc)&display_and_free_note, NULL); |
1163
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
572 scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
573 update_roster = TRUE; |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
574 g_slist_free(notes); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
575 } |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
576 |
1016 | 577 static void roster_note(char *arg) |
578 { | |
1058 | 579 const char *bjid; |
1016 | 580 guint type; |
581 | |
582 if (!current_buddy) | |
583 return; | |
584 | |
1058 | 585 bjid = buddy_getjid(BUDDATA(current_buddy)); |
1016 | 586 type = buddy_gettype(BUDDATA(current_buddy)); |
587 | |
1058 | 588 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
|
589 // 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
|
590 // Let's display all server notes |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
591 display_all_annotations(); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
592 return; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
593 } |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
594 |
1058 | 595 if (!bjid || (type != ROSTER_TYPE_USER && |
1016 | 596 type != ROSTER_TYPE_ROOM && |
597 type != ROSTER_TYPE_AGENT)) { | |
598 scr_LogPrint(LPRINT_NORMAL, "This item can't have a note."); | |
599 return; | |
600 } | |
601 | |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
602 if (arg && *arg) { // Set a note |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
603 gchar *msg, *notetxt; |
1016 | 604 msg = to_utf8(arg); |
605 if (!strcmp(msg, "-")) | |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
606 notetxt = NULL; // delete note |
1016 | 607 else |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
608 notetxt = msg; |
1058 | 609 jb_set_storage_rosternotes(bjid, notetxt); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
610 g_free(msg); |
1016 | 611 } else { // Display a note |
1058 | 612 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
|
613 if (note) { |
1058 | 614 display_and_free_note(note, bjid); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
615 } else { |
1058 | 616 scr_WriteIncomingMessage(bjid, "This item doesn't have a note.", 0, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
617 HBB_PREFIX_INFO, 0); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
618 } |
1016 | 619 } |
620 } | |
621 | |
104 | 622 /* Commands callback functions */ |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
623 /* 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
|
624 /* (with arg not null) */ |
104 | 625 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
626 static void do_roster(char *arg) |
104 | 627 { |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
628 char **paramlst; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
629 char *subcmd; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
630 |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
631 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
632 subcmd = *paramlst; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
633 arg = *(paramlst+1); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
634 |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
635 if (!subcmd || !*subcmd) { |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
636 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
637 free_arg_lst(paramlst); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
638 return; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
639 } |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
640 |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
641 if (!strcasecmp(subcmd, "top")) { |
104 | 642 scr_RosterTop(); |
128 | 643 update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
644 } else if (!strcasecmp(subcmd, "bottom")) { |
104 | 645 scr_RosterBottom(); |
128 | 646 update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
647 } else if (!strcasecmp(subcmd, "hide")) { |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
648 scr_RosterVisibility(0); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
649 } else if (!strcasecmp(subcmd, "show")) { |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
650 scr_RosterVisibility(1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
651 } else if (!strcasecmp(subcmd, "toggle")) { |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
652 scr_RosterVisibility(-1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
653 } else if (!strcasecmp(subcmd, "hide_offline")) { |
120 | 654 buddylist_set_hide_offline_buddies(TRUE); |
104 | 655 if (current_buddy) |
656 buddylist_build(); | |
128 | 657 update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
658 } else if (!strcasecmp(subcmd, "show_offline")) { |
120 | 659 buddylist_set_hide_offline_buddies(FALSE); |
124 | 660 buddylist_build(); |
128 | 661 update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
662 } else if (!strcasecmp(subcmd, "toggle_offline")) { |
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
663 buddylist_set_hide_offline_buddies(-1); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
664 buddylist_build(); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
665 update_roster = TRUE; |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1305
diff
changeset
|
666 } else if (!strcasecmp(subcmd, "display")) { |
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1305
diff
changeset
|
667 scr_RosterDisplay(arg); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
668 } else if (!strcasecmp(subcmd, "item_lock")) { |
1350
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
669 roster_buddylock(arg, 1); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
670 } else if (!strcasecmp(subcmd, "item_unlock")) { |
1350
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
671 roster_buddylock(arg, 0); |
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
672 } else if (!strcasecmp(subcmd, "item_toggle_lock")) { |
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
673 roster_buddylock(arg, -1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
674 } else if (!strcasecmp(subcmd, "unread_first")) { |
236 | 675 scr_RosterUnreadMessage(0); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
676 } else if (!strcasecmp(subcmd, "unread_next")) { |
236 | 677 scr_RosterUnreadMessage(1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
678 } else if (!strcasecmp(subcmd, "alternate")) { |
330 | 679 scr_RosterJumpAlternate(); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
680 } else if (!strncasecmp(subcmd, "search", 6)) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
681 strip_arg_special_chars(arg); |
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
682 if (!arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
683 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
|
684 free_arg_lst(paramlst); |
265 | 685 return; |
686 } | |
978 | 687 scr_RosterSearch(arg); |
265 | 688 update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
689 } else if (!strcasecmp(subcmd, "up")) { |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
690 scr_RosterUp(); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
691 } else if (!strcasecmp(subcmd, "down")) { |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
692 scr_RosterDown(); |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1074
diff
changeset
|
693 } 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
|
694 scr_RosterPrevGroup(); |
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1074
diff
changeset
|
695 } 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
|
696 scr_RosterNextGroup(); |
1016 | 697 } else if (!strcasecmp(subcmd, "note")) { |
698 roster_note(arg); | |
104 | 699 } else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
700 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
701 free_arg_lst(paramlst); |
104 | 702 } |
108 | 703 |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
704 void do_color(char *arg) |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
705 { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
706 char **paramlst; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
707 char *subcmd; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
708 |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
709 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
710 subcmd = *paramlst; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
711 arg = *(paramlst+1); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
712 |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
713 if (!subcmd || !*subcmd) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
714 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
715 free_arg_lst(paramlst); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
716 return; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
717 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
718 |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
719 if (!strcasecmp(subcmd, "roster")) { |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
720 char *status, *wildcard, *color; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
721 char **arglist = split_arg(arg, 3, 0); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
722 |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
723 status = *arglist; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
724 wildcard = to_utf8(arglist[1]); |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
725 color = arglist[2]; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
726 |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
727 if (status && !strcmp(status, "clear")) { // Not a color command, clear all |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
728 scr_RosterClearColor(); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
729 update_roster = TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
730 } else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
731 if (!status || !*status || !wildcard || !*wildcard || !color || !*color) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
732 scr_LogPrint(LPRINT_NORMAL, "Missing argument"); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
733 } else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
734 update_roster = scr_RosterColor(status, wildcard, color) |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
735 || update_roster; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
736 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
737 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
738 free_arg_lst(arglist); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
739 g_free(wildcard); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
740 } else if (!strcasecmp(subcmd, "muc")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
741 char **arglist = split_arg(arg, 2, 0); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
742 char *free_muc = to_utf8(*arglist); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
743 const char *muc = free_muc, *mode = arglist[1]; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
744 if (!muc || !*muc) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
745 scr_LogPrint(LPRINT_NORMAL, "What MUC?"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
746 else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
747 if (!strcmp(muc, ".")) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
748 if (!(muc = CURRENT_JID)) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
749 scr_LogPrint(LPRINT_NORMAL, "No JID selected"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
750 if (muc) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
751 if (check_jid_syntax(muc) && strcmp(muc, "*")) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
752 scr_LogPrint(LPRINT_NORMAL, "Not a JID"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
753 else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
754 if (!mode || !*mode || !strcasecmp(mode, "on")) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
755 scr_MucColor(muc, MC_ALL); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
756 else if (!strcasecmp(mode, "preset")) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
757 scr_MucColor(muc, MC_PRESET); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
758 else if (!strcasecmp(mode, "off")) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
759 scr_MucColor(muc, MC_OFF); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
760 else if (!strcmp(mode, "-")) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
761 scr_MucColor(muc, MC_REMOVE); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
762 else |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
763 scr_LogPrint(LPRINT_NORMAL, "Unknown coloring mode"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
764 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
765 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
766 } |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
767 free_arg_lst(arglist); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
768 g_free(free_muc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
769 } else if (!strcasecmp(subcmd, "mucnick")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
770 char **arglist = split_arg(arg, 2, 0); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
771 const char *nick = *arglist, *color = arglist[1]; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
772 if (!nick || !*nick || !color || !*color) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
773 scr_LogPrint(LPRINT_NORMAL, "Missing argument"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
774 else |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
775 scr_MucNickColor(nick, color); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
776 free_arg_lst(arglist); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
777 } else |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
778 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
779 free_arg_lst(paramlst); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
780 } |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
781 |
444 | 782 // setstatus(recipient, arg) |
783 // Set your Jabber status. | |
784 // - if recipient is not NULL, the status is sent to this contact only | |
785 // - arg must be "status message" (message is optional) | |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1138
diff
changeset
|
786 void setstatus(const char *recipient, const char *arg) |
116 | 787 { |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
788 char **paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
789 char *status; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
790 char *msg; |
116 | 791 enum imstatus st; |
792 | |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
793 if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
794 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
|
795 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
796 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
797 |
1368
23afeb5c555b
Don't strip quotes from a status message (Suggested by bb)
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
798 paramlst = split_arg(arg, 2, 1); // status, message |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
799 status = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
800 msg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
801 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
802 if (!status) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
803 free_arg_lst(paramlst); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
804 return; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
805 } |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
806 |
967 | 807 if (!strcasecmp(status, IMSTATUS_OFFLINE)) st = offline; |
808 else if (!strcasecmp(status, IMSTATUS_ONLINE)) st = available; | |
809 else if (!strcasecmp(status, IMSTATUS_AVAILABLE)) st = available; | |
810 else if (!strcasecmp(status, IMSTATUS_AWAY)) st = away; | |
811 else if (!strcasecmp(status, IMSTATUS_INVISIBLE)) st = invisible; | |
812 else if (!strcasecmp(status, IMSTATUS_DONOTDISTURB)) st = dontdisturb; | |
813 else if (!strcasecmp(status, IMSTATUS_NOTAVAILABLE)) st = notavail; | |
814 else if (!strcasecmp(status, IMSTATUS_FREE4CHAT)) st = freeforchat; | |
116 | 815 else { |
444 | 816 scr_LogPrint(LPRINT_NORMAL, "Unrecognized status!"); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
817 free_arg_lst(paramlst); |
116 | 818 return; |
819 } | |
820 | |
677
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
821 // Use provided message |
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
822 if (msg && !*msg) { |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
823 msg = NULL; |
677
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
824 } |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
825 |
528
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
826 // 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
|
827 if (recipient && !msg) |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
828 msg = ""; |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
829 |
1050
ea71d31a2607
PGP: Do not sign presence messages to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
1043
diff
changeset
|
830 jb_setstatus(st, recipient, msg, FALSE); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
831 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
832 free_arg_lst(paramlst); |
444 | 833 } |
834 | |
835 static void do_status(char *arg) | |
836 { | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
837 if (!*arg) { |
519
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
838 const char *sm = jb_getstatusmsg(); |
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
839 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
|
840 imstatus2char[jb_getstatus()], |
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
841 (sm ? sm : "")); |
444 | 842 return; |
843 } | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
844 arg = to_utf8(arg); |
444 | 845 setstatus(NULL, arg); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
846 g_free(arg); |
444 | 847 } |
848 | |
849 static void do_status_to(char *arg) | |
850 { | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
851 char **paramlst; |
1058 | 852 char *fjid, *st, *msg; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
853 char *jid_utf8 = NULL; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
854 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
855 paramlst = split_arg(arg, 3, 1); // jid, status, [message] |
1058 | 856 fjid = *paramlst; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
857 st = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
858 msg = *(paramlst+2); |
444 | 859 |
1058 | 860 if (!fjid || !st) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
861 scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
862 "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
|
863 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
|
864 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
|
865 } |
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
|
866 |
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
|
867 // Allow things like /status_to "" away |
1058 | 868 if (!*fjid || !strcmp(fjid, ".")) |
869 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
|
870 |
1058 | 871 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
|
872 // The JID has been specified. Quick check... |
1058 | 873 if (check_jid_syntax(fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
874 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
875 "<%s> is not a valid Jabber ID.", fjid); |
1058 | 876 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
|
877 } else { |
696
ee06382dfb22
/status_to: Do not convert resource name to lower case
Mikael Berthe <mikael@lilotux.net>
parents:
694
diff
changeset
|
878 // Convert jid to lowercase |
1058 | 879 char *p = fjid; |
977
5b01de4ac5e1
Cosmetic changes
Alexis Hildebrandt <afh [at] 2drop [dot] net>
parents:
974
diff
changeset
|
880 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
|
881 *p = tolower(*p); |
1058 | 882 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
|
883 } |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
884 } 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
|
885 // 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
|
886 if (current_buddy) |
1058 | 887 fjid = (char*)buddy_getjid(BUDDATA(current_buddy)); |
888 if (!fjid) | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
889 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
|
890 } |
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
|
891 |
1058 | 892 if (fjid) { |
893 char *cmdline; | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
894 if (!msg) |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
895 msg = ""; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
896 msg = to_utf8(msg); |
1058 | 897 cmdline = g_strdup_printf("%s %s", st, msg); |
898 scr_LogPrint(LPRINT_LOGNORM, "Sending to <%s> /status %s", fjid, cmdline); | |
899 setstatus(fjid, cmdline); | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
900 g_free(msg); |
1058 | 901 g_free(cmdline); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
902 g_free(jid_utf8); |
444 | 903 } |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
904 free_arg_lst(paramlst); |
116 | 905 } |
906 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
907 static void do_add(char *arg) |
124 | 908 { |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
909 char **paramlst; |
244 | 910 char *id, *nick; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
911 char *jid_utf8 = NULL; |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
912 |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
913 if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
914 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
|
915 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
916 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
917 |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
918 paramlst = split_arg(arg, 2, 0); // jid, [nickname] |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
919 id = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
920 nick = *(paramlst+1); |
244 | 921 |
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
|
922 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
|
923 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
|
924 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
|
925 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
|
926 |
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
|
927 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
|
928 // 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
|
929 if (check_jid_syntax(id)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
930 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
931 "<%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
|
932 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
|
933 } 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
|
934 mc_strtolower(id); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
935 // 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
|
936 // be used. |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
937 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
|
938 } |
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
|
939 } 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
|
940 // 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
|
941 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
|
942 id = (char*)buddy_getjid(BUDDATA(current_buddy)); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
943 if (!id) |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
944 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
|
945 } |
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
|
946 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
947 if (nick) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
948 nick = to_utf8(nick); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
949 |
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
|
950 if (id) { |
452 | 951 // 2nd parameter = optional nickname |
952 jb_addbuddy(id, nick, NULL); | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
953 scr_LogPrint(LPRINT_LOGNORM, "Sent presence notification request to <%s>.", |
452 | 954 id); |
955 } | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
956 |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
957 g_free(jid_utf8); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
958 g_free(nick); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
959 free_arg_lst(paramlst); |
124 | 960 } |
128 | 961 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
962 static void do_del(char *arg) |
206 | 963 { |
1058 | 964 const char *bjid; |
206 | 965 |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
966 if (*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
967 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
|
968 "the currently-selected buddy will be deleted."); |
206 | 969 return; |
970 } | |
971 | |
1058 | 972 if (!current_buddy) |
973 return; | |
974 bjid = buddy_getjid(BUDDATA(current_buddy)); | |
975 if (!bjid) | |
976 return; | |
206 | 977 |
540
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
978 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
|
979 // This is a chatroom |
652
b243d3b3ff1b
We do not need buddy_isresource() anymore
Mikael Berthe <mikael@lilotux.net>
parents:
650
diff
changeset
|
980 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
|
981 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
|
982 return; |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
983 } |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
984 } |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
985 |
1165
d5b26a0a9771
Close a buffer when using /del
Mikael Berthe <mikael@lilotux.net>
parents:
1163
diff
changeset
|
986 // Close the buffer |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
987 scr_BufferPurge(1, NULL); |
1165
d5b26a0a9771
Close a buffer when using /del
Mikael Berthe <mikael@lilotux.net>
parents:
1163
diff
changeset
|
988 |
1058 | 989 scr_LogPrint(LPRINT_LOGNORM, "Removing <%s>...", bjid); |
990 jb_delbuddy(bjid); | |
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
861
diff
changeset
|
991 scr_UpdateBuddyWindow(); |
206 | 992 } |
993 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
994 static void do_group(char *arg) |
128 | 995 { |
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
996 gpointer group = NULL; |
958
30b799632653
Cosmetics (change a variable name)
Mikael Berthe <mikael@lilotux.net>
parents:
957
diff
changeset
|
997 guint leave_buddywindow; |
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
998 char **paramlst; |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
999 char *subcmd; |
1360 | 1000 enum { group_unfold = 0, group_fold, group_toggle } group_state = 0; |
128 | 1001 |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1002 if (!*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1003 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
128 | 1004 return; |
1005 } | |
1006 | |
1058 | 1007 if (!current_buddy) |
1008 return; | |
128 | 1009 |
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1010 paramlst = split_arg(arg, 2, 1); // subcmd, [arg] |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1011 subcmd = *paramlst; |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1012 arg = *(paramlst+1); |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1013 |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1014 if (!subcmd || !*subcmd) |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1015 goto do_group_return; // Should not happen anyway |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1016 |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1017 if (arg && *arg) { |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1018 GSList *roster_elt; |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1019 roster_elt = roster_find(arg, namesearch, ROSTER_TYPE_GROUP); |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1020 if (roster_elt) |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1021 group = buddy_getgroup(roster_elt->data); |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1022 } else { |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1023 group = buddy_getgroup(BUDDATA(current_buddy)); |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1024 } |
1058 | 1025 if (!group) |
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1026 goto do_group_return; |
853
bdd526ec62bc
Fix segfault when using /group with the [status] entry
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1027 |
212 | 1028 // We'll have to redraw the chat window if we're not currently on the group |
1029 // entry itself, because it means we'll have to leave the current buddy | |
1030 // chat window. | |
1360 | 1031 leave_buddywindow = (group != BUDDATA(current_buddy) && |
1032 group == buddy_getgroup(BUDDATA(current_buddy))); | |
1033 | |
166 | 1034 |
128 | 1035 if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1036 scr_LogPrint(LPRINT_NORMAL, "You need to select a group."); |
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1037 goto do_group_return; |
128 | 1038 } |
166 | 1039 |
1360 | 1040 if (!strcasecmp(subcmd, "expand") || !strcasecmp(subcmd, "unfold")) |
1041 group_state = group_unfold; | |
1042 else if (!strcasecmp(subcmd, "shrink") || !strcasecmp(subcmd, "fold")) | |
1043 group_state = group_fold; | |
1044 else if (!strcasecmp(subcmd, "toggle")) | |
1045 group_state = group_toggle; | |
1046 else { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1047 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1048 goto do_group_return; |
128 | 1049 } |
1050 | |
1360 | 1051 if (group_state != group_unfold && leave_buddywindow) |
1052 scr_RosterPrevGroup(); | |
1053 | |
1054 if (group_state == group_unfold) | |
1055 buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE); | |
1056 else if (group_state == group_fold) | |
1057 buddy_setflags(group, ROSTER_FLAG_HIDE, TRUE); | |
1058 else if (group_state == group_toggle) | |
1059 buddy_setflags(group, ROSTER_FLAG_HIDE, | |
1060 !(buddy_getflags(group) & ROSTER_FLAG_HIDE)); | |
1061 | |
128 | 1062 buddylist_build(); |
1063 update_roster = TRUE; | |
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1064 |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1065 do_group_return: |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1066 free_arg_lst(paramlst); |
128 | 1067 } |
1068 | |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1069 static int send_message_to(const char *fjid, const char *msg, const char *subj, |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1070 const char *type_overwrite) |
636 | 1071 { |
1072 char *bare_jid, *rp; | |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1073 char *hmsg; |
1197 | 1074 gint crypted; |
1075 gint retval = 0; | |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1076 int isroom; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1077 |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1078 if (!jb_getonline()) { |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1079 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1080 return 1; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1081 } |
1058 | 1082 if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1083 scr_LogPrint(LPRINT_NORMAL, "You must specify a Jabber ID."); |
636 | 1084 return 1; |
1085 } | |
1086 if (!msg || !*msg) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1087 scr_LogPrint(LPRINT_NORMAL, "You must specify a message."); |
636 | 1088 return 1; |
1089 } | |
1058 | 1090 if (check_jid_syntax((char*)fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1091 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1092 "<%s> is not a valid Jabber ID.", fjid); |
636 | 1093 return 1; |
1094 } | |
1095 | |
1096 // We must use the bare jid in hk_message_out() | |
1058 | 1097 rp = strchr(fjid, JID_RESOURCE_SEPARATOR); |
1098 if (rp) bare_jid = g_strndup(fjid, rp - fjid); | |
1099 else bare_jid = (char*)fjid; | |
636 | 1100 |
1101 // Jump to window, create one if needed | |
1102 scr_RosterJumpJid(bare_jid); | |
1103 | |
1104 // Check if we're sending a message to a conference room | |
1105 // If not, we must make sure rp is NULL, for hk_message_out() | |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1106 isroom = !!roster_find(bare_jid, jidsearch, ROSTER_TYPE_ROOM); |
636 | 1107 if (rp) { |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1108 if (isroom) rp++; |
636 | 1109 else rp = NULL; |
1110 } | |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1111 isroom = isroom && (!rp || !*rp); |
636 | 1112 |
1113 // local part (UI, logging, etc.) | |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1114 if (subj) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1115 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
|
1116 else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1117 hmsg = (char*)msg; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1118 |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
1119 // Network part |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1120 jb_send_msg(fjid, msg, (isroom ? ROSTER_TYPE_ROOM : ROSTER_TYPE_USER), |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1121 subj, NULL, &crypted, |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1122 type_overwrite); |
636 | 1123 |
1197 | 1124 if (crypted == -1) { |
1125 scr_LogPrint(LPRINT_LOGNORM, "Encryption error. Message was not sent."); | |
1126 retval = 1; | |
1127 goto send_message_to_return; | |
1128 } | |
1129 | |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
1130 // Hook |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
1131 if (!isroom) |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1132 hk_message_out(bare_jid, rp, 0, hmsg, crypted); |
1197 | 1133 |
1134 send_message_to_return: | |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
1135 if (hmsg != msg) g_free(hmsg); |
636 | 1136 if (rp) g_free(bare_jid); |
1197 | 1137 return retval; |
636 | 1138 } |
1139 | |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1140 // send_message(msg, subj, type_overwrite) |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1141 // Write the message in the buddy's window and send the message on |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1142 // the network. |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1143 static void send_message(const char *msg, const char *subj, |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1144 const char *type_overwrite) |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1145 { |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1146 const char *bjid; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1147 |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1148 if (!current_buddy) { |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1149 scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected."); |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1150 return; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1151 } |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1152 |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1153 bjid = CURRENT_JID; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1154 if (!bjid) { |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1155 scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected."); |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1156 return; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1157 } |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1158 |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1159 send_message_to(bjid, msg, subj, type_overwrite); |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1160 } |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1161 |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1162 static const char *scan_mtype(char **arg) |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1163 { |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1164 //Try splitting it |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1165 char **parlist = split_arg(*arg, 2, 1); |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1166 const char *result = NULL; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1167 //Is it any good parameter? |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
1168 if (parlist && *parlist) { |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
1169 if (!strcmp("-n", *parlist)) { |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1170 result = TMSG_NORMAL; |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
1171 } else if (!strcmp("-h", *parlist)) { |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1172 result = TMSG_HEADLINE; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1173 } |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
1174 if (result || (!strcmp("--", *parlist))) |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1175 *arg += strlen(*arg) - (parlist[1] ? strlen(parlist[1]) : 0); |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1176 } |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1177 //Anything found? -> skip it |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1178 free_arg_lst(parlist); |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1179 return result; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1180 } |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1181 |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1182 static void do_say_internal(char *arg, int parse_flags) |
132 | 1183 { |
164 | 1184 gpointer bud; |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1185 const char *msgtype = NULL; |
132 | 1186 |
1187 scr_set_chatmode(TRUE); | |
1130
b2040a7fb7fc
Refresh chat buffer when sending a message in non-chatmode
Mikael Berthe <mikael@lilotux.net>
parents:
1126
diff
changeset
|
1188 scr_ShowBuddyWindow(); |
164 | 1189 |
1190 if (!current_buddy) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1191 scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1192 "Whom are you talking to? Please select a buddy."); |
164 | 1193 return; |
132 | 1194 } |
164 | 1195 |
1196 bud = BUDDATA(current_buddy); | |
631
423c24e5875a
Allow sending a message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
626
diff
changeset
|
1197 if (!(buddy_gettype(bud) & |
423c24e5875a
Allow sending a message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
626
diff
changeset
|
1198 (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
|
1199 scr_LogPrint(LPRINT_NORMAL, "This is not a user."); |
164 | 1200 return; |
1201 } | |
1202 | |
1203 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); | |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
1204 if (parse_flags) |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1205 msgtype = scan_mtype(&arg); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1206 arg = to_utf8(arg); |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1207 send_message(arg, NULL, msgtype); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1208 g_free(arg); |
132 | 1209 } |
1210 | |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1211 static void do_say(char *arg) { |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1212 do_say_internal(arg, 1); |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1213 } |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1214 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1215 static void do_msay(char *arg) |
238 | 1216 { |
636 | 1217 /* Parameters: begin verbatim abort send send_to */ |
1218 char **paramlst; | |
1219 char *subcmd; | |
1220 | |
1221 paramlst = split_arg(arg, 2, 1); // subcmd, arg | |
1222 subcmd = *paramlst; | |
1223 arg = *(paramlst+1); | |
238 | 1224 |
636 | 1225 if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1226 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
636 | 1227 scr_LogPrint(LPRINT_NORMAL, "Please read the manual before using " |
1228 "the /msay command."); | |
967 | 1229 scr_LogPrint(LPRINT_NORMAL, "(Use \"%s begin\" to enter " |
1230 "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
|
1231 goto do_msay_return; |
636 | 1232 } |
1233 | |
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1234 if (!strcasecmp(subcmd, "toggle")) { |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1235 if (scr_get_multimode()) |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1236 subcmd = "send"; |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1237 else |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1238 subcmd = "begin"; |
838
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1239 } else if (!strcasecmp(subcmd, "toggle_verbatim")) { |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1240 if (scr_get_multimode()) |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1241 subcmd = "send"; |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1242 else |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1243 subcmd = "verbatim"; |
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1244 } |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1245 |
636 | 1246 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
|
1247 if (scr_get_multimode()) |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1248 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
|
1249 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
|
1250 goto do_msay_return; |
636 | 1251 } else if ((!strcasecmp(subcmd, "begin")) || |
1252 (!strcasecmp(subcmd, "verbatim"))) { | |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1253 bool verbat; |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1254 gchar *subj_utf8 = to_utf8(arg); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1255 if (!strcasecmp(subcmd, "verbatim")) { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1256 scr_set_multimode(2, subj_utf8); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1257 verbat = TRUE; |
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1258 } else { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1259 scr_set_multimode(1, subj_utf8); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1260 verbat = FALSE; |
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1261 } |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
1262 |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1263 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
|
1264 verbat ? "VERBATIM " : ""); |
967 | 1265 scr_LogPrint(LPRINT_NORMAL, "Select a buddy and use \"%s send\" " |
1266 "when your message is ready.", mkcmdstr("msay")); | |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1267 if (verbat) |
967 | 1268 scr_LogPrint(LPRINT_NORMAL, "Use \"%s abort\" to abort this mode.", |
1269 mkcmdstr("msay")); | |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1270 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
|
1271 goto do_msay_return; |
636 | 1272 } else if (strcasecmp(subcmd, "send") && strcasecmp(subcmd, "send_to")) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1273 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
|
1274 goto do_msay_return; |
238 | 1275 } |
1276 | |
636 | 1277 /* send/send_to command */ |
238 | 1278 |
1279 if (!scr_get_multimode()) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1280 scr_LogPrint(LPRINT_NORMAL, "No message to send. " |
967 | 1281 "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
|
1282 goto do_msay_return; |
238 | 1283 } |
1284 | |
1285 scr_set_chatmode(TRUE); | |
1130
b2040a7fb7fc
Refresh chat buffer when sending a message in non-chatmode
Mikael Berthe <mikael@lilotux.net>
parents:
1126
diff
changeset
|
1286 scr_ShowBuddyWindow(); |
238 | 1287 |
636 | 1288 if (!strcasecmp(subcmd, "send_to")) { |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1289 int err = FALSE; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1290 gchar *msg_utf8; |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1291 const char *msg_type = scan_mtype(&arg); |
636 | 1292 // Let's send to the specified JID. We leave now if there |
1293 // 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
|
1294 arg = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1295 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
|
1296 if (msg_utf8) { |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1297 err = send_message_to(arg, msg_utf8, scr_get_multimode_subj(), msg_type); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1298 g_free(msg_utf8); |
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1299 } |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1300 g_free(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1301 if (err) |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1302 goto do_msay_return; |
636 | 1303 } else { // Send to currently selected buddy |
1304 gpointer bud; | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1305 gchar *msg_utf8; |
238 | 1306 |
636 | 1307 if (!current_buddy) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1308 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
|
1309 goto do_msay_return; |
636 | 1310 } |
1311 | |
1312 bud = BUDDATA(current_buddy); | |
1181
807815928754
Allow sending a multi-line message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
1177
diff
changeset
|
1313 if (!(buddy_gettype(bud) & |
807815928754
Allow sending a multi-line message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
1177
diff
changeset
|
1314 (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
|
1315 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
|
1316 goto do_msay_return; |
636 | 1317 } |
1318 | |
1319 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
|
1320 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
|
1321 if (msg_utf8) { |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1322 send_message(msg_utf8, scr_get_multimode_subj(), scan_mtype(&arg)); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1323 g_free(msg_utf8); |
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1324 } |
238 | 1325 } |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1326 scr_set_multimode(FALSE, NULL); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1327 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
|
1328 do_msay_return: |
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1329 free_arg_lst(paramlst); |
238 | 1330 } |
1331 | |
480 | 1332 static void do_say_to(char *arg) |
1333 { | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1334 char **paramlst; |
1058 | 1335 char *fjid, *msg; |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1336 const char *msg_type = NULL; |
480 | 1337 |
1338 if (!jb_getonline()) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1339 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
480 | 1340 return; |
1341 } | |
1342 | |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1343 msg_type = scan_mtype(&arg); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1344 paramlst = split_arg(arg, 2, 1); // jid, message |
1058 | 1345 fjid = *paramlst; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1346 msg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1347 |
1058 | 1348 if (!fjid || !strcmp(fjid, ".")) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1349 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
|
1350 free_arg_lst(paramlst); |
480 | 1351 return; |
1352 } | |
1353 | |
1058 | 1354 fjid = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1355 msg = to_utf8(msg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1356 |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1357 send_message_to(fjid, msg, NULL, msg_type); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1358 |
1058 | 1359 g_free(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1360 g_free(msg); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1361 free_arg_lst(paramlst); |
480 | 1362 } |
1363 | |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1364 // buffer_updown(updown, nblines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1365 // updown: -1=up, +1=down |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1366 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
|
1367 { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1368 int nblines; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1369 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1370 if (!nlines || !*nlines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1371 nblines = 0; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1372 else |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1373 nblines = atoi(nlines); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1374 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1375 if (nblines >= 0) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1376 scr_BufferScrollUpDown(updown, nblines); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1377 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1378 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1379 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
|
1380 { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1381 if (!arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1382 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1383 return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1384 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1385 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1386 scr_BufferSearch(direction, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1387 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1388 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1389 static void buffer_date(char *date) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1390 { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1391 time_t t; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1392 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1393 if (!date || !*date) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1394 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1395 return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1396 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1397 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1398 strip_arg_special_chars(date); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1399 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1400 t = from_iso8601(date, 0); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1401 if (t) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1402 scr_BufferDate(t); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1403 else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1404 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
|
1405 "not correctly formatted or invalid."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1406 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1407 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1408 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
|
1409 { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1410 // Basically, user has typed "%arg1 arg2" |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1411 // "%50" -> arg1 = 50, arg2 null pointer |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1412 // "% 50" -> arg1 = \0, arg2 = 50 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1413 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1414 if (!*arg1 && (!arg2 || !*arg2)) { // No value |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1415 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1416 return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1417 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1418 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1419 if (*arg1 && arg2 && *arg2) { // Two values |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1420 scr_LogPrint(LPRINT_NORMAL, "Wrong parameters."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1421 return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1422 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1423 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1424 scr_BufferPercent(atoi((*arg1 ? arg1 : arg2))); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1425 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1426 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1427 static void do_buffer(char *arg) |
187 | 1428 { |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1429 char **paramlst; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1430 char *subcmd; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1431 |
1058 | 1432 if (!current_buddy) |
1433 return; | |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1434 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1435 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
|
1436 subcmd = *paramlst; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1437 arg = *(paramlst+1); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1438 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1439 if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1440 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1441 free_arg_lst(paramlst); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1442 return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1443 } |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1444 |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1445 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP && |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1446 strcasecmp(subcmd, "close_all")) { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1447 scr_LogPrint(LPRINT_NORMAL, "Groups have no buffer."); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1448 free_arg_lst(paramlst); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1449 return; |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1450 } |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1451 |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1452 if (!strcasecmp(subcmd, "top")) { |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
336
diff
changeset
|
1453 scr_BufferTopBottom(-1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1454 } else if (!strcasecmp(subcmd, "bottom")) { |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
336
diff
changeset
|
1455 scr_BufferTopBottom(1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1456 } else if (!strcasecmp(subcmd, "clear")) { |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
1457 scr_BufferClear(); |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1130
diff
changeset
|
1458 } else if (!strcasecmp(subcmd, "close")) { |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
1459 scr_BufferPurge(1, arg); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1460 } else if (!strcasecmp(subcmd, "close_all")) { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1461 scr_BufferPurgeAll(1); |
866 | 1462 } else if (!strcasecmp(subcmd, "purge")) { |
1279
8bbc764139ef
Implement /buffer close|purge [jid]
Mikael Berthe <mikael@lilotux.net>
parents:
1272
diff
changeset
|
1463 scr_BufferPurge(0, arg); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1464 } else if (!strcasecmp(subcmd, "scroll_lock")) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1465 scr_BufferScrollLock(1); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1466 } else if (!strcasecmp(subcmd, "scroll_unlock")) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1467 scr_BufferScrollLock(0); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1468 } else if (!strcasecmp(subcmd, "scroll_toggle")) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1469 scr_BufferScrollLock(-1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1470 } else if (!strcasecmp(subcmd, "up")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1471 buffer_updown(-1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1472 } else if (!strcasecmp(subcmd, "down")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1473 buffer_updown(1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1474 } else if (!strcasecmp(subcmd, "search_backward")) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
1475 strip_arg_special_chars(arg); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1476 buffer_search(-1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1477 } else if (!strcasecmp(subcmd, "search_forward")) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
1478 strip_arg_special_chars(arg); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1479 buffer_search(1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1480 } else if (!strcasecmp(subcmd, "date")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1481 buffer_date(arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1482 } else if (*subcmd == '%') { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1483 buffer_percent(subcmd+1, arg); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1221
diff
changeset
|
1484 #ifdef DEBUG_ENABLE |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1221
diff
changeset
|
1485 } else if (!strcasecmp(subcmd, "list")) { |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1221
diff
changeset
|
1486 scr_BufferList(); |
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1221
diff
changeset
|
1487 #endif |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1488 } else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1489 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1490 } |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1491 |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1492 free_arg_lst(paramlst); |
187 | 1493 } |
1494 | |
967 | 1495 static void do_clear(char *arg) // Alias for "buffer clear" |
187 | 1496 { |
1497 do_buffer("clear"); | |
1498 } | |
1499 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1500 static void do_info(char *arg) |
191 | 1501 { |
1502 gpointer bud; | |
1058 | 1503 const char *bjid, *name; |
1355 | 1504 guint type, on_srv; |
191 | 1505 char *buffer; |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1506 enum subscr esub; |
191 | 1507 |
1058 | 1508 if (!current_buddy) |
1509 return; | |
191 | 1510 bud = BUDDATA(current_buddy); |
1511 | |
1058 | 1512 bjid = buddy_getjid(bud); |
191 | 1513 name = buddy_getname(bud); |
1514 type = buddy_gettype(bud); | |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1515 esub = buddy_getsubscription(bud); |
1355 | 1516 on_srv = buddy_getonserverflag(bud); |
191 | 1517 |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1518 buffer = g_new(char, 4096); |
191 | 1519 |
1058 | 1520 if (bjid) { |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1521 GSList *resources, *p_res; |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1522 char *bstr = "unknown"; |
191 | 1523 |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1524 // Enter chat mode |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1525 scr_set_chatmode(TRUE); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1526 scr_ShowBuddyWindow(); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1527 |
1058 | 1528 snprintf(buffer, 4095, "jid: <%s>", bjid); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1529 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
191 | 1530 if (name) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1531 snprintf(buffer, 4095, "Name: %s", name); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1532 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
191 | 1533 } |
1534 | |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1535 if (type == ROSTER_TYPE_USER) bstr = "user"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1536 else if (type == ROSTER_TYPE_ROOM) bstr = "chatroom"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1537 else if (type == ROSTER_TYPE_AGENT) bstr = "agent"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1538 snprintf(buffer, 127, "Type: %s", bstr); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1539 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1540 |
1355 | 1541 if (!on_srv) { |
1542 scr_WriteIncomingMessage(bjid, "(Local item, not on the server)", | |
1543 0, HBB_PREFIX_INFO, 0); | |
1544 } | |
1545 | |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1546 if (esub == sub_both) bstr = "both"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1547 else if (esub & sub_from) bstr = "from"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1548 else if (esub & sub_to) bstr = "to"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1549 else bstr = "none"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1550 snprintf(buffer, 64, "Subscription: %s", bstr); |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1551 if (esub & sub_pending) |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1552 strcat(buffer, " (pending)"); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1553 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1554 |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1555 resources = buddy_getresources(bud); |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1556 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
|
1557 // 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
|
1558 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
|
1559 if (rst_msg) { |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1560 snprintf(buffer, 4095, "Last status message: %s", rst_msg); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1561 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1562 } |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1563 } |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1564 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
|
1565 gchar rprio; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1566 enum imstatus rstatus; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1567 const char *rst_msg; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1568 time_t rst_time; |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1569 struct pgp_data *rpgp; |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1570 |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1571 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
|
1572 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
|
1573 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
|
1574 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
|
1575 rpgp = buddy_resource_pgp(bud, p_res->data); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1576 |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1577 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
|
1578 rprio, (char*)p_res->data); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1579 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1580 if (rst_msg) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1581 snprintf(buffer, 4095, "Status message: %s", rst_msg); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
1582 scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1583 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1584 } |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1585 if (rst_time) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1586 char tbuf[128]; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1587 |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1588 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
|
1589 snprintf(buffer, 127, "Status timestamp: %s", tbuf); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
1590 scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1591 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1592 } |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1593 #ifdef HAVE_GPGME |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1594 if (rpgp && rpgp->sign_keyid) { |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1595 snprintf(buffer, 4095, "PGP key id: %s", rpgp->sign_keyid); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
1596 scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1597 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1598 if (rpgp->last_sigsum) { |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1599 gpgme_sigsum_t ss = rpgp->last_sigsum; |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1600 snprintf(buffer, 4095, "Last PGP signature: %s", |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1601 (ss & GPGME_SIGSUM_GREEN ? "good": |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1602 (ss & GPGME_SIGSUM_RED ? "bad" : "unknown"))); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
1603 scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1604 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1605 } |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1606 } |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1607 #endif |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1608 g_free(p_res->data); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1609 } |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1610 g_slist_free(resources); |
1355 | 1611 } else { /* Item has no jid */ |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1612 if (name) scr_LogPrint(LPRINT_NORMAL, "Name: %s", name); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1613 scr_LogPrint(LPRINT_NORMAL, "Type: %s", |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1614 type == ROSTER_TYPE_GROUP ? "group" : |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1615 (type == ROSTER_TYPE_SPECIAL ? "special" : "unknown")); |
191 | 1616 } |
1617 g_free(buffer); | |
1618 | |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1619 // 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
|
1620 if (type == ROSTER_TYPE_USER || |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1621 type == ROSTER_TYPE_ROOM || |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1622 type == ROSTER_TYPE_AGENT) { |
1058 | 1623 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
|
1624 if (note) { |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1625 // 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
|
1626 g_free(note->text); |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
1627 g_free(note->jid); |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1628 g_free(note); |
1058 | 1629 scr_WriteIncomingMessage(bjid, "(This item has an annotation)", 0, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1630 HBB_PREFIX_INFO, 0); |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1631 } |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1632 } |
191 | 1633 } |
1634 | |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1635 // room_names() is a variation of do_info(), for chatrooms only |
552 | 1636 static void room_names(gpointer bud, char *arg) |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1637 { |
1058 | 1638 const char *bjid; |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1639 char *buffer; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1640 GSList *resources, *p_res; |
1341
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1641 enum { style_normal = 0, style_detail, style_short, style_quiet } style = 0; |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1642 |
552 | 1643 if (*arg) { |
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1644 if (!strcasecmp(arg, "--short")) |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1645 style = style_short; |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1646 else if (!strcasecmp(arg, "--quiet")) |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1647 style = style_quiet; |
1341
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1648 else if (!strcasecmp(arg, "--detail")) |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1649 style = style_detail; |
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1650 else { |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1651 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1652 return; |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1653 } |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1654 } |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1655 |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1656 // Enter chat mode |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1657 scr_set_chatmode(TRUE); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1658 scr_ShowBuddyWindow(); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1659 |
1058 | 1660 bjid = buddy_getjid(bud); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1661 |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1662 buffer = g_new(char, 4096); |
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1663 strncpy(buffer, "Room members:", 127); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1664 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1665 |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1666 resources = buddy_getresources(bud); |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1667 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
|
1668 enum imstatus rstatus; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1669 const char *rst_msg; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1670 |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1671 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
|
1672 rst_msg = buddy_getstatusmsg(bud, p_res->data); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1673 |
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1674 if (style == style_short) { |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1675 snprintf(buffer, 4095, "[%c] %s%s%s", imstatus2char[rstatus], |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1676 (char*)p_res->data, |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1677 rst_msg ? " -- " : "", rst_msg ? rst_msg : ""); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1678 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1679 } else { |
1341
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1680 // (Style "normal", "detail" or "quiet") |
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1681 snprintf(buffer, 4095, "[%c] %s", imstatus2char[rstatus], |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1682 (char*)p_res->data); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1683 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
1341
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1684 if (rst_msg && style != style_quiet) { |
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1685 snprintf(buffer, 4095, "Status message: %s", rst_msg); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
1686 scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1687 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1688 } |
1341
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1689 if (style == style_detail) { |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1690 enum imrole role = buddy_getrole(bud, p_res->data); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1691 enum imaffiliation affil = buddy_getaffil(bud, p_res->data); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1692 |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1693 snprintf(buffer, 4095, "Role: %s", strrole[role]); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1694 scr_WriteIncomingMessage(bjid, buffer, |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1695 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1696 if (affil != affil_none) { |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1697 snprintf(buffer, 4095, "Affiliat.: %s", straffil[affil]); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1698 scr_WriteIncomingMessage(bjid, buffer, |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1699 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1700 } |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
1701 } |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1702 } |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1703 g_free(p_res->data); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1704 } |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1705 g_slist_free(resources); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1706 g_free(buffer); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1707 } |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1708 |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1709 static void move_group_member(gpointer bud, void *groupnamedata) |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1710 { |
1058 | 1711 const char *bjid, *name, *groupname; |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1712 |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1713 groupname = (char *)groupnamedata; |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1714 |
1058 | 1715 bjid = buddy_getjid(bud); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1716 name = buddy_getname(bud); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1717 |
1058 | 1718 jb_updatebuddy(bjid, name, *groupname ? groupname : NULL); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1719 } |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1720 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1721 static void do_rename(char *arg) |
208 | 1722 { |
1723 gpointer bud; | |
1058 | 1724 const char *bjid, *group; |
1356
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
1725 guint type, on_srv; |
208 | 1726 char *newname, *p; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1727 char *name_utf8; |
208 | 1728 |
1058 | 1729 if (!current_buddy) |
1730 return; | |
208 | 1731 bud = BUDDATA(current_buddy); |
1732 | |
1356
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
1733 bjid = buddy_getjid(bud); |
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
1734 group = buddy_getgroupname(bud); |
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
1735 type = buddy_gettype(bud); |
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
1736 on_srv = buddy_getonserverflag(bud); |
208 | 1737 |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1738 if (type & ROSTER_TYPE_SPECIAL) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1739 scr_LogPrint(LPRINT_NORMAL, "You can't rename this item."); |
208 | 1740 return; |
1741 } | |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1742 |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1743 if (!*arg && !(type & ROSTER_TYPE_GROUP)) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1744 scr_LogPrint(LPRINT_NORMAL, "Please specify a new name."); |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1745 return; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1746 } |
208 | 1747 |
1356
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
1748 if (!(type & ROSTER_TYPE_GROUP) && !on_srv) { |
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
1749 scr_LogPrint(LPRINT_NORMAL, |
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
1750 "Note: this item will be added to your server roster."); |
1363
32077249de77
Warn if a MUC room without bookmark is renamed
Mikael Berthe <mikael@lilotux.net>
parents:
1362
diff
changeset
|
1751 // If this is a MUC room w/o bookmark, let's give a small hint... |
32077249de77
Warn if a MUC room without bookmark is renamed
Mikael Berthe <mikael@lilotux.net>
parents:
1362
diff
changeset
|
1752 if (!jb_is_bookmarked(bjid)) { |
32077249de77
Warn if a MUC room without bookmark is renamed
Mikael Berthe <mikael@lilotux.net>
parents:
1362
diff
changeset
|
1753 scr_LogPrint(LPRINT_NORMAL, |
32077249de77
Warn if a MUC room without bookmark is renamed
Mikael Berthe <mikael@lilotux.net>
parents:
1362
diff
changeset
|
1754 "You should add a room bookmark or it will not be " |
32077249de77
Warn if a MUC room without bookmark is renamed
Mikael Berthe <mikael@lilotux.net>
parents:
1362
diff
changeset
|
1755 "recognized as a MUC room next time you run mcabber."); |
32077249de77
Warn if a MUC room without bookmark is renamed
Mikael Berthe <mikael@lilotux.net>
parents:
1362
diff
changeset
|
1756 } |
1356
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
1757 } |
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
1758 |
208 | 1759 newname = g_strdup(arg); |
1760 // Remove trailing space | |
1761 for (p = newname; *p; p++) ; | |
1762 while (p > newname && *p == ' ') *p = 0; | |
1763 | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1764 strip_arg_special_chars(newname); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1765 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1766 name_utf8 = to_utf8(newname); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1767 |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1768 if (type & ROSTER_TYPE_GROUP) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1769 // Rename a whole group |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1770 foreach_group_member(bud, &move_group_member, name_utf8); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1771 // 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
|
1772 // disappear when we receive the server answer. |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1773 scr_RosterUp(); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1774 } else { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1775 // Rename a single buddy |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1776 buddy_setname(bud, name_utf8); |
1058 | 1777 jb_updatebuddy(bjid, name_utf8, group); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1778 } |
208 | 1779 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1780 g_free(name_utf8); |
208 | 1781 g_free(newname); |
1782 update_roster = TRUE; | |
1783 } | |
1784 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1785 static void do_move(char *arg) |
210 | 1786 { |
1787 gpointer bud; | |
1058 | 1788 const char *bjid, *name, *oldgroupname; |
210 | 1789 guint type; |
1790 char *newgroupname, *p; | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1791 char *group_utf8; |
210 | 1792 |
1058 | 1793 if (!current_buddy) |
1794 return; | |
210 | 1795 bud = BUDDATA(current_buddy); |
1796 | |
1058 | 1797 bjid = buddy_getjid(bud); |
210 | 1798 name = buddy_getname(bud); |
1799 type = buddy_gettype(bud); | |
1800 | |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1801 oldgroupname = buddy_getgroupname(bud); |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1802 |
210 | 1803 if (type & ROSTER_TYPE_GROUP) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1804 scr_LogPrint(LPRINT_NORMAL, "You can't move groups!"); |
210 | 1805 return; |
1806 } | |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1807 if (type & ROSTER_TYPE_SPECIAL) { |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1808 scr_LogPrint(LPRINT_NORMAL, "You can't move this item."); |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1809 return; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1810 } |
210 | 1811 |
1812 newgroupname = g_strdup(arg); | |
1813 // Remove trailing space | |
1814 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
|
1815 while (p > newgroupname && *p == ' ') *p-- = 0; |
210 | 1816 |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1817 strip_arg_special_chars(newgroupname); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1818 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1819 group_utf8 = to_utf8(newgroupname); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1820 if (strcmp(oldgroupname, group_utf8)) { |
1058 | 1821 jb_updatebuddy(bjid, name, *group_utf8 ? group_utf8 : NULL); |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1822 scr_RosterUp(); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1823 buddy_setgroup(bud, group_utf8); |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1824 } |
210 | 1825 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1826 g_free(group_utf8); |
210 | 1827 g_free(newgroupname); |
1828 update_roster = TRUE; | |
1829 } | |
1830 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1831 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
|
1832 { |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1833 guint assign; |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1834 gchar *option, *value; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1835 gchar *option_utf8; |
393 | 1836 |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1837 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
|
1838 if (!option) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1839 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
|
1840 return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1841 } |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1842 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
|
1843 g_free(option); |
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1844 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
|
1845 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
|
1846 if (val) |
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1847 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
|
1848 else |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1849 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
|
1850 g_free(option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1851 return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1852 } |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1853 // Update the option |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1854 // 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
|
1855 // 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
|
1856 // (hide_offline_buddies for ex.) |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1857 if (!value) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1858 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
|
1859 } else { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1860 gchar *value_utf8 = to_utf8(value); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1861 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
|
1862 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
|
1863 g_free(value); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1864 } |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1865 g_free(option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1866 } |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1867 |
1070
9eaacc0ad3a2
Use a hash for settings
Mikael Berthe <mikael@lilotux.net>
parents:
1066
diff
changeset
|
1868 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
|
1869 { |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1870 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
|
1871 } |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1872 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1873 static void do_alias(char *arg) |
285 | 1874 { |
1875 guint assign; | |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1876 gchar *alias, *value; |
393 | 1877 |
285 | 1878 assign = parse_assigment(arg, &alias, &value); |
1879 if (!alias) { | |
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1880 settings_foreach(SETTINGS_TYPE_ALIAS, &dump_alias, NULL); |
285 | 1881 return; |
1882 } | |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1883 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
|
1884 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
|
1885 // 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
|
1886 if (val) |
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1887 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
|
1888 else |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1889 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1890 "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
|
1891 goto do_alias_return; |
285 | 1892 } |
1893 // Check the alias does not conflict with a registered command | |
1894 if (cmd_get(alias)) { | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1895 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1896 "'%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
|
1897 goto do_alias_return; |
285 | 1898 } |
1899 // Update the alias | |
1900 if (!value) { | |
1901 if (settings_get(SETTINGS_TYPE_ALIAS, alias)) { | |
1902 settings_del(SETTINGS_TYPE_ALIAS, alias); | |
1903 // Remove alias from the completion list | |
1904 compl_del_category_word(COMPL_CMD, alias); | |
1905 } | |
1906 } else { | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1907 /* 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
|
1908 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
|
1909 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
|
1910 system) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1911 */ |
285 | 1912 if (!settings_get(SETTINGS_TYPE_ALIAS, alias)) |
1913 compl_add_category_word(COMPL_CMD, alias); | |
1914 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
|
1915 g_free(value); |
285 | 1916 } |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1917 do_alias_return: |
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1918 g_free(alias); |
285 | 1919 } |
1920 | |
1070
9eaacc0ad3a2
Use a hash for settings
Mikael Berthe <mikael@lilotux.net>
parents:
1066
diff
changeset
|
1921 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
|
1922 { |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1923 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
|
1924 } |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1925 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1926 static void do_bind(char *arg) |
288 | 1927 { |
1928 guint assign; | |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1929 gchar *k_code, *value; |
393 | 1930 |
1058 | 1931 assign = parse_assigment(arg, &k_code, &value); |
1932 if (!k_code) { | |
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1933 settings_foreach(SETTINGS_TYPE_BINDING, &dump_bind, NULL); |
288 | 1934 return; |
1935 } | |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1936 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
|
1937 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
|
1938 if (val) |
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1939 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
|
1940 else |
1058 | 1941 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
|
1942 g_free(k_code); |
288 | 1943 return; |
1944 } | |
1945 // Update the key binding | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1946 if (!value) { |
1058 | 1947 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
|
1948 } else { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1949 gchar *value_utf8 = to_utf8(value); |
1058 | 1950 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
|
1951 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
|
1952 g_free(value); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1953 } |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
1954 g_free(k_code); |
288 | 1955 } |
1956 | |
436 | 1957 static void do_rawxml(char *arg) |
1958 { | |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1959 char **paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1960 char *subcmd; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1961 |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1962 if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1963 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
|
1964 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1965 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1966 |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1967 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1968 subcmd = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1969 arg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1970 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1971 if (!subcmd || !*subcmd) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1972 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
|
1973 " before using /rawxml :-)"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1974 free_arg_lst(paramlst); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1975 return; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1976 } |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1977 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1978 if (!strcasecmp(subcmd, "send")) { |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1979 gchar *buffer; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1980 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1981 if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1982 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1983 free_arg_lst(paramlst); |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1984 return; |
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1985 } |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1986 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1987 // 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
|
1988 // 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
|
1989 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1990 buffer = to_utf8(arg); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1991 if (buffer) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1992 scr_LogPrint(LPRINT_NORMAL, "Sending XML string"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1993 jb_send_raw(buffer); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1994 g_free(buffer); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1995 } else { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1996 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
|
1997 } |
436 | 1998 } else { |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1999 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
436 | 2000 } |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2001 |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2002 free_arg_lst(paramlst); |
436 | 2003 } |
2004 | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2005 // check_room_subcommand(arg, param_needed, buddy_must_be_a_room) |
552 | 2006 // - Check if this is a room, if buddy_must_be_a_room is not null |
2007 // - Check there is at least 1 parameter, if param_needed is true | |
2008 // - Return null if one of the checks fails, or a pointer to the first | |
2009 // non-space character. | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2010 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
|
2011 gpointer buddy_must_be_a_room) |
552 | 2012 { |
2013 if (buddy_must_be_a_room && | |
2014 !(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
|
2015 scr_LogPrint(LPRINT_NORMAL, "This isn't a conference room."); |
552 | 2016 return NULL; |
2017 } | |
2018 | |
2019 if (param_needed) { | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2020 if (!arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2021 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
552 | 2022 return NULL; |
2023 } | |
2024 } | |
2025 | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2026 if (arg) |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2027 return arg; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2028 else |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2029 return ""; |
552 | 2030 } |
2031 | |
2032 static void room_join(gpointer bud, char *arg) | |
2033 { | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2034 char **paramlst; |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2035 char *roomname, *nick, *pass; |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2036 char *roomname_tmp = NULL; |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2037 char *pass_utf8; |
552 | 2038 |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2039 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
|
2040 roomname = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2041 nick = *(paramlst+1); |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2042 pass = *(paramlst+2); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2043 |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2044 if (!roomname) |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2045 nick = NULL; |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2046 if (!nick) |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2047 pass = NULL; |
552 | 2048 |
841
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
2049 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
|
2050 // 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
|
2051 // 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
|
2052 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
|
2053 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
|
2054 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
|
2055 return; |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
2056 } |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
2057 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
|
2058 } else if (strchr(roomname, '/')) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2059 scr_LogPrint(LPRINT_NORMAL, "Invalid room name."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2060 free_arg_lst(paramlst); |
552 | 2061 return; |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2062 } else { |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2063 // 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
|
2064 roomname_tmp = to_utf8(roomname); |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2065 mc_strtolower(roomname_tmp); |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2066 roomname = roomname_tmp; |
552 | 2067 } |
2068 | |
659
e61aa455c61b
MUC: Add "nickname" option variable
Mikael Berthe <mikael@lilotux.net>
parents:
653
diff
changeset
|
2069 // If no nickname is provided with the /join command, |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2070 // we try to get a default nickname. |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2071 if (!nick || !*nick) |
1395
d431cd75eb53
Use bookmarked nickname when manually joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
1392
diff
changeset
|
2072 nick = default_muc_nickname(roomname); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2073 else |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2074 nick = to_utf8(nick); |
659
e61aa455c61b
MUC: Add "nickname" option variable
Mikael Berthe <mikael@lilotux.net>
parents:
653
diff
changeset
|
2075 // 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
|
2076 if (!nick || !*nick) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2077 scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2078 g_free(nick); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2079 free_arg_lst(paramlst); |
552 | 2080 return; |
2081 } | |
2082 | |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2083 pass_utf8 = to_utf8(pass); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2084 |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2085 jb_room_join(roomname, nick, pass_utf8); |
552 | 2086 |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2087 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
|
2088 |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2089 g_free(roomname_tmp); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2090 g_free(nick); |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2091 g_free(pass_utf8); |
552 | 2092 buddylist_build(); |
2093 update_roster = TRUE; | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2094 free_arg_lst(paramlst); |
552 | 2095 } |
2096 | |
2097 static void room_invite(gpointer bud, char *arg) | |
2098 { | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2099 char **paramlst; |
552 | 2100 const gchar *roomname; |
1058 | 2101 char* fjid; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2102 gchar *reason_utf8; |
552 | 2103 |
570
29806b0fe830
Some parsing improvements
Mikael Berthe <mikael@lilotux.net>
parents:
568
diff
changeset
|
2104 paramlst = split_arg(arg, 2, 1); // jid, [reason] |
1058 | 2105 fjid = *paramlst; |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2106 arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2107 // An empty reason is no reason... |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2108 if (arg && !*arg) |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2109 arg = NULL; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2110 |
1058 | 2111 if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2112 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
|
2113 free_arg_lst(paramlst); |
552 | 2114 return; |
2115 } | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2116 |
552 | 2117 roomname = buddy_getjid(bud); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2118 reason_utf8 = to_utf8(arg); |
1058 | 2119 jb_room_invite(roomname, fjid, reason_utf8); |
2120 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
|
2121 g_free(reason_utf8); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2122 free_arg_lst(paramlst); |
552 | 2123 } |
2124 | |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2125 static void room_affil(gpointer bud, char *arg) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2126 { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2127 char **paramlst; |
1058 | 2128 gchar *fjid, *rolename; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2129 struct role_affil ra; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2130 const char *roomid = buddy_getjid(bud); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2131 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2132 paramlst = split_arg(arg, 3, 1); // jid, new_affil, [reason] |
1058 | 2133 fjid = *paramlst; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2134 rolename = *(paramlst+1); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2135 arg = *(paramlst+2); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2136 |
1058 | 2137 if (!fjid || !*fjid || !rolename || !*rolename) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2138 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
|
2139 free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2140 return; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2141 } |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2142 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2143 ra.type = type_affil; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2144 ra.val.affil = affil_none; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2145 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
|
2146 if (!strcasecmp(rolename, straffil[ra.val.affil])) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2147 break; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2148 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2149 if (ra.val.affil < imaffiliation_size) { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2150 gchar *jid_utf8, *reason_utf8; |
1058 | 2151 jid_utf8 = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2152 reason_utf8 = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2153 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
|
2154 g_free(jid_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2155 g_free(reason_utf8); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2156 } else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2157 scr_LogPrint(LPRINT_NORMAL, "Wrong affiliation parameter."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2158 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2159 free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2160 } |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2161 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2162 static void room_role(gpointer bud, char *arg) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2163 { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2164 char **paramlst; |
1058 | 2165 gchar *fjid, *rolename; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2166 struct role_affil ra; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2167 const char *roomid = buddy_getjid(bud); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2168 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2169 paramlst = split_arg(arg, 3, 1); // jid, new_role, [reason] |
1058 | 2170 fjid = *paramlst; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2171 rolename = *(paramlst+1); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2172 arg = *(paramlst+2); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2173 |
1058 | 2174 if (!fjid || !*fjid || !rolename || !*rolename) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2175 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
|
2176 free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2177 return; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2178 } |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2179 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2180 ra.type = type_role; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2181 ra.val.role = role_none; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2182 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
|
2183 if (!strcasecmp(rolename, strrole[ra.val.role])) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2184 break; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2185 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2186 if (ra.val.role < imrole_size) { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2187 gchar *jid_utf8, *reason_utf8; |
1058 | 2188 jid_utf8 = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2189 reason_utf8 = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2190 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
|
2191 g_free(jid_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2192 g_free(reason_utf8); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2193 } else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2194 scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2195 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2196 free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2197 } |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2198 |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2199 |
571 | 2200 // The expected argument is a Jabber id |
2201 static void room_ban(gpointer bud, char *arg) | |
2202 { | |
2203 char **paramlst; | |
1391
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2204 gchar *fjid, *bjid; |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2205 const gchar *banjid; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2206 gchar *jid_utf8, *reason_utf8; |
584 | 2207 struct role_affil ra; |
571 | 2208 const char *roomid = buddy_getjid(bud); |
2209 | |
2210 paramlst = split_arg(arg, 2, 1); // jid, [reason] | |
1058 | 2211 fjid = *paramlst; |
571 | 2212 arg = *(paramlst+1); |
2213 | |
1058 | 2214 if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2215 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
571 | 2216 free_arg_lst(paramlst); |
2217 return; | |
2218 } | |
2219 | |
584 | 2220 ra.type = type_affil; |
2221 ra.val.affil = affil_outcast; | |
2222 | |
1391
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2223 bjid = jidtodisp(fjid); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2224 jid_utf8 = to_utf8(bjid); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2225 |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2226 // If the argument doesn't look like a jid, we'll try to find a matching |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2227 // nickname. |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2228 if (!strchr(bjid, JID_DOMAIN_SEPARATOR) || check_jid_syntax(bjid)) { |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2229 const gchar *tmp; |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2230 // We want the initial argument, so the fjid variable, because |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2231 // we don't want to strip a resource-like string from the nickname! |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2232 g_free(jid_utf8); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2233 jid_utf8 = to_utf8(fjid); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2234 tmp = buddy_getrjid(bud, jid_utf8); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2235 if (!tmp) { |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2236 scr_LogPrint(LPRINT_NORMAL, "Wrong JID or nickname"); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2237 goto room_ban_return; |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2238 } |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2239 banjid = jidtodisp(tmp); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2240 } else |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2241 banjid = jid_utf8; |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2242 |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2243 scr_LogPrint(LPRINT_NORMAL, "Requesting a ban for %s", banjid); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2244 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2245 reason_utf8 = to_utf8(arg); |
1391
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2246 jb_room_setattrib(roomid, banjid, NULL, ra, reason_utf8); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2247 g_free(reason_utf8); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2248 |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2249 room_ban_return: |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2250 g_free(bjid); |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2251 g_free(jid_utf8); |
571 | 2252 free_arg_lst(paramlst); |
2253 } | |
2254 | |
1260
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2255 // The expected argument is a Jabber id |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2256 static void room_unban(gpointer bud, char *arg) |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2257 { |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2258 gchar *fjid = arg; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2259 gchar *jid_utf8; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2260 struct role_affil ra; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2261 const char *roomid = buddy_getjid(bud); |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2262 |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2263 if (!fjid || !*fjid) { |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2264 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2265 return; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2266 } |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2267 |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2268 ra.type = type_affil; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2269 ra.val.affil = affil_none; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2270 |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2271 jid_utf8 = to_utf8(fjid); |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2272 jb_room_setattrib(roomid, jid_utf8, NULL, ra, NULL); |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2273 g_free(jid_utf8); |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2274 } |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2275 |
571 | 2276 // The expected argument is a nickname |
568 | 2277 static void room_kick(gpointer bud, char *arg) |
2278 { | |
2279 char **paramlst; | |
2280 gchar *nick; | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2281 gchar *nick_utf8, *reason_utf8; |
584 | 2282 struct role_affil ra; |
568 | 2283 const char *roomid = buddy_getjid(bud); |
2284 | |
571 | 2285 paramlst = split_arg(arg, 2, 1); // nickname, [reason] |
568 | 2286 nick = *paramlst; |
2287 arg = *(paramlst+1); | |
2288 | |
2289 if (!nick || !*nick) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2290 scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
568 | 2291 free_arg_lst(paramlst); |
2292 return; | |
2293 } | |
2294 | |
584 | 2295 ra.type = type_role; |
2296 ra.val.affil = role_none; | |
2297 | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2298 nick_utf8 = to_utf8(nick); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2299 reason_utf8 = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2300 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
|
2301 g_free(nick_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2302 g_free(reason_utf8); |
568 | 2303 |
2304 free_arg_lst(paramlst); | |
2305 } | |
2306 | |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1138
diff
changeset
|
2307 void room_leave(gpointer bud, char *arg) |
552 | 2308 { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2309 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
|
2310 const char *nickname; |
552 | 2311 |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2312 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
|
2313 if (!nickname) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2314 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
|
2315 return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2316 } |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2317 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2318 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
|
2319 desc = to_utf8(arg); |
1050
ea71d31a2607
PGP: Do not sign presence messages to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
1043
diff
changeset
|
2320 jb_setstatus(offline, roomid, desc, TRUE); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2321 g_free(desc); |
552 | 2322 g_free(roomid); |
2323 } | |
2324 | |
2325 static void room_nick(gpointer bud, char *arg) | |
2326 { | |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2327 if (!buddy_getinsideroom(bud)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2328 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
|
2329 return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2330 } |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2331 |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2332 if (!arg || !*arg) { |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2333 const char *nick = buddy_getnickname(bud); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2334 if (nick) |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2335 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
|
2336 else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2337 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
|
2338 } else { |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2339 gchar *roomname, *roomname_tmp, *nick; |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2340 roomname_tmp = g_strdup(buddy_getjid(bud)); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2341 mc_strtolower(roomname_tmp); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2342 roomname = to_utf8(roomname_tmp); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2343 g_free(roomname_tmp); |
1392
3d4963c8ce87
Quotes should be escaped in /room nick
Mikael Berthe <mikael@lilotux.net>
parents:
1391
diff
changeset
|
2344 |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2345 nick = to_utf8(arg); |
1392
3d4963c8ce87
Quotes should be escaped in /room nick
Mikael Berthe <mikael@lilotux.net>
parents:
1391
diff
changeset
|
2346 strip_arg_special_chars(nick); |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2347 |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2348 jb_room_join(roomname, nick, NULL); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2349 g_free(roomname); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2350 g_free(nick); |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2351 } |
552 | 2352 } |
2353 | |
2354 static void room_privmsg(gpointer bud, char *arg) | |
2355 { | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2356 char **paramlst; |
1312
f4830fada2af
Fix /room privmsg when the MUC nickname contains spaces (Reported by sadeness)
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
2357 gchar *fjid, *nick, *fjid_utf8, *msg; |
552 | 2358 |
1100
2bef748356de
Do not strip quotes in /room privmsg
Mikael Berthe <mikael@lilotux.net>
parents:
1086
diff
changeset
|
2359 paramlst = split_arg(arg, 2, 1); // nickname, message |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2360 nick = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2361 arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2362 |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2363 if (!nick || !*nick || !arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2364 scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2365 "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
|
2366 free_arg_lst(paramlst); |
552 | 2367 return; |
2368 } | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2369 |
1312
f4830fada2af
Fix /room privmsg when the MUC nickname contains spaces (Reported by sadeness)
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
2370 fjid = g_strdup_printf("%s/%s", buddy_getjid(bud), nick); |
f4830fada2af
Fix /room privmsg when the MUC nickname contains spaces (Reported by sadeness)
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
2371 fjid_utf8 = to_utf8(fjid); |
f4830fada2af
Fix /room privmsg when the MUC nickname contains spaces (Reported by sadeness)
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
2372 msg = to_utf8(arg); |
f4830fada2af
Fix /room privmsg when the MUC nickname contains spaces (Reported by sadeness)
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
2373 send_message_to(fjid_utf8, msg, NULL, NULL); |
f4830fada2af
Fix /room privmsg when the MUC nickname contains spaces (Reported by sadeness)
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
2374 g_free(fjid); |
f4830fada2af
Fix /room privmsg when the MUC nickname contains spaces (Reported by sadeness)
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
2375 g_free(fjid_utf8); |
f4830fada2af
Fix /room privmsg when the MUC nickname contains spaces (Reported by sadeness)
Mikael Berthe <mikael@lilotux.net>
parents:
1311
diff
changeset
|
2376 g_free(msg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2377 free_arg_lst(paramlst); |
552 | 2378 } |
2379 | |
2380 static void room_remove(gpointer bud, char *arg) | |
2381 { | |
2382 if (*arg) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2383 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
|
2384 "the currently-selected room will be removed."); |
552 | 2385 return; |
2386 } | |
2387 | |
2388 // 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
|
2389 if (buddy_getinsideroom(bud)) { |
552 | 2390 scr_LogPrint(LPRINT_NORMAL, "You haven't left this room!"); |
2391 return; | |
2392 } | |
2393 // Delete the room | |
2394 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
|
2395 scr_UpdateBuddyWindow(); |
552 | 2396 buddylist_build(); |
2397 update_roster = TRUE; | |
2398 } | |
2399 | |
2400 static void room_topic(gpointer bud, char *arg) | |
2401 { | |
2402 gchar *msg; | |
2403 | |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2404 if (!buddy_getinsideroom(bud)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2405 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
|
2406 return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2407 } |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2408 |
552 | 2409 // If no parameter is given, display the current topic |
2410 if (!*arg) { | |
2411 const char *topic = buddy_gettopic(bud); | |
2412 if (topic) | |
2413 scr_LogPrint(LPRINT_NORMAL, "Topic: %s", topic); | |
2414 else | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2415 scr_LogPrint(LPRINT_NORMAL, "No topic has been set."); |
552 | 2416 return; |
2417 } | |
2418 | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2419 arg = to_utf8(arg); |
552 | 2420 // Set the topic |
967 | 2421 msg = g_strdup_printf("%s has set the topic to: %s", mkcmdstr("me"), arg); |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
2422 jb_send_msg(buddy_getjid(bud), msg, ROSTER_TYPE_ROOM, arg, NULL, NULL, NULL); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2423 g_free(arg); |
552 | 2424 g_free(msg); |
2425 } | |
2426 | |
599 | 2427 static void room_destroy(gpointer bud, char *arg) |
2428 { | |
2429 gchar *msg; | |
2430 | |
2431 if (arg && *arg) | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2432 msg = to_utf8(arg); |
599 | 2433 else |
2434 msg = NULL; | |
2435 | |
2436 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
|
2437 g_free(msg); |
599 | 2438 } |
2439 | |
552 | 2440 static void room_unlock(gpointer bud, char *arg) |
2441 { | |
2442 if (*arg) { | |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2443 scr_LogPrint(LPRINT_NORMAL, "Unknown parameter."); |
552 | 2444 return; |
2445 } | |
2446 | |
2447 jb_room_unlock(buddy_getjid(bud)); | |
2448 } | |
2449 | |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2450 static void room_setopt(gpointer bud, char *arg) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2451 { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2452 char **paramlst; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2453 char *param, *value; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2454 enum { opt_none = 0, opt_printstatus, opt_autowhois } option = 0; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2455 |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2456 paramlst = split_arg(arg, 2, 1); // param, value |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2457 param = *paramlst; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2458 value = *(paramlst+1); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2459 if (!param) { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2460 scr_LogPrint(LPRINT_NORMAL, "Please specify a room option."); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2461 free_arg_lst(paramlst); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2462 return; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2463 } |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2464 |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2465 if (!strcasecmp(param, "print_status")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2466 option = opt_printstatus; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2467 else if (!strcasecmp(param, "auto_whois")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2468 option = opt_autowhois; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2469 else { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2470 scr_LogPrint(LPRINT_NORMAL, "Wrong option!"); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2471 free_arg_lst(paramlst); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2472 return; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2473 } |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2474 |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2475 // If no value is given, display the current value |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2476 if (!value) { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2477 const char *strval; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2478 if (option == opt_printstatus) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2479 strval = strprintstatus[buddy_getprintstatus(bud)]; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2480 else |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2481 strval = strautowhois[buddy_getautowhois(bud)]; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2482 scr_LogPrint(LPRINT_NORMAL, "%s is set to: %s", param, strval); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2483 free_arg_lst(paramlst); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2484 return; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2485 } |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2486 |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2487 if (option == opt_printstatus) { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2488 enum room_printstatus eval; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2489 if (!strcasecmp(value, "none")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2490 eval = status_none; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2491 else if (!strcasecmp(value, "in_and_out")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2492 eval = status_in_and_out; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2493 else if (!strcasecmp(value, "all")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2494 eval = status_all; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2495 else { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2496 eval = status_default; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2497 if (strcasecmp(value, "default") != 0) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2498 scr_LogPrint(LPRINT_NORMAL, "Unrecognized value, assuming default..."); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2499 } |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2500 buddy_setprintstatus(bud, eval); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2501 } else if (option == opt_autowhois) { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2502 enum room_autowhois eval; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2503 if (!strcasecmp(value, "on")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2504 eval = autowhois_on; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2505 else if (!strcasecmp(value, "off")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2506 eval = autowhois_off; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2507 else { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2508 eval = autowhois_default; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2509 if (strcasecmp(value, "default") != 0) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2510 scr_LogPrint(LPRINT_NORMAL, "Unrecognized value, assuming default..."); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2511 } |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2512 buddy_setautowhois(bud, eval); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2513 } |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2514 |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2515 free_arg_lst(paramlst); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2516 } |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2517 |
960
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2518 // room_whois(..) |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2519 // 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
|
2520 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
|
2521 { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2522 char **paramlst; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2523 gchar *nick, *buffer; |
1058 | 2524 const char *bjid, *realjid; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2525 const char *rst_msg; |
575 | 2526 gchar rprio; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2527 enum imstatus rstatus; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2528 enum imrole role; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2529 enum imaffiliation affil; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2530 time_t rst_time; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2531 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2532 paramlst = split_arg(arg, 1, 0); // nickname |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2533 nick = *paramlst; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2534 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2535 if (!nick || !*nick) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2536 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
|
2537 free_arg_lst(paramlst); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2538 return; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2539 } |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2540 |
791
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2541 nick = to_utf8(nick); |
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2542 |
960
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2543 if (interactive) { |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2544 // Enter chat mode |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2545 scr_set_chatmode(TRUE); |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2546 scr_ShowBuddyWindow(); |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2547 } |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
2548 |
1058 | 2549 bjid = buddy_getjid(bud); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2550 rstatus = buddy_getstatus(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2551 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2552 if (rstatus == offline) { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2553 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
|
2554 free_arg_lst(paramlst); |
791
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2555 g_free(nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2556 return; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2557 } |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2558 |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2559 rst_time = buddy_getstatustime(bud, nick); |
575 | 2560 rprio = buddy_getresourceprio(bud, nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2561 rst_msg = buddy_getstatusmsg(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2562 if (!rst_msg) rst_msg = ""; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2563 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2564 role = buddy_getrole(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2565 affil = buddy_getaffil(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2566 realjid = buddy_getrjid(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2567 |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2568 buffer = g_new(char, 4096); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2569 |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2570 snprintf(buffer, 4095, "Whois [%s]", nick); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
2571 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2572 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
|
2573 rst_msg); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
2574 scr_WriteIncomingMessage(bjid, buffer, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
2575 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2576 |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2577 if (rst_time) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2578 char tbuf[128]; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2579 |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2580 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
|
2581 snprintf(buffer, 127, "Timestamp: %s", tbuf); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
2582 scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
2583 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2584 } |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2585 |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2586 if (realjid) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2587 snprintf(buffer, 4095, "JID : <%s>", realjid); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
2588 scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
2589 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2590 } |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2591 |
1058 | 2592 snprintf(buffer, 4095, "Role : %s", strrole[role]); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
2593 scr_WriteIncomingMessage(bjid, buffer, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
2594 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2595 snprintf(buffer, 4095, "Affiliat.: %s", straffil[affil]); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
2596 scr_WriteIncomingMessage(bjid, buffer, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
2597 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2598 snprintf(buffer, 4095, "Priority : %d", rprio); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
2599 scr_WriteIncomingMessage(bjid, buffer, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
2600 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
2601 |
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
2602 scr_WriteIncomingMessage(bjid, "End of WHOIS", 0, HBB_PREFIX_INFO, 0); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2603 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2604 g_free(buffer); |
791
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2605 g_free(nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2606 free_arg_lst(paramlst); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2607 } |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2608 |
1009 | 2609 static void room_bookmark(gpointer bud, char *arg) |
2610 { | |
2611 const char *roomid; | |
2612 const char *name = NULL, *nick = NULL; | |
1379
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1377
diff
changeset
|
2613 enum room_autowhois autowhois = 0; |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1377
diff
changeset
|
2614 enum room_printstatus printstatus = 0; |
1009 | 2615 enum { bm_add = 0, bm_del = 1 } action = 0; |
2616 int autojoin = 0; | |
2617 | |
2618 if (arg && *arg) { | |
2619 // /room bookmark [add|del] [[+|-]autojoin] | |
2620 char **paramlst; | |
2621 char **pp; | |
2622 | |
2623 paramlst = split_arg(arg, 2, 0); // At most 2 parameters | |
2624 for (pp = paramlst; *pp; pp++) { | |
2625 if (!strcasecmp(*pp, "add")) | |
2626 action = bm_add; | |
2627 else if (!strcasecmp(*pp, "del")) | |
2628 action = bm_del; | |
2629 else if (!strcasecmp(*pp, "-autojoin")) | |
2630 autojoin = 0; | |
2631 else if (!strcasecmp(*pp, "+autojoin") || !strcasecmp(*pp, "autojoin")) | |
2632 autojoin = 1; | |
2633 } | |
2634 free_arg_lst(paramlst); | |
2635 } | |
2636 | |
2637 roomid = buddy_getjid(bud); | |
2638 | |
2639 if (action == bm_add) { | |
2640 name = buddy_getname(bud); | |
2641 nick = buddy_getnickname(bud); | |
1379
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1377
diff
changeset
|
2642 printstatus = buddy_getprintstatus(bud); |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1377
diff
changeset
|
2643 autowhois = buddy_getautowhois(bud); |
1009 | 2644 } |
2645 | |
1379
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1377
diff
changeset
|
2646 jb_set_storage_bookmark(roomid, name, nick, NULL, autojoin, |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1377
diff
changeset
|
2647 printstatus, autowhois); |
1009 | 2648 } |
2649 | |
1163
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2650 static void display_all_bookmarks(void) |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2651 { |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2652 GSList *bm, *bmp; |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2653 GString *sbuf; |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2654 |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2655 bm = jb_get_all_storage_bookmarks(); |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2656 |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2657 if (!bm) |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2658 return; |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2659 |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2660 sbuf = g_string_new(""); |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2661 |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
2662 scr_WriteIncomingMessage(NULL, "List of MUC bookmarks:", |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
2663 0, HBB_PREFIX_INFO, 0); |
1163
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2664 |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2665 for (bmp = bm; bmp; bmp = g_slist_next(bmp)) { |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2666 g_string_printf(sbuf, "<%s>", (char*)bmp->data); |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1260
diff
changeset
|
2667 scr_WriteIncomingMessage(NULL, sbuf->str, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
2668 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1163
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2669 } |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2670 |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2671 scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2672 update_roster = TRUE; |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2673 g_string_free(sbuf, TRUE); |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2674 g_slist_free(bm); |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2675 } |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2676 |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2677 |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2678 static void do_room(char *arg) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2679 { |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2680 char **paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2681 char *subcmd; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2682 gpointer bud; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2683 |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2684 if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2685 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
|
2686 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2687 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2688 |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2689 paramlst = split_arg(arg, 2, 1); // subcmd, arg |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2690 subcmd = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2691 arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2692 |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2693 if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2694 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2695 free_arg_lst(paramlst); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2696 return; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2697 } |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2698 |
831
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2699 if (current_buddy) { |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2700 bud = BUDDATA(current_buddy); |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2701 } else { |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2702 if (strcasecmp(subcmd, "join")) { |
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2703 free_arg_lst(paramlst); |
831
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2704 return; |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2705 } |
831
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2706 // "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
|
2707 // current_buddy. |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2708 bud = NULL; |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2709 } |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2710 |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2711 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
|
2712 if ((arg = check_room_subcommand(arg, FALSE, NULL)) != NULL) |
552 | 2713 room_join(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2714 } else if (!strcasecmp(subcmd, "invite")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2715 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
552 | 2716 room_invite(bud, arg); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2717 } else if (!strcasecmp(subcmd, "affil")) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2718 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
|
2719 room_affil(bud, arg); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2720 } else if (!strcasecmp(subcmd, "role")) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2721 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
|
2722 room_role(bud, arg); |
571 | 2723 } else if (!strcasecmp(subcmd, "ban")) { |
2724 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) | |
2725 room_ban(bud, arg); | |
1260
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2726 } else if (!strcasecmp(subcmd, "unban")) { |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2727 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2728 room_unban(bud, arg); |
568 | 2729 } else if (!strcasecmp(subcmd, "kick")) { |
2730 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) | |
2731 room_kick(bud, arg); | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2732 } else if (!strcasecmp(subcmd, "leave")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2733 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2734 room_leave(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2735 } else if (!strcasecmp(subcmd, "names")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2736 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2737 room_names(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2738 } else if (!strcasecmp(subcmd, "nick")) { |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2739 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2740 room_nick(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2741 } else if (!strcasecmp(subcmd, "privmsg")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2742 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
552 | 2743 room_privmsg(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2744 } else if (!strcasecmp(subcmd, "remove")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2745 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2746 room_remove(bud, arg); |
599 | 2747 } else if (!strcasecmp(subcmd, "destroy")) { |
2748 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) | |
2749 room_destroy(bud, arg); | |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2750 } else if (!strcasecmp(subcmd, "unlock")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2751 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2752 room_unlock(bud, arg); |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2753 } else if (!strcasecmp(subcmd, "setopt")) { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2754 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2755 room_setopt(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2756 } else if (!strcasecmp(subcmd, "topic")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2757 if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2758 room_topic(bud, arg); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2759 } else if (!strcasecmp(subcmd, "whois")) { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2760 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
|
2761 room_whois(bud, arg, TRUE); |
1009 | 2762 } else if (!strcasecmp(subcmd, "bookmark")) { |
1163
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2763 if (!arg && !buddy_getjid(BUDDATA(current_buddy)) && |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2764 buddy_gettype(BUDDATA(current_buddy)) == ROSTER_TYPE_SPECIAL) |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2765 display_all_bookmarks(); |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
2766 else if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
1009 | 2767 room_bookmark(bud, arg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2768 } else { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2769 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2770 } |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2771 |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2772 free_arg_lst(paramlst); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2773 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2774 |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2775 static void do_authorization(char *arg) |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2776 { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2777 char **paramlst; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2778 char *subcmd; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2779 char *jid_utf8; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2780 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2781 if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2782 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2783 return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2784 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2785 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2786 paramlst = split_arg(arg, 2, 0); // subcmd, [jid] |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2787 subcmd = *paramlst; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2788 arg = *(paramlst+1); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2789 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2790 if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2791 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
|
2792 goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2793 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2794 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2795 // Use the provided jid, if it looks valid |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2796 if (arg) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2797 if (!*arg) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2798 // If no jid is provided, we use the current selected buddy |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2799 arg = NULL; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2800 } else { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2801 if (check_jid_syntax(arg)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2802 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2803 "<%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
|
2804 goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2805 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2806 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2807 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2808 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2809 if (!arg) { // Use the current selected buddy's jid |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2810 gpointer bud; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2811 guint type; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2812 |
1058 | 2813 if (!current_buddy) |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
2814 goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2815 bud = BUDDATA(current_buddy); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2816 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2817 jid_utf8 = arg = (char*)buddy_getjid(bud); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2818 type = buddy_gettype(bud); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2819 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2820 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
|
2821 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
|
2822 goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2823 } |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2824 } else { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2825 jid_utf8 = to_utf8(arg); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2826 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2827 |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2828 if (!strcasecmp(subcmd, "allow")) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2829 jb_subscr_send_auth(jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2830 scr_LogPrint(LPRINT_LOGNORM, |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2831 "<%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
|
2832 jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2833 } else if (!strcasecmp(subcmd, "cancel")) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2834 jb_subscr_cancel_auth(jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2835 scr_LogPrint(LPRINT_LOGNORM, |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2836 "<%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
|
2837 jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2838 } else if (!strcasecmp(subcmd, "request")) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2839 jb_subscr_request_auth(jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2840 scr_LogPrint(LPRINT_LOGNORM, |
957 | 2841 "Sent presence notification request to <%s>.", jid_utf8); |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2842 } else if (!strcasecmp(subcmd, "request_unsubscribe")) { |
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2843 jb_subscr_request_cancel(jid_utf8); |
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2844 scr_LogPrint(LPRINT_LOGNORM, |
957 | 2845 "Sent presence notification unsubscription request to <%s>.", |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2846 jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2847 } else { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2848 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2849 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2850 |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2851 // 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
|
2852 if (jid_utf8 && jid_utf8 != arg) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2853 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
|
2854 do_authorization_return: |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2855 free_arg_lst(paramlst); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2856 } |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2857 |
622 | 2858 static void do_version(char *arg) |
2859 { | |
777
e6d42f239541
"/version" shows Mercurial changeset (if there's one)
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
2860 gchar *ver = mcabber_version(); |
e6d42f239541
"/version" shows Mercurial changeset (if there's one)
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
2861 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
|
2862 g_free(ver); |
622 | 2863 } |
2864 | |
693 | 2865 static void do_request(char *arg) |
2866 { | |
2867 char **paramlst; | |
1058 | 2868 char *fjid, *type; |
740 | 2869 enum iqreq_type numtype = iqreq_none; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2870 char *jid_utf8 = NULL; |
693 | 2871 |
2872 paramlst = split_arg(arg, 2, 0); // type, jid | |
2873 type = *paramlst; | |
1058 | 2874 fjid = *(paramlst+1); |
693 | 2875 |
2876 if (type) { | |
2877 // Quick check... | |
2878 if (!strcasecmp(type, "version")) | |
2879 numtype = iqreq_version; | |
2880 else if (!strcasecmp(type, "time")) | |
2881 numtype = iqreq_time; | |
1015 | 2882 else if (!strcasecmp(type, "last")) |
2883 numtype = iqreq_last; | |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
2884 else if (!strcasecmp(type, "vcard")) |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
2885 numtype = iqreq_vcard; |
694
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2886 else if (!strcasecmp(type, "show_list")) { |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2887 // Undocumented command, for debugging purposes only |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2888 jb_iqs_display_list(); |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2889 free_arg_lst(paramlst); |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2890 return; |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2891 } |
693 | 2892 } |
2893 | |
2894 if (!type || !numtype) { | |
2895 scr_LogPrint(LPRINT_NORMAL, | |
1015 | 2896 "Please specify a query type (version, time...)."); |
693 | 2897 free_arg_lst(paramlst); |
2898 return; | |
2899 } | |
2900 | |
2901 // Allow special jid "" or "." (current buddy) | |
1058 | 2902 if (fjid && (!*fjid || !strcmp(fjid, "."))) |
2903 fjid = NULL; | |
693 | 2904 |
1058 | 2905 if (fjid) { |
693 | 2906 // The JID has been specified. Quick check... |
1058 | 2907 if (check_jid_syntax(fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2908 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2909 "<%s> is not a valid Jabber ID.", fjid); |
1058 | 2910 fjid = NULL; |
693 | 2911 } else { |
2912 // Convert jid to lowercase | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2913 char *p; |
1058 | 2914 for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) |
693 | 2915 *p = tolower(*p); |
1058 | 2916 fjid = jid_utf8 = to_utf8(fjid); |
693 | 2917 } |
2918 } else { | |
2919 // Add the current buddy | |
2920 if (current_buddy) | |
1058 | 2921 fjid = (char*)buddy_getjid(BUDDATA(current_buddy)); |
2922 if (!fjid) | |
693 | 2923 scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
2924 } | |
2925 | |
1058 | 2926 if (fjid) { |
693 | 2927 switch (numtype) { |
2928 case iqreq_version: | |
2929 case iqreq_time: | |
1015 | 2930 case iqreq_last: |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
2931 case iqreq_vcard: |
1058 | 2932 jb_request(fjid, numtype); |
693 | 2933 break; |
2934 default: | |
2935 break; | |
2936 } | |
2937 } | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2938 g_free(jid_utf8); |
693 | 2939 free_arg_lst(paramlst); |
2940 } | |
2941 | |
748 | 2942 static void do_event(char *arg) |
2943 { | |
2944 char **paramlst; | |
2945 char *evid, *subcmd; | |
2946 int action = -1; | |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2947 GSList *evidlst; |
748 | 2948 |
2949 paramlst = split_arg(arg, 2, 0); // id, subcmd | |
2950 evid = *paramlst; | |
2951 subcmd = *(paramlst+1); | |
2952 | |
2953 if (!evid || !subcmd) { | |
2954 // Special case: /event list | |
2955 if (evid && !strcasecmp(evid, "list")) | |
2956 evs_display_list(); | |
2957 else | |
2958 scr_LogPrint(LPRINT_NORMAL, | |
2959 "Missing parameter. Usage: /event num action"); | |
2960 free_arg_lst(paramlst); | |
2961 return; | |
2962 } | |
2963 | |
2964 if (!strcasecmp(subcmd, "reject")) | |
2965 action = 0; | |
2966 else if (!strcasecmp(subcmd, "accept")) | |
2967 action = 1; | |
755 | 2968 else if (!strcasecmp(subcmd, "ignore")) |
2969 action = 2; | |
748 | 2970 |
2971 if (action == -1) { | |
2972 scr_LogPrint(LPRINT_NORMAL, "Wrong action parameter."); | |
755 | 2973 } else if (action >= 0 && action <= 2) { |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2974 GSList *p; |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2975 |
755 | 2976 if (action == 2) { |
2977 action = EVS_CONTEXT_CANCEL; | |
2978 } else { | |
2979 action += EVS_CONTEXT_USER; | |
2980 } | |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2981 |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2982 if (!strcmp(evid, "*")) { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2983 // Use completion list |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2984 evidlst = evs_geteventslist(FALSE); |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2985 } else { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2986 // Let's create a slist with the provided event id |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2987 evidlst = g_slist_append(NULL, g_strdup(evid)); |
748 | 2988 } |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2989 for (p = evidlst; p; p = g_slist_next(p)) { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2990 if (evs_callback(p->data, action) == -1) { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2991 scr_LogPrint(LPRINT_NORMAL, "Event %s not found.", p->data); |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2992 } |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2993 g_free(p->data); |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2994 } |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2995 g_slist_free(evidlst); |
748 | 2996 } |
2997 | |
2998 free_arg_lst(paramlst); | |
2999 } | |
3000 | |
1066 | 3001 static void do_pgp(char *arg) |
3002 { | |
3003 char **paramlst; | |
3004 char *fjid, *subcmd, *keyid; | |
3005 enum { | |
3006 pgp_none, | |
3007 pgp_enable, | |
3008 pgp_disable, | |
3009 pgp_setkey, | |
1197 | 3010 pgp_force, |
1066 | 3011 pgp_info |
3012 } op = 0; | |
1197 | 3013 int force = FALSE; |
1066 | 3014 |
3015 paramlst = split_arg(arg, 3, 0); // subcmd, jid, [key] | |
3016 subcmd = *paramlst; | |
3017 fjid = *(paramlst+1); | |
3018 keyid = *(paramlst+2); | |
3019 | |
3020 if (!subcmd) | |
3021 fjid = NULL; | |
3022 if (!fjid) | |
3023 keyid = NULL; | |
3024 | |
3025 if (subcmd) { | |
3026 if (!strcasecmp(subcmd, "enable")) | |
3027 op = pgp_enable; | |
3028 else if (!strcasecmp(subcmd, "disable")) | |
3029 op = pgp_disable; | |
3030 else if (!strcasecmp(subcmd, "setkey")) | |
3031 op = pgp_setkey; | |
1197 | 3032 else if ((!strcasecmp(subcmd, "force")) || |
3033 (!strcasecmp(subcmd, "+force"))) { | |
3034 op = pgp_force; | |
3035 force = TRUE; | |
3036 } else if (!strcasecmp(subcmd, "-force")) | |
3037 op = pgp_force; | |
1066 | 3038 else if (!strcasecmp(subcmd, "info")) |
3039 op = pgp_info; | |
3040 } | |
3041 | |
3042 if (!op) { | |
3043 scr_LogPrint(LPRINT_NORMAL, "Unrecognized or missing parameter!"); | |
3044 free_arg_lst(paramlst); | |
3045 return; | |
3046 } | |
3047 | |
3048 // Allow special jid "" or "." (current buddy) | |
3049 if (fjid && (!*fjid || !strcmp(fjid, "."))) | |
3050 fjid = NULL; | |
3051 | |
3052 if (fjid) { | |
3053 // The JID has been specified. Quick check... | |
3054 if (check_jid_syntax(fjid) || !strchr(fjid, '@')) { | |
3055 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, | |
3056 "<%s> is not a valid Jabber ID.", fjid); | |
3057 fjid = NULL; | |
3058 } else { | |
3059 // Convert jid to lowercase and strip resource | |
3060 char *p; | |
3061 for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) | |
3062 *p = tolower(*p); | |
3063 if (*p == JID_RESOURCE_SEPARATOR) | |
3064 *p = '\0'; | |
3065 } | |
3066 } else { | |
3067 gpointer bud = NULL; | |
3068 if (current_buddy) | |
3069 bud = BUDDATA(current_buddy); | |
3070 if (bud) { | |
3071 guint type = buddy_gettype(bud); | |
3072 if (type & ROSTER_TYPE_USER) // Is it a user? | |
3073 fjid = (char*)buddy_getjid(bud); | |
3074 else | |
3075 scr_LogPrint(LPRINT_NORMAL, "The selected item should be a user."); | |
3076 } | |
3077 } | |
3078 | |
3079 if (fjid) { // fjid is actually a bare jid... | |
1197 | 3080 guint disabled; |
1066 | 3081 GString *sbuf; |
3082 switch (op) { | |
3083 case pgp_enable: | |
3084 case pgp_disable: | |
3085 settings_pgp_setdisabled(fjid, (op == pgp_disable ? TRUE : FALSE)); | |
3086 break; | |
1197 | 3087 case pgp_force: |
3088 settings_pgp_setforce(fjid, force); | |
3089 break; | |
1066 | 3090 case pgp_setkey: |
3091 settings_pgp_setkeyid(fjid, keyid); | |
3092 break; | |
3093 case pgp_info: | |
3094 sbuf = g_string_new(""); | |
3095 if (settings_pgp_getkeyid(fjid)) { | |
3096 g_string_printf(sbuf, "PGP Encryption key id: %s", | |
3097 settings_pgp_getkeyid(fjid)); | |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
3098 scr_WriteIncomingMessage(fjid, sbuf->str, 0, HBB_PREFIX_INFO, 0); |
1066 | 3099 } |
1197 | 3100 disabled = settings_pgp_getdisabled(fjid); |
1066 | 3101 g_string_printf(sbuf, "PGP encryption is %s", |
1197 | 3102 (disabled ? "disabled" : "enabled")); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
3103 scr_WriteIncomingMessage(fjid, sbuf->str, 0, HBB_PREFIX_INFO, 0); |
1197 | 3104 if (!disabled && settings_pgp_getforce(fjid)) { |
3105 scr_WriteIncomingMessage(fjid, | |
3106 "Encryption enforced (no negotiation)", | |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
3107 0, HBB_PREFIX_INFO, 0); |
1197 | 3108 } |
1066 | 3109 g_string_free(sbuf, TRUE); |
3110 break; | |
3111 default: | |
3112 break; | |
3113 } | |
3114 } else { | |
3115 scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); | |
3116 } | |
3117 | |
3118 free_arg_lst(paramlst); | |
3119 } | |
3120 | |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3121 static void do_otr(char *arg) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3122 { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3123 #ifdef HAVE_LIBOTR |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3124 char **paramlst; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3125 char *fjid, *subcmd, *keyid; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3126 enum { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3127 otr_none, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3128 otr_start, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3129 otr_stop, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3130 otr_fpr, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3131 otr_smpq, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3132 otr_smpr, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3133 otr_smpa, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3134 otr_k, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3135 otr_info |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3136 } op = 0; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3137 |
1347
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1341
diff
changeset
|
3138 if (!otr_enabled()) { |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1341
diff
changeset
|
3139 scr_LogPrint(LPRINT_LOGNORM, |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1341
diff
changeset
|
3140 "Warning: OTR hasn't been enabled -- command ignored."); |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1341
diff
changeset
|
3141 return; |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1341
diff
changeset
|
3142 } |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1341
diff
changeset
|
3143 |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3144 paramlst = split_arg(arg, 3, 0); // subcmd, jid, [key] |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3145 subcmd = *paramlst; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3146 fjid = *(paramlst+1); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3147 keyid = *(paramlst+2); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3148 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3149 if (!subcmd) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3150 fjid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3151 if (!fjid) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3152 keyid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3153 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3154 if (subcmd) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3155 if (!strcasecmp(subcmd, "start")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3156 op = otr_start; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3157 else if (!strcasecmp(subcmd, "stop")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3158 op = otr_stop; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3159 else if (!strcasecmp(subcmd, "fingerprint")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3160 op = otr_fpr; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3161 else if (!strcasecmp(subcmd, "smpq")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3162 op = otr_smpq; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3163 else if (!strcasecmp(subcmd, "smpr")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3164 op = otr_smpr; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3165 else if (!strcasecmp(subcmd, "smpa")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3166 op = otr_smpa; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3167 else if (!strcasecmp(subcmd, "key")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3168 op = otr_k; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3169 else if (!strcasecmp(subcmd, "info")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3170 op = otr_info; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3171 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3172 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3173 if (!op) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3174 scr_LogPrint(LPRINT_NORMAL, "Unrecognized or missing parameter!"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3175 free_arg_lst(paramlst); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3176 return; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3177 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3178 |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
3179 if (op == otr_k) |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3180 otr_key(); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3181 else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3182 // Allow special jid "" or "." (current buddy) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3183 if (fjid && (!*fjid || !strcmp(fjid, "."))) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3184 fjid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3185 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3186 if (fjid) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3187 // The JID has been specified. Quick check... |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3188 if (check_jid_syntax(fjid) || !strchr(fjid, '@')) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3189 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3190 "<%s> is not a valid Jabber ID.", fjid); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3191 fjid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3192 } else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3193 // Convert jid to lowercase and strip resource |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3194 char *p; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3195 for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3196 *p = tolower(*p); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3197 if (*p == JID_RESOURCE_SEPARATOR) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3198 *p = '\0'; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3199 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3200 } else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3201 gpointer bud = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3202 if (current_buddy) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3203 bud = BUDDATA(current_buddy); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3204 if (bud) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3205 guint type = buddy_gettype(bud); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3206 if (type & ROSTER_TYPE_USER) // Is it a user? |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3207 fjid = (char*)buddy_getjid(bud); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3208 else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3209 scr_LogPrint(LPRINT_NORMAL, "The selected item should be a user."); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3210 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3211 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3212 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3213 if (fjid) { // fjid is actually a bare jid... |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3214 switch (op) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3215 case otr_start: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3216 otr_establish(fjid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3217 case otr_stop: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3218 otr_disconnect(fjid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3219 case otr_fpr: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3220 otr_fingerprint(fjid, keyid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3221 case otr_smpq: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3222 otr_smp_query(fjid, keyid); break; |
1329 | 3223 case otr_smpr: |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3224 otr_smp_respond(fjid, keyid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3225 case otr_smpa: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3226 otr_smp_abort(fjid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3227 case otr_info: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3228 otr_print_info(fjid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3229 default: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3230 break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3231 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3232 } else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3233 scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3234 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3235 free_arg_lst(paramlst); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3236 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3237 #else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3238 scr_LogPrint(LPRINT_NORMAL, "Please recompile mcabber with libotr enabled."); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3239 #endif /* HAVE_LIBOTR */ |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3240 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3241 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3242 #ifdef HAVE_LIBOTR |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3243 static char * string_for_otrpolicy(enum otr_policy p) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3244 { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3245 switch (p) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3246 case plain: return "plain"; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3247 case opportunistic: return "opportunistic"; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3248 case manual: return "manual"; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3249 case always: return "always"; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3250 default: return "unknown"; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3251 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3252 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3253 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3254 static void dump_otrpolicy(char * k, char * v, void * nothing) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3255 { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3256 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, "otrpolicy for %s: %s", k, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3257 string_for_otrpolicy(*(enum otr_policy*)v)); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3258 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3259 #endif |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3260 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3261 static void do_otrpolicy(char *arg) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3262 { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3263 #ifdef HAVE_LIBOTR |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3264 char **paramlst; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3265 char *fjid, *policy; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3266 enum otr_policy p; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3267 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3268 paramlst = split_arg(arg, 2, 0); // [jid|default] policy |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3269 fjid = *paramlst; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3270 policy = *(paramlst+1); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3271 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3272 if (!fjid && !policy) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3273 scr_LogPrint(LPRINT_NORMAL, "default otrpolicy: %s", |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3274 string_for_otrpolicy(settings_otr_getpolicy(NULL))); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3275 settings_foreach(SETTINGS_TYPE_OTR, &dump_otrpolicy, NULL); |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3276 free_arg_lst(paramlst); |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3277 return; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3278 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3279 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3280 if (!policy) { |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3281 scr_LogPrint(LPRINT_NORMAL, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3282 "Please call otrpolicy correctly: /otrpolicy (default|jid) " |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3283 "(plain|manual|opportunistic|always)"); |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3284 free_arg_lst(paramlst); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3285 return; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3286 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3287 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3288 if (!strcasecmp(policy, "plain")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3289 p = plain; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3290 else if (!strcasecmp(policy, "manual")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3291 p = manual; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3292 else if (!strcasecmp(policy, "opportunistic")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3293 p = opportunistic; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3294 else if (!strcasecmp(policy, "always")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3295 p = always; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3296 else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3297 /* Fail, we don't know _this_ policy*/ |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3298 scr_LogPrint(LPRINT_NORMAL, "mcabber doesn't support _this_ policy!"); |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3299 free_arg_lst(paramlst); |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3300 return; |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3301 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3302 |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
3303 if (!strcasecmp(fjid, "default") || !strcasecmp(fjid, "*")) { |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3304 /*set default policy*/ |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3305 settings_otr_setpolicy(NULL, p); |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3306 free_arg_lst(paramlst); |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3307 return; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3308 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3309 // Allow special jid "" or "." (current buddy) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3310 if (fjid && (!*fjid || !strcmp(fjid, "."))) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3311 fjid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3312 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3313 if (fjid) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3314 // The JID has been specified. Quick check... |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3315 if (check_jid_syntax(fjid) || !strchr(fjid, '@')) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3316 scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3317 "<%s> is not a valid Jabber ID.", fjid); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3318 fjid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3319 } else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3320 // Convert jid to lowercase and strip resource |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3321 char *p; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3322 for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3323 *p = tolower(*p); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3324 if (*p == JID_RESOURCE_SEPARATOR) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3325 *p = '\0'; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3326 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3327 } else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3328 gpointer bud = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3329 if (current_buddy) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3330 bud = BUDDATA(current_buddy); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3331 if (bud) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3332 guint type = buddy_gettype(bud); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3333 if (type & ROSTER_TYPE_USER) // Is it a user? |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3334 fjid = (char*)buddy_getjid(bud); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3335 else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3336 scr_LogPrint(LPRINT_NORMAL, "The selected item should be a user."); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3337 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3338 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3339 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3340 if (fjid) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3341 settings_otr_setpolicy(fjid, p); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3342 else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3343 scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3344 |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3345 free_arg_lst(paramlst); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3346 #else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3347 scr_LogPrint(LPRINT_NORMAL, "Please recompile mcabber with libotr enabled."); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3348 #endif /* HAVE_LIBOTR */ |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3349 } |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3350 |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3351 /* !!! |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3352 After changing the /iline arguments names here, you must change ones |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3353 in init_bindings(). |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3354 */ |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3355 static void do_iline(char *arg) |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3356 { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3357 if (!strcasecmp(arg, "fword")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3358 readline_forward_word(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3359 } else if (!strcasecmp(arg, "bword")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3360 readline_backward_word(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3361 } else if (!strcasecmp(arg, "word_fdel")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3362 readline_forward_kill_word(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3363 } else if (!strcasecmp(arg, "word_bdel")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3364 readline_backward_kill_word(); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3365 } else if (!strcasecmp(arg, "word_upcase")) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3366 readline_updowncase_word(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3367 } else if (!strcasecmp(arg, "word_downcase")) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3368 readline_updowncase_word(0); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3369 } else if (!strcasecmp(arg, "word_capit")) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3370 readline_capitalize_word(); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3371 } else if (!strcasecmp(arg, "fchar")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3372 readline_forward_char(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3373 } else if (!strcasecmp(arg, "bchar")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3374 readline_backward_char(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3375 } else if (!strcasecmp(arg, "char_fdel")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3376 readline_forward_kill_char(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3377 } else if (!strcasecmp(arg, "char_bdel")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3378 readline_backward_kill_char(); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3379 } else if (!strcasecmp(arg, "char_swap")) { |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3380 readline_transpose_chars(); |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3381 } else if (!strcasecmp(arg, "hist_beginning_search_bwd")) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3382 readline_hist_beginning_search_bwd(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3383 } else if (!strcasecmp(arg, "hist_beginning_search_fwd")) { |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3384 readline_hist_beginning_search_fwd(); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3385 } else if (!strcasecmp(arg, "hist_prev")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3386 readline_hist_prev(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3387 } else if (!strcasecmp(arg, "hist_next")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3388 readline_hist_next(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3389 } else if (!strcasecmp(arg, "iline_start")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3390 readline_iline_start(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3391 } else if (!strcasecmp(arg, "iline_end")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3392 readline_iline_end(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3393 } else if (!strcasecmp(arg, "iline_fdel")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3394 readline_forward_kill_iline(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3395 } else if (!strcasecmp(arg, "iline_bdel")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3396 readline_backward_kill_iline(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3397 } else if (!strcasecmp(arg, "send_multiline")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3398 readline_send_multiline(); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3399 } else if (!strcasecmp(arg, "iline_accept")) { |
1177
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
3400 retval_for_cmds = readline_accept_line(FALSE); |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
3401 } else if (!strcasecmp(arg, "iline_accept_down_hist")) { |
10733d7de004
Refactor readline_accept_line() and readline_accept_line_down_hist()
Mikael Berthe <mikael@lilotux.net>
parents:
1173
diff
changeset
|
3402 retval_for_cmds = readline_accept_line(TRUE); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3403 } else if (!strcasecmp(arg, "compl_cancel")) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3404 readline_cancel_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3405 } else if (!strcasecmp(arg, "compl_do")) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3406 readline_do_completion(); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3407 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3408 } |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3409 |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3410 static void do_screen_refresh(char *arg) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3411 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3412 readline_refresh_screen(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3413 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3414 |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3415 static void do_chat_disable(char *arg) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3416 { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3417 readline_disable_chat_mode(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3418 } |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3419 |
1192 | 3420 static void do_source(char *arg) |
3421 { | |
3422 static int recur_level; | |
1202
ede6c7aa59b0
Handle "~" in /source paths
Mikael Berthe <mikael@lilotux.net>
parents:
1197
diff
changeset
|
3423 gchar *filename, *expfname; |
1192 | 3424 if (!*arg) { |
3425 scr_LogPrint(LPRINT_NORMAL, "Missing filename."); | |
3426 return; | |
3427 } | |
3428 if (recur_level > 20) { | |
3429 scr_LogPrint(LPRINT_LOGNORM, "** Too many source commands!"); | |
3430 return; | |
3431 } | |
3432 filename = g_strdup(arg); | |
3433 strip_arg_special_chars(filename); | |
1202
ede6c7aa59b0
Handle "~" in /source paths
Mikael Berthe <mikael@lilotux.net>
parents:
1197
diff
changeset
|
3434 expfname = expand_filename(filename); |
1192 | 3435 recur_level++; |
1202
ede6c7aa59b0
Handle "~" in /source paths
Mikael Berthe <mikael@lilotux.net>
parents:
1197
diff
changeset
|
3436 cfg_read_file(expfname, FALSE); |
1192 | 3437 recur_level--; |
3438 g_free(filename); | |
1202
ede6c7aa59b0
Handle "~" in /source paths
Mikael Berthe <mikael@lilotux.net>
parents:
1197
diff
changeset
|
3439 g_free(expfname); |
1192 | 3440 } |
3441 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
3442 static void do_connect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
3443 { |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
3444 mcabber_connect(); |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
3445 } |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
3446 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
3447 static void do_disconnect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
3448 { |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
3449 jb_disconnect(); |
1381
40095d413da9
Fix compilation on OpenBSD
Mikael Berthe <mikael@lilotux.net>
parents:
1379
diff
changeset
|
3450 AutoConnection = FALSE; |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
3451 } |
576 | 3452 |
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
3453 static void do_help(char *arg) |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
3454 { |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
3455 help_process(arg); |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
3456 } |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
3457 |
580 | 3458 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |