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