author | Myhailo Danylenko <isbear@ukrpost.net> |
Sat, 28 Jul 2012 22:10:12 +0300 | |
changeset 2020 | 46a21258ad91 |
parent 2016 | e9b6e168a45e |
child 2021 | f88de5187d3b |
permissions | -rw-r--r-- |
47 | 1 |
/* |
699 | 2 |
* commands.c -- user commands handling |
393 | 3 |
* |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1726
diff
changeset
|
4 |
* Copyright (C) 2005-2010 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" |
1654
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_AVAILABLE "avail" |
|
51 |
#define IMSTATUS_NOTAVAILABLE "notavail" |
|
52 |
#define IMSTATUS_DONOTDISTURB "dnd" |
|
1972
45f0f0f60656
Remove deprecated status invisible
Mikael Berthe <mikael@lilotux.net>
parents:
1959
diff
changeset
|
53 |
#ifdef WITH_DEPRECATED_STATUS_INVISIBLE |
45f0f0f60656
Remove deprecated status invisible
Mikael Berthe <mikael@lilotux.net>
parents:
1959
diff
changeset
|
54 |
# define IMSTATUS_INVISIBLE "invisible" |
45f0f0f60656
Remove deprecated status invisible
Mikael Berthe <mikael@lilotux.net>
parents:
1959
diff
changeset
|
55 |
#endif |
967 | 56 |
|
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
57 |
// 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
|
58 |
static int retval_for_cmds; |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
59 |
|
104 | 60 |
// Commands callbacks |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
61 |
static void do_roster(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
62 |
static void do_status(char *arg); |
444 | 63 |
static void do_status_to(char *arg); |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
64 |
static void do_add(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
65 |
static void do_del(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
66 |
static void do_group(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
67 |
static void do_say(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
68 |
static void do_msay(char *arg); |
480 | 69 |
static void do_say_to(char *arg); |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
70 |
static void do_buffer(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
71 |
static void do_clear(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
72 |
static void do_info(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
73 |
static void do_rename(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
74 |
static void do_move(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
75 |
static void do_set(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
76 |
static void do_alias(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
77 |
static void do_bind(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
78 |
static void do_connect(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
79 |
static void do_disconnect(char *arg); |
436 | 80 |
static void do_rawxml(char *arg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
81 |
static void do_room(char *arg); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
82 |
static void do_authorization(char *arg); |
622 | 83 |
static void do_version(char *arg); |
693 | 84 |
static void do_request(char *arg); |
748 | 85 |
static void do_event(char *arg); |
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
86 |
static void do_help(char *arg); |
1066 | 87 |
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
|
88 |
static void do_iline(char *arg); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
89 |
static void do_screen_refresh(char *arg); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
90 |
static void do_chat_disable(char *arg); |
1192 | 91 |
static void do_source(char *arg); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
92 |
static void do_color(char *arg); |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
93 |
static void do_otr(char *arg); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
94 |
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
|
95 |
static void do_echo(char *arg); |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
96 |
static void do_module(char *arg); |
47 | 97 |
|
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
98 |
static void room_bookmark(gpointer bud, char *arg); |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
99 |
|
104 | 100 |
// Global variable for the commands list |
95 | 101 |
static GSList *Commands; |
1988
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
102 |
static GSList *safe_commands; |
95 | 103 |
|
1607 | 104 |
#ifdef MODULES_ENABLE |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
105 |
#include "modules.h" |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
106 |
|
1986
ad77110343d6
Use a command ID with cmd_add/cmd_del (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1985
diff
changeset
|
107 |
gpointer cmd_del(gpointer id) |
1607 | 108 |
{ |
1649
44bbdc961234
Allow commands shading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1648
diff
changeset
|
109 |
GSList *sl_cmd; |
1992 | 110 |
if (!id) return NULL; |
1986
ad77110343d6
Use a command ID with cmd_add/cmd_del (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1985
diff
changeset
|
111 |
for (sl_cmd = Commands; sl_cmd; sl_cmd = sl_cmd->next) |
ad77110343d6
Use a command ID with cmd_add/cmd_del (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1985
diff
changeset
|
112 |
if (sl_cmd -> data == id) { |
ad77110343d6
Use a command ID with cmd_add/cmd_del (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1985
diff
changeset
|
113 |
cmd *command = (cmd *) sl_cmd->data; |
1649
44bbdc961234
Allow commands shading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1648
diff
changeset
|
114 |
gpointer userdata = command->userdata; |
44bbdc961234
Allow commands shading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1648
diff
changeset
|
115 |
Commands = g_slist_delete_link(Commands, sl_cmd); |
44bbdc961234
Allow commands shading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1648
diff
changeset
|
116 |
compl_del_category_word(COMPL_CMD, command->name); |
44bbdc961234
Allow commands shading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1648
diff
changeset
|
117 |
g_free(command); |
44bbdc961234
Allow commands shading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1648
diff
changeset
|
118 |
return userdata; |
44bbdc961234
Allow commands shading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1648
diff
changeset
|
119 |
} |
1607 | 120 |
return NULL; |
121 |
} |
|
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
122 |
#endif |
104 | 123 |
|
95 | 124 |
// cmd_add() |
125 |
// Adds a command to the commands list and to the CMD completion list |
|
1986
ad77110343d6
Use a command ID with cmd_add/cmd_del (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1985
diff
changeset
|
126 |
gpointer cmd_add(const char *name, const char *help, guint flags_row1, |
ad77110343d6
Use a command ID with cmd_add/cmd_del (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1985
diff
changeset
|
127 |
guint flags_row2, void (*f)(char*), gpointer userdata) |
95 | 128 |
{ |
129 |
cmd *n_cmd = g_new0(cmd, 1); |
|
130 |
strncpy(n_cmd->name, name, 32-1); |
|
131 |
n_cmd->help = help; |
|
132 |
n_cmd->completion_flags[0] = flags_row1; |
|
133 |
n_cmd->completion_flags[1] = flags_row2; |
|
134 |
n_cmd->func = f; |
|
1607 | 135 |
n_cmd->userdata = userdata; |
1649
44bbdc961234
Allow commands shading
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1648
diff
changeset
|
136 |
Commands = g_slist_prepend(Commands, n_cmd); |
95 | 137 |
// Add to completion CMD category |
138 |
compl_add_category_word(COMPL_CMD, name); |
|
1986
ad77110343d6
Use a command ID with cmd_add/cmd_del (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1985
diff
changeset
|
139 |
return n_cmd; |
95 | 140 |
} |
141 |
||
1988
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
142 |
// cmd_set_safe(name, safe) |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
143 |
// Sets if command can be used in startup configuration file. |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
144 |
gboolean cmd_set_safe(const gchar *name, gboolean safe) |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
145 |
{ |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
146 |
GSList *sel; |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
147 |
if (!name) |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
148 |
return FALSE; |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
149 |
for (sel = safe_commands; sel; sel = sel->next) |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
150 |
if (!strcmp((const char *)sel->data, name)) { |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
151 |
if (safe) |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
152 |
return FALSE; |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
153 |
else { |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
154 |
g_free(sel->data); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
155 |
safe_commands = g_slist_delete_link(safe_commands, sel); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
156 |
} |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
157 |
} |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
158 |
if (safe) |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
159 |
safe_commands = g_slist_append(safe_commands, g_strdup(name)); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
160 |
else |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
161 |
return FALSE; |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
162 |
return TRUE; |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
163 |
} |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
164 |
|
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
165 |
// cmd_is_safe(name) |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
166 |
// Returns if command is safe or not |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
167 |
gboolean cmd_is_safe(const gchar *name) |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
168 |
{ |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
169 |
GSList *sel; |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
170 |
if (!name) |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
171 |
return FALSE; |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
172 |
for (sel = safe_commands; sel; sel = sel->next) |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
173 |
if (!strcmp((const char *)sel->data, name)) |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
174 |
return TRUE; |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
175 |
return FALSE; |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
176 |
} |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
177 |
|
95 | 178 |
// cmd_init() |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
179 |
// Commands table initialization |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
180 |
// !!! |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
181 |
// 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
|
182 |
// ones in init_bindings()! |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
183 |
// |
95 | 184 |
void cmd_init(void) |
185 |
{ |
|
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
186 |
cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
187 |
cmd_add("alias", "Add an alias", 0, 0, &do_alias, NULL); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
188 |
cmd_add("authorization", "Manage subscription authorizations", |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
189 |
COMPL_AUTH, COMPL_JID, &do_authorization, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
190 |
cmd_add("bind", "Add an key binding", 0, 0, &do_bind, NULL); |
187 | 191 |
cmd_add("buffer", "Manipulate current buddy's buffer (chat window)", |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
192 |
COMPL_BUFFER, 0, &do_buffer, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
193 |
cmd_add("chat_disable", "Disable chat mode", 0, 0, &do_chat_disable, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
194 |
cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
195 |
cmd_add("color", "Set coloring options", COMPL_COLOR, 0, &do_color, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
196 |
cmd_add("connect", "Connect to the server", 0, 0, &do_connect, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
197 |
cmd_add("del", "Delete the current buddy", 0, 0, &do_del, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
198 |
cmd_add("disconnect", "Disconnect from server", 0, 0, &do_disconnect, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
199 |
cmd_add("echo", "Display a string in the log window", 0, 0, &do_echo, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
200 |
cmd_add("event", "Process an event", COMPL_EVENTSID, COMPL_EVENTS, &do_event, |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
201 |
NULL); |
1507
3de24d857ef7
Complete group names in /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1506
diff
changeset
|
202 |
cmd_add("group", "Change group display settings", |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
203 |
COMPL_GROUP, COMPL_GROUPNAME, &do_group, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
204 |
cmd_add("help", "Display some help", COMPL_CMD, 0, &do_help, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
205 |
cmd_add("iline", "Manipulate input buffer", 0, 0, &do_iline, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
206 |
cmd_add("info", "Show basic info on current buddy", 0, 0, &do_info, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
207 |
cmd_add("module", "Manipulations with modules", COMPL_MODULE, 0, &do_module, |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
208 |
NULL); |
225 | 209 |
cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
210 |
0, &do_move, NULL); |
238 | 211 |
cmd_add("msay", "Send a multi-lines message to the selected buddy", |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
212 |
COMPL_MULTILINE, 0, &do_msay, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
213 |
cmd_add("otr", "Manage OTR settings", COMPL_OTR, COMPL_JID, &do_otr, NULL); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
214 |
cmd_add("otrpolicy", "Manage OTR policies", COMPL_JID, COMPL_OTRPOLICY, |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
215 |
&do_otrpolicy, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
216 |
cmd_add("pgp", "Manage PGP settings", COMPL_PGP, COMPL_JID, &do_pgp, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
217 |
cmd_add("quit", "Exit the software", 0, 0, NULL, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
218 |
cmd_add("rawxml", "Send a raw XML string", 0, 0, &do_rawxml, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
219 |
cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename, NULL); |
902
2016f52a167f
Sort commands (for the completion system)
Mikael Berthe <mikael@lilotux.net>
parents:
900
diff
changeset
|
220 |
cmd_add("request", "Send a Jabber IQ request", COMPL_REQUEST, COMPL_JID, |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
221 |
&do_request, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
222 |
cmd_add("room", "MUC actions command", COMPL_ROOM, 0, &do_room, NULL); |
128 | 223 |
cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
224 |
&do_roster, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
225 |
cmd_add("say", "Say something to the selected buddy", 0, 0, &do_say, NULL); |
488
9e8519078e00
Enable jid completion for /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
486
diff
changeset
|
226 |
cmd_add("say_to", "Say something to a specific buddy", COMPL_JID, 0, |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
227 |
&do_say_to, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
228 |
cmd_add("screen_refresh", "Redraw mcabber screen", 0, 0, &do_screen_refresh, |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
229 |
NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
230 |
cmd_add("set", "Set/query an option value", 0, 0, &do_set, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
231 |
cmd_add("source", "Read a configuration file", 0, 0, &do_source, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
232 |
cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status, |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
233 |
NULL); |
444 | 234 |
cmd_add("status_to", "Show or set your status for one recipient", |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
235 |
COMPL_JID, COMPL_STATUS, &do_status_to, NULL); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
236 |
cmd_add("version", "Show mcabber version", 0, 0, &do_version, NULL); |
95 | 237 |
|
1988
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
238 |
cmd_set_safe("set", TRUE); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
239 |
cmd_set_safe("bind", TRUE); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
240 |
cmd_set_safe("alias", TRUE); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
241 |
cmd_set_safe("pgp", TRUE); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
242 |
cmd_set_safe("source", TRUE); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
243 |
cmd_set_safe("status", TRUE); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
244 |
cmd_set_safe("color", TRUE); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
245 |
cmd_set_safe("otrpolicy", TRUE); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
246 |
cmd_set_safe("module", TRUE); |
dd65a18dc480
Add cmd_set_safe() / cmd_is_safe() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1986
diff
changeset
|
247 |
|
95 | 248 |
// Status category |
249 |
compl_add_category_word(COMPL_STATUS, "online"); |
|
250 |
compl_add_category_word(COMPL_STATUS, "avail"); |
|
1972
45f0f0f60656
Remove deprecated status invisible
Mikael Berthe <mikael@lilotux.net>
parents:
1959
diff
changeset
|
251 |
#ifdef WITH_DEPRECATED_STATUS_INVISIBLE |
95 | 252 |
compl_add_category_word(COMPL_STATUS, "invisible"); |
1972
45f0f0f60656
Remove deprecated status invisible
Mikael Berthe <mikael@lilotux.net>
parents:
1959
diff
changeset
|
253 |
#endif |
95 | 254 |
compl_add_category_word(COMPL_STATUS, "free"); |
255 |
compl_add_category_word(COMPL_STATUS, "dnd"); |
|
256 |
compl_add_category_word(COMPL_STATUS, "notavail"); |
|
257 |
compl_add_category_word(COMPL_STATUS, "away"); |
|
1235
58d6e7713164
Complete /status offline
Mikael Berthe <mikael@lilotux.net>
parents:
1226
diff
changeset
|
258 |
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
|
259 |
compl_add_category_word(COMPL_STATUS, "message"); |
103 | 260 |
|
261 |
// Roster category |
|
262 |
compl_add_category_word(COMPL_ROSTER, "bottom"); |
|
265 | 263 |
compl_add_category_word(COMPL_ROSTER, "top"); |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
264 |
compl_add_category_word(COMPL_ROSTER, "up"); |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
265 |
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
|
266 |
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
|
267 |
compl_add_category_word(COMPL_ROSTER, "group_next"); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
268 |
compl_add_category_word(COMPL_ROSTER, "hide"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
269 |
compl_add_category_word(COMPL_ROSTER, "show"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
270 |
compl_add_category_word(COMPL_ROSTER, "toggle"); |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1305
diff
changeset
|
271 |
compl_add_category_word(COMPL_ROSTER, "display"); |
103 | 272 |
compl_add_category_word(COMPL_ROSTER, "hide_offline"); |
273 |
compl_add_category_word(COMPL_ROSTER, "show_offline"); |
|
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
274 |
compl_add_category_word(COMPL_ROSTER, "toggle_offline"); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
275 |
compl_add_category_word(COMPL_ROSTER, "item_lock"); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
276 |
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
|
277 |
compl_add_category_word(COMPL_ROSTER, "item_toggle_lock"); |
330 | 278 |
compl_add_category_word(COMPL_ROSTER, "alternate"); |
265 | 279 |
compl_add_category_word(COMPL_ROSTER, "search"); |
236 | 280 |
compl_add_category_word(COMPL_ROSTER, "unread_first"); |
281 |
compl_add_category_word(COMPL_ROSTER, "unread_next"); |
|
1016 | 282 |
compl_add_category_word(COMPL_ROSTER, "note"); |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
283 |
compl_add_category_word(COMPL_ROSTER, "resource_lock"); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
284 |
compl_add_category_word(COMPL_ROSTER, "resource_unlock"); |
127 | 285 |
|
1626 | 286 |
// Buffer category |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
287 |
compl_add_category_word(COMPL_BUFFER, "clear"); |
187 | 288 |
compl_add_category_word(COMPL_BUFFER, "bottom"); |
289 |
compl_add_category_word(COMPL_BUFFER, "top"); |
|
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
290 |
compl_add_category_word(COMPL_BUFFER, "up"); |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
291 |
compl_add_category_word(COMPL_BUFFER, "down"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
292 |
compl_add_category_word(COMPL_BUFFER, "search_backward"); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
293 |
compl_add_category_word(COMPL_BUFFER, "search_forward"); |
1959
ed97057f0881
Add completion item for /buffer readmark subcommand
Mikael Berthe <mikael@lilotux.net>
parents:
1956
diff
changeset
|
294 |
compl_add_category_word(COMPL_BUFFER, "readmark"); |
464 | 295 |
compl_add_category_word(COMPL_BUFFER, "date"); |
462 | 296 |
compl_add_category_word(COMPL_BUFFER, "%"); |
866 | 297 |
compl_add_category_word(COMPL_BUFFER, "purge"); |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1130
diff
changeset
|
298 |
compl_add_category_word(COMPL_BUFFER, "close"); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
299 |
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
|
300 |
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
|
301 |
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
|
302 |
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
|
303 |
compl_add_category_word(COMPL_BUFFER, "list"); |
1485
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
304 |
compl_add_category_word(COMPL_BUFFER, "save"); |
187 | 305 |
|
127 | 306 |
// Group category |
240 | 307 |
compl_add_category_word(COMPL_GROUP, "fold"); |
308 |
compl_add_category_word(COMPL_GROUP, "unfold"); |
|
130 | 309 |
compl_add_category_word(COMPL_GROUP, "toggle"); |
238 | 310 |
|
311 |
// Multi-line (msay) category |
|
312 |
compl_add_category_word(COMPL_MULTILINE, "abort"); |
|
313 |
compl_add_category_word(COMPL_MULTILINE, "begin"); |
|
314 |
compl_add_category_word(COMPL_MULTILINE, "send"); |
|
636 | 315 |
compl_add_category_word(COMPL_MULTILINE, "send_to"); |
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
316 |
compl_add_category_word(COMPL_MULTILINE, "toggle"); |
838
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
317 |
compl_add_category_word(COMPL_MULTILINE, "toggle_verbatim"); |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
318 |
compl_add_category_word(COMPL_MULTILINE, "verbatim"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
319 |
|
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
320 |
// Room category |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
321 |
compl_add_category_word(COMPL_ROOM, "affil"); |
571 | 322 |
compl_add_category_word(COMPL_ROOM, "ban"); |
1009 | 323 |
compl_add_category_word(COMPL_ROOM, "bookmark"); |
599 | 324 |
compl_add_category_word(COMPL_ROOM, "destroy"); |
486 | 325 |
compl_add_category_word(COMPL_ROOM, "invite"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
326 |
compl_add_category_word(COMPL_ROOM, "join"); |
568 | 327 |
compl_add_category_word(COMPL_ROOM, "kick"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
328 |
compl_add_category_word(COMPL_ROOM, "leave"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
329 |
compl_add_category_word(COMPL_ROOM, "names"); |
470 | 330 |
compl_add_category_word(COMPL_ROOM, "nick"); |
490 | 331 |
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
|
332 |
compl_add_category_word(COMPL_ROOM, "remove"); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
333 |
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
|
334 |
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
|
335 |
compl_add_category_word(COMPL_ROOM, "topic"); |
1260
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
336 |
compl_add_category_word(COMPL_ROOM, "unban"); |
449 | 337 |
compl_add_category_word(COMPL_ROOM, "unlock"); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
338 |
compl_add_category_word(COMPL_ROOM, "whois"); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
339 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
340 |
// Authorization category |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
341 |
compl_add_category_word(COMPL_AUTH, "allow"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
342 |
compl_add_category_word(COMPL_AUTH, "cancel"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
343 |
compl_add_category_word(COMPL_AUTH, "request"); |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
344 |
compl_add_category_word(COMPL_AUTH, "request_unsubscribe"); |
693 | 345 |
|
346 |
// Request (query) category |
|
1015 | 347 |
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
|
348 |
compl_add_category_word(COMPL_REQUEST, "ping"); |
693 | 349 |
compl_add_category_word(COMPL_REQUEST, "time"); |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
350 |
compl_add_category_word(COMPL_REQUEST, "vcard"); |
693 | 351 |
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
|
352 |
|
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
353 |
// Events category |
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
354 |
compl_add_category_word(COMPL_EVENTS, "accept"); |
755 | 355 |
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
|
356 |
compl_add_category_word(COMPL_EVENTS, "reject"); |
1066 | 357 |
|
358 |
// PGP category |
|
359 |
compl_add_category_word(COMPL_PGP, "disable"); |
|
360 |
compl_add_category_word(COMPL_PGP, "enable"); |
|
1197 | 361 |
compl_add_category_word(COMPL_PGP, "force"); |
1066 | 362 |
compl_add_category_word(COMPL_PGP, "info"); |
363 |
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
|
364 |
|
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
365 |
// OTR category |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
366 |
compl_add_category_word(COMPL_OTR, "start"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
367 |
compl_add_category_word(COMPL_OTR, "stop"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
368 |
compl_add_category_word(COMPL_OTR, "fingerprint"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
369 |
compl_add_category_word(COMPL_OTR, "smpq"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
370 |
compl_add_category_word(COMPL_OTR, "smpr"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
371 |
compl_add_category_word(COMPL_OTR, "smpa"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
372 |
compl_add_category_word(COMPL_OTR, "info"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
373 |
compl_add_category_word(COMPL_OTR, "key"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
374 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
375 |
// OTR Policy category |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
376 |
compl_add_category_word(COMPL_OTRPOLICY, "plain"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
377 |
compl_add_category_word(COMPL_OTRPOLICY, "manual"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
378 |
compl_add_category_word(COMPL_OTRPOLICY, "opportunistic"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
379 |
compl_add_category_word(COMPL_OTRPOLICY, "always"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
380 |
|
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
381 |
// Color category |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
382 |
compl_add_category_word(COMPL_COLOR, "roster"); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
383 |
compl_add_category_word(COMPL_COLOR, "muc"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
384 |
compl_add_category_word(COMPL_COLOR, "mucnick"); |
1923
924f4552996c
Add a category module to complete the /module subcommands
Mikael Berthe <mikael@lilotux.net>
parents:
1921
diff
changeset
|
385 |
|
924f4552996c
Add a category module to complete the /module subcommands
Mikael Berthe <mikael@lilotux.net>
parents:
1921
diff
changeset
|
386 |
#ifdef MODULES_ENABLE |
924f4552996c
Add a category module to complete the /module subcommands
Mikael Berthe <mikael@lilotux.net>
parents:
1921
diff
changeset
|
387 |
// Module category |
924f4552996c
Add a category module to complete the /module subcommands
Mikael Berthe <mikael@lilotux.net>
parents:
1921
diff
changeset
|
388 |
compl_add_category_word(COMPL_MODULE, "info"); |
924f4552996c
Add a category module to complete the /module subcommands
Mikael Berthe <mikael@lilotux.net>
parents:
1921
diff
changeset
|
389 |
compl_add_category_word(COMPL_MODULE, "list"); |
924f4552996c
Add a category module to complete the /module subcommands
Mikael Berthe <mikael@lilotux.net>
parents:
1921
diff
changeset
|
390 |
compl_add_category_word(COMPL_MODULE, "load"); |
924f4552996c
Add a category module to complete the /module subcommands
Mikael Berthe <mikael@lilotux.net>
parents:
1921
diff
changeset
|
391 |
compl_add_category_word(COMPL_MODULE, "unload"); |
924f4552996c
Add a category module to complete the /module subcommands
Mikael Berthe <mikael@lilotux.net>
parents:
1921
diff
changeset
|
392 |
#endif |
95 | 393 |
} |
94 | 394 |
|
285 | 395 |
// expandalias(line) |
396 |
// If there is one, expand the alias in line and returns a new allocated line |
|
397 |
// 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
|
398 |
// 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
|
399 |
// g_free() the pointer after use |
1352
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
400 |
char *expandalias(const char *line) |
285 | 401 |
{ |
402 |
const char *p1, *p2; |
|
403 |
char *word; |
|
404 |
const gchar *value; |
|
1352
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
405 |
char *newline = (char*)line; |
285 | 406 |
|
967 | 407 |
// Ignore leading COMMAND_CHAR |
408 |
for (p1 = line ; *p1 == COMMAND_CHAR ; p1++) |
|
285 | 409 |
; |
410 |
// Locate the end of the word |
|
411 |
for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) |
|
412 |
; |
|
1387 | 413 |
// Extract the word and look for an alias in the list |
285 | 414 |
word = g_strndup(p1, p2-p1); |
415 |
value = settings_get(SETTINGS_TYPE_ALIAS, (const char*)word); |
|
416 |
g_free(word); |
|
417 |
||
1387 | 418 |
if (value) |
419 |
newline = g_strdup_printf("%c%s%s", COMMAND_CHAR, value, p2); |
|
420 |
||
285 | 421 |
return newline; |
422 |
} |
|
423 |
||
102 | 424 |
// cmd_get |
425 |
// Finds command in the command list structure. |
|
426 |
// Returns a pointer to the cmd entry, or NULL if command not found. |
|
238 | 427 |
cmd *cmd_get(const char *command) |
102 | 428 |
{ |
238 | 429 |
const char *p1, *p2; |
102 | 430 |
char *com; |
431 |
GSList *sl_com; |
|
285 | 432 |
|
967 | 433 |
// Ignore leading COMMAND_CHAR |
434 |
for (p1 = command ; *p1 == COMMAND_CHAR ; p1++) |
|
102 | 435 |
; |
436 |
// Locate the end of the command |
|
437 |
for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) |
|
438 |
; |
|
439 |
// Copy the clean command |
|
440 |
com = g_strndup(p1, p2-p1); |
|
441 |
||
442 |
// Look for command in the list |
|
443 |
for (sl_com=Commands; sl_com; sl_com = g_slist_next(sl_com)) { |
|
444 |
if (!strcasecmp(com, ((cmd*)sl_com->data)->name)) |
|
445 |
break; |
|
446 |
} |
|
447 |
g_free(com); |
|
448 |
||
449 |
if (sl_com) // Command has been found. |
|
450 |
return (cmd*)sl_com->data; |
|
451 |
return NULL; |
|
452 |
} |
|
453 |
||
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1181
diff
changeset
|
454 |
// process_command(line, iscmd) |
288 | 455 |
// 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
|
456 |
// 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
|
457 |
// it is intended to be used for key bindings. |
288 | 458 |
// 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
|
459 |
int process_command(const char *line, guint iscmd) |
47 | 460 |
{ |
101 | 461 |
char *p; |
285 | 462 |
char *xpline; |
104 | 463 |
cmd *curcmd; |
464 |
||
1365 | 465 |
if (!line) |
466 |
return 0; |
|
467 |
||
285 | 468 |
// 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
|
469 |
if (iscmd || scr_get_multimode() != 2) |
288 | 470 |
xpline = expandalias(line); |
471 |
else |
|
1352
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
472 |
xpline = (char*)line; // No expansion in verbatim multi-line mode |
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
473 |
|
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1351
diff
changeset
|
474 |
// We want to use a copy |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
475 |
if (xpline == line) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
476 |
xpline = g_strdup(line); |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
477 |
|
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
478 |
// Remove trailing spaces: |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
479 |
for (p=xpline ; *p ; p++) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
480 |
; |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
481 |
for (p-- ; p>xpline && (*p == ' ') ; p--) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
482 |
*p = 0; |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
483 |
|
101 | 484 |
// 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
|
485 |
if ((iscmd || scr_get_multimode() != 2) |
1126
771eb6aa2d41
Fix another memory leak, spotted by valgrind
misc@mandriva.org
parents:
1100
diff
changeset
|
486 |
&& (!strncasecmp(xpline, mkcmdstr("quit"), strlen(mkcmdstr("quit"))))) { |
771eb6aa2d41
Fix another memory leak, spotted by valgrind
misc@mandriva.org
parents:
1100
diff
changeset
|
487 |
if (!xpline[5] || xpline[5] == ' ') { |
771eb6aa2d41
Fix another memory leak, spotted by valgrind
misc@mandriva.org
parents:
1100
diff
changeset
|
488 |
g_free(xpline); |
116 | 489 |
return 255; |
1126
771eb6aa2d41
Fix another memory leak, spotted by valgrind
misc@mandriva.org
parents:
1100
diff
changeset
|
490 |
} |
1359
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1356
diff
changeset
|
491 |
} 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
|
492 |
(!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
|
493 |
// 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
|
494 |
// character (usually '/'). |
7daf906fbcdc
The command /quit can be used in bindings, hooks and sourced files
Mikael Berthe <mikael@lilotux.net>
parents:
1356
diff
changeset
|
495 |
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
|
496 |
return 255; |
1126
771eb6aa2d41
Fix another memory leak, spotted by valgrind
misc@mandriva.org
parents:
1100
diff
changeset
|
497 |
} |
104 | 498 |
|
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
499 |
// 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
|
500 |
if (!iscmd && scr_get_multimode() == 2 |
967 | 501 |
&& (strncasecmp(xpline, mkcmdstr("msay "), strlen(mkcmdstr("msay "))))) { |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
502 |
// It isn't an /msay command |
285 | 503 |
scr_append_multiline(xpline); |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
504 |
g_free(xpline); |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
505 |
return 0; |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
506 |
} |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
507 |
|
47 | 508 |
// Commands handling |
285 | 509 |
curcmd = cmd_get(xpline); |
47 | 510 |
|
104 | 511 |
if (!curcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
512 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized command. " |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
513 |
"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
|
514 |
g_free(xpline); |
104 | 515 |
return 0; |
516 |
} |
|
517 |
if (!curcmd->func) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
518 |
scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
519 |
"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
|
520 |
g_free(xpline); |
104 | 521 |
return 0; |
522 |
} |
|
523 |
// Lets go to the command parameters |
|
285 | 524 |
for (p = xpline+1; *p && (*p != ' ') ; p++) |
104 | 525 |
; |
526 |
// Skip spaces |
|
285 | 527 |
while (*p && (*p == ' ')) |
528 |
p++; |
|
104 | 529 |
// Call command-specific function |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
530 |
retval_for_cmds = 0; |
1607 | 531 |
#ifdef MODULES_ENABLE |
532 |
if (curcmd->userdata) |
|
533 |
(*(void (*)(char *p, gpointer u))curcmd->func)(p, curcmd->userdata); |
|
534 |
else |
|
535 |
(*curcmd->func)(p); |
|
536 |
#else |
|
285 | 537 |
(*curcmd->func)(p); |
1607 | 538 |
#endif |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
539 |
g_free(xpline); |
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
540 |
return retval_for_cmds; |
47 | 541 |
} |
542 |
||
288 | 543 |
// process_line(line) |
544 |
// Process a command/message line. |
|
545 |
// If this isn't a command, this is a message and it is sent to the |
|
546 |
// currently selected buddy. |
|
547 |
// 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
|
548 |
int process_line(const char *line) |
288 | 549 |
{ |
550 |
if (!*line) { // User only pressed enter |
|
551 |
if (scr_get_multimode()) { |
|
552 |
scr_append_multiline(""); |
|
553 |
return 0; |
|
554 |
} |
|
555 |
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
|
556 |
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP) |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1745
diff
changeset
|
557 |
do_group("toggle"); |
1410
0cb4361c85a7
Pressing enter when a group is selected will toggle the fold status (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1395
diff
changeset
|
558 |
else { |
0cb4361c85a7
Pressing enter when a group is selected will toggle the fold status (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1395
diff
changeset
|
559 |
// 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
|
560 |
scr_set_chatmode(TRUE); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
561 |
scr_show_buddy_window(); |
1410
0cb4361c85a7
Pressing enter when a group is selected will toggle the fold status (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1395
diff
changeset
|
562 |
} |
288 | 563 |
} |
564 |
return 0; |
|
565 |
} |
|
566 |
||
967 | 567 |
if (*line != COMMAND_CHAR) { |
288 | 568 |
// This isn't a command |
569 |
if (scr_get_multimode()) |
|
570 |
scr_append_multiline(line); |
|
571 |
else |
|
1740
391863b7952c
Rename do_say_internal() and export it as say_cmd()
Mikael Berthe <mikael@lilotux.net>
parents:
1737
diff
changeset
|
572 |
say_cmd((char*)line, 0); |
288 | 573 |
return 0; |
574 |
} |
|
575 |
||
1187
16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
Mikael Berthe <mikael@lilotux.net>
parents:
1181
diff
changeset
|
576 |
/* 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
|
577 |
return process_command(line, FALSE); |
288 | 578 |
} |
579 |
||
1350
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
580 |
// 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
|
581 |
// "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
|
582 |
static void roster_buddylock(char *bjid, int lock) |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
583 |
{ |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
584 |
gpointer bud = NULL; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
585 |
bool may_need_refresh = FALSE; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
586 |
|
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
587 |
// Allow special jid "" or "." (current buddy) |
1058 | 588 |
if (bjid && (!*bjid || !strcmp(bjid, "."))) |
589 |
bjid = NULL; |
|
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
590 |
|
1058 | 591 |
if (bjid) { |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
592 |
// The JID has been specified. Quick check... |
1058 | 593 |
if (check_jid_syntax(bjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
594 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
595 |
"<%s> is not a valid Jabber ID.", bjid); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
596 |
} else { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
597 |
// Find the buddy |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
598 |
GSList *roster_elt; |
1058 | 599 |
roster_elt = roster_find(bjid, jidsearch, |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
600 |
ROSTER_TYPE_USER|ROSTER_TYPE_ROOM); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
601 |
if (roster_elt) |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
602 |
bud = roster_elt->data; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
603 |
else |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
604 |
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
|
605 |
may_need_refresh = TRUE; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
606 |
} |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
607 |
} else { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
608 |
// Use the current buddy |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
609 |
if (current_buddy) |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
610 |
bud = BUDDATA(current_buddy); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
611 |
} |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
612 |
|
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
613 |
// Update the ROSTER_FLAG_USRLOCK flag |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
614 |
if (bud) { |
1350
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
615 |
if (lock == -1) |
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
616 |
lock = !(buddy_getflags(bud) & ROSTER_FLAG_USRLOCK); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
617 |
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
|
618 |
if (may_need_refresh) { |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
619 |
buddylist_build(); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
620 |
update_roster = TRUE; |
1350
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
621 |
} |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
622 |
} |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
623 |
} |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
624 |
|
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
625 |
static void roster_resourcelock(char *jidres, gboolean lock) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
626 |
gpointer bud = NULL; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
627 |
char *resource = NULL; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
628 |
|
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
629 |
if (!jidres) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
630 |
if (lock) return; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
631 |
jidres = "."; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
632 |
} |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
633 |
|
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
634 |
if (jidres[0] == '.' && |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
635 |
(jidres[1] == '\0' || jidres[1] == JID_RESOURCE_SEPARATOR)) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
636 |
//Special jid: . or ./resource |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
637 |
switch (jidres[1]) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
638 |
case JID_RESOURCE_SEPARATOR: |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
639 |
resource = jidres+2; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
640 |
case '\0': |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
641 |
if (current_buddy) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
642 |
bud = BUDDATA(current_buddy); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
643 |
} |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
644 |
} else { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
645 |
char *tmp; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
646 |
if (!check_jid_syntax(jidres) && |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
647 |
(tmp = strchr(jidres, JID_RESOURCE_SEPARATOR))) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
648 |
//Any other valid full jid |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
649 |
*tmp = '\0'; // for roster search by bare jid; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
650 |
resource = tmp+1; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
651 |
GSList *roster_elt; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
652 |
roster_elt = roster_find(jidres, jidsearch, |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
653 |
ROSTER_TYPE_USER|ROSTER_TYPE_AGENT); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
654 |
if (roster_elt) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
655 |
bud = roster_elt->data; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
656 |
*tmp = JID_RESOURCE_SEPARATOR; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
657 |
} |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
658 |
if (!bud) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
659 |
//Resource for current buddy |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
660 |
if (current_buddy) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
661 |
bud = BUDDATA(current_buddy); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
662 |
resource = jidres; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
663 |
} |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
664 |
} |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
665 |
|
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
666 |
if (bud && buddy_gettype(bud) & (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT)) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
667 |
if (lock) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
668 |
GSList *resources, *p_res; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
669 |
gboolean found = FALSE; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
670 |
resources = buddy_getresources(bud); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
671 |
for (p_res = resources ; p_res ; p_res = g_slist_next(p_res)) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
672 |
if (!g_strcmp0((char*)p_res->data, resource)) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
673 |
found = TRUE; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
674 |
g_free(p_res->data); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
675 |
} |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
676 |
g_slist_free(resources); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
677 |
if (!found) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
678 |
scr_LogPrint(LPRINT_NORMAL, "No such resource <%s>...", jidres); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
679 |
return; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
680 |
} |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
681 |
} else { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
682 |
resource = NULL; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
683 |
} |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
684 |
buddy_setactiveresource(bud, resource); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
685 |
scr_update_chat_status(TRUE); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
686 |
} |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
687 |
} |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
688 |
// display_and_free_note(note, winId) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
689 |
// 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
|
690 |
// (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
|
691 |
// display the note jid too) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
692 |
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
|
693 |
{ |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
694 |
gchar tbuf[128]; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
695 |
GString *sbuf; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
696 |
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
|
697 |
/* 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
|
698 |
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
|
699 |
|
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
700 |
if (!note) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
701 |
return; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
702 |
|
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
703 |
sbuf = g_string_new(""); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
704 |
|
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
705 |
if (!winId) { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
706 |
// 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
|
707 |
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
|
708 |
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
|
709 |
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
|
710 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
711 |
|
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
712 |
// 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
|
713 |
if (note->cdate) { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
714 |
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
|
715 |
localtime(¬e->cdate)); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
716 |
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
|
717 |
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
|
718 |
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
|
719 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
720 |
// 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
|
721 |
// 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
|
722 |
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
|
723 |
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
|
724 |
localtime(¬e->mdate)); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
725 |
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
|
726 |
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
|
727 |
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
|
728 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
729 |
// Note text |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
730 |
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
|
731 |
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
|
732 |
|
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
733 |
g_string_free(sbuf, TRUE); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
734 |
g_free(note->text); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
735 |
g_free(note->jid); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
736 |
g_free(note); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
737 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
738 |
|
1059 | 739 |
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
|
740 |
{ |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
741 |
GSList *notes; |
1598 | 742 |
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
|
743 |
|
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
744 |
if (!notes) |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
745 |
return; |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
746 |
|
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
747 |
// 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
|
748 |
// with winId = NULL (special window) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
749 |
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
|
750 |
scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
1815
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
751 |
scr_setattentionflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE, |
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
752 |
ROSTER_UI_PRIO_STATUS_WIN_MESSAGE, prio_max); |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
753 |
g_slist_free(notes); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
754 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
755 |
|
1016 | 756 |
static void roster_note(char *arg) |
757 |
{ |
|
1058 | 758 |
const char *bjid; |
1016 | 759 |
guint type; |
760 |
||
761 |
if (!current_buddy) |
|
762 |
return; |
|
763 |
||
1058 | 764 |
bjid = buddy_getjid(BUDDATA(current_buddy)); |
1016 | 765 |
type = buddy_gettype(BUDDATA(current_buddy)); |
766 |
||
1058 | 767 |
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
|
768 |
// 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
|
769 |
// Let's display all server notes |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
770 |
display_all_annotations(); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
771 |
return; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
772 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
773 |
|
1058 | 774 |
if (!bjid || (type != ROSTER_TYPE_USER && |
1016 | 775 |
type != ROSTER_TYPE_ROOM && |
776 |
type != ROSTER_TYPE_AGENT)) { |
|
777 |
scr_LogPrint(LPRINT_NORMAL, "This item can't have a note."); |
|
778 |
return; |
|
779 |
} |
|
780 |
||
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
781 |
if (arg && *arg) { // Set a note |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
782 |
gchar *msg, *notetxt; |
1016 | 783 |
msg = to_utf8(arg); |
784 |
if (!strcmp(msg, "-")) |
|
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
785 |
notetxt = NULL; // delete note |
1016 | 786 |
else |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
787 |
notetxt = msg; |
1598 | 788 |
xmpp_set_storage_rosternotes(bjid, notetxt); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
789 |
g_free(msg); |
1016 | 790 |
} else { // Display a note |
1598 | 791 |
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
|
792 |
if (note) { |
1058 | 793 |
display_and_free_note(note, bjid); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
794 |
} else { |
1058 | 795 |
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
|
796 |
HBB_PREFIX_INFO, 0); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
797 |
} |
1016 | 798 |
} |
799 |
} |
|
800 |
||
1577
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
801 |
// roster_updown(updown, nitems) |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
802 |
// updown: -1=up, +1=down |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
803 |
inline static void roster_updown(int updown, char *nitems) |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
804 |
{ |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
805 |
int nbitems; |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
806 |
|
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
807 |
if (!nitems || !*nitems) |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
808 |
nbitems = 1; |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
809 |
else |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
810 |
nbitems = strtol(nitems, NULL, 10); |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
811 |
|
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
812 |
if (nbitems > 0) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
813 |
scr_roster_up_down(updown, nbitems); |
1577
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
814 |
} |
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
815 |
|
104 | 816 |
/* Commands callback functions */ |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
817 |
/* 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
|
818 |
/* (with arg not null) */ |
104 | 819 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
820 |
static void do_roster(char *arg) |
104 | 821 |
{ |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
822 |
char **paramlst; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
823 |
char *subcmd; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
824 |
|
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
825 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
826 |
subcmd = *paramlst; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
827 |
arg = *(paramlst+1); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
828 |
|
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
829 |
if (!subcmd || !*subcmd) { |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
830 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
831 |
free_arg_lst(paramlst); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
832 |
return; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
833 |
} |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
834 |
|
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
835 |
if (!strcasecmp(subcmd, "top")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
836 |
scr_roster_top(); |
128 | 837 |
update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
838 |
} else if (!strcasecmp(subcmd, "bottom")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
839 |
scr_roster_bottom(); |
128 | 840 |
update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
841 |
} else if (!strcasecmp(subcmd, "hide")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
842 |
scr_roster_visibility(0); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
843 |
} else if (!strcasecmp(subcmd, "show")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
844 |
scr_roster_visibility(1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
845 |
} else if (!strcasecmp(subcmd, "toggle")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
846 |
scr_roster_visibility(-1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
847 |
} else if (!strcasecmp(subcmd, "hide_offline")) { |
120 | 848 |
buddylist_set_hide_offline_buddies(TRUE); |
104 | 849 |
if (current_buddy) |
850 |
buddylist_build(); |
|
128 | 851 |
update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
852 |
} else if (!strcasecmp(subcmd, "show_offline")) { |
120 | 853 |
buddylist_set_hide_offline_buddies(FALSE); |
124 | 854 |
buddylist_build(); |
128 | 855 |
update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
856 |
} else if (!strcasecmp(subcmd, "toggle_offline")) { |
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
857 |
buddylist_set_hide_offline_buddies(-1); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
858 |
buddylist_build(); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
859 |
update_roster = TRUE; |
1311
0dda8238af21
Implement "/roster display"
Mikael Berthe <mikael@lilotux.net>
parents:
1305
diff
changeset
|
860 |
} else if (!strcasecmp(subcmd, "display")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
861 |
scr_roster_display(arg); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
862 |
} 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
|
863 |
roster_buddylock(arg, 1); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
864 |
} 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
|
865 |
roster_buddylock(arg, 0); |
096411233fce
Add /roster item_toggle_lock (suggested by Wolfram S.)
Mikael Berthe <mikael@lilotux.net>
parents:
1347
diff
changeset
|
866 |
} 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
|
867 |
roster_buddylock(arg, -1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
868 |
} else if (!strcasecmp(subcmd, "unread_first")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
869 |
scr_roster_unread_message(0); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
870 |
} else if (!strcasecmp(subcmd, "unread_next")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
871 |
scr_roster_unread_message(1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
872 |
} else if (!strcasecmp(subcmd, "alternate")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
873 |
scr_roster_jump_alternate(); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
874 |
} else if (!strncasecmp(subcmd, "search", 6)) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
875 |
strip_arg_special_chars(arg); |
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
876 |
if (!arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
877 |
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
|
878 |
free_arg_lst(paramlst); |
265 | 879 |
return; |
880 |
} |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
881 |
scr_roster_search(arg); |
265 | 882 |
update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
883 |
} else if (!strcasecmp(subcmd, "up")) { |
1577
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
884 |
roster_updown(-1, arg); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
885 |
} else if (!strcasecmp(subcmd, "down")) { |
1577
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
886 |
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
|
887 |
} else if (!strcasecmp(subcmd, "group_prev")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
888 |
scr_roster_prev_group(); |
1086
5e2e647e781b
Add command /roster group_prev|group_next and update documentation
Mikael Berthe <mikael@lilotux.net>
parents:
1074
diff
changeset
|
889 |
} else if (!strcasecmp(subcmd, "group_next")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
890 |
scr_roster_next_group(); |
1016 | 891 |
} else if (!strcasecmp(subcmd, "note")) { |
892 |
roster_note(arg); |
|
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
893 |
} else if (!strcasecmp(subcmd, "resource_lock")) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
894 |
roster_resourcelock(arg, TRUE); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
895 |
} else if (!strcasecmp(subcmd, "resource_unlock")) { |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
896 |
roster_resourcelock(arg, FALSE); |
104 | 897 |
} else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
898 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
899 |
free_arg_lst(paramlst); |
104 | 900 |
} |
108 | 901 |
|
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
902 |
void do_color(char *arg) |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
903 |
{ |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
904 |
char **paramlst; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
905 |
char *subcmd; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
906 |
|
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
907 |
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
|
908 |
subcmd = *paramlst; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
909 |
arg = *(paramlst+1); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
910 |
|
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
911 |
if (!subcmd || !*subcmd) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
912 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
913 |
free_arg_lst(paramlst); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
914 |
return; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
915 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
916 |
|
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
917 |
if (!strcasecmp(subcmd, "roster")) { |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
918 |
char *status, *wildcard, *color; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
919 |
char **arglist = split_arg(arg, 3, 0); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
920 |
|
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
921 |
status = *arglist; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
922 |
wildcard = to_utf8(arglist[1]); |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
923 |
color = arglist[2]; |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
924 |
|
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
925 |
if (status && !strcmp(status, "clear")) { // Not a color command, clear all |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
926 |
scr_roster_clear_color(); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
927 |
update_roster = TRUE; |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
928 |
} else { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
929 |
if (!status || !*status || !wildcard || !*wildcard || !color || !*color) { |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
930 |
scr_LogPrint(LPRINT_NORMAL, "Missing argument"); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
931 |
} else { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
932 |
update_roster = scr_roster_color(status, wildcard, color) || |
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
933 |
update_roster; |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
934 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
935 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
936 |
free_arg_lst(arglist); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
937 |
g_free(wildcard); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
938 |
} else if (!strcasecmp(subcmd, "muc")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
939 |
char **arglist = split_arg(arg, 2, 0); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
940 |
char *free_muc = to_utf8(*arglist); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
941 |
const char *muc = free_muc, *mode = arglist[1]; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
942 |
if (!muc || !*muc) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
943 |
scr_LogPrint(LPRINT_NORMAL, "What MUC?"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
944 |
else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
945 |
if (!strcmp(muc, ".")) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
946 |
if (!(muc = CURRENT_JID)) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
947 |
scr_LogPrint(LPRINT_NORMAL, "No JID selected"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
948 |
if (muc) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
949 |
if (check_jid_syntax(muc) && strcmp(muc, "*")) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
950 |
scr_LogPrint(LPRINT_NORMAL, "Not a JID"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
951 |
else { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
952 |
if (!mode || !*mode || !strcasecmp(mode, "on")) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
953 |
scr_muc_color(muc, MC_ALL); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
954 |
else if (!strcasecmp(mode, "preset")) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
955 |
scr_muc_color(muc, MC_PRESET); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
956 |
else if (!strcasecmp(mode, "off")) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
957 |
scr_muc_color(muc, MC_OFF); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
958 |
else if (!strcmp(mode, "-")) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
959 |
scr_muc_color(muc, MC_REMOVE); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
960 |
else |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
961 |
scr_LogPrint(LPRINT_NORMAL, "Unknown coloring mode"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
962 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
963 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
964 |
} |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
965 |
free_arg_lst(arglist); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
966 |
g_free(free_muc); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
967 |
} else if (!strcasecmp(subcmd, "mucnick")) { |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
968 |
char **arglist = split_arg(arg, 2, 0); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
969 |
const char *nick = *arglist, *color = arglist[1]; |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
970 |
if (!nick || !*nick || !color || !*color) |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
971 |
scr_LogPrint(LPRINT_NORMAL, "Missing argument"); |
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
972 |
else |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
973 |
scr_muc_nick_color(nick, color); |
1292
382ec54b584e
Muc nick coloring functionality
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1290
diff
changeset
|
974 |
free_arg_lst(arglist); |
1272
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
975 |
} else |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
976 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
977 |
free_arg_lst(paramlst); |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
978 |
} |
033576acac4c
Add configurable roster colors (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
979 |
|
1415
317f8d181626
Rename command public functions
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
980 |
// cmd_setstatus(recipient, arg) |
444 | 981 |
// Set your Jabber status. |
982 |
// - if recipient is not NULL, the status is sent to this contact only |
|
983 |
// - arg must be "status message" (message is optional) |
|
1415
317f8d181626
Rename command public functions
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
984 |
void cmd_setstatus(const char *recipient, const char *arg) |
116 | 985 |
{ |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
986 |
char **paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
987 |
char *status; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
988 |
char *msg; |
116 | 989 |
enum imstatus st; |
990 |
||
1732
4e57d6275a86
Allow status command in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
991 |
if (!xmpp_is_online()) |
4e57d6275a86
Allow status command in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
992 |
scr_LogPrint(LPRINT_NORMAL, "You are currently not connected..."); |
4e57d6275a86
Allow status command in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
993 |
// We do not return now, so that the status is memorized and used later... |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
994 |
|
1428
5667048423db
Reset auto-away before changing the status
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
995 |
// 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
|
996 |
// (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
|
997 |
// unexpected... |
1429
99d95d4ea806
No need to explicitly reset auto-away for directed presence messages
Mikael Berthe <mikael@lilotux.net>
parents:
1428
diff
changeset
|
998 |
if (!recipient) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
999 |
scr_check_auto_away(TRUE); |
1428
5667048423db
Reset auto-away before changing the status
Mikael Berthe <mikael@lilotux.net>
parents:
1424
diff
changeset
|
1000 |
|
1368
23afeb5c555b
Don't strip quotes from a status message (Suggested by bb)
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
1001 |
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
|
1002 |
status = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1003 |
msg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1004 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1005 |
if (!status) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1006 |
free_arg_lst(paramlst); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1007 |
return; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1008 |
} |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
1009 |
|
967 | 1010 |
if (!strcasecmp(status, IMSTATUS_OFFLINE)) st = offline; |
1011 |
else if (!strcasecmp(status, IMSTATUS_ONLINE)) st = available; |
|
1012 |
else if (!strcasecmp(status, IMSTATUS_AVAILABLE)) st = available; |
|
1013 |
else if (!strcasecmp(status, IMSTATUS_AWAY)) st = away; |
|
1972
45f0f0f60656
Remove deprecated status invisible
Mikael Berthe <mikael@lilotux.net>
parents:
1959
diff
changeset
|
1014 |
#ifdef WITH_DEPRECATED_STATUS_INVISIBLE |
967 | 1015 |
else if (!strcasecmp(status, IMSTATUS_INVISIBLE)) st = invisible; |
1972
45f0f0f60656
Remove deprecated status invisible
Mikael Berthe <mikael@lilotux.net>
parents:
1959
diff
changeset
|
1016 |
#endif |
967 | 1017 |
else if (!strcasecmp(status, IMSTATUS_DONOTDISTURB)) st = dontdisturb; |
1018 |
else if (!strcasecmp(status, IMSTATUS_NOTAVAILABLE)) st = notavail; |
|
1019 |
else if (!strcasecmp(status, IMSTATUS_FREE4CHAT)) st = freeforchat; |
|
1463
477581e3b95e
"status message" expects a message
Mikael Berthe <mikael@lilotux.net>
parents:
1462
diff
changeset
|
1020 |
else if (!strcasecmp(status, "message")) { |
477581e3b95e
"status message" expects a message
Mikael Berthe <mikael@lilotux.net>
parents:
1462
diff
changeset
|
1021 |
if (!msg || !*msg) { |
477581e3b95e
"status message" expects a message
Mikael Berthe <mikael@lilotux.net>
parents:
1462
diff
changeset
|
1022 |
// 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
|
1023 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
477581e3b95e
"status message" expects a message
Mikael Berthe <mikael@lilotux.net>
parents:
1462
diff
changeset
|
1024 |
free_arg_lst(paramlst); |
477581e3b95e
"status message" expects a message
Mikael Berthe <mikael@lilotux.net>
parents:
1462
diff
changeset
|
1025 |
return; |
477581e3b95e
"status message" expects a message
Mikael Berthe <mikael@lilotux.net>
parents:
1462
diff
changeset
|
1026 |
} |
1598 | 1027 |
st = xmpp_getstatus(); // Preserve current status |
1463
477581e3b95e
"status message" expects a message
Mikael Berthe <mikael@lilotux.net>
parents:
1462
diff
changeset
|
1028 |
} else { |
444 | 1029 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized status!"); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1030 |
free_arg_lst(paramlst); |
116 | 1031 |
return; |
1032 |
} |
|
1033 |
||
677
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
1034 |
// Use provided message |
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
1035 |
if (msg && !*msg) { |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
1036 |
msg = NULL; |
677
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
1037 |
} |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
1038 |
|
528
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
1039 |
// 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
|
1040 |
if (recipient && !msg) |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
1041 |
msg = ""; |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
1042 |
|
1598 | 1043 |
xmpp_setstatus(st, recipient, msg, FALSE); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1044 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1045 |
free_arg_lst(paramlst); |
444 | 1046 |
} |
1047 |
||
1048 |
static void do_status(char *arg) |
|
1049 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1050 |
if (!*arg) { |
1598 | 1051 |
const char *sm = xmpp_getstatusmsg(); |
519
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
1052 |
scr_LogPrint(LPRINT_NORMAL, "Your status is: [%c] %s", |
1598 | 1053 |
imstatus2char[xmpp_getstatus()], |
519
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
1054 |
(sm ? sm : "")); |
444 | 1055 |
return; |
1056 |
} |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1057 |
arg = to_utf8(arg); |
1415
317f8d181626
Rename command public functions
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
1058 |
cmd_setstatus(NULL, arg); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1059 |
g_free(arg); |
444 | 1060 |
} |
1061 |
||
1062 |
static void do_status_to(char *arg) |
|
1063 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1064 |
char **paramlst; |
1058 | 1065 |
char *fjid, *st, *msg; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1066 |
char *jid_utf8 = NULL; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1067 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1068 |
paramlst = split_arg(arg, 3, 1); // jid, status, [message] |
1058 | 1069 |
fjid = *paramlst; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1070 |
st = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1071 |
msg = *(paramlst+2); |
444 | 1072 |
|
1058 | 1073 |
if (!fjid || !st) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1074 |
scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1075 |
"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
|
1076 |
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
|
1077 |
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
|
1078 |
} |
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
|
1079 |
|
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
|
1080 |
// Allow things like /status_to "" away |
1058 | 1081 |
if (!*fjid || !strcmp(fjid, ".")) |
1082 |
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
|
1083 |
|
1058 | 1084 |
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
|
1085 |
// The JID has been specified. Quick check... |
1058 | 1086 |
if (check_jid_syntax(fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1087 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1088 |
"<%s> is not a valid Jabber ID.", fjid); |
1058 | 1089 |
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
|
1090 |
} else { |
696
ee06382dfb22
/status_to: Do not convert resource name to lower case
Mikael Berthe <mikael@lilotux.net>
parents:
694
diff
changeset
|
1091 |
// Convert jid to lowercase |
1058 | 1092 |
char *p = fjid; |
977
5b01de4ac5e1
Cosmetic changes
Alexis Hildebrandt <afh [at] 2drop [dot] net>
parents:
974
diff
changeset
|
1093 |
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
|
1094 |
*p = tolower(*p); |
1058 | 1095 |
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
|
1096 |
} |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1097 |
} 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
|
1098 |
// 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
|
1099 |
if (current_buddy) |
1058 | 1100 |
fjid = (char*)buddy_getjid(BUDDATA(current_buddy)); |
1101 |
if (!fjid) |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1102 |
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
|
1103 |
} |
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
|
1104 |
|
1058 | 1105 |
if (fjid) { |
1106 |
char *cmdline; |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1107 |
if (!msg) |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1108 |
msg = ""; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1109 |
msg = to_utf8(msg); |
1058 | 1110 |
cmdline = g_strdup_printf("%s %s", st, msg); |
1111 |
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
|
1112 |
cmd_setstatus(fjid, cmdline); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1113 |
g_free(msg); |
1058 | 1114 |
g_free(cmdline); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1115 |
g_free(jid_utf8); |
444 | 1116 |
} |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1117 |
free_arg_lst(paramlst); |
116 | 1118 |
} |
1119 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1120 |
static void do_add(char *arg) |
124 | 1121 |
{ |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1122 |
char **paramlst; |
244 | 1123 |
char *id, *nick; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1124 |
char *jid_utf8 = NULL; |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1125 |
|
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
1126 |
if (!xmpp_is_online()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1127 |
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
|
1128 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1129 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1130 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1131 |
paramlst = split_arg(arg, 2, 0); // jid, [nickname] |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1132 |
id = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1133 |
nick = *(paramlst+1); |
244 | 1134 |
|
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
|
1135 |
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
|
1136 |
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
|
1137 |
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
|
1138 |
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
|
1139 |
|
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
|
1140 |
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
|
1141 |
// 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
|
1142 |
if (check_jid_syntax(id)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1143 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1144 |
"<%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
|
1145 |
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
|
1146 |
} 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
|
1147 |
mc_strtolower(id); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1148 |
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
|
1149 |
} |
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
|
1150 |
} 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
|
1151 |
// 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
|
1152 |
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
|
1153 |
id = (char*)buddy_getjid(BUDDATA(current_buddy)); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1154 |
if (!id) |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1155 |
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
|
1156 |
} |
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
|
1157 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1158 |
if (nick) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1159 |
nick = to_utf8(nick); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1160 |
|
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
|
1161 |
if (id) { |
452 | 1162 |
// 2nd parameter = optional nickname |
1598 | 1163 |
xmpp_addbuddy(id, nick, NULL); |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1164 |
scr_LogPrint(LPRINT_LOGNORM, "Sent presence notification request to <%s>.", |
452 | 1165 |
id); |
1166 |
} |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1167 |
|
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1168 |
g_free(jid_utf8); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1169 |
g_free(nick); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1170 |
free_arg_lst(paramlst); |
124 | 1171 |
} |
128 | 1172 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1173 |
static void do_del(char *arg) |
206 | 1174 |
{ |
1058 | 1175 |
const char *bjid; |
206 | 1176 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1177 |
if (*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1178 |
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
|
1179 |
"the currently-selected buddy will be deleted."); |
206 | 1180 |
return; |
1181 |
} |
|
1182 |
||
1058 | 1183 |
if (!current_buddy) |
1184 |
return; |
|
1185 |
bjid = buddy_getjid(BUDDATA(current_buddy)); |
|
1186 |
if (!bjid) |
|
1187 |
return; |
|
206 | 1188 |
|
540
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1189 |
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
|
1190 |
// This is a chatroom |
652
b243d3b3ff1b
We do not need buddy_isresource() anymore
Mikael Berthe <mikael@lilotux.net>
parents:
650
diff
changeset
|
1191 |
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
|
1192 |
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
|
1193 |
return; |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1194 |
} |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1195 |
} |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1196 |
|
1165
d5b26a0a9771
Close a buffer when using /del
Mikael Berthe <mikael@lilotux.net>
parents:
1163
diff
changeset
|
1197 |
// Close the buffer |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1198 |
scr_buffer_purge(1, NULL); |
1165
d5b26a0a9771
Close a buffer when using /del
Mikael Berthe <mikael@lilotux.net>
parents:
1163
diff
changeset
|
1199 |
|
1058 | 1200 |
scr_LogPrint(LPRINT_LOGNORM, "Removing <%s>...", bjid); |
1598 | 1201 |
xmpp_delbuddy(bjid); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1202 |
scr_update_buddy_window(); |
206 | 1203 |
} |
1204 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1205 |
static void do_group(char *arg) |
128 | 1206 |
{ |
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1207 |
gpointer group = NULL; |
958
30b799632653
Cosmetics (change a variable name)
Mikael Berthe <mikael@lilotux.net>
parents:
957
diff
changeset
|
1208 |
guint leave_buddywindow; |
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1209 |
char **paramlst; |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1210 |
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
|
1211 |
enum { group_toggle = -1, group_unfold = 0, group_fold = 1 } group_state = 0; |
128 | 1212 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1213 |
if (!*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1214 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
128 | 1215 |
return; |
1216 |
} |
|
1217 |
||
1058 | 1218 |
if (!current_buddy) |
1219 |
return; |
|
128 | 1220 |
|
1508
86620c83123b
Handle quotes in group commands
Mikael Berthe <mikael@lilotux.net>
parents:
1507
diff
changeset
|
1221 |
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
|
1222 |
subcmd = *paramlst; |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1223 |
arg = *(paramlst+1); |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1224 |
|
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1225 |
if (!subcmd || !*subcmd) |
2016
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1226 |
goto do_group_return; // Should not happen |
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1227 |
|
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1228 |
if (!strcasecmp(subcmd, "expand") || !strcasecmp(subcmd, "unfold")) |
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1229 |
group_state = group_unfold; |
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1230 |
else if (!strcasecmp(subcmd, "shrink") || !strcasecmp(subcmd, "fold")) |
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1231 |
group_state = group_fold; |
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1232 |
else if (!strcasecmp(subcmd, "toggle")) |
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1233 |
group_state = group_toggle; |
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1234 |
else { |
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1235 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1236 |
goto do_group_return; |
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1237 |
} |
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1238 |
|
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1239 |
if (arg && *arg) { |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1240 |
GSList *roster_elt; |
1506
8a63d4514503
Fix encoding issue in /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1503
diff
changeset
|
1241 |
char *group_utf8 = to_utf8(arg); |
8a63d4514503
Fix encoding issue in /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1503
diff
changeset
|
1242 |
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
|
1243 |
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
|
1244 |
if (roster_elt) |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1245 |
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
|
1246 |
} else { |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1247 |
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
|
1248 |
} |
2016
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1249 |
if (!group) { |
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1250 |
scr_LogPrint(LPRINT_NORMAL, "Group not found."); |
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1251 |
goto do_group_return; |
2016
e9b6e168a45e
Improve checks for /group command parameters
Mikael Berthe <mikael@lilotux.net>
parents:
2013
diff
changeset
|
1252 |
} |
853
bdd526ec62bc
Fix segfault when using /group with the [status] entry
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
1253 |
|
212 | 1254 |
// We'll have to redraw the chat window if we're not currently on the group |
1255 |
// entry itself, because it means we'll have to leave the current buddy |
|
1256 |
// chat window. |
|
1360 | 1257 |
leave_buddywindow = (group != BUDDATA(current_buddy) && |
1258 |
group == buddy_getgroup(BUDDATA(current_buddy))); |
|
1259 |
||
128 | 1260 |
if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1261 |
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
|
1262 |
goto do_group_return; |
128 | 1263 |
} |
166 | 1264 |
|
1360 | 1265 |
if (group_state != group_unfold && leave_buddywindow) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1266 |
scr_roster_prev_group(); |
1360 | 1267 |
|
1410
0cb4361c85a7
Pressing enter when a group is selected will toggle the fold status (franky)
Mikael Berthe <mikael@lilotux.net>
parents:
1395
diff
changeset
|
1268 |
buddy_hide_group(group, group_state); |
1360 | 1269 |
|
128 | 1270 |
buddylist_build(); |
1271 |
update_roster = TRUE; |
|
1351
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1272 |
|
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1273 |
do_group_return: |
43e777a5ff06
The group name can be specified in the /group command
Mikael Berthe <mikael@lilotux.net>
parents:
1350
diff
changeset
|
1274 |
free_arg_lst(paramlst); |
128 | 1275 |
} |
1276 |
||
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1277 |
static int send_message_to(const char *fjid, const char *msg, const char *subj, |
1598 | 1278 |
LmMessageSubType type_overwrite, bool quiet) |
636 | 1279 |
{ |
1280 |
char *bare_jid, *rp; |
|
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1281 |
char *hmsg; |
1197 | 1282 |
gint crypted; |
1283 |
gint retval = 0; |
|
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1284 |
int isroom; |
1602 | 1285 |
gpointer xep184 = NULL; |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1286 |
|
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
1287 |
if (!xmpp_is_online()) { |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1288 |
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
|
1289 |
return 1; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1290 |
} |
1058 | 1291 |
if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1292 |
scr_LogPrint(LPRINT_NORMAL, "You must specify a Jabber ID."); |
636 | 1293 |
return 1; |
1294 |
} |
|
1295 |
if (!msg || !*msg) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1296 |
scr_LogPrint(LPRINT_NORMAL, "You must specify a message."); |
636 | 1297 |
return 1; |
1298 |
} |
|
1058 | 1299 |
if (check_jid_syntax((char*)fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1300 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
1301 |
"<%s> is not a valid Jabber ID.", fjid); |
636 | 1302 |
return 1; |
1303 |
} |
|
1304 |
||
1305 |
// We must use the bare jid in hk_message_out() |
|
1058 | 1306 |
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
|
1307 |
if (rp) |
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1308 |
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
|
1309 |
else |
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1310 |
bare_jid = (char*)fjid; |
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1311 |
|
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1312 |
if (!quiet) { |
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1313 |
// Jump to window, create one if needed |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1314 |
scr_roster_jump_jid(bare_jid); |
1430
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1315 |
} |
636 | 1316 |
|
1317 |
// Check if we're sending a message to a conference room |
|
1318 |
// 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
|
1319 |
isroom = !!roster_find(bare_jid, jidsearch, ROSTER_TYPE_ROOM); |
636 | 1320 |
if (rp) { |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1321 |
if (isroom) rp++; |
636 | 1322 |
else rp = NULL; |
1323 |
} |
|
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1324 |
isroom = isroom && (!rp || !*rp); |
636 | 1325 |
|
1326 |
// local part (UI, logging, etc.) |
|
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1327 |
if (subj) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1328 |
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
|
1329 |
else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1330 |
hmsg = (char*)msg; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1331 |
|
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
1332 |
// Network part |
1598 | 1333 |
xmpp_send_msg(fjid, msg, (isroom ? ROSTER_TYPE_ROOM : ROSTER_TYPE_USER), |
1602 | 1334 |
subj, FALSE, &crypted, type_overwrite, &xep184); |
636 | 1335 |
|
1197 | 1336 |
if (crypted == -1) { |
1337 |
scr_LogPrint(LPRINT_LOGNORM, "Encryption error. Message was not sent."); |
|
1338 |
retval = 1; |
|
1339 |
goto send_message_to_return; |
|
1340 |
} |
|
1341 |
||
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
1342 |
// Hook |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
1343 |
if (!isroom) |
1602 | 1344 |
hk_message_out(bare_jid, rp, 0, hmsg, crypted, xep184); |
1197 | 1345 |
|
1346 |
send_message_to_return: |
|
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
1347 |
if (hmsg != msg) g_free(hmsg); |
636 | 1348 |
if (rp) g_free(bare_jid); |
1197 | 1349 |
return retval; |
636 | 1350 |
} |
1351 |
||
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1352 |
// 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
|
1353 |
// 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
|
1354 |
// the network. |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1355 |
static void send_message(const char *msg, const char *subj, |
1598 | 1356 |
LmMessageSubType type_overwrite) |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1357 |
{ |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1358 |
const char *bjid; |
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
1359 |
char *jid; |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
1360 |
const char *activeres; |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1361 |
|
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1362 |
if (!current_buddy) { |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1363 |
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
|
1364 |
return; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1365 |
} |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1366 |
|
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1367 |
bjid = CURRENT_JID; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1368 |
if (!bjid) { |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1369 |
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
|
1370 |
return; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1371 |
} |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1372 |
|
2013
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
1373 |
activeres = buddy_getactiveresource(BUDDATA(current_buddy)); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
1374 |
if (activeres) |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
1375 |
jid = g_strdup_printf("%s/%s", bjid, activeres); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
1376 |
else |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
1377 |
jid = g_strdup(bjid); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
1378 |
|
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
1379 |
send_message_to(jid, msg, subj, type_overwrite, FALSE); |
8dc418af3e72
Allow to select to which buddy resource messages go. Closes issue #55
Hermitifier
parents:
2010
diff
changeset
|
1380 |
g_free(jid); |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1381 |
} |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1382 |
|
1598 | 1383 |
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
|
1384 |
{ |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1726
diff
changeset
|
1385 |
// Try splitting it |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1386 |
char **parlist = split_arg(*arg, 2, 1); |
1598 | 1387 |
LmMessageSubType result = LM_MESSAGE_SUB_TYPE_NOT_SET; |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1726
diff
changeset
|
1388 |
// Is it a good parameter? |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
1389 |
if (parlist && *parlist) { |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
1390 |
if (!strcmp("-n", *parlist)) { |
1598 | 1391 |
result = LM_MESSAGE_SUB_TYPE_NORMAL; |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
1392 |
} else if (!strcmp("-h", *parlist)) { |
1598 | 1393 |
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
|
1394 |
} |
1598 | 1395 |
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
|
1396 |
*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
|
1397 |
} |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1726
diff
changeset
|
1398 |
// Anything found? -> skip it |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1399 |
free_arg_lst(parlist); |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1400 |
return result; |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1401 |
} |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1402 |
|
1740
391863b7952c
Rename do_say_internal() and export it as say_cmd()
Mikael Berthe <mikael@lilotux.net>
parents:
1737
diff
changeset
|
1403 |
void say_cmd(char *arg, int parse_flags) |
132 | 1404 |
{ |
164 | 1405 |
gpointer bud; |
1598 | 1406 |
LmMessageSubType msgtype = LM_MESSAGE_SUB_TYPE_NOT_SET; |
132 | 1407 |
|
1408 |
scr_set_chatmode(TRUE); |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1409 |
scr_show_buddy_window(); |
164 | 1410 |
|
1411 |
if (!current_buddy) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1412 |
scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1413 |
"Whom are you talking to? Please select a buddy."); |
164 | 1414 |
return; |
132 | 1415 |
} |
164 | 1416 |
|
1417 |
bud = BUDDATA(current_buddy); |
|
631
423c24e5875a
Allow sending a message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
626
diff
changeset
|
1418 |
if (!(buddy_gettype(bud) & |
423c24e5875a
Allow sending a message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
626
diff
changeset
|
1419 |
(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
|
1420 |
scr_LogPrint(LPRINT_NORMAL, "This is not a user."); |
164 | 1421 |
return; |
1422 |
} |
|
1423 |
||
1424 |
buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); |
|
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
1425 |
if (parse_flags) |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1426 |
msgtype = scan_mtype(&arg); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1427 |
arg = to_utf8(arg); |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1428 |
send_message(arg, NULL, msgtype); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1429 |
g_free(arg); |
132 | 1430 |
} |
1431 |
||
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1432 |
static void do_say(char *arg) { |
1740
391863b7952c
Rename do_say_internal() and export it as say_cmd()
Mikael Berthe <mikael@lilotux.net>
parents:
1737
diff
changeset
|
1433 |
say_cmd(arg, 1); |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1434 |
} |
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1435 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1436 |
static void do_msay(char *arg) |
238 | 1437 |
{ |
636 | 1438 |
/* Parameters: begin verbatim abort send send_to */ |
1439 |
char **paramlst; |
|
1440 |
char *subcmd; |
|
1441 |
||
1442 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
|
1443 |
subcmd = *paramlst; |
|
1444 |
arg = *(paramlst+1); |
|
238 | 1445 |
|
636 | 1446 |
if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1447 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
636 | 1448 |
scr_LogPrint(LPRINT_NORMAL, "Please read the manual before using " |
1449 |
"the /msay command."); |
|
967 | 1450 |
scr_LogPrint(LPRINT_NORMAL, "(Use \"%s begin\" to enter " |
1451 |
"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
|
1452 |
goto do_msay_return; |
636 | 1453 |
} |
1454 |
||
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1455 |
if (!strcasecmp(subcmd, "toggle")) { |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1456 |
if (scr_get_multimode()) |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1457 |
subcmd = "send"; |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1458 |
else |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1459 |
subcmd = "begin"; |
838
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1460 |
} else if (!strcasecmp(subcmd, "toggle_verbatim")) { |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1461 |
if (scr_get_multimode()) |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1462 |
subcmd = "send"; |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1463 |
else |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1464 |
subcmd = "verbatim"; |
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1465 |
} |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1466 |
|
636 | 1467 |
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
|
1468 |
if (scr_get_multimode()) |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1469 |
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
|
1470 |
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
|
1471 |
goto do_msay_return; |
636 | 1472 |
} else if ((!strcasecmp(subcmd, "begin")) || |
1473 |
(!strcasecmp(subcmd, "verbatim"))) { |
|
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1474 |
bool verbat; |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1475 |
gchar *subj_utf8 = to_utf8(arg); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1476 |
if (!strcasecmp(subcmd, "verbatim")) { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1477 |
scr_set_multimode(2, subj_utf8); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1478 |
verbat = TRUE; |
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1479 |
} else { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1480 |
scr_set_multimode(1, subj_utf8); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1481 |
verbat = FALSE; |
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1482 |
} |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
1483 |
|
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1484 |
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
|
1485 |
verbat ? "VERBATIM " : ""); |
967 | 1486 |
scr_LogPrint(LPRINT_NORMAL, "Select a buddy and use \"%s send\" " |
1487 |
"when your message is ready.", mkcmdstr("msay")); |
|
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1488 |
if (verbat) |
967 | 1489 |
scr_LogPrint(LPRINT_NORMAL, "Use \"%s abort\" to abort this mode.", |
1490 |
mkcmdstr("msay")); |
|
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1491 |
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
|
1492 |
goto do_msay_return; |
636 | 1493 |
} else if (strcasecmp(subcmd, "send") && strcasecmp(subcmd, "send_to")) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1494 |
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
|
1495 |
goto do_msay_return; |
238 | 1496 |
} |
1497 |
||
636 | 1498 |
/* send/send_to command */ |
238 | 1499 |
|
1500 |
if (!scr_get_multimode()) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1501 |
scr_LogPrint(LPRINT_NORMAL, "No message to send. " |
967 | 1502 |
"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
|
1503 |
goto do_msay_return; |
238 | 1504 |
} |
1505 |
||
1506 |
scr_set_chatmode(TRUE); |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1507 |
scr_show_buddy_window(); |
238 | 1508 |
|
636 | 1509 |
if (!strcasecmp(subcmd, "send_to")) { |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1510 |
int err = FALSE; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1511 |
gchar *msg_utf8; |
1598 | 1512 |
LmMessageSubType msg_type = scan_mtype(&arg); |
636 | 1513 |
// Let's send to the specified JID. We leave now if there |
1514 |
// 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
|
1515 |
arg = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1516 |
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
|
1517 |
if (msg_utf8) { |
1430
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1518 |
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
|
1519 |
FALSE); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1520 |
g_free(msg_utf8); |
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1521 |
} |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1522 |
g_free(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1523 |
if (err) |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1524 |
goto do_msay_return; |
636 | 1525 |
} else { // Send to currently selected buddy |
1526 |
gpointer bud; |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1527 |
gchar *msg_utf8; |
238 | 1528 |
|
636 | 1529 |
if (!current_buddy) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1530 |
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
|
1531 |
goto do_msay_return; |
636 | 1532 |
} |
1533 |
||
1534 |
bud = BUDDATA(current_buddy); |
|
1181
807815928754
Allow sending a multi-line message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
1177
diff
changeset
|
1535 |
if (!(buddy_gettype(bud) & |
807815928754
Allow sending a multi-line message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
1177
diff
changeset
|
1536 |
(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
|
1537 |
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
|
1538 |
goto do_msay_return; |
636 | 1539 |
} |
1540 |
||
1541 |
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
|
1542 |
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
|
1543 |
if (msg_utf8) { |
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1544 |
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
|
1545 |
g_free(msg_utf8); |
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1546 |
} |
238 | 1547 |
} |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1548 |
scr_set_multimode(FALSE, NULL); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1549 |
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
|
1550 |
do_msay_return: |
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
1551 |
free_arg_lst(paramlst); |
238 | 1552 |
} |
1553 |
||
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1554 |
// load_message_from_file(filename) |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1555 |
// 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
|
1556 |
// 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
|
1557 |
// use. |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1558 |
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
|
1559 |
{ |
1434
bed2f0caa952
Expand filename in /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1433
diff
changeset
|
1560 |
FILE *fd; |
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1561 |
struct stat buf; |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1562 |
char *msgbuf, *msgbuf_utf8; |
1442
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1563 |
char *p; |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1564 |
char *next_utf8_char; |
1443
0623d694a77f
Forbid NUL characters when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1442
diff
changeset
|
1565 |
size_t len; |
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1566 |
|
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1567 |
fd = fopen(filename, "r"); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1568 |
|
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1569 |
if (!fd || fstat(fileno(fd), &buf)) { |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1570 |
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
|
1571 |
return NULL; |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1572 |
} |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1573 |
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
|
1574 |
if (!buf.st_size) |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1575 |
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
|
1576 |
else |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1577 |
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
|
1578 |
fclose(fd); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1579 |
return NULL; |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1580 |
} |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1581 |
|
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1582 |
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
|
1583 |
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
|
1584 |
fclose(fd); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1585 |
|
1442
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1586 |
next_utf8_char = msgbuf; |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1587 |
|
1443
0623d694a77f
Forbid NUL characters when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1442
diff
changeset
|
1588 |
// 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
|
1589 |
for (p = msgbuf ; *p ; p++) { |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1590 |
if (utf8_mode) { |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1591 |
if (p == next_utf8_char) { |
1462
2b43d89a10bb
Allow tab characters with /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1443
diff
changeset
|
1592 |
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
|
1593 |
break; |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1594 |
next_utf8_char = next_char(p); |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1595 |
} |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1596 |
} else { |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1597 |
unsigned char sc = *p; |
1462
2b43d89a10bb
Allow tab characters with /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1443
diff
changeset
|
1598 |
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
|
1599 |
break; |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1600 |
} |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1601 |
} |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1602 |
|
1443
0623d694a77f
Forbid NUL characters when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1442
diff
changeset
|
1603 |
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
|
1604 |
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
|
1605 |
"invalid characters (%s)", filename); |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1606 |
g_free(msgbuf); |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1607 |
return NULL; |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1608 |
} |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1609 |
|
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1610 |
// 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
|
1611 |
// Let's strip trailing newlines |
1442
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1612 |
if (p > msgbuf) |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1613 |
p--; |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1614 |
while (p > msgbuf && *p == '\n') |
b49a1edba983
Check file content when using /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
1615 |
*p-- = 0; |
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1616 |
|
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1617 |
// 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
|
1618 |
if (p == msgbuf && *p == '\n') { |
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1619 |
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
|
1620 |
g_free(msgbuf); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1621 |
return NULL; |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1622 |
} |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1623 |
|
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1624 |
msgbuf_utf8 = to_utf8(msgbuf); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1625 |
|
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1626 |
if (!msgbuf_utf8 && msgbuf) |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1627 |
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
|
1628 |
filename); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1629 |
g_free(msgbuf); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1630 |
return msgbuf_utf8; |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1631 |
} |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1632 |
|
480 | 1633 |
static void do_say_to(char *arg) |
1634 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1635 |
char **paramlst; |
1058 | 1636 |
char *fjid, *msg; |
1943
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1637 |
char *uncompletedfjid = NULL; |
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1638 |
char *file = NULL; |
1598 | 1639 |
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
|
1640 |
bool quiet = FALSE; |
480 | 1641 |
|
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
1642 |
if (!xmpp_is_online()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1643 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
480 | 1644 |
return; |
1645 |
} |
|
1646 |
||
1305
9bc68473f8a3
-n and -f flags to message-sending commands
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1301
diff
changeset
|
1647 |
msg_type = scan_mtype(&arg); |
1430
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1648 |
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
|
1649 |
|
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1650 |
if (!*paramlst) { // No parameter? |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1651 |
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
|
1652 |
free_arg_lst(paramlst); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1653 |
return; |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1654 |
} |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1655 |
|
1430
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1656 |
// Check for an option parameter |
1563
248da27faff3
Fix segfault when using /say_to with a bad syntax (reported by ISBear)
Mikael Berthe <mikael@lilotux.net>
parents:
1528
diff
changeset
|
1657 |
while (*paramlst) { |
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1658 |
if (!strcmp(*paramlst, "-q")) { |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1659 |
char **oldparamlst = paramlst; |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1660 |
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
|
1661 |
free_arg_lst(oldparamlst); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1662 |
quiet = TRUE; |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1663 |
} else if (!strcmp(*paramlst, "-f")) { |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1664 |
char **oldparamlst = paramlst; |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1665 |
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
|
1666 |
free_arg_lst(oldparamlst); |
1563
248da27faff3
Fix segfault when using /say_to with a bad syntax (reported by ISBear)
Mikael Berthe <mikael@lilotux.net>
parents:
1528
diff
changeset
|
1667 |
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
|
1668 |
scr_LogPrint(LPRINT_NORMAL, "Wrong usage."); |
1876
ad1f7e7c2745
Fix bug in /say_to introduced in changeset 5492b87ba9d0
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1861
diff
changeset
|
1669 |
free_arg_lst(paramlst); |
1563
248da27faff3
Fix segfault when using /say_to with a bad syntax (reported by ISBear)
Mikael Berthe <mikael@lilotux.net>
parents:
1528
diff
changeset
|
1670 |
return; |
248da27faff3
Fix segfault when using /say_to with a bad syntax (reported by ISBear)
Mikael Berthe <mikael@lilotux.net>
parents:
1528
diff
changeset
|
1671 |
} |
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1672 |
file = g_strdup(*paramlst); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1673 |
// One more parameter shift... |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1674 |
oldparamlst = paramlst; |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1675 |
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
|
1676 |
free_arg_lst(oldparamlst); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1677 |
} else |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1678 |
break; |
1430
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1679 |
} |
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1680 |
|
1563
248da27faff3
Fix segfault when using /say_to with a bad syntax (reported by ISBear)
Mikael Berthe <mikael@lilotux.net>
parents:
1528
diff
changeset
|
1681 |
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
|
1682 |
scr_LogPrint(LPRINT_NORMAL, "Wrong usage."); |
1876
ad1f7e7c2745
Fix bug in /say_to introduced in changeset 5492b87ba9d0
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1861
diff
changeset
|
1683 |
free_arg_lst(paramlst); |
1563
248da27faff3
Fix segfault when using /say_to with a bad syntax (reported by ISBear)
Mikael Berthe <mikael@lilotux.net>
parents:
1528
diff
changeset
|
1684 |
return; |
248da27faff3
Fix segfault when using /say_to with a bad syntax (reported by ISBear)
Mikael Berthe <mikael@lilotux.net>
parents:
1528
diff
changeset
|
1685 |
} |
248da27faff3
Fix segfault when using /say_to with a bad syntax (reported by ISBear)
Mikael Berthe <mikael@lilotux.net>
parents:
1528
diff
changeset
|
1686 |
|
1058 | 1687 |
fjid = *paramlst; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1688 |
msg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1689 |
|
1876
ad1f7e7c2745
Fix bug in /say_to introduced in changeset 5492b87ba9d0
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1861
diff
changeset
|
1690 |
if (fjid[0] == '.') { |
ad1f7e7c2745
Fix bug in /say_to introduced in changeset 5492b87ba9d0
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1861
diff
changeset
|
1691 |
const gchar *cjid = (current_buddy ? CURRENT_JID : NULL); |
ad1f7e7c2745
Fix bug in /say_to introduced in changeset 5492b87ba9d0
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1861
diff
changeset
|
1692 |
if (fjid[1] == '\0') { |
ad1f7e7c2745
Fix bug in /say_to introduced in changeset 5492b87ba9d0
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1861
diff
changeset
|
1693 |
fjid = g_strdup(cjid); |
ad1f7e7c2745
Fix bug in /say_to introduced in changeset 5492b87ba9d0
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1861
diff
changeset
|
1694 |
} else if (fjid[1] == JID_RESOURCE_SEPARATOR) { |
ad1f7e7c2745
Fix bug in /say_to introduced in changeset 5492b87ba9d0
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1861
diff
changeset
|
1695 |
char *res_utf8 = to_utf8(fjid+2); |
ad1f7e7c2745
Fix bug in /say_to introduced in changeset 5492b87ba9d0
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1861
diff
changeset
|
1696 |
fjid = g_strdup_printf("%s%c%s", cjid, JID_RESOURCE_SEPARATOR, res_utf8); |
1861
81822de0edf6
Fix a potential encoding issue on non-UTF8 systems
Mikael Berthe <mikael@lilotux.net>
parents:
1860
diff
changeset
|
1697 |
g_free(res_utf8); |
1876
ad1f7e7c2745
Fix bug in /say_to introduced in changeset 5492b87ba9d0
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1861
diff
changeset
|
1698 |
} else |
ad1f7e7c2745
Fix bug in /say_to introduced in changeset 5492b87ba9d0
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1861
diff
changeset
|
1699 |
fjid = to_utf8(fjid); |
1861
81822de0edf6
Fix a potential encoding issue on non-UTF8 systems
Mikael Berthe <mikael@lilotux.net>
parents:
1860
diff
changeset
|
1700 |
} else |
81822de0edf6
Fix a potential encoding issue on non-UTF8 systems
Mikael Berthe <mikael@lilotux.net>
parents:
1860
diff
changeset
|
1701 |
fjid = to_utf8(fjid); |
81822de0edf6
Fix a potential encoding issue on non-UTF8 systems
Mikael Berthe <mikael@lilotux.net>
parents:
1860
diff
changeset
|
1702 |
|
1943
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1703 |
if (!strchr(fjid, JID_DOMAIN_SEPARATOR)) { |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1704 |
const gchar *append_server = settings_opt_get("default_server"); |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1705 |
if (append_server) { |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1706 |
gchar *res = strchr(fjid, JID_RESOURCE_SEPARATOR); |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1707 |
uncompletedfjid = fjid; |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1708 |
if (res) { |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1709 |
*res++ = '\0'; |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1710 |
fjid = g_strdup_printf("%s%c%s%c%s", fjid, JID_DOMAIN_SEPARATOR, append_server, |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1711 |
JID_RESOURCE_SEPARATOR, res); |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1712 |
} else |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1713 |
fjid = g_strdup_printf("%s%c%s", fjid, JID_DOMAIN_SEPARATOR, append_server); |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1714 |
} |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1715 |
} |
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1716 |
|
1861
81822de0edf6
Fix a potential encoding issue on non-UTF8 systems
Mikael Berthe <mikael@lilotux.net>
parents:
1860
diff
changeset
|
1717 |
if (check_jid_syntax(fjid)) { |
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1718 |
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
|
1719 |
free_arg_lst(paramlst); |
1943
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1720 |
g_free(uncompletedfjid); |
1861
81822de0edf6
Fix a potential encoding issue on non-UTF8 systems
Mikael Berthe <mikael@lilotux.net>
parents:
1860
diff
changeset
|
1721 |
g_free(fjid); |
480 | 1722 |
return; |
1723 |
} |
|
1724 |
||
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1725 |
if (!file) { |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1726 |
msg = to_utf8(msg); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1727 |
} else { |
1434
bed2f0caa952
Expand filename in /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1433
diff
changeset
|
1728 |
char *filename_xp; |
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1729 |
if (msg) |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1730 |
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
|
1731 |
filename_xp = expand_filename(file); |
bed2f0caa952
Expand filename in /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1433
diff
changeset
|
1732 |
msg = load_message_from_file(filename_xp); |
bed2f0caa952
Expand filename in /say_to -f
Mikael Berthe <mikael@lilotux.net>
parents:
1433
diff
changeset
|
1733 |
g_free(filename_xp); |
1432
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1734 |
g_free(file); |
46e5eb9917bc
Add an option "-f" (file) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1430
diff
changeset
|
1735 |
} |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1736 |
|
1430
12847b0ea8c9
Add an option "-q" (quiet) to /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
1429
diff
changeset
|
1737 |
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
|
1738 |
|
1943
11bda6d8daab
Add default server for private messages
Mikael Berthe <mikael@lilotux.net>
parents:
1939
diff
changeset
|
1739 |
g_free(uncompletedfjid); |
1058 | 1740 |
g_free(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1741 |
g_free(msg); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1742 |
free_arg_lst(paramlst); |
480 | 1743 |
} |
1744 |
||
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1745 |
// buffer_updown(updown, nblines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1746 |
// updown: -1=up, +1=down |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1747 |
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
|
1748 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1749 |
int nblines; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1750 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1751 |
if (!nlines || !*nlines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1752 |
nblines = 0; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1753 |
else |
1577
ece4f26bf9ff
Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents:
1563
diff
changeset
|
1754 |
nblines = strtol(nlines, NULL, 10); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1755 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1756 |
if (nblines >= 0) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1757 |
scr_buffer_scroll_up_down(updown, nblines); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1758 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1759 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1760 |
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
|
1761 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1762 |
if (!arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1763 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1764 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1765 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1766 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1767 |
scr_buffer_search(direction, arg); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1768 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1769 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1770 |
static void buffer_date(char *date) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1771 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1772 |
time_t t; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1773 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1774 |
if (!date || !*date) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1775 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1776 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1777 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1778 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1779 |
strip_arg_special_chars(date); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1780 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1781 |
t = from_iso8601(date, 0); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1782 |
if (t) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1783 |
scr_buffer_date(t); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1784 |
else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1785 |
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
|
1786 |
"not correctly formatted or invalid."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1787 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1788 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1789 |
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
|
1790 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1791 |
// Basically, user has typed "%arg1 arg2" |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1792 |
// "%50" -> arg1 = 50, arg2 null pointer |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1793 |
// "% 50" -> arg1 = \0, arg2 = 50 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1794 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1795 |
if (!*arg1 && (!arg2 || !*arg2)) { // No value |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1796 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1797 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1798 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1799 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1800 |
if (*arg1 && arg2 && *arg2) { // Two values |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1801 |
scr_LogPrint(LPRINT_NORMAL, "Wrong parameters."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1802 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1803 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1804 |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1805 |
scr_buffer_percent(atoi((*arg1 ? arg1 : arg2))); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1806 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1807 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1808 |
static void do_buffer(char *arg) |
187 | 1809 |
{ |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1810 |
char **paramlst; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1811 |
char *subcmd; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1812 |
|
1058 | 1813 |
if (!current_buddy) |
1814 |
return; |
|
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1815 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1816 |
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
|
1817 |
subcmd = *paramlst; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1818 |
arg = *(paramlst+1); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1819 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1820 |
if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1821 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1822 |
free_arg_lst(paramlst); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1823 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1824 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1825 |
|
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1826 |
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP && |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1827 |
strcasecmp(subcmd, "close_all")) { |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1828 |
scr_LogPrint(LPRINT_NORMAL, "Groups have no buffer."); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1829 |
free_arg_lst(paramlst); |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1830 |
return; |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1831 |
} |
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1832 |
|
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1833 |
if (!strcasecmp(subcmd, "top")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1834 |
scr_buffer_top_bottom(-1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1835 |
} else if (!strcasecmp(subcmd, "bottom")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1836 |
scr_buffer_top_bottom(1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1837 |
} else if (!strcasecmp(subcmd, "clear")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1838 |
scr_buffer_clear(); |
1135
5d7c05932b13
Add command /buffer close
Mikael Berthe <mikael@lilotux.net>
parents:
1130
diff
changeset
|
1839 |
} else if (!strcasecmp(subcmd, "close")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1840 |
scr_buffer_purge(1, arg); |
1138
8ba4b1e8b42d
Add command /buffer close_all
Mikael Berthe <mikael@lilotux.net>
parents:
1135
diff
changeset
|
1841 |
} else if (!strcasecmp(subcmd, "close_all")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1842 |
scr_buffer_purge_all(1); |
866 | 1843 |
} else if (!strcasecmp(subcmd, "purge")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1844 |
scr_buffer_purge(0, arg); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1845 |
} else if (!strcasecmp(subcmd, "scroll_lock")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1846 |
scr_buffer_scroll_lock(1); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1847 |
} else if (!strcasecmp(subcmd, "scroll_unlock")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1848 |
scr_buffer_scroll_lock(0); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1849 |
} else if (!strcasecmp(subcmd, "scroll_toggle")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1850 |
scr_buffer_scroll_lock(-1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1851 |
} else if (!strcasecmp(subcmd, "up")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1852 |
buffer_updown(-1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1853 |
} else if (!strcasecmp(subcmd, "down")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1854 |
buffer_updown(1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1855 |
} else if (!strcasecmp(subcmd, "search_backward")) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
1856 |
strip_arg_special_chars(arg); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1857 |
buffer_search(-1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1858 |
} else if (!strcasecmp(subcmd, "search_forward")) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
1859 |
strip_arg_special_chars(arg); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1860 |
buffer_search(1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1861 |
} else if (!strcasecmp(subcmd, "date")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1862 |
buffer_date(arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1863 |
} else if (*subcmd == '%') { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1864 |
buffer_percent(subcmd+1, arg); |
1485
0121b6f3047c
New command: /buffer save
Mikael Berthe <mikael@lilotux.net>
parents:
1484
diff
changeset
|
1865 |
} else if (!strcasecmp(subcmd, "save")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1866 |
scr_buffer_dump(arg); |
1226
2521efbf3b72
New (debug) subcommand, buffer list
Mikael Berthe <mikael@lilotux.net>
parents:
1221
diff
changeset
|
1867 |
} else if (!strcasecmp(subcmd, "list")) { |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1868 |
scr_buffer_list(); |
1956
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1946
diff
changeset
|
1869 |
} else if (!strcasecmp(subcmd, "readmark")) { |
f309f343070c
Add command /buffer readmark
Mikael Berthe <mikael@lilotux.net>
parents:
1946
diff
changeset
|
1870 |
scr_buffer_jump_readmark(); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1871 |
} else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1872 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1873 |
} |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1874 |
|
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1875 |
free_arg_lst(paramlst); |
187 | 1876 |
} |
1877 |
||
967 | 1878 |
static void do_clear(char *arg) // Alias for "buffer clear" |
187 | 1879 |
{ |
1880 |
do_buffer("clear"); |
|
1881 |
} |
|
1882 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1883 |
static void do_info(char *arg) |
191 | 1884 |
{ |
1885 |
gpointer bud; |
|
1058 | 1886 |
const char *bjid, *name; |
1355 | 1887 |
guint type, on_srv; |
191 | 1888 |
char *buffer; |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1889 |
enum subscr esub; |
191 | 1890 |
|
1058 | 1891 |
if (!current_buddy) |
1892 |
return; |
|
191 | 1893 |
bud = BUDDATA(current_buddy); |
1894 |
||
1058 | 1895 |
bjid = buddy_getjid(bud); |
191 | 1896 |
name = buddy_getname(bud); |
1897 |
type = buddy_gettype(bud); |
|
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1898 |
esub = buddy_getsubscription(bud); |
1355 | 1899 |
on_srv = buddy_getonserverflag(bud); |
191 | 1900 |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1901 |
buffer = g_new(char, 4096); |
191 | 1902 |
|
1058 | 1903 |
if (bjid) { |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1904 |
GSList *resources, *p_res; |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1905 |
char *bstr = "unknown"; |
191 | 1906 |
|
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1907 |
// Enter chat mode |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1908 |
scr_set_chatmode(TRUE); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
1909 |
scr_show_buddy_window(); |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1910 |
|
1058 | 1911 |
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
|
1912 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
191 | 1913 |
if (name) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1914 |
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
|
1915 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
191 | 1916 |
} |
1917 |
||
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1918 |
if (type == ROSTER_TYPE_USER) bstr = "user"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1919 |
else if (type == ROSTER_TYPE_ROOM) bstr = "chatroom"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1920 |
else if (type == ROSTER_TYPE_AGENT) bstr = "agent"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1921 |
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
|
1922 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1923 |
|
1355 | 1924 |
if (!on_srv) { |
1925 |
scr_WriteIncomingMessage(bjid, "(Local item, not on the server)", |
|
1926 |
0, HBB_PREFIX_INFO, 0); |
|
1927 |
} |
|
1928 |
||
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1929 |
if (esub == sub_both) bstr = "both"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1930 |
else if (esub & sub_from) bstr = "from"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1931 |
else if (esub & sub_to) bstr = "to"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1932 |
else bstr = "none"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1933 |
snprintf(buffer, 64, "Subscription: %s", bstr); |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1934 |
if (esub & sub_pending) |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1935 |
strcat(buffer, " (pending)"); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1936 |
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
|
1937 |
|
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1938 |
resources = buddy_getresources(bud); |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1939 |
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
|
1940 |
// 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
|
1941 |
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
|
1942 |
if (rst_msg) { |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1943 |
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
|
1944 |
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
|
1945 |
} |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1946 |
} |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1947 |
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
|
1948 |
gchar rprio; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1949 |
enum imstatus rstatus; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1950 |
const char *rst_msg; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1951 |
time_t rst_time; |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1952 |
|
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1953 |
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
|
1954 |
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
|
1955 |
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
|
1956 |
rst_time = buddy_getstatustime(bud, p_res->data); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1957 |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1958 |
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
|
1959 |
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
|
1960 |
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
|
1961 |
if (rst_msg) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1962 |
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
|
1963 |
scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1964 |
0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1965 |
} |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1966 |
if (rst_time) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1967 |
char tbuf[128]; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1968 |
|
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1969 |
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
|
1970 |
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
|
1971 |
scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1972 |
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
|
1973 |
} |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1974 |
#ifdef HAVE_GPGME |
2020
46a21258ad91
Fix some compiler warnings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
2016
diff
changeset
|
1975 |
struct pgp_data *rpgp = buddy_resource_pgp(bud, p_res->data); |
46a21258ad91
Fix some compiler warnings
Myhailo Danylenko <isbear@ukrpost.net>
parents:
2016
diff
changeset
|
1976 |
|
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1977 |
if (rpgp && rpgp->sign_keyid) { |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1978 |
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
|
1979 |
scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1980 |
0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1981 |
if (rpgp->last_sigsum) { |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1982 |
gpgme_sigsum_t ss = rpgp->last_sigsum; |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1983 |
snprintf(buffer, 4095, "Last PGP signature: %s", |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1984 |
(ss & GPGME_SIGSUM_GREEN ? "good": |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1985 |
(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
|
1986 |
scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
1987 |
0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1988 |
} |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1989 |
} |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1990 |
#endif |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1991 |
g_free(p_res->data); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1992 |
} |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
1993 |
g_slist_free(resources); |
1355 | 1994 |
} else { /* Item has no jid */ |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1995 |
if (name) scr_LogPrint(LPRINT_NORMAL, "Name: %s", name); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1996 |
scr_LogPrint(LPRINT_NORMAL, "Type: %s", |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1997 |
type == ROSTER_TYPE_GROUP ? "group" : |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1998 |
(type == ROSTER_TYPE_SPECIAL ? "special" : "unknown")); |
191 | 1999 |
} |
2000 |
g_free(buffer); |
|
2001 |
||
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
2002 |
// 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
|
2003 |
if (type == ROSTER_TYPE_USER || |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
2004 |
type == ROSTER_TYPE_ROOM || |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
2005 |
type == ROSTER_TYPE_AGENT) { |
1598 | 2006 |
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
|
2007 |
if (note) { |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
2008 |
// 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
|
2009 |
g_free(note->text); |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
2010 |
g_free(note->jid); |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
2011 |
g_free(note); |
1058 | 2012 |
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
|
2013 |
HBB_PREFIX_INFO, 0); |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
2014 |
} |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
2015 |
} |
191 | 2016 |
} |
2017 |
||
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2018 |
// room_names() is a variation of do_info(), for chatrooms only |
552 | 2019 |
static void room_names(gpointer bud, char *arg) |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2020 |
{ |
1058 | 2021 |
const char *bjid; |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2022 |
char *buffer; |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
2023 |
GSList *resources, *p_res; |
1587 | 2024 |
enum { style_normal = 0, style_detail, style_short, |
2025 |
style_quiet, style_compact } style = 0; |
|
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2026 |
|
552 | 2027 |
if (*arg) { |
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2028 |
if (!strcasecmp(arg, "--short")) |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2029 |
style = style_short; |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2030 |
else if (!strcasecmp(arg, "--quiet")) |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2031 |
style = style_quiet; |
1341
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2032 |
else if (!strcasecmp(arg, "--detail")) |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2033 |
style = style_detail; |
1587 | 2034 |
else if (!strcasecmp(arg, "--compact")) |
2035 |
style = style_compact; |
|
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2036 |
else { |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2037 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2038 |
return; |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2039 |
} |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2040 |
} |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2041 |
|
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
2042 |
// Enter chat mode |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
2043 |
scr_set_chatmode(TRUE); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
2044 |
scr_show_buddy_window(); |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
2045 |
|
1058 | 2046 |
bjid = buddy_getjid(bud); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2047 |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2048 |
buffer = g_new(char, 4096); |
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2049 |
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
|
2050 |
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
|
2051 |
|
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2052 |
resources = buddy_getresources(bud); |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
2053 |
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
|
2054 |
enum imstatus rstatus; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2055 |
const char *rst_msg; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2056 |
|
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
2057 |
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
|
2058 |
rst_msg = buddy_getstatusmsg(bud, p_res->data); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2059 |
|
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2060 |
if (style == style_short) { |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2061 |
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
|
2062 |
(char*)p_res->data, |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2063 |
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
|
2064 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
1587 | 2065 |
} else if (style == style_compact) { |
2066 |
enum imrole role = buddy_getrole(bud, p_res->data); |
|
2067 |
enum imaffiliation affil = buddy_getaffil(bud, p_res->data); |
|
1588 | 2068 |
bool showaffil = (affil != affil_none); |
2069 |
||
2070 |
snprintf(buffer, 4095, "[%c] %s (%s%s%s)", |
|
2071 |
imstatus2char[rstatus], (char*)p_res->data, |
|
2072 |
showaffil ? straffil[affil] : "\0", |
|
2073 |
showaffil ? "/" : "\0", |
|
2074 |
strrole[role]); |
|
1587 | 2075 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
2076 |
} else { |
|
1341
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2077 |
// (Style "normal", "detail" or "quiet") |
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2078 |
snprintf(buffer, 4095, "[%c] %s", imstatus2char[rstatus], |
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2079 |
(char*)p_res->data); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
2080 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
1341
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2081 |
if (rst_msg && style != style_quiet) { |
1162
39b20ea22ce9
/room names: add options --short, --quiet
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
2082 |
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
|
2083 |
scr_WriteIncomingMessage(bjid, buffer, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
2084 |
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
|
2085 |
} |
1341
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2086 |
if (style == style_detail) { |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2087 |
enum imrole role = buddy_getrole(bud, p_res->data); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2088 |
enum imaffiliation affil = buddy_getaffil(bud, p_res->data); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2089 |
|
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2090 |
snprintf(buffer, 4095, "Role: %s", strrole[role]); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2091 |
scr_WriteIncomingMessage(bjid, buffer, |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2092 |
0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2093 |
if (affil != affil_none) { |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2094 |
snprintf(buffer, 4095, "Affiliat.: %s", straffil[affil]); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2095 |
scr_WriteIncomingMessage(bjid, buffer, |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2096 |
0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2097 |
} |
305f7a609545
Add "/room names --detail"
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
2098 |
} |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2099 |
} |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
2100 |
g_free(p_res->data); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2101 |
} |
1072
2a3cfb98bd5e
Fix memory leaks after calls to buddy_getresources()
Mikael Berthe <mikael@lilotux.net>
parents:
1070
diff
changeset
|
2102 |
g_slist_free(resources); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2103 |
g_free(buffer); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2104 |
} |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
2105 |
|
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2106 |
static void move_group_member(gpointer bud, void *groupnamedata) |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2107 |
{ |
1058 | 2108 |
const char *bjid, *name, *groupname; |
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2109 |
guint type, on_srv; |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2110 |
|
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2111 |
groupname = (char *)groupnamedata; |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2112 |
|
1058 | 2113 |
bjid = buddy_getjid(bud); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2114 |
name = buddy_getname(bud); |
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2115 |
type = buddy_gettype(bud); |
1976
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2116 |
on_srv = buddy_getonserverflag(bud); |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2117 |
|
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2118 |
if (on_srv) |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2119 |
xmpp_updatebuddy(bjid, name, *groupname ? groupname : NULL); |
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2120 |
else { |
1978
986e514bec97
Fix changeset e6beab22099b (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1976
diff
changeset
|
2121 |
buddy_setgroup(bud, (char *)groupname); |
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2122 |
if ((type & ROSTER_TYPE_ROOM) && xmpp_is_bookmarked(bjid) && |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2123 |
settings_opt_get_int("muc_bookmark_autoupdate")) |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2124 |
room_bookmark(bud, NULL); |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2125 |
} |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2126 |
} |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2127 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
2128 |
static void do_rename(char *arg) |
208 | 2129 |
{ |
2130 |
gpointer bud; |
|
1058 | 2131 |
const char *bjid, *group; |
1356
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
2132 |
guint type, on_srv; |
208 | 2133 |
char *newname, *p; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2134 |
char *name_utf8; |
208 | 2135 |
|
1058 | 2136 |
if (!current_buddy) |
2137 |
return; |
|
208 | 2138 |
bud = BUDDATA(current_buddy); |
2139 |
||
1356
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
2140 |
bjid = buddy_getjid(bud); |
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
2141 |
group = buddy_getgroupname(bud); |
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
2142 |
type = buddy_gettype(bud); |
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
2143 |
on_srv = buddy_getonserverflag(bud); |
208 | 2144 |
|
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2145 |
if (type & ROSTER_TYPE_SPECIAL) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2146 |
scr_LogPrint(LPRINT_NORMAL, "You can't rename this item."); |
208 | 2147 |
return; |
2148 |
} |
|
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2149 |
|
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2150 |
if (!*arg && !(type & ROSTER_TYPE_GROUP)) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2151 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a new name."); |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
2152 |
return; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
2153 |
} |
208 | 2154 |
|
1976
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2155 |
//if (!(type & ROSTER_TYPE_GROUP) && !on_srv) { |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2156 |
// scr_LogPrint(LPRINT_NORMAL, |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2157 |
// "Note: this item will be added to your server roster."); |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2158 |
// // If this is a MUC room w/o bookmark, let's give a small hint... |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2159 |
// if ((type & ROSTER_TYPE_ROOM) && !xmpp_is_bookmarked(bjid)) { |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2160 |
// scr_LogPrint(LPRINT_NORMAL, |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2161 |
// "You should add a room bookmark or it will not be " |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2162 |
// "recognized as a MUC room next time you run mcabber."); |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2163 |
// } |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2164 |
//} |
1356
7794d76ca90e
Warn if the user renames a local item
Mikael Berthe <mikael@lilotux.net>
parents:
1355
diff
changeset
|
2165 |
|
208 | 2166 |
newname = g_strdup(arg); |
2167 |
// Remove trailing space |
|
2168 |
for (p = newname; *p; p++) ; |
|
2169 |
while (p > newname && *p == ' ') *p = 0; |
|
2170 |
||
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2171 |
strip_arg_special_chars(newname); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2172 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2173 |
name_utf8 = to_utf8(newname); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2174 |
|
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2175 |
if (type & ROSTER_TYPE_GROUP) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2176 |
// Rename a whole group |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2177 |
foreach_group_member(bud, &move_group_member, name_utf8); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2178 |
// 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
|
2179 |
// disappear when we receive the server answer. |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
2180 |
scr_roster_up_down(-1, 1); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2181 |
} else { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2182 |
// Rename a single buddy |
1527
ac87eef9050f
"/rename -" can be used to delete the nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1525
diff
changeset
|
2183 |
guint del_name = 0; |
ac87eef9050f
"/rename -" can be used to delete the nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1525
diff
changeset
|
2184 |
if (!*newname || !strcmp(arg, "-")) |
ac87eef9050f
"/rename -" can be used to delete the nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1525
diff
changeset
|
2185 |
del_name = TRUE; |
1976
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2186 |
if (on_srv) { |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2187 |
/* We do not rename the buddy right now because the server could reject |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2188 |
* the request. Let's wait for the server answer. |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2189 |
*/ |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2190 |
xmpp_updatebuddy(bjid, (del_name ? NULL : name_utf8), group); |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2191 |
} else { |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2192 |
// This is a local item, we rename it without adding to roster. |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2193 |
buddy_setname(bud, (del_name ? (char*)bjid : name_utf8)); |
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2194 |
if ((type & ROSTER_TYPE_ROOM) && xmpp_is_bookmarked(bjid) && |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2195 |
settings_opt_get_int("muc_bookmark_autoupdate")) |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2196 |
room_bookmark(bud, NULL); |
1976
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2197 |
} |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
2198 |
} |
208 | 2199 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2200 |
g_free(name_utf8); |
208 | 2201 |
g_free(newname); |
2202 |
update_roster = TRUE; |
|
2203 |
} |
|
2204 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
2205 |
static void do_move(char *arg) |
210 | 2206 |
{ |
2207 |
gpointer bud; |
|
1058 | 2208 |
const char *bjid, *name, *oldgroupname; |
1976
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2209 |
guint type, on_srv; |
210 | 2210 |
char *newgroupname, *p; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2211 |
char *group_utf8; |
210 | 2212 |
|
1058 | 2213 |
if (!current_buddy) |
2214 |
return; |
|
210 | 2215 |
bud = BUDDATA(current_buddy); |
2216 |
||
1058 | 2217 |
bjid = buddy_getjid(bud); |
210 | 2218 |
name = buddy_getname(bud); |
2219 |
type = buddy_gettype(bud); |
|
1976
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2220 |
on_srv = buddy_getonserverflag(bud); |
210 | 2221 |
|
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
2222 |
oldgroupname = buddy_getgroupname(bud); |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
2223 |
|
210 | 2224 |
if (type & ROSTER_TYPE_GROUP) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
2225 |
scr_LogPrint(LPRINT_NORMAL, "You can't move groups!"); |
210 | 2226 |
return; |
2227 |
} |
|
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
2228 |
if (type & ROSTER_TYPE_SPECIAL) { |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
2229 |
scr_LogPrint(LPRINT_NORMAL, "You can't move this item."); |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
2230 |
return; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
2231 |
} |
210 | 2232 |
|
2233 |
newgroupname = g_strdup(arg); |
|
2234 |
// Remove trailing space |
|
2235 |
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
|
2236 |
while (p > newgroupname && *p == ' ') *p-- = 0; |
210 | 2237 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2238 |
strip_arg_special_chars(newgroupname); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2239 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2240 |
group_utf8 = to_utf8(newgroupname); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2241 |
if (strcmp(oldgroupname, group_utf8)) { |
1976
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2242 |
if (on_srv) { |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2243 |
xmpp_updatebuddy(bjid, name, *group_utf8 ? group_utf8 : NULL); |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2244 |
scr_roster_up_down(-1, 1); |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2245 |
|
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2246 |
/* We do not move the buddy right now because the server could reject |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2247 |
* the request. Let's wait for the server answer. |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2248 |
*/ |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2249 |
} else { |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2250 |
// This is a local item, we move it without adding to roster. |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2251 |
guint msgflag; |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2252 |
|
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2253 |
// If the buddy has a pending message flag, |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2254 |
// we remove it temporarily in order to reset the global group |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2255 |
// flag. We set it back once the room is in the new group, |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2256 |
// which will update the new group's flag. |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2257 |
msgflag = buddy_getflags(bud) & ROSTER_FLAG_MSG; |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2258 |
if (msgflag) |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2259 |
roster_msg_setflag(bjid, FALSE, FALSE); |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2260 |
buddy_setgroup(bud, group_utf8); |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2261 |
if (msgflag) |
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2262 |
roster_msg_setflag(bjid, FALSE, TRUE); |
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2263 |
if ((type & ROSTER_TYPE_ROOM) && xmpp_is_bookmarked(bjid) && |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2264 |
settings_opt_get_int("muc_bookmark_autoupdate")) |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2265 |
room_bookmark(bud, NULL); |
1976
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
2266 |
} |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
2267 |
} |
210 | 2268 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2269 |
g_free(group_utf8); |
210 | 2270 |
g_free(newgroupname); |
2271 |
update_roster = TRUE; |
|
2272 |
} |
|
2273 |
||
1761
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2274 |
static void list_option_cb(char *k, char *v, void *f) |
1661
64a7428afcb3
Print list of options with '/set'
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1654
diff
changeset
|
2275 |
{ |
1772
c450d1e66c2e
Don't let "/set" show the password with all other variables
Mikael Berthe <mikael@lilotux.net>
parents:
1762
diff
changeset
|
2276 |
if (strcmp(k, "password")) { |
c450d1e66c2e
Don't let "/set" show the password with all other variables
Mikael Berthe <mikael@lilotux.net>
parents:
1762
diff
changeset
|
2277 |
GSList **list = f; |
c450d1e66c2e
Don't let "/set" show the password with all other variables
Mikael Berthe <mikael@lilotux.net>
parents:
1762
diff
changeset
|
2278 |
*list = g_slist_insert_sorted(*list, k, (GCompareFunc)strcmp); |
c450d1e66c2e
Don't let "/set" show the password with all other variables
Mikael Berthe <mikael@lilotux.net>
parents:
1762
diff
changeset
|
2279 |
} |
1661
64a7428afcb3
Print list of options with '/set'
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1654
diff
changeset
|
2280 |
} |
64a7428afcb3
Print list of options with '/set'
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1654
diff
changeset
|
2281 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
2282 |
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
|
2283 |
{ |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
2284 |
guint assign; |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2285 |
gchar *option, *value; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2286 |
gchar *option_utf8; |
393 | 2287 |
|
1661
64a7428afcb3
Print list of options with '/set'
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1654
diff
changeset
|
2288 |
if (!*arg) { |
64a7428afcb3
Print list of options with '/set'
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1654
diff
changeset
|
2289 |
// list all set options |
1761
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2290 |
GSList *list = NULL; |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2291 |
// Get sorted list of keys |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2292 |
settings_foreach(SETTINGS_TYPE_OPTION, list_option_cb, &list); |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2293 |
if (list) { |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2294 |
gsize max = 0; |
1762
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1761
diff
changeset
|
2295 |
gsize maxmax = scr_gettextwidth() / 3; |
1761
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2296 |
GSList *lel; |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2297 |
gchar *format; |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2298 |
// Find out maximum key length |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2299 |
for (lel = list; lel; lel = lel->next) { |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2300 |
const gchar *key = lel->data; |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2301 |
gsize len = strlen(key); |
1762
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1761
diff
changeset
|
2302 |
if (len > max) { |
1761
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2303 |
max = len; |
1762
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1761
diff
changeset
|
2304 |
if (max > maxmax) { |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1761
diff
changeset
|
2305 |
max = maxmax; |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1761
diff
changeset
|
2306 |
break; |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1761
diff
changeset
|
2307 |
} |
61f0482d3993
Limit = alignment to 1/3 of screen in option list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1761
diff
changeset
|
2308 |
} |
1761
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2309 |
} |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2310 |
// Print out list of options |
1774 | 2311 |
format = g_strdup_printf("%%-%us = [%%s]", (unsigned)max); |
1761
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2312 |
for (lel = list; lel; lel = lel->next) { |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2313 |
const gchar *key = lel->data; |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2314 |
scr_LogPrint(LPRINT_NORMAL, format, key, settings_opt_get(key)); |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2315 |
} |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2316 |
g_free(format); |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2317 |
scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
1815
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
2318 |
scr_setattentionflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE, |
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
2319 |
ROSTER_UI_PRIO_STATUS_WIN_MESSAGE, prio_max); |
1761
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2320 |
} else |
106bbf7e97da
Sort and pretty-format options list
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1749
diff
changeset
|
2321 |
scr_LogPrint(LPRINT_NORMAL, "No options found."); |
1661
64a7428afcb3
Print list of options with '/set'
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1654
diff
changeset
|
2322 |
return; |
64a7428afcb3
Print list of options with '/set'
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1654
diff
changeset
|
2323 |
} |
64a7428afcb3
Print list of options with '/set'
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1654
diff
changeset
|
2324 |
|
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
2325 |
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
|
2326 |
if (!option) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2327 |
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
|
2328 |
return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
2329 |
} |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2330 |
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
|
2331 |
g_free(option); |
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2332 |
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
|
2333 |
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
|
2334 |
if (val) |
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2335 |
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
|
2336 |
else |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2337 |
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
|
2338 |
g_free(option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
2339 |
return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
2340 |
} |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
2341 |
// Update the option |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2342 |
// 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
|
2343 |
// 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
|
2344 |
// (hide_offline_buddies for ex.) |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
2345 |
if (!value) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2346 |
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
|
2347 |
} else { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2348 |
gchar *value_utf8 = to_utf8(value); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2349 |
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
|
2350 |
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
|
2351 |
g_free(value); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
2352 |
} |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2353 |
g_free(option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
2354 |
} |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
2355 |
|
1070
9eaacc0ad3a2
Use a hash for settings
Mikael Berthe <mikael@lilotux.net>
parents:
1066
diff
changeset
|
2356 |
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
|
2357 |
{ |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2358 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, "Alias %s = %s", k, v); |
1745
5ef7629a96ff
Set the message flag when using /set, /bind or /alias
Mikael Berthe <mikael@lilotux.net>
parents:
1740
diff
changeset
|
2359 |
scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
1815
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
2360 |
scr_setattentionflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE, |
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
2361 |
ROSTER_UI_PRIO_STATUS_WIN_MESSAGE, prio_max); |
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2362 |
} |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2363 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
2364 |
static void do_alias(char *arg) |
285 | 2365 |
{ |
2366 |
guint assign; |
|
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2367 |
gchar *alias, *value; |
393 | 2368 |
|
285 | 2369 |
assign = parse_assigment(arg, &alias, &value); |
2370 |
if (!alias) { |
|
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2371 |
settings_foreach(SETTINGS_TYPE_ALIAS, &dump_alias, NULL); |
1745
5ef7629a96ff
Set the message flag when using /set, /bind or /alias
Mikael Berthe <mikael@lilotux.net>
parents:
1740
diff
changeset
|
2372 |
update_roster = TRUE; |
285 | 2373 |
return; |
2374 |
} |
|
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2375 |
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
|
2376 |
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
|
2377 |
// 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
|
2378 |
if (val) |
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2379 |
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
|
2380 |
else |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2381 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2382 |
"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
|
2383 |
goto do_alias_return; |
285 | 2384 |
} |
2385 |
// Check the alias does not conflict with a registered command |
|
2386 |
if (cmd_get(alias)) { |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2387 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2388 |
"'%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
|
2389 |
goto do_alias_return; |
285 | 2390 |
} |
2391 |
// Update the alias |
|
2392 |
if (!value) { |
|
2393 |
if (settings_get(SETTINGS_TYPE_ALIAS, alias)) { |
|
2394 |
settings_del(SETTINGS_TYPE_ALIAS, alias); |
|
2395 |
// Remove alias from the completion list |
|
2396 |
compl_del_category_word(COMPL_CMD, alias); |
|
2397 |
} |
|
2398 |
} else { |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2399 |
/* 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
|
2400 |
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
|
2401 |
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
|
2402 |
system) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2403 |
*/ |
285 | 2404 |
if (!settings_get(SETTINGS_TYPE_ALIAS, alias)) |
2405 |
compl_add_category_word(COMPL_CMD, alias); |
|
2406 |
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
|
2407 |
g_free(value); |
285 | 2408 |
} |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2409 |
do_alias_return: |
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2410 |
g_free(alias); |
285 | 2411 |
} |
2412 |
||
1070
9eaacc0ad3a2
Use a hash for settings
Mikael Berthe <mikael@lilotux.net>
parents:
1066
diff
changeset
|
2413 |
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
|
2414 |
{ |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2415 |
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
|
2416 |
} |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2417 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
2418 |
static void do_bind(char *arg) |
288 | 2419 |
{ |
2420 |
guint assign; |
|
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2421 |
gchar *k_code, *value; |
393 | 2422 |
|
1058 | 2423 |
assign = parse_assigment(arg, &k_code, &value); |
2424 |
if (!k_code) { |
|
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
2425 |
settings_foreach(SETTINGS_TYPE_BINDING, &dump_bind, NULL); |
1745
5ef7629a96ff
Set the message flag when using /set, /bind or /alias
Mikael Berthe <mikael@lilotux.net>
parents:
1740
diff
changeset
|
2426 |
scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
1815
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
2427 |
scr_setattentionflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE, |
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
2428 |
ROSTER_UI_PRIO_STATUS_WIN_MESSAGE, prio_max); |
288 | 2429 |
return; |
2430 |
} |
|
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2431 |
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
|
2432 |
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
|
2433 |
if (val) |
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2434 |
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
|
2435 |
else |
1058 | 2436 |
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
|
2437 |
g_free(k_code); |
288 | 2438 |
return; |
2439 |
} |
|
2440 |
// Update the key binding |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2441 |
if (!value) { |
1058 | 2442 |
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
|
2443 |
} else { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2444 |
gchar *value_utf8 = to_utf8(value); |
1058 | 2445 |
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
|
2446 |
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
|
2447 |
g_free(value); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2448 |
} |
1074
b2fc694a8228
Fix a few memory leaks after calls to parse_assigment()
Mikael Berthe <mikael@lilotux.net>
parents:
1073
diff
changeset
|
2449 |
g_free(k_code); |
288 | 2450 |
} |
2451 |
||
436 | 2452 |
static void do_rawxml(char *arg) |
2453 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2454 |
char **paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2455 |
char *subcmd; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2456 |
|
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
2457 |
if (!xmpp_is_online()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2458 |
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
|
2459 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2460 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2461 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2462 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2463 |
subcmd = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2464 |
arg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2465 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2466 |
if (!subcmd || !*subcmd) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2467 |
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
|
2468 |
" before using /rawxml :-)"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2469 |
free_arg_lst(paramlst); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2470 |
return; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2471 |
} |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2472 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2473 |
if (!strcasecmp(subcmd, "send")) { |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
2474 |
gchar *buffer; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2475 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2476 |
if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2477 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2478 |
free_arg_lst(paramlst); |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
2479 |
return; |
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
2480 |
} |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2481 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2482 |
// 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
|
2483 |
// 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
|
2484 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2485 |
buffer = to_utf8(arg); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2486 |
if (buffer) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2487 |
scr_LogPrint(LPRINT_NORMAL, "Sending XML string"); |
1598 | 2488 |
lm_connection_send_raw(lconnection, buffer, NULL); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2489 |
g_free(buffer); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2490 |
} else { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2491 |
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
|
2492 |
} |
436 | 2493 |
} else { |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2494 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
436 | 2495 |
} |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2496 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
2497 |
free_arg_lst(paramlst); |
436 | 2498 |
} |
2499 |
||
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2500 |
// check_room_subcommand(arg, param_needed, buddy_must_be_a_room) |
552 | 2501 |
// - Check if this is a room, if buddy_must_be_a_room is not null |
2502 |
// - Check there is at least 1 parameter, if param_needed is true |
|
2503 |
// - Return null if one of the checks fails, or a pointer to the first |
|
2504 |
// non-space character. |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2505 |
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
|
2506 |
gpointer buddy_must_be_a_room) |
552 | 2507 |
{ |
2508 |
if (buddy_must_be_a_room && |
|
2509 |
!(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
|
2510 |
scr_LogPrint(LPRINT_NORMAL, "This isn't a conference room."); |
552 | 2511 |
return NULL; |
2512 |
} |
|
2513 |
||
2514 |
if (param_needed) { |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2515 |
if (!arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2516 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
552 | 2517 |
return NULL; |
2518 |
} |
|
2519 |
} |
|
2520 |
||
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2521 |
if (arg) |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2522 |
return arg; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2523 |
else |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2524 |
return ""; |
552 | 2525 |
} |
2526 |
||
2527 |
static void room_join(gpointer bud, char *arg) |
|
2528 |
{ |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2529 |
char **paramlst; |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2530 |
char *roomname, *nick, *pass; |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2531 |
char *roomname_tmp = NULL; |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2532 |
char *pass_utf8; |
552 | 2533 |
|
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2534 |
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
|
2535 |
roomname = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2536 |
nick = *(paramlst+1); |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2537 |
pass = *(paramlst+2); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2538 |
|
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2539 |
if (!roomname) |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2540 |
nick = NULL; |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2541 |
if (!nick) |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2542 |
pass = NULL; |
552 | 2543 |
|
841
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
2544 |
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
|
2545 |
// 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
|
2546 |
// 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
|
2547 |
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
|
2548 |
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
|
2549 |
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
|
2550 |
return; |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
2551 |
} |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
2552 |
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
|
2553 |
} else if (strchr(roomname, '/')) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2554 |
scr_LogPrint(LPRINT_NORMAL, "Invalid room name."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2555 |
free_arg_lst(paramlst); |
552 | 2556 |
return; |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2557 |
} else { |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2558 |
// 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
|
2559 |
mc_strtolower(roomname); |
63d8473df2c3
Fix encoding issues in room command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1635
diff
changeset
|
2560 |
roomname = roomname_tmp = to_utf8(roomname); |
552 | 2561 |
} |
2562 |
||
659
e61aa455c61b
MUC: Add "nickname" option variable
Mikael Berthe <mikael@lilotux.net>
parents:
653
diff
changeset
|
2563 |
// If no nickname is provided with the /join command, |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2564 |
// we try to get a default nickname. |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2565 |
if (!nick || !*nick) |
1395
d431cd75eb53
Use bookmarked nickname when manually joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
1392
diff
changeset
|
2566 |
nick = default_muc_nickname(roomname); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2567 |
else |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2568 |
nick = to_utf8(nick); |
659
e61aa455c61b
MUC: Add "nickname" option variable
Mikael Berthe <mikael@lilotux.net>
parents:
653
diff
changeset
|
2569 |
// 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
|
2570 |
if (!nick || !*nick) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2571 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2572 |
g_free(nick); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2573 |
free_arg_lst(paramlst); |
552 | 2574 |
return; |
2575 |
} |
|
2576 |
||
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2577 |
pass_utf8 = to_utf8(pass); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2578 |
|
1598 | 2579 |
xmpp_room_join(roomname, nick, pass_utf8); |
552 | 2580 |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2581 |
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
|
2582 |
|
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
2583 |
g_free(roomname_tmp); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
2584 |
g_free(nick); |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2585 |
g_free(pass_utf8); |
552 | 2586 |
buddylist_build(); |
2587 |
update_roster = TRUE; |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2588 |
free_arg_lst(paramlst); |
552 | 2589 |
} |
2590 |
||
2591 |
static void room_invite(gpointer bud, char *arg) |
|
2592 |
{ |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2593 |
char **paramlst; |
552 | 2594 |
const gchar *roomname; |
1058 | 2595 |
char* fjid; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2596 |
gchar *reason_utf8; |
552 | 2597 |
|
570
29806b0fe830
Some parsing improvements
Mikael Berthe <mikael@lilotux.net>
parents:
568
diff
changeset
|
2598 |
paramlst = split_arg(arg, 2, 1); // jid, [reason] |
1058 | 2599 |
fjid = *paramlst; |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2600 |
arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2601 |
// An empty reason is no reason... |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2602 |
if (arg && !*arg) |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2603 |
arg = NULL; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2604 |
|
1058 | 2605 |
if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2606 |
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
|
2607 |
free_arg_lst(paramlst); |
552 | 2608 |
return; |
2609 |
} |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2610 |
|
552 | 2611 |
roomname = buddy_getjid(bud); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2612 |
reason_utf8 = to_utf8(arg); |
1598 | 2613 |
xmpp_room_invite(roomname, fjid, reason_utf8); |
1058 | 2614 |
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
|
2615 |
g_free(reason_utf8); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2616 |
free_arg_lst(paramlst); |
552 | 2617 |
} |
2618 |
||
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2619 |
static void room_affil(gpointer bud, char *arg) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2620 |
{ |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2621 |
char **paramlst; |
1058 | 2622 |
gchar *fjid, *rolename; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2623 |
struct role_affil ra; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2624 |
const char *roomid = buddy_getjid(bud); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2625 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2626 |
paramlst = split_arg(arg, 3, 1); // jid, new_affil, [reason] |
1058 | 2627 |
fjid = *paramlst; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2628 |
rolename = *(paramlst+1); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2629 |
arg = *(paramlst+2); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2630 |
|
1058 | 2631 |
if (!fjid || !*fjid || !rolename || !*rolename) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2632 |
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
|
2633 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2634 |
return; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2635 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2636 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2637 |
ra.type = type_affil; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2638 |
ra.val.affil = affil_none; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2639 |
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
|
2640 |
if (!strcasecmp(rolename, straffil[ra.val.affil])) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2641 |
break; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2642 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2643 |
if (ra.val.affil < imaffiliation_size) { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2644 |
gchar *jid_utf8, *reason_utf8; |
1058 | 2645 |
jid_utf8 = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2646 |
reason_utf8 = to_utf8(arg); |
1598 | 2647 |
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
|
2648 |
g_free(jid_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2649 |
g_free(reason_utf8); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2650 |
} else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2651 |
scr_LogPrint(LPRINT_NORMAL, "Wrong affiliation parameter."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2652 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2653 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2654 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2655 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2656 |
static void room_role(gpointer bud, char *arg) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2657 |
{ |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2658 |
char **paramlst; |
1058 | 2659 |
gchar *fjid, *rolename; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2660 |
struct role_affil ra; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2661 |
const char *roomid = buddy_getjid(bud); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2662 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2663 |
paramlst = split_arg(arg, 3, 1); // jid, new_role, [reason] |
1058 | 2664 |
fjid = *paramlst; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2665 |
rolename = *(paramlst+1); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2666 |
arg = *(paramlst+2); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2667 |
|
1058 | 2668 |
if (!fjid || !*fjid || !rolename || !*rolename) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2669 |
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
|
2670 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2671 |
return; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2672 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2673 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2674 |
ra.type = type_role; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2675 |
ra.val.role = role_none; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2676 |
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
|
2677 |
if (!strcasecmp(rolename, strrole[ra.val.role])) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2678 |
break; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2679 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2680 |
if (ra.val.role < imrole_size) { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2681 |
gchar *jid_utf8, *reason_utf8; |
1058 | 2682 |
jid_utf8 = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2683 |
reason_utf8 = to_utf8(arg); |
1598 | 2684 |
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
|
2685 |
g_free(jid_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2686 |
g_free(reason_utf8); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2687 |
} else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2688 |
scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2689 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2690 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2691 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2692 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2693 |
|
571 | 2694 |
// The expected argument is a Jabber id |
2695 |
static void room_ban(gpointer bud, char *arg) |
|
2696 |
{ |
|
2697 |
char **paramlst; |
|
1391
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2698 |
gchar *fjid, *bjid; |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2699 |
const gchar *banjid; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2700 |
gchar *jid_utf8, *reason_utf8; |
584 | 2701 |
struct role_affil ra; |
571 | 2702 |
const char *roomid = buddy_getjid(bud); |
2703 |
||
2704 |
paramlst = split_arg(arg, 2, 1); // jid, [reason] |
|
1058 | 2705 |
fjid = *paramlst; |
571 | 2706 |
arg = *(paramlst+1); |
2707 |
||
1058 | 2708 |
if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2709 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
571 | 2710 |
free_arg_lst(paramlst); |
2711 |
return; |
|
2712 |
} |
|
2713 |
||
584 | 2714 |
ra.type = type_affil; |
2715 |
ra.val.affil = affil_outcast; |
|
2716 |
||
1391
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2717 |
bjid = jidtodisp(fjid); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2718 |
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
|
2719 |
|
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2720 |
// 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
|
2721 |
// nickname. |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2722 |
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
|
2723 |
const gchar *tmp; |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2724 |
// 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
|
2725 |
// 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
|
2726 |
g_free(jid_utf8); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2727 |
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
|
2728 |
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
|
2729 |
if (!tmp) { |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2730 |
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
|
2731 |
goto room_ban_return; |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2732 |
} |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2733 |
banjid = jidtodisp(tmp); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2734 |
} else |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2735 |
banjid = jid_utf8; |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2736 |
|
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2737 |
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
|
2738 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2739 |
reason_utf8 = to_utf8(arg); |
1598 | 2740 |
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
|
2741 |
g_free(reason_utf8); |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2742 |
|
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2743 |
room_ban_return: |
e20ab87c4c4c
The command /room ban can be used with a nickname
Mikael Berthe <mikael@lilotux.net>
parents:
1387
diff
changeset
|
2744 |
g_free(bjid); |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2745 |
g_free(jid_utf8); |
571 | 2746 |
free_arg_lst(paramlst); |
2747 |
} |
|
2748 |
||
1260
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2749 |
// The expected argument is a Jabber id |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2750 |
static void room_unban(gpointer bud, char *arg) |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2751 |
{ |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2752 |
gchar *fjid = arg; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2753 |
gchar *jid_utf8; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2754 |
struct role_affil ra; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2755 |
const char *roomid = buddy_getjid(bud); |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2756 |
|
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2757 |
if (!fjid || !*fjid) { |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2758 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2759 |
return; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2760 |
} |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2761 |
|
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2762 |
ra.type = type_affil; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2763 |
ra.val.affil = affil_none; |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2764 |
|
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2765 |
jid_utf8 = to_utf8(fjid); |
1598 | 2766 |
xmpp_room_setattrib(roomid, jid_utf8, NULL, ra, NULL); |
1260
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2767 |
g_free(jid_utf8); |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2768 |
} |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
2769 |
|
571 | 2770 |
// The expected argument is a nickname |
568 | 2771 |
static void room_kick(gpointer bud, char *arg) |
2772 |
{ |
|
2773 |
char **paramlst; |
|
2774 |
gchar *nick; |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2775 |
gchar *nick_utf8, *reason_utf8; |
584 | 2776 |
struct role_affil ra; |
568 | 2777 |
const char *roomid = buddy_getjid(bud); |
2778 |
||
571 | 2779 |
paramlst = split_arg(arg, 2, 1); // nickname, [reason] |
568 | 2780 |
nick = *paramlst; |
2781 |
arg = *(paramlst+1); |
|
2782 |
||
2783 |
if (!nick || !*nick) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2784 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
568 | 2785 |
free_arg_lst(paramlst); |
2786 |
return; |
|
2787 |
} |
|
2788 |
||
584 | 2789 |
ra.type = type_role; |
2790 |
ra.val.affil = role_none; |
|
2791 |
||
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2792 |
nick_utf8 = to_utf8(nick); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2793 |
reason_utf8 = to_utf8(arg); |
1598 | 2794 |
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
|
2795 |
g_free(nick_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2796 |
g_free(reason_utf8); |
568 | 2797 |
|
2798 |
free_arg_lst(paramlst); |
|
2799 |
} |
|
2800 |
||
1415
317f8d181626
Rename command public functions
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
2801 |
void cmd_room_leave(gpointer bud, char *arg) |
552 | 2802 |
{ |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2803 |
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
|
2804 |
const char *nickname; |
552 | 2805 |
|
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2806 |
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
|
2807 |
if (!nickname) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2808 |
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
|
2809 |
return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2810 |
} |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2811 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2812 |
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
|
2813 |
desc = to_utf8(arg); |
1598 | 2814 |
xmpp_setstatus(offline, roomid, desc, TRUE); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2815 |
g_free(desc); |
552 | 2816 |
g_free(roomid); |
2817 |
} |
|
2818 |
||
2819 |
static void room_nick(gpointer bud, char *arg) |
|
2820 |
{ |
|
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2821 |
if (!buddy_getinsideroom(bud)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2822 |
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
|
2823 |
return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2824 |
} |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2825 |
|
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2826 |
if (!arg || !*arg) { |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2827 |
const char *nick = buddy_getnickname(bud); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2828 |
if (nick) |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2829 |
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
|
2830 |
else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2831 |
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
|
2832 |
} else { |
1648
63d8473df2c3
Fix encoding issues in room command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1635
diff
changeset
|
2833 |
gchar *nick = to_utf8(arg); |
1392
3d4963c8ce87
Quotes should be escaped in /room nick
Mikael Berthe <mikael@lilotux.net>
parents:
1391
diff
changeset
|
2834 |
strip_arg_special_chars(nick); |
1648
63d8473df2c3
Fix encoding issues in room command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1635
diff
changeset
|
2835 |
xmpp_room_join(buddy_getjid(bud), nick, NULL); |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2836 |
g_free(nick); |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2837 |
} |
552 | 2838 |
} |
2839 |
||
2840 |
static void room_privmsg(gpointer bud, char *arg) |
|
2841 |
{ |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2842 |
char **paramlst; |
1648
63d8473df2c3
Fix encoding issues in room command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1635
diff
changeset
|
2843 |
gchar *fjid_utf8, *nick, *nick_utf8, *msg; |
552 | 2844 |
|
1100
2bef748356de
Do not strip quotes in /room privmsg
Mikael Berthe <mikael@lilotux.net>
parents:
1086
diff
changeset
|
2845 |
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
|
2846 |
nick = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2847 |
arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2848 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2849 |
if (!nick || !*nick || !arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2850 |
scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2851 |
"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
|
2852 |
free_arg_lst(paramlst); |
552 | 2853 |
return; |
2854 |
} |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2855 |
|
1648
63d8473df2c3
Fix encoding issues in room command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1635
diff
changeset
|
2856 |
nick_utf8 = to_utf8(nick); |
63d8473df2c3
Fix encoding issues in room command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1635
diff
changeset
|
2857 |
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
|
2858 |
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
|
2859 |
msg = to_utf8(arg); |
1598 | 2860 |
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
|
2861 |
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
|
2862 |
g_free(msg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2863 |
free_arg_lst(paramlst); |
552 | 2864 |
} |
2865 |
||
2866 |
static void room_remove(gpointer bud, char *arg) |
|
2867 |
{ |
|
2868 |
if (*arg) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2869 |
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
|
2870 |
"the currently-selected room will be removed."); |
552 | 2871 |
return; |
2872 |
} |
|
2873 |
||
2874 |
// 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
|
2875 |
if (buddy_getinsideroom(bud)) { |
552 | 2876 |
scr_LogPrint(LPRINT_NORMAL, "You haven't left this room!"); |
2877 |
return; |
|
2878 |
} |
|
2879 |
// Delete the room |
|
2880 |
roster_del_user(buddy_getjid(bud)); |
|
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
2881 |
scr_update_buddy_window(); |
552 | 2882 |
buddylist_build(); |
2883 |
update_roster = TRUE; |
|
2884 |
} |
|
2885 |
||
2886 |
static void room_topic(gpointer bud, char *arg) |
|
2887 |
{ |
|
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2888 |
if (!buddy_getinsideroom(bud)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2889 |
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
|
2890 |
return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2891 |
} |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2892 |
|
552 | 2893 |
// If no parameter is given, display the current topic |
2894 |
if (!*arg) { |
|
2895 |
const char *topic = buddy_gettopic(bud); |
|
2896 |
if (topic) |
|
2897 |
scr_LogPrint(LPRINT_NORMAL, "Topic: %s", topic); |
|
2898 |
else |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2899 |
scr_LogPrint(LPRINT_NORMAL, "No topic has been set."); |
552 | 2900 |
return; |
2901 |
} |
|
2902 |
||
1528
4b4b3948420c
MUC fix: the topic couldn't be cleared
Mikael Berthe <mikael@lilotux.net>
parents:
1527
diff
changeset
|
2903 |
// 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
|
2904 |
if (!strcmp(arg, "-")) |
4b4b3948420c
MUC fix: the topic couldn't be cleared
Mikael Berthe <mikael@lilotux.net>
parents:
1527
diff
changeset
|
2905 |
arg = NULL; |
4b4b3948420c
MUC fix: the topic couldn't be cleared
Mikael Berthe <mikael@lilotux.net>
parents:
1527
diff
changeset
|
2906 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2907 |
arg = to_utf8(arg); |
552 | 2908 |
// Set the topic |
1598 | 2909 |
xmpp_send_msg(buddy_getjid(bud), NULL, ROSTER_TYPE_ROOM, arg ? arg : "", |
1602 | 2910 |
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
|
2911 |
g_free(arg); |
552 | 2912 |
} |
2913 |
||
599 | 2914 |
static void room_destroy(gpointer bud, char *arg) |
2915 |
{ |
|
2916 |
gchar *msg; |
|
2917 |
||
2918 |
if (arg && *arg) |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2919 |
msg = to_utf8(arg); |
599 | 2920 |
else |
2921 |
msg = NULL; |
|
2922 |
||
1598 | 2923 |
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
|
2924 |
g_free(msg); |
599 | 2925 |
} |
2926 |
||
552 | 2927 |
static void room_unlock(gpointer bud, char *arg) |
2928 |
{ |
|
2929 |
if (*arg) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2930 |
scr_LogPrint(LPRINT_NORMAL, "Unknown parameter."); |
552 | 2931 |
return; |
2932 |
} |
|
2933 |
||
1598 | 2934 |
xmpp_room_unlock(buddy_getjid(bud)); |
552 | 2935 |
} |
2936 |
||
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2937 |
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
|
2938 |
{ |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2939 |
char **paramlst; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2940 |
char *param, *value; |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
2941 |
enum { opt_none = 0, opt_printstatus, |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
2942 |
opt_autowhois, opt_flagjoins } option = 0; |
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2943 |
guint changed = 0; |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2944 |
|
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2945 |
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
|
2946 |
param = *paramlst; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2947 |
value = *(paramlst+1); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2948 |
if (!param) { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2949 |
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
|
2950 |
free_arg_lst(paramlst); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2951 |
return; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2952 |
} |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2953 |
|
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2954 |
if (!strcasecmp(param, "print_status")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2955 |
option = opt_printstatus; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2956 |
else if (!strcasecmp(param, "auto_whois")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2957 |
option = opt_autowhois; |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
2958 |
else if (!strcasecmp(param, "flag_joins")) |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
2959 |
option = opt_flagjoins; |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2960 |
else { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2961 |
scr_LogPrint(LPRINT_NORMAL, "Wrong option!"); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2962 |
free_arg_lst(paramlst); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2963 |
return; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2964 |
} |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2965 |
|
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2966 |
// 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
|
2967 |
if (!value) { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2968 |
const char *strval; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2969 |
if (option == opt_printstatus) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2970 |
strval = strprintstatus[buddy_getprintstatus(bud)]; |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
2971 |
else if (option == opt_autowhois) |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
2972 |
strval = strautowhois[buddy_getautowhois(bud)]; |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2973 |
else |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
2974 |
strval = strflagjoins[buddy_getflagjoins(bud)]; |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2975 |
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
|
2976 |
free_arg_lst(paramlst); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2977 |
return; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2978 |
} |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2979 |
|
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2980 |
if (option == opt_printstatus) { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2981 |
enum room_printstatus eval; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2982 |
if (!strcasecmp(value, "none")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2983 |
eval = status_none; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2984 |
else if (!strcasecmp(value, "in_and_out")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2985 |
eval = status_in_and_out; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2986 |
else if (!strcasecmp(value, "all")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2987 |
eval = status_all; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2988 |
else { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2989 |
eval = status_default; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2990 |
if (strcasecmp(value, "default") != 0) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2991 |
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
|
2992 |
} |
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2993 |
if (eval != buddy_getprintstatus(bud)) { |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2994 |
buddy_setprintstatus(bud, eval); |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2995 |
changed = 1; |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
2996 |
} |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2997 |
} else if (option == opt_autowhois) { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2998 |
enum room_autowhois eval; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
2999 |
if (!strcasecmp(value, "on")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3000 |
eval = autowhois_on; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3001 |
else if (!strcasecmp(value, "off")) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3002 |
eval = autowhois_off; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3003 |
else { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3004 |
eval = autowhois_default; |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3005 |
if (strcasecmp(value, "default") != 0) |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3006 |
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
|
3007 |
} |
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3008 |
if (eval != buddy_getautowhois(bud)) { |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3009 |
buddy_setautowhois(bud, eval); |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3010 |
changed = 1; |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3011 |
} |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3012 |
} else if (option == opt_flagjoins) { |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3013 |
enum room_flagjoins eval; |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3014 |
if (!strcasecmp(value, "none")) |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3015 |
eval = flagjoins_none; |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3016 |
else if (!strcasecmp(value, "joins")) |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3017 |
eval = flagjoins_joins; |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3018 |
else if (!strcasecmp(value, "all")) |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3019 |
eval = flagjoins_all; |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3020 |
else { |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3021 |
eval = flagjoins_default; |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3022 |
if (strcasecmp(value, "default") != 0) |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3023 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized value, assuming default..."); |
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3024 |
} |
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3025 |
if (eval != buddy_getflagjoins(bud)) { |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3026 |
buddy_setflagjoins(bud, eval); |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3027 |
changed = 1; |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3028 |
} |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3029 |
} |
1980
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3030 |
if (changed && |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3031 |
xmpp_is_bookmarked(buddy_getjid(bud)) && |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3032 |
settings_opt_get_int("muc_bookmark_autoupdate")) |
3bcc57751283
Add 'muc_bookmark_autoupdate' (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1979
diff
changeset
|
3033 |
room_bookmark(bud, NULL); |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3034 |
|
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3035 |
free_arg_lst(paramlst); |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3036 |
} |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3037 |
|
1415
317f8d181626
Rename command public functions
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
3038 |
// cmd_room_whois(..) |
960
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
3039 |
// If interactive is TRUE, chatmode can be enabled. |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
3040 |
// Please note that usernick is expected in UTF-8 locale iff interactive is |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
3041 |
// FALSE (in order to work correctly with auto_whois). |
1938
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3042 |
void cmd_room_whois(gpointer bud, const char *usernick, guint interactive) |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3043 |
{ |
1938
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3044 |
char **paramlst = NULL; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3045 |
gchar *nick, *buffer; |
1058 | 3046 |
const char *bjid, *realjid; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3047 |
const char *rst_msg; |
575 | 3048 |
gchar rprio; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3049 |
enum imstatus rstatus; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3050 |
enum imrole role; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3051 |
enum imaffiliation affil; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
3052 |
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
|
3053 |
guint msg_flag = HBB_PREFIX_INFO; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3054 |
|
1938
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3055 |
if (interactive) { |
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3056 |
paramlst = split_arg(usernick, 1, 0); // nickname |
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3057 |
nick = to_utf8(*paramlst); |
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3058 |
} else { |
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3059 |
nick = g_strdup(usernick); |
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3060 |
} |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3061 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3062 |
if (!nick || !*nick) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
3063 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
1938
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3064 |
if (paramlst) |
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3065 |
free_arg_lst(paramlst); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3066 |
return; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3067 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3068 |
|
960
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
3069 |
if (interactive) { |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
3070 |
// Enter chat mode |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
3071 |
scr_set_chatmode(TRUE); |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1774
diff
changeset
|
3072 |
scr_show_buddy_window(); |
1416
7f0da8de2a7d
[MUC] Auto-whois doesn't set the new message flag
Mikael Berthe <mikael@lilotux.net>
parents:
1415
diff
changeset
|
3073 |
} else |
7f0da8de2a7d
[MUC] Auto-whois doesn't set the new message flag
Mikael Berthe <mikael@lilotux.net>
parents:
1415
diff
changeset
|
3074 |
msg_flag |= HBB_PREFIX_NOFLAG; |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
3075 |
|
1058 | 3076 |
bjid = buddy_getjid(bud); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3077 |
rstatus = buddy_getstatus(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3078 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3079 |
if (rstatus == offline) { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3080 |
scr_LogPrint(LPRINT_NORMAL, "No such member: %s", nick); |
1938
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3081 |
if (paramlst) |
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3082 |
free_arg_lst(paramlst); |
791
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
3083 |
g_free(nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3084 |
return; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3085 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3086 |
|
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
3087 |
rst_time = buddy_getstatustime(bud, nick); |
575 | 3088 |
rprio = buddy_getresourceprio(bud, nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3089 |
rst_msg = buddy_getstatusmsg(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3090 |
if (!rst_msg) rst_msg = ""; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3091 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3092 |
role = buddy_getrole(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3093 |
affil = buddy_getaffil(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3094 |
realjid = buddy_getrjid(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3095 |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
3096 |
buffer = g_new(char, 4096); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3097 |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
3098 |
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
|
3099 |
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
|
3100 |
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
|
3101 |
rst_msg); |
1416
7f0da8de2a7d
[MUC] Auto-whois doesn't set the new message flag
Mikael Berthe <mikael@lilotux.net>
parents:
1415
diff
changeset
|
3102 |
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
|
3103 |
|
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
3104 |
if (rst_time) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
3105 |
char tbuf[128]; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
3106 |
|
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
3107 |
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
|
3108 |
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
|
3109 |
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
|
3110 |
} |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
3111 |
|
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3112 |
if (realjid) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
3113 |
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
|
3114 |
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
|
3115 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3116 |
|
1058 | 3117 |
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
|
3118 |
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
|
3119 |
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
|
3120 |
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
|
3121 |
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
|
3122 |
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
|
3123 |
|
7f0da8de2a7d
[MUC] Auto-whois doesn't set the new message flag
Mikael Berthe <mikael@lilotux.net>
parents:
1415
diff
changeset
|
3124 |
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
|
3125 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3126 |
g_free(buffer); |
791
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
3127 |
g_free(nick); |
1938
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3128 |
if (paramlst) |
26e437e79e60
Fix MUC whois / auto_whois
Mikael Berthe <mikael@lilotux.net>
parents:
1923
diff
changeset
|
3129 |
free_arg_lst(paramlst); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3130 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3131 |
|
1009 | 3132 |
static void room_bookmark(gpointer bud, char *arg) |
3133 |
{ |
|
3134 |
const char *roomid; |
|
1976
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
3135 |
const char *name = NULL, *nick = NULL, *group = NULL; |
1603
54029aba9452
Allow specifying nickname for bookmark
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
3136 |
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
|
3137 |
enum room_autowhois autowhois = 0; |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3138 |
enum room_flagjoins flagjoins = 0; |
1379
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1377
diff
changeset
|
3139 |
enum room_printstatus printstatus = 0; |
1009 | 3140 |
enum { bm_add = 0, bm_del = 1 } action = 0; |
2010 | 3141 |
int autojoin = 0, autojoin_set = 0; |
1603
54029aba9452
Allow specifying nickname for bookmark
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
3142 |
int nick_set = 0; |
1009 | 3143 |
|
3144 |
if (arg && *arg) { |
|
1603
54029aba9452
Allow specifying nickname for bookmark
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
3145 |
// /room bookmark [add|del] [[+|-]autojoin] [-|nick] |
1009 | 3146 |
char **paramlst; |
3147 |
char **pp; |
|
3148 |
||
1603
54029aba9452
Allow specifying nickname for bookmark
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
3149 |
paramlst = split_arg(arg, 3, 0); // At most 3 parameters |
1009 | 3150 |
for (pp = paramlst; *pp; pp++) { |
3151 |
if (!strcasecmp(*pp, "add")) |
|
3152 |
action = bm_add; |
|
3153 |
else if (!strcasecmp(*pp, "del")) |
|
3154 |
action = bm_del; |
|
2010 | 3155 |
else if (!strcasecmp(*pp, "-autojoin")) { |
1009 | 3156 |
autojoin = 0; |
2010 | 3157 |
autojoin_set = 1; |
3158 |
} else if (!strcasecmp(*pp, "+autojoin") |
|
3159 |
|| !strcasecmp(*pp, "autojoin")) { |
|
1009 | 3160 |
autojoin = 1; |
2010 | 3161 |
autojoin_set = 1; |
3162 |
} else if (!strcmp(*pp, "-")) |
|
1603
54029aba9452
Allow specifying nickname for bookmark
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
3163 |
nick_set = 1; |
54029aba9452
Allow specifying nickname for bookmark
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
3164 |
else { |
54029aba9452
Allow specifying nickname for bookmark
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
3165 |
nick_set = 1; |
54029aba9452
Allow specifying nickname for bookmark
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
3166 |
nick = tmpnick = to_utf8 (*pp); |
54029aba9452
Allow specifying nickname for bookmark
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
3167 |
} |
1009 | 3168 |
} |
3169 |
free_arg_lst(paramlst); |
|
3170 |
} |
|
3171 |
||
3172 |
roomid = buddy_getjid(bud); |
|
3173 |
||
3174 |
if (action == bm_add) { |
|
3175 |
name = buddy_getname(bud); |
|
1993
d4273346d52d
MUC: preserve bookmark when updating a non-joined room
Jan Zachorowski <quantifier666@gmail.com>
parents:
1992
diff
changeset
|
3176 |
if (!nick_set) { |
1603
54029aba9452
Allow specifying nickname for bookmark
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
3177 |
nick = buddy_getnickname(bud); |
1993
d4273346d52d
MUC: preserve bookmark when updating a non-joined room
Jan Zachorowski <quantifier666@gmail.com>
parents:
1992
diff
changeset
|
3178 |
if (!nick) //we are probably bookmarking offline room |
d4273346d52d
MUC: preserve bookmark when updating a non-joined room
Jan Zachorowski <quantifier666@gmail.com>
parents:
1992
diff
changeset
|
3179 |
nick = xmpp_get_bookmark_nick(roomid); |
d4273346d52d
MUC: preserve bookmark when updating a non-joined room
Jan Zachorowski <quantifier666@gmail.com>
parents:
1992
diff
changeset
|
3180 |
} |
2010 | 3181 |
if (!autojoin_set) { |
3182 |
autojoin = xmpp_get_bookmark_autojoin(roomid); |
|
3183 |
} |
|
1379
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1377
diff
changeset
|
3184 |
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
|
3185 |
autowhois = buddy_getautowhois(bud); |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3186 |
flagjoins = buddy_getflagjoins(bud); |
1976
e6beab22099b
Do not add items to roster with commands /move and /rename (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1972
diff
changeset
|
3187 |
group = buddy_getgroupname(bud); |
1009 | 3188 |
} |
3189 |
||
1598 | 3190 |
xmpp_set_storage_bookmark(roomid, name, nick, NULL, autojoin, |
1979
6febc7d1f760
Add /room setopt flag_joins (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1978
diff
changeset
|
3191 |
printstatus, autowhois, flagjoins, group); |
1603
54029aba9452
Allow specifying nickname for bookmark
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1602
diff
changeset
|
3192 |
g_free (tmpnick); |
1009 | 3193 |
} |
3194 |
||
1163
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3195 |
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
|
3196 |
{ |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3197 |
GSList *bm, *bmp; |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3198 |
GString *sbuf; |
1525
68580b6be895
Display more information in /room bookmark (autojoin, nick...)
Mikael Berthe <mikael@lilotux.net>
parents:
1518
diff
changeset
|
3199 |
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
|
3200 |
|
1598 | 3201 |
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
|
3202 |
|
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3203 |
if (!bm) |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3204 |
return; |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3205 |
|
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3206 |
sbuf = g_string_new(""); |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3207 |
|
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
3208 |
scr_WriteIncomingMessage(NULL, "List of MUC bookmarks:", |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
3209 |
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
|
3210 |
|
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3211 |
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
|
3212 |
bm_elt = bmp->data; |
68580b6be895
Display more information in /room bookmark (autojoin, nick...)
Mikael Berthe <mikael@lilotux.net>
parents:
1518
diff
changeset
|
3213 |
g_string_printf(sbuf, "%c <%s>", |
68580b6be895
Display more information in /room bookmark (autojoin, nick...)
Mikael Berthe <mikael@lilotux.net>
parents:
1518
diff
changeset
|
3214 |
(bm_elt->autojoin ? '*' : ' '), bm_elt->roomjid); |
68580b6be895
Display more information in /room bookmark (autojoin, nick...)
Mikael Berthe <mikael@lilotux.net>
parents:
1518
diff
changeset
|
3215 |
if (bm_elt->nick) |
68580b6be895
Display more information in /room bookmark (autojoin, nick...)
Mikael Berthe <mikael@lilotux.net>
parents:
1518
diff
changeset
|
3216 |
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
|
3217 |
if (bm_elt->name) |
68580b6be895
Display more information in /room bookmark (autojoin, nick...)
Mikael Berthe <mikael@lilotux.net>
parents:
1518
diff
changeset
|
3218 |
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
|
3219 |
g_free(bm_elt->roomjid); |
68580b6be895
Display more information in /room bookmark (autojoin, nick...)
Mikael Berthe <mikael@lilotux.net>
parents:
1518
diff
changeset
|
3220 |
g_free(bm_elt->name); |
68580b6be895
Display more information in /room bookmark (autojoin, nick...)
Mikael Berthe <mikael@lilotux.net>
parents:
1518
diff
changeset
|
3221 |
g_free(bm_elt->nick); |
68580b6be895
Display more information in /room bookmark (autojoin, nick...)
Mikael Berthe <mikael@lilotux.net>
parents:
1518
diff
changeset
|
3222 |
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
|
3223 |
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
|
3224 |
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
|
3225 |
} |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3226 |
|
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3227 |
scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
1815
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
3228 |
scr_setattentionflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE, |
6abca6000762
Make use of ROSTER_UI_PRIO_STATUS_WIN_MESSAGE
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
3229 |
ROSTER_UI_PRIO_STATUS_WIN_MESSAGE, prio_max); |
1163
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3230 |
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
|
3231 |
g_slist_free(bm); |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3232 |
} |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3233 |
|
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3234 |
static void do_module(char *arg) |
1607 | 3235 |
{ |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
3236 |
#ifdef MODULES_ENABLE |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3237 |
gboolean force = FALSE; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3238 |
char **args; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3239 |
|
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3240 |
args = split_arg(arg, 2, 0); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3241 |
if (!args[0] || !strcmp(args[0], "list")) { |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3242 |
module_list_print(); |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3243 |
} else { |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1745
diff
changeset
|
3244 |
const gchar *error = NULL; |
1737
764ed5c12589
Move -f flag of /module command after a subcommand
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1735
diff
changeset
|
3245 |
const gchar *name = args[1]; |
764ed5c12589
Move -f flag of /module command after a subcommand
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1735
diff
changeset
|
3246 |
|
764ed5c12589
Move -f flag of /module command after a subcommand
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1735
diff
changeset
|
3247 |
if (name && name[0] == '-' && name[1] == 'f') { |
764ed5c12589
Move -f flag of /module command after a subcommand
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1735
diff
changeset
|
3248 |
force = TRUE; |
764ed5c12589
Move -f flag of /module command after a subcommand
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1735
diff
changeset
|
3249 |
name +=2; |
764ed5c12589
Move -f flag of /module command after a subcommand
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1735
diff
changeset
|
3250 |
while (*name && *name == ' ') |
764ed5c12589
Move -f flag of /module command after a subcommand
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1735
diff
changeset
|
3251 |
++name; |
764ed5c12589
Move -f flag of /module command after a subcommand
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1735
diff
changeset
|
3252 |
} |
764ed5c12589
Move -f flag of /module command after a subcommand
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1735
diff
changeset
|
3253 |
|
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3254 |
if (!strcmp(args[0], "load")) |
1737
764ed5c12589
Move -f flag of /module command after a subcommand
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1735
diff
changeset
|
3255 |
error = module_load(name, TRUE, force); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3256 |
else if (!strcmp(args[0], "unload")) |
1737
764ed5c12589
Move -f flag of /module command after a subcommand
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1735
diff
changeset
|
3257 |
error = module_unload(name, TRUE, force); |
1749
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1745
diff
changeset
|
3258 |
else if (!strcmp(args[0], "info")) |
7ee390513463
Use api version for module checks
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1745
diff
changeset
|
3259 |
module_info_print(name); |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3260 |
else |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3261 |
error = "Unknown subcommand"; |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3262 |
if (error) |
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3263 |
scr_LogPrint(LPRINT_LOGNORM, "Error: %s.", error); |
1607 | 3264 |
} |
1735
5093b5ca1572
New modules loading scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1732
diff
changeset
|
3265 |
free_arg_lst(args); |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
3266 |
#else |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
3267 |
scr_log_print(LPRINT_NORMAL, |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
3268 |
"Please recompile mcabber with modules enabled."); |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
3269 |
#endif |
1607 | 3270 |
} |
1163
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3271 |
|
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
3272 |
static void do_room(char *arg) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
3273 |
{ |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3274 |
char **paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3275 |
char *subcmd; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
3276 |
gpointer bud; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
3277 |
|
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
3278 |
if (!xmpp_is_online()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
3279 |
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
|
3280 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
3281 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
3282 |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3283 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3284 |
subcmd = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3285 |
arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3286 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3287 |
if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
3288 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3289 |
free_arg_lst(paramlst); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3290 |
return; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3291 |
} |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3292 |
|
831
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
3293 |
if (current_buddy) { |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
3294 |
bud = BUDDATA(current_buddy); |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
3295 |
} else { |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
3296 |
if (strcasecmp(subcmd, "join")) { |
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
3297 |
free_arg_lst(paramlst); |
831
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
3298 |
return; |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
3299 |
} |
831
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
3300 |
// "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
|
3301 |
// current_buddy. |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
3302 |
bud = NULL; |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
3303 |
} |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
3304 |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3305 |
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
|
3306 |
if ((arg = check_room_subcommand(arg, FALSE, NULL)) != NULL) |
552 | 3307 |
room_join(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3308 |
} else if (!strcasecmp(subcmd, "invite")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3309 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
552 | 3310 |
room_invite(bud, arg); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
3311 |
} else if (!strcasecmp(subcmd, "affil")) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
3312 |
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
|
3313 |
room_affil(bud, arg); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
3314 |
} else if (!strcasecmp(subcmd, "role")) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
3315 |
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
|
3316 |
room_role(bud, arg); |
571 | 3317 |
} else if (!strcasecmp(subcmd, "ban")) { |
3318 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
|
3319 |
room_ban(bud, arg); |
|
1260
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
3320 |
} else if (!strcasecmp(subcmd, "unban")) { |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
3321 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
b4ccc5b2a6de
Add command /room unban
Mikael Berthe <mikael@lilotux.net>
parents:
1235
diff
changeset
|
3322 |
room_unban(bud, arg); |
568 | 3323 |
} else if (!strcasecmp(subcmd, "kick")) { |
3324 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
|
3325 |
room_kick(bud, arg); |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3326 |
} else if (!strcasecmp(subcmd, "leave")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3327 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
1415
317f8d181626
Rename command public functions
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
3328 |
cmd_room_leave(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3329 |
} else if (!strcasecmp(subcmd, "names")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3330 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 3331 |
room_names(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3332 |
} else if (!strcasecmp(subcmd, "nick")) { |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
3333 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 3334 |
room_nick(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3335 |
} else if (!strcasecmp(subcmd, "privmsg")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3336 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
552 | 3337 |
room_privmsg(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3338 |
} else if (!strcasecmp(subcmd, "remove")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3339 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 3340 |
room_remove(bud, arg); |
599 | 3341 |
} else if (!strcasecmp(subcmd, "destroy")) { |
3342 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
|
3343 |
room_destroy(bud, arg); |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3344 |
} else if (!strcasecmp(subcmd, "unlock")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3345 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 3346 |
room_unlock(bud, arg); |
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3347 |
} else if (!strcasecmp(subcmd, "setopt")) { |
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1368
diff
changeset
|
3348 |
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
|
3349 |
room_setopt(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3350 |
} else if (!strcasecmp(subcmd, "topic")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3351 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 3352 |
room_topic(bud, arg); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3353 |
} else if (!strcasecmp(subcmd, "whois")) { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
3354 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
1415
317f8d181626
Rename command public functions
Mikael Berthe <mikael@lilotux.net>
parents:
1414
diff
changeset
|
3355 |
cmd_room_whois(bud, arg, TRUE); |
1009 | 3356 |
} 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
|
3357 |
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
|
3358 |
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
|
3359 |
display_all_bookmarks(); |
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1162
diff
changeset
|
3360 |
else if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
1009 | 3361 |
room_bookmark(bud, arg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
3362 |
} else { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
3363 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
3364 |
} |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3365 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
3366 |
free_arg_lst(paramlst); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
3367 |
} |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
3368 |
|
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3369 |
static void do_authorization(char *arg) |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3370 |
{ |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3371 |
char **paramlst; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3372 |
char *subcmd; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
3373 |
char *jid_utf8; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3374 |
|
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
3375 |
if (!xmpp_is_online()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
3376 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3377 |
return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3378 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3379 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3380 |
paramlst = split_arg(arg, 2, 0); // subcmd, [jid] |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3381 |
subcmd = *paramlst; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3382 |
arg = *(paramlst+1); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3383 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3384 |
if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
3385 |
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
|
3386 |
goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3387 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3388 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3389 |
// Use the provided jid, if it looks valid |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3390 |
if (arg) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3391 |
if (!*arg) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3392 |
// If no jid is provided, we use the current selected buddy |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3393 |
arg = NULL; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3394 |
} else { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3395 |
if (check_jid_syntax(arg)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
3396 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
3397 |
"<%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
|
3398 |
goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3399 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3400 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3401 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3402 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3403 |
if (!arg) { // Use the current selected buddy's jid |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3404 |
gpointer bud; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3405 |
guint type; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3406 |
|
1058 | 3407 |
if (!current_buddy) |
1073
253e8988eb5c
Fix a few memory leaks after calls to split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
3408 |
goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3409 |
bud = BUDDATA(current_buddy); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3410 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
3411 |
jid_utf8 = arg = (char*)buddy_getjid(bud); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3412 |
type = buddy_gettype(bud); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3413 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3414 |
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
|
3415 |
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
|
3416 |
goto do_authorization_return; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3417 |
} |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
3418 |
} else { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
3419 |
jid_utf8 = to_utf8(arg); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3420 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3421 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3422 |
if (!strcasecmp(subcmd, "allow")) { |
1598 | 3423 |
xmpp_send_s10n(jid_utf8, LM_MESSAGE_SUB_TYPE_SUBSCRIBED); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3424 |
scr_LogPrint(LPRINT_LOGNORM, |
1635
a57f2634ee7c
Fix a misleading message
Mikael Berthe <mikael@lilotux.net>
parents:
1631
diff
changeset
|
3425 |
"Sent presence subscription approval to <%s>.", |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
3426 |
jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3427 |
} else if (!strcasecmp(subcmd, "cancel")) { |
1598 | 3428 |
xmpp_send_s10n(jid_utf8, LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3429 |
scr_LogPrint(LPRINT_LOGNORM, |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
3430 |
"<%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
|
3431 |
jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3432 |
} else if (!strcasecmp(subcmd, "request")) { |
1598 | 3433 |
xmpp_send_s10n(jid_utf8, LM_MESSAGE_SUB_TYPE_SUBSCRIBE); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3434 |
scr_LogPrint(LPRINT_LOGNORM, |
957 | 3435 |
"Sent presence notification request to <%s>.", jid_utf8); |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
3436 |
} else if (!strcasecmp(subcmd, "request_unsubscribe")) { |
1598 | 3437 |
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
|
3438 |
scr_LogPrint(LPRINT_LOGNORM, |
957 | 3439 |
"Sent presence notification unsubscription request to <%s>.", |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
3440 |
jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3441 |
} else { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3442 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3443 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3444 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
3445 |
// 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
|
3446 |
if (jid_utf8 && jid_utf8 != arg) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
3447 |
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
|
3448 |
do_authorization_return: |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3449 |
free_arg_lst(paramlst); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3450 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
3451 |
|
622 | 3452 |
static void do_version(char *arg) |
3453 |
{ |
|
777
e6d42f239541
"/version" shows Mercurial changeset (if there's one)
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
3454 |
gchar *ver = mcabber_version(); |
e6d42f239541
"/version" shows Mercurial changeset (if there's one)
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
3455 |
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
|
3456 |
g_free(ver); |
1921
7d72b7d2d93a
Add module information in the output of /version
Mikael Berthe <mikael@lilotux.net>
parents:
1876
diff
changeset
|
3457 |
#ifdef MODULES_ENABLE |
7d72b7d2d93a
Add module information in the output of /version
Mikael Berthe <mikael@lilotux.net>
parents:
1876
diff
changeset
|
3458 |
scr_LogPrint(LPRINT_NORMAL, "Compiled with modules support (API %s:%d-%d).", |
7d72b7d2d93a
Add module information in the output of /version
Mikael Berthe <mikael@lilotux.net>
parents:
1876
diff
changeset
|
3459 |
MCABBER_BRANCH, MCABBER_API_MIN, MCABBER_API_VERSION); |
7d72b7d2d93a
Add module information in the output of /version
Mikael Berthe <mikael@lilotux.net>
parents:
1876
diff
changeset
|
3460 |
# ifdef PKGLIB_DIR |
7d72b7d2d93a
Add module information in the output of /version
Mikael Berthe <mikael@lilotux.net>
parents:
1876
diff
changeset
|
3461 |
scr_LogPrint(LPRINT_NORMAL, " Modules directory: " PKGLIB_DIR); |
7d72b7d2d93a
Add module information in the output of /version
Mikael Berthe <mikael@lilotux.net>
parents:
1876
diff
changeset
|
3462 |
# endif |
7d72b7d2d93a
Add module information in the output of /version
Mikael Berthe <mikael@lilotux.net>
parents:
1876
diff
changeset
|
3463 |
#endif |
622 | 3464 |
} |
3465 |
||
693 | 3466 |
static void do_request(char *arg) |
3467 |
{ |
|
3468 |
char **paramlst; |
|
1722
b18142457ca9
Fix vCard requests in MUC rooms
Mikael Berthe <mikael@lilotux.net>
parents:
1720
diff
changeset
|
3469 |
char *fjid, *type; |
740 | 3470 |
enum iqreq_type numtype = iqreq_none; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
3471 |
char *jid_utf8 = NULL; |
693 | 3472 |
|
3473 |
paramlst = split_arg(arg, 2, 0); // type, jid |
|
3474 |
type = *paramlst; |
|
1058 | 3475 |
fjid = *(paramlst+1); |
693 | 3476 |
|
3477 |
if (type) { |
|
3478 |
// Quick check... |
|
3479 |
if (!strcasecmp(type, "version")) |
|
3480 |
numtype = iqreq_version; |
|
3481 |
else if (!strcasecmp(type, "time")) |
|
3482 |
numtype = iqreq_time; |
|
1015 | 3483 |
else if (!strcasecmp(type, "last")) |
3484 |
numtype = iqreq_last; |
|
1705
ac881b5f9248
Add /request ping (XEP-0199), by merging isbear's module
Mikael Berthe <mikael@lilotux.net>
parents:
1686
diff
changeset
|
3485 |
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
|
3486 |
numtype = iqreq_ping; |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
3487 |
else if (!strcasecmp(type, "vcard")) |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
3488 |
numtype = iqreq_vcard; |
693 | 3489 |
} |
3490 |
||
3491 |
if (!type || !numtype) { |
|
3492 |
scr_LogPrint(LPRINT_NORMAL, |
|
1015 | 3493 |
"Please specify a query type (version, time...)."); |
693 | 3494 |
free_arg_lst(paramlst); |
3495 |
return; |
|
3496 |
} |
|
3497 |
||
1684
95df4ea512c8
Provide xmpp_is_online()
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1682
diff
changeset
|
3498 |
if (!xmpp_is_online()) { |
1592
1802b926e3fa
Display a warning when using /request while disconnected
Mikael Berthe <mikael@lilotux.net>
parents:
1588
diff
changeset
|
3499 |
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
|
3500 |
free_arg_lst(paramlst); |
1802b926e3fa
Display a warning when using /request while disconnected
Mikael Berthe <mikael@lilotux.net>
parents:
1588
diff
changeset
|
3501 |
return; |
1802b926e3fa
Display a warning when using /request while disconnected
Mikael Berthe <mikael@lilotux.net>
parents:
1588
diff
changeset
|
3502 |
} |
1802b926e3fa
Display a warning when using /request while disconnected
Mikael Berthe <mikael@lilotux.net>
parents:
1588
diff
changeset
|
3503 |
|
693 | 3504 |
// Allow special jid "" or "." (current buddy) |
1058 | 3505 |
if (fjid && (!*fjid || !strcmp(fjid, "."))) |
3506 |
fjid = NULL; |
|
693 | 3507 |
|
1058 | 3508 |
if (fjid) { |
693 | 3509 |
// The JID has been specified. Quick check... |
1058 | 3510 |
if (check_jid_syntax(fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
3511 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
3512 |
"<%s> is not a valid Jabber ID.", fjid); |
1058 | 3513 |
fjid = NULL; |
693 | 3514 |
} else { |
3515 |
// Convert jid to lowercase |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
3516 |
char *p; |
1058 | 3517 |
for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) |
693 | 3518 |
*p = tolower(*p); |
1058 | 3519 |
fjid = jid_utf8 = to_utf8(fjid); |
693 | 3520 |
} |
3521 |
} else { |
|
3522 |
// Add the current buddy |
|
3523 |
if (current_buddy) |
|
1058 | 3524 |
fjid = (char*)buddy_getjid(BUDDATA(current_buddy)); |
3525 |
if (!fjid) |
|
693 | 3526 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
3527 |
} |
|
3528 |
||
1058 | 3529 |
if (fjid) { |
693 | 3530 |
switch (numtype) { |
1720
98d99485d276
Do not use the full JID for vcard requests (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1705
diff
changeset
|
3531 |
case iqreq_vcard: |
1722
b18142457ca9
Fix vCard requests in MUC rooms
Mikael Berthe <mikael@lilotux.net>
parents:
1720
diff
changeset
|
3532 |
{ // 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
|
3533 |
gchar *tmp = strchr(fjid, JID_RESOURCE_SEPARATOR); |
b18142457ca9
Fix vCard requests in MUC rooms
Mikael Berthe <mikael@lilotux.net>
parents:
1720
diff
changeset
|
3534 |
if (tmp) { |
b18142457ca9
Fix vCard requests in MUC rooms
Mikael Berthe <mikael@lilotux.net>
parents:
1720
diff
changeset
|
3535 |
gchar *bjid = jidtodisp(fjid); |
b18142457ca9
Fix vCard requests in MUC rooms
Mikael Berthe <mikael@lilotux.net>
parents:
1720
diff
changeset
|
3536 |
if (!roster_find(bjid, jidsearch, ROSTER_TYPE_ROOM)) |
b18142457ca9
Fix vCard requests in MUC rooms
Mikael Berthe <mikael@lilotux.net>
parents:
1720
diff
changeset
|
3537 |
*tmp = '\0'; |
b18142457ca9
Fix vCard requests in MUC rooms
Mikael Berthe <mikael@lilotux.net>
parents:
1720
diff
changeset
|
3538 |
g_free(bjid); |
b18142457ca9
Fix vCard requests in MUC rooms
Mikael Berthe <mikael@lilotux.net>
parents:
1720
diff
changeset
|
3539 |
} |
b18142457ca9
Fix vCard requests in MUC rooms
Mikael Berthe <mikael@lilotux.net>
parents:
1720
diff
changeset
|
3540 |
} |
693 | 3541 |
case iqreq_version: |
3542 |
case iqreq_time: |
|
1015 | 3543 |
case iqreq_last: |
1705
ac881b5f9248
Add /request ping (XEP-0199), by merging isbear's module
Mikael Berthe <mikael@lilotux.net>
parents:
1686
diff
changeset
|
3544 |
case iqreq_ping: |
1598 | 3545 |
xmpp_request(fjid, numtype); |
693 | 3546 |
break; |
3547 |
default: |
|
3548 |
break; |
|
3549 |
} |
|
3550 |
} |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
3551 |
g_free(jid_utf8); |
693 | 3552 |
free_arg_lst(paramlst); |
3553 |
} |
|
3554 |
||
748 | 3555 |
static void do_event(char *arg) |
3556 |
{ |
|
3557 |
char **paramlst; |
|
3558 |
char *evid, *subcmd; |
|
3559 |
int action = -1; |
|
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3560 |
|
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3561 |
paramlst = split_arg(arg, 3, 1); // id, subcmd, optional arg |
748 | 3562 |
evid = *paramlst; |
3563 |
subcmd = *(paramlst+1); |
|
3564 |
||
3565 |
if (!evid || !subcmd) { |
|
3566 |
// Special case: /event list |
|
3567 |
if (evid && !strcasecmp(evid, "list")) |
|
3568 |
evs_display_list(); |
|
3569 |
else |
|
3570 |
scr_LogPrint(LPRINT_NORMAL, |
|
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3571 |
"Missing parameter. Usage: /event num action " |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3572 |
"[event-specific args]"); |
748 | 3573 |
free_arg_lst(paramlst); |
3574 |
return; |
|
3575 |
} |
|
3576 |
||
3577 |
if (!strcasecmp(subcmd, "reject")) |
|
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3578 |
action = EVS_CONTEXT_REJECT; |
748 | 3579 |
else if (!strcasecmp(subcmd, "accept")) |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3580 |
action = EVS_CONTEXT_ACCEPT; |
755 | 3581 |
else if (!strcasecmp(subcmd, "ignore")) |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3582 |
action = EVS_CONTEXT_CANCEL; |
748 | 3583 |
|
3584 |
if (action == -1) { |
|
3585 |
scr_LogPrint(LPRINT_NORMAL, "Wrong action parameter."); |
|
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3586 |
} else { |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
3587 |
GSList *p; |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3588 |
GSList *evidlst; |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
3589 |
|
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
3590 |
if (!strcmp(evid, "*")) { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
3591 |
// Use completion list |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3592 |
evidlst = evs_geteventslist(); |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
3593 |
} else { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
3594 |
// Let's create a slist with the provided event id |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3595 |
evidlst = g_slist_append(NULL, evid); |
748 | 3596 |
} |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
3597 |
for (p = evidlst; p; p = g_slist_next(p)) { |
1685
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3598 |
if (evs_callback(p->data, action, |
1342df44c814
Improved events interface
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1684
diff
changeset
|
3599 |
(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
|
3600 |
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
|
3601 |
(const char *)p->data); |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
3602 |
} |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
3603 |
} |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
3604 |
g_slist_free(evidlst); |
748 | 3605 |
} |
3606 |
||
3607 |
free_arg_lst(paramlst); |
|
3608 |
} |
|
3609 |
||
1066 | 3610 |
static void do_pgp(char *arg) |
3611 |
{ |
|
3612 |
char **paramlst; |
|
3613 |
char *fjid, *subcmd, *keyid; |
|
3614 |
enum { |
|
3615 |
pgp_none, |
|
3616 |
pgp_enable, |
|
3617 |
pgp_disable, |
|
3618 |
pgp_setkey, |
|
1197 | 3619 |
pgp_force, |
1066 | 3620 |
pgp_info |
3621 |
} op = 0; |
|
1197 | 3622 |
int force = FALSE; |
1066 | 3623 |
|
3624 |
paramlst = split_arg(arg, 3, 0); // subcmd, jid, [key] |
|
3625 |
subcmd = *paramlst; |
|
3626 |
fjid = *(paramlst+1); |
|
3627 |
keyid = *(paramlst+2); |
|
3628 |
||
3629 |
if (!subcmd) |
|
3630 |
fjid = NULL; |
|
3631 |
if (!fjid) |
|
3632 |
keyid = NULL; |
|
3633 |
||
3634 |
if (subcmd) { |
|
3635 |
if (!strcasecmp(subcmd, "enable")) |
|
3636 |
op = pgp_enable; |
|
3637 |
else if (!strcasecmp(subcmd, "disable")) |
|
3638 |
op = pgp_disable; |
|
3639 |
else if (!strcasecmp(subcmd, "setkey")) |
|
3640 |
op = pgp_setkey; |
|
1197 | 3641 |
else if ((!strcasecmp(subcmd, "force")) || |
3642 |
(!strcasecmp(subcmd, "+force"))) { |
|
3643 |
op = pgp_force; |
|
3644 |
force = TRUE; |
|
3645 |
} else if (!strcasecmp(subcmd, "-force")) |
|
3646 |
op = pgp_force; |
|
1066 | 3647 |
else if (!strcasecmp(subcmd, "info")) |
3648 |
op = pgp_info; |
|
3649 |
} |
|
3650 |
||
3651 |
if (!op) { |
|
3652 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized or missing parameter!"); |
|
3653 |
free_arg_lst(paramlst); |
|
3654 |
return; |
|
3655 |
} |
|
3656 |
||
3657 |
// Allow special jid "" or "." (current buddy) |
|
3658 |
if (fjid && (!*fjid || !strcmp(fjid, "."))) |
|
3659 |
fjid = NULL; |
|
3660 |
||
3661 |
if (fjid) { |
|
3662 |
// The JID has been specified. Quick check... |
|
3663 |
if (check_jid_syntax(fjid) || !strchr(fjid, '@')) { |
|
3664 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
|
3665 |
"<%s> is not a valid Jabber ID.", fjid); |
|
3666 |
fjid = NULL; |
|
3667 |
} else { |
|
3668 |
// Convert jid to lowercase and strip resource |
|
3669 |
char *p; |
|
3670 |
for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) |
|
3671 |
*p = tolower(*p); |
|
3672 |
if (*p == JID_RESOURCE_SEPARATOR) |
|
3673 |
*p = '\0'; |
|
3674 |
} |
|
3675 |
} else { |
|
3676 |
gpointer bud = NULL; |
|
3677 |
if (current_buddy) |
|
3678 |
bud = BUDDATA(current_buddy); |
|
3679 |
if (bud) { |
|
3680 |
guint type = buddy_gettype(bud); |
|
3681 |
if (type & ROSTER_TYPE_USER) // Is it a user? |
|
3682 |
fjid = (char*)buddy_getjid(bud); |
|
3683 |
else |
|
3684 |
scr_LogPrint(LPRINT_NORMAL, "The selected item should be a user."); |
|
3685 |
} |
|
3686 |
} |
|
3687 |
||
3688 |
if (fjid) { // fjid is actually a bare jid... |
|
1197 | 3689 |
guint disabled; |
1066 | 3690 |
GString *sbuf; |
3691 |
switch (op) { |
|
3692 |
case pgp_enable: |
|
3693 |
case pgp_disable: |
|
3694 |
settings_pgp_setdisabled(fjid, (op == pgp_disable ? TRUE : FALSE)); |
|
3695 |
break; |
|
1197 | 3696 |
case pgp_force: |
3697 |
settings_pgp_setforce(fjid, force); |
|
3698 |
break; |
|
1066 | 3699 |
case pgp_setkey: |
3700 |
settings_pgp_setkeyid(fjid, keyid); |
|
3701 |
break; |
|
3702 |
case pgp_info: |
|
3703 |
sbuf = g_string_new(""); |
|
3704 |
if (settings_pgp_getkeyid(fjid)) { |
|
3705 |
g_string_printf(sbuf, "PGP Encryption key id: %s", |
|
3706 |
settings_pgp_getkeyid(fjid)); |
|
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
3707 |
scr_WriteIncomingMessage(fjid, sbuf->str, 0, HBB_PREFIX_INFO, 0); |
1066 | 3708 |
} |
1197 | 3709 |
disabled = settings_pgp_getdisabled(fjid); |
1066 | 3710 |
g_string_printf(sbuf, "PGP encryption is %s", |
1197 | 3711 |
(disabled ? "disabled" : "enabled")); |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
3712 |
scr_WriteIncomingMessage(fjid, sbuf->str, 0, HBB_PREFIX_INFO, 0); |
1197 | 3713 |
if (!disabled && settings_pgp_getforce(fjid)) { |
3714 |
scr_WriteIncomingMessage(fjid, |
|
3715 |
"Encryption enforced (no negotiation)", |
|
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1279
diff
changeset
|
3716 |
0, HBB_PREFIX_INFO, 0); |
1197 | 3717 |
} |
1066 | 3718 |
g_string_free(sbuf, TRUE); |
3719 |
break; |
|
3720 |
default: |
|
3721 |
break; |
|
3722 |
} |
|
3723 |
} else { |
|
3724 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); |
|
3725 |
} |
|
3726 |
||
3727 |
free_arg_lst(paramlst); |
|
3728 |
} |
|
3729 |
||
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3730 |
static void do_otr(char *arg) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3731 |
{ |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3732 |
#ifdef HAVE_LIBOTR |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3733 |
char **paramlst; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3734 |
char *fjid, *subcmd, *keyid; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3735 |
enum { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3736 |
otr_none, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3737 |
otr_start, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3738 |
otr_stop, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3739 |
otr_fpr, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3740 |
otr_smpq, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3741 |
otr_smpr, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3742 |
otr_smpa, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3743 |
otr_k, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3744 |
otr_info |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3745 |
} op = 0; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3746 |
|
1347
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1341
diff
changeset
|
3747 |
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
|
3748 |
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
|
3749 |
"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
|
3750 |
return; |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1341
diff
changeset
|
3751 |
} |
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1341
diff
changeset
|
3752 |
|
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3753 |
paramlst = split_arg(arg, 3, 0); // subcmd, jid, [key] |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3754 |
subcmd = *paramlst; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3755 |
fjid = *(paramlst+1); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3756 |
keyid = *(paramlst+2); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3757 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3758 |
if (!subcmd) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3759 |
fjid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3760 |
if (!fjid) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3761 |
keyid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3762 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3763 |
if (subcmd) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3764 |
if (!strcasecmp(subcmd, "start")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3765 |
op = otr_start; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3766 |
else if (!strcasecmp(subcmd, "stop")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3767 |
op = otr_stop; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3768 |
else if (!strcasecmp(subcmd, "fingerprint")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3769 |
op = otr_fpr; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3770 |
else if (!strcasecmp(subcmd, "smpq")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3771 |
op = otr_smpq; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3772 |
else if (!strcasecmp(subcmd, "smpr")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3773 |
op = otr_smpr; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3774 |
else if (!strcasecmp(subcmd, "smpa")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3775 |
op = otr_smpa; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3776 |
else if (!strcasecmp(subcmd, "key")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3777 |
op = otr_k; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3778 |
else if (!strcasecmp(subcmd, "info")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3779 |
op = otr_info; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3780 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3781 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3782 |
if (!op) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3783 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized or missing parameter!"); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3784 |
free_arg_lst(paramlst); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3785 |
return; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3786 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3787 |
|
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
3788 |
if (op == otr_k) |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3789 |
otr_key(); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3790 |
else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3791 |
// Allow special jid "" or "." (current buddy) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3792 |
if (fjid && (!*fjid || !strcmp(fjid, "."))) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3793 |
fjid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3794 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3795 |
if (fjid) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3796 |
// The JID has been specified. Quick check... |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3797 |
if (check_jid_syntax(fjid) || !strchr(fjid, '@')) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3798 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3799 |
"<%s> is not a valid Jabber ID.", fjid); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3800 |
fjid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3801 |
} else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3802 |
// Convert jid to lowercase and strip resource |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3803 |
char *p; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3804 |
for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3805 |
*p = tolower(*p); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3806 |
if (*p == JID_RESOURCE_SEPARATOR) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3807 |
*p = '\0'; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3808 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3809 |
} else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3810 |
gpointer bud = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3811 |
if (current_buddy) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3812 |
bud = BUDDATA(current_buddy); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3813 |
if (bud) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3814 |
guint type = buddy_gettype(bud); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3815 |
if (type & ROSTER_TYPE_USER) // Is it a user? |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3816 |
fjid = (char*)buddy_getjid(bud); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3817 |
else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3818 |
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
|
3819 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3820 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3821 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3822 |
if (fjid) { // fjid is actually a bare jid... |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3823 |
switch (op) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3824 |
case otr_start: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3825 |
otr_establish(fjid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3826 |
case otr_stop: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3827 |
otr_disconnect(fjid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3828 |
case otr_fpr: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3829 |
otr_fingerprint(fjid, keyid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3830 |
case otr_smpq: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3831 |
otr_smp_query(fjid, keyid); break; |
1329 | 3832 |
case otr_smpr: |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3833 |
otr_smp_respond(fjid, keyid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3834 |
case otr_smpa: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3835 |
otr_smp_abort(fjid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3836 |
case otr_info: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3837 |
otr_print_info(fjid); break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3838 |
default: |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3839 |
break; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3840 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3841 |
} else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3842 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3843 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3844 |
free_arg_lst(paramlst); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3845 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3846 |
#else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3847 |
scr_LogPrint(LPRINT_NORMAL, "Please recompile mcabber with libotr enabled."); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3848 |
#endif /* HAVE_LIBOTR */ |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3849 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3850 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3851 |
#ifdef HAVE_LIBOTR |
1598 | 3852 |
static char *string_for_otrpolicy(enum otr_policy p) |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3853 |
{ |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3854 |
switch (p) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3855 |
case plain: return "plain"; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3856 |
case opportunistic: return "opportunistic"; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3857 |
case manual: return "manual"; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3858 |
case always: return "always"; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3859 |
default: return "unknown"; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3860 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3861 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3862 |
|
1598 | 3863 |
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
|
3864 |
{ |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3865 |
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
|
3866 |
string_for_otrpolicy(*(enum otr_policy*)v)); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3867 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3868 |
#endif |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3869 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3870 |
static void do_otrpolicy(char *arg) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3871 |
{ |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3872 |
#ifdef HAVE_LIBOTR |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3873 |
char **paramlst; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3874 |
char *fjid, *policy; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3875 |
enum otr_policy p; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3876 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3877 |
paramlst = split_arg(arg, 2, 0); // [jid|default] policy |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3878 |
fjid = *paramlst; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3879 |
policy = *(paramlst+1); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3880 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3881 |
if (!fjid && !policy) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3882 |
scr_LogPrint(LPRINT_NORMAL, "default otrpolicy: %s", |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3883 |
string_for_otrpolicy(settings_otr_getpolicy(NULL))); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3884 |
settings_foreach(SETTINGS_TYPE_OTR, &dump_otrpolicy, NULL); |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3885 |
free_arg_lst(paramlst); |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3886 |
return; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3887 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3888 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3889 |
if (!policy) { |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3890 |
scr_LogPrint(LPRINT_NORMAL, |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3891 |
"Please call otrpolicy correctly: /otrpolicy (default|jid) " |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3892 |
"(plain|manual|opportunistic|always)"); |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3893 |
free_arg_lst(paramlst); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3894 |
return; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3895 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3896 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3897 |
if (!strcasecmp(policy, "plain")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3898 |
p = plain; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3899 |
else if (!strcasecmp(policy, "manual")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3900 |
p = manual; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3901 |
else if (!strcasecmp(policy, "opportunistic")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3902 |
p = opportunistic; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3903 |
else if (!strcasecmp(policy, "always")) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3904 |
p = always; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3905 |
else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3906 |
/* Fail, we don't know _this_ policy*/ |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3907 |
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
|
3908 |
free_arg_lst(paramlst); |
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3909 |
return; |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3910 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3911 |
|
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1329
diff
changeset
|
3912 |
if (!strcasecmp(fjid, "default") || !strcasecmp(fjid, "*")) { |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3913 |
/*set default policy*/ |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3914 |
settings_otr_setpolicy(NULL, p); |
1301
37b41ed9ed35
Fixed compiler warnings
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1299
diff
changeset
|
3915 |
free_arg_lst(paramlst); |
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3916 |
return; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3917 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3918 |
// Allow special jid "" or "." (current buddy) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3919 |
if (fjid && (!*fjid || !strcmp(fjid, "."))) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3920 |
fjid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3921 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3922 |
if (fjid) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3923 |
// The JID has been specified. Quick check... |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3924 |
if (check_jid_syntax(fjid) || !strchr(fjid, '@')) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3925 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3926 |
"<%s> is not a valid Jabber ID.", fjid); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3927 |
fjid = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3928 |
} else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3929 |
// Convert jid to lowercase and strip resource |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3930 |
char *p; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3931 |
for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3932 |
*p = tolower(*p); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3933 |
if (*p == JID_RESOURCE_SEPARATOR) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3934 |
*p = '\0'; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3935 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3936 |
} else { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3937 |
gpointer bud = NULL; |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3938 |
if (current_buddy) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3939 |
bud = BUDDATA(current_buddy); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3940 |
if (bud) { |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3941 |
guint type = buddy_gettype(bud); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3942 |
if (type & ROSTER_TYPE_USER) // Is it a user? |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3943 |
fjid = (char*)buddy_getjid(bud); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3944 |
else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3945 |
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
|
3946 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3947 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3948 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3949 |
if (fjid) |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3950 |
settings_otr_setpolicy(fjid, p); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3951 |
else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3952 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a valid Jabber ID."); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3953 |
|
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3954 |
free_arg_lst(paramlst); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3955 |
#else |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3956 |
scr_LogPrint(LPRINT_NORMAL, "Please recompile mcabber with libotr enabled."); |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3957 |
#endif /* HAVE_LIBOTR */ |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3958 |
} |
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1292
diff
changeset
|
3959 |
|
1173
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3960 |
/* !!! |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3961 |
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
|
3962 |
in init_bindings(). |
960f34ec22a2
Add init_bindings() for default key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1172
diff
changeset
|
3963 |
*/ |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3964 |
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
|
3965 |
{ |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3966 |
if (!strcasecmp(arg, "fword")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3967 |
readline_forward_word(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3968 |
} else if (!strcasecmp(arg, "bword")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3969 |
readline_backward_word(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3970 |
} 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
|
3971 |
readline_forward_kill_word(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3972 |
} 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
|
3973 |
readline_backward_kill_word(); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3974 |
} else if (!strcasecmp(arg, "word_upcase")) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3975 |
readline_updowncase_word(1); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3976 |
} else if (!strcasecmp(arg, "word_downcase")) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3977 |
readline_updowncase_word(0); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3978 |
} else if (!strcasecmp(arg, "word_capit")) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3979 |
readline_capitalize_word(); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3980 |
} else if (!strcasecmp(arg, "fchar")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3981 |
readline_forward_char(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3982 |
} else if (!strcasecmp(arg, "bchar")) { |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3983 |
readline_backward_char(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3984 |
} 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
|
3985 |
readline_forward_kill_char(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3986 |
} 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
|
3987 |
readline_backward_kill_char(); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
3988 |
} 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
|
3989 |
readline_transpose_chars(); |
1190
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3990 |
} 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
|
3991 |
readline_hist_beginning_search_bwd(); |
be06bbe7e449
Add readline_hist_beginning_search_bwd/fwd functions
Mikael Berthe <mikael@lilotux.net>
parents:
1187
diff
changeset
|
3992 |
} 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
|
3993 |
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
|
3994 |
} 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
|
3995 |
readline_hist_prev(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3996 |
} 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
|
3997 |
readline_hist_next(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
3998 |
} 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
|
3999 |
readline_iline_start(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
4000 |
} 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
|
4001 |
readline_iline_end(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
4002 |
} 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
|
4003 |
readline_forward_kill_iline(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
4004 |
} 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
|
4005 |
readline_backward_kill_iline(); |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
4006 |
} 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
|
4007 |
readline_send_multiline(); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4008 |
} 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
|
4009 |
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
|
4010 |
} 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
|
4011 |
retval_for_cmds = readline_accept_line(TRUE); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4012 |
} else if (!strcasecmp(arg, "compl_cancel")) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4013 |
readline_cancel_completion(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4014 |
} else if (!strcasecmp(arg, "compl_do")) { |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4015 |
readline_do_completion(); |
1985
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1980
diff
changeset
|
4016 |
} else if (!strcasecmp(arg, "clear_history")) { |
0870005f7efc
Add command /iline clear_history
Mikael Berthe <mikael@lilotux.net>
parents:
1980
diff
changeset
|
4017 |
readline_clear_history(); |
1945
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4018 |
} else { |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4019 |
char **paramlst; |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4020 |
char *subcmd; |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4021 |
|
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4022 |
paramlst = split_arg(arg, 2, 0); // subcmd, arg |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4023 |
subcmd = *paramlst; |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4024 |
arg = *(paramlst+1); |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4025 |
|
1946
69f03eabe514
Complain when the iline subcommand is missing/incorrect
Mikael Berthe <mikael@lilotux.net>
parents:
1945
diff
changeset
|
4026 |
if (!subcmd || !*subcmd) { |
69f03eabe514
Complain when the iline subcommand is missing/incorrect
Mikael Berthe <mikael@lilotux.net>
parents:
1945
diff
changeset
|
4027 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
69f03eabe514
Complain when the iline subcommand is missing/incorrect
Mikael Berthe <mikael@lilotux.net>
parents:
1945
diff
changeset
|
4028 |
free_arg_lst(paramlst); |
69f03eabe514
Complain when the iline subcommand is missing/incorrect
Mikael Berthe <mikael@lilotux.net>
parents:
1945
diff
changeset
|
4029 |
return; |
69f03eabe514
Complain when the iline subcommand is missing/incorrect
Mikael Berthe <mikael@lilotux.net>
parents:
1945
diff
changeset
|
4030 |
} |
69f03eabe514
Complain when the iline subcommand is missing/incorrect
Mikael Berthe <mikael@lilotux.net>
parents:
1945
diff
changeset
|
4031 |
|
1945
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4032 |
if (!strcasecmp(subcmd, "iline_insert")) { |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4033 |
readline_insert(arg); |
1946
69f03eabe514
Complain when the iline subcommand is missing/incorrect
Mikael Berthe <mikael@lilotux.net>
parents:
1945
diff
changeset
|
4034 |
} else { |
69f03eabe514
Complain when the iline subcommand is missing/incorrect
Mikael Berthe <mikael@lilotux.net>
parents:
1945
diff
changeset
|
4035 |
scr_LogPrint(LPRINT_NORMAL, "Invalid subcommand."); |
1945
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4036 |
} |
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4037 |
|
518740bcd78b
Add /iline iline_insert (Hermitifier)
Mikael Berthe <mikael@lilotux.net>
parents:
1943
diff
changeset
|
4038 |
free_arg_lst(paramlst); |
1171
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
4039 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
4040 |
} |
03a38b7ad2e0
Add a collection of commands for key bindings (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1165
diff
changeset
|
4041 |
|
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4042 |
static void do_screen_refresh(char *arg) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4043 |
{ |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4044 |
readline_refresh_screen(); |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4045 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4046 |
|
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4047 |
static void do_chat_disable(char *arg) |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4048 |
{ |
1503
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
4049 |
guint show_roster; |
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
4050 |
|
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
4051 |
if (arg && !strcasecmp(arg, "--show-roster")) |
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
4052 |
show_roster = 1; |
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
4053 |
else |
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
4054 |
show_roster = 0; |
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
4055 |
|
c74cfe7fd848
Add option --show-roster to command chat_disable.
Mikael Berthe <mikael@lilotux.net>
parents:
1485
diff
changeset
|
4056 |
readline_disable_chat_mode(show_roster); |
1172
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4057 |
} |
334ae9f498f1
Add some more iline functions (Lego12239)
Mikael Berthe <mikael@lilotux.net>
parents:
1171
diff
changeset
|
4058 |
|
1675
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4059 |
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
|
4060 |
{ |
1939
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
4061 |
scr_LogPrint(LPRINT_DEBUG, "Source: glob (%s) error: %s.", |
932d1b250a55
Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents:
1938
diff
changeset
|
4062 |
path, strerror(eerrno)); |
1675
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4063 |
return 0; |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4064 |
} |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4065 |
|
1192 | 4066 |
static void do_source(char *arg) |
4067 |
{ |
|
4068 |
static int recur_level; |
|
1202
ede6c7aa59b0
Handle "~" in /source paths
Mikael Berthe <mikael@lilotux.net>
parents:
1197
diff
changeset
|
4069 |
gchar *filename, *expfname; |
1675
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4070 |
glob_t flist; |
1192 | 4071 |
if (!*arg) { |
4072 |
scr_LogPrint(LPRINT_NORMAL, "Missing filename."); |
|
4073 |
return; |
|
4074 |
} |
|
4075 |
if (recur_level > 20) { |
|
4076 |
scr_LogPrint(LPRINT_LOGNORM, "** Too many source commands!"); |
|
4077 |
return; |
|
4078 |
} |
|
4079 |
filename = g_strdup(arg); |
|
4080 |
strip_arg_special_chars(filename); |
|
1202
ede6c7aa59b0
Handle "~" in /source paths
Mikael Berthe <mikael@lilotux.net>
parents:
1197
diff
changeset
|
4081 |
expfname = expand_filename(filename); |
1192 | 4082 |
g_free(filename); |
1675
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4083 |
// match |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4084 |
flist.gl_offs = 0; |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4085 |
if (glob(expfname, 0, source_print_error, &flist)) { |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4086 |
scr_LogPrint(LPRINT_LOGNORM, "Source: error: %s.", strerror (errno)); |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4087 |
} else { |
1680 | 4088 |
unsigned int i; |
1675
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4089 |
// sort list |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4090 |
for (i = 1; i < flist.gl_pathc; ++i) { |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4091 |
int j; |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4092 |
for (j = i-1; j > 0; --j) { |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4093 |
char *a = flist.gl_pathv[j+1]; |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4094 |
char *b = flist.gl_pathv[j]; |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4095 |
if (strcmp(a, b) < 0) { |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4096 |
flist.gl_pathv[j] = a; |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4097 |
flist.gl_pathv[j+1] = b; |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4098 |
} else |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4099 |
break; |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4100 |
} |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4101 |
} |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4102 |
// source files in list |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4103 |
for (i=0; i < flist.gl_pathc; ++i) { |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4104 |
recur_level++; |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4105 |
cfg_read_file(flist.gl_pathv[i], FALSE); |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4106 |
recur_level--; |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4107 |
} |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4108 |
// free |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4109 |
globfree(&flist); |
c73b31124fa6
Use glob() in source command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
4110 |
} |
1202
ede6c7aa59b0
Handle "~" in /source paths
Mikael Berthe <mikael@lilotux.net>
parents:
1197
diff
changeset
|
4111 |
g_free(expfname); |
1192 | 4112 |
} |
4113 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
4114 |
static void do_connect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
4115 |
{ |
1598 | 4116 |
xmpp_connect(); |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
4117 |
} |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
4118 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
4119 |
static void do_disconnect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
4120 |
{ |
1598 | 4121 |
xmpp_disconnect(); |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
4122 |
} |
576 | 4123 |
|
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
4124 |
static void do_help(char *arg) |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
4125 |
{ |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
4126 |
help_process(arg); |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
4127 |
} |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
4128 |
|
1518
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1508
diff
changeset
|
4129 |
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
|
4130 |
{ |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1508
diff
changeset
|
4131 |
if (arg) |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1508
diff
changeset
|
4132 |
scr_print_logwindow(arg); |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1508
diff
changeset
|
4133 |
} |
63dc211a4c1a
New command: /echo (display a message in the log window)
Mikael Berthe <mikael@lilotux.net>
parents:
1508
diff
changeset
|
4134 |
|
1811 | 4135 |
/* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2: For Vim users... */ |