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"
|
81
|
24 #include "roster.h"
|
47
|
25 #include "screen.h"
|
81
|
26 #include "utf8.h"
|
47
|
27 #include "utils.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;
|
81
|
36 const char *jid;
|
|
37
|
|
38 if (!current_buddy) {
|
|
39 scr_LogPrint("No buddy currently selected.");
|
|
40 return;
|
|
41 }
|
|
42
|
|
43 jid = CURRENT_JID;
|
|
44 if (!jid) {
|
|
45 scr_LogPrint("No buddy currently selected.");
|
|
46 return;
|
|
47 }
|
47
|
48
|
|
49 // UI part
|
81
|
50 scr_WriteOutgoingMessage(jid, msg);
|
47
|
51
|
|
52 // Network part
|
|
53 buffer = utf8_encode(msg);
|
81
|
54 jb_send_msg(jid, buffer);
|
47
|
55 free(buffer);
|
|
56 }
|
|
57
|
|
58 // process_line(line)
|
|
59 // Process a command/message line.
|
|
60 // If this isn't a command, this is a message and it is sent to the
|
|
61 // currently selected buddy.
|
|
62 int process_line(char *line)
|
|
63 {
|
|
64 if (*line != '/') {
|
|
65 send_message(line);
|
|
66 return 0;
|
|
67 }
|
|
68 if (!strcasecmp(line, "/quit")) {
|
|
69 return 255;
|
|
70 }
|
|
71 // Commands handling
|
|
72 // TODO
|
|
73 // say, send_raw...
|
|
74
|
|
75 scr_LogPrint("Unrecognised command, sorry.");
|
|
76 return 0;
|
|
77 }
|
|
78
|