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