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