author | Mikael Berthe <mikael@lilotux.net> |
Fri, 16 Dec 2005 13:34:13 +0100 | |
changeset 617 | d3a8b43bf9e7 |
parent 608 | 89f5672eb523 |
child 620 | 97dd14e22b2a |
permissions | -rw-r--r-- |
47 | 1 |
/* |
2 |
* commands.c -- user commands handling |
|
393 | 3 |
* |
47 | 4 |
* Copyright (C) 2005 Mikael Berthe <bmikael@lists.lilotux.net> |
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or modify |
|
7 |
* it under the terms of the GNU General Public License as published by |
|
8 |
* the Free Software Foundation; either version 2 of the License, or (at |
|
9 |
* your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but |
|
12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
* General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
19 |
* USA |
|
20 |
*/ |
|
21 |
||
95 | 22 |
#include <string.h> |
23 |
||
47 | 24 |
#include "commands.h" |
25 |
#include "jabglue.h" |
|
81 | 26 |
#include "roster.h" |
47 | 27 |
#include "screen.h" |
95 | 28 |
#include "compl.h" |
113 | 29 |
#include "hooks.h" |
191 | 30 |
#include "hbuf.h" |
47 | 31 |
#include "utils.h" |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
32 |
#include "settings.h" |
47 | 33 |
|
104 | 34 |
// Commands callbacks |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
35 |
static void do_roster(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
36 |
static void do_status(char *arg); |
444 | 37 |
static void do_status_to(char *arg); |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
38 |
static void do_add(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
39 |
static void do_del(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
40 |
static void do_group(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
41 |
static void do_say(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
42 |
static void do_msay(char *arg); |
480 | 43 |
static void do_say_to(char *arg); |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
44 |
static void do_buffer(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
45 |
static void do_clear(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
46 |
static void do_info(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
47 |
static void do_rename(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
48 |
static void do_move(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
49 |
static void do_set(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
50 |
static void do_alias(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
51 |
static void do_bind(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
52 |
static void do_connect(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
53 |
static void do_disconnect(char *arg); |
436 | 54 |
static void do_rawxml(char *arg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
55 |
static void do_room(char *arg); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
56 |
static void do_authorization(char *arg); |
47 | 57 |
|
104 | 58 |
// Global variable for the commands list |
95 | 59 |
static GSList *Commands; |
60 |
||
104 | 61 |
|
95 | 62 |
// cmd_add() |
63 |
// Adds a command to the commands list and to the CMD completion list |
|
64 |
void cmd_add(const char *name, const char *help, |
|
104 | 65 |
guint flags_row1, guint flags_row2, void (*f)()) |
95 | 66 |
{ |
67 |
cmd *n_cmd = g_new0(cmd, 1); |
|
68 |
strncpy(n_cmd->name, name, 32-1); |
|
69 |
n_cmd->help = help; |
|
70 |
n_cmd->completion_flags[0] = flags_row1; |
|
71 |
n_cmd->completion_flags[1] = flags_row2; |
|
72 |
n_cmd->func = f; |
|
102 | 73 |
Commands = g_slist_append(Commands, n_cmd); |
95 | 74 |
// Add to completion CMD category |
75 |
compl_add_category_word(COMPL_CMD, name); |
|
76 |
} |
|
77 |
||
78 |
// cmd_init() |
|
79 |
// ... |
|
80 |
void cmd_init(void) |
|
81 |
{ |
|
124 | 82 |
cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add); |
285 | 83 |
cmd_add("alias", "Add an alias", 0, 0, &do_alias); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
84 |
cmd_add("authorization", "Manage subscription authorizations", |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
85 |
COMPL_AUTH, COMPL_JID, &do_authorization); |
288 | 86 |
cmd_add("bind", "Add an key binding", 0, 0, &do_bind); |
187 | 87 |
cmd_add("buffer", "Manipulate current buddy's buffer (chat window)", |
88 |
COMPL_BUFFER, 0, &do_buffer); |
|
108 | 89 |
cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear); |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
90 |
cmd_add("connect", "Connect to the server", 0, 0, &do_connect); |
205 | 91 |
cmd_add("del", "Delete the current buddy", 0, 0, &do_del); |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
92 |
cmd_add("disconnect", "Disconnect from server", 0, 0, &do_disconnect); |
128 | 93 |
cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group); |
262
ab6f83a82811
Do not add /help to command completion, as it isn't implemented yet.
mikael@frmp8452
parents:
260
diff
changeset
|
94 |
//cmd_add("help", "Display some help", COMPL_CMD, 0, NULL); |
191 | 95 |
cmd_add("info", "Show basic infos on current buddy", 0, 0, &do_info); |
225 | 96 |
cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, |
97 |
0, &do_move); |
|
238 | 98 |
cmd_add("msay", "Send a multi-lines message to the selected buddy", |
99 |
COMPL_MULTILINE, 0, &do_msay); |
|
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
100 |
cmd_add("room", "MUC actions command", COMPL_ROOM, 0, &do_room); |
95 | 101 |
cmd_add("quit", "Exit the software", 0, 0, NULL); |
436 | 102 |
cmd_add("rawxml", "Send a raw XML string", 0, 0, &do_rawxml); |
208 | 103 |
cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename); |
128 | 104 |
cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, |
105 |
&do_roster); |
|
132 | 106 |
cmd_add("say", "Say something to the selected buddy", 0, 0, &do_say); |
488
9e8519078e00
Enable jid completion for /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
486
diff
changeset
|
107 |
cmd_add("say_to", "Say something to a specific buddy", COMPL_JID, 0, |
9e8519078e00
Enable jid completion for /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
486
diff
changeset
|
108 |
&do_say_to); |
95 | 109 |
//cmd_add("search"); |
310 | 110 |
cmd_add("set", "Set/query an option value", 0, 0, &do_set); |
116 | 111 |
cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status); |
444 | 112 |
cmd_add("status_to", "Show or set your status for one recipient", |
113 |
COMPL_JID, COMPL_STATUS, &do_status_to); |
|
95 | 114 |
|
115 |
// Status category |
|
116 |
compl_add_category_word(COMPL_STATUS, "online"); |
|
117 |
compl_add_category_word(COMPL_STATUS, "avail"); |
|
118 |
compl_add_category_word(COMPL_STATUS, "invisible"); |
|
119 |
compl_add_category_word(COMPL_STATUS, "free"); |
|
120 |
compl_add_category_word(COMPL_STATUS, "dnd"); |
|
121 |
compl_add_category_word(COMPL_STATUS, "notavail"); |
|
122 |
compl_add_category_word(COMPL_STATUS, "away"); |
|
103 | 123 |
|
124 |
// Roster category |
|
125 |
compl_add_category_word(COMPL_ROSTER, "bottom"); |
|
265 | 126 |
compl_add_category_word(COMPL_ROSTER, "top"); |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
127 |
compl_add_category_word(COMPL_ROSTER, "up"); |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
128 |
compl_add_category_word(COMPL_ROSTER, "down"); |
103 | 129 |
compl_add_category_word(COMPL_ROSTER, "hide_offline"); |
130 |
compl_add_category_word(COMPL_ROSTER, "show_offline"); |
|
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
131 |
compl_add_category_word(COMPL_ROSTER, "toggle_offline"); |
330 | 132 |
compl_add_category_word(COMPL_ROSTER, "alternate"); |
265 | 133 |
compl_add_category_word(COMPL_ROSTER, "search"); |
236 | 134 |
compl_add_category_word(COMPL_ROSTER, "unread_first"); |
135 |
compl_add_category_word(COMPL_ROSTER, "unread_next"); |
|
127 | 136 |
|
187 | 137 |
// Roster category |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
138 |
compl_add_category_word(COMPL_BUFFER, "clear"); |
187 | 139 |
compl_add_category_word(COMPL_BUFFER, "bottom"); |
140 |
compl_add_category_word(COMPL_BUFFER, "top"); |
|
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
141 |
compl_add_category_word(COMPL_BUFFER, "up"); |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
142 |
compl_add_category_word(COMPL_BUFFER, "down"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
143 |
compl_add_category_word(COMPL_BUFFER, "search_backward"); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
144 |
compl_add_category_word(COMPL_BUFFER, "search_forward"); |
464 | 145 |
compl_add_category_word(COMPL_BUFFER, "date"); |
462 | 146 |
compl_add_category_word(COMPL_BUFFER, "%"); |
187 | 147 |
|
127 | 148 |
// Group category |
240 | 149 |
compl_add_category_word(COMPL_GROUP, "fold"); |
150 |
compl_add_category_word(COMPL_GROUP, "unfold"); |
|
130 | 151 |
compl_add_category_word(COMPL_GROUP, "toggle"); |
238 | 152 |
|
153 |
// Multi-line (msay) category |
|
154 |
compl_add_category_word(COMPL_MULTILINE, "abort"); |
|
155 |
compl_add_category_word(COMPL_MULTILINE, "begin"); |
|
156 |
compl_add_category_word(COMPL_MULTILINE, "send"); |
|
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
157 |
compl_add_category_word(COMPL_MULTILINE, "verbatim"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
158 |
|
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
159 |
// Room category |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
160 |
compl_add_category_word(COMPL_ROOM, "affil"); |
571 | 161 |
compl_add_category_word(COMPL_ROOM, "ban"); |
599 | 162 |
compl_add_category_word(COMPL_ROOM, "destroy"); |
486 | 163 |
compl_add_category_word(COMPL_ROOM, "invite"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
164 |
compl_add_category_word(COMPL_ROOM, "join"); |
568 | 165 |
compl_add_category_word(COMPL_ROOM, "kick"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
166 |
compl_add_category_word(COMPL_ROOM, "leave"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
167 |
compl_add_category_word(COMPL_ROOM, "names"); |
470 | 168 |
compl_add_category_word(COMPL_ROOM, "nick"); |
490 | 169 |
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
|
170 |
compl_add_category_word(COMPL_ROOM, "remove"); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
171 |
compl_add_category_word(COMPL_ROOM, "role"); |
475
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
172 |
compl_add_category_word(COMPL_ROOM, "topic"); |
449 | 173 |
compl_add_category_word(COMPL_ROOM, "unlock"); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
174 |
compl_add_category_word(COMPL_ROOM, "whois"); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
175 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
176 |
// Authorization category |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
177 |
compl_add_category_word(COMPL_AUTH, "allow"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
178 |
compl_add_category_word(COMPL_AUTH, "cancel"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
179 |
compl_add_category_word(COMPL_AUTH, "request"); |
95 | 180 |
} |
94 | 181 |
|
285 | 182 |
// expandalias(line) |
183 |
// If there is one, expand the alias in line and returns a new allocated line |
|
184 |
// If no alias is found, returns line |
|
185 |
// Note : if the returned pointer is different from line, the caller should |
|
186 |
// g_free() the pointer after use |
|
187 |
char *expandalias(char *line) |
|
188 |
{ |
|
189 |
const char *p1, *p2; |
|
190 |
char *word; |
|
191 |
const gchar *value; |
|
192 |
char *newline = line; |
|
193 |
||
194 |
// Ignore leading '/' |
|
195 |
for (p1 = line ; *p1 == '/' ; p1++) |
|
196 |
; |
|
197 |
// Locate the end of the word |
|
198 |
for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) |
|
199 |
; |
|
200 |
// Extract the word |
|
201 |
word = g_strndup(p1, p2-p1); |
|
202 |
||
203 |
// Look for an alias in the list |
|
204 |
value = settings_get(SETTINGS_TYPE_ALIAS, (const char*)word); |
|
205 |
if (value) { |
|
206 |
// There is an alias to expand |
|
207 |
newline = g_new(char, strlen(value)+strlen(p2)+2); |
|
208 |
*newline = '/'; |
|
209 |
strcpy(newline+1, value); |
|
210 |
strcat(newline, p2); |
|
211 |
} |
|
212 |
g_free(word); |
|
213 |
||
214 |
return newline; |
|
215 |
} |
|
216 |
||
102 | 217 |
// cmd_get |
218 |
// Finds command in the command list structure. |
|
219 |
// Returns a pointer to the cmd entry, or NULL if command not found. |
|
238 | 220 |
cmd *cmd_get(const char *command) |
102 | 221 |
{ |
238 | 222 |
const char *p1, *p2; |
102 | 223 |
char *com; |
224 |
GSList *sl_com; |
|
285 | 225 |
|
102 | 226 |
// Ignore leading '/' |
227 |
for (p1 = command ; *p1 == '/' ; p1++) |
|
228 |
; |
|
229 |
// Locate the end of the command |
|
230 |
for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) |
|
231 |
; |
|
232 |
// Copy the clean command |
|
233 |
com = g_strndup(p1, p2-p1); |
|
234 |
||
235 |
// Look for command in the list |
|
236 |
for (sl_com=Commands; sl_com; sl_com = g_slist_next(sl_com)) { |
|
237 |
if (!strcasecmp(com, ((cmd*)sl_com->data)->name)) |
|
238 |
break; |
|
239 |
} |
|
240 |
g_free(com); |
|
241 |
||
242 |
if (sl_com) // Command has been found. |
|
243 |
return (cmd*)sl_com->data; |
|
244 |
return NULL; |
|
245 |
} |
|
246 |
||
47 | 247 |
// send_message(msg) |
248 |
// Write the message in the buddy's window and send the message on |
|
249 |
// the network. |
|
238 | 250 |
void send_message(const char *msg) |
47 | 251 |
{ |
81 | 252 |
const char *jid; |
393 | 253 |
|
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
254 |
if (!jb_getonline()) { |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
255 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
256 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
257 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
258 |
|
81 | 259 |
if (!current_buddy) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
260 |
scr_LogPrint(LPRINT_NORMAL, "No buddy currently selected."); |
81 | 261 |
return; |
262 |
} |
|
263 |
||
264 |
jid = CURRENT_JID; |
|
265 |
if (!jid) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
266 |
scr_LogPrint(LPRINT_NORMAL, "No buddy currently selected."); |
81 | 267 |
return; |
268 |
} |
|
47 | 269 |
|
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
270 |
if (buddy_gettype(BUDDATA(current_buddy)) != ROSTER_TYPE_ROOM) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
271 |
// local part (UI, logging, etc.) |
484
00e2d3821a5b
Display PRIV for private messages in a room when using /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
272 |
hk_message_out(jid, NULL, 0, msg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
273 |
} |
47 | 274 |
|
275 |
// Network part |
|
475
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
276 |
jb_send_msg(jid, msg, buddy_gettype(BUDDATA(current_buddy)), NULL); |
47 | 277 |
} |
278 |
||
288 | 279 |
// process_command(line) |
280 |
// Process a command line. |
|
281 |
// Return 255 if this is the /quit command, and 0 for the other commands. |
|
282 |
int process_command(char *line) |
|
47 | 283 |
{ |
101 | 284 |
char *p; |
285 | 285 |
char *xpline; |
104 | 286 |
cmd *curcmd; |
287 |
||
101 | 288 |
// Remove trailing spaces: |
289 |
for (p=line ; *p ; p++) |
|
290 |
; |
|
291 |
for (p-- ; p>line && (*p == ' ') ; p--) |
|
292 |
*p = 0; |
|
293 |
||
285 | 294 |
// We do alias expansion here |
288 | 295 |
if (scr_get_multimode() != 2) |
296 |
xpline = expandalias(line); |
|
297 |
else |
|
298 |
xpline = line; // No expansion in verbatim multi-line mode |
|
285 | 299 |
|
101 | 300 |
// Command "quit"? |
285 | 301 |
if ((!strncasecmp(xpline, "/quit", 5)) && (scr_get_multimode() != 2) ) |
302 |
if (!xpline[5] || xpline[5] == ' ') |
|
116 | 303 |
return 255; |
104 | 304 |
|
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
305 |
// If verbatim multi-line mode, we check if another /msay command is typed |
285 | 306 |
if ((scr_get_multimode() == 2) && (strncasecmp(xpline, "/msay ", 6))) { |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
307 |
// It isn't an /msay command |
285 | 308 |
scr_append_multiline(xpline); |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
309 |
return 0; |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
310 |
} |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
311 |
|
47 | 312 |
// Commands handling |
285 | 313 |
curcmd = cmd_get(xpline); |
47 | 314 |
|
104 | 315 |
if (!curcmd) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
316 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized command, sorry."); |
285 | 317 |
if (xpline != line) g_free(xpline); |
104 | 318 |
return 0; |
319 |
} |
|
320 |
if (!curcmd->func) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
321 |
scr_LogPrint(LPRINT_NORMAL, "Not yet implemented, sorry."); |
285 | 322 |
if (xpline != line) g_free(xpline); |
104 | 323 |
return 0; |
324 |
} |
|
325 |
// Lets go to the command parameters |
|
285 | 326 |
for (p = xpline+1; *p && (*p != ' ') ; p++) |
104 | 327 |
; |
328 |
// Skip spaces |
|
285 | 329 |
while (*p && (*p == ' ')) |
330 |
p++; |
|
104 | 331 |
// Call command-specific function |
285 | 332 |
(*curcmd->func)(p); |
333 |
if (xpline != line) g_free(xpline); |
|
47 | 334 |
return 0; |
335 |
} |
|
336 |
||
288 | 337 |
// process_line(line) |
338 |
// Process a command/message line. |
|
339 |
// If this isn't a command, this is a message and it is sent to the |
|
340 |
// currently selected buddy. |
|
341 |
// Return 255 if the line is the /quit command, or 0. |
|
342 |
int process_line(char *line) |
|
343 |
{ |
|
344 |
if (!*line) { // User only pressed enter |
|
345 |
if (scr_get_multimode()) { |
|
346 |
scr_append_multiline(""); |
|
347 |
return 0; |
|
348 |
} |
|
349 |
if (current_buddy) { |
|
350 |
scr_set_chatmode(TRUE); |
|
351 |
buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
|
352 |
scr_ShowBuddyWindow(); |
|
353 |
} |
|
354 |
return 0; |
|
355 |
} |
|
356 |
||
357 |
if (*line != '/') { |
|
358 |
// This isn't a command |
|
359 |
if (scr_get_multimode()) |
|
360 |
scr_append_multiline(line); |
|
361 |
else |
|
362 |
do_say(line); |
|
363 |
return 0; |
|
364 |
} |
|
365 |
||
366 |
/* It is (probably) a command -- except for verbatim multi-line mode */ |
|
367 |
return process_command(line); |
|
368 |
} |
|
369 |
||
104 | 370 |
/* Commands callback functions */ |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
371 |
/* 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
|
372 |
/* (with arg not null) */ |
104 | 373 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
374 |
static void do_roster(char *arg) |
104 | 375 |
{ |
376 |
if (!strcasecmp(arg, "top")) { |
|
377 |
scr_RosterTop(); |
|
128 | 378 |
update_roster = TRUE; |
104 | 379 |
} else if (!strcasecmp(arg, "bottom")) { |
380 |
scr_RosterBottom(); |
|
128 | 381 |
update_roster = TRUE; |
104 | 382 |
} else if (!strcasecmp(arg, "hide_offline")) { |
120 | 383 |
buddylist_set_hide_offline_buddies(TRUE); |
104 | 384 |
if (current_buddy) |
385 |
buddylist_build(); |
|
128 | 386 |
update_roster = TRUE; |
104 | 387 |
} else if (!strcasecmp(arg, "show_offline")) { |
120 | 388 |
buddylist_set_hide_offline_buddies(FALSE); |
124 | 389 |
buddylist_build(); |
128 | 390 |
update_roster = TRUE; |
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
391 |
} else if (!strcasecmp(arg, "toggle_offline")) { |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
392 |
buddylist_set_hide_offline_buddies(-1); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
393 |
buddylist_build(); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
394 |
update_roster = TRUE; |
236 | 395 |
} else if (!strcasecmp(arg, "unread_first")) { |
396 |
scr_RosterUnreadMessage(0); |
|
397 |
} else if (!strcasecmp(arg, "unread_next")) { |
|
398 |
scr_RosterUnreadMessage(1); |
|
330 | 399 |
} else if (!strcasecmp(arg, "alternate")) { |
400 |
scr_RosterJumpAlternate(); |
|
265 | 401 |
} else if (!strncasecmp(arg, "search", 6)) { |
402 |
char *string = arg+6; |
|
403 |
if (*string && (*string != ' ')) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
404 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
265 | 405 |
return; |
406 |
} |
|
407 |
while (*string == ' ') |
|
408 |
string++; |
|
409 |
if (!*string) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
410 |
scr_LogPrint(LPRINT_NORMAL, "What name or jid are you looking for?"); |
265 | 411 |
return; |
412 |
} |
|
413 |
scr_RosterSearch(string); |
|
414 |
update_roster = TRUE; |
|
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
415 |
} else if (!strcasecmp(arg, "up")) { |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
416 |
scr_RosterUp(); |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
417 |
} else if (!strcasecmp(arg, "down")) { |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
418 |
scr_RosterDown(); |
104 | 419 |
} else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
420 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
104 | 421 |
} |
108 | 422 |
|
444 | 423 |
// setstatus(recipient, arg) |
424 |
// Set your Jabber status. |
|
425 |
// - if recipient is not NULL, the status is sent to this contact only |
|
426 |
// - arg must be "status message" (message is optional) |
|
427 |
static void setstatus(const char *recipient, const char *arg) |
|
116 | 428 |
{ |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
429 |
char **paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
430 |
char *status; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
431 |
char *msg; |
116 | 432 |
enum imstatus st; |
433 |
||
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
434 |
if (!jb_getonline()) { |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
435 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
436 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
437 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
438 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
439 |
paramlst = split_arg(arg, 2, 0); // status, message |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
440 |
status = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
441 |
msg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
442 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
443 |
if (!status) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
444 |
free_arg_lst(paramlst); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
445 |
return; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
446 |
} |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
447 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
448 |
if (!strcasecmp(status, "offline")) st = offline; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
449 |
else if (!strcasecmp(status, "online")) st = available; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
450 |
else if (!strcasecmp(status, "avail")) st = available; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
451 |
else if (!strcasecmp(status, "away")) st = away; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
452 |
else if (!strcasecmp(status, "invisible")) st = invisible; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
453 |
else if (!strcasecmp(status, "dnd")) st = dontdisturb; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
454 |
else if (!strcasecmp(status, "notavail")) st = notavail; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
455 |
else if (!strcasecmp(status, "free")) st = freeforchat; |
116 | 456 |
else { |
444 | 457 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized status!"); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
458 |
free_arg_lst(paramlst); |
116 | 459 |
return; |
460 |
} |
|
461 |
||
528
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
462 |
// Use provided message, unless requested status is "invisible" |
416
48e7808c4191
Allow offline status message
Mikael Berthe <mikael@lilotux.net>
parents:
402
diff
changeset
|
463 |
if (msg && st != invisible) { |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
464 |
if (!*msg) msg = NULL; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
465 |
} else |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
466 |
msg = NULL; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
467 |
|
528
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
468 |
// 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
|
469 |
if (recipient && !msg) |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
470 |
msg = ""; |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
471 |
|
444 | 472 |
jb_setstatus(st, recipient, msg); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
473 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
474 |
free_arg_lst(paramlst); |
444 | 475 |
} |
476 |
||
477 |
static void do_status(char *arg) |
|
478 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
479 |
if (!*arg) { |
519
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
480 |
const char *sm = jb_getstatusmsg(); |
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
481 |
scr_LogPrint(LPRINT_NORMAL, "Your status is: [%c] %s", |
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
482 |
imstatus2char[jb_getstatus()], |
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
483 |
(sm ? sm : "")); |
444 | 484 |
return; |
485 |
} |
|
486 |
setstatus(NULL, arg); |
|
487 |
} |
|
488 |
||
489 |
static void do_status_to(char *arg) |
|
490 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
491 |
char **paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
492 |
char *jid, *st, *msg; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
493 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
494 |
paramlst = split_arg(arg, 3, 1); // jid, status, [message] |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
495 |
jid = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
496 |
st = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
497 |
msg = *(paramlst+2); |
444 | 498 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
499 |
if (!jid || !st) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
500 |
scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
501 |
} else if (check_jid_syntax(jid)) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
502 |
scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", jid); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
503 |
} else { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
504 |
char *cmd; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
505 |
if (!msg) |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
506 |
msg = ""; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
507 |
mc_strtolower(jid); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
508 |
cmd = g_strdup_printf("%s %s", st, msg); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
509 |
scr_LogPrint(LPRINT_LOGNORM, "Sending to <%s> /status %s", jid, cmd); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
510 |
setstatus(jid, cmd); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
511 |
g_free(cmd); |
444 | 512 |
} |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
513 |
free_arg_lst(paramlst); |
116 | 514 |
} |
515 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
516 |
static void do_add(char *arg) |
124 | 517 |
{ |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
518 |
char **paramlst; |
244 | 519 |
char *id, *nick; |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
520 |
|
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
521 |
if (!jb_getonline()) { |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
522 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
523 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
524 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
525 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
526 |
paramlst = split_arg(arg, 2, 0); // jid, [nickname] |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
527 |
id = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
528 |
nick = *(paramlst+1); |
244 | 529 |
|
452 | 530 |
if (check_jid_syntax(id)) { |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
531 |
if (!id) |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
532 |
scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
533 |
else |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
534 |
scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", id); |
452 | 535 |
} else { |
536 |
mc_strtolower(id); |
|
537 |
// 2nd parameter = optional nickname |
|
538 |
jb_addbuddy(id, nick, NULL); |
|
539 |
scr_LogPrint(LPRINT_LOGNORM, "Sent presence notification request to <%s>", |
|
540 |
id); |
|
541 |
} |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
542 |
free_arg_lst(paramlst); |
124 | 543 |
} |
128 | 544 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
545 |
static void do_del(char *arg) |
206 | 546 |
{ |
547 |
const char *jid; |
|
548 |
||
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
549 |
if (*arg) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
550 |
scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); |
206 | 551 |
return; |
552 |
} |
|
553 |
||
554 |
if (!current_buddy) return; |
|
555 |
jid = buddy_getjid(BUDDATA(current_buddy)); |
|
556 |
if (!jid) return; |
|
557 |
||
540
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
558 |
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_ROOM) { |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
559 |
// This is a chatroom |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
560 |
// If there are resources, we haven't left |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
561 |
if (buddy_isresource(BUDDATA(current_buddy))) { |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
562 |
scr_LogPrint(LPRINT_NORMAL, "You haven't left this room!"); |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
563 |
return; |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
564 |
} |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
565 |
} |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
566 |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
567 |
scr_LogPrint(LPRINT_LOGNORM, "Removing <%s>...", jid); |
206 | 568 |
jb_delbuddy(jid); |
598 | 569 |
scr_ShowBuddyWindow(); |
206 | 570 |
} |
571 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
572 |
static void do_group(char *arg) |
128 | 573 |
{ |
574 |
gpointer group; |
|
166 | 575 |
guint leave_windowbuddy; |
128 | 576 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
577 |
if (!*arg) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
578 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
128 | 579 |
return; |
580 |
} |
|
581 |
||
166 | 582 |
if (!current_buddy) return; |
128 | 583 |
|
166 | 584 |
group = buddy_getgroup(BUDDATA(current_buddy)); |
212 | 585 |
// We'll have to redraw the chat window if we're not currently on the group |
586 |
// entry itself, because it means we'll have to leave the current buddy |
|
587 |
// chat window. |
|
166 | 588 |
leave_windowbuddy = (group != BUDDATA(current_buddy)); |
589 |
||
128 | 590 |
if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
591 |
scr_LogPrint(LPRINT_NORMAL, "You need to select a group"); |
128 | 592 |
return; |
593 |
} |
|
166 | 594 |
|
595 |
if (!strcasecmp(arg, "expand") || !strcasecmp(arg, "unfold")) { |
|
128 | 596 |
buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE); |
166 | 597 |
} else if (!strcasecmp(arg, "shrink") || !strcasecmp(arg, "fold")) { |
128 | 598 |
buddy_setflags(group, ROSTER_FLAG_HIDE, TRUE); |
130 | 599 |
} else if (!strcasecmp(arg, "toggle")) { |
600 |
buddy_setflags(group, ROSTER_FLAG_HIDE, |
|
601 |
!(buddy_getflags(group) & ROSTER_FLAG_HIDE)); |
|
128 | 602 |
} else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
603 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
128 | 604 |
return; |
605 |
} |
|
606 |
||
607 |
buddylist_build(); |
|
608 |
update_roster = TRUE; |
|
166 | 609 |
if (leave_windowbuddy) scr_ShowBuddyWindow(); |
128 | 610 |
} |
611 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
612 |
static void do_say(char *arg) |
132 | 613 |
{ |
164 | 614 |
gpointer bud; |
132 | 615 |
|
616 |
scr_set_chatmode(TRUE); |
|
164 | 617 |
|
618 |
if (!current_buddy) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
619 |
scr_LogPrint(LPRINT_NORMAL, "Who are you talking to??"); |
164 | 620 |
return; |
132 | 621 |
} |
164 | 622 |
|
623 |
bud = BUDDATA(current_buddy); |
|
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
624 |
if (!(buddy_gettype(bud) & (ROSTER_TYPE_USER|ROSTER_TYPE_ROOM))) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
625 |
scr_LogPrint(LPRINT_NORMAL, "This is not a user"); |
164 | 626 |
return; |
627 |
} |
|
628 |
||
629 |
buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); |
|
630 |
send_message(arg); |
|
132 | 631 |
} |
632 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
633 |
static void do_msay(char *arg) |
238 | 634 |
{ |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
635 |
/* Parameters: begin verbatim abort send */ |
238 | 636 |
gpointer bud; |
637 |
||
638 |
if (!strcasecmp(arg, "abort")) { |
|
315
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
639 |
if (scr_get_multimode()) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
640 |
scr_LogPrint(LPRINT_NORMAL, "Leaving multi-line message mode"); |
238 | 641 |
scr_set_multimode(FALSE); |
642 |
return; |
|
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
643 |
} else if ((!strcasecmp(arg, "begin")) || (!strcasecmp(arg, "verbatim"))) { |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
644 |
if (!strcasecmp(arg, "verbatim")) |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
645 |
scr_set_multimode(2); |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
646 |
else |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
647 |
scr_set_multimode(1); |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
648 |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
649 |
scr_LogPrint(LPRINT_NORMAL, "Entered multi-line message mode."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
650 |
scr_LogPrint(LPRINT_NORMAL, "Select a buddy and use \"/msay send\" " |
238 | 651 |
"when your message is ready."); |
652 |
return; |
|
446 | 653 |
} else if (!*arg) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
654 |
scr_LogPrint(LPRINT_NORMAL, "Please read the manual before using " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
655 |
"the /msay command."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
656 |
scr_LogPrint(LPRINT_NORMAL, "(Use \"/msay begin\" to enter " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
657 |
"multi-line mode...)"); |
238 | 658 |
return; |
659 |
} else if (strcasecmp(arg, "send")) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
660 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
238 | 661 |
return; |
662 |
} |
|
663 |
||
664 |
// send command |
|
665 |
||
666 |
if (!scr_get_multimode()) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
667 |
scr_LogPrint(LPRINT_NORMAL, "No message to send. " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
668 |
"Use \"/msay begin\" first."); |
238 | 669 |
return; |
670 |
} |
|
671 |
||
672 |
scr_set_chatmode(TRUE); |
|
673 |
||
674 |
if (!current_buddy) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
675 |
scr_LogPrint(LPRINT_NORMAL, "Who are you talking to??"); |
238 | 676 |
return; |
677 |
} |
|
678 |
||
679 |
bud = BUDDATA(current_buddy); |
|
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
680 |
if (!(buddy_gettype(bud) & (ROSTER_TYPE_USER|ROSTER_TYPE_ROOM))) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
681 |
scr_LogPrint(LPRINT_NORMAL, "This is not a user"); |
238 | 682 |
return; |
683 |
} |
|
684 |
||
685 |
buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); |
|
686 |
send_message(scr_get_multiline()); |
|
687 |
scr_set_multimode(FALSE); |
|
688 |
} |
|
689 |
||
480 | 690 |
static void do_say_to(char *arg) |
691 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
692 |
char **paramlst; |
480 | 693 |
char *jid, *msg; |
694 |
char *bare_jid, *p; |
|
695 |
||
696 |
if (!jb_getonline()) { |
|
697 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
|
698 |
return; |
|
699 |
} |
|
700 |
||
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
701 |
paramlst = split_arg(arg, 2, 1); // jid, message |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
702 |
jid = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
703 |
msg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
704 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
705 |
if (check_jid_syntax(jid)) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
706 |
if (!jid) |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
707 |
scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
708 |
else |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
709 |
scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", jid); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
710 |
free_arg_lst(paramlst); |
480 | 711 |
return; |
712 |
} |
|
713 |
||
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
714 |
if (!msg || !*msg) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
715 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
716 |
free_arg_lst(paramlst); |
480 | 717 |
return; |
718 |
} |
|
719 |
||
720 |
// We must use the bare jid in hk_message_out() |
|
721 |
p = strchr(jid, '/'); |
|
722 |
if (p) bare_jid = g_strndup(jid, p - jid); |
|
723 |
else bare_jid = jid; |
|
724 |
||
725 |
// Jump to window, create one if needed |
|
726 |
scr_RosterJumpJid(bare_jid); |
|
727 |
||
484
00e2d3821a5b
Display PRIV for private messages in a room when using /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
728 |
// Check if we're sending a message to a conference room |
00e2d3821a5b
Display PRIV for private messages in a room when using /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
729 |
// If not, we must make sure p is NULL, for hk_message_out() |
00e2d3821a5b
Display PRIV for private messages in a room when using /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
730 |
if (p) { |
00e2d3821a5b
Display PRIV for private messages in a room when using /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
731 |
if (roster_find(bare_jid, jidsearch, ROSTER_TYPE_ROOM)) p++; |
00e2d3821a5b
Display PRIV for private messages in a room when using /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
732 |
else p = NULL; |
00e2d3821a5b
Display PRIV for private messages in a room when using /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
733 |
} |
00e2d3821a5b
Display PRIV for private messages in a room when using /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
734 |
|
480 | 735 |
// local part (UI, logging, etc.) |
484
00e2d3821a5b
Display PRIV for private messages in a room when using /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
480
diff
changeset
|
736 |
hk_message_out(bare_jid, p, 0, msg); |
480 | 737 |
|
738 |
// Network part |
|
739 |
jb_send_msg(jid, msg, ROSTER_TYPE_USER, NULL); |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
740 |
|
480 | 741 |
if (p) g_free(bare_jid); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
742 |
free_arg_lst(paramlst); |
480 | 743 |
} |
744 |
||
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
745 |
// buffer_updown(updown, nblines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
746 |
// updown: -1=up, +1=down |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
747 |
inline static void buffer_updown(int updown, char *nlines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
748 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
749 |
int nblines; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
750 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
751 |
if (!nlines || !*nlines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
752 |
nblines = 0; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
753 |
else |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
754 |
nblines = atoi(nlines); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
755 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
756 |
if (nblines >= 0) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
757 |
scr_BufferScrollUpDown(updown, nblines); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
758 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
759 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
760 |
static void buffer_search(int direction, char *arg) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
761 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
762 |
if (!arg || !*arg) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
763 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
764 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
765 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
766 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
767 |
scr_BufferSearch(direction, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
768 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
769 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
770 |
static void buffer_date(char *date) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
771 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
772 |
time_t t; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
773 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
774 |
if (!date || !*date) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
775 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
776 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
777 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
778 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
779 |
strip_arg_special_chars(date); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
780 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
781 |
t = from_iso8601(date, 0); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
782 |
if (t) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
783 |
scr_BufferDate(t); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
784 |
else |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
785 |
scr_LogPrint(LPRINT_NORMAL, "Wrong parameter"); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
786 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
787 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
788 |
static void buffer_percent(char *arg1, char *arg2) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
789 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
790 |
// Basically, user has typed "%arg1 arg2" |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
791 |
// "%50" -> arg1 = 50, arg2 null pointer |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
792 |
// "% 50" -> arg1 = \0, arg2 = 50 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
793 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
794 |
if (!*arg1 && (!arg2 || !*arg2)) { // No value |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
795 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
796 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
797 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
798 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
799 |
if (*arg1 && arg2 && *arg2) { // Two values |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
800 |
scr_LogPrint(LPRINT_NORMAL, "Wrong parameters"); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
801 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
802 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
803 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
804 |
scr_BufferPercent(atoi((*arg1 ? arg1 : arg2))); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
805 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
806 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
807 |
static void do_buffer(char *arg) |
187 | 808 |
{ |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
809 |
char **paramlst; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
810 |
char *subcmd; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
811 |
|
471
82a27508fb85
Fix segfaults when using /buffer and /room while not connected
Mikael Berthe <mikael@lilotux.net>
parents:
470
diff
changeset
|
812 |
if (!current_buddy) return; |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
813 |
|
446 | 814 |
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP) { |
815 |
scr_LogPrint(LPRINT_NORMAL, "Groups have no buffer"); |
|
816 |
return; |
|
817 |
} |
|
818 |
||
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
819 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
820 |
subcmd = *paramlst; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
821 |
arg = *(paramlst+1); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
822 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
823 |
if (!subcmd || !*subcmd) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
824 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
825 |
free_arg_lst(paramlst); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
826 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
827 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
828 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
829 |
if (!strcasecmp(subcmd, "top")) { |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
336
diff
changeset
|
830 |
scr_BufferTopBottom(-1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
831 |
} else if (!strcasecmp(subcmd, "bottom")) { |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
336
diff
changeset
|
832 |
scr_BufferTopBottom(1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
833 |
} else if (!strcasecmp(subcmd, "clear")) { |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
834 |
scr_BufferClear(); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
835 |
} else if (!strcasecmp(subcmd, "up")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
836 |
buffer_updown(-1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
837 |
} else if (!strcasecmp(subcmd, "down")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
838 |
buffer_updown(1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
839 |
} else if (!strcasecmp(subcmd, "search_backward")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
840 |
buffer_search(-1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
841 |
} else if (!strcasecmp(subcmd, "search_forward")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
842 |
buffer_search(1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
843 |
} else if (!strcasecmp(subcmd, "date")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
844 |
buffer_date(arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
845 |
} else if (*subcmd == '%') { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
846 |
buffer_percent(subcmd+1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
847 |
} else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
848 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
849 |
} |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
850 |
|
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
851 |
free_arg_lst(paramlst); |
187 | 852 |
} |
853 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
854 |
static void do_clear(char *arg) // Alias for "/buffer clear" |
187 | 855 |
{ |
856 |
do_buffer("clear"); |
|
857 |
} |
|
858 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
859 |
static void do_info(char *arg) |
191 | 860 |
{ |
861 |
gpointer bud; |
|
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
862 |
const char *jid, *name; |
191 | 863 |
guint type; |
864 |
char *buffer; |
|
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
865 |
enum subscr esub; |
191 | 866 |
|
867 |
if (!current_buddy) return; |
|
868 |
bud = BUDDATA(current_buddy); |
|
869 |
||
870 |
jid = buddy_getjid(bud); |
|
871 |
name = buddy_getname(bud); |
|
872 |
type = buddy_gettype(bud); |
|
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
873 |
esub = buddy_getsubscription(bud); |
191 | 874 |
|
875 |
buffer = g_new(char, 128); |
|
876 |
||
877 |
if (jid) { |
|
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
878 |
GSList *resources; |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
879 |
char *bstr = "unknown"; |
191 | 880 |
|
881 |
snprintf(buffer, 127, "jid: <%s>", jid); |
|
882 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
|
883 |
if (name) { |
|
884 |
snprintf(buffer, 127, "Name: %s", name); |
|
885 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
|
886 |
} |
|
887 |
||
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
888 |
if (type == ROSTER_TYPE_USER) bstr = "user"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
889 |
else if (type == ROSTER_TYPE_ROOM) bstr = "chatroom"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
890 |
else if (type == ROSTER_TYPE_AGENT) bstr = "agent"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
891 |
snprintf(buffer, 127, "Type: %s", bstr); |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
892 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
893 |
|
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
894 |
if (esub == sub_both) bstr = "both"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
895 |
else if (esub & sub_from) bstr = "from"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
896 |
else if (esub & sub_to) bstr = "to"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
897 |
else bstr = "none"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
898 |
snprintf(buffer, 64, "Subscription: %s", bstr); |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
899 |
if (esub & sub_pending) |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
900 |
strcat(buffer, " (pending)"); |
191 | 901 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
902 |
|
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
903 |
resources = buddy_getresources(bud); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
904 |
for ( ; resources ; resources = g_slist_next(resources) ) { |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
905 |
gchar rprio; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
906 |
enum imstatus rstatus; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
907 |
const char *rst_msg; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
908 |
|
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
909 |
rprio = buddy_getresourceprio(bud, resources->data); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
910 |
rstatus = buddy_getstatus(bud, resources->data); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
911 |
rst_msg = buddy_getstatusmsg(bud, resources->data); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
912 |
|
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
913 |
snprintf(buffer, 127, "Resource: [%c] (%d) %s", imstatus2char[rstatus], |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
914 |
rprio, (char*)resources->data); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
915 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
916 |
if (rst_msg) { |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
917 |
snprintf(buffer, 127, "Status message: %s", rst_msg); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
918 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
919 |
} |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
920 |
} |
191 | 921 |
} else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
922 |
if (name) scr_LogPrint(LPRINT_NORMAL, "Name: %s", name); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
923 |
scr_LogPrint(LPRINT_NORMAL, "Type: %s", |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
924 |
((type == ROSTER_TYPE_GROUP) ? "group" : "unknown")); |
191 | 925 |
} |
926 |
||
927 |
g_free(buffer); |
|
928 |
} |
|
929 |
||
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
930 |
// room_names() is a variation of do_info(), for chatrooms only |
552 | 931 |
static void room_names(gpointer bud, char *arg) |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
932 |
{ |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
933 |
const char *jid; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
934 |
char *buffer; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
935 |
GSList *resources; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
936 |
|
552 | 937 |
if (*arg) { |
938 |
scr_LogPrint(LPRINT_NORMAL, "Unknown parameter"); |
|
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
939 |
return; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
940 |
} |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
941 |
|
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
942 |
jid = buddy_getjid(bud); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
943 |
|
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
944 |
buffer = g_new(char, 128); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
945 |
snprintf(buffer, 127, "Room members:"); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
946 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
947 |
|
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
948 |
resources = buddy_getresources(bud); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
949 |
for ( ; resources ; resources = g_slist_next(resources) ) { |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
950 |
enum imstatus rstatus; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
951 |
const char *rst_msg; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
952 |
|
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
953 |
rstatus = buddy_getstatus(bud, resources->data); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
954 |
rst_msg = buddy_getstatusmsg(bud, resources->data); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
955 |
|
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
956 |
snprintf(buffer, 127, "[%c] %s", imstatus2char[rstatus], |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
957 |
(char*)resources->data); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
958 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
959 |
if (rst_msg) { |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
960 |
snprintf(buffer, 127, "Status message: %s", rst_msg); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
961 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
962 |
} |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
963 |
} |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
964 |
|
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
965 |
g_free(buffer); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
966 |
} |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
967 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
968 |
static void do_rename(char *arg) |
208 | 969 |
{ |
970 |
gpointer bud; |
|
971 |
const char *jid, *group; |
|
972 |
guint type; |
|
973 |
char *newname, *p; |
|
974 |
||
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
975 |
if (!*arg) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
976 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
208 | 977 |
return; |
978 |
} |
|
979 |
||
980 |
if (!current_buddy) return; |
|
981 |
bud = BUDDATA(current_buddy); |
|
982 |
||
983 |
jid = buddy_getjid(bud); |
|
984 |
group = buddy_getgroupname(bud); |
|
985 |
type = buddy_gettype(bud); |
|
986 |
||
987 |
if (type & ROSTER_TYPE_GROUP) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
988 |
scr_LogPrint(LPRINT_NORMAL, "You can't rename groups"); |
208 | 989 |
return; |
990 |
} |
|
991 |
||
992 |
newname = g_strdup(arg); |
|
993 |
// Remove trailing space |
|
994 |
for (p = newname; *p; p++) ; |
|
995 |
while (p > newname && *p == ' ') *p = 0; |
|
996 |
||
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
997 |
strip_arg_special_chars(newname); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
998 |
|
208 | 999 |
buddy_setname(bud, newname); |
1000 |
jb_updatebuddy(jid, newname, group); |
|
1001 |
||
1002 |
g_free(newname); |
|
1003 |
update_roster = TRUE; |
|
1004 |
} |
|
1005 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1006 |
static void do_move(char *arg) |
210 | 1007 |
{ |
1008 |
gpointer bud; |
|
1009 |
const char *jid, *name; |
|
1010 |
guint type; |
|
1011 |
char *newgroupname, *p; |
|
1012 |
||
1013 |
if (!current_buddy) return; |
|
1014 |
bud = BUDDATA(current_buddy); |
|
1015 |
||
1016 |
jid = buddy_getjid(bud); |
|
1017 |
name = buddy_getname(bud); |
|
1018 |
type = buddy_gettype(bud); |
|
1019 |
||
1020 |
if (type & ROSTER_TYPE_GROUP) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1021 |
scr_LogPrint(LPRINT_NORMAL, "You can't move groups!"); |
210 | 1022 |
return; |
1023 |
} |
|
1024 |
||
1025 |
newgroupname = g_strdup(arg); |
|
1026 |
// Remove trailing space |
|
1027 |
for (p = newgroupname; *p; p++) ; |
|
608
89f5672eb523
/move: really strip trailing space, and assign to no group if no group is specified
Mikael Berthe <mikael@lilotux.net>
parents:
604
diff
changeset
|
1028 |
while (p > newgroupname && *p == ' ') *p-- = 0; |
210 | 1029 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1030 |
strip_arg_special_chars(newgroupname); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1031 |
|
210 | 1032 |
// Call to buddy_setgroup() should be at the end, as current implementation |
1033 |
// clones the buddy and deletes the old one (and thus, jid and name are |
|
1034 |
// freed) |
|
608
89f5672eb523
/move: really strip trailing space, and assign to no group if no group is specified
Mikael Berthe <mikael@lilotux.net>
parents:
604
diff
changeset
|
1035 |
jb_updatebuddy(jid, name, *newgroupname ? newgroupname : NULL); |
506
74dcd0df532e
"/move" does not jump to the buddy in the new group
Mikael Berthe <mikael@lilotux.net>
parents:
504
diff
changeset
|
1036 |
scr_RosterUp(); |
210 | 1037 |
buddy_setgroup(bud, newgroupname); |
1038 |
||
1039 |
g_free(newgroupname); |
|
1040 |
update_roster = TRUE; |
|
1041 |
} |
|
1042 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1043 |
static void do_set(char *arg) |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1044 |
{ |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1045 |
guint assign; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1046 |
const gchar *option, *value; |
393 | 1047 |
|
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1048 |
assign = parse_assigment(arg, &option, &value); |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1049 |
if (!option) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1050 |
scr_LogPrint(LPRINT_NORMAL, "Huh?"); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1051 |
return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1052 |
} |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1053 |
if (!assign) { |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1054 |
// This is a query |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1055 |
value = settings_opt_get(option); |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1056 |
if (value) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1057 |
scr_LogPrint(LPRINT_NORMAL, "%s = [%s]", option, value); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1058 |
} else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1059 |
scr_LogPrint(LPRINT_NORMAL, "Option %s is not set", option); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1060 |
return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1061 |
} |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1062 |
// Update the option |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1063 |
// XXX Maybe some options should be protected when user is connected |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1064 |
// (server, username, etc.). And we should catch some options here, too |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1065 |
// (hide_offline_buddies for ex.) |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1066 |
if (!value) { |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1067 |
settings_del(SETTINGS_TYPE_OPTION, option); |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1068 |
} else { |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1069 |
settings_set(SETTINGS_TYPE_OPTION, option, value); |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1070 |
} |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1071 |
} |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1072 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1073 |
static void do_alias(char *arg) |
285 | 1074 |
{ |
1075 |
guint assign; |
|
1076 |
const gchar *alias, *value; |
|
393 | 1077 |
|
285 | 1078 |
assign = parse_assigment(arg, &alias, &value); |
1079 |
if (!alias) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1080 |
scr_LogPrint(LPRINT_NORMAL, "Huh?"); |
285 | 1081 |
return; |
1082 |
} |
|
1083 |
if (!assign) { |
|
1084 |
// This is a query |
|
1085 |
value = settings_get(SETTINGS_TYPE_ALIAS, alias); |
|
1086 |
if (value) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1087 |
scr_LogPrint(LPRINT_NORMAL, "%s = %s", alias, value); |
285 | 1088 |
} else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1089 |
scr_LogPrint(LPRINT_NORMAL, "Alias '%s' does not exist", alias); |
285 | 1090 |
return; |
1091 |
} |
|
1092 |
// Check the alias does not conflict with a registered command |
|
1093 |
if (cmd_get(alias)) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1094 |
scr_LogPrint(LPRINT_NORMAL, "'%s' is a reserved word!", alias); |
285 | 1095 |
return; |
1096 |
} |
|
1097 |
// Update the alias |
|
1098 |
if (!value) { |
|
1099 |
if (settings_get(SETTINGS_TYPE_ALIAS, alias)) { |
|
1100 |
settings_del(SETTINGS_TYPE_ALIAS, alias); |
|
1101 |
// Remove alias from the completion list |
|
1102 |
compl_del_category_word(COMPL_CMD, alias); |
|
1103 |
} |
|
1104 |
} else { |
|
1105 |
// Add alias to the completion list, if not already in |
|
1106 |
if (!settings_get(SETTINGS_TYPE_ALIAS, alias)) |
|
1107 |
compl_add_category_word(COMPL_CMD, alias); |
|
1108 |
settings_set(SETTINGS_TYPE_ALIAS, alias, value); |
|
1109 |
} |
|
1110 |
} |
|
1111 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1112 |
static void do_bind(char *arg) |
288 | 1113 |
{ |
1114 |
guint assign; |
|
1115 |
const gchar *keycode, *value; |
|
393 | 1116 |
|
288 | 1117 |
assign = parse_assigment(arg, &keycode, &value); |
1118 |
if (!keycode) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1119 |
scr_LogPrint(LPRINT_NORMAL, "Huh?"); |
288 | 1120 |
return; |
1121 |
} |
|
1122 |
if (!assign) { |
|
1123 |
// This is a query |
|
1124 |
value = settings_get(SETTINGS_TYPE_BINDING, keycode); |
|
1125 |
if (value) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1126 |
scr_LogPrint(LPRINT_NORMAL, "Key %s is bound to: %s", keycode, value); |
288 | 1127 |
} else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1128 |
scr_LogPrint(LPRINT_NORMAL, "Key %s is not bound", keycode); |
288 | 1129 |
return; |
1130 |
} |
|
1131 |
// Update the key binding |
|
1132 |
if (!value) |
|
1133 |
settings_del(SETTINGS_TYPE_BINDING, keycode); |
|
1134 |
else |
|
1135 |
settings_set(SETTINGS_TYPE_BINDING, keycode, value); |
|
1136 |
} |
|
1137 |
||
436 | 1138 |
static void do_rawxml(char *arg) |
1139 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1140 |
char **paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1141 |
char *subcmd; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1142 |
|
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1143 |
if (!jb_getonline()) { |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1144 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1145 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1146 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1147 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1148 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1149 |
subcmd = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1150 |
arg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1151 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1152 |
if (!subcmd || !*subcmd) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1153 |
scr_LogPrint(LPRINT_NORMAL, "Please read the manual page" |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1154 |
" before using /rawxml :-)"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1155 |
free_arg_lst(paramlst); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1156 |
return; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1157 |
} |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1158 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1159 |
if (!strcasecmp(subcmd, "send")) { |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1160 |
gchar *buffer; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1161 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1162 |
if (!subcmd || !*subcmd) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1163 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1164 |
free_arg_lst(paramlst); |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1165 |
return; |
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1166 |
} |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1167 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1168 |
// We don't strip_arg_special_chars() here, because it would be a pain for |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1169 |
// the user to escape quotes in a XML stream... |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1170 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1171 |
buffer = to_utf8(arg); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1172 |
if (buffer) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1173 |
scr_LogPrint(LPRINT_NORMAL, "Sending XML string"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1174 |
jb_send_raw(buffer); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1175 |
g_free(buffer); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1176 |
} else { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1177 |
scr_LogPrint(LPRINT_NORMAL, "Conversion error in XML string"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1178 |
} |
436 | 1179 |
} else { |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1180 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
436 | 1181 |
} |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1182 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1183 |
free_arg_lst(paramlst); |
436 | 1184 |
} |
1185 |
||
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1186 |
// check_room_subcommand(arg, param_needed, buddy_must_be_a_room) |
552 | 1187 |
// - Check if this is a room, if buddy_must_be_a_room is not null |
1188 |
// - Check there is at least 1 parameter, if param_needed is true |
|
1189 |
// - Return null if one of the checks fails, or a pointer to the first |
|
1190 |
// non-space character. |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1191 |
static char *check_room_subcommand(char *arg, bool param_needed, |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1192 |
gpointer buddy_must_be_a_room) |
552 | 1193 |
{ |
1194 |
if (buddy_must_be_a_room && |
|
1195 |
!(buddy_gettype(buddy_must_be_a_room) & ROSTER_TYPE_ROOM)) { |
|
1196 |
scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom"); |
|
1197 |
return NULL; |
|
1198 |
} |
|
1199 |
||
1200 |
if (param_needed) { |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1201 |
if (!arg) { |
568 | 1202 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
552 | 1203 |
return NULL; |
1204 |
} |
|
1205 |
} |
|
1206 |
||
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1207 |
if (arg) |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1208 |
return arg; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1209 |
else |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1210 |
return ""; |
552 | 1211 |
} |
1212 |
||
1213 |
static void room_join(gpointer bud, char *arg) |
|
1214 |
{ |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1215 |
char **paramlst; |
552 | 1216 |
char *roomname, *nick; |
1217 |
||
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1218 |
paramlst = split_arg(arg, 2, 0); // roomid, nickname |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1219 |
roomname = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1220 |
nick = *(paramlst+1); |
552 | 1221 |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1222 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1223 |
if (!roomname || strchr(roomname, '/')) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1224 |
scr_LogPrint(LPRINT_NORMAL, "Invalid room name"); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1225 |
free_arg_lst(paramlst); |
552 | 1226 |
return; |
1227 |
} |
|
1228 |
||
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1229 |
if (!nick || !*nick) { |
552 | 1230 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter (nickname)"); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1231 |
free_arg_lst(paramlst); |
552 | 1232 |
return; |
1233 |
} |
|
1234 |
||
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1235 |
// Note that roomname is part of the array allocated by split_arg(), |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1236 |
// so we can modify it. |
552 | 1237 |
mc_strtolower(roomname); |
1238 |
jb_room_join(roomname, nick); |
|
1239 |
||
1240 |
buddylist_build(); |
|
1241 |
update_roster = TRUE; |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1242 |
free_arg_lst(paramlst); |
552 | 1243 |
} |
1244 |
||
1245 |
static void room_invite(gpointer bud, char *arg) |
|
1246 |
{ |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1247 |
char **paramlst; |
552 | 1248 |
const gchar *roomname; |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1249 |
char* jid; |
552 | 1250 |
|
570
29806b0fe830
Some parsing improvements
Mikael Berthe <mikael@lilotux.net>
parents:
568
diff
changeset
|
1251 |
paramlst = split_arg(arg, 2, 1); // jid, [reason] |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1252 |
jid = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1253 |
arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1254 |
// An empty reason is no reason... |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1255 |
if (arg && !*arg) |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1256 |
arg = NULL; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1257 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1258 |
if (!jid || !*jid) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1259 |
scr_LogPrint(LPRINT_NORMAL, "Missing or incorrect parameter"); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1260 |
free_arg_lst(paramlst); |
552 | 1261 |
return; |
1262 |
} |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1263 |
|
552 | 1264 |
roomname = buddy_getjid(bud); |
1265 |
jb_room_invite(roomname, jid, arg); |
|
1266 |
scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>", jid); |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1267 |
free_arg_lst(paramlst); |
552 | 1268 |
} |
1269 |
||
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1270 |
static void room_affil(gpointer bud, char *arg) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1271 |
{ |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1272 |
char **paramlst; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1273 |
gchar *jid, *rolename; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1274 |
struct role_affil ra; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1275 |
const char *roomid = buddy_getjid(bud); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1276 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1277 |
paramlst = split_arg(arg, 3, 1); // jid, new_affil, [reason] |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1278 |
jid = *paramlst; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1279 |
rolename = *(paramlst+1); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1280 |
arg = *(paramlst+2); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1281 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1282 |
if (!jid || !*jid || !rolename || !*rolename) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1283 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1284 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1285 |
return; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1286 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1287 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1288 |
ra.type = type_affil; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1289 |
ra.val.affil = affil_none; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1290 |
for (; ra.val.affil < imaffiliation_size; ra.val.affil++) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1291 |
if (!strcasecmp(rolename, straffil[ra.val.affil])) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1292 |
break; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1293 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1294 |
if (ra.val.affil < imaffiliation_size) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1295 |
jb_room_setattrib(roomid, jid, NULL, ra, arg); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1296 |
else |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1297 |
scr_LogPrint(LPRINT_NORMAL, "Wrong affiliation parameter"); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1298 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1299 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1300 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1301 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1302 |
static void room_role(gpointer bud, char *arg) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1303 |
{ |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1304 |
char **paramlst; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1305 |
gchar *jid, *rolename; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1306 |
struct role_affil ra; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1307 |
const char *roomid = buddy_getjid(bud); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1308 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1309 |
paramlst = split_arg(arg, 3, 1); // jid, new_role, [reason] |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1310 |
jid = *paramlst; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1311 |
rolename = *(paramlst+1); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1312 |
arg = *(paramlst+2); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1313 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1314 |
if (!jid || !*jid || !rolename || !*rolename) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1315 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1316 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1317 |
return; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1318 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1319 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1320 |
ra.type = type_role; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1321 |
ra.val.role = role_none; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1322 |
for (; ra.val.role < imrole_size; ra.val.role++) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1323 |
if (!strcasecmp(rolename, strrole[ra.val.role])) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1324 |
break; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1325 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1326 |
if (ra.val.role < imrole_size) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1327 |
jb_room_setattrib(roomid, jid, NULL, ra, arg); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1328 |
else |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1329 |
scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter"); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1330 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1331 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1332 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1333 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1334 |
|
571 | 1335 |
// The expected argument is a Jabber id |
1336 |
static void room_ban(gpointer bud, char *arg) |
|
1337 |
{ |
|
1338 |
char **paramlst; |
|
1339 |
gchar *jid; |
|
584 | 1340 |
struct role_affil ra; |
571 | 1341 |
const char *roomid = buddy_getjid(bud); |
1342 |
||
1343 |
paramlst = split_arg(arg, 2, 1); // jid, [reason] |
|
1344 |
jid = *paramlst; |
|
1345 |
arg = *(paramlst+1); |
|
1346 |
||
1347 |
if (!jid || !*jid) { |
|
1348 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter (Jabber id)"); |
|
1349 |
free_arg_lst(paramlst); |
|
1350 |
return; |
|
1351 |
} |
|
1352 |
||
584 | 1353 |
ra.type = type_affil; |
1354 |
ra.val.affil = affil_outcast; |
|
1355 |
||
1356 |
jb_room_setattrib(roomid, jid, NULL, ra, arg); |
|
571 | 1357 |
|
1358 |
free_arg_lst(paramlst); |
|
1359 |
} |
|
1360 |
||
1361 |
// The expected argument is a nickname |
|
568 | 1362 |
static void room_kick(gpointer bud, char *arg) |
1363 |
{ |
|
1364 |
char **paramlst; |
|
1365 |
gchar *nick; |
|
584 | 1366 |
struct role_affil ra; |
568 | 1367 |
const char *roomid = buddy_getjid(bud); |
1368 |
||
571 | 1369 |
paramlst = split_arg(arg, 2, 1); // nickname, [reason] |
568 | 1370 |
nick = *paramlst; |
1371 |
arg = *(paramlst+1); |
|
1372 |
||
1373 |
if (!nick || !*nick) { |
|
1374 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter (nickname)"); |
|
1375 |
free_arg_lst(paramlst); |
|
1376 |
return; |
|
1377 |
} |
|
1378 |
||
584 | 1379 |
ra.type = type_role; |
1380 |
ra.val.affil = role_none; |
|
1381 |
||
1382 |
jb_room_setattrib(roomid, NULL, nick, ra, arg); |
|
568 | 1383 |
|
1384 |
free_arg_lst(paramlst); |
|
1385 |
} |
|
1386 |
||
552 | 1387 |
static void room_leave(gpointer bud, char *arg) |
1388 |
{ |
|
1389 |
gchar *roomid, *utf8_nickname; |
|
1390 |
||
1391 |
utf8_nickname = to_utf8(buddy_getnickname(bud)); |
|
1392 |
roomid = g_strdup_printf("%s/%s", buddy_getjid(bud), utf8_nickname); |
|
1393 |
jb_setstatus(offline, roomid, arg); |
|
1394 |
g_free(utf8_nickname); |
|
1395 |
g_free(roomid); |
|
1396 |
} |
|
1397 |
||
1398 |
static void room_nick(gpointer bud, char *arg) |
|
1399 |
{ |
|
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1400 |
if (!arg || !*arg) { |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1401 |
const char *nick = buddy_getnickname(bud); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1402 |
if (nick) |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1403 |
scr_LogPrint(LPRINT_NORMAL, "Your nickname is: %s", nick); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1404 |
else |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1405 |
scr_LogPrint(LPRINT_NORMAL, "You have no nickname"); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1406 |
} else { |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1407 |
gchar *cmd; |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1408 |
cmd = g_strdup_printf("%s %s", buddy_getjid(bud), arg); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1409 |
room_join(bud, cmd); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1410 |
g_free(cmd); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1411 |
} |
552 | 1412 |
} |
1413 |
||
1414 |
static void room_privmsg(gpointer bud, char *arg) |
|
1415 |
{ |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1416 |
char **paramlst; |
552 | 1417 |
gchar *nick, *cmd; |
1418 |
||
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1419 |
paramlst = split_arg(arg, 2, 0); // nickname, message |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1420 |
nick = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1421 |
arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1422 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1423 |
if (!nick || !*nick || !arg || !*arg) { |
552 | 1424 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1425 |
free_arg_lst(paramlst); |
552 | 1426 |
return; |
1427 |
} |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1428 |
|
552 | 1429 |
cmd = g_strdup_printf("%s/%s %s", buddy_getjid(bud), nick, arg); |
1430 |
do_say_to(cmd); |
|
1431 |
g_free(cmd); |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1432 |
free_arg_lst(paramlst); |
552 | 1433 |
} |
1434 |
||
1435 |
static void room_remove(gpointer bud, char *arg) |
|
1436 |
{ |
|
1437 |
if (*arg) { |
|
1438 |
scr_LogPrint(LPRINT_NORMAL, "Unknown parameter"); |
|
1439 |
return; |
|
1440 |
} |
|
1441 |
||
1442 |
// Quick check: if there are resources, we haven't left |
|
1443 |
if (buddy_isresource(bud)) { |
|
1444 |
scr_LogPrint(LPRINT_NORMAL, "You haven't left this room!"); |
|
1445 |
return; |
|
1446 |
} |
|
1447 |
// Delete the room |
|
1448 |
roster_del_user(buddy_getjid(bud)); |
|
598 | 1449 |
scr_ShowBuddyWindow(); |
552 | 1450 |
buddylist_build(); |
1451 |
update_roster = TRUE; |
|
1452 |
} |
|
1453 |
||
1454 |
static void room_topic(gpointer bud, char *arg) |
|
1455 |
{ |
|
1456 |
gchar *msg; |
|
1457 |
||
1458 |
// If no parameter is given, display the current topic |
|
1459 |
if (!*arg) { |
|
1460 |
const char *topic = buddy_gettopic(bud); |
|
1461 |
if (topic) |
|
1462 |
scr_LogPrint(LPRINT_NORMAL, "Topic: %s", topic); |
|
1463 |
else |
|
1464 |
scr_LogPrint(LPRINT_NORMAL, "No topic has been set"); |
|
1465 |
return; |
|
1466 |
} |
|
1467 |
||
1468 |
// Set the topic |
|
1469 |
msg = g_strdup_printf("/me has set the topic to: %s", arg); |
|
1470 |
jb_send_msg(buddy_getjid(bud), msg, ROSTER_TYPE_ROOM, arg); |
|
1471 |
g_free(msg); |
|
1472 |
} |
|
1473 |
||
599 | 1474 |
static void room_destroy(gpointer bud, char *arg) |
1475 |
{ |
|
1476 |
gchar *msg; |
|
1477 |
||
1478 |
if (arg && *arg) |
|
1479 |
msg = arg; |
|
1480 |
else |
|
1481 |
msg = NULL; |
|
1482 |
||
1483 |
jb_room_destroy(buddy_getjid(bud), NULL, msg); |
|
1484 |
} |
|
1485 |
||
552 | 1486 |
static void room_unlock(gpointer bud, char *arg) |
1487 |
{ |
|
1488 |
if (*arg) { |
|
1489 |
scr_LogPrint(LPRINT_NORMAL, "Unknown parameter"); |
|
1490 |
return; |
|
1491 |
} |
|
1492 |
||
1493 |
jb_room_unlock(buddy_getjid(bud)); |
|
1494 |
} |
|
1495 |
||
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1496 |
static void room_whois(gpointer bud, char *arg) |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1497 |
{ |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1498 |
char **paramlst; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1499 |
gchar *nick, *buffer; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1500 |
const char *jid, *realjid; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1501 |
const char *rst_msg; |
575 | 1502 |
gchar rprio; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1503 |
enum imstatus rstatus; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1504 |
enum imrole role; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1505 |
enum imaffiliation affil; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1506 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1507 |
char *strroles[] = { "none", "moderator", "participant", "visitor" }; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1508 |
char *straffil[] = { "none", "owner", "admin", "member", "outcast" }; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1509 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1510 |
paramlst = split_arg(arg, 1, 0); // nickname |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1511 |
nick = *paramlst; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1512 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1513 |
if (!nick || !*nick) { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1514 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter (nickname)"); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1515 |
free_arg_lst(paramlst); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1516 |
return; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1517 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1518 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1519 |
jid = buddy_getjid(bud); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1520 |
rstatus = buddy_getstatus(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1521 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1522 |
if (rstatus == offline) { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1523 |
scr_LogPrint(LPRINT_NORMAL, "No such member: %s", nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1524 |
free_arg_lst(paramlst); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1525 |
return; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1526 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1527 |
|
575 | 1528 |
rprio = buddy_getresourceprio(bud, nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1529 |
rst_msg = buddy_getstatusmsg(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1530 |
if (!rst_msg) rst_msg = ""; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1531 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1532 |
role = buddy_getrole(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1533 |
affil = buddy_getaffil(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1534 |
realjid = buddy_getrjid(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1535 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1536 |
buffer = g_new(char, 128); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1537 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1538 |
snprintf(buffer, 127, "Whois [%s]", nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1539 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
575 | 1540 |
snprintf(buffer, 127, "Status : [%c] %s", imstatus2char[rstatus], |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1541 |
rst_msg); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1542 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1543 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1544 |
if (realjid) { |
590
a5707d61e469
Fix a few UTF-8 related issues
Mikael Berthe <mikael@lilotux.net>
parents:
588
diff
changeset
|
1545 |
snprintf(buffer, 127, "JID : <%s>", realjid); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1546 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1547 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1548 |
|
575 | 1549 |
snprintf(buffer, 127, "Role : %s", strroles[role]); |
1550 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
|
1551 |
snprintf(buffer, 127, "Affiliat.: %s", straffil[affil]); |
|
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1552 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
575 | 1553 |
snprintf(buffer, 127, "Priority : %d", rprio); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1554 |
scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
575 | 1555 |
scr_WriteIncomingMessage(jid, "End of WHOIS", 0, HBB_PREFIX_INFO); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1556 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1557 |
g_free(buffer); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1558 |
free_arg_lst(paramlst); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1559 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1560 |
|
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1561 |
static void do_room(char *arg) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1562 |
{ |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1563 |
char **paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1564 |
char *subcmd; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1565 |
gpointer bud; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1566 |
|
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1567 |
if (!jb_getonline()) { |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1568 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1569 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1570 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1571 |
|
471
82a27508fb85
Fix segfaults when using /buffer and /room while not connected
Mikael Berthe <mikael@lilotux.net>
parents:
470
diff
changeset
|
1572 |
if (!current_buddy) return; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1573 |
bud = BUDDATA(current_buddy); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1574 |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1575 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1576 |
subcmd = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1577 |
arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1578 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1579 |
if (!subcmd || !*subcmd) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1580 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1581 |
free_arg_lst(paramlst); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1582 |
return; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1583 |
} |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1584 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1585 |
if (!strcasecmp(subcmd, "join")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1586 |
if ((arg = check_room_subcommand(arg, TRUE, NULL)) != NULL) |
552 | 1587 |
room_join(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1588 |
} else if (!strcasecmp(subcmd, "invite")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1589 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
552 | 1590 |
room_invite(bud, arg); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1591 |
} else if (!strcasecmp(subcmd, "affil")) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1592 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1593 |
room_affil(bud, arg); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1594 |
} else if (!strcasecmp(subcmd, "role")) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1595 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1596 |
room_role(bud, arg); |
571 | 1597 |
} else if (!strcasecmp(subcmd, "ban")) { |
1598 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
|
1599 |
room_ban(bud, arg); |
|
568 | 1600 |
} else if (!strcasecmp(subcmd, "kick")) { |
1601 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
|
1602 |
room_kick(bud, arg); |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1603 |
} else if (!strcasecmp(subcmd, "leave")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1604 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 1605 |
room_leave(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1606 |
} else if (!strcasecmp(subcmd, "names")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1607 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 1608 |
room_names(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1609 |
} else if (!strcasecmp(subcmd, "nick")) { |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1610 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 1611 |
room_nick(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1612 |
} else if (!strcasecmp(subcmd, "privmsg")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1613 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
552 | 1614 |
room_privmsg(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1615 |
} else if (!strcasecmp(subcmd, "remove")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1616 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 1617 |
room_remove(bud, arg); |
599 | 1618 |
} else if (!strcasecmp(subcmd, "destroy")) { |
1619 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
|
1620 |
room_destroy(bud, arg); |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1621 |
} else if (!strcasecmp(subcmd, "unlock")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1622 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 1623 |
room_unlock(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1624 |
} else if (!strcasecmp(subcmd, "topic")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1625 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 1626 |
room_topic(bud, arg); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1627 |
} else if (!strcasecmp(subcmd, "whois")) { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1628 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
1629 |
room_whois(bud, arg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1630 |
} else { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1631 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1632 |
} |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1633 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1634 |
free_arg_lst(paramlst); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1635 |
} |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1636 |
|
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1637 |
static void do_authorization(char *arg) |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1638 |
{ |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1639 |
char **paramlst; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1640 |
char *subcmd; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1641 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1642 |
if (!jb_getonline()) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1643 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1644 |
return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1645 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1646 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1647 |
paramlst = split_arg(arg, 2, 0); // subcmd, [jid] |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1648 |
subcmd = *paramlst; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1649 |
arg = *(paramlst+1); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1650 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1651 |
if (!subcmd || !*subcmd) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1652 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1653 |
free_arg_lst(paramlst); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1654 |
return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1655 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1656 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1657 |
// Use the provided jid, if it looks valid |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1658 |
if (arg) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1659 |
if (!*arg) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1660 |
// If no jid is provided, we use the current selected buddy |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1661 |
arg = NULL; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1662 |
} else { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1663 |
if (check_jid_syntax(arg)) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1664 |
scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", arg); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1665 |
free_arg_lst(paramlst); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1666 |
return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1667 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1668 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1669 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1670 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1671 |
if (!arg) { // Use the current selected buddy's jid |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1672 |
gpointer bud; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1673 |
guint type; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1674 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1675 |
if (!current_buddy) return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1676 |
bud = BUDDATA(current_buddy); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1677 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1678 |
arg = (char*)buddy_getjid(bud); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1679 |
type = buddy_gettype(bud); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1680 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1681 |
if (!(type & (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT))) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1682 |
scr_LogPrint(LPRINT_NORMAL, "Invalid buddy"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1683 |
return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1684 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1685 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1686 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1687 |
if (!strcasecmp(subcmd, "allow")) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1688 |
jb_subscr_send_auth(arg); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1689 |
scr_LogPrint(LPRINT_LOGNORM, |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1690 |
"<%s> is allowed to receive your presence updates", arg); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1691 |
} else if (!strcasecmp(subcmd, "cancel")) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1692 |
jb_subscr_cancel_auth(arg); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1693 |
scr_LogPrint(LPRINT_LOGNORM, |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1694 |
"<%s> is no more allowed to receive your presence updates", |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1695 |
arg); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1696 |
} else if (!strcasecmp(subcmd, "request")) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1697 |
jb_subscr_request_auth(arg); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1698 |
scr_LogPrint(LPRINT_LOGNORM, |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1699 |
"Sent presence notification request to <%s>", arg); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1700 |
} else { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1701 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1702 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1703 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1704 |
free_arg_lst(paramlst); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1705 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
1706 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1707 |
static void do_connect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1708 |
{ |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1709 |
mcabber_connect(); |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1710 |
} |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1711 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1712 |
static void do_disconnect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1713 |
{ |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1714 |
jb_disconnect(); |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1715 |
} |
576 | 1716 |
|
580 | 1717 |
/* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |