annotate mcabber/mcabber/commands.c @ 2020:46a21258ad91

Fix some compiler warnings
author Myhailo Danylenko <isbear@ukrpost.net>
date Sat, 28 Jul 2012 22:10:12 +0300
parents e9b6e168a45e
children f88de5187d3b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
1 /*
699
ee03b56b93ee Update Copyright (2006)
Mikael Berthe <mikael@lilotux.net>
parents: 696
diff changeset
2 * commands.c -- user commands handling
393
f8f3c7493457 Whitespace cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 384
diff changeset
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
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
5 *
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or (at
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
9 * your option) any later version.
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
10 *
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
14 * General Public License for more details.
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
15 *
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
19 * USA
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
20 */
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
21
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
22 #include <string.h>
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1592
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
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
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
31 #include "commands.h"
868
cefdaeb42e67 Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents: 867
diff changeset
32 #include "help.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
33 #include "roster.h"
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
34 #include "screen.h"
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
35 #include "compl.h"
113
8ac67e951eab [/trunk] Changeset 127 by mikael
mikael
parents: 108
diff changeset
36 #include "hooks.h"
191
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
37 #include "hbuf.h"
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
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
53a000411587 Add /event command
Mikael Berthe <mikael@lilotux.net>
parents: 740
diff changeset
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
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1592
diff changeset
43 #include "xmpp.h"
1653
fca9a4c17432 Improve UI latency and CPU usage
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1649
diff changeset
44 #include "main.h"
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
45
967
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
46 #define IMSTATUS_AWAY "away"
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
47 #define IMSTATUS_ONLINE "online"
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
48 #define IMSTATUS_OFFLINE "offline"
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
49 #define IMSTATUS_FREE4CHAT "free"
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
50 #define IMSTATUS_AVAILABLE "avail"
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
51 #define IMSTATUS_NOTAVAILABLE "notavail"
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
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
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
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
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
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
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
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
882e1acae422 Add /say_to command
Mikael Berthe <mikael@lilotux.net>
parents: 475
diff changeset
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
802da817a684 Add /rawxml command
Mikael Berthe <mikael@lilotux.net>
parents: 416
diff changeset
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
2b7ef605ddc6 Add /version command
Mikael Berthe <mikael@lilotux.net>
parents: 620
diff changeset
83 static void do_version(char *arg);
693
e98abd3ce28c Add /request command
Mikael Berthe <mikael@lilotux.net>
parents: 681
diff changeset
84 static void do_request(char *arg);
748
53a000411587 Add /event command
Mikael Berthe <mikael@lilotux.net>
parents: 740
diff changeset
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
6de60e142372 Add command /pgp
Mikael Berthe <mikael@lilotux.net>
parents: 1065
diff changeset
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
7b8765c10abb New command: /source
Mikael Berthe <mikael@lilotux.net>
parents: 1190
diff changeset
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
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
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
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
100 // Global variable for the commands list
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
103
1607
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
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
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
108 {
1649
44bbdc961234 Allow commands shading
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1648
diff changeset
109 GSList *sl_cmd;
1992
5dc408aacb14 Accept cmd_del(NULL)
Mikael Berthe <mikael@lilotux.net>
parents: 1988
diff changeset
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
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
120 return NULL;
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
121 }
1939
932d1b250a55 Simplify cmd_add() (Myhailo Danylenko)
Mikael Berthe <mikael@lilotux.net>
parents: 1938
diff changeset
122 #endif
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
123
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
124 // cmd_add()
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
128 {
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
129 cmd *n_cmd = g_new0(cmd, 1);
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
130 strncpy(n_cmd->name, name, 32-1);
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
131 n_cmd->help = help;
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
132 n_cmd->completion_flags[0] = flags_row1;
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
133 n_cmd->completion_flags[1] = flags_row2;
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
134 n_cmd->func = f;
1607
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
137 // Add to completion CMD category
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
140 }
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
184 void cmd_init(void)
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
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
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
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
d5ae42cbe1fa [/trunk] Changeset 237 by mikael
mikael
parents: 221
diff changeset
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
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
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
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
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
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
248 // Status category
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
249 compl_add_category_word(COMPL_STATUS, "online");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
254 compl_add_category_word(COMPL_STATUS, "free");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
255 compl_add_category_word(COMPL_STATUS, "dnd");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
256 compl_add_category_word(COMPL_STATUS, "notavail");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
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
93dcc4e15d4a [/trunk] Changeset 117 by mikael
mikael
parents: 102
diff changeset
260
93dcc4e15d4a [/trunk] Changeset 117 by mikael
mikael
parents: 102
diff changeset
261 // Roster category
93dcc4e15d4a [/trunk] Changeset 117 by mikael
mikael
parents: 102
diff changeset
262 compl_add_category_word(COMPL_ROSTER, "bottom");
265
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
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
93dcc4e15d4a [/trunk] Changeset 117 by mikael
mikael
parents: 102
diff changeset
272 compl_add_category_word(COMPL_ROSTER, "hide_offline");
93dcc4e15d4a [/trunk] Changeset 117 by mikael
mikael
parents: 102
diff changeset
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
a9013124ede6 Add "/roster alternate"
Mikael Berthe <mikael@lilotux.net>
parents: 318
diff changeset
278 compl_add_category_word(COMPL_ROSTER, "alternate");
265
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
279 compl_add_category_word(COMPL_ROSTER, "search");
236
72fd1273f2b7 [/trunk] Changeset 249 by mikael
mikael
parents: 232
diff changeset
280 compl_add_category_word(COMPL_ROSTER, "unread_first");
72fd1273f2b7 [/trunk] Changeset 249 by mikael
mikael
parents: 232
diff changeset
281 compl_add_category_word(COMPL_ROSTER, "unread_next");
1016
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
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
0f7ec11efd06 [/trunk] Changeset 140 by mikael
mikael
parents: 124
diff changeset
285
1626
055ea3cdbcd3 Fix buggy comment
Mikael Berthe <mikael@lilotux.net>
parents: 1607
diff changeset
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
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
288 compl_add_category_word(COMPL_BUFFER, "bottom");
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
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
e4840b288be0 Add "/buffer date"
Mikael Berthe <mikael@lilotux.net>
parents: 462
diff changeset
295 compl_add_category_word(COMPL_BUFFER, "date");
462
d580e87c11ed Add "/buffer %n"
Mikael Berthe <mikael@lilotux.net>
parents: 461
diff changeset
296 compl_add_category_word(COMPL_BUFFER, "%");
866
b30df2ab457f Add "/buffer purge"
Mikael Berthe <mikael@lilotux.net>
parents: 865
diff changeset
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
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
305
127
0f7ec11efd06 [/trunk] Changeset 140 by mikael
mikael
parents: 124
diff changeset
306 // Group category
240
723433a677f0 [/trunk] Changeset 253 by mikael
mikael
parents: 238
diff changeset
307 compl_add_category_word(COMPL_GROUP, "fold");
723433a677f0 [/trunk] Changeset 253 by mikael
mikael
parents: 238
diff changeset
308 compl_add_category_word(COMPL_GROUP, "unfold");
130
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
309 compl_add_category_word(COMPL_GROUP, "toggle");
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
310
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
311 // Multi-line (msay) category
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
312 compl_add_category_word(COMPL_MULTILINE, "abort");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
313 compl_add_category_word(COMPL_MULTILINE, "begin");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
314 compl_add_category_word(COMPL_MULTILINE, "send");
636
f84cce8382e8 Add "/msay send_to"
Mikael Berthe <mikael@lilotux.net>
parents: 631
diff changeset
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
d63e6cbdc297 Add "/room ban"
Mikael Berthe <mikael@lilotux.net>
parents: 570
diff changeset
322 compl_add_category_word(COMPL_ROOM, "ban");
1009
c112423ac012 Add /room bookmark
Mikael Berthe <mikael@lilotux.net>
parents: 1004
diff changeset
323 compl_add_category_word(COMPL_ROOM, "bookmark");
599
fb67bf62f4eb Add "/room destroy"
Mikael Berthe <mikael@lilotux.net>
parents: 598
diff changeset
324 compl_add_category_word(COMPL_ROOM, "destroy");
486
2a6a8ebb813b Add "/room invite"
Mikael Berthe <mikael@lilotux.net>
parents: 484
diff changeset
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
eb1df2371581 Add "/room kick"
Mikael Berthe <mikael@lilotux.net>
parents: 566
diff changeset
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
eaa2ad773192 Add "/room nick"
Mikael Berthe <mikael@lilotux.net>
parents: 469
diff changeset
330 compl_add_category_word(COMPL_ROOM, "nick");
490
af6e31e32d9e Add "/room privmsg"
Mikael Berthe <mikael@lilotux.net>
parents: 488
diff changeset
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
e08b0c2d0e54 Add "/room unlock"
Mikael Berthe <mikael@lilotux.net>
parents: 448
diff changeset
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
e98abd3ce28c Add /request command
Mikael Berthe <mikael@lilotux.net>
parents: 681
diff changeset
345
e98abd3ce28c Add /request command
Mikael Berthe <mikael@lilotux.net>
parents: 681
diff changeset
346 // Request (query) category
1015
579299b1c9b2 Add /request last
Mikael Berthe <mikael@lilotux.net>
parents: 1014
diff changeset
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
e98abd3ce28c Add /request command
Mikael Berthe <mikael@lilotux.net>
parents: 681
diff changeset
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
e98abd3ce28c Add /request command
Mikael Berthe <mikael@lilotux.net>
parents: 681
diff changeset
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
b747f76e57ae Add "/event n ignore"
Mikael Berthe <mikael@lilotux.net>
parents: 750
diff changeset
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
6de60e142372 Add command /pgp
Mikael Berthe <mikael@lilotux.net>
parents: 1065
diff changeset
357
6de60e142372 Add command /pgp
Mikael Berthe <mikael@lilotux.net>
parents: 1065
diff changeset
358 // PGP category
6de60e142372 Add command /pgp
Mikael Berthe <mikael@lilotux.net>
parents: 1065
diff changeset
359 compl_add_category_word(COMPL_PGP, "disable");
6de60e142372 Add command /pgp
Mikael Berthe <mikael@lilotux.net>
parents: 1065
diff changeset
360 compl_add_category_word(COMPL_PGP, "enable");
1197
6f602d3270a4 Add /pgp [-]force
Mikael Berthe <mikael@lilotux.net>
parents: 1192
diff changeset
361 compl_add_category_word(COMPL_PGP, "force");
1066
6de60e142372 Add command /pgp
Mikael Berthe <mikael@lilotux.net>
parents: 1065
diff changeset
362 compl_add_category_word(COMPL_PGP, "info");
6de60e142372 Add command /pgp
Mikael Berthe <mikael@lilotux.net>
parents: 1065
diff changeset
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
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
393 }
94
9a4aa2797f02 [/trunk] Changeset 108 by mikael
mikael
parents: 81
diff changeset
394
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
395 // expandalias(line)
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
396 // If there is one, expand the alias in line and returns a new allocated line
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
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
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
401 {
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
402 const char *p1, *p2;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
403 char *word;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
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
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
406
967
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
407 // Ignore leading COMMAND_CHAR
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
408 for (p1 = line ; *p1 == COMMAND_CHAR ; p1++)
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
409 ;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
410 // Locate the end of the word
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
411 for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++)
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
412 ;
1387
3067c096cfc4 Small code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
413 // Extract the word and look for an alias in the list
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
414 word = g_strndup(p1, p2-p1);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
415 value = settings_get(SETTINGS_TYPE_ALIAS, (const char*)word);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
416 g_free(word);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
417
1387
3067c096cfc4 Small code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
418 if (value)
3067c096cfc4 Small code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
419 newline = g_strdup_printf("%c%s%s", COMMAND_CHAR, value, p2);
3067c096cfc4 Small code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1381
diff changeset
420
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
421 return newline;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
422 }
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
423
102
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
424 // cmd_get
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
425 // Finds command in the command list structure.
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
426 // Returns a pointer to the cmd entry, or NULL if command not found.
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
427 cmd *cmd_get(const char *command)
102
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
428 {
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
429 const char *p1, *p2;
102
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
430 char *com;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
431 GSList *sl_com;
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
432
967
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
433 // Ignore leading COMMAND_CHAR
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
434 for (p1 = command ; *p1 == COMMAND_CHAR ; p1++)
102
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
435 ;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
436 // Locate the end of the command
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
437 for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++)
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
438 ;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
439 // Copy the clean command
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
440 com = g_strndup(p1, p2-p1);
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
441
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
442 // Look for command in the list
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
443 for (sl_com=Commands; sl_com; sl_com = g_slist_next(sl_com)) {
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
444 if (!strcasecmp(com, ((cmd*)sl_com->data)->name))
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
445 break;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
446 }
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
447 g_free(com);
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
448
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
449 if (sl_com) // Command has been found.
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
450 return (cmd*)sl_com->data;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
451 return NULL;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
452 }
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
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
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
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
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
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
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
460 {
101
4f3ad00b5187 [/trunk] Changeset 115 by mikael
mikael
parents: 98
diff changeset
461 char *p;
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
462 char *xpline;
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
463 cmd *curcmd;
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
464
1365
c7e709719c43 Small code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1363
diff changeset
465 if (!line)
c7e709719c43 Small code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1363
diff changeset
466 return 0;
c7e709719c43 Small code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1363
diff changeset
467
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
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
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
470 xpline = expandalias(line);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
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
4f3ad00b5187 [/trunk] Changeset 115 by mikael
mikael
parents: 98
diff changeset
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
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
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
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
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
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
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
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
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
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
508 // Commands handling
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
509 curcmd = cmd_get(xpline);
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
510
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
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
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
515 return 0;
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
516 }
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
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
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
521 return 0;
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
522 }
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
523 // Lets go to the command parameters
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
524 for (p = xpline+1; *p && (*p != ' ') ; p++)
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
525 ;
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
526 // Skip spaces
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
527 while (*p && (*p == ' '))
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
528 p++;
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
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
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
531 #ifdef MODULES_ENABLE
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
532 if (curcmd->userdata)
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
533 (*(void (*)(char *p, gpointer u))curcmd->func)(p, curcmd->userdata);
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
534 else
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
535 (*curcmd->func)(p);
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
536 #else
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
537 (*curcmd->func)(p);
1607
14690e624e9d Add modules
Myhailo Danylenko <isbear@ukrpost.net>
parents: 1603
diff changeset
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
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
541 }
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
542
288
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
543 // process_line(line)
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
544 // Process a command/message line.
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
545 // If this isn't a command, this is a message and it is sent to the
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
546 // currently selected buddy.
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
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
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
549 {
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
550 if (!*line) { // User only pressed enter
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
551 if (scr_get_multimode()) {
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
552 scr_append_multiline("");
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
553 return 0;
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
554 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
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
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
563 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
564 return 0;
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
565 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
566
967
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
567 if (*line != COMMAND_CHAR) {
288
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
568 // This isn't a command
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
569 if (scr_get_multimode())
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
570 scr_append_multiline(line);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
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
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
573 return 0;
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
574 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
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
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
578 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
588 if (bjid && (!*bjid || !strcmp(bjid, ".")))
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
589 bjid = NULL;
974
36f7753dfb59 Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents: 968
diff changeset
590
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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(&note->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(&note->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
875d2c9d399c Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1058
diff changeset
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
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1592
diff changeset
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
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
756 static void roster_note(char *arg)
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
757 {
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
758 const char *bjid;
1016
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
759 guint type;
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
760
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
761 if (!current_buddy)
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
762 return;
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
763
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
764 bjid = buddy_getjid(BUDDATA(current_buddy));
1016
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
765 type = buddy_gettype(BUDDATA(current_buddy));
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
766
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
774 if (!bjid || (type != ROSTER_TYPE_USER &&
1016
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
775 type != ROSTER_TYPE_ROOM &&
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
776 type != ROSTER_TYPE_AGENT)) {
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
777 scr_LogPrint(LPRINT_NORMAL, "This item can't have a note.");
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
778 return;
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
779 }
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
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
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
783 msg = to_utf8(arg);
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
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
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
786 else
1019
9d5f6e0ea7b3 XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents: 1016
diff changeset
787 notetxt = msg;
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1592
diff changeset
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
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
790 } else { // Display a note
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1592
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
798 }
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
799 }
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
800
1573
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
diff changeset
801 // roster_updown(updown, nitems)
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
diff changeset
802 // updown: -1=up, +1=down
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
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: 1562
diff changeset
804 {
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
diff changeset
805 int nbitems;
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
diff changeset
806
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
diff changeset
807 if (!nitems || !*nitems)
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
diff changeset
808 nbitems = 1;
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
diff changeset
809 else
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
diff changeset
810 nbitems = strtol(nitems, NULL, 10);
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
diff changeset
811
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
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);
1573
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
diff changeset
814 }
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
diff changeset
815
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
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
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
819
336
eb994ee40029 Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents: 330
diff changeset
820 static void do_roster(char *arg)
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
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
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
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
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
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
cfd3df636d5f [/trunk] Changeset 133 by mikael
mikael
parents: 118
diff changeset
848 buddylist_set_hide_offline_buddies(TRUE);
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
849 if (current_buddy)
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
850 buddylist_build();
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
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
cfd3df636d5f [/trunk] Changeset 133 by mikael
mikael
parents: 118
diff changeset
853 buddylist_set_hide_offline_buddies(FALSE);
124
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
854 buddylist_build();
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
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
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
879 return;
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
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
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
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")) {
1573
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
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")) {
1573
ece4f26bf9ff Add count parameter to roster up/down command
Mikael Berthe <mikael@lilotux.net>
parents: 1562
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
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
891 } else if (!strcasecmp(subcmd, "note")) {
4d3c48844746 Add /roster note
Mikael Berthe <mikael@lilotux.net>
parents: 1015
diff changeset
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
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
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
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
900 }
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 104
diff changeset
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
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
981 // Set your Jabber status.
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
982 // - if recipient is not NULL, the status is sent to this contact only
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
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
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
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
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
989 enum imstatus st;
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
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
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
1010 if (!strcasecmp(status, IMSTATUS_OFFLINE)) st = offline;
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
1011 else if (!strcasecmp(status, IMSTATUS_ONLINE)) st = available;
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
1012 else if (!strcasecmp(status, IMSTATUS_AVAILABLE)) st = available;
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
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
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
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
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
1017 else if (!strcasecmp(status, IMSTATUS_DONOTDISTURB)) st = dontdisturb;
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
1018 else if (!strcasecmp(status, IMSTATUS_NOTAVAILABLE)) st = notavail;
303408ef5e5d Configurable command character
Alexis Hildebrandt
parents: 960
diff changeset
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
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1592
diff changeset
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
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
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
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
1031 return;
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
1032 }
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
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
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1592
diff changeset
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
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
1046 }
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
1047
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
1048 static void do_status(char *arg)
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
1049 {
557
c72a66dfd2d4 Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents: 555
diff changeset
1050 if (!*arg) {
1598
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1592
diff changeset
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
a087125d8fc8 Replace libjabber with loudmouth
franky
parents: 1592
diff changeset
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
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
1055 return;
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
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
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
1060 }
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
1061
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
1062 static void do_status_to(char *arg)
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
1063 {
557
c72a66dfd2d4 Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents: 555
diff changeset
1064 char **paramlst;
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
5927c3bfba13 Add /status_to command
Mikael Berthe <mikael@lilotux.net>
parents: 439
diff changeset
1072
1058
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
1081 if (!*fjid || !strcmp(fjid, "."))
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
1100 fjid = (char*)buddy_getjid(BUDDATA(current_buddy));
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
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
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
1105 if (fjid) {
c0d44a9a99bc Code cleanup
Mikael Berthe <mikael@lilotux.net>
parents: 1055
diff changeset
1106 char *cmdline;