annotate mcabber/src/commands.c @ 308:70914672c8e7 0.6.3

Ready for 0.6.3 release
author Mikael Berthe <mikael@lilotux.net>
date Tue, 12 Jul 2005 17:36:06 +0100
parents 12f919be3da5
children 29b27c8692ea
rev   line source
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
1 /*
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
2 * commands.c -- user commands handling
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
3 *
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
4 * Copyright (C) 2005 Mikael Berthe <bmikael@lists.lilotux.net>
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
5 *
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or (at
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
9 * your option) any later version.
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
10 *
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
14 * General Public License for more details.
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
15 *
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
19 * USA
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
20 */
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
21
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
22 #include <string.h>
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
23
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
24 #include "commands.h"
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
25 #include "jabglue.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
26 #include "roster.h"
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
27 #include "screen.h"
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
28 #include "compl.h"
113
8ac67e951eab [/trunk] Changeset 127 by mikael
mikael
parents: 108
diff changeset
29 #include "hooks.h"
191
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
30 #include "hbuf.h"
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
31 #include "utf8.h"
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
32 #include "utils.h"
283
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
33 #include "settings.h"
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
34
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
35 // Commands callbacks
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
36 void do_roster(char *arg);
116
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
37 void do_status(char *arg);
124
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
38 void do_add(char *arg);
205
e01bf6d9b4b8 [/trunk] Changeset 217 by mikael
mikael
parents: 191
diff changeset
39 void do_del(char *arg);
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
40 void do_group(char *arg);
132
6531bcf030ae [/trunk] Changeset 145 by mikael
mikael
parents: 130
diff changeset
41 void do_say(char *arg);
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
42 void do_msay(char *arg);
187
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
43 void do_buffer(char *arg);
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
44 void do_clear(char *arg);
191
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
45 void do_info(char *arg);
208
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
46 void do_rename(char *arg);
210
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
47 void do_move(char *arg);
283
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
48 void do_set(char *arg);
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
49 void do_alias(char *arg);
288
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
50 void do_bind(char *arg);
298
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
51 void do_connect(char *arg);
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
52 void do_disconnect(char *arg);
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
53
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
54 // Global variable for the commands list
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
55 static GSList *Commands;
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
56
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
57
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
58 // cmd_add()
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
59 // Adds a command to the commands list and to the CMD completion list
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
60 void cmd_add(const char *name, const char *help,
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
61 guint flags_row1, guint flags_row2, void (*f)())
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
62 {
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
63 cmd *n_cmd = g_new0(cmd, 1);
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
64 strncpy(n_cmd->name, name, 32-1);
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
65 n_cmd->help = help;
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
66 n_cmd->completion_flags[0] = flags_row1;
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
67 n_cmd->completion_flags[1] = flags_row2;
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
68 n_cmd->func = f;
102
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
69 Commands = g_slist_append(Commands, n_cmd);
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
70 // Add to completion CMD category
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
71 compl_add_category_word(COMPL_CMD, name);
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
72 }
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
73
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
74 // cmd_init()
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
75 // ...
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
76 void cmd_init(void)
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
77 {
124
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
78 cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add);
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
79 cmd_add("alias", "Add an alias", 0, 0, &do_alias);
288
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
80 cmd_add("bind", "Add an key binding", 0, 0, &do_bind);
187
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
81 cmd_add("buffer", "Manipulate current buddy's buffer (chat window)",
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
82 COMPL_BUFFER, 0, &do_buffer);
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 104
diff changeset
83 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
84 cmd_add("connect", "Connect to the server", 0, 0, &do_connect);
205
e01bf6d9b4b8 [/trunk] Changeset 217 by mikael
mikael
parents: 191
diff changeset
85 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
86 cmd_add("disconnect", "Disconnect from server", 0, 0, &do_disconnect);
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
87 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
88 //cmd_add("help", "Display some help", COMPL_CMD, 0, NULL);
191
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
89 cmd_add("info", "Show basic infos on current buddy", 0, 0, &do_info);
225
d5ae42cbe1fa [/trunk] Changeset 237 by mikael
mikael
parents: 221
diff changeset
90 cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME,
d5ae42cbe1fa [/trunk] Changeset 237 by mikael
mikael
parents: 221
diff changeset
91 0, &do_move);
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
92 cmd_add("msay", "Send a multi-lines message to the selected buddy",
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
93 COMPL_MULTILINE, 0, &do_msay);
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
94 //cmd_add("nick");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
95 cmd_add("quit", "Exit the software", 0, 0, NULL);
208
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
96 cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename);
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
97 //cmd_add("request_auth");
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
98 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0,
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
99 &do_roster);
132
6531bcf030ae [/trunk] Changeset 145 by mikael
mikael
parents: 130
diff changeset
100 cmd_add("say", "Say something to the selected buddy", 0, 0, &do_say);
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
101 //cmd_add("search");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
102 //cmd_add("send_auth");
308
70914672c8e7 Ready for 0.6.3 release
Mikael Berthe <mikael@lilotux.net>
parents: 300
diff changeset
103 //cmd_add("set", "Set/query an option value", 0, 0, &do_set);
116
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
104 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status);
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
105
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
106 // Status category
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
107 compl_add_category_word(COMPL_STATUS, "online");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
108 compl_add_category_word(COMPL_STATUS, "avail");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
109 compl_add_category_word(COMPL_STATUS, "invisible");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
110 compl_add_category_word(COMPL_STATUS, "free");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
111 compl_add_category_word(COMPL_STATUS, "dnd");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
112 compl_add_category_word(COMPL_STATUS, "notavail");
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
113 compl_add_category_word(COMPL_STATUS, "away");
103
93dcc4e15d4a [/trunk] Changeset 117 by mikael
mikael
parents: 102
diff changeset
114
93dcc4e15d4a [/trunk] Changeset 117 by mikael
mikael
parents: 102
diff changeset
115 // Roster category
93dcc4e15d4a [/trunk] Changeset 117 by mikael
mikael
parents: 102
diff changeset
116 compl_add_category_word(COMPL_ROSTER, "bottom");
265
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
117 compl_add_category_word(COMPL_ROSTER, "top");
103
93dcc4e15d4a [/trunk] Changeset 117 by mikael
mikael
parents: 102
diff changeset
118 compl_add_category_word(COMPL_ROSTER, "hide_offline");
93dcc4e15d4a [/trunk] Changeset 117 by mikael
mikael
parents: 102
diff changeset
119 compl_add_category_word(COMPL_ROSTER, "show_offline");
290
f63839a4cb35 Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
120 compl_add_category_word(COMPL_ROSTER, "toggle_offline");
265
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
121 compl_add_category_word(COMPL_ROSTER, "search");
236
72fd1273f2b7 [/trunk] Changeset 249 by mikael
mikael
parents: 232
diff changeset
122 compl_add_category_word(COMPL_ROSTER, "unread_first");
72fd1273f2b7 [/trunk] Changeset 249 by mikael
mikael
parents: 232
diff changeset
123 compl_add_category_word(COMPL_ROSTER, "unread_next");
127
0f7ec11efd06 [/trunk] Changeset 140 by mikael
mikael
parents: 124
diff changeset
124
187
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
125 // Roster category
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
126 compl_add_category_word(COMPL_BUFFER, "bottom");
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
127 compl_add_category_word(COMPL_BUFFER, "clear");
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
128 compl_add_category_word(COMPL_BUFFER, "top");
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
129
127
0f7ec11efd06 [/trunk] Changeset 140 by mikael
mikael
parents: 124
diff changeset
130 // Group category
240
723433a677f0 [/trunk] Changeset 253 by mikael
mikael
parents: 238
diff changeset
131 compl_add_category_word(COMPL_GROUP, "fold");
723433a677f0 [/trunk] Changeset 253 by mikael
mikael
parents: 238
diff changeset
132 compl_add_category_word(COMPL_GROUP, "unfold");
130
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
133 compl_add_category_word(COMPL_GROUP, "toggle");
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
134
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
135 // Multi-line (msay) category
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
136 compl_add_category_word(COMPL_MULTILINE, "abort");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
137 compl_add_category_word(COMPL_MULTILINE, "begin");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
138 compl_add_category_word(COMPL_MULTILINE, "send");
260
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
139 compl_add_category_word(COMPL_MULTILINE, "verbatim");
95
9e6b7897ec37 [/trunk] Changeset 109 by mikael
mikael
parents: 94
diff changeset
140 }
94
9a4aa2797f02 [/trunk] Changeset 108 by mikael
mikael
parents: 81
diff changeset
141
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
142 // expandalias(line)
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
143 // If there is one, expand the alias in line and returns a new allocated line
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
144 // If no alias is found, returns line
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
145 // Note : if the returned pointer is different from line, the caller should
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
146 // g_free() the pointer after use
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
147 char *expandalias(char *line)
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
148 {
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
149 const char *p1, *p2;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
150 char *word;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
151 const gchar *value;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
152 char *newline = line;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
153
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
154 // Ignore leading '/'
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
155 for (p1 = line ; *p1 == '/' ; p1++)
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
156 ;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
157 // Locate the end of the word
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
158 for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++)
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
159 ;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
160 // Extract the word
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
161 word = g_strndup(p1, p2-p1);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
162
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
163 // Look for an alias in the list
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
164 value = settings_get(SETTINGS_TYPE_ALIAS, (const char*)word);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
165 if (value) {
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
166 // There is an alias to expand
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
167 newline = g_new(char, strlen(value)+strlen(p2)+2);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
168 *newline = '/';
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
169 strcpy(newline+1, value);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
170 strcat(newline, p2);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
171 }
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
172 g_free(word);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
173
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
174 return newline;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
175 }
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
176
102
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
177 // cmd_get
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
178 // Finds command in the command list structure.
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
179 // Returns a pointer to the cmd entry, or NULL if command not found.
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
180 cmd *cmd_get(const char *command)
102
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
181 {
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
182 const char *p1, *p2;
102
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
183 char *com;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
184 GSList *sl_com;
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
185
102
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
186 // Ignore leading '/'
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
187 for (p1 = command ; *p1 == '/' ; p1++)
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
188 ;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
189 // Locate the end of the command
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
190 for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++)
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
191 ;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
192 // Copy the clean command
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
193 com = g_strndup(p1, p2-p1);
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
194
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
195 // Look for command in the list
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
196 for (sl_com=Commands; sl_com; sl_com = g_slist_next(sl_com)) {
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
197 if (!strcasecmp(com, ((cmd*)sl_com->data)->name))
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
198 break;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
199 }
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
200 g_free(com);
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
201
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
202 if (sl_com) // Command has been found.
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
203 return (cmd*)sl_com->data;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
204 return NULL;
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
205 }
2b4cc6bc5bf2 [/trunk] Changeset 116 by mikael
mikael
parents: 101
diff changeset
206
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
207 // send_message(msg)
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
208 // Write the message in the buddy's window and send the message on
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
209 // the network.
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
210 void send_message(const char *msg)
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
211 {
81
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
212 const char *jid;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
213
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
214 if (!current_buddy) {
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
215 scr_LogPrint("No buddy currently selected.");
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
216 return;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
217 }
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
218
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
219 jid = CURRENT_JID;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
220 if (!jid) {
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
221 scr_LogPrint("No buddy currently selected.");
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
222 return;
0bd578421ce9 [/trunk] Changeset 95 by mikael
mikael
parents: 47
diff changeset
223 }
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
224
113
8ac67e951eab [/trunk] Changeset 127 by mikael
mikael
parents: 108
diff changeset
225 // local part (UI, logging, etc.)
8ac67e951eab [/trunk] Changeset 127 by mikael
mikael
parents: 108
diff changeset
226 hk_message_out(jid, 0, msg);
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
227
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
228 // Network part
213
4fcdbfdf7c20 [/trunk] Changeset 225 by mikael
mikael
parents: 212
diff changeset
229 jb_send_msg(jid, msg);
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
230 }
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
231
288
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
232 // process_command(line)
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
233 // Process a command line.
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
234 // Return 255 if this is the /quit command, and 0 for the other commands.
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
235 int process_command(char *line)
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
236 {
101
4f3ad00b5187 [/trunk] Changeset 115 by mikael
mikael
parents: 98
diff changeset
237 char *p;
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
238 char *xpline;
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
239 cmd *curcmd;
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
240
101
4f3ad00b5187 [/trunk] Changeset 115 by mikael
mikael
parents: 98
diff changeset
241 // Remove trailing spaces:
4f3ad00b5187 [/trunk] Changeset 115 by mikael
mikael
parents: 98
diff changeset
242 for (p=line ; *p ; p++)
4f3ad00b5187 [/trunk] Changeset 115 by mikael
mikael
parents: 98
diff changeset
243 ;
4f3ad00b5187 [/trunk] Changeset 115 by mikael
mikael
parents: 98
diff changeset
244 for (p-- ; p>line && (*p == ' ') ; p--)
4f3ad00b5187 [/trunk] Changeset 115 by mikael
mikael
parents: 98
diff changeset
245 *p = 0;
4f3ad00b5187 [/trunk] Changeset 115 by mikael
mikael
parents: 98
diff changeset
246
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
247 // We do alias expansion here
288
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
248 if (scr_get_multimode() != 2)
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
249 xpline = expandalias(line);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
250 else
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
251 xpline = line; // No expansion in verbatim multi-line mode
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
252
101
4f3ad00b5187 [/trunk] Changeset 115 by mikael
mikael
parents: 98
diff changeset
253 // Command "quit"?
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
254 if ((!strncasecmp(xpline, "/quit", 5)) && (scr_get_multimode() != 2) )
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
255 if (!xpline[5] || xpline[5] == ' ')
116
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
256 return 255;
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
257
260
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
258 // If verbatim multi-line mode, we check if another /msay command is typed
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
259 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
260 // It isn't an /msay command
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
261 scr_append_multiline(xpline);
260
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
262 return 0;
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
263 }
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
264
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
265 // Commands handling
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
266 curcmd = cmd_get(xpline);
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
267
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
268 if (!curcmd) {
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
269 scr_LogPrint("Unrecognized command, sorry.");
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
270 if (xpline != line) g_free(xpline);
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
271 return 0;
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
272 }
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
273 if (!curcmd->func) {
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
274 scr_LogPrint("Not yet implemented, sorry.");
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
275 if (xpline != line) g_free(xpline);
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
276 return 0;
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
277 }
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
278 // Lets go to the command parameters
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
279 for (p = xpline+1; *p && (*p != ' ') ; p++)
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
280 ;
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
281 // Skip spaces
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
282 while (*p && (*p == ' '))
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
283 p++;
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
284 // Call command-specific function
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
285 (*curcmd->func)(p);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
286 if (xpline != line) g_free(xpline);
47
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
287 return 0;
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
288 }
7259a61e1a4b [/trunk] Changeset 63 by mikael
mikael
parents:
diff changeset
289
288
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
290 // process_line(line)
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
291 // Process a command/message line.
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
292 // If this isn't a command, this is a message and it is sent to the
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
293 // currently selected buddy.
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
294 // Return 255 if the line is the /quit command, or 0.
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
295 int process_line(char *line)
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
296 {
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
297 if (!*line) { // User only pressed enter
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
298 if (scr_get_multimode()) {
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
299 scr_append_multiline("");
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
300 return 0;
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
301 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
302 if (current_buddy) {
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
303 scr_set_chatmode(TRUE);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
304 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
305 scr_ShowBuddyWindow();
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
306 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
307 return 0;
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
308 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
309
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
310 if (*line != '/') {
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
311 // This isn't a command
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
312 if (scr_get_multimode())
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
313 scr_append_multiline(line);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
314 else
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
315 do_say(line);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
316 return 0;
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
317 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
318
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
319 /* It is (probably) a command -- except for verbatim multi-line mode */
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
320 return process_command(line);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
321 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
322
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
323 /* Commands callback functions */
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
324
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
325 void do_roster(char *arg)
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
326 {
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
327 if (!strcasecmp(arg, "top")) {
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
328 scr_RosterTop();
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
329 update_roster = TRUE;
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
330 } else if (!strcasecmp(arg, "bottom")) {
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
331 scr_RosterBottom();
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
332 update_roster = TRUE;
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
333 } else if (!strcasecmp(arg, "hide_offline")) {
120
cfd3df636d5f [/trunk] Changeset 133 by mikael
mikael
parents: 118
diff changeset
334 buddylist_set_hide_offline_buddies(TRUE);
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
335 if (current_buddy)
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
336 buddylist_build();
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
337 update_roster = TRUE;
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
338 } else if (!strcasecmp(arg, "show_offline")) {
120
cfd3df636d5f [/trunk] Changeset 133 by mikael
mikael
parents: 118
diff changeset
339 buddylist_set_hide_offline_buddies(FALSE);
124
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
340 buddylist_build();
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
341 update_roster = TRUE;
290
f63839a4cb35 Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
342 } else if (!strcasecmp(arg, "toggle_offline")) {
f63839a4cb35 Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
343 buddylist_set_hide_offline_buddies(-1);
f63839a4cb35 Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
344 buddylist_build();
f63839a4cb35 Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents: 288
diff changeset
345 update_roster = TRUE;
236
72fd1273f2b7 [/trunk] Changeset 249 by mikael
mikael
parents: 232
diff changeset
346 } else if (!strcasecmp(arg, "unread_first")) {
72fd1273f2b7 [/trunk] Changeset 249 by mikael
mikael
parents: 232
diff changeset
347 scr_RosterUnreadMessage(0);
72fd1273f2b7 [/trunk] Changeset 249 by mikael
mikael
parents: 232
diff changeset
348 } else if (!strcasecmp(arg, "unread_next")) {
72fd1273f2b7 [/trunk] Changeset 249 by mikael
mikael
parents: 232
diff changeset
349 scr_RosterUnreadMessage(1);
265
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
350 } else if (!strncasecmp(arg, "search", 6)) {
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
351 char *string = arg+6;
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
352 if (*string && (*string != ' ')) {
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
353 scr_LogPrint("Unrecognized parameter!");
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
354 return;
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
355 }
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
356 while (*string == ' ')
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
357 string++;
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
358 if (!*string) {
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
359 scr_LogPrint("What name or jid are you looking for?");
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
360 return;
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
361 }
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
362 scr_RosterSearch(string);
49e9e02dd6d0 Add "/roster search" command
mikael@frmp8452
parents: 262
diff changeset
363 update_roster = TRUE;
104
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
364 } else
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
365 scr_LogPrint("Unrecognized parameter!");
fe7257d251ac [/trunk] Changeset 118 by mikael
mikael
parents: 103
diff changeset
366 }
108
7fb72bc13732 [/trunk] Changeset 122 by mikael
mikael
parents: 104
diff changeset
367
116
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
368 void do_status(char *arg)
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
369 {
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
370 enum imstatus st;
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
371
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
372 if (!arg || (*arg == 0)) {
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
373 scr_LogPrint("Your status is: %c", imstatus2char[jb_getstatus()]);
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
374 return;
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
375 }
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
376
130
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
377 if (!strcasecmp(arg, "offline")) st = offline;
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
378 else if (!strcasecmp(arg, "online")) st = available;
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
379 else if (!strcasecmp(arg, "avail")) st = available;
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
380 else if (!strcasecmp(arg, "away")) st = away;
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
381 else if (!strcasecmp(arg, "invisible")) st = invisible;
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
382 else if (!strcasecmp(arg, "dnd")) st = dontdisturb;
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
383 else if (!strcasecmp(arg, "notavail")) st = notavail;
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
384 else if (!strcasecmp(arg, "free")) st = freeforchat;
116
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
385 else {
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
386 scr_LogPrint("Unrecognized parameter!");
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
387 return;
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
388 }
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
389
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
390 // XXX special case if offline??
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
391 jb_setstatus(st, NULL); // TODO handle message (instead of NULL)
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
392 }
1e7e59775f12 [/trunk] Changeset 130 by mikael
mikael
parents: 113
diff changeset
393
124
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
394 void do_add(char *arg)
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
395 {
244
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
396 char *id, *nick;
124
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
397 if (!arg || (*arg == 0)) {
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
398 scr_LogPrint("Wrong usage");
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
399 return;
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
400 }
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
401
244
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
402 id = g_strdup(arg);
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
403 nick = strchr(id, ' ');
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
404 if (nick) {
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
405 *nick++ = 0;
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
406 while (*nick && *nick == ' ')
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
407 nick++;
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
408 }
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
409
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
410 // FIXME check id =~ jabber id
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
411 // 2nd parameter = optional nickname
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
412 jb_addbuddy(id, nick, NULL);
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
413 scr_LogPrint("Sent presence notfication request to <%s>", id);
5f8b529412bd [/trunk] Changeset 257 by mikael
mikael
parents: 240
diff changeset
414 g_free(id);
124
6d2122c003c4 [/trunk] Changeset 137 by mikael
mikael
parents: 120
diff changeset
415 }
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
416
206
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
417 void do_del(char *arg)
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
418 {
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
419 const char *jid;
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
420
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
421 if (arg && (*arg)) {
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
422 scr_LogPrint("Wrong usage");
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
423 return;
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
424 }
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
425
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
426 if (!current_buddy) return;
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
427 jid = buddy_getjid(BUDDATA(current_buddy));
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
428 if (!jid) return;
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
429
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
430 scr_LogPrint("Removing <%s>...", jid);
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
431 jb_delbuddy(jid);
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
432 }
766167c0c57f [/trunk] Changeset 218 by mikael
mikael
parents: 205
diff changeset
433
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
434 void do_group(char *arg)
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
435 {
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
436 gpointer group;
166
aa5b635520ef [/trunk] Changeset 178 by mikael
mikael
parents: 164
diff changeset
437 guint leave_windowbuddy;
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
438
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
439 if (!arg || (*arg == 0)) {
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
440 scr_LogPrint("Missing parameter");
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
441 return;
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
442 }
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
443
166
aa5b635520ef [/trunk] Changeset 178 by mikael
mikael
parents: 164
diff changeset
444 if (!current_buddy) return;
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
445
166
aa5b635520ef [/trunk] Changeset 178 by mikael
mikael
parents: 164
diff changeset
446 group = buddy_getgroup(BUDDATA(current_buddy));
212
465d98d2f8e3 [/trunk] Changeset 224 by mikael
mikael
parents: 210
diff changeset
447 // We'll have to redraw the chat window if we're not currently on the group
465d98d2f8e3 [/trunk] Changeset 224 by mikael
mikael
parents: 210
diff changeset
448 // entry itself, because it means we'll have to leave the current buddy
465d98d2f8e3 [/trunk] Changeset 224 by mikael
mikael
parents: 210
diff changeset
449 // chat window.
166
aa5b635520ef [/trunk] Changeset 178 by mikael
mikael
parents: 164
diff changeset
450 leave_windowbuddy = (group != BUDDATA(current_buddy));
aa5b635520ef [/trunk] Changeset 178 by mikael
mikael
parents: 164
diff changeset
451
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
452 if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) {
166
aa5b635520ef [/trunk] Changeset 178 by mikael
mikael
parents: 164
diff changeset
453 scr_LogPrint("You need to select a group");
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
454 return;
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
455 }
166
aa5b635520ef [/trunk] Changeset 178 by mikael
mikael
parents: 164
diff changeset
456
aa5b635520ef [/trunk] Changeset 178 by mikael
mikael
parents: 164
diff changeset
457 if (!strcasecmp(arg, "expand") || !strcasecmp(arg, "unfold")) {
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
458 buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE);
166
aa5b635520ef [/trunk] Changeset 178 by mikael
mikael
parents: 164
diff changeset
459 } else if (!strcasecmp(arg, "shrink") || !strcasecmp(arg, "fold")) {
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
460 buddy_setflags(group, ROSTER_FLAG_HIDE, TRUE);
130
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
461 } else if (!strcasecmp(arg, "toggle")) {
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
462 buddy_setflags(group, ROSTER_FLAG_HIDE,
60694c9ddde3 [/trunk] Changeset 143 by mikael
mikael
parents: 129
diff changeset
463 !(buddy_getflags(group) & ROSTER_FLAG_HIDE));
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
464 } else {
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
465 scr_LogPrint("Unrecognized parameter!");
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
466 return;
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
467 }
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
468
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
469 buddylist_build();
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
470 update_roster = TRUE;
166
aa5b635520ef [/trunk] Changeset 178 by mikael
mikael
parents: 164
diff changeset
471 if (leave_windowbuddy) scr_ShowBuddyWindow();
128
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
472 }
81ccb1091dd8 [/trunk] Changeset 141 by mikael
mikael
parents: 127
diff changeset
473
132
6531bcf030ae [/trunk] Changeset 145 by mikael
mikael
parents: 130
diff changeset
474 void do_say(char *arg)
6531bcf030ae [/trunk] Changeset 145 by mikael
mikael
parents: 130
diff changeset
475 {
164
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
476 gpointer bud;
132
6531bcf030ae [/trunk] Changeset 145 by mikael
mikael
parents: 130
diff changeset
477
6531bcf030ae [/trunk] Changeset 145 by mikael
mikael
parents: 130
diff changeset
478 scr_set_chatmode(TRUE);
164
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
479
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
480 if (!current_buddy) {
132
6531bcf030ae [/trunk] Changeset 145 by mikael
mikael
parents: 130
diff changeset
481 scr_LogPrint("Who are you talking to??");
164
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
482 return;
132
6531bcf030ae [/trunk] Changeset 145 by mikael
mikael
parents: 130
diff changeset
483 }
164
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
484
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
485 bud = BUDDATA(current_buddy);
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
486 if (!(buddy_gettype(bud) & ROSTER_TYPE_USER)) {
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
487 scr_LogPrint("This is not a user");
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
488 return;
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
489 }
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
490
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
491 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE);
faf534be8ff0 [/trunk] Changeset 176 by mikael
mikael
parents: 132
diff changeset
492 send_message(arg);
132
6531bcf030ae [/trunk] Changeset 145 by mikael
mikael
parents: 130
diff changeset
493 }
6531bcf030ae [/trunk] Changeset 145 by mikael
mikael
parents: 130
diff changeset
494
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
495 void do_msay(char *arg)
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
496 {
260
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
497 /* Parameters: begin verbatim abort send */
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
498 gpointer bud;
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
499
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
500 if (!strcasecmp(arg, "abort")) {
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
501 scr_set_multimode(FALSE);
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
502 return;
260
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
503 } else if ((!strcasecmp(arg, "begin")) || (!strcasecmp(arg, "verbatim"))) {
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
504 if (!strcasecmp(arg, "verbatim"))
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
505 scr_set_multimode(2);
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
506 else
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
507 scr_set_multimode(1);
33e1a05864a6 Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents: 244
diff changeset
508
238
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
509 scr_LogPrint("Entered multi-line message mode.");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
510 scr_LogPrint("Select a buddy and use \"/msay send\" "
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
511 "when your message is ready.");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
512 return;
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
513 } else if (*arg == 0) {
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
514 scr_LogPrint("Please read the manual before using the /msay command.");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
515 scr_LogPrint("(Use /msay begin to enter multi-line mode...)");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
516 return;
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
517 } else if (strcasecmp(arg, "send")) {
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
518 scr_LogPrint("Unrecognized parameter!");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
519 return;
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
520 }
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
521
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
522 // send command
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
523
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
524 if (!scr_get_multimode()) {
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
525 scr_LogPrint("No message to send. Use \"/msay begin\" first.");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
526 return;
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
527 }
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
528
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
529 scr_set_chatmode(TRUE);
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
530
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
531 if (!current_buddy) {
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
532 scr_LogPrint("Who are you talking to??");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
533 return;
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
534 }
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
535
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
536 bud = BUDDATA(current_buddy);
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
537 if (!(buddy_gettype(bud) & ROSTER_TYPE_USER)) {
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
538 scr_LogPrint("This is not a user");
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
539 return;
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
540 }
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
541
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
542 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE);
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
543 send_message(scr_get_multiline());
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
544 scr_set_multimode(FALSE);
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
545 }
8e30b2bb380e [/trunk] Changeset 251 by mikael
mikael
parents: 236
diff changeset
546
187
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
547 void do_buffer(char *arg)
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
548 {
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
549 if (!strcasecmp(arg, "top")) {
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
550 scr_BufferTop();
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
551 } else if (!strcasecmp(arg, "bottom")) {
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
552 scr_BufferBottom();
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
553 } else if (!strcasecmp(arg, "clear")) {
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
554 scr_Clear();
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
555 } else
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
556 scr_LogPrint("Unrecognized parameter!");
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
557 }
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
558
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
559 void do_clear(char *arg) // Alias for "/buffer clear"
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
560 {
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
561 do_buffer("clear");
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
562 }
4ce9ff808baa [/trunk] Changeset 199 by mikael
mikael
parents: 166
diff changeset
563
191
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
564 void do_info(char *arg)
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
565 {
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
566 gpointer bud;
221
73f6ce668ba8 [/trunk] Changeset 233 by mikael
mikael
parents: 213
diff changeset
567 const char *jid, *name, *st_msg;
191
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
568 guint type;
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
569 enum imstatus status;
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
570 char *buffer;
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
571
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
572 if (!current_buddy) return;
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
573 bud = BUDDATA(current_buddy);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
574
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
575 jid = buddy_getjid(bud);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
576 name = buddy_getname(bud);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
577 type = buddy_gettype(bud);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
578 status = buddy_getstatus(bud);
221
73f6ce668ba8 [/trunk] Changeset 233 by mikael
mikael
parents: 213
diff changeset
579 st_msg = buddy_getstatusmsg(bud);
191
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
580
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
581 buffer = g_new(char, 128);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
582
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
583 if (jid) {
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
584 char *typestr = "unknown";
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
585
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
586 snprintf(buffer, 127, "jid: <%s>", jid);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
587 scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
588 if (name) {
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
589 snprintf(buffer, 127, "Name: %s", name);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
590 scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
591 }
221
73f6ce668ba8 [/trunk] Changeset 233 by mikael
mikael
parents: 213
diff changeset
592 if (st_msg) {
73f6ce668ba8 [/trunk] Changeset 233 by mikael
mikael
parents: 213
diff changeset
593 snprintf(buffer, 127, "Status message: %s", st_msg);
73f6ce668ba8 [/trunk] Changeset 233 by mikael
mikael
parents: 213
diff changeset
594 scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
73f6ce668ba8 [/trunk] Changeset 233 by mikael
mikael
parents: 213
diff changeset
595 }
191
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
596
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
597 if (type == ROSTER_TYPE_USER) typestr = "user";
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
598 else if (type == ROSTER_TYPE_AGENT) typestr = "agent";
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
599
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
600 snprintf(buffer, 127, "Type: %s", typestr);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
601 scr_WriteIncomingMessage(jid, buffer, 0, HBB_PREFIX_INFO);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
602 } else {
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
603 if (name) scr_LogPrint("Name: %s", name);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
604 scr_LogPrint("Type: %s",
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
605 ((type == ROSTER_TYPE_GROUP) ? "group" : "unknown"));
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
606 }
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
607
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
608 g_free(buffer);
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
609 }
24e6bcb589b0 [/trunk] Changeset 203 by mikael
mikael
parents: 187
diff changeset
610
208
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
611 void do_rename(char *arg)
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
612 {
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
613 gpointer bud;
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
614 const char *jid, *group;
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
615 guint type;
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
616 char *newname, *p;
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
617
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
618 if (!arg || (*arg == 0)) {
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
619 scr_LogPrint("Missing parameter");
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
620 return;
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
621 }
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
622
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
623 if (!current_buddy) return;
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
624 bud = BUDDATA(current_buddy);
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
625
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
626 jid = buddy_getjid(bud);
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
627 group = buddy_getgroupname(bud);
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
628 type = buddy_gettype(bud);
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
629
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
630 if (type & ROSTER_TYPE_GROUP) {
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
631 scr_LogPrint("You can't rename groups");
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
632 return;
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
633 }
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
634
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
635 newname = g_strdup(arg);
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
636 // Remove trailing space
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
637 for (p = newname; *p; p++) ;
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
638 while (p > newname && *p == ' ') *p = 0;
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
639
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
640 buddy_setname(bud, newname);
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
641 jb_updatebuddy(jid, newname, group);
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
642
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
643 g_free(newname);
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
644 update_roster = TRUE;
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
645 }
8b08f34922c5 [/trunk] Changeset 220 by mikael
mikael
parents: 206
diff changeset
646
210
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
647 void do_move(char *arg)
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
648 {
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
649 gpointer bud;
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
650 const char *jid, *name;
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
651 guint type;
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
652 char *newgroupname, *p;
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
653
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
654 if (!current_buddy) return;
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
655 bud = BUDDATA(current_buddy);
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
656
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
657 jid = buddy_getjid(bud);
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
658 name = buddy_getname(bud);
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
659 type = buddy_gettype(bud);
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
660
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
661 if (type & ROSTER_TYPE_GROUP) {
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
662 scr_LogPrint("You can't move groups!");
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
663 return;
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
664 }
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
665
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
666 newgroupname = g_strdup(arg);
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
667 // Remove trailing space
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
668 for (p = newgroupname; *p; p++) ;
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
669 while (p > newgroupname && *p == ' ') *p = 0;
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
670
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
671 // Call to buddy_setgroup() should be at the end, as current implementation
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
672 // clones the buddy and deletes the old one (and thus, jid and name are
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
673 // freed)
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
674 jb_updatebuddy(jid, name, newgroupname);
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
675 buddy_setgroup(bud, newgroupname);
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
676
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
677 g_free(newgroupname);
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
678 update_roster = TRUE;
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
679 }
f64818ba3503 [/trunk] Changeset 222 by mikael
mikael
parents: 208
diff changeset
680
283
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
681 void do_set(char *arg)
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
682 {
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
683 guint assign;
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
684 const gchar *option, *value;
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
685
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
686 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
687 if (!option) {
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
688 scr_LogPrint("Huh?");
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
689 return;
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
690 }
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
691 if (!assign) {
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
692 // This is a query
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
693 value = settings_opt_get(option);
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
694 if (value) {
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
695 scr_LogPrint("%s = [%s]", option, value);
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
696 } else
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
697 scr_LogPrint("Option %s is not set", option);
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
698 return;
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
699 }
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
700 // Update the option
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
701 // 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
702 // (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
703 // (hide_offline_buddies for ex.)
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
704 if (!value) {
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
705 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
706 } else {
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
707 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
708 }
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
709 }
00b2377539ac Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents: 277
diff changeset
710
285
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
711 void do_alias(char *arg)
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
712 {
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
713 guint assign;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
714 const gchar *alias, *value;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
715
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
716 assign = parse_assigment(arg, &alias, &value);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
717 if (!alias) {
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
718 scr_LogPrint("Huh?");
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
719 return;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
720 }
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
721 if (!assign) {
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
722 // This is a query
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
723 value = settings_get(SETTINGS_TYPE_ALIAS, alias);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
724 if (value) {
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
725 scr_LogPrint("%s = %s", alias, value);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
726 } else
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
727 scr_LogPrint("Alias '%s' does not exist", alias);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
728 return;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
729 }
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
730 // Check the alias does not conflict with a registered command
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
731 if (cmd_get(alias)) {
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
732 scr_LogPrint("'%s' is a reserved word!", alias);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
733 return;
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
734 }
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
735 // Update the alias
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
736 if (!value) {
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
737 if (settings_get(SETTINGS_TYPE_ALIAS, alias)) {
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
738 settings_del(SETTINGS_TYPE_ALIAS, alias);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
739 // Remove alias from the completion list
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
740 compl_del_category_word(COMPL_CMD, alias);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
741 }
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
742 } else {
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
743 // Add alias to the completion list, if not already in
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
744 if (!settings_get(SETTINGS_TYPE_ALIAS, alias))
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
745 compl_add_category_word(COMPL_CMD, alias);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
746 settings_set(SETTINGS_TYPE_ALIAS, alias, value);
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
747 }
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
748 }
edc263a5d350 Add /alias command
Mikael Berthe <mikael@lilotux.net>
parents: 283
diff changeset
749
288
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
750 void do_bind(char *arg)
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
751 {
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
752 guint assign;
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
753 const gchar *keycode, *value;
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
754
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
755 assign = parse_assigment(arg, &keycode, &value);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
756 if (!keycode) {
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
757 scr_LogPrint("Huh?");
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
758 return;
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
759 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
760 if (!assign) {
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
761 // This is a query
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
762 value = settings_get(SETTINGS_TYPE_BINDING, keycode);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
763 if (value) {
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
764 scr_LogPrint("Key %s is bound to: %s", keycode, value);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
765 } else
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
766 scr_LogPrint("Key %s is not bound", keycode);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
767 return;
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
768 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
769 // Update the key binding
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
770 if (!value)
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
771 settings_del(SETTINGS_TYPE_BINDING, keycode);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
772 else
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
773 settings_set(SETTINGS_TYPE_BINDING, keycode, value);
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
774 }
1eea0fa0955e Add /bind command
Mikael Berthe <mikael@lilotux.net>
parents: 285
diff changeset
775
298
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
776 void do_connect(char *arg)
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
777 {
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
778 mcabber_connect();
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
779 }
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
780
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
781 void do_disconnect(char *arg)
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
782 {
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
783 jb_disconnect();
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
784 }
35cda94e570d Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents: 290
diff changeset
785