47
|
1 /* |
|
2 * commands.c -- user commands handling |
|
3 * |
|
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 |
|
22 #include "commands.h" |
|
23 #include "jabglue.h" |
|
24 #include "screen.h" |
|
25 #include "utils.h" |
|
26 #include "buddies.h" |
|
27 #include "utf8.h" |
|
28 |
|
29 |
|
30 // send_message(msg) |
|
31 // Write the message in the buddy's window and send the message on |
|
32 // the network. |
|
33 void send_message(char *msg) |
|
34 { |
|
35 char *buffer; |
|
36 buddy_entry_t *tmp = bud_SelectedInfo(); |
|
37 |
|
38 // UI part |
|
39 scr_WriteOutgoingMessage(tmp->jid, msg); |
|
40 |
|
41 // Network part |
|
42 buffer = utf8_encode(msg); |
|
43 jb_send_msg(tmp->jid, buffer); |
|
44 free(buffer); |
|
45 } |
|
46 |
|
47 // process_line(line) |
|
48 // Process a command/message line. |
|
49 // If this isn't a command, this is a message and it is sent to the |
|
50 // currently selected buddy. |
|
51 int process_line(char *line) |
|
52 { |
|
53 if (*line != '/') { |
|
54 send_message(line); |
|
55 return 0; |
|
56 } |
|
57 if (!strcasecmp(line, "/quit")) { |
|
58 return 255; |
|
59 } |
|
60 // Commands handling |
|
61 // TODO |
|
62 // say, send_raw... |
|
63 |
|
64 scr_LogPrint("Unrecognised command, sorry."); |
|
65 return 0; |
|
66 } |
|
67 |