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