author | Mikael Berthe <mikael@lilotux.net> |
Sat, 02 Dec 2006 11:13:40 +0100 | |
changeset 1065 | 230dca34dbea |
parent 1064 | 516b5f7d1023 |
child 1066 | 6de60e142372 |
permissions | -rw-r--r-- |
47 | 1 |
/* |
699 | 2 |
* commands.c -- user commands handling |
393 | 3 |
* |
699 | 4 |
* Copyright (C) 2005, 2006 Mikael Berthe <bmikael@lists.lilotux.net> |
47 | 5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
|
7 |
* it under the terms of the GNU General Public License as published by |
|
8 |
* the Free Software Foundation; either version 2 of the License, or (at |
|
9 |
* your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but |
|
12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
* General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
19 |
* USA |
|
20 |
*/ |
|
21 |
||
95 | 22 |
#include <string.h> |
23 |
||
47 | 24 |
#include "commands.h" |
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
25 |
#include "help.h" |
47 | 26 |
#include "jabglue.h" |
81 | 27 |
#include "roster.h" |
47 | 28 |
#include "screen.h" |
95 | 29 |
#include "compl.h" |
113 | 30 |
#include "hooks.h" |
191 | 31 |
#include "hbuf.h" |
47 | 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" |
748 | 34 |
#include "events.h" |
47 | 35 |
|
967 | 36 |
#define IMSTATUS_AWAY "away" |
37 |
#define IMSTATUS_ONLINE "online" |
|
38 |
#define IMSTATUS_OFFLINE "offline" |
|
39 |
#define IMSTATUS_FREE4CHAT "free" |
|
40 |
#define IMSTATUS_INVISIBLE "invisible" |
|
41 |
#define IMSTATUS_AVAILABLE "avail" |
|
42 |
#define IMSTATUS_NOTAVAILABLE "notavail" |
|
43 |
#define IMSTATUS_DONOTDISTURB "dnd" |
|
44 |
||
104 | 45 |
// Commands callbacks |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
46 |
static void do_roster(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
47 |
static void do_status(char *arg); |
444 | 48 |
static void do_status_to(char *arg); |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
49 |
static void do_add(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
50 |
static void do_del(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
51 |
static void do_group(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
52 |
static void do_say(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
53 |
static void do_msay(char *arg); |
480 | 54 |
static void do_say_to(char *arg); |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
55 |
static void do_buffer(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
56 |
static void do_clear(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
57 |
static void do_info(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
58 |
static void do_rename(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
59 |
static void do_move(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
60 |
static void do_set(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
61 |
static void do_alias(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
62 |
static void do_bind(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
63 |
static void do_connect(char *arg); |
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
64 |
static void do_disconnect(char *arg); |
436 | 65 |
static void do_rawxml(char *arg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
66 |
static void do_room(char *arg); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
67 |
static void do_authorization(char *arg); |
622 | 68 |
static void do_version(char *arg); |
693 | 69 |
static void do_request(char *arg); |
748 | 70 |
static void do_event(char *arg); |
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
71 |
static void do_help(char *arg); |
47 | 72 |
|
104 | 73 |
// Global variable for the commands list |
95 | 74 |
static GSList *Commands; |
75 |
||
104 | 76 |
|
95 | 77 |
// cmd_add() |
78 |
// Adds a command to the commands list and to the CMD completion list |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
79 |
static void cmd_add(const char *name, const char *help, |
1059 | 80 |
guint flags_row1, guint flags_row2, void (*f)(char*)) |
95 | 81 |
{ |
82 |
cmd *n_cmd = g_new0(cmd, 1); |
|
83 |
strncpy(n_cmd->name, name, 32-1); |
|
84 |
n_cmd->help = help; |
|
85 |
n_cmd->completion_flags[0] = flags_row1; |
|
86 |
n_cmd->completion_flags[1] = flags_row2; |
|
87 |
n_cmd->func = f; |
|
102 | 88 |
Commands = g_slist_append(Commands, n_cmd); |
95 | 89 |
// Add to completion CMD category |
90 |
compl_add_category_word(COMPL_CMD, name); |
|
91 |
} |
|
92 |
||
93 |
// cmd_init() |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
94 |
// Commands table initialization |
95 | 95 |
void cmd_init(void) |
96 |
{ |
|
124 | 97 |
cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add); |
285 | 98 |
cmd_add("alias", "Add an alias", 0, 0, &do_alias); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
99 |
cmd_add("authorization", "Manage subscription authorizations", |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
100 |
COMPL_AUTH, COMPL_JID, &do_authorization); |
288 | 101 |
cmd_add("bind", "Add an key binding", 0, 0, &do_bind); |
187 | 102 |
cmd_add("buffer", "Manipulate current buddy's buffer (chat window)", |
103 |
COMPL_BUFFER, 0, &do_buffer); |
|
108 | 104 |
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
|
105 |
cmd_add("connect", "Connect to the server", 0, 0, &do_connect); |
205 | 106 |
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
|
107 |
cmd_add("disconnect", "Disconnect from server", 0, 0, &do_disconnect); |
757
ae23c8826efb
Improve completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
755
diff
changeset
|
108 |
cmd_add("event", "Process an event", COMPL_EVENTSID, COMPL_EVENTS, &do_event); |
128 | 109 |
cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group); |
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
110 |
cmd_add("help", "Display some help", COMPL_CMD, 0, &do_help); |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
111 |
cmd_add("info", "Show basic info on current buddy", 0, 0, &do_info); |
225 | 112 |
cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, |
113 |
0, &do_move); |
|
238 | 114 |
cmd_add("msay", "Send a multi-lines message to the selected buddy", |
115 |
COMPL_MULTILINE, 0, &do_msay); |
|
95 | 116 |
cmd_add("quit", "Exit the software", 0, 0, NULL); |
436 | 117 |
cmd_add("rawxml", "Send a raw XML string", 0, 0, &do_rawxml); |
208 | 118 |
cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename); |
902
2016f52a167f
Sort commands (for the completion system)
Mikael Berthe <mikael@lilotux.net>
parents:
900
diff
changeset
|
119 |
cmd_add("request", "Send a Jabber IQ request", COMPL_REQUEST, COMPL_JID, |
2016f52a167f
Sort commands (for the completion system)
Mikael Berthe <mikael@lilotux.net>
parents:
900
diff
changeset
|
120 |
&do_request); |
2016f52a167f
Sort commands (for the completion system)
Mikael Berthe <mikael@lilotux.net>
parents:
900
diff
changeset
|
121 |
cmd_add("room", "MUC actions command", COMPL_ROOM, 0, &do_room); |
128 | 122 |
cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, |
123 |
&do_roster); |
|
132 | 124 |
cmd_add("say", "Say something to the selected buddy", 0, 0, &do_say); |
488
9e8519078e00
Enable jid completion for /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
486
diff
changeset
|
125 |
cmd_add("say_to", "Say something to a specific buddy", COMPL_JID, 0, |
9e8519078e00
Enable jid completion for /say_to
Mikael Berthe <mikael@lilotux.net>
parents:
486
diff
changeset
|
126 |
&do_say_to); |
95 | 127 |
//cmd_add("search"); |
310 | 128 |
cmd_add("set", "Set/query an option value", 0, 0, &do_set); |
116 | 129 |
cmd_add("status", "Show or set your status", COMPL_STATUS, 0, &do_status); |
444 | 130 |
cmd_add("status_to", "Show or set your status for one recipient", |
131 |
COMPL_JID, COMPL_STATUS, &do_status_to); |
|
622 | 132 |
cmd_add("version", "Show mcabber version", 0, 0, &do_version); |
95 | 133 |
|
134 |
// Status category |
|
135 |
compl_add_category_word(COMPL_STATUS, "online"); |
|
136 |
compl_add_category_word(COMPL_STATUS, "avail"); |
|
137 |
compl_add_category_word(COMPL_STATUS, "invisible"); |
|
138 |
compl_add_category_word(COMPL_STATUS, "free"); |
|
139 |
compl_add_category_word(COMPL_STATUS, "dnd"); |
|
140 |
compl_add_category_word(COMPL_STATUS, "notavail"); |
|
141 |
compl_add_category_word(COMPL_STATUS, "away"); |
|
103 | 142 |
|
143 |
// Roster category |
|
144 |
compl_add_category_word(COMPL_ROSTER, "bottom"); |
|
265 | 145 |
compl_add_category_word(COMPL_ROSTER, "top"); |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
146 |
compl_add_category_word(COMPL_ROSTER, "up"); |
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
147 |
compl_add_category_word(COMPL_ROSTER, "down"); |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
148 |
compl_add_category_word(COMPL_ROSTER, "hide"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
149 |
compl_add_category_word(COMPL_ROSTER, "show"); |
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
150 |
compl_add_category_word(COMPL_ROSTER, "toggle"); |
103 | 151 |
compl_add_category_word(COMPL_ROSTER, "hide_offline"); |
152 |
compl_add_category_word(COMPL_ROSTER, "show_offline"); |
|
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
153 |
compl_add_category_word(COMPL_ROSTER, "toggle_offline"); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
154 |
compl_add_category_word(COMPL_ROSTER, "item_lock"); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
155 |
compl_add_category_word(COMPL_ROSTER, "item_unlock"); |
330 | 156 |
compl_add_category_word(COMPL_ROSTER, "alternate"); |
265 | 157 |
compl_add_category_word(COMPL_ROSTER, "search"); |
236 | 158 |
compl_add_category_word(COMPL_ROSTER, "unread_first"); |
159 |
compl_add_category_word(COMPL_ROSTER, "unread_next"); |
|
1016 | 160 |
compl_add_category_word(COMPL_ROSTER, "note"); |
127 | 161 |
|
187 | 162 |
// Roster category |
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
163 |
compl_add_category_word(COMPL_BUFFER, "clear"); |
187 | 164 |
compl_add_category_word(COMPL_BUFFER, "bottom"); |
165 |
compl_add_category_word(COMPL_BUFFER, "top"); |
|
508
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
166 |
compl_add_category_word(COMPL_BUFFER, "up"); |
5a2132ba2220
Add "/buffer up" and "/buffer down"
Mikael Berthe <mikael@lilotux.net>
parents:
506
diff
changeset
|
167 |
compl_add_category_word(COMPL_BUFFER, "down"); |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
168 |
compl_add_category_word(COMPL_BUFFER, "search_backward"); |
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
169 |
compl_add_category_word(COMPL_BUFFER, "search_forward"); |
464 | 170 |
compl_add_category_word(COMPL_BUFFER, "date"); |
462 | 171 |
compl_add_category_word(COMPL_BUFFER, "%"); |
866 | 172 |
compl_add_category_word(COMPL_BUFFER, "purge"); |
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
173 |
compl_add_category_word(COMPL_BUFFER, "scroll_lock"); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
174 |
compl_add_category_word(COMPL_BUFFER, "scroll_unlock"); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
175 |
compl_add_category_word(COMPL_BUFFER, "scroll_toggle"); |
187 | 176 |
|
127 | 177 |
// Group category |
240 | 178 |
compl_add_category_word(COMPL_GROUP, "fold"); |
179 |
compl_add_category_word(COMPL_GROUP, "unfold"); |
|
130 | 180 |
compl_add_category_word(COMPL_GROUP, "toggle"); |
238 | 181 |
|
182 |
// Multi-line (msay) category |
|
183 |
compl_add_category_word(COMPL_MULTILINE, "abort"); |
|
184 |
compl_add_category_word(COMPL_MULTILINE, "begin"); |
|
185 |
compl_add_category_word(COMPL_MULTILINE, "send"); |
|
636 | 186 |
compl_add_category_word(COMPL_MULTILINE, "send_to"); |
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
187 |
compl_add_category_word(COMPL_MULTILINE, "toggle"); |
838
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
188 |
compl_add_category_word(COMPL_MULTILINE, "toggle_verbatim"); |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
189 |
compl_add_category_word(COMPL_MULTILINE, "verbatim"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
190 |
|
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
191 |
// Room category |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
192 |
compl_add_category_word(COMPL_ROOM, "affil"); |
571 | 193 |
compl_add_category_word(COMPL_ROOM, "ban"); |
1009 | 194 |
compl_add_category_word(COMPL_ROOM, "bookmark"); |
599 | 195 |
compl_add_category_word(COMPL_ROOM, "destroy"); |
486 | 196 |
compl_add_category_word(COMPL_ROOM, "invite"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
197 |
compl_add_category_word(COMPL_ROOM, "join"); |
568 | 198 |
compl_add_category_word(COMPL_ROOM, "kick"); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
199 |
compl_add_category_word(COMPL_ROOM, "leave"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
200 |
compl_add_category_word(COMPL_ROOM, "names"); |
470 | 201 |
compl_add_category_word(COMPL_ROOM, "nick"); |
490 | 202 |
compl_add_category_word(COMPL_ROOM, "privmsg"); |
448
39a28cb59af3
Add "/room remove", to remove an old chatroom from the roster
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
203 |
compl_add_category_word(COMPL_ROOM, "remove"); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
204 |
compl_add_category_word(COMPL_ROOM, "role"); |
475
fa49ac0bb8f3
Add "/room topic", and display topic changes
Mikael Berthe <mikael@lilotux.net>
parents:
472
diff
changeset
|
205 |
compl_add_category_word(COMPL_ROOM, "topic"); |
449 | 206 |
compl_add_category_word(COMPL_ROOM, "unlock"); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
207 |
compl_add_category_word(COMPL_ROOM, "whois"); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
208 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
209 |
// Authorization category |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
210 |
compl_add_category_word(COMPL_AUTH, "allow"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
211 |
compl_add_category_word(COMPL_AUTH, "cancel"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
212 |
compl_add_category_word(COMPL_AUTH, "request"); |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
213 |
compl_add_category_word(COMPL_AUTH, "request_unsubscribe"); |
693 | 214 |
|
215 |
// Request (query) category |
|
1015 | 216 |
compl_add_category_word(COMPL_REQUEST, "last"); |
693 | 217 |
compl_add_category_word(COMPL_REQUEST, "time"); |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
218 |
compl_add_category_word(COMPL_REQUEST, "vcard"); |
693 | 219 |
compl_add_category_word(COMPL_REQUEST, "version"); |
750
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
220 |
|
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
221 |
// Events category |
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
222 |
compl_add_category_word(COMPL_EVENTS, "accept"); |
755 | 223 |
compl_add_category_word(COMPL_EVENTS, "ignore"); |
750
938a8791658c
Add partial completion for the "/event" command
Mikael Berthe <mikael@lilotux.net>
parents:
748
diff
changeset
|
224 |
compl_add_category_word(COMPL_EVENTS, "reject"); |
95 | 225 |
} |
94 | 226 |
|
285 | 227 |
// expandalias(line) |
228 |
// If there is one, expand the alias in line and returns a new allocated line |
|
229 |
// If no alias is found, returns line |
|
230 |
// Note : if the returned pointer is different from line, the caller should |
|
231 |
// g_free() the pointer after use |
|
232 |
char *expandalias(char *line) |
|
233 |
{ |
|
234 |
const char *p1, *p2; |
|
235 |
char *word; |
|
236 |
const gchar *value; |
|
237 |
char *newline = line; |
|
238 |
||
967 | 239 |
// Ignore leading COMMAND_CHAR |
240 |
for (p1 = line ; *p1 == COMMAND_CHAR ; p1++) |
|
285 | 241 |
; |
242 |
// Locate the end of the word |
|
243 |
for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) |
|
244 |
; |
|
245 |
// Extract the word |
|
246 |
word = g_strndup(p1, p2-p1); |
|
247 |
||
248 |
// Look for an alias in the list |
|
249 |
value = settings_get(SETTINGS_TYPE_ALIAS, (const char*)word); |
|
250 |
if (value) { |
|
251 |
// There is an alias to expand |
|
252 |
newline = g_new(char, strlen(value)+strlen(p2)+2); |
|
967 | 253 |
*newline = COMMAND_CHAR; |
285 | 254 |
strcpy(newline+1, value); |
255 |
strcat(newline, p2); |
|
256 |
} |
|
257 |
g_free(word); |
|
258 |
||
259 |
return newline; |
|
260 |
} |
|
261 |
||
102 | 262 |
// cmd_get |
263 |
// Finds command in the command list structure. |
|
264 |
// Returns a pointer to the cmd entry, or NULL if command not found. |
|
238 | 265 |
cmd *cmd_get(const char *command) |
102 | 266 |
{ |
238 | 267 |
const char *p1, *p2; |
102 | 268 |
char *com; |
269 |
GSList *sl_com; |
|
285 | 270 |
|
967 | 271 |
// Ignore leading COMMAND_CHAR |
272 |
for (p1 = command ; *p1 == COMMAND_CHAR ; p1++) |
|
102 | 273 |
; |
274 |
// Locate the end of the command |
|
275 |
for (p2 = p1 ; *p2 && (*p2 != ' ') ; p2++) |
|
276 |
; |
|
277 |
// Copy the clean command |
|
278 |
com = g_strndup(p1, p2-p1); |
|
279 |
||
280 |
// Look for command in the list |
|
281 |
for (sl_com=Commands; sl_com; sl_com = g_slist_next(sl_com)) { |
|
282 |
if (!strcasecmp(com, ((cmd*)sl_com->data)->name)) |
|
283 |
break; |
|
284 |
} |
|
285 |
g_free(com); |
|
286 |
||
287 |
if (sl_com) // Command has been found. |
|
288 |
return (cmd*)sl_com->data; |
|
289 |
return NULL; |
|
290 |
} |
|
291 |
||
47 | 292 |
// send_message(msg) |
293 |
// Write the message in the buddy's window and send the message on |
|
294 |
// the network. |
|
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
295 |
static void send_message(const char *msg, const char *subj) |
47 | 296 |
{ |
1058 | 297 |
const char *bjid; |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
298 |
guint crypted; |
393 | 299 |
|
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
300 |
if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
301 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
302 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
303 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
304 |
|
81 | 305 |
if (!current_buddy) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
306 |
scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected."); |
81 | 307 |
return; |
308 |
} |
|
309 |
||
1058 | 310 |
bjid = CURRENT_JID; |
311 |
if (!bjid) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
312 |
scr_LogPrint(LPRINT_NORMAL, "No buddy is currently selected."); |
81 | 313 |
return; |
314 |
} |
|
47 | 315 |
|
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
316 |
// Network part |
1058 | 317 |
jb_send_msg(bjid, msg, buddy_gettype(BUDDATA(current_buddy)), subj, NULL, |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
318 |
&crypted); |
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
319 |
|
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
320 |
// Hook |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
321 |
if (buddy_gettype(BUDDATA(current_buddy)) != ROSTER_TYPE_ROOM) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
322 |
// local part (UI, logging, etc.) |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
323 |
gchar *hmsg; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
324 |
if (subj) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
325 |
hmsg = g_strdup_printf("[%s]\n%s", subj, msg); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
326 |
else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
327 |
hmsg = (char*)msg; |
1058 | 328 |
hk_message_out(bjid, NULL, 0, hmsg, crypted); |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
329 |
if (hmsg != msg) g_free(hmsg); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
330 |
} |
47 | 331 |
} |
332 |
||
288 | 333 |
// process_command(line) |
334 |
// Process a command line. |
|
335 |
// Return 255 if this is the /quit command, and 0 for the other commands. |
|
336 |
int process_command(char *line) |
|
47 | 337 |
{ |
101 | 338 |
char *p; |
285 | 339 |
char *xpline; |
104 | 340 |
cmd *curcmd; |
341 |
||
285 | 342 |
// We do alias expansion here |
288 | 343 |
if (scr_get_multimode() != 2) |
344 |
xpline = expandalias(line); |
|
345 |
else |
|
346 |
xpline = line; // No expansion in verbatim multi-line mode |
|
285 | 347 |
|
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
348 |
// We want to have a copy |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
349 |
if (xpline == line) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
350 |
xpline = g_strdup(line); |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
351 |
|
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
352 |
// Remove trailing spaces: |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
353 |
for (p=xpline ; *p ; p++) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
354 |
; |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
355 |
for (p-- ; p>xpline && (*p == ' ') ; p--) |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
356 |
*p = 0; |
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
357 |
|
101 | 358 |
// Command "quit"? |
967 | 359 |
if ((scr_get_multimode() != 2) |
360 |
&& (!strncasecmp(xpline, mkcmdstr("quit"), strlen(mkcmdstr("quit"))))) |
|
285 | 361 |
if (!xpline[5] || xpline[5] == ' ') |
116 | 362 |
return 255; |
104 | 363 |
|
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
364 |
// If verbatim multi-line mode, we check if another /msay command is typed |
967 | 365 |
if ((scr_get_multimode() == 2) |
366 |
&& (strncasecmp(xpline, mkcmdstr("msay "), strlen(mkcmdstr("msay "))))) { |
|
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
367 |
// It isn't an /msay command |
285 | 368 |
scr_append_multiline(xpline); |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
369 |
g_free(xpline); |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
370 |
return 0; |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
371 |
} |
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
372 |
|
47 | 373 |
// Commands handling |
285 | 374 |
curcmd = cmd_get(xpline); |
47 | 375 |
|
104 | 376 |
if (!curcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
377 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized command. " |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
378 |
"Please see the manual for a list of known commands."); |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
379 |
g_free(xpline); |
104 | 380 |
return 0; |
381 |
} |
|
382 |
if (!curcmd->func) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
383 |
scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
384 |
"This functionality is not yet implemented, sorry."); |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
385 |
g_free(xpline); |
104 | 386 |
return 0; |
387 |
} |
|
388 |
// Lets go to the command parameters |
|
285 | 389 |
for (p = xpline+1; *p && (*p != ' ') ; p++) |
104 | 390 |
; |
391 |
// Skip spaces |
|
285 | 392 |
while (*p && (*p == ' ')) |
393 |
p++; |
|
104 | 394 |
// Call command-specific function |
285 | 395 |
(*curcmd->func)(p); |
954
27a7b2f986f5
Fix a freeze with UTF-8 locales
Mikael Berthe <mikael@lilotux.net>
parents:
902
diff
changeset
|
396 |
g_free(xpline); |
47 | 397 |
return 0; |
398 |
} |
|
399 |
||
288 | 400 |
// process_line(line) |
401 |
// Process a command/message line. |
|
402 |
// If this isn't a command, this is a message and it is sent to the |
|
403 |
// currently selected buddy. |
|
404 |
// Return 255 if the line is the /quit command, or 0. |
|
405 |
int process_line(char *line) |
|
406 |
{ |
|
407 |
if (!*line) { // User only pressed enter |
|
408 |
if (scr_get_multimode()) { |
|
409 |
scr_append_multiline(""); |
|
410 |
return 0; |
|
411 |
} |
|
412 |
if (current_buddy) { |
|
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
413 |
// Enter chat mode |
288 | 414 |
scr_set_chatmode(TRUE); |
415 |
scr_ShowBuddyWindow(); |
|
416 |
} |
|
417 |
return 0; |
|
418 |
} |
|
419 |
||
967 | 420 |
if (*line != COMMAND_CHAR) { |
288 | 421 |
// This isn't a command |
422 |
if (scr_get_multimode()) |
|
423 |
scr_append_multiline(line); |
|
424 |
else |
|
425 |
do_say(line); |
|
426 |
return 0; |
|
427 |
} |
|
428 |
||
429 |
/* It is (probably) a command -- except for verbatim multi-line mode */ |
|
430 |
return process_command(line); |
|
431 |
} |
|
432 |
||
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
433 |
// Helper routine for buffer item_{lock,unlock} |
1058 | 434 |
static void roster_buddylock(char *bjid, bool lock) |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
435 |
{ |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
436 |
gpointer bud = NULL; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
437 |
bool may_need_refresh = FALSE; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
438 |
|
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
439 |
// Allow special jid "" or "." (current buddy) |
1058 | 440 |
if (bjid && (!*bjid || !strcmp(bjid, "."))) |
441 |
bjid = NULL; |
|
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
442 |
|
1058 | 443 |
if (bjid) { |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
444 |
// The JID has been specified. Quick check... |
1058 | 445 |
if (check_jid_syntax(bjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
446 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
447 |
"<%s> is not a valid Jabber ID.", bjid); |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
448 |
} else { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
449 |
// Find the buddy |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
450 |
GSList *roster_elt; |
1058 | 451 |
roster_elt = roster_find(bjid, jidsearch, |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
452 |
ROSTER_TYPE_USER|ROSTER_TYPE_ROOM); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
453 |
if (roster_elt) |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
454 |
bud = roster_elt->data; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
455 |
else |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
456 |
scr_LogPrint(LPRINT_NORMAL, "This jid isn't in the roster."); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
457 |
may_need_refresh = TRUE; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
458 |
} |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
459 |
} else { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
460 |
// Use the current buddy |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
461 |
if (current_buddy) |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
462 |
bud = BUDDATA(current_buddy); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
463 |
} |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
464 |
|
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
465 |
// Update the ROSTER_FLAG_USRLOCK flag |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
466 |
if (bud) { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
467 |
buddy_setflags(bud, ROSTER_FLAG_USRLOCK, lock); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
468 |
if (may_need_refresh) |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
469 |
buddylist_build(); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
470 |
update_roster = TRUE; |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
471 |
} |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
472 |
} |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
473 |
|
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
474 |
// display_and_free_note(note, winId) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
475 |
// Display the note information in the winId buffer, and free note |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
476 |
// (winId is a bare jid or NULL for the status window, in which case we |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
477 |
// display the note jid too) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
478 |
static void display_and_free_note(struct annotation *note, const char *winId) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
479 |
{ |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
480 |
gchar tbuf[128]; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
481 |
GString *sbuf; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
482 |
guint msg_flag = HBB_PREFIX_INFO; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
483 |
/* We use the flag prefix_info for the first line, and prefix_none |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
484 |
for the other lines, for better readability */ |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
485 |
|
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
486 |
if (!note) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
487 |
return; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
488 |
|
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
489 |
sbuf = g_string_new(""); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
490 |
|
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
491 |
if (!winId) { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
492 |
// We're writing to the status window, so let's show the jid too. |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
493 |
g_string_printf(sbuf, "Annotation on <%s>", note->jid); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
494 |
scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
495 |
msg_flag = HBB_PREFIX_NONE; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
496 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
497 |
|
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
498 |
// If we have the creation date, display it |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
499 |
if (note->cdate) { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
500 |
strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
501 |
localtime(¬e->cdate)); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
502 |
g_string_printf(sbuf, "Note created %s", tbuf); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
503 |
scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
504 |
msg_flag = HBB_PREFIX_NONE; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
505 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
506 |
// If we have the modification date, display it |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
507 |
// unless it's the same as the creation date |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
508 |
if (note->mdate && note->mdate != note->cdate) { |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
509 |
strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
510 |
localtime(¬e->mdate)); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
511 |
g_string_printf(sbuf, "Note modified %s", tbuf); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
512 |
scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
513 |
msg_flag = HBB_PREFIX_NONE; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
514 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
515 |
// Note text |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
516 |
g_string_printf(sbuf, "Note: %s", note->text); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
517 |
scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
518 |
|
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
519 |
g_string_free(sbuf, TRUE); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
520 |
g_free(note->text); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
521 |
g_free(note->jid); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
522 |
g_free(note); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
523 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
524 |
|
1059 | 525 |
static void display_all_annotations(void) |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
526 |
{ |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
527 |
GSList *notes; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
528 |
notes = jb_get_all_storage_rosternotes(); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
529 |
// Call display_and_free_note() for each note, |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
530 |
// with winId = NULL (special window) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
531 |
g_slist_foreach(notes, (GFunc)&display_and_free_note, NULL); |
1038
f9e8fd9cb58b
Set new_msg flag when listing annotations in the status buffer in non-chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
1037
diff
changeset
|
532 |
if (notes) { |
f9e8fd9cb58b
Set new_msg flag when listing annotations in the status buffer in non-chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
1037
diff
changeset
|
533 |
scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
f9e8fd9cb58b
Set new_msg flag when listing annotations in the status buffer in non-chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
1037
diff
changeset
|
534 |
update_roster = TRUE; |
f9e8fd9cb58b
Set new_msg flag when listing annotations in the status buffer in non-chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
1037
diff
changeset
|
535 |
} |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
536 |
g_slist_free(notes); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
537 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
538 |
|
1016 | 539 |
static void roster_note(char *arg) |
540 |
{ |
|
1058 | 541 |
const char *bjid; |
1016 | 542 |
guint type; |
543 |
||
544 |
if (!current_buddy) |
|
545 |
return; |
|
546 |
||
1058 | 547 |
bjid = buddy_getjid(BUDDATA(current_buddy)); |
1016 | 548 |
type = buddy_gettype(BUDDATA(current_buddy)); |
549 |
||
1058 | 550 |
if (!bjid && type == ROSTER_TYPE_SPECIAL && !arg) { |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
551 |
// We're in the status window (the only special buffer currently) |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
552 |
// Let's display all server notes |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
553 |
display_all_annotations(); |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
554 |
return; |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
555 |
} |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
556 |
|
1058 | 557 |
if (!bjid || (type != ROSTER_TYPE_USER && |
1016 | 558 |
type != ROSTER_TYPE_ROOM && |
559 |
type != ROSTER_TYPE_AGENT)) { |
|
560 |
scr_LogPrint(LPRINT_NORMAL, "This item can't have a note."); |
|
561 |
return; |
|
562 |
} |
|
563 |
||
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
564 |
if (arg && *arg) { // Set a note |
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
565 |
gchar *msg, *notetxt; |
1016 | 566 |
msg = to_utf8(arg); |
567 |
if (!strcmp(msg, "-")) |
|
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
568 |
notetxt = NULL; // delete note |
1016 | 569 |
else |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
570 |
notetxt = msg; |
1058 | 571 |
jb_set_storage_rosternotes(bjid, notetxt); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
572 |
g_free(msg); |
1016 | 573 |
} else { // Display a note |
1058 | 574 |
struct annotation *note = jb_get_storage_rosternotes(bjid, FALSE); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
575 |
if (note) { |
1058 | 576 |
display_and_free_note(note, bjid); |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
577 |
} else { |
1058 | 578 |
scr_WriteIncomingMessage(bjid, "This item doesn't have a note.", 0, |
1019
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
579 |
HBB_PREFIX_INFO); |
9d5f6e0ea7b3
XEP-0145: display note dates
Mikael Berthe <mikael@lilotux.net>
parents:
1016
diff
changeset
|
580 |
} |
1016 | 581 |
} |
582 |
} |
|
583 |
||
104 | 584 |
/* Commands callback functions */ |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
585 |
/* All these do_*() functions will be called with a "arg" parameter */ |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
586 |
/* (with arg not null) */ |
104 | 587 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
588 |
static void do_roster(char *arg) |
104 | 589 |
{ |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
590 |
char **paramlst; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
591 |
char *subcmd; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
592 |
|
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
593 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
594 |
subcmd = *paramlst; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
595 |
arg = *(paramlst+1); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
596 |
|
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
597 |
if (!subcmd || !*subcmd) { |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
598 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
599 |
free_arg_lst(paramlst); |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
600 |
return; |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
601 |
} |
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
602 |
|
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
603 |
if (!strcasecmp(subcmd, "top")) { |
104 | 604 |
scr_RosterTop(); |
128 | 605 |
update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
606 |
} else if (!strcasecmp(subcmd, "bottom")) { |
104 | 607 |
scr_RosterBottom(); |
128 | 608 |
update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
609 |
} else if (!strcasecmp(subcmd, "hide")) { |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
610 |
scr_RosterVisibility(0); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
611 |
} else if (!strcasecmp(subcmd, "show")) { |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
612 |
scr_RosterVisibility(1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
613 |
} else if (!strcasecmp(subcmd, "toggle")) { |
707
b26a0bde4cdb
Add /roster hide|show|toggle
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
614 |
scr_RosterVisibility(-1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
615 |
} else if (!strcasecmp(subcmd, "hide_offline")) { |
120 | 616 |
buddylist_set_hide_offline_buddies(TRUE); |
104 | 617 |
if (current_buddy) |
618 |
buddylist_build(); |
|
128 | 619 |
update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
620 |
} else if (!strcasecmp(subcmd, "show_offline")) { |
120 | 621 |
buddylist_set_hide_offline_buddies(FALSE); |
124 | 622 |
buddylist_build(); |
128 | 623 |
update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
624 |
} else if (!strcasecmp(subcmd, "toggle_offline")) { |
290
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
625 |
buddylist_set_hide_offline_buddies(-1); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
626 |
buddylist_build(); |
f63839a4cb35
Add /roster toggle_offline
Mikael Berthe <mikael@lilotux.net>
parents:
288
diff
changeset
|
627 |
update_roster = TRUE; |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
628 |
} else if (!strcasecmp(subcmd, "item_lock")) { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
629 |
roster_buddylock(arg, TRUE); |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
630 |
} else if (!strcasecmp(subcmd, "item_unlock")) { |
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
968
diff
changeset
|
631 |
roster_buddylock(arg, FALSE); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
632 |
} else if (!strcasecmp(subcmd, "unread_first")) { |
236 | 633 |
scr_RosterUnreadMessage(0); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
634 |
} else if (!strcasecmp(subcmd, "unread_next")) { |
236 | 635 |
scr_RosterUnreadMessage(1); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
636 |
} else if (!strcasecmp(subcmd, "alternate")) { |
330 | 637 |
scr_RosterJumpAlternate(); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
638 |
} else if (!strncasecmp(subcmd, "search", 6)) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
639 |
strip_arg_special_chars(arg); |
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
640 |
if (!arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
641 |
scr_LogPrint(LPRINT_NORMAL, "What name or JID are you looking for?"); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
642 |
free_arg_lst(paramlst); |
265 | 643 |
return; |
644 |
} |
|
978 | 645 |
scr_RosterSearch(arg); |
265 | 646 |
update_roster = TRUE; |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
647 |
} else if (!strcasecmp(subcmd, "up")) { |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
648 |
scr_RosterUp(); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
649 |
} else if (!strcasecmp(subcmd, "down")) { |
377
00809e3e327e
Add "/roster up" and "/roster down"
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
650 |
scr_RosterDown(); |
1016 | 651 |
} else if (!strcasecmp(subcmd, "note")) { |
652 |
roster_note(arg); |
|
104 | 653 |
} else |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
654 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
968
d3bfa9e9d88c
Use split_arg() in do_roster()
Mikael Berthe <mikael@lilotux.net>
parents:
967
diff
changeset
|
655 |
free_arg_lst(paramlst); |
104 | 656 |
} |
108 | 657 |
|
444 | 658 |
// setstatus(recipient, arg) |
659 |
// Set your Jabber status. |
|
660 |
// - if recipient is not NULL, the status is sent to this contact only |
|
661 |
// - arg must be "status message" (message is optional) |
|
662 |
static void setstatus(const char *recipient, const char *arg) |
|
116 | 663 |
{ |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
664 |
char **paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
665 |
char *status; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
666 |
char *msg; |
116 | 667 |
enum imstatus st; |
668 |
||
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
669 |
if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
670 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
671 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
672 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
673 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
674 |
paramlst = split_arg(arg, 2, 0); // status, message |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
675 |
status = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
676 |
msg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
677 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
678 |
if (!status) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
679 |
free_arg_lst(paramlst); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
680 |
return; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
681 |
} |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
682 |
|
967 | 683 |
if (!strcasecmp(status, IMSTATUS_OFFLINE)) st = offline; |
684 |
else if (!strcasecmp(status, IMSTATUS_ONLINE)) st = available; |
|
685 |
else if (!strcasecmp(status, IMSTATUS_AVAILABLE)) st = available; |
|
686 |
else if (!strcasecmp(status, IMSTATUS_AWAY)) st = away; |
|
687 |
else if (!strcasecmp(status, IMSTATUS_INVISIBLE)) st = invisible; |
|
688 |
else if (!strcasecmp(status, IMSTATUS_DONOTDISTURB)) st = dontdisturb; |
|
689 |
else if (!strcasecmp(status, IMSTATUS_NOTAVAILABLE)) st = notavail; |
|
690 |
else if (!strcasecmp(status, IMSTATUS_FREE4CHAT)) st = freeforchat; |
|
116 | 691 |
else { |
444 | 692 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized status!"); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
693 |
free_arg_lst(paramlst); |
116 | 694 |
return; |
695 |
} |
|
696 |
||
677
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
697 |
// Use provided message |
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
698 |
if (msg && !*msg) { |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
699 |
msg = NULL; |
677
633a0522bd37
Using "/status invisible -" did not clear the status message
Mikael Berthe <mikael@lilotux.net>
parents:
659
diff
changeset
|
700 |
} |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
701 |
|
528
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
702 |
// If a recipient is specified, let's don't use default status messages |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
703 |
if (recipient && !msg) |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
704 |
msg = ""; |
2f714bd701a1
Do not use default status messages with /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
519
diff
changeset
|
705 |
|
1050
ea71d31a2607
PGP: Do not sign presence messages to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
1043
diff
changeset
|
706 |
jb_setstatus(st, recipient, msg, FALSE); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
707 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
708 |
free_arg_lst(paramlst); |
444 | 709 |
} |
710 |
||
711 |
static void do_status(char *arg) |
|
712 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
713 |
if (!*arg) { |
519
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
714 |
const char *sm = jb_getstatusmsg(); |
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
715 |
scr_LogPrint(LPRINT_NORMAL, "Your status is: [%c] %s", |
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
716 |
imstatus2char[jb_getstatus()], |
5c338d31de56
Show current global status message in "/status"
Mikael Berthe <mikael@lilotux.net>
parents:
508
diff
changeset
|
717 |
(sm ? sm : "")); |
444 | 718 |
return; |
719 |
} |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
720 |
arg = to_utf8(arg); |
444 | 721 |
setstatus(NULL, arg); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
722 |
g_free(arg); |
444 | 723 |
} |
724 |
||
725 |
static void do_status_to(char *arg) |
|
726 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
727 |
char **paramlst; |
1058 | 728 |
char *fjid, *st, *msg; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
729 |
char *jid_utf8 = NULL; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
730 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
731 |
paramlst = split_arg(arg, 3, 1); // jid, status, [message] |
1058 | 732 |
fjid = *paramlst; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
733 |
st = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
734 |
msg = *(paramlst+2); |
444 | 735 |
|
1058 | 736 |
if (!fjid || !st) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
737 |
scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
738 |
"Please specify both a Jabber ID and a status."); |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
739 |
free_arg_lst(paramlst); |
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
740 |
return; |
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
741 |
} |
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
742 |
|
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
743 |
// Allow things like /status_to "" away |
1058 | 744 |
if (!*fjid || !strcmp(fjid, ".")) |
745 |
fjid = NULL; |
|
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
746 |
|
1058 | 747 |
if (fjid) { |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
748 |
// The JID has been specified. Quick check... |
1058 | 749 |
if (check_jid_syntax(fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
750 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
751 |
"<%s> is not a valid Jabber ID.", fjid); |
1058 | 752 |
fjid = NULL; |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
753 |
} else { |
696
ee06382dfb22
/status_to: Do not convert resource name to lower case
Mikael Berthe <mikael@lilotux.net>
parents:
694
diff
changeset
|
754 |
// Convert jid to lowercase |
1058 | 755 |
char *p = fjid; |
977
5b01de4ac5e1
Cosmetic changes
Alexis Hildebrandt <afh [at] 2drop [dot] net>
parents:
974
diff
changeset
|
756 |
for ( ; *p && *p != JID_RESOURCE_SEPARATOR; p++) |
696
ee06382dfb22
/status_to: Do not convert resource name to lower case
Mikael Berthe <mikael@lilotux.net>
parents:
694
diff
changeset
|
757 |
*p = tolower(*p); |
1058 | 758 |
fjid = jid_utf8 = to_utf8(fjid); |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
759 |
} |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
760 |
} else { |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
761 |
// Add the current buddy |
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
762 |
if (current_buddy) |
1058 | 763 |
fjid = (char*)buddy_getjid(BUDDATA(current_buddy)); |
764 |
if (!fjid) |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
765 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
640
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
766 |
} |
1cd7f8e3895b
"/status_to" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
638
diff
changeset
|
767 |
|
1058 | 768 |
if (fjid) { |
769 |
char *cmdline; |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
770 |
if (!msg) |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
771 |
msg = ""; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
772 |
msg = to_utf8(msg); |
1058 | 773 |
cmdline = g_strdup_printf("%s %s", st, msg); |
774 |
scr_LogPrint(LPRINT_LOGNORM, "Sending to <%s> /status %s", fjid, cmdline); |
|
775 |
setstatus(fjid, cmdline); |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
776 |
g_free(msg); |
1058 | 777 |
g_free(cmdline); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
778 |
g_free(jid_utf8); |
444 | 779 |
} |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
780 |
free_arg_lst(paramlst); |
116 | 781 |
} |
782 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
783 |
static void do_add(char *arg) |
124 | 784 |
{ |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
785 |
char **paramlst; |
244 | 786 |
char *id, *nick; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
787 |
char *jid_utf8 = NULL; |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
788 |
|
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
789 |
if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
790 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
791 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
792 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
793 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
794 |
paramlst = split_arg(arg, 2, 0); // jid, [nickname] |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
795 |
id = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
796 |
nick = *(paramlst+1); |
244 | 797 |
|
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
798 |
if (!id) |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
799 |
nick = NULL; // Allow things like: /add "" nick |
641
62679532ea55
Allow special jid "." in commands /add and /status_to
Mikael Berthe <mikael@lilotux.net>
parents:
640
diff
changeset
|
800 |
else if (!*id || !strcmp(id, ".")) |
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
801 |
id = NULL; |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
802 |
|
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
803 |
if (id) { |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
804 |
// The JID has been specified. Quick check... |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
805 |
if (check_jid_syntax(id)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
806 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
807 |
"<%s> is not a valid Jabber ID.", id); |
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
808 |
id = NULL; |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
809 |
} else { |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
810 |
mc_strtolower(id); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
811 |
// Actually an UTF-8 id isn't needed because only the bare jid will |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
812 |
// be used. |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
813 |
id = jid_utf8 = to_utf8(id); |
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
814 |
} |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
815 |
} else { |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
816 |
// Add the current buddy |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
817 |
if (current_buddy) |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
818 |
id = (char*)buddy_getjid(BUDDATA(current_buddy)); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
819 |
if (!id) |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
820 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
821 |
} |
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
822 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
823 |
if (nick) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
824 |
nick = to_utf8(nick); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
825 |
|
638
f6946251acdf
"/add" can be used with no jid (it will use the current buddy's jid)
Mikael Berthe <mikael@lilotux.net>
parents:
636
diff
changeset
|
826 |
if (id) { |
452 | 827 |
// 2nd parameter = optional nickname |
828 |
jb_addbuddy(id, nick, NULL); |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
829 |
scr_LogPrint(LPRINT_LOGNORM, "Sent presence notification request to <%s>.", |
452 | 830 |
id); |
831 |
} |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
832 |
|
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
833 |
g_free(jid_utf8); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
834 |
g_free(nick); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
835 |
free_arg_lst(paramlst); |
124 | 836 |
} |
128 | 837 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
838 |
static void do_del(char *arg) |
206 | 839 |
{ |
1058 | 840 |
const char *bjid; |
206 | 841 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
842 |
if (*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
843 |
scr_LogPrint(LPRINT_NORMAL, "This action does not require a parameter; " |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
844 |
"the currently-selected buddy will be deleted."); |
206 | 845 |
return; |
846 |
} |
|
847 |
||
1058 | 848 |
if (!current_buddy) |
849 |
return; |
|
850 |
bjid = buddy_getjid(BUDDATA(current_buddy)); |
|
851 |
if (!bjid) |
|
852 |
return; |
|
206 | 853 |
|
540
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
854 |
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_ROOM) { |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
855 |
// This is a chatroom |
652
b243d3b3ff1b
We do not need buddy_isresource() anymore
Mikael Berthe <mikael@lilotux.net>
parents:
650
diff
changeset
|
856 |
if (buddy_getinsideroom(BUDDATA(current_buddy))) { |
540
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
857 |
scr_LogPrint(LPRINT_NORMAL, "You haven't left this room!"); |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
858 |
return; |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
859 |
} |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
860 |
} |
887c1bd37617
Prevent deletion from rooms we haven't left
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
861 |
|
1058 | 862 |
scr_LogPrint(LPRINT_LOGNORM, "Removing <%s>...", bjid); |
863 |
jb_delbuddy(bjid); |
|
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
861
diff
changeset
|
864 |
scr_UpdateBuddyWindow(); |
206 | 865 |
} |
866 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
867 |
static void do_group(char *arg) |
128 | 868 |
{ |
869 |
gpointer group; |
|
958
30b799632653
Cosmetics (change a variable name)
Mikael Berthe <mikael@lilotux.net>
parents:
957
diff
changeset
|
870 |
guint leave_buddywindow; |
128 | 871 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
872 |
if (!*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
873 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
128 | 874 |
return; |
875 |
} |
|
876 |
||
1058 | 877 |
if (!current_buddy) |
878 |
return; |
|
128 | 879 |
|
166 | 880 |
group = buddy_getgroup(BUDDATA(current_buddy)); |
1058 | 881 |
if (!group) |
882 |
return; |
|
853
bdd526ec62bc
Fix segfault when using /group with the [status] entry
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
883 |
|
212 | 884 |
// We'll have to redraw the chat window if we're not currently on the group |
885 |
// entry itself, because it means we'll have to leave the current buddy |
|
886 |
// chat window. |
|
958
30b799632653
Cosmetics (change a variable name)
Mikael Berthe <mikael@lilotux.net>
parents:
957
diff
changeset
|
887 |
leave_buddywindow = (group != BUDDATA(current_buddy)); |
166 | 888 |
|
128 | 889 |
if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
890 |
scr_LogPrint(LPRINT_NORMAL, "You need to select a group."); |
128 | 891 |
return; |
892 |
} |
|
166 | 893 |
|
894 |
if (!strcasecmp(arg, "expand") || !strcasecmp(arg, "unfold")) { |
|
128 | 895 |
buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE); |
166 | 896 |
} else if (!strcasecmp(arg, "shrink") || !strcasecmp(arg, "fold")) { |
128 | 897 |
buddy_setflags(group, ROSTER_FLAG_HIDE, TRUE); |
130 | 898 |
} else if (!strcasecmp(arg, "toggle")) { |
899 |
buddy_setflags(group, ROSTER_FLAG_HIDE, |
|
900 |
!(buddy_getflags(group) & ROSTER_FLAG_HIDE)); |
|
128 | 901 |
} else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
902 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
128 | 903 |
return; |
904 |
} |
|
905 |
||
906 |
buddylist_build(); |
|
907 |
update_roster = TRUE; |
|
958
30b799632653
Cosmetics (change a variable name)
Mikael Berthe <mikael@lilotux.net>
parents:
957
diff
changeset
|
908 |
if (leave_buddywindow) scr_ShowBuddyWindow(); |
128 | 909 |
} |
910 |
||
1058 | 911 |
static int send_message_to(const char *fjid, const char *msg, const char *subj) |
636 | 912 |
{ |
913 |
char *bare_jid, *rp; |
|
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
914 |
char *hmsg; |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
915 |
guint crypted; |
636 | 916 |
|
1058 | 917 |
if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
918 |
scr_LogPrint(LPRINT_NORMAL, "You must specify a Jabber ID."); |
636 | 919 |
return 1; |
920 |
} |
|
921 |
if (!msg || !*msg) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
922 |
scr_LogPrint(LPRINT_NORMAL, "You must specify a message."); |
636 | 923 |
return 1; |
924 |
} |
|
1058 | 925 |
if (check_jid_syntax((char*)fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
926 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
927 |
"<%s> is not a valid Jabber ID.", fjid); |
636 | 928 |
return 1; |
929 |
} |
|
930 |
||
931 |
// We must use the bare jid in hk_message_out() |
|
1058 | 932 |
rp = strchr(fjid, JID_RESOURCE_SEPARATOR); |
933 |
if (rp) bare_jid = g_strndup(fjid, rp - fjid); |
|
934 |
else bare_jid = (char*)fjid; |
|
636 | 935 |
|
936 |
// Jump to window, create one if needed |
|
937 |
scr_RosterJumpJid(bare_jid); |
|
938 |
||
939 |
// Check if we're sending a message to a conference room |
|
940 |
// If not, we must make sure rp is NULL, for hk_message_out() |
|
941 |
if (rp) { |
|
942 |
if (roster_find(bare_jid, jidsearch, ROSTER_TYPE_ROOM)) rp++; |
|
943 |
else rp = NULL; |
|
944 |
} |
|
945 |
||
946 |
// local part (UI, logging, etc.) |
|
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
947 |
if (subj) |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
948 |
hmsg = g_strdup_printf("[%s]\n%s", subj, msg); |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
949 |
else |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
950 |
hmsg = (char*)msg; |
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
951 |
|
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
952 |
// Network part |
1058 | 953 |
jb_send_msg(fjid, msg, ROSTER_TYPE_USER, subj, NULL, &crypted); |
636 | 954 |
|
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
955 |
// Hook |
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
956 |
hk_message_out(bare_jid, rp, 0, hmsg, crypted); |
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
957 |
if (hmsg != msg) g_free(hmsg); |
636 | 958 |
|
959 |
if (rp) g_free(bare_jid); |
|
960 |
return 0; |
|
961 |
} |
|
962 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
963 |
static void do_say(char *arg) |
132 | 964 |
{ |
164 | 965 |
gpointer bud; |
132 | 966 |
|
967 |
scr_set_chatmode(TRUE); |
|
164 | 968 |
|
969 |
if (!current_buddy) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
970 |
scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
971 |
"Whom are you talking to? Please select a buddy."); |
164 | 972 |
return; |
132 | 973 |
} |
164 | 974 |
|
975 |
bud = BUDDATA(current_buddy); |
|
631
423c24e5875a
Allow sending a message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
626
diff
changeset
|
976 |
if (!(buddy_gettype(bud) & |
423c24e5875a
Allow sending a message to an agent
Mikael Berthe <mikael@lilotux.net>
parents:
626
diff
changeset
|
977 |
(ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM))) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
978 |
scr_LogPrint(LPRINT_NORMAL, "This is not a user."); |
164 | 979 |
return; |
980 |
} |
|
981 |
||
982 |
buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
983 |
arg = to_utf8(arg); |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
984 |
send_message(arg, NULL); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
985 |
g_free(arg); |
132 | 986 |
} |
987 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
988 |
static void do_msay(char *arg) |
238 | 989 |
{ |
636 | 990 |
/* Parameters: begin verbatim abort send send_to */ |
991 |
char **paramlst; |
|
992 |
char *subcmd; |
|
993 |
||
994 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
|
995 |
subcmd = *paramlst; |
|
996 |
arg = *(paramlst+1); |
|
238 | 997 |
|
636 | 998 |
if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
999 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
636 | 1000 |
scr_LogPrint(LPRINT_NORMAL, "Please read the manual before using " |
1001 |
"the /msay command."); |
|
967 | 1002 |
scr_LogPrint(LPRINT_NORMAL, "(Use \"%s begin\" to enter " |
1003 |
"multi-line mode...)", mkcmdstr("msay")); |
|
636 | 1004 |
free_arg_lst(paramlst); |
1005 |
return; |
|
1006 |
} |
|
1007 |
||
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1008 |
if (!strcasecmp(subcmd, "toggle")) { |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1009 |
if (scr_get_multimode()) |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1010 |
subcmd = "send"; |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1011 |
else |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1012 |
subcmd = "begin"; |
838
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1013 |
} else if (!strcasecmp(subcmd, "toggle_verbatim")) { |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1014 |
if (scr_get_multimode()) |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1015 |
subcmd = "send"; |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1016 |
else |
ea1204c8a30b
Add "/msay toggle_verbatim"
Mikael Berthe <mikael@lilotux.net>
parents:
837
diff
changeset
|
1017 |
subcmd = "verbatim"; |
796
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1018 |
} |
79c8823da808
Add "/msay toggle" command
Mikael Berthe <mikael@lilotux.net>
parents:
791
diff
changeset
|
1019 |
|
636 | 1020 |
if (!strcasecmp(subcmd, "abort")) { |
315
65aa05520556
First Ctrl-C now also leaves multi-line message mode
Mikael Berthe <mikael@lilotux.net>
parents:
310
diff
changeset
|
1021 |
if (scr_get_multimode()) |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1022 |
scr_LogPrint(LPRINT_NORMAL, "Leaving multi-line message mode."); |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1023 |
scr_set_multimode(FALSE, NULL); |
238 | 1024 |
return; |
636 | 1025 |
} else if ((!strcasecmp(subcmd, "begin")) || |
1026 |
(!strcasecmp(subcmd, "verbatim"))) { |
|
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1027 |
bool verbat; |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1028 |
gchar *subj_utf8 = to_utf8(arg); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1029 |
if (!strcasecmp(subcmd, "verbatim")) { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1030 |
scr_set_multimode(2, subj_utf8); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1031 |
verbat = TRUE; |
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1032 |
} else { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1033 |
scr_set_multimode(1, subj_utf8); |
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1034 |
verbat = FALSE; |
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1035 |
} |
260
33e1a05864a6
Add "verbatim multi-line" mode, with commands disabled
mikael@frmp8452
parents:
244
diff
changeset
|
1036 |
|
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1037 |
scr_LogPrint(LPRINT_NORMAL, "Entered %smulti-line message mode.", |
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1038 |
verbat ? "VERBATIM " : ""); |
967 | 1039 |
scr_LogPrint(LPRINT_NORMAL, "Select a buddy and use \"%s send\" " |
1040 |
"when your message is ready.", mkcmdstr("msay")); |
|
840
2903fd66c3ad
Be more verbose about verbatim mode
Mikael Berthe <mikael@lilotux.net>
parents:
838
diff
changeset
|
1041 |
if (verbat) |
967 | 1042 |
scr_LogPrint(LPRINT_NORMAL, "Use \"%s abort\" to abort this mode.", |
1043 |
mkcmdstr("msay")); |
|
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1044 |
g_free(subj_utf8); |
238 | 1045 |
return; |
636 | 1046 |
} else if (strcasecmp(subcmd, "send") && strcasecmp(subcmd, "send_to")) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1047 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
238 | 1048 |
return; |
1049 |
} |
|
1050 |
||
636 | 1051 |
/* send/send_to command */ |
238 | 1052 |
|
1053 |
if (!scr_get_multimode()) { |
|
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1054 |
scr_LogPrint(LPRINT_NORMAL, "No message to send. " |
967 | 1055 |
"Use \"%s begin\" first.", mkcmdstr("msay")); |
238 | 1056 |
return; |
1057 |
} |
|
1058 |
||
1059 |
scr_set_chatmode(TRUE); |
|
1060 |
||
636 | 1061 |
if (!strcasecmp(subcmd, "send_to")) { |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1062 |
int err = FALSE; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1063 |
gchar *msg_utf8; |
636 | 1064 |
// Let's send to the specified JID. We leave now if there |
1065 |
// has been an error (so we don't leave multi-line mode). |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1066 |
arg = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1067 |
msg_utf8 = to_utf8(scr_get_multiline()); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1068 |
if (msg_utf8) { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1069 |
err = send_message_to(arg, msg_utf8, scr_get_multimode_subj()); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1070 |
g_free(msg_utf8); |
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1071 |
} |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1072 |
g_free(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1073 |
if (err) |
636 | 1074 |
return; |
1075 |
} else { // Send to currently selected buddy |
|
1076 |
gpointer bud; |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1077 |
gchar *msg_utf8; |
238 | 1078 |
|
636 | 1079 |
if (!current_buddy) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1080 |
scr_LogPrint(LPRINT_NORMAL, "Whom are you talking to?"); |
636 | 1081 |
return; |
1082 |
} |
|
1083 |
||
1084 |
bud = BUDDATA(current_buddy); |
|
1085 |
if (!(buddy_gettype(bud) & (ROSTER_TYPE_USER|ROSTER_TYPE_ROOM))) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1086 |
scr_LogPrint(LPRINT_NORMAL, "This is not a user."); |
636 | 1087 |
return; |
1088 |
} |
|
1089 |
||
1090 |
buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1091 |
msg_utf8 = to_utf8(scr_get_multiline()); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1092 |
if (msg_utf8) { |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1093 |
send_message(msg_utf8, scr_get_multimode_subj()); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1094 |
g_free(msg_utf8); |
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1095 |
} |
238 | 1096 |
} |
807
f6cda389db48
Allow messages with a subject (/msay)
Mikael Berthe <mikael@lilotux.net>
parents:
797
diff
changeset
|
1097 |
scr_set_multimode(FALSE, NULL); |
797
5eb701c1bc1f
Multi-line mode: Do not send empty messages
Mikael Berthe <mikael@lilotux.net>
parents:
796
diff
changeset
|
1098 |
scr_LogPrint(LPRINT_NORMAL, "You have left multi-line message mode."); |
238 | 1099 |
} |
1100 |
||
480 | 1101 |
static void do_say_to(char *arg) |
1102 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1103 |
char **paramlst; |
1058 | 1104 |
char *fjid, *msg; |
480 | 1105 |
|
1106 |
if (!jb_getonline()) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1107 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
480 | 1108 |
return; |
1109 |
} |
|
1110 |
||
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1111 |
paramlst = split_arg(arg, 2, 1); // jid, message |
1058 | 1112 |
fjid = *paramlst; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1113 |
msg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1114 |
|
1058 | 1115 |
if (!fjid || !strcmp(fjid, ".")) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1116 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1117 |
free_arg_lst(paramlst); |
480 | 1118 |
return; |
1119 |
} |
|
1120 |
||
1058 | 1121 |
fjid = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1122 |
msg = to_utf8(msg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1123 |
|
1058 | 1124 |
send_message_to(fjid, msg, NULL); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1125 |
|
1058 | 1126 |
g_free(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1127 |
g_free(msg); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1128 |
free_arg_lst(paramlst); |
480 | 1129 |
} |
1130 |
||
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1131 |
// buffer_updown(updown, nblines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1132 |
// updown: -1=up, +1=down |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1133 |
inline static void buffer_updown(int updown, char *nlines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1134 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1135 |
int nblines; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1136 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1137 |
if (!nlines || !*nlines) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1138 |
nblines = 0; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1139 |
else |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1140 |
nblines = atoi(nlines); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1141 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1142 |
if (nblines >= 0) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1143 |
scr_BufferScrollUpDown(updown, nblines); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1144 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1145 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1146 |
static void buffer_search(int direction, char *arg) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1147 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1148 |
if (!arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1149 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1150 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1151 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1152 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1153 |
scr_BufferSearch(direction, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1154 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1155 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1156 |
static void buffer_date(char *date) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1157 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1158 |
time_t t; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1159 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1160 |
if (!date || !*date) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1161 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1162 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1163 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1164 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1165 |
strip_arg_special_chars(date); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1166 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1167 |
t = from_iso8601(date, 0); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1168 |
if (t) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1169 |
scr_BufferDate(t); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1170 |
else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1171 |
scr_LogPrint(LPRINT_NORMAL, "The date you specified is " |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1172 |
"not correctly formatted or invalid."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1173 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1174 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1175 |
static void buffer_percent(char *arg1, char *arg2) |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1176 |
{ |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1177 |
// Basically, user has typed "%arg1 arg2" |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1178 |
// "%50" -> arg1 = 50, arg2 null pointer |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1179 |
// "% 50" -> arg1 = \0, arg2 = 50 |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1180 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1181 |
if (!*arg1 && (!arg2 || !*arg2)) { // No value |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1182 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1183 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1184 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1185 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1186 |
if (*arg1 && arg2 && *arg2) { // Two values |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1187 |
scr_LogPrint(LPRINT_NORMAL, "Wrong parameters."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1188 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1189 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1190 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1191 |
scr_BufferPercent(atoi((*arg1 ? arg1 : arg2))); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1192 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1193 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1194 |
static void do_buffer(char *arg) |
187 | 1195 |
{ |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1196 |
char **paramlst; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1197 |
char *subcmd; |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1198 |
|
1058 | 1199 |
if (!current_buddy) |
1200 |
return; |
|
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1201 |
|
446 | 1202 |
if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_GROUP) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1203 |
scr_LogPrint(LPRINT_NORMAL, "Groups have no buffer."); |
446 | 1204 |
return; |
1205 |
} |
|
1206 |
||
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1207 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1208 |
subcmd = *paramlst; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1209 |
arg = *(paramlst+1); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1210 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1211 |
if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1212 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1213 |
free_arg_lst(paramlst); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1214 |
return; |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1215 |
} |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1216 |
|
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1217 |
if (!strcasecmp(subcmd, "top")) { |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
336
diff
changeset
|
1218 |
scr_BufferTopBottom(-1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1219 |
} else if (!strcasecmp(subcmd, "bottom")) { |
361
51ff319947c3
Code cleanup/optimization
Mikael Berthe <mikael@lilotux.net>
parents:
336
diff
changeset
|
1220 |
scr_BufferTopBottom(1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1221 |
} else if (!strcasecmp(subcmd, "clear")) { |
369
499170ed71c9
Rename some buffer commands, for homogeneity
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
1222 |
scr_BufferClear(); |
866 | 1223 |
} else if (!strcasecmp(subcmd, "purge")) { |
1224 |
scr_BufferPurge(); |
|
873
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1225 |
} else if (!strcasecmp(subcmd, "scroll_lock")) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1226 |
scr_BufferScrollLock(1); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1227 |
} else if (!strcasecmp(subcmd, "scroll_unlock")) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1228 |
scr_BufferScrollLock(0); |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1229 |
} else if (!strcasecmp(subcmd, "scroll_toggle")) { |
ee39f6d94d43
Add /buffer {scroll_lock|scroll_unlock|toggle_scroll}
Mikael Berthe <mikael@lilotux.net>
parents:
868
diff
changeset
|
1230 |
scr_BufferScrollLock(-1); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1231 |
} else if (!strcasecmp(subcmd, "up")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1232 |
buffer_updown(-1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1233 |
} else if (!strcasecmp(subcmd, "down")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1234 |
buffer_updown(1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1235 |
} else if (!strcasecmp(subcmd, "search_backward")) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
1236 |
strip_arg_special_chars(arg); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1237 |
buffer_search(-1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1238 |
} else if (!strcasecmp(subcmd, "search_forward")) { |
979
ea939ff047d8
Improve /buffer search_*
Mikael Berthe <mikael@lilotux.net>
parents:
978
diff
changeset
|
1239 |
strip_arg_special_chars(arg); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1240 |
buffer_search(1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1241 |
} else if (!strcasecmp(subcmd, "date")) { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1242 |
buffer_date(arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1243 |
} else if (*subcmd == '%') { |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1244 |
buffer_percent(subcmd+1, arg); |
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1245 |
} else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1246 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1247 |
} |
370
dd9e2eb52916
Add /buffer search_{backward,forward}
Mikael Berthe <mikael@lilotux.net>
parents:
369
diff
changeset
|
1248 |
|
558
db019a5f874f
Split do_buffer() and use split_arg()
Mikael Berthe <mikael@lilotux.net>
parents:
557
diff
changeset
|
1249 |
free_arg_lst(paramlst); |
187 | 1250 |
} |
1251 |
||
967 | 1252 |
static void do_clear(char *arg) // Alias for "buffer clear" |
187 | 1253 |
{ |
1254 |
do_buffer("clear"); |
|
1255 |
} |
|
1256 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1257 |
static void do_info(char *arg) |
191 | 1258 |
{ |
1259 |
gpointer bud; |
|
1058 | 1260 |
const char *bjid, *name; |
191 | 1261 |
guint type; |
1262 |
char *buffer; |
|
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1263 |
enum subscr esub; |
191 | 1264 |
|
1058 | 1265 |
if (!current_buddy) |
1266 |
return; |
|
191 | 1267 |
bud = BUDDATA(current_buddy); |
1268 |
||
1058 | 1269 |
bjid = buddy_getjid(bud); |
191 | 1270 |
name = buddy_getname(bud); |
1271 |
type = buddy_gettype(bud); |
|
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1272 |
esub = buddy_getsubscription(bud); |
191 | 1273 |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1274 |
buffer = g_new(char, 4096); |
191 | 1275 |
|
1058 | 1276 |
if (bjid) { |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1277 |
GSList *resources; |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1278 |
char *bstr = "unknown"; |
191 | 1279 |
|
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1280 |
// Enter chat mode |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1281 |
scr_set_chatmode(TRUE); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1282 |
scr_ShowBuddyWindow(); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1283 |
|
1058 | 1284 |
snprintf(buffer, 4095, "jid: <%s>", bjid); |
1285 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
|
191 | 1286 |
if (name) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1287 |
snprintf(buffer, 4095, "Name: %s", name); |
1058 | 1288 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
191 | 1289 |
} |
1290 |
||
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1291 |
if (type == ROSTER_TYPE_USER) bstr = "user"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1292 |
else if (type == ROSTER_TYPE_ROOM) bstr = "chatroom"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1293 |
else if (type == ROSTER_TYPE_AGENT) bstr = "agent"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1294 |
snprintf(buffer, 127, "Type: %s", bstr); |
1058 | 1295 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
604
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1296 |
|
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1297 |
if (esub == sub_both) bstr = "both"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1298 |
else if (esub & sub_from) bstr = "from"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1299 |
else if (esub & sub_to) bstr = "to"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1300 |
else bstr = "none"; |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1301 |
snprintf(buffer, 64, "Subscription: %s", bstr); |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1302 |
if (esub & sub_pending) |
2e8342168ebc
"/info" shows buddy subscription
Mikael Berthe <mikael@lilotux.net>
parents:
600
diff
changeset
|
1303 |
strcat(buffer, " (pending)"); |
1058 | 1304 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1305 |
|
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1306 |
resources = buddy_getresources(bud); |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1307 |
if (!resources && type == ROSTER_TYPE_USER) { |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1308 |
// No resource; display last status message, if any. |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1309 |
const char *rst_msg = buddy_getstatusmsg(bud, ""); |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1310 |
if (rst_msg) { |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1311 |
snprintf(buffer, 4095, "Last status message: %s", rst_msg); |
1058 | 1312 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1313 |
} |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
841
diff
changeset
|
1314 |
} |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1315 |
for ( ; resources ; resources = g_slist_next(resources) ) { |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1316 |
gchar rprio; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1317 |
enum imstatus rstatus; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1318 |
const char *rst_msg; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1319 |
time_t rst_time; |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1320 |
struct pgp_data *rpgp; |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1321 |
|
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1322 |
rprio = buddy_getresourceprio(bud, resources->data); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1323 |
rstatus = buddy_getstatus(bud, resources->data); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1324 |
rst_msg = buddy_getstatusmsg(bud, resources->data); |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1325 |
rst_time = buddy_getstatustime(bud, resources->data); |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1326 |
rpgp = buddy_resource_pgp(bud, resources->data); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1327 |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1328 |
snprintf(buffer, 4095, "Resource: [%c] (%d) %s", imstatus2char[rstatus], |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1329 |
rprio, (char*)resources->data); |
1058 | 1330 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1331 |
if (rst_msg) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1332 |
snprintf(buffer, 4095, "Status message: %s", rst_msg); |
1058 | 1333 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1334 |
} |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1335 |
if (rst_time) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1336 |
char tbuf[128]; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1337 |
|
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1338 |
strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time)); |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1339 |
snprintf(buffer, 127, "Status timestamp: %s", tbuf); |
1058 | 1340 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
1341 |
} |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1342 |
#ifdef HAVE_GPGME |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1343 |
if (rpgp && rpgp->sign_keyid) { |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1344 |
snprintf(buffer, 4095, "PGP key id: %s", rpgp->sign_keyid); |
1058 | 1345 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1346 |
if (rpgp->last_sigsum) { |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1347 |
gpgme_sigsum_t ss = rpgp->last_sigsum; |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1348 |
snprintf(buffer, 4095, "Last PGP signature: %s", |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1349 |
(ss & GPGME_SIGSUM_GREEN ? "good": |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1350 |
(ss & GPGME_SIGSUM_RED ? "bad" : "unknown"))); |
1058 | 1351 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1352 |
} |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1353 |
} |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1038
diff
changeset
|
1354 |
#endif |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1355 |
} |
1065
230dca34dbea
Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents:
1064
diff
changeset
|
1356 |
#ifdef HAVE_GPGME |
230dca34dbea
Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents:
1064
diff
changeset
|
1357 |
if (settings_pgp_getdisabled(bjid)) |
230dca34dbea
Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents:
1064
diff
changeset
|
1358 |
scr_WriteIncomingMessage(bjid, "PGP is disabled", 0, HBB_PREFIX_NONE); |
230dca34dbea
Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents:
1064
diff
changeset
|
1359 |
#endif |
191 | 1360 |
} else { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1361 |
if (name) scr_LogPrint(LPRINT_NORMAL, "Name: %s", name); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1362 |
scr_LogPrint(LPRINT_NORMAL, "Type: %s", |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1363 |
type == ROSTER_TYPE_GROUP ? "group" : |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1364 |
(type == ROSTER_TYPE_SPECIAL ? "special" : "unknown")); |
191 | 1365 |
} |
1366 |
g_free(buffer); |
|
1367 |
||
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1368 |
// Tell the user if this item has an annotation. |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1369 |
if (type == ROSTER_TYPE_USER || |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1370 |
type == ROSTER_TYPE_ROOM || |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1371 |
type == ROSTER_TYPE_AGENT) { |
1058 | 1372 |
struct annotation *note = jb_get_storage_rosternotes(bjid, TRUE); |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1373 |
if (note) { |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1374 |
// We do not display the note, we just tell the user. |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1375 |
g_free(note->text); |
1022
4c8d7b558e83
Annotations listing (/roster note in the status buffer)
Mikael Berthe <mikael@lilotux.net>
parents:
1021
diff
changeset
|
1376 |
g_free(note->jid); |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1377 |
g_free(note); |
1058 | 1378 |
scr_WriteIncomingMessage(bjid, "(This item has an annotation)", 0, |
1020
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1379 |
HBB_PREFIX_INFO); |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1380 |
} |
60c94b697f61
Show in /info when the contact has an annotation
Mikael Berthe <mikael@lilotux.net>
parents:
1019
diff
changeset
|
1381 |
} |
191 | 1382 |
} |
1383 |
||
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1384 |
// room_names() is a variation of do_info(), for chatrooms only |
552 | 1385 |
static void room_names(gpointer bud, char *arg) |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1386 |
{ |
1058 | 1387 |
const char *bjid; |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1388 |
char *buffer; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1389 |
GSList *resources; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1390 |
|
552 | 1391 |
if (*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1392 |
scr_LogPrint(LPRINT_NORMAL, "This action does not require a parameter."); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1393 |
return; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1394 |
} |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1395 |
|
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1396 |
// Enter chat mode |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1397 |
scr_set_chatmode(TRUE); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1398 |
scr_ShowBuddyWindow(); |
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
1399 |
|
1058 | 1400 |
bjid = buddy_getjid(bud); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1401 |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1402 |
buffer = g_new(char, 4096); |
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1403 |
strncpy(buffer, "Room members:", 127); |
1058 | 1404 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1405 |
|
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1406 |
resources = buddy_getresources(bud); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1407 |
for ( ; resources ; resources = g_slist_next(resources) ) { |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1408 |
enum imstatus rstatus; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1409 |
const char *rst_msg; |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1410 |
|
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1411 |
rstatus = buddy_getstatus(bud, resources->data); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1412 |
rst_msg = buddy_getstatusmsg(bud, resources->data); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1413 |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1414 |
snprintf(buffer, 4095, "[%c] %s", imstatus2char[rstatus], |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1415 |
(char*)resources->data); |
1058 | 1416 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1417 |
if (rst_msg) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
1418 |
snprintf(buffer, 4095, "Status message: %s", rst_msg); |
1058 | 1419 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
504
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1420 |
} |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1421 |
} |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1422 |
|
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1423 |
g_free(buffer); |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1424 |
} |
321ae11e7ddb
Prettier display for "/room names"
Mikael Berthe <mikael@lilotux.net>
parents:
490
diff
changeset
|
1425 |
|
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1426 |
static void move_group_member(gpointer bud, void *groupnamedata) |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1427 |
{ |
1058 | 1428 |
const char *bjid, *name, *groupname; |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1429 |
|
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1430 |
groupname = (char *)groupnamedata; |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1431 |
|
1058 | 1432 |
bjid = buddy_getjid(bud); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1433 |
name = buddy_getname(bud); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1434 |
|
1058 | 1435 |
jb_updatebuddy(bjid, name, *groupname ? groupname : NULL); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1436 |
} |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1437 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1438 |
static void do_rename(char *arg) |
208 | 1439 |
{ |
1440 |
gpointer bud; |
|
1058 | 1441 |
const char *bjid, *group; |
208 | 1442 |
guint type; |
1443 |
char *newname, *p; |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1444 |
char *name_utf8; |
208 | 1445 |
|
1058 | 1446 |
if (!current_buddy) |
1447 |
return; |
|
208 | 1448 |
bud = BUDDATA(current_buddy); |
1449 |
||
1058 | 1450 |
bjid = buddy_getjid(bud); |
208 | 1451 |
group = buddy_getgroupname(bud); |
1452 |
type = buddy_gettype(bud); |
|
1453 |
||
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1454 |
if (type & ROSTER_TYPE_SPECIAL) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1455 |
scr_LogPrint(LPRINT_NORMAL, "You can't rename this item."); |
208 | 1456 |
return; |
1457 |
} |
|
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1458 |
|
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1459 |
if (!*arg && !(type & ROSTER_TYPE_GROUP)) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1460 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a new name."); |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1461 |
return; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1462 |
} |
208 | 1463 |
|
1464 |
newname = g_strdup(arg); |
|
1465 |
// Remove trailing space |
|
1466 |
for (p = newname; *p; p++) ; |
|
1467 |
while (p > newname && *p == ' ') *p = 0; |
|
1468 |
||
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1469 |
strip_arg_special_chars(newname); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1470 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1471 |
name_utf8 = to_utf8(newname); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1472 |
|
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1473 |
if (type & ROSTER_TYPE_GROUP) { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1474 |
// Rename a whole group |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1475 |
foreach_group_member(bud, &move_group_member, name_utf8); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1476 |
// Let's jump to the previous buddy, because this group name should |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1477 |
// disappear when we receive the server answer. |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1478 |
scr_RosterUp(); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1479 |
} else { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1480 |
// Rename a single buddy |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1481 |
buddy_setname(bud, name_utf8); |
1058 | 1482 |
jb_updatebuddy(bjid, name_utf8, group); |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
873
diff
changeset
|
1483 |
} |
208 | 1484 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1485 |
g_free(name_utf8); |
208 | 1486 |
g_free(newname); |
1487 |
update_roster = TRUE; |
|
1488 |
} |
|
1489 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1490 |
static void do_move(char *arg) |
210 | 1491 |
{ |
1492 |
gpointer bud; |
|
1058 | 1493 |
const char *bjid, *name, *oldgroupname; |
210 | 1494 |
guint type; |
1495 |
char *newgroupname, *p; |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1496 |
char *group_utf8; |
210 | 1497 |
|
1058 | 1498 |
if (!current_buddy) |
1499 |
return; |
|
210 | 1500 |
bud = BUDDATA(current_buddy); |
1501 |
||
1058 | 1502 |
bjid = buddy_getjid(bud); |
210 | 1503 |
name = buddy_getname(bud); |
1504 |
type = buddy_gettype(bud); |
|
1505 |
||
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1506 |
oldgroupname = buddy_getgroupname(bud); |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1507 |
|
210 | 1508 |
if (type & ROSTER_TYPE_GROUP) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
371
diff
changeset
|
1509 |
scr_LogPrint(LPRINT_NORMAL, "You can't move groups!"); |
210 | 1510 |
return; |
1511 |
} |
|
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1512 |
if (type & ROSTER_TYPE_SPECIAL) { |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1513 |
scr_LogPrint(LPRINT_NORMAL, "You can't move this item."); |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1514 |
return; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
847
diff
changeset
|
1515 |
} |
210 | 1516 |
|
1517 |
newgroupname = g_strdup(arg); |
|
1518 |
// Remove trailing space |
|
1519 |
for (p = newgroupname; *p; p++) ; |
|
608
89f5672eb523
/move: really strip trailing space, and assign to no group if no group is specified
Mikael Berthe <mikael@lilotux.net>
parents:
604
diff
changeset
|
1520 |
while (p > newgroupname && *p == ' ') *p-- = 0; |
210 | 1521 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1522 |
strip_arg_special_chars(newgroupname); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1523 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1524 |
group_utf8 = to_utf8(newgroupname); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1525 |
if (strcmp(oldgroupname, group_utf8)) { |
1058 | 1526 |
jb_updatebuddy(bjid, name, *group_utf8 ? group_utf8 : NULL); |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1527 |
scr_RosterUp(); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1528 |
buddy_setgroup(bud, group_utf8); |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
617
diff
changeset
|
1529 |
} |
210 | 1530 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1531 |
g_free(group_utf8); |
210 | 1532 |
g_free(newgroupname); |
1533 |
update_roster = TRUE; |
|
1534 |
} |
|
1535 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1536 |
static void do_set(char *arg) |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1537 |
{ |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1538 |
guint assign; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1539 |
const gchar *option, *value; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1540 |
gchar *option_utf8; |
393 | 1541 |
|
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1542 |
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
|
1543 |
if (!option) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1544 |
scr_LogPrint(LPRINT_NORMAL, "Set what option?"); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1545 |
return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1546 |
} |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1547 |
option_utf8 = to_utf8(option); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1548 |
if (!assign) { |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1549 |
// This is a query |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1550 |
value = settings_opt_get(option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1551 |
if (value) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1552 |
scr_LogPrint(LPRINT_NORMAL, "%s = [%s]", option_utf8, value); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1553 |
} else |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1554 |
scr_LogPrint(LPRINT_NORMAL, "Option %s is not set", option_utf8); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1555 |
g_free(option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1556 |
return; |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1557 |
} |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1558 |
// Update the option |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1559 |
// 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
|
1560 |
// (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
|
1561 |
// (hide_offline_buddies for ex.) |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1562 |
if (!value) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1563 |
settings_del(SETTINGS_TYPE_OPTION, option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1564 |
} else { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1565 |
gchar *value_utf8 = to_utf8(value); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1566 |
settings_set(SETTINGS_TYPE_OPTION, option_utf8, value_utf8); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1567 |
g_free(value_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1568 |
} |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1569 |
g_free(option_utf8); |
283
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1570 |
} |
00b2377539ac
Add /set command (to get/set/unset options values)
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
1571 |
|
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1572 |
static void dump_alias(void *param, char *k, char *v) |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1573 |
{ |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1574 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, "Alias %s = %s", k, v); |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1575 |
} |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1576 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1577 |
static void do_alias(char *arg) |
285 | 1578 |
{ |
1579 |
guint assign; |
|
1580 |
const gchar *alias, *value; |
|
393 | 1581 |
|
285 | 1582 |
assign = parse_assigment(arg, &alias, &value); |
1583 |
if (!alias) { |
|
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1584 |
settings_foreach(SETTINGS_TYPE_ALIAS, &dump_alias, NULL); |
285 | 1585 |
return; |
1586 |
} |
|
1587 |
if (!assign) { |
|
1588 |
// This is a query |
|
1589 |
value = settings_get(SETTINGS_TYPE_ALIAS, alias); |
|
1590 |
if (value) { |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1591 |
// XXX LPRINT_NOTUTF8 here, see below why it isn't encoded... |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1592 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, "%s = %s", alias, value); |
285 | 1593 |
} else |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1594 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1595 |
"Alias '%s' does not exist", alias); |
285 | 1596 |
return; |
1597 |
} |
|
1598 |
// Check the alias does not conflict with a registered command |
|
1599 |
if (cmd_get(alias)) { |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1600 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1601 |
"'%s' is a reserved word!", alias); |
285 | 1602 |
return; |
1603 |
} |
|
1604 |
// Update the alias |
|
1605 |
if (!value) { |
|
1606 |
if (settings_get(SETTINGS_TYPE_ALIAS, alias)) { |
|
1607 |
settings_del(SETTINGS_TYPE_ALIAS, alias); |
|
1608 |
// Remove alias from the completion list |
|
1609 |
compl_del_category_word(COMPL_CMD, alias); |
|
1610 |
} |
|
1611 |
} else { |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1612 |
/* Add alias to the completion list, if not already in. |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1613 |
XXX We're not UTF8-encoding "alias" and "value" here because UTF-8 is |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1614 |
not yet supported in the UI... (and we use the values in the completion |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1615 |
system) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1616 |
*/ |
285 | 1617 |
if (!settings_get(SETTINGS_TYPE_ALIAS, alias)) |
1618 |
compl_add_category_word(COMPL_CMD, alias); |
|
1619 |
settings_set(SETTINGS_TYPE_ALIAS, alias, value); |
|
1620 |
} |
|
1621 |
} |
|
1622 |
||
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1623 |
static void dump_bind(void *param, char *k, char *v) |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1624 |
{ |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1625 |
scr_LogPrint(LPRINT_NORMAL, "Key %4s is bound to: %s", k, v); |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1626 |
} |
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1627 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
1628 |
static void do_bind(char *arg) |
288 | 1629 |
{ |
1630 |
guint assign; |
|
1058 | 1631 |
const gchar *k_code, *value; |
393 | 1632 |
|
1058 | 1633 |
assign = parse_assigment(arg, &k_code, &value); |
1634 |
if (!k_code) { |
|
867
7f056c566569
Commands /alias & /bind list the key bindings and aliases
Mikael Berthe <mikael@lilotux.net>
parents:
866
diff
changeset
|
1635 |
settings_foreach(SETTINGS_TYPE_BINDING, &dump_bind, NULL); |
288 | 1636 |
return; |
1637 |
} |
|
1638 |
if (!assign) { |
|
1639 |
// This is a query |
|
1058 | 1640 |
value = settings_get(SETTINGS_TYPE_BINDING, k_code); |
288 | 1641 |
if (value) { |
1058 | 1642 |
scr_LogPrint(LPRINT_NORMAL, "Key %s is bound to: %s", k_code, value); |
288 | 1643 |
} else |
1058 | 1644 |
scr_LogPrint(LPRINT_NORMAL, "Key %s is not bound.", k_code); |
288 | 1645 |
return; |
1646 |
} |
|
1647 |
// Update the key binding |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1648 |
if (!value) { |
1058 | 1649 |
settings_del(SETTINGS_TYPE_BINDING, k_code); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1650 |
} else { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1651 |
gchar *value_utf8 = to_utf8(value); |
1058 | 1652 |
settings_set(SETTINGS_TYPE_BINDING, k_code, value_utf8); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1653 |
g_free(value_utf8); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1654 |
} |
288 | 1655 |
} |
1656 |
||
436 | 1657 |
static void do_rawxml(char *arg) |
1658 |
{ |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1659 |
char **paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1660 |
char *subcmd; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1661 |
|
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1662 |
if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1663 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1664 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1665 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
1666 |
|
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1667 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1668 |
subcmd = *paramlst; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1669 |
arg = *(paramlst+1); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1670 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1671 |
if (!subcmd || !*subcmd) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1672 |
scr_LogPrint(LPRINT_NORMAL, "Please read the manual page" |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1673 |
" before using /rawxml :-)"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1674 |
free_arg_lst(paramlst); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1675 |
return; |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1676 |
} |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1677 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1678 |
if (!strcasecmp(subcmd, "send")) { |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1679 |
gchar *buffer; |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1680 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1681 |
if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1682 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1683 |
free_arg_lst(paramlst); |
461
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1684 |
return; |
1d8f5b3a5f2b
Convert /rawxml argument to UTF8
Mikael Berthe <mikael@lilotux.net>
parents:
454
diff
changeset
|
1685 |
} |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1686 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1687 |
// We don't strip_arg_special_chars() here, because it would be a pain for |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1688 |
// the user to escape quotes in a XML stream... |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1689 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1690 |
buffer = to_utf8(arg); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1691 |
if (buffer) { |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1692 |
scr_LogPrint(LPRINT_NORMAL, "Sending XML string"); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1693 |
jb_send_raw(buffer); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1694 |
g_free(buffer); |
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1695 |
} else { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1696 |
scr_LogPrint(LPRINT_NORMAL, "Conversion error in XML string."); |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1697 |
} |
436 | 1698 |
} else { |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1699 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
436 | 1700 |
} |
557
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1701 |
|
c72a66dfd2d4
Use split_arg() in most commands
Mikael Berthe <mikael@lilotux.net>
parents:
555
diff
changeset
|
1702 |
free_arg_lst(paramlst); |
436 | 1703 |
} |
1704 |
||
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1705 |
// check_room_subcommand(arg, param_needed, buddy_must_be_a_room) |
552 | 1706 |
// - Check if this is a room, if buddy_must_be_a_room is not null |
1707 |
// - Check there is at least 1 parameter, if param_needed is true |
|
1708 |
// - Return null if one of the checks fails, or a pointer to the first |
|
1709 |
// non-space character. |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1710 |
static char *check_room_subcommand(char *arg, bool param_needed, |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1711 |
gpointer buddy_must_be_a_room) |
552 | 1712 |
{ |
1713 |
if (buddy_must_be_a_room && |
|
1714 |
!(buddy_gettype(buddy_must_be_a_room) & ROSTER_TYPE_ROOM)) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1715 |
scr_LogPrint(LPRINT_NORMAL, "This isn't a conference room."); |
552 | 1716 |
return NULL; |
1717 |
} |
|
1718 |
||
1719 |
if (param_needed) { |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1720 |
if (!arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1721 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
552 | 1722 |
return NULL; |
1723 |
} |
|
1724 |
} |
|
1725 |
||
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1726 |
if (arg) |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1727 |
return arg; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1728 |
else |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1729 |
return ""; |
552 | 1730 |
} |
1731 |
||
1732 |
static void room_join(gpointer bud, char *arg) |
|
1733 |
{ |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1734 |
char **paramlst; |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1735 |
char *roomname, *nick, *pass; |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1736 |
char *roomname_tmp = NULL; |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1737 |
char *pass_utf8; |
552 | 1738 |
|
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1739 |
paramlst = split_arg(arg, 3, 0); // roomid, nickname, password |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1740 |
roomname = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1741 |
nick = *(paramlst+1); |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1742 |
pass = *(paramlst+2); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1743 |
|
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1744 |
if (!roomname) |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1745 |
nick = NULL; |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1746 |
if (!nick) |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1747 |
pass = NULL; |
552 | 1748 |
|
841
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1749 |
if (!roomname || !strcmp(roomname, ".")) { |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1750 |
// If the current_buddy is recognized as a room, the room name |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1751 |
// can be omitted (or "." can be used). |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1752 |
if (!bud || !(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) { |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1753 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a room name."); |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1754 |
free_arg_lst(paramlst); |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1755 |
return; |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1756 |
} |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1757 |
roomname = (char*)buddy_getjid(bud); |
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
1758 |
} else if (strchr(roomname, '/')) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1759 |
scr_LogPrint(LPRINT_NORMAL, "Invalid room name."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1760 |
free_arg_lst(paramlst); |
552 | 1761 |
return; |
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1762 |
} else { |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1763 |
// The room id has been specified. Let's convert it and use it. |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1764 |
roomname_tmp = to_utf8(roomname); |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1765 |
mc_strtolower(roomname_tmp); |
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1766 |
roomname = roomname_tmp; |
552 | 1767 |
} |
1768 |
||
659
e61aa455c61b
MUC: Add "nickname" option variable
Mikael Berthe <mikael@lilotux.net>
parents:
653
diff
changeset
|
1769 |
// If no nickname is provided with the /join command, |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1770 |
// we try to get a default nickname. |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1771 |
if (!nick || !*nick) |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1772 |
nick = default_muc_nickname(); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1773 |
else |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1774 |
nick = to_utf8(nick); |
659
e61aa455c61b
MUC: Add "nickname" option variable
Mikael Berthe <mikael@lilotux.net>
parents:
653
diff
changeset
|
1775 |
// If we still have no nickname, give up |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1776 |
if (!nick || !*nick) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1777 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1778 |
g_free(nick); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1779 |
free_arg_lst(paramlst); |
552 | 1780 |
return; |
1781 |
} |
|
1782 |
||
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1783 |
pass_utf8 = to_utf8(pass); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1784 |
|
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1785 |
jb_room_join(roomname, nick, pass_utf8); |
552 | 1786 |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1787 |
scr_LogPrint(LPRINT_LOGNORM, "Sent a join request to <%s>...", roomname); |
653
d5db5be78eb0
MUC: Be more verbose when joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1788 |
|
1033
056364952b0d
[BP-7f216b904315] Fix a potential double UTF-8 encoding
Mikael Berthe <mikael@lilotux.net>
parents:
960
diff
changeset
|
1789 |
g_free(roomname_tmp); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
1790 |
g_free(nick); |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1791 |
g_free(pass_utf8); |
552 | 1792 |
buddylist_build(); |
1793 |
update_roster = TRUE; |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1794 |
free_arg_lst(paramlst); |
552 | 1795 |
} |
1796 |
||
1797 |
static void room_invite(gpointer bud, char *arg) |
|
1798 |
{ |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1799 |
char **paramlst; |
552 | 1800 |
const gchar *roomname; |
1058 | 1801 |
char* fjid; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1802 |
gchar *reason_utf8; |
552 | 1803 |
|
570
29806b0fe830
Some parsing improvements
Mikael Berthe <mikael@lilotux.net>
parents:
568
diff
changeset
|
1804 |
paramlst = split_arg(arg, 2, 1); // jid, [reason] |
1058 | 1805 |
fjid = *paramlst; |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1806 |
arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1807 |
// An empty reason is no reason... |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1808 |
if (arg && !*arg) |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1809 |
arg = NULL; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1810 |
|
1058 | 1811 |
if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1812 |
scr_LogPrint(LPRINT_NORMAL, "Missing or incorrect Jabber ID."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1813 |
free_arg_lst(paramlst); |
552 | 1814 |
return; |
1815 |
} |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1816 |
|
552 | 1817 |
roomname = buddy_getjid(bud); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1818 |
reason_utf8 = to_utf8(arg); |
1058 | 1819 |
jb_room_invite(roomname, fjid, reason_utf8); |
1820 |
scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>.", fjid); |
|
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1821 |
g_free(reason_utf8); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
1822 |
free_arg_lst(paramlst); |
552 | 1823 |
} |
1824 |
||
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1825 |
static void room_affil(gpointer bud, char *arg) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1826 |
{ |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1827 |
char **paramlst; |
1058 | 1828 |
gchar *fjid, *rolename; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1829 |
struct role_affil ra; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1830 |
const char *roomid = buddy_getjid(bud); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1831 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1832 |
paramlst = split_arg(arg, 3, 1); // jid, new_affil, [reason] |
1058 | 1833 |
fjid = *paramlst; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1834 |
rolename = *(paramlst+1); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1835 |
arg = *(paramlst+2); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1836 |
|
1058 | 1837 |
if (!fjid || !*fjid || !rolename || !*rolename) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1838 |
scr_LogPrint(LPRINT_NORMAL, "Please specify both a Jabber ID and a role."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1839 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1840 |
return; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1841 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1842 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1843 |
ra.type = type_affil; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1844 |
ra.val.affil = affil_none; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1845 |
for (; ra.val.affil < imaffiliation_size; ra.val.affil++) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1846 |
if (!strcasecmp(rolename, straffil[ra.val.affil])) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1847 |
break; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1848 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1849 |
if (ra.val.affil < imaffiliation_size) { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1850 |
gchar *jid_utf8, *reason_utf8; |
1058 | 1851 |
jid_utf8 = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1852 |
reason_utf8 = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1853 |
jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1854 |
g_free(jid_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1855 |
g_free(reason_utf8); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1856 |
} else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1857 |
scr_LogPrint(LPRINT_NORMAL, "Wrong affiliation parameter."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1858 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1859 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1860 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1861 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1862 |
static void room_role(gpointer bud, char *arg) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1863 |
{ |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1864 |
char **paramlst; |
1058 | 1865 |
gchar *fjid, *rolename; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1866 |
struct role_affil ra; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1867 |
const char *roomid = buddy_getjid(bud); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1868 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1869 |
paramlst = split_arg(arg, 3, 1); // jid, new_role, [reason] |
1058 | 1870 |
fjid = *paramlst; |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1871 |
rolename = *(paramlst+1); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1872 |
arg = *(paramlst+2); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1873 |
|
1058 | 1874 |
if (!fjid || !*fjid || !rolename || !*rolename) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1875 |
scr_LogPrint(LPRINT_NORMAL, "Please specify both a Jabber ID and a role."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1876 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1877 |
return; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1878 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1879 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1880 |
ra.type = type_role; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1881 |
ra.val.role = role_none; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1882 |
for (; ra.val.role < imrole_size; ra.val.role++) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1883 |
if (!strcasecmp(rolename, strrole[ra.val.role])) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1884 |
break; |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1885 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1886 |
if (ra.val.role < imrole_size) { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1887 |
gchar *jid_utf8, *reason_utf8; |
1058 | 1888 |
jid_utf8 = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1889 |
reason_utf8 = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1890 |
jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1891 |
g_free(jid_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1892 |
g_free(reason_utf8); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1893 |
} else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1894 |
scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter."); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1895 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1896 |
free_arg_lst(paramlst); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1897 |
} |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1898 |
|
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
1899 |
|
571 | 1900 |
// The expected argument is a Jabber id |
1901 |
static void room_ban(gpointer bud, char *arg) |
|
1902 |
{ |
|
1903 |
char **paramlst; |
|
1058 | 1904 |
gchar *fjid; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1905 |
gchar *jid_utf8, *reason_utf8; |
584 | 1906 |
struct role_affil ra; |
571 | 1907 |
const char *roomid = buddy_getjid(bud); |
1908 |
||
1909 |
paramlst = split_arg(arg, 2, 1); // jid, [reason] |
|
1058 | 1910 |
fjid = *paramlst; |
571 | 1911 |
arg = *(paramlst+1); |
1912 |
||
1058 | 1913 |
if (!fjid || !*fjid) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1914 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
571 | 1915 |
free_arg_lst(paramlst); |
1916 |
return; |
|
1917 |
} |
|
1918 |
||
584 | 1919 |
ra.type = type_affil; |
1920 |
ra.val.affil = affil_outcast; |
|
1921 |
||
1058 | 1922 |
jid_utf8 = to_utf8(fjid); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1923 |
reason_utf8 = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1924 |
jb_room_setattrib(roomid, jid_utf8, NULL, ra, reason_utf8); |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1925 |
g_free(jid_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1926 |
g_free(reason_utf8); |
571 | 1927 |
|
1928 |
free_arg_lst(paramlst); |
|
1929 |
} |
|
1930 |
||
1931 |
// The expected argument is a nickname |
|
568 | 1932 |
static void room_kick(gpointer bud, char *arg) |
1933 |
{ |
|
1934 |
char **paramlst; |
|
1935 |
gchar *nick; |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1936 |
gchar *nick_utf8, *reason_utf8; |
584 | 1937 |
struct role_affil ra; |
568 | 1938 |
const char *roomid = buddy_getjid(bud); |
1939 |
||
571 | 1940 |
paramlst = split_arg(arg, 2, 1); // nickname, [reason] |
568 | 1941 |
nick = *paramlst; |
1942 |
arg = *(paramlst+1); |
|
1943 |
||
1944 |
if (!nick || !*nick) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1945 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
568 | 1946 |
free_arg_lst(paramlst); |
1947 |
return; |
|
1948 |
} |
|
1949 |
||
584 | 1950 |
ra.type = type_role; |
1951 |
ra.val.affil = role_none; |
|
1952 |
||
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1953 |
nick_utf8 = to_utf8(nick); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1954 |
reason_utf8 = to_utf8(arg); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1955 |
jb_room_setattrib(roomid, NULL, nick_utf8, ra, reason_utf8); |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1956 |
g_free(nick_utf8); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
1957 |
g_free(reason_utf8); |
568 | 1958 |
|
1959 |
free_arg_lst(paramlst); |
|
1960 |
} |
|
1961 |
||
552 | 1962 |
static void room_leave(gpointer bud, char *arg) |
1963 |
{ |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1964 |
gchar *roomid, *desc; |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1965 |
const char *nickname; |
552 | 1966 |
|
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1967 |
nickname = buddy_getnickname(bud); |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1968 |
if (!nickname) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1969 |
scr_LogPrint(LPRINT_NORMAL, "You are not in this room."); |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1970 |
return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1971 |
} |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1972 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1973 |
roomid = g_strdup_printf("%s/%s", buddy_getjid(bud), nickname); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1974 |
desc = to_utf8(arg); |
1050
ea71d31a2607
PGP: Do not sign presence messages to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
1043
diff
changeset
|
1975 |
jb_setstatus(offline, roomid, desc, TRUE); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
1976 |
g_free(desc); |
552 | 1977 |
g_free(roomid); |
1978 |
} |
|
1979 |
||
1980 |
static void room_nick(gpointer bud, char *arg) |
|
1981 |
{ |
|
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1982 |
if (!buddy_getinsideroom(bud)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1983 |
scr_LogPrint(LPRINT_NORMAL, "You are not in this room."); |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1984 |
return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1985 |
} |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
1986 |
|
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1987 |
if (!arg || !*arg) { |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1988 |
const char *nick = buddy_getnickname(bud); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1989 |
if (nick) |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1990 |
scr_LogPrint(LPRINT_NORMAL, "Your nickname is: %s", nick); |
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1991 |
else |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
1992 |
scr_LogPrint(LPRINT_NORMAL, "You have no nickname in this room."); |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
1993 |
} else { |
900
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1994 |
gchar *roomname, *roomname_tmp, *nick; |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1995 |
roomname_tmp = g_strdup(buddy_getjid(bud)); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1996 |
mc_strtolower(roomname_tmp); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1997 |
roomname = to_utf8(roomname_tmp); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1998 |
g_free(roomname_tmp); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
1999 |
nick = to_utf8(arg); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2000 |
|
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2001 |
jb_room_join(roomname, nick, NULL); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2002 |
g_free(roomname); |
b41684465283
MUC: join password-protected room
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
2003 |
g_free(nick); |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2004 |
} |
552 | 2005 |
} |
2006 |
||
2007 |
static void room_privmsg(gpointer bud, char *arg) |
|
2008 |
{ |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2009 |
char **paramlst; |
1058 | 2010 |
gchar *nick, *cmdline; |
552 | 2011 |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2012 |
paramlst = split_arg(arg, 2, 0); // nickname, message |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2013 |
nick = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2014 |
arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2015 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2016 |
if (!nick || !*nick || !arg || !*arg) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2017 |
scr_LogPrint(LPRINT_NORMAL, |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2018 |
"Please specify both a Jabber ID and a message."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2019 |
free_arg_lst(paramlst); |
552 | 2020 |
return; |
2021 |
} |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2022 |
|
1058 | 2023 |
cmdline = g_strdup_printf("%s/%s %s", buddy_getjid(bud), nick, arg); |
2024 |
do_say_to(cmdline); |
|
2025 |
g_free(cmdline); |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2026 |
free_arg_lst(paramlst); |
552 | 2027 |
} |
2028 |
||
2029 |
static void room_remove(gpointer bud, char *arg) |
|
2030 |
{ |
|
2031 |
if (*arg) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2032 |
scr_LogPrint(LPRINT_NORMAL, "This action does not require a parameter; " |
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2033 |
"the currently-selected room will be removed."); |
552 | 2034 |
return; |
2035 |
} |
|
2036 |
||
2037 |
// Quick check: if there are resources, we haven't left |
|
652
b243d3b3ff1b
We do not need buddy_isresource() anymore
Mikael Berthe <mikael@lilotux.net>
parents:
650
diff
changeset
|
2038 |
if (buddy_getinsideroom(bud)) { |
552 | 2039 |
scr_LogPrint(LPRINT_NORMAL, "You haven't left this room!"); |
2040 |
return; |
|
2041 |
} |
|
2042 |
// Delete the room |
|
2043 |
roster_del_user(buddy_getjid(bud)); |
|
865
cee8d6be04e1
Improve changeset a3db3ee8b99e, do not enable chatmode when refreshing
Mikael Berthe <mikael@lilotux.net>
parents:
861
diff
changeset
|
2044 |
scr_UpdateBuddyWindow(); |
552 | 2045 |
buddylist_build(); |
2046 |
update_roster = TRUE; |
|
2047 |
} |
|
2048 |
||
2049 |
static void room_topic(gpointer bud, char *arg) |
|
2050 |
{ |
|
2051 |
gchar *msg; |
|
2052 |
||
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2053 |
if (!buddy_getinsideroom(bud)) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2054 |
scr_LogPrint(LPRINT_NORMAL, "You are not in this room."); |
650
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2055 |
return; |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2056 |
} |
c2d50b97ced4
MUC: /room {leave,nick,topic} can only be used when inside a room
Mikael Berthe <mikael@lilotux.net>
parents:
647
diff
changeset
|
2057 |
|
552 | 2058 |
// If no parameter is given, display the current topic |
2059 |
if (!*arg) { |
|
2060 |
const char *topic = buddy_gettopic(bud); |
|
2061 |
if (topic) |
|
2062 |
scr_LogPrint(LPRINT_NORMAL, "Topic: %s", topic); |
|
2063 |
else |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2064 |
scr_LogPrint(LPRINT_NORMAL, "No topic has been set."); |
552 | 2065 |
return; |
2066 |
} |
|
2067 |
||
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2068 |
arg = to_utf8(arg); |
552 | 2069 |
// Set the topic |
967 | 2070 |
msg = g_strdup_printf("%s has set the topic to: %s", mkcmdstr("me"), arg); |
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1050
diff
changeset
|
2071 |
jb_send_msg(buddy_getjid(bud), msg, ROSTER_TYPE_ROOM, arg, NULL, NULL); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2072 |
g_free(arg); |
552 | 2073 |
g_free(msg); |
2074 |
} |
|
2075 |
||
599 | 2076 |
static void room_destroy(gpointer bud, char *arg) |
2077 |
{ |
|
2078 |
gchar *msg; |
|
2079 |
||
2080 |
if (arg && *arg) |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2081 |
msg = to_utf8(arg); |
599 | 2082 |
else |
2083 |
msg = NULL; |
|
2084 |
||
2085 |
jb_room_destroy(buddy_getjid(bud), NULL, msg); |
|
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
2086 |
g_free(msg); |
599 | 2087 |
} |
2088 |
||
552 | 2089 |
static void room_unlock(gpointer bud, char *arg) |
2090 |
{ |
|
2091 |
if (*arg) { |
|
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2092 |
scr_LogPrint(LPRINT_NORMAL, "Unknown parameter."); |
552 | 2093 |
return; |
2094 |
} |
|
2095 |
||
2096 |
jb_room_unlock(buddy_getjid(bud)); |
|
2097 |
} |
|
2098 |
||
960
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2099 |
// room_whois(..) |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2100 |
// If interactive is TRUE, chatmode can be enabled. |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2101 |
void room_whois(gpointer bud, char *arg, guint interactive) |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2102 |
{ |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2103 |
char **paramlst; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2104 |
gchar *nick, *buffer; |
1058 | 2105 |
const char *bjid, *realjid; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2106 |
const char *rst_msg; |
575 | 2107 |
gchar rprio; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2108 |
enum imstatus rstatus; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2109 |
enum imrole role; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2110 |
enum imaffiliation affil; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2111 |
time_t rst_time; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2112 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2113 |
paramlst = split_arg(arg, 1, 0); // nickname |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2114 |
nick = *paramlst; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2115 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2116 |
if (!nick || !*nick) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2117 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a nickname."); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2118 |
free_arg_lst(paramlst); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2119 |
return; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2120 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2121 |
|
791
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2122 |
nick = to_utf8(nick); |
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2123 |
|
960
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2124 |
if (interactive) { |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2125 |
// Enter chat mode |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2126 |
scr_set_chatmode(TRUE); |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2127 |
scr_ShowBuddyWindow(); |
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2128 |
} |
647
c6c41dd2464a
Enter chat mode automatically when using some commands
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
2129 |
|
1058 | 2130 |
bjid = buddy_getjid(bud); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2131 |
rstatus = buddy_getstatus(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2132 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2133 |
if (rstatus == offline) { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2134 |
scr_LogPrint(LPRINT_NORMAL, "No such member: %s", nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2135 |
free_arg_lst(paramlst); |
791
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2136 |
g_free(nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2137 |
return; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2138 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2139 |
|
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2140 |
rst_time = buddy_getstatustime(bud, nick); |
575 | 2141 |
rprio = buddy_getresourceprio(bud, nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2142 |
rst_msg = buddy_getstatusmsg(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2143 |
if (!rst_msg) rst_msg = ""; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2144 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2145 |
role = buddy_getrole(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2146 |
affil = buddy_getaffil(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2147 |
realjid = buddy_getrjid(bud, nick); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2148 |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2149 |
buffer = g_new(char, 4096); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2150 |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2151 |
snprintf(buffer, 4095, "Whois [%s]", nick); |
1058 | 2152 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2153 |
snprintf(buffer, 4095, "Status : [%c] %s", imstatus2char[rstatus], |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2154 |
rst_msg); |
1058 | 2155 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2156 |
|
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2157 |
if (rst_time) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2158 |
char tbuf[128]; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2159 |
|
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2160 |
strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time)); |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2161 |
snprintf(buffer, 127, "Timestamp: %s", tbuf); |
1058 | 2162 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2163 |
} |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2164 |
|
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2165 |
if (realjid) { |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2166 |
snprintf(buffer, 4095, "JID : <%s>", realjid); |
1058 | 2167 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2168 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2169 |
|
1058 | 2170 |
snprintf(buffer, 4095, "Role : %s", strrole[role]); |
2171 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
|
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2172 |
snprintf(buffer, 4095, "Affiliat.: %s", straffil[affil]); |
1058 | 2173 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
626
b75f4105ce32
Use a larger buffer for commands like /info
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
2174 |
snprintf(buffer, 4095, "Priority : %d", rprio); |
1058 | 2175 |
scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
622
diff
changeset
|
2176 |
|
1058 | 2177 |
scr_WriteIncomingMessage(bjid, "End of WHOIS", 0, HBB_PREFIX_INFO); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2178 |
|
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2179 |
g_free(buffer); |
791
6c9e8fb69965
Fix "/room whois" with UTF-8 nickname
Mikael Berthe <mikael@lilotux.net>
parents:
777
diff
changeset
|
2180 |
g_free(nick); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2181 |
free_arg_lst(paramlst); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2182 |
} |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2183 |
|
1009 | 2184 |
static void room_bookmark(gpointer bud, char *arg) |
2185 |
{ |
|
2186 |
const char *roomid; |
|
2187 |
const char *name = NULL, *nick = NULL; |
|
2188 |
enum { bm_add = 0, bm_del = 1 } action = 0; |
|
2189 |
int autojoin = 0; |
|
2190 |
||
2191 |
if (arg && *arg) { |
|
2192 |
// /room bookmark [add|del] [[+|-]autojoin] |
|
2193 |
char **paramlst; |
|
2194 |
char **pp; |
|
2195 |
||
2196 |
paramlst = split_arg(arg, 2, 0); // At most 2 parameters |
|
2197 |
for (pp = paramlst; *pp; pp++) { |
|
2198 |
if (!strcasecmp(*pp, "add")) |
|
2199 |
action = bm_add; |
|
2200 |
else if (!strcasecmp(*pp, "del")) |
|
2201 |
action = bm_del; |
|
2202 |
else if (!strcasecmp(*pp, "-autojoin")) |
|
2203 |
autojoin = 0; |
|
2204 |
else if (!strcasecmp(*pp, "+autojoin") || !strcasecmp(*pp, "autojoin")) |
|
2205 |
autojoin = 1; |
|
2206 |
} |
|
2207 |
free_arg_lst(paramlst); |
|
2208 |
} |
|
2209 |
||
2210 |
roomid = buddy_getjid(bud); |
|
2211 |
||
2212 |
if (action == bm_add) { |
|
2213 |
name = buddy_getname(bud); |
|
2214 |
nick = buddy_getnickname(bud); |
|
2215 |
} |
|
2216 |
||
2217 |
jb_set_storage_bookmark(roomid, name, nick, NULL, autojoin); |
|
2218 |
} |
|
2219 |
||
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2220 |
static void do_room(char *arg) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2221 |
{ |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2222 |
char **paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2223 |
char *subcmd; |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2224 |
gpointer bud; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2225 |
|
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2226 |
if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2227 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2228 |
return; |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2229 |
} |
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
471
diff
changeset
|
2230 |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2231 |
paramlst = split_arg(arg, 2, 1); // subcmd, arg |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2232 |
subcmd = *paramlst; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2233 |
arg = *(paramlst+1); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2234 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2235 |
if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2236 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2237 |
free_arg_lst(paramlst); |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2238 |
return; |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2239 |
} |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2240 |
|
831
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2241 |
if (current_buddy) { |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2242 |
bud = BUDDATA(current_buddy); |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2243 |
} else { |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2244 |
if (strcasecmp(subcmd, "join")) |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2245 |
return; |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2246 |
// "room join" is a special case, we don't need to have a valid |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2247 |
// current_buddy. |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2248 |
bud = NULL; |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2249 |
} |
dd865cc57aa2
Fix joining a room when the buddylist is empty
Mikael Berthe <mikael@lilotux.net>
parents:
820
diff
changeset
|
2250 |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2251 |
if (!strcasecmp(subcmd, "join")) { |
841
f8c0447beec2
Allow "/room join . [nick]" if the current item is a MUC room
Mikael Berthe <mikael@lilotux.net>
parents:
840
diff
changeset
|
2252 |
if ((arg = check_room_subcommand(arg, FALSE, NULL)) != NULL) |
552 | 2253 |
room_join(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2254 |
} else if (!strcasecmp(subcmd, "invite")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2255 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
552 | 2256 |
room_invite(bud, arg); |
585
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2257 |
} else if (!strcasecmp(subcmd, "affil")) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2258 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2259 |
room_affil(bud, arg); |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2260 |
} else if (!strcasecmp(subcmd, "role")) { |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2261 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
7eff2c1481fa
Add "/room affil" and "/room role"
Mikael Berthe <mikael@lilotux.net>
parents:
584
diff
changeset
|
2262 |
room_role(bud, arg); |
571 | 2263 |
} else if (!strcasecmp(subcmd, "ban")) { |
2264 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
|
2265 |
room_ban(bud, arg); |
|
568 | 2266 |
} else if (!strcasecmp(subcmd, "kick")) { |
2267 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
|
2268 |
room_kick(bud, arg); |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2269 |
} else if (!strcasecmp(subcmd, "leave")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2270 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2271 |
room_leave(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2272 |
} else if (!strcasecmp(subcmd, "names")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2273 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2274 |
room_names(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2275 |
} else if (!strcasecmp(subcmd, "nick")) { |
565
89c347b3e4c1
MUC: Make "/room nick" display the current nickname
Mikael Berthe <mikael@lilotux.net>
parents:
558
diff
changeset
|
2276 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2277 |
room_nick(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2278 |
} else if (!strcasecmp(subcmd, "privmsg")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2279 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
552 | 2280 |
room_privmsg(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2281 |
} else if (!strcasecmp(subcmd, "remove")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2282 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2283 |
room_remove(bud, arg); |
599 | 2284 |
} else if (!strcasecmp(subcmd, "destroy")) { |
2285 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
|
2286 |
room_destroy(bud, arg); |
|
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2287 |
} else if (!strcasecmp(subcmd, "unlock")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2288 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2289 |
room_unlock(bud, arg); |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2290 |
} else if (!strcasecmp(subcmd, "topic")) { |
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2291 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
552 | 2292 |
room_topic(bud, arg); |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2293 |
} else if (!strcasecmp(subcmd, "whois")) { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
571
diff
changeset
|
2294 |
if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) |
960
90ff94f0fbbb
Auto-whois shouldn't enable chat mode
Mikael Berthe <mikael@lilotux.net>
parents:
958
diff
changeset
|
2295 |
room_whois(bud, arg, TRUE); |
1009 | 2296 |
} else if (!strcasecmp(subcmd, "bookmark")) { |
2297 |
if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL) |
|
2298 |
room_bookmark(bud, arg); |
|
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2299 |
} else { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2300 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2301 |
} |
554
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2302 |
|
2424bbf0a6db
Some more work on do_room()
Mikael Berthe <mikael@lilotux.net>
parents:
552
diff
changeset
|
2303 |
free_arg_lst(paramlst); |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2304 |
} |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
446
diff
changeset
|
2305 |
|
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2306 |
static void do_authorization(char *arg) |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2307 |
{ |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2308 |
char **paramlst; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2309 |
char *subcmd; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2310 |
char *jid_utf8; |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2311 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2312 |
if (!jb_getonline()) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2313 |
scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2314 |
return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2315 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2316 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2317 |
paramlst = split_arg(arg, 2, 0); // subcmd, [jid] |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2318 |
subcmd = *paramlst; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2319 |
arg = *(paramlst+1); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2320 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2321 |
if (!subcmd || !*subcmd) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2322 |
scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2323 |
free_arg_lst(paramlst); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2324 |
return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2325 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2326 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2327 |
// Use the provided jid, if it looks valid |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2328 |
if (arg) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2329 |
if (!*arg) { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2330 |
// If no jid is provided, we use the current selected buddy |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2331 |
arg = NULL; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2332 |
} else { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2333 |
if (check_jid_syntax(arg)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2334 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2335 |
"<%s> is not a valid Jabber ID.", arg); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2336 |
free_arg_lst(paramlst); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2337 |
return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2338 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2339 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2340 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2341 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2342 |
if (!arg) { // Use the current selected buddy's jid |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2343 |
gpointer bud; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2344 |
guint type; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2345 |
|
1058 | 2346 |
if (!current_buddy) |
2347 |
return; |
|
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2348 |
bud = BUDDATA(current_buddy); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2349 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2350 |
jid_utf8 = arg = (char*)buddy_getjid(bud); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2351 |
type = buddy_gettype(bud); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2352 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2353 |
if (!(type & (ROSTER_TYPE_USER|ROSTER_TYPE_AGENT))) { |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2354 |
scr_LogPrint(LPRINT_NORMAL, "Invalid buddy."); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2355 |
return; |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2356 |
} |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2357 |
} else { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2358 |
jid_utf8 = to_utf8(arg); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2359 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2360 |
|
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2361 |
if (!strcasecmp(subcmd, "allow")) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2362 |
jb_subscr_send_auth(jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2363 |
scr_LogPrint(LPRINT_LOGNORM, |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2364 |
"<%s> is now allowed to receive your presence updates.", |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2365 |
jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2366 |
} else if (!strcasecmp(subcmd, "cancel")) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2367 |
jb_subscr_cancel_auth(jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2368 |
scr_LogPrint(LPRINT_LOGNORM, |
681
8dc602a246a4
Improve messages in commands.c
Philip M. White <pmw@qnan.org>
parents:
677
diff
changeset
|
2369 |
"<%s> will no longer receive your presence updates.", |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2370 |
jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2371 |
} else if (!strcasecmp(subcmd, "request")) { |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2372 |
jb_subscr_request_auth(jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2373 |
scr_LogPrint(LPRINT_LOGNORM, |
957 | 2374 |
"Sent presence notification request to <%s>.", jid_utf8); |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2375 |
} else if (!strcasecmp(subcmd, "request_unsubscribe")) { |
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2376 |
jb_subscr_request_cancel(jid_utf8); |
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2377 |
scr_LogPrint(LPRINT_LOGNORM, |
957 | 2378 |
"Sent presence notification unsubscription request to <%s>.", |
835
6a732d2ad4b4
Add "/authorization request_unsubscribe"
Mikael Berthe <mikael@lilotux.net>
parents:
831
diff
changeset
|
2379 |
jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2380 |
} else { |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2381 |
scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2382 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2383 |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2384 |
// Only free jid_utf8 if it has been allocated, i.e. if != arg. |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2385 |
if (jid_utf8 && jid_utf8 != arg) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2386 |
g_free(jid_utf8); |
617
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2387 |
free_arg_lst(paramlst); |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2388 |
} |
d3a8b43bf9e7
Add "/authorization" command
Mikael Berthe <mikael@lilotux.net>
parents:
608
diff
changeset
|
2389 |
|
622 | 2390 |
static void do_version(char *arg) |
2391 |
{ |
|
777
e6d42f239541
"/version" shows Mercurial changeset (if there's one)
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
2392 |
gchar *ver = mcabber_version(); |
e6d42f239541
"/version" shows Mercurial changeset (if there's one)
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
2393 |
scr_LogPrint(LPRINT_NORMAL, "This is mcabber version %s.", ver); |
e6d42f239541
"/version" shows Mercurial changeset (if there's one)
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
2394 |
g_free(ver); |
622 | 2395 |
} |
2396 |
||
693 | 2397 |
static void do_request(char *arg) |
2398 |
{ |
|
2399 |
char **paramlst; |
|
1058 | 2400 |
char *fjid, *type; |
740 | 2401 |
enum iqreq_type numtype = iqreq_none; |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2402 |
char *jid_utf8 = NULL; |
693 | 2403 |
|
2404 |
paramlst = split_arg(arg, 2, 0); // type, jid |
|
2405 |
type = *paramlst; |
|
1058 | 2406 |
fjid = *(paramlst+1); |
693 | 2407 |
|
2408 |
if (type) { |
|
2409 |
// Quick check... |
|
2410 |
if (!strcasecmp(type, "version")) |
|
2411 |
numtype = iqreq_version; |
|
2412 |
else if (!strcasecmp(type, "time")) |
|
2413 |
numtype = iqreq_time; |
|
1015 | 2414 |
else if (!strcasecmp(type, "last")) |
2415 |
numtype = iqreq_last; |
|
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
2416 |
else if (!strcasecmp(type, "vcard")) |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
2417 |
numtype = iqreq_vcard; |
694
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2418 |
else if (!strcasecmp(type, "show_list")) { |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2419 |
// Undocumented command, for debugging purposes only |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2420 |
jb_iqs_display_list(); |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2421 |
free_arg_lst(paramlst); |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2422 |
return; |
6d6fdaf846ed
Add "/request show_list"
Mikael Berthe <mikael@lilotux.net>
parents:
693
diff
changeset
|
2423 |
} |
693 | 2424 |
} |
2425 |
||
2426 |
if (!type || !numtype) { |
|
2427 |
scr_LogPrint(LPRINT_NORMAL, |
|
1015 | 2428 |
"Please specify a query type (version, time...)."); |
693 | 2429 |
free_arg_lst(paramlst); |
2430 |
return; |
|
2431 |
} |
|
2432 |
||
2433 |
// Allow special jid "" or "." (current buddy) |
|
1058 | 2434 |
if (fjid && (!*fjid || !strcmp(fjid, "."))) |
2435 |
fjid = NULL; |
|
693 | 2436 |
|
1058 | 2437 |
if (fjid) { |
693 | 2438 |
// The JID has been specified. Quick check... |
1058 | 2439 |
if (check_jid_syntax(fjid)) { |
1064
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2440 |
scr_LogPrint(LPRINT_NORMAL|LPRINT_NOTUTF8, |
516b5f7d1023
Fix some UTF-8 related problems
Mikael Berthe <mikael@lilotux.net>
parents:
1059
diff
changeset
|
2441 |
"<%s> is not a valid Jabber ID.", fjid); |
1058 | 2442 |
fjid = NULL; |
693 | 2443 |
} else { |
2444 |
// Convert jid to lowercase |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2445 |
char *p; |
1058 | 2446 |
for (p = fjid; *p && *p != JID_RESOURCE_SEPARATOR; p++) |
693 | 2447 |
*p = tolower(*p); |
1058 | 2448 |
fjid = jid_utf8 = to_utf8(fjid); |
693 | 2449 |
} |
2450 |
} else { |
|
2451 |
// Add the current buddy |
|
2452 |
if (current_buddy) |
|
1058 | 2453 |
fjid = (char*)buddy_getjid(BUDDATA(current_buddy)); |
2454 |
if (!fjid) |
|
693 | 2455 |
scr_LogPrint(LPRINT_NORMAL, "Please specify a Jabber ID."); |
2456 |
} |
|
2457 |
||
1058 | 2458 |
if (fjid) { |
693 | 2459 |
switch (numtype) { |
2460 |
case iqreq_version: |
|
2461 |
case iqreq_time: |
|
1015 | 2462 |
case iqreq_last: |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
2463 |
case iqreq_vcard: |
1058 | 2464 |
jb_request(fjid, numtype); |
693 | 2465 |
break; |
2466 |
default: |
|
2467 |
break; |
|
2468 |
} |
|
2469 |
} |
|
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
757
diff
changeset
|
2470 |
g_free(jid_utf8); |
693 | 2471 |
free_arg_lst(paramlst); |
2472 |
} |
|
2473 |
||
748 | 2474 |
static void do_event(char *arg) |
2475 |
{ |
|
2476 |
char **paramlst; |
|
2477 |
char *evid, *subcmd; |
|
2478 |
int action = -1; |
|
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2479 |
GSList *evidlst; |
748 | 2480 |
|
2481 |
paramlst = split_arg(arg, 2, 0); // id, subcmd |
|
2482 |
evid = *paramlst; |
|
2483 |
subcmd = *(paramlst+1); |
|
2484 |
||
2485 |
if (!evid || !subcmd) { |
|
2486 |
// Special case: /event list |
|
2487 |
if (evid && !strcasecmp(evid, "list")) |
|
2488 |
evs_display_list(); |
|
2489 |
else |
|
2490 |
scr_LogPrint(LPRINT_NORMAL, |
|
2491 |
"Missing parameter. Usage: /event num action"); |
|
2492 |
free_arg_lst(paramlst); |
|
2493 |
return; |
|
2494 |
} |
|
2495 |
||
2496 |
if (!strcasecmp(subcmd, "reject")) |
|
2497 |
action = 0; |
|
2498 |
else if (!strcasecmp(subcmd, "accept")) |
|
2499 |
action = 1; |
|
755 | 2500 |
else if (!strcasecmp(subcmd, "ignore")) |
2501 |
action = 2; |
|
748 | 2502 |
|
2503 |
if (action == -1) { |
|
2504 |
scr_LogPrint(LPRINT_NORMAL, "Wrong action parameter."); |
|
755 | 2505 |
} else if (action >= 0 && action <= 2) { |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2506 |
GSList *p; |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2507 |
|
755 | 2508 |
if (action == 2) { |
2509 |
action = EVS_CONTEXT_CANCEL; |
|
2510 |
} else { |
|
2511 |
action += EVS_CONTEXT_USER; |
|
2512 |
} |
|
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2513 |
|
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2514 |
if (!strcmp(evid, "*")) { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2515 |
// Use completion list |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2516 |
evidlst = evs_geteventslist(FALSE); |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2517 |
} else { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2518 |
// Let's create a slist with the provided event id |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2519 |
evidlst = g_slist_append(NULL, g_strdup(evid)); |
748 | 2520 |
} |
820
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2521 |
for (p = evidlst; p; p = g_slist_next(p)) { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2522 |
if (evs_callback(p->data, action) == -1) { |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2523 |
scr_LogPrint(LPRINT_NORMAL, "Event %s not found.", p->data); |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2524 |
} |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2525 |
g_free(p->data); |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2526 |
} |
80bd7f49075f
Allow '*' in /event command
Mikael Berthe <mikael@lilotux.net>
parents:
807
diff
changeset
|
2527 |
g_slist_free(evidlst); |
748 | 2528 |
} |
2529 |
||
2530 |
free_arg_lst(paramlst); |
|
2531 |
} |
|
2532 |
||
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
2533 |
static void do_connect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2534 |
{ |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2535 |
mcabber_connect(); |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2536 |
} |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2537 |
|
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
330
diff
changeset
|
2538 |
static void do_disconnect(char *arg) |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2539 |
{ |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2540 |
jb_disconnect(); |
1014
99c5278bf6b8
Keep the status and status messages when we're disconnected
Mikael Berthe <mikael@lilotux.net>
parents:
1012
diff
changeset
|
2541 |
AutoConnection = false; |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
290
diff
changeset
|
2542 |
} |
576 | 2543 |
|
868
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
2544 |
static void do_help(char *arg) |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
2545 |
{ |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
2546 |
help_process(arg); |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
2547 |
} |
cefdaeb42e67
Add online /help command
Mikael Berthe <mikael@lilotux.net>
parents:
867
diff
changeset
|
2548 |
|
580 | 2549 |
/* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |