Mercurial > hg
annotate mcabber/src/commands.c @ 483:4a10c04ac2fb
Fix a bug in roster_find()
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Wed, 05 Oct 2005 21:46:13 +0200 |
parents | 882e1acae422 |
children | 00e2d3821a5b |
rev | line source |
---|---|
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); |
47 | 56 |
104 | 57 // Global variable for the commands list |
95 | 58 static GSList *Commands; |
59 | |
104 | 60 |
95 | 61 // cmd_add() |
62 // Adds a command to the commands list and to the CMD completion list | |
63 void cmd_add(const char *name, const char *help, | |
104 | 64 guint flags_row1, guint flags_row2, void (*f)()) |
95 | 65 { |
66 cmd *n_cmd = g_new0(cmd, 1); | |
67 strncpy(n_cmd->name, name, 32-1); | |
68 n_cmd->help = help; | |
69 n_cmd->completion_flags[0] = flags_row1; | |
70 n_cmd->completion_flags[1] = flags_row2; | |
71 n_cmd->func = f; | |
102 | 72 Commands = g_slist_append(Commands, n_cmd); |
95 | 73 // Add to completion CMD category |
74 compl_add_category_word(COMPL_CMD, name); | |
75 } | |
76 | |
77 // cmd_init() | |
78 // ... | |
79 void cmd_init(void) | |
80 { | |
124 | 81 cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add); |
285 | 82 cmd_add("alias", "Add an alias", 0, 0, &do_alias); |
288 | 83 cmd_add("bind", "Add an key binding", 0, 0, &do_bind); |
187 | 84 cmd_add("buffer", "Manipulate current buddy's buffer (chat window)", |
85 COMPL_BUFFER, 0, &do_buffer); | |
108 | 86 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
|
87 cmd_add("connect", "Connect to the server", 0, 0, &do_connect); |
205 | 88 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
|
89 cmd_add("disconnect", "Disconnect from server", 0, 0, &do_disconnect); |
128 | 90 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
|
91 //cmd_add("help", "Display some help", COMPL_CMD, 0, NULL); |
191 | 92 cmd_add("info", "Show basic infos on current buddy", 0, 0, &do_info); |
225 | 93 cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, |
94 0, &do_move); | |
238 | 95 cmd_add("msay", "Send a multi-lines message to the selected buddy", |
96 COMPL_MULTILINE, 0, &do_msay); | |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
97 cmd_add("room", "MUC actions command", COMPL_ROOM, 0, &do_room); |
95 | 98 cmd_add("quit", "Exit the software", 0, 0, NULL); |
436 | 99 cmd_add("rawxml", "Send a raw XML string", 0, 0, &do_rawxml); |
208 | 100 cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename); |
95 | 101 //cmd_add("request_auth"); |
128 | 102 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, |
103 &do_roster); | |
132 | 104 cmd_add("say", "Say something to the selected buddy", 0, 0, &do_say); |
480 | 105 cmd_add("say_to", "Say something to a specific buddy", 0, 0, &do_say_to); |
95 | 106 //cmd_add("search"); |
107 //cmd_add("send_auth"); | |
310 | 108 cmd_add("set", "Set/query an option value", 0, 0, &do_set); |
116 | 109 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status); |
444 | 110 cmd_add("status_to", "Show or set your status for one recipient", |
111 COMPL_JID, COMPL_STATUS, &do_status_to); | |
95 | 112 |
113 // Status category | |
114 compl_add_category_word(COMPL_STATUS, "online"); | |
115 compl_add_category_word(COMPL_STATUS, "avail"); | |
116 compl_add_category_word(COMPL_STATUS, "invisible"); | |
117 compl_add_category_word(COMPL_STATUS, "free"); | |
118 compl_add_category_word(COMPL_STATUS, "dnd"); | |
119 compl_add_category_word(COMPL_STATUS, "notavail"); | |
120 compl_add_category_word(COMPL_STATUS, "away"); | |
103 | 121 |
122 // Roster category | |
123 compl_add_category_word(COMPL_ROSTER, "bottom"); | |
265 | 124 compl_add_category_word(COMPL_ROSTER, "top"); |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
125 compl_add_category_word(COMPL_ROSTER, "up"); |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
126 compl_add_category_word(COMPL_ROSTER, "down"); |
103 | 127 compl_add_category_word(COMPL_ROSTER, "hide_offline"); |
128 compl_add_category_word(COMPL_ROSTER, "show_offline"); | |
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
129 compl_add_category_word(COMPL_ROSTER, "toggle_offline"); |
330 | 130 compl_add_category_word(COMPL_ROSTER, "alternate"); |
265 | 131 compl_add_category_word(COMPL_ROSTER, "search"); |
236 | 132 compl_add_category_word(COMPL_ROSTER, "unread_first"); |
133 compl_add_category_word(COMPL_ROSTER, "unread_next"); | |
127 | 134 |
187 | 135 // Roster category |
136 compl_add_category_word(COMPL_BUFFER, "bottom"); | |
137 compl_add_category_word(COMPL_BUFFER, "clear"); | |
138 compl_add_category_word(COMPL_BUFFER, "top"); | |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
139 compl_add_category_word(COMPL_BUFFER, "search_backward"); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
140 compl_add_category_word(COMPL_BUFFER, "search_forward"); |
464 | 141 compl_add_category_word(COMPL_BUFFER, "date"); |
462 | 142 compl_add_category_word(COMPL_BUFFER, "%"); |
187 | 143 |
127 | 144 // Group category |
240 | 145 compl_add_category_word(COMPL_GROUP, "fold"); |
146 compl_add_category_word(COMPL_GROUP, "unfold"); | |
130 | 147 compl_add_category_word(COMPL_GROUP, "toggle"); |
238 | 148 |
149 // Multi-line (msay) category | |
150 compl_add_category_word(COMPL_MULTILINE, "abort"); | |
151 compl_add_category_word(COMPL_MULTILINE, "begin"); | |
152 compl_add_category_word(COMPL_MULTILINE, "send"); | |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
153 compl_add_category_word(COMPL_MULTILINE, "verbatim"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
154 |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
155 // Room category |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
156 compl_add_category_word(COMPL_ROOM, "join"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
157 compl_add_category_word(COMPL_ROOM, "leave"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
158 compl_add_category_word(COMPL_ROOM, "names"); |
470 | 159 compl_add_category_word(COMPL_ROOM, "nick"); |
448
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
160 compl_add_category_word(COMPL_ROOM, "remove"); |
475
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
161 compl_add_category_word(COMPL_ROOM, "topic"); |
449 | 162 compl_add_category_word(COMPL_ROOM, "unlock"); |
95 | 163 } |
94 | 164 |
285 | 165 // expandalias(line) |
166 // If there is one, expand the alias in line and returns a new allocated line | |
167 // If no alias is found, returns line | |
168 // Note : if the returned pointer is different from line, the caller should | |
169 // g_free() the pointer after use | |
170 char *expandalias(char *line) | |
171 { | |
172 const char *p1, *p2; | |
173 char *word; | |
174 const gchar *value; | |
175 char *newline = line; | |
176 | |
177 // Ignore leading '/' | |
178 for (p1 = line ; *p1 == '/' ; p1++) | |
179 ; | |
180 // Locate the end of the word | |
181 for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) | |
182 ; | |
183 // Extract the word | |
184 word = g_strndup(p1, p2-p1); | |
185 | |
186 // Look for an alias in the list | |
187 value = settings_get(SETTINGS_TYPE_ALIAS, (const char*)word); | |
188 if (value) { | |
189 // There is an alias to expand | |
190 newline = g_new(char, strlen(value)+strlen(p2)+2); | |
191 *newline = '/'; | |
192 strcpy(newline+1, value); | |
193 strcat(newline, p2); | |
194 } | |
195 g_free(word); | |
196 | |
197 return newline; | |
198 } | |
199 | |
102 | 200 // cmd_get |
201 // Finds command in the command list structure. | |
202 // Returns a pointer to the cmd entry, or NULL if command not found. | |
238 | 203 cmd *cmd_get(const char *command) |
102 | 204 { |
238 | 205 const char *p1, *p2; |
102 | 206 char *com; |
207 GSList *sl_com; | |
285 | 208 |
102 | 209 // Ignore leading '/' |
210 for (p1 = command ; *p1 == '/' ; p1++) | |
211 ; | |
212 // Locate the end of the command | |
213 for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) | |
214 ; | |
215 // Copy the clean command | |
216 com = g_strndup(p1, p2-p1); | |
217 | |
218 // Look for command in the list | |
219 for (sl_com=Commands; sl_com; sl_com = g_slist_next(sl_com)) { | |
220 if (!strcasecmp(com, ((cmd*)sl_com->data)->name)) | |
221 break; | |
222 } | |
223 g_free(com); | |
224 | |
225 if (sl_com) // Command has been found. | |
226 return (cmd*)sl_com->data; | |
227 return NULL; | |
228 } | |
229 | |
47 | 230 // send_message(msg) |
231 // Write the message in the buddy's window and send the message on | |
232 // the network. | |
238 | 233 void send_message(const char *msg) |
47 | 234 { |
81 | 235 const char *jid; |
393 | 236 |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
237 if (!jb_getonline()) { |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
238 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
239 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
240 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
241 |
81 | 242 if (!current_buddy) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
243 scr_LogPrint(LPRINT_NORMAL, "No buddy currently selected."); |
81 | 244 return; |
245 } | |
246 | |
247 jid = CURRENT_JID; | |
248 if (!jid) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
249 scr_LogPrint(LPRINT_NORMAL, "No buddy currently selected."); |
81 | 250 return; |
251 } | |
47 | 252 |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
253 if (buddy_gettype(BUDDATA(current_buddy)) != ROSTER_TYPE_ROOM) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
254 // local part (UI, logging, etc.) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
255 hk_message_out(jid, 0, msg); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
256 } |
47 | 257 |
258 // Network part | |
475
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
259 jb_send_msg(jid, msg, buddy_gettype(BUDDATA(current_buddy)), NULL); |
47 | 260 } |
261 | |
288 | 262 // process_command(line) |
263 // Process a command line. | |
264 // Return 255 if this is the /quit command, and 0 for the other commands. | |
265 int process_command(char *line) | |
47 | 266 { |
101 | 267 char *p; |
285 | 268 char *xpline; |
104 | 269 cmd *curcmd; |
270 | |
101 | 271 // Remove trailing spaces: |
272 for (p=line ; *p ; p++) | |
273 ; | |
274 for (p-- ; p>line && (*p == ' ') ; p--) | |
275 *p = 0; | |
276 | |
285 | 277 // We do alias expansion here |
288 | 278 if (scr_get_multimode() != 2) |
279 xpline = expandalias(line); | |
280 else | |
281 xpline = line; // No expansion in verbatim multi-line mode | |
285 | 282 |
101 | 283 // Command "quit"? |
285 | 284 if ((!strncasecmp(xpline, "/quit", 5)) && (scr_get_multimode() != 2) ) |
285 if (!xpline[5] || xpline[5] == ' ') | |
116 | 286 return 255; |
104 | 287 |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
288 // If verbatim multi-line mode, we check if another /msay command is typed |
285 | 289 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
|
290 // It isn't an /msay command |
285 | 291 scr_append_multiline(xpline); |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
292 return 0; |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
293 } |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
294 |
47 | 295 // Commands handling |
285 | 296 curcmd = cmd_get(xpline); |
47 | 297 |
104 | 298 if (!curcmd) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
299 scr_LogPrint(LPRINT_NORMAL, "Unrecognized command, sorry."); |
285 | 300 if (xpline != line) g_free(xpline); |
104 | 301 return 0; |
302 } | |
303 if (!curcmd->func) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
304 scr_LogPrint(LPRINT_NORMAL, "Not yet implemented, sorry."); |
285 | 305 if (xpline != line) g_free(xpline); |
104 | 306 return 0; |
307 } | |
308 // Lets go to the command parameters | |
285 | 309 for (p = xpline+1; *p && (*p != ' ') ; p++) |
104 | 310 ; |
311 // Skip spaces | |
285 | 312 while (*p && (*p == ' ')) |
313 p++; | |
104 | 314 // Call command-specific function |
285 | 315 (*curcmd->func)(p); |
316 if (xpline != line) g_free(xpline); | |
47 | 317 return 0; |
318 } | |
319 | |
288 | 320 // process_line(line) |
321 // Process a command/message line. | |
322 // If this isn't a command, this is a message and it is sent to the | |
323 // currently selected buddy. | |
324 // Return 255 if the line is the /quit command, or 0. | |
325 int process_line(char *line) | |
326 { | |
327 if (!*line) { // User only pressed enter | |
328 if (scr_get_multimode()) { | |
329 scr_append_multiline(""); | |
330 return 0; | |
331 } | |
332 if (current_buddy) { | |
333 scr_set_chatmode(TRUE); | |
334 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); | |
335 scr_ShowBuddyWindow(); | |
336 } | |
337 return 0; | |
338 } | |
339 | |
340 if (*line != '/') { | |
341 // This isn't a command | |
342 if (scr_get_multimode()) | |
343 scr_append_multiline(line); | |
344 else | |
345 do_say(line); | |
346 return 0; | |
347 } | |
348 | |
349 /* It is (probably) a command -- except for verbatim multi-line mode */ | |
350 return process_command(line); | |
351 } | |
352 | |
104 | 353 /* Commands callback functions */ |
354 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
355 static void do_roster(char *arg) |
104 | 356 { |
357 if (!strcasecmp(arg, "top")) { | |
358 scr_RosterTop(); | |
128 | 359 update_roster = TRUE; |
104 | 360 } else if (!strcasecmp(arg, "bottom")) { |
361 scr_RosterBottom(); | |
128 | 362 update_roster = TRUE; |
104 | 363 } else if (!strcasecmp(arg, "hide_offline")) { |
120 | 364 buddylist_set_hide_offline_buddies(TRUE); |
104 | 365 if (current_buddy) |
366 buddylist_build(); | |
128 | 367 update_roster = TRUE; |
104 | 368 } else if (!strcasecmp(arg, "show_offline")) { |
120 | 369 buddylist_set_hide_offline_buddies(FALSE); |
124 | 370 buddylist_build(); |
128 | 371 update_roster = TRUE; |
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
372 } else if (!strcasecmp(arg, "toggle_offline")) { |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
373 buddylist_set_hide_offline_buddies(-1); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
374 buddylist_build(); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
375 update_roster = TRUE; |
236 | 376 } else if (!strcasecmp(arg, "unread_first")) { |
377 scr_RosterUnreadMessage(0); | |
378 } else if (!strcasecmp(arg, "unread_next")) { | |
379 scr_RosterUnreadMessage(1); | |
330 | 380 } else if (!strcasecmp(arg, "alternate")) { |
381 scr_RosterJumpAlternate(); | |
265 | 382 } else if (!strncasecmp(arg, "search", 6)) { |
383 char *string = arg+6; | |
384 if (*string && (*string != ' ')) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
385 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
265 | 386 return; |
387 } | |
388 while (*string == ' ') | |
389 string++; | |
390 if (!*string) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
391 scr_LogPrint(LPRINT_NORMAL, "What name or jid are you looking for?"); |
265 | 392 return; |
393 } | |
394 scr_RosterSearch(string); | |
395 update_roster = TRUE; | |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
396 } else if (!strcasecmp(arg, "up")) { |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
397 scr_RosterUp(); |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
398 } else if (!strcasecmp(arg, "down")) { |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
399 scr_RosterDown(); |
104 | 400 } else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
401 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
104 | 402 } |
108 | 403 |
444 | 404 // setstatus(recipient, arg) |
405 // Set your Jabber status. | |
406 // - if recipient is not NULL, the status is sent to this contact only | |
407 // - arg must be "status message" (message is optional) | |
408 static void setstatus(const char *recipient, const char *arg) | |
116 | 409 { |
410 enum imstatus st; | |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
411 int len; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
412 char *msg; |
116 | 413 |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
414 if (!jb_getonline()) { |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
415 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
416 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
417 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
418 |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
419 msg = strchr(arg, ' '); |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
420 if (!msg) |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
421 len = strlen(arg); |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
422 else |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
423 len = msg - arg; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
424 |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
425 if (!strncasecmp(arg, "offline", len)) st = offline; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
426 else if (!strncasecmp(arg, "online", len)) st = available; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
427 else if (!strncasecmp(arg, "avail", len)) st = available; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
428 else if (!strncasecmp(arg, "away", len)) st = away; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
429 else if (!strncasecmp(arg, "invisible", len)) st = invisible; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
430 else if (!strncasecmp(arg, "dnd", len)) st = dontdisturb; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
431 else if (!strncasecmp(arg, "notavail", len)) st = notavail; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
432 else if (!strncasecmp(arg, "free", len)) st = freeforchat; |
116 | 433 else { |
444 | 434 scr_LogPrint(LPRINT_NORMAL, "Unrecognized status!"); |
116 | 435 return; |
436 } | |
437 | |
416
48e7808c4191
Allow offline status message
Mikael Berthe <mikael@lilotux.net>
parents:
402
diff
changeset
|
438 if (msg && st != invisible) { |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
439 for (msg++ ; *msg && *msg == ' ' ; msg++) ; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
440 if (!*msg) msg = NULL; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
441 } else |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
442 msg = NULL; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
443 |
444 | 444 jb_setstatus(st, recipient, msg); |
445 } | |
446 | |
447 static void do_status(char *arg) | |
448 { | |
449 if (!arg || (!*arg)) { | |
450 scr_LogPrint(LPRINT_NORMAL, "Your status is: %c", | |
451 imstatus2char[jb_getstatus()]); | |
452 return; | |
453 } | |
454 setstatus(NULL, arg); | |
455 } | |
456 | |
457 static void do_status_to(char *arg) | |
458 { | |
459 char *id, *st; | |
460 if (!arg || (*arg == 0)) { | |
461 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | |
462 return; | |
463 } | |
464 | |
465 // Split recipient jid, status | |
466 id = g_strdup(arg); | |
467 st = strchr(id, ' '); | |
468 if (!st) { | |
469 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | |
470 g_free(id); | |
471 return; | |
472 } | |
473 | |
474 *st++ = 0; | |
475 while (*st && *st == ' ') | |
476 st++; | |
477 | |
452 | 478 if (check_jid_syntax(id)) { |
479 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", id); | |
480 } else { | |
481 mc_strtolower(id); | |
482 scr_LogPrint(LPRINT_LOGNORM, "Sending to <%s> /status %s", id, st); | |
483 setstatus(id, st); | |
484 } | |
485 g_free(id); | |
116 | 486 } |
487 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
488 static void do_add(char *arg) |
124 | 489 { |
244 | 490 char *id, *nick; |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
491 |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
492 if (!jb_getonline()) { |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
493 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
494 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
495 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
496 |
446 | 497 if (!arg || (!*arg)) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
498 scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); |
124 | 499 return; |
500 } | |
501 | |
244 | 502 id = g_strdup(arg); |
503 nick = strchr(id, ' '); | |
504 if (nick) { | |
505 *nick++ = 0; | |
506 while (*nick && *nick == ' ') | |
507 nick++; | |
508 } | |
509 | |
452 | 510 if (check_jid_syntax(id)) { |
511 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", id); | |
512 } else { | |
513 mc_strtolower(id); | |
514 // 2nd parameter = optional nickname | |
515 jb_addbuddy(id, nick, NULL); | |
516 scr_LogPrint(LPRINT_LOGNORM, "Sent presence notification request to <%s>", | |
517 id); | |
518 } | |
244 | 519 g_free(id); |
124 | 520 } |
128 | 521 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
522 static void do_del(char *arg) |
206 | 523 { |
524 const char *jid; | |
525 | |
526 if (arg && (*arg)) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
527 scr_LogPrint(LPRINT_NORMAL, "Wrong usage"); |
206 | 528 return; |
529 } | |
530 | |
531 if (!current_buddy) return; | |
532 jid = buddy_getjid(BUDDATA(current_buddy)); | |
533 if (!jid) return; | |
534 | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
535 scr_LogPrint(LPRINT_LOGNORM, "Removing <%s>...", jid); |
206 | 536 jb_delbuddy(jid); |
537 } | |
538 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
539 static void do_group(char *arg) |
128 | 540 { |
541 gpointer group; | |
166 | 542 guint leave_windowbuddy; |
128 | 543 |
446 | 544 if (!arg || (!*arg)) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
545 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
128 | 546 return; |
547 } | |
548 | |
166 | 549 if (!current_buddy) return; |
128 | 550 |
166 | 551 group = buddy_getgroup(BUDDATA(current_buddy)); |
212 | 552 // We'll have to redraw the chat window if we're not currently on the group |
553 // entry itself, because it means we'll have to leave the current buddy | |
554 // chat window. | |
166 | 555 leave_windowbuddy = (group != BUDDATA(current_buddy)); |
556 | |
128 | 557 if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
558 scr_LogPrint(LPRINT_NORMAL, "You need to select a group"); |
128 | 559 return; |
560 } | |
166 | 561 |
562 if (!strcasecmp(arg, "expand") || !strcasecmp(arg, "unfold")) { | |
128 | 563 buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE); |
166 | 564 } else if (!strcasecmp(arg, "shrink") || !strcasecmp(arg, "fold")) { |
128 | 565 buddy_setflags(group, ROSTER_FLAG_HIDE, TRUE); |
130 | 566 } else if (!strcasecmp(arg, "toggle")) { |
567 buddy_setflags(group, ROSTER_FLAG_HIDE, | |
568 !(buddy_getflags(group) & ROSTER_FLAG_HIDE)); | |
128 | 569 } else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
570 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
128 | 571 return; |
572 } | |
573 | |
574 buddylist_build(); | |
575 update_roster = TRUE; | |
166 | 576 if (leave_windowbuddy) scr_ShowBuddyWindow(); |
128 | 577 } |
578 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
579 static void do_say(char *arg) |
132 | 580 { |
164 | 581 gpointer bud; |
132 | 582 |
583 scr_set_chatmode(TRUE); | |
164 | 584 |
585 if (!current_buddy) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
586 scr_LogPrint(LPRINT_NORMAL, "Who are you talking to??"); |
164 | 587 return; |
132 | 588 } |
164 | 589 |
590 bud = BUDDATA(current_buddy); | |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
591 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
|
592 scr_LogPrint(LPRINT_NORMAL, "This is not a user"); |
164 | 593 return; |
594 } | |
595 | |
596 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); | |
597 send_message(arg); | |
132 | 598 } |
599 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
600 static void do_msay(char *arg) |
238 | 601 { |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
602 /* Parameters: begin verbatim abort send */ |
238 | 603 gpointer bud; |
604 | |
605 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
|
606 if (scr_get_multimode()) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
607 scr_LogPrint(LPRINT_NORMAL, "Leaving multi-line message mode"); |
238 | 608 scr_set_multimode(FALSE); |
609 return; | |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
610 } else if ((!strcasecmp(arg, "begin")) || (!strcasecmp(arg, "verbatim"))) { |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
611 if (!strcasecmp(arg, "verbatim")) |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
612 scr_set_multimode(2); |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
613 else |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
614 scr_set_multimode(1); |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
615 |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
616 scr_LogPrint(LPRINT_NORMAL, "Entered multi-line message mode."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
617 scr_LogPrint(LPRINT_NORMAL, "Select a buddy and use \"/msay send\" " |
238 | 618 "when your message is ready."); |
619 return; | |
446 | 620 } else if (!*arg) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
621 scr_LogPrint(LPRINT_NORMAL, "Please read the manual before using " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
622 "the /msay command."); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
623 scr_LogPrint(LPRINT_NORMAL, "(Use \"/msay begin\" to enter " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
624 "multi-line mode...)"); |
238 | 625 return; |
626 } else if (strcasecmp(arg, "send")) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
627 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
238 | 628 return; |
629 } | |
630 | |
631 // send command | |
632 | |
633 if (!scr_get_multimode()) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
634 scr_LogPrint(LPRINT_NORMAL, "No message to send. " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
635 "Use \"/msay begin\" first."); |
238 | 636 return; |
637 } | |
638 | |
639 scr_set_chatmode(TRUE); | |
640 | |
641 if (!current_buddy) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
642 scr_LogPrint(LPRINT_NORMAL, "Who are you talking to??"); |
238 | 643 return; |
644 } | |
645 | |
646 bud = BUDDATA(current_buddy); | |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
647 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
|
648 scr_LogPrint(LPRINT_NORMAL, "This is not a user"); |
238 | 649 return; |
650 } | |
651 | |
652 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); | |
653 send_message(scr_get_multiline()); | |
654 scr_set_multimode(FALSE); | |
655 } | |
656 | |
480 | 657 static void do_say_to(char *arg) |
658 { | |
659 char *jid, *msg; | |
660 char *bare_jid, *p; | |
661 | |
662 if (!jb_getonline()) { | |
663 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); | |
664 return; | |
665 } | |
666 | |
667 msg = strchr(arg, ' '); | |
668 if (!msg) { | |
669 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); | |
670 return; | |
671 } | |
672 | |
673 jid = g_strndup(arg, msg - arg); | |
674 | |
675 if (check_jid_syntax(jid)) { | |
676 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", jid); | |
677 g_free(jid); | |
678 return; | |
679 } | |
680 | |
681 while (*msg == ' ') msg++; | |
682 if (!*msg) { | |
683 scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); | |
684 g_free(jid); | |
685 return; | |
686 } | |
687 | |
688 // We must use the bare jid in hk_message_out() | |
689 p = strchr(jid, '/'); | |
690 if (p) bare_jid = g_strndup(jid, p - jid); | |
691 else bare_jid = jid; | |
692 | |
693 // Jump to window, create one if needed | |
694 scr_RosterJumpJid(bare_jid); | |
695 | |
696 // local part (UI, logging, etc.) | |
697 hk_message_out(bare_jid, 0, msg); | |
698 | |
699 // Network part | |
700 jb_send_msg(jid, msg, ROSTER_TYPE_USER, NULL); | |
701 g_free(jid); | |
702 if (p) g_free(bare_jid); | |
703 } | |
704 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
705 static void do_buffer(char *arg) |
187 | 706 { |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
707 int search_dir = 0; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
708 |
471
82a27508fb85
Fix segfaults when using /buffer and /room while not connected
Mikael Berthe <mikael@lilotux.net>
parents:
470
diff
changeset
|
709 if (!current_buddy) return; |
446 | 710 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP) { |
711 scr_LogPrint(LPRINT_NORMAL, "Groups have no buffer"); | |
712 return; | |
713 } | |
714 | |
187 | 715 if (!strcasecmp(arg, "top")) { |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
336
diff
changeset
|
716 scr_BufferTopBottom(-1); |
187 | 717 } else if (!strcasecmp(arg, "bottom")) { |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
336
diff
changeset
|
718 scr_BufferTopBottom(1); |
187 | 719 } else if (!strcasecmp(arg, "clear")) { |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
720 scr_BufferClear(); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
721 } else if (!strncasecmp(arg, "search_backward", 15)) { |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
722 arg += 15; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
723 if (*arg++ == ' ') |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
724 search_dir = -1; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
725 else |
446 | 726 scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
727 } else if (!strncasecmp(arg, "search_forward", 14)) { |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
728 arg += 14; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
729 if (*arg++ == ' ') |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
730 search_dir = 1; |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
731 else |
446 | 732 scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); |
464 | 733 } else if (!strncasecmp(arg, "date", 4)) { |
734 arg += 4; | |
735 if (*arg++ != ' ') { | |
736 scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); | |
737 return; | |
738 } | |
739 while (*arg == ' ') arg++; | |
740 if (*arg) { | |
741 time_t t = from_iso8601(arg, 0); | |
742 if (t) | |
743 scr_BufferDate(t); | |
744 else | |
745 scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); | |
746 } | |
747 else | |
748 scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); | |
462 | 749 } else if (*arg == '%') { |
750 arg++; | |
751 while (*arg == ' ') arg++; | |
752 if (*arg) | |
753 scr_BufferPercent(atoi(arg)); | |
754 else | |
755 scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); | |
187 | 756 } else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
757 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
758 |
371
bc54af8ed048
/buffer search_*: skip leading spaces (if any) in string parameter
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
759 if (search_dir) { // It is a string search command |
bc54af8ed048
/buffer search_*: skip leading spaces (if any) in string parameter
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
760 for ( ; *arg && *arg == ' ' ; arg++) |
bc54af8ed048
/buffer search_*: skip leading spaces (if any) in string parameter
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
761 ; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
762 scr_BufferSearch(search_dir, arg); |
371
bc54af8ed048
/buffer search_*: skip leading spaces (if any) in string parameter
Mikael Berthe <mikael@lilotux.net>
parents:
370
diff
changeset
|
763 } |
187 | 764 } |
765 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
766 static void do_clear(char *arg) // Alias for "/buffer clear" |
187 | 767 { |
768 do_buffer("clear"); | |
769 } | |
770 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
771 static void do_info(char *arg) |
191 | 772 { |
773 gpointer bud; | |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
774 const char *jid, *name; |
191 | 775 guint type; |
776 char *buffer; | |
777 | |
778 if (!current_buddy) return; | |
779 bud = BUDDATA(current_buddy); | |
780 | |
781 jid = buddy_getjid(bud); | |
782 name = buddy_getname(bud); | |
783 type = buddy_gettype(bud); | |
784 | |
785 buffer = g_new(char, 128); | |
786 | |
787 if (jid) { | |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
788 GSList *resources; |
191 | 789 char *typestr = "unknown"; |
790 | |
791 snprintf(buffer, 127, "jid: <%s>", jid); | |
792 scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); | |
793 if (name) { | |
794 snprintf(buffer, 127, "Name: %s", name); | |
795 scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); | |
796 } | |
797 | |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
798 if (type == ROSTER_TYPE_USER) typestr = "user"; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
799 else if (type == ROSTER_TYPE_ROOM) typestr = "chatroom"; |
191 | 800 else if (type == ROSTER_TYPE_AGENT) typestr = "agent"; |
801 snprintf(buffer, 127, "Type: %s", typestr); | |
802 scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); | |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
803 |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
804 resources = buddy_getresources(bud); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
805 for ( ; resources ; resources = g_slist_next(resources) ) { |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
806 gchar rprio; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
807 enum imstatus rstatus; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
808 const char *rst_msg; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
809 |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
810 rprio = buddy_getresourceprio(bud, resources->data); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
811 rstatus = buddy_getstatus(bud, resources->data); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
812 rst_msg = buddy_getstatusmsg(bud, resources->data); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
813 |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
814 snprintf(buffer, 127, "Resource: [%c] (%d) %s", imstatus2char[rstatus], |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
815 rprio, (char*)resources->data); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
816 scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
817 if (rst_msg) { |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
818 snprintf(buffer, 127, "Status message: %s", rst_msg); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
819 scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
820 } |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
821 } |
191 | 822 } else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
823 if (name) scr_LogPrint(LPRINT_NORMAL, "Name: %s", name); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
824 scr_LogPrint(LPRINT_NORMAL, "Type: %s", |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
825 ((type == ROSTER_TYPE_GROUP) ? "group" : "unknown")); |
191 | 826 } |
827 | |
828 g_free(buffer); | |
829 } | |
830 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
831 static void do_rename(char *arg) |
208 | 832 { |
833 gpointer bud; | |
834 const char *jid, *group; | |
835 guint type; | |
836 char *newname, *p; | |
837 | |
446 | 838 if (!arg || (!*arg)) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
839 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
208 | 840 return; |
841 } | |
842 | |
843 if (!current_buddy) return; | |
844 bud = BUDDATA(current_buddy); | |
845 | |
846 jid = buddy_getjid(bud); | |
847 group = buddy_getgroupname(bud); | |
848 type = buddy_gettype(bud); | |
849 | |
850 if (type & ROSTER_TYPE_GROUP) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
851 scr_LogPrint(LPRINT_NORMAL, "You can't rename groups"); |
208 | 852 return; |
853 } | |
854 | |
855 newname = g_strdup(arg); | |
856 // Remove trailing space | |
857 for (p = newname; *p; p++) ; | |
858 while (p > newname && *p == ' ') *p = 0; | |
859 | |
860 buddy_setname(bud, newname); | |
861 jb_updatebuddy(jid, newname, group); | |
862 | |
863 g_free(newname); | |
864 update_roster = TRUE; | |
865 } | |
866 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
867 static void do_move(char *arg) |
210 | 868 { |
869 gpointer bud; | |
870 const char *jid, *name; | |
871 guint type; | |
872 char *newgroupname, *p; | |
873 | |
874 if (!current_buddy) return; | |
875 bud = BUDDATA(current_buddy); | |
876 | |
877 jid = buddy_getjid(bud); | |
878 name = buddy_getname(bud); | |
879 type = buddy_gettype(bud); | |
880 | |
881 if (type & ROSTER_TYPE_GROUP) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
882 scr_LogPrint(LPRINT_NORMAL, "You can't move groups!"); |
210 | 883 return; |
884 } | |
885 | |
886 newgroupname = g_strdup(arg); | |
887 // Remove trailing space | |
888 for (p = newgroupname; *p; p++) ; | |
889 while (p > newgroupname && *p == ' ') *p = 0; | |
890 | |
891 // Call to buddy_setgroup() should be at the end, as current implementation | |
892 // clones the buddy and deletes the old one (and thus, jid and name are | |
893 // freed) | |
894 jb_updatebuddy(jid, name, newgroupname); | |
895 buddy_setgroup(bud, newgroupname); | |
896 | |
897 g_free(newgroupname); | |
898 update_roster = TRUE; | |
899 } | |
900 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
901 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
|
902 { |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
903 guint assign; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
904 const gchar *option, *value; |
393 | 905 |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
906 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
|
907 if (!option) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
908 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
|
909 return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
910 } |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
911 if (!assign) { |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
912 // This is a query |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
913 value = settings_opt_get(option); |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
914 if (value) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
915 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
|
916 } else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
917 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
|
918 return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
919 } |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
920 // Update the option |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
921 // 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
|
922 // (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
|
923 // (hide_offline_buddies for ex.) |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
924 if (!value) { |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
925 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
|
926 } else { |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
927 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
|
928 } |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
929 } |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
930 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
931 static void do_alias(char *arg) |
285 | 932 { |
933 guint assign; | |
934 const gchar *alias, *value; | |
393 | 935 |
285 | 936 assign = parse_assigment(arg, &alias, &value); |
937 if (!alias) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
938 scr_LogPrint(LPRINT_NORMAL, "Huh?"); |
285 | 939 return; |
940 } | |
941 if (!assign) { | |
942 // This is a query | |
943 value = settings_get(SETTINGS_TYPE_ALIAS, alias); | |
944 if (value) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
945 scr_LogPrint(LPRINT_NORMAL, "%s = %s", alias, value); |
285 | 946 } else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
947 scr_LogPrint(LPRINT_NORMAL, "Alias '%s' does not exist", alias); |
285 | 948 return; |
949 } | |
950 // Check the alias does not conflict with a registered command | |
951 if (cmd_get(alias)) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
952 scr_LogPrint(LPRINT_NORMAL, "'%s' is a reserved word!", alias); |
285 | 953 return; |
954 } | |
955 // Update the alias | |
956 if (!value) { | |
957 if (settings_get(SETTINGS_TYPE_ALIAS, alias)) { | |
958 settings_del(SETTINGS_TYPE_ALIAS, alias); | |
959 // Remove alias from the completion list | |
960 compl_del_category_word(COMPL_CMD, alias); | |
961 } | |
962 } else { | |
963 // Add alias to the completion list, if not already in | |
964 if (!settings_get(SETTINGS_TYPE_ALIAS, alias)) | |
965 compl_add_category_word(COMPL_CMD, alias); | |
966 settings_set(SETTINGS_TYPE_ALIAS, alias, value); | |
967 } | |
968 } | |
969 | |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
970 static void do_bind(char *arg) |
288 | 971 { |
972 guint assign; | |
973 const gchar *keycode, *value; | |
393 | 974 |
288 | 975 assign = parse_assigment(arg, &keycode, &value); |
976 if (!keycode) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
977 scr_LogPrint(LPRINT_NORMAL, "Huh?"); |
288 | 978 return; |
979 } | |
980 if (!assign) { | |
981 // This is a query | |
982 value = settings_get(SETTINGS_TYPE_BINDING, keycode); | |
983 if (value) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
984 scr_LogPrint(LPRINT_NORMAL, "Key %s is bound to: %s", keycode, value); |
288 | 985 } else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
986 scr_LogPrint(LPRINT_NORMAL, "Key %s is not bound", keycode); |
288 | 987 return; |
988 } | |
989 // Update the key binding | |
990 if (!value) | |
991 settings_del(SETTINGS_TYPE_BINDING, keycode); | |
992 else | |
993 settings_set(SETTINGS_TYPE_BINDING, keycode, value); | |
994 } | |
995 | |
436 | 996 static void do_rawxml(char *arg) |
997 { | |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
998 if (!jb_getonline()) { |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
999 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1000 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1001 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1002 |
436 | 1003 if (!strncasecmp(arg, "send ", 5)) { |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1004 gchar *buffer; |
436 | 1005 for (arg += 5; *arg && *arg == ' '; arg++) |
1006 ; | |
469
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
464
diff
changeset
|
1007 buffer = to_utf8(arg); |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1008 if (!buffer) { |
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1009 scr_LogPrint(LPRINT_NORMAL, "Conversion error in XML string"); |
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1010 return; |
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1011 } |
436 | 1012 scr_LogPrint(LPRINT_NORMAL, "Sending XML string"); |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1013 jb_send_raw(buffer); |
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1014 g_free(buffer); |
436 | 1015 } else { |
1016 scr_LogPrint(LPRINT_NORMAL, "Please read the manual page" | |
1017 " before using /rawxml :-)"); | |
1018 } | |
1019 } | |
1020 | |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1021 static void do_room(char *arg) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1022 { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1023 gpointer bud; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1024 |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1025 if (!jb_getonline()) { |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1026 scr_LogPrint(LPRINT_NORMAL, "You are not connected"); |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1027 return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1028 } |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1029 |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1030 if (!arg || (!*arg)) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1031 scr_LogPrint(LPRINT_NORMAL, "Missing parameter"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1032 return; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1033 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1034 |
471
82a27508fb85
Fix segfaults when using /buffer and /room while not connected
Mikael Berthe <mikael@lilotux.net>
parents:
470
diff
changeset
|
1035 if (!current_buddy) return; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1036 bud = BUDDATA(current_buddy); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1037 |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1038 if (!strncasecmp(arg, "join", 4)) { |
469
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
464
diff
changeset
|
1039 char *roomname, *nick; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1040 |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1041 arg += 4; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1042 if (*arg++ != ' ') { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1043 scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1044 return; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1045 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1046 for (; *arg && *arg == ' '; arg++) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1047 ; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1048 |
454
d647b92e541f
MUC: Disallow room names with a '/'
Mikael Berthe <mikael@lilotux.net>
parents:
452
diff
changeset
|
1049 if (strchr(arg, '/')) { |
d647b92e541f
MUC: Disallow room names with a '/'
Mikael Berthe <mikael@lilotux.net>
parents:
452
diff
changeset
|
1050 scr_LogPrint(LPRINT_NORMAL, "Invalid room name"); |
d647b92e541f
MUC: Disallow room names with a '/'
Mikael Berthe <mikael@lilotux.net>
parents:
452
diff
changeset
|
1051 return; |
d647b92e541f
MUC: Disallow room names with a '/'
Mikael Berthe <mikael@lilotux.net>
parents:
452
diff
changeset
|
1052 } |
d647b92e541f
MUC: Disallow room names with a '/'
Mikael Berthe <mikael@lilotux.net>
parents:
452
diff
changeset
|
1053 |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1054 roomname = g_strdup(arg); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1055 nick = strchr(roomname, ' '); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1056 if (!nick) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1057 scr_LogPrint(LPRINT_NORMAL, "Missing parameter (nickname)"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1058 g_free(roomname); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1059 return; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1060 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1061 |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1062 *nick++ = 0; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1063 while (*nick && *nick == ' ') |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1064 nick++; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1065 if (!*nick) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1066 scr_LogPrint(LPRINT_NORMAL, "Missing parameter (nickname)"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1067 g_free(roomname); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1068 return; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1069 } |
452 | 1070 |
469
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
464
diff
changeset
|
1071 mc_strtolower(roomname); |
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
464
diff
changeset
|
1072 jb_room_join(roomname, nick); |
452 | 1073 |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1074 g_free(roomname); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1075 buddylist_build(); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1076 update_roster = TRUE; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1077 } else if (!strncasecmp(arg, "leave", 5)) { |
469
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
464
diff
changeset
|
1078 gchar *roomid, *utf8_nickname; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1079 arg += 5; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1080 for (; *arg && *arg == ' '; arg++) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1081 ; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1082 if (!(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1083 scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1084 return; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1085 } |
469
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
464
diff
changeset
|
1086 utf8_nickname = to_utf8(buddy_getnickname(bud)); |
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
464
diff
changeset
|
1087 roomid = g_strdup_printf("%s/%s", buddy_getjid(bud), utf8_nickname); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1088 jb_setstatus(offline, roomid, arg); |
469
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
464
diff
changeset
|
1089 g_free(utf8_nickname); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1090 g_free(roomid); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1091 buddy_setnickname(bud, NULL); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1092 buddy_del_all_resources(bud); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1093 scr_LogPrint(LPRINT_NORMAL, "You have left %s", buddy_getjid(bud)); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1094 } else if (!strcasecmp(arg, "names")) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1095 if (!(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1096 scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1097 return; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1098 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1099 do_info(NULL); |
470 | 1100 } else if (!strncasecmp(arg, "nick", 4)) { |
1101 gchar *cmd; | |
1102 arg += 4; | |
1103 if (*arg++ != ' ') { | |
1104 scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); | |
1105 return; | |
1106 } | |
1107 for (; *arg && *arg == ' '; arg++) | |
1108 ; | |
1109 if (!(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) { | |
1110 scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom"); | |
1111 return; | |
1112 } | |
1113 cmd = g_strdup_printf("join %s %s", buddy_getjid(bud), arg); | |
1114 do_room(cmd); | |
1115 g_free(cmd); | |
448
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1116 } else if (!strcasecmp(arg, "remove")) { |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1117 if (!(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) { |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1118 scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom"); |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1119 return; |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1120 } |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1121 // Quick check: if there are resources, we haven't left |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1122 if (buddy_getresources(bud)) { |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1123 scr_LogPrint(LPRINT_NORMAL, "You haven't left this room!"); |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1124 return; |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1125 } |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1126 // Delete the room |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1127 roster_del_user(buddy_getjid(bud)); |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1128 buddylist_build(); |
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1129 update_roster = TRUE; |
449 | 1130 } else if (!strcasecmp(arg, "unlock")) { |
1131 if (!(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) { | |
1132 scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom"); | |
1133 return; | |
1134 } | |
1135 jb_room_unlock(buddy_getjid(bud)); | |
475
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1136 } else if (!strncasecmp(arg, "topic", 5)) { |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1137 gchar *msg; |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1138 arg += 5; |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1139 if (*arg++ != ' ') { |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1140 scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1141 return; |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1142 } |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1143 for (; *arg && *arg == ' '; arg++) |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1144 ; |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1145 if (!(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) { |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1146 scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom"); |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1147 return; |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1148 } |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1149 msg = g_strdup_printf("/me has set the topic to: %s", arg); |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1150 jb_send_msg(buddy_getjid(bud), msg, ROSTER_TYPE_ROOM, arg); |
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
1151 g_free(msg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1152 } else { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1153 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1154 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1155 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
1156 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1157 static void do_connect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1158 { |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1159 mcabber_connect(); |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1160 } |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1161 |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1162 static void do_disconnect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1163 { |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1164 jb_disconnect(); |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
1165 } |