author | franky |
Sun, 19 Feb 2017 18:55:12 +0100 | |
changeset 2312 | def5f64c253d |
parent 2303 | 4f3821bda633 |
child 2347 | db8de1b464d3 |
permissions | -rw-r--r-- |
1599 | 1 |
/* |
2 |
* xmpp_iq.c -- Jabber protocol IQ-related stuff |
|
3 |
* |
|
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1701
diff
changeset
|
4 |
* Copyright (C) 2008-2010 Frank Zschockelt <mcabber@freakysoft.de> |
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1701
diff
changeset
|
5 |
* Copyright (C) 2005-2010 Mikael Berthe <mikael@lilotux.net> |
1599 | 6 |
* Parts come from the centericq project: |
7 |
* Copyright (C) 2002-2005 by Konstantin Klyagin <konst@konst.org.ua> |
|
8 |
* Some small parts come from the Pidgin project <http://pidgin.im/> |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or modify |
|
11 |
* it under the terms of the GNU General Public License as published by |
|
12 |
* the Free Software Foundation; either version 2 of the License, or (at |
|
13 |
* your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, but |
|
16 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 |
* General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
2268
f5402d705f67
Fix FSF addresses in all files
Mikael Berthe <mikael@lilotux.net>
parents:
2210
diff
changeset
|
21 |
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
1599 | 22 |
*/ |
1598 | 23 |
|
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
24 |
#include <string.h> |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
25 |
#include <sys/utsname.h> |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
26 |
|
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
27 |
#include "xmpp_helper.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
28 |
#include "commands.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
29 |
#include "screen.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
30 |
#include "utils.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
31 |
#include "logprint.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
32 |
#include "settings.h" |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
33 |
#include "caps.h" |
1654
fca9a4c17432
Improve UI latency and CPU usage
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1652
diff
changeset
|
34 |
#include "main.h" |
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
35 |
|
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
36 |
extern struct xmpp_error xmpp_errors[]; |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
37 |
|
1598 | 38 |
static LmHandlerResult handle_iq_command_set_status(LmMessageHandler *h, |
39 |
LmConnection *c, |
|
40 |
LmMessage *m, |
|
41 |
gpointer ud); |
|
29 | 42 |
|
1598 | 43 |
static LmHandlerResult handle_iq_command_leave_groupchats(LmMessageHandler *h, |
44 |
LmConnection *c, |
|
45 |
LmMessage *m, |
|
46 |
gpointer ud); |
|
29 | 47 |
|
1598 | 48 |
inline double seconds_since_last_use(void); |
29 | 49 |
|
1598 | 50 |
struct adhoc_command { |
51 |
char *name; |
|
52 |
char *description; |
|
53 |
bool only_for_self; |
|
54 |
LmHandleMessageFunction callback; |
|
1378 | 55 |
}; |
56 |
||
1598 | 57 |
const struct adhoc_command adhoc_command_list[] = { |
58 |
{ "http://jabber.org/protocol/rc#set-status", |
|
59 |
"Change client status", |
|
60 |
1, |
|
61 |
&handle_iq_command_set_status }, |
|
62 |
{ "http://jabber.org/protocol/rc#leave-groupchats", |
|
63 |
"Leave groupchat(s)", |
|
64 |
1, |
|
65 |
&handle_iq_command_leave_groupchats }, |
|
66 |
{ NULL, NULL, 0, NULL }, |
|
67 |
}; |
|
1383 | 68 |
|
1598 | 69 |
struct adhoc_status { |
70 |
char *name; // the name used by adhoc |
|
71 |
char *description; |
|
72 |
char *status; // the string, used by setstus |
|
73 |
}; |
|
74 |
// It has to match imstatus of roster.h! |
|
75 |
const struct adhoc_status adhoc_status_list[] = { |
|
76 |
{"offline", "Offline", "offline"}, |
|
77 |
{"online", "Online", "avail"}, |
|
78 |
{"chat", "Chat", "free"}, |
|
79 |
{"dnd", "Do not disturb", "dnd"}, |
|
2083
ec0a361f3ff1
Fix typo in form field value for set-status remote command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
2067
diff
changeset
|
80 |
{"xa", "Extended away", "notavail"}, |
1598 | 81 |
{"away", "Away", "away"}, |
2002
a0437e179b35
Remove invisible status from remote command form
Hermitifier
parents:
1999
diff
changeset
|
82 |
#ifdef WITH_DEPRECATED_STATUS_INVISIBLE |
1598 | 83 |
{"invisible", "Invisible", "invisible"}, |
2002
a0437e179b35
Remove invisible status from remote command form
Hermitifier
parents:
1999
diff
changeset
|
84 |
#endif |
1598 | 85 |
{NULL, NULL, NULL}, |
86 |
}; |
|
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
87 |
|
1598 | 88 |
static char *generate_session_id(char *prefix) |
29 | 89 |
{ |
1598 | 90 |
char *result; |
91 |
static int counter = 0; |
|
92 |
counter++; |
|
93 |
// TODO better use timestamp? |
|
94 |
result = g_strdup_printf("%s-%i", prefix, counter); |
|
95 |
return result; |
|
29 | 96 |
} |
97 |
||
1598 | 98 |
static LmMessage *lm_message_new_iq_error(LmMessage *m, guint error) |
29 | 99 |
{ |
1598 | 100 |
LmMessage *r; |
101 |
LmMessageNode *err; |
|
102 |
int i; |
|
103 |
||
2210 | 104 |
if (G_UNLIKELY(!m)) return NULL; |
105 |
||
1598 | 106 |
for (i = 0; xmpp_errors[i].code; ++i) |
107 |
if (xmpp_errors[i].code == error) |
|
108 |
break; |
|
109 |
g_return_val_if_fail(xmpp_errors[i].code > 0, NULL); |
|
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
110 |
|
1598 | 111 |
r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_ERROR); |
112 |
err = lm_message_node_add_child(r->node, "error", NULL); |
|
113 |
lm_message_node_set_attribute(err, "code", xmpp_errors[i].code_str); |
|
114 |
lm_message_node_set_attribute(err, "type", xmpp_errors[i].type); |
|
115 |
lm_message_node_set_attribute |
|
116 |
(lm_message_node_add_child(err, |
|
117 |
xmpp_errors[i].condition, NULL), |
|
118 |
"xmlns", NS_XMPP_STANZAS); |
|
634
f3c05d5fe459
Send "</stream:stream>" when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
633
diff
changeset
|
119 |
|
1598 | 120 |
return r; |
436 | 121 |
} |
122 |
||
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
123 |
void send_iq_error(LmConnection *c, LmMessage *m, guint error) |
1001
dff25377c11f
Auto-reconnect after a network/server failure
Mikael Berthe <mikael@lilotux.net>
parents:
999
diff
changeset
|
124 |
{ |
1598 | 125 |
LmMessage *r; |
126 |
r = lm_message_new_iq_error(m, error); |
|
2210 | 127 |
if (r) { |
128 |
lm_connection_send(c, r, NULL); |
|
129 |
lm_message_unref(r); |
|
130 |
} |
|
1001
dff25377c11f
Auto-reconnect after a network/server failure
Mikael Berthe <mikael@lilotux.net>
parents:
999
diff
changeset
|
131 |
} |
dff25377c11f
Auto-reconnect after a network/server failure
Mikael Berthe <mikael@lilotux.net>
parents:
999
diff
changeset
|
132 |
|
1598 | 133 |
static void lm_message_node_add_dataform_result(LmMessageNode *node, |
134 |
const char *message) |
|
29 | 135 |
{ |
1598 | 136 |
LmMessageNode *x, *field; |
939
12fa2ae6445d
Get rid of "busy-waiting" (Christof Meerwald)
Mikael Berthe <mikael@lilotux.net>
parents:
924
diff
changeset
|
137 |
|
1598 | 138 |
x = lm_message_node_add_child(node, "x", NULL); |
139 |
lm_message_node_set_attributes(x, |
|
140 |
"type", "result", |
|
141 |
"xmlns", "jabber:x:data", |
|
142 |
NULL); |
|
143 |
field = lm_message_node_add_child(x, "field", NULL); |
|
144 |
lm_message_node_set_attributes(field, |
|
145 |
"type", "text-single", |
|
146 |
"var", "message", |
|
147 |
NULL); |
|
148 |
lm_message_node_add_child(field, "value", message); |
|
149 |
} |
|
1439
fd09c95bc2b5
Wake up less often when not connected to the server
Mikael Berthe <mikael@lilotux.net>
parents:
1435
diff
changeset
|
150 |
|
1701
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
151 |
// Dummy handler to ignore IQ response |
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
152 |
LmHandlerResult handle_iq_dummy(LmMessageHandler *h, LmConnection *c, |
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
153 |
LmMessage *m, gpointer ud) |
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
154 |
{ |
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
155 |
LmMessageSubType mstype = lm_message_get_sub_type(m); |
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
156 |
if (mstype == LM_MESSAGE_SUB_TYPE_ERROR) { |
1800
d2747442918a
When displaying a server error, show the sender JID
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
157 |
display_server_error(lm_message_node_get_child(m->node, "error"), |
d2747442918a
When displaying a server error, show the sender JID
Mikael Berthe <mikael@lilotux.net>
parents:
1780
diff
changeset
|
158 |
lm_message_get_from(m)); |
1701
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
159 |
} |
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
160 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
161 |
} |
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
162 |
|
1598 | 163 |
static LmHandlerResult handle_iq_commands_list(LmMessageHandler *h, |
164 |
LmConnection *c, |
|
165 |
LmMessage *m, gpointer ud) |
|
166 |
{ |
|
167 |
LmMessage *iq; |
|
168 |
LmMessageNode *query; |
|
169 |
const char *requester_jid; |
|
170 |
const struct adhoc_command *command; |
|
171 |
const char *node; |
|
172 |
gboolean from_self; |
|
940 | 173 |
|
1598 | 174 |
iq = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT); |
175 |
query = lm_message_node_add_child(iq->node, "query", NULL); |
|
1667
8af0e0ad20ad
Fix some more xmlns attributes in IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1666
diff
changeset
|
176 |
lm_message_node_set_attribute(query, "xmlns", NS_COMMANDS); |
1598 | 177 |
node = lm_message_node_get_attribute |
178 |
(lm_message_node_get_child(m->node, "query"), |
|
179 |
"node"); |
|
180 |
if (node) |
|
181 |
lm_message_node_set_attribute(query, "node", node); |
|
29 | 182 |
|
1598 | 183 |
requester_jid = lm_message_get_from(m); |
184 |
from_self = jid_equal(lm_connection_get_jid(c), requester_jid); |
|
686
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
684
diff
changeset
|
185 |
|
1598 | 186 |
for (command = adhoc_command_list ; command->name ; command++) { |
187 |
if (!command->only_for_self || from_self) { |
|
188 |
lm_message_node_set_attributes |
|
189 |
(lm_message_node_add_child(query, "item", NULL), |
|
190 |
"node", command->name, |
|
191 |
"name", command->description, |
|
192 |
"jid", lm_connection_get_jid(c), |
|
193 |
NULL); |
|
29 | 194 |
} |
195 |
} |
|
196 |
||
1598 | 197 |
lm_connection_send(c, iq, NULL); |
198 |
lm_message_unref(iq); |
|
199 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
534 | 200 |
} |
201 |
||
1598 | 202 |
static LmHandlerResult handle_iq_command_set_status(LmMessageHandler *h, |
203 |
LmConnection *c, |
|
204 |
LmMessage *m, gpointer ud) |
|
988
6e2bfd1ffded
Add ids to message stanzas if needed
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
205 |
{ |
1598 | 206 |
const char *action, *node; |
207 |
char *sessionid; |
|
208 |
LmMessage *iq; |
|
209 |
LmMessageNode *command, *x, *y; |
|
210 |
const struct adhoc_status *s; |
|
211 |
||
212 |
x = lm_message_node_get_child(m->node, "command"); |
|
213 |
action = lm_message_node_get_attribute(x, "action"); |
|
214 |
node = lm_message_node_get_attribute(x, "node"); |
|
215 |
sessionid = (char *)lm_message_node_get_attribute(x, "sessionid"); |
|
216 |
||
217 |
iq = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT); |
|
218 |
command = lm_message_node_add_child(iq->node, "command", NULL); |
|
219 |
lm_message_node_set_attribute(command, "node", node); |
|
220 |
lm_message_node_set_attribute(command, "xmlns", NS_COMMANDS); |
|
221 |
||
222 |
if (!sessionid) { |
|
223 |
sessionid = generate_session_id("set-status"); |
|
224 |
lm_message_node_set_attribute(command, "sessionid", sessionid); |
|
225 |
g_free(sessionid); |
|
226 |
sessionid = NULL; |
|
227 |
lm_message_node_set_attribute(command, "status", "executing"); |
|
988
6e2bfd1ffded
Add ids to message stanzas if needed
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
228 |
|
1598 | 229 |
x = lm_message_node_add_child(command, "x", NULL); |
230 |
lm_message_node_set_attribute(x, "type", "form"); |
|
231 |
lm_message_node_set_attribute(x, "xmlns", "jabber:x:data"); |
|
232 |
||
233 |
lm_message_node_add_child(x, "title", "Change Status"); |
|
234 |
||
235 |
lm_message_node_add_child(x, "instructions", |
|
236 |
"Choose the status and status message"); |
|
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
444
diff
changeset
|
237 |
|
1598 | 238 |
// TODO see if factorisation is possible |
239 |
y = lm_message_node_add_child(x, "field", NULL); |
|
240 |
lm_message_node_set_attribute(y, "type", "hidden"); |
|
241 |
lm_message_node_set_attribute(y, "var", "FORM_TYPE"); |
|
242 |
||
243 |
lm_message_node_add_child(y, "value", "http://jabber.org/protocol/rc"); |
|
1055
6eb1efea75d0
PGP: Visual encryption flag
Mikael Berthe <mikael@lilotux.net>
parents:
1053
diff
changeset
|
244 |
|
1598 | 245 |
y = lm_message_node_add_child(x, "field", NULL); |
246 |
lm_message_node_set_attributes(y, |
|
247 |
"type", "list-single", |
|
248 |
"var", "status", |
|
249 |
"label", "Status", |
|
250 |
NULL); |
|
251 |
lm_message_node_add_child(y, "required", NULL); |
|
472
75442262c082
Disable some commands when not connected
Mikael Berthe <mikael@lilotux.net>
parents:
470
diff
changeset
|
252 |
|
1598 | 253 |
// XXX: ugly |
254 |
lm_message_node_add_child(y, "value", |
|
255 |
adhoc_status_list[xmpp_getstatus()].name); |
|
256 |
for (s = adhoc_status_list; s->name; s++) { |
|
257 |
LmMessageNode *option = lm_message_node_add_child(y, "option", NULL); |
|
258 |
lm_message_node_add_child(option, "value", s->name); |
|
259 |
lm_message_node_set_attribute(option, "label", s->description); |
|
1299
3b338a5c01fc
OTR support
Frank Zschockelt <mcabber_otr[at]freakysoft.de>
parents:
1290
diff
changeset
|
260 |
} |
1598 | 261 |
// TODO add priority ? |
262 |
// I do not think this is useful, user should not have to care of the |
|
263 |
// priority like gossip and gajim do (misc) |
|
264 |
lm_message_node_set_attributes |
|
265 |
(lm_message_node_add_child(x, "field", NULL), |
|
266 |
"type", "text-multi", |
|
267 |
"var", "status-message", |
|
268 |
"label", "Message", |
|
269 |
NULL); |
|
270 |
} else if (action && !strcmp(action, "cancel")) { |
|
271 |
lm_message_node_set_attribute(command, "status", "canceled"); |
|
272 |
} else { // (if sessionid and not canceled) |
|
273 |
y = lm_message_node_find_xmlns(x, "jabber:x:data"); //x?xmlns=jabber:x:data |
|
274 |
if (y) { |
|
275 |
const char *value=NULL, *message=NULL; |
|
276 |
LmMessageNode *fields, *field; |
|
277 |
field = fields = lm_message_node_get_child(y, "field"); //field?var=status |
|
278 |
while (field && strcmp("status", |
|
279 |
lm_message_node_get_attribute(field, "var"))) |
|
280 |
field = field->next; |
|
281 |
field = lm_message_node_get_child(field, "value"); |
|
282 |
if (field) |
|
283 |
value = lm_message_node_get_value(field); |
|
284 |
field = fields; //field?var=status-message |
|
285 |
while (field && strcmp("status-message", |
|
286 |
lm_message_node_get_attribute(field, "var"))) |
|
287 |
field = field->next; |
|
288 |
field = lm_message_node_get_child(field, "value"); |
|
289 |
if (field) |
|
290 |
message = lm_message_node_get_value(field); |
|
291 |
if (value) { |
|
292 |
for (s = adhoc_status_list; !s->name || strcmp(s->name, value); s++); |
|
293 |
if (s->name) { |
|
294 |
char *status = g_strdup_printf("%s %s", s->status, |
|
295 |
message ? message : ""); |
|
296 |
cmd_setstatus(NULL, status); |
|
297 |
g_free(status); |
|
298 |
lm_message_node_set_attribute(command, "status", "completed"); |
|
299 |
lm_message_node_add_dataform_result(command, |
|
300 |
"Status has been changed"); |
|
1197 | 301 |
} |
1067
a5dc85fdebde
Add key comparison for signatures & use user-provided PGP keys for encryption
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
302 |
} |
1065
230dca34dbea
Extand pgp_data structure
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
303 |
} |
1044
52cfe9bf9840
Encryption support for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
1043
diff
changeset
|
304 |
} |
1598 | 305 |
if (sessionid) |
306 |
lm_message_node_set_attribute(command, "sessionid", sessionid); |
|
307 |
lm_connection_send(c, iq, NULL); |
|
308 |
lm_message_unref(iq); |
|
309 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
310 |
} |
|
1067
a5dc85fdebde
Add key comparison for signatures & use user-provided PGP keys for encryption
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
311 |
|
1598 | 312 |
static void _callback_foreach_buddy_groupchat(gpointer rosterdata, void *param) |
313 |
{ |
|
1665
1a4890514eb9
Clean up some dead assignments/dead variables
Ulrich Spörlein
parents:
1654
diff
changeset
|
314 |
LmMessageNode *field, *option; |
1598 | 315 |
const char *room_jid, *nickname; |
316 |
char *desc; |
|
317 |
||
318 |
room_jid = buddy_getjid(rosterdata); |
|
319 |
if (!room_jid) return; |
|
320 |
nickname = buddy_getnickname(rosterdata); |
|
321 |
if (!nickname) return; |
|
322 |
field = param; |
|
1044
52cfe9bf9840
Encryption support for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
1043
diff
changeset
|
323 |
|
1598 | 324 |
option = lm_message_node_add_child(field, "option", NULL); |
1665
1a4890514eb9
Clean up some dead assignments/dead variables
Ulrich Spörlein
parents:
1654
diff
changeset
|
325 |
lm_message_node_add_child(option, "value", room_jid); |
1598 | 326 |
desc = g_strdup_printf("%s on %s", nickname, room_jid); |
327 |
lm_message_node_set_attribute(option, "label", desc); |
|
328 |
g_free(desc); |
|
329 |
} |
|
1044
52cfe9bf9840
Encryption support for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
1043
diff
changeset
|
330 |
|
1598 | 331 |
static LmHandlerResult handle_iq_command_leave_groupchats(LmMessageHandler *h, |
332 |
LmConnection *c, |
|
333 |
LmMessage *m, |
|
334 |
gpointer ud) |
|
335 |
{ |
|
336 |
const char *action, *node; |
|
337 |
char *sessionid; |
|
338 |
LmMessage *iq; |
|
339 |
LmMessageNode *command, *x; |
|
1044
52cfe9bf9840
Encryption support for outgoing messages
Mikael Berthe <mikael@lilotux.net>
parents:
1043
diff
changeset
|
340 |
|
1598 | 341 |
x = lm_message_node_get_child(m->node, "command"); |
2210 | 342 |
if (!x) |
343 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
344 |
||
1598 | 345 |
action = lm_message_node_get_attribute(x, "action"); |
346 |
node = lm_message_node_get_attribute(x, "node"); |
|
347 |
sessionid = (char*)lm_message_node_get_attribute(x, "sessionid"); |
|
348 |
||
349 |
iq = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT); |
|
350 |
command = lm_message_node_add_child(iq->node, "command", NULL); |
|
351 |
lm_message_node_set_attributes(command, |
|
352 |
"node", node, |
|
353 |
"xmlns", NS_COMMANDS, |
|
354 |
NULL); |
|
355 |
||
356 |
if (!sessionid) { |
|
357 |
LmMessageNode *field; |
|
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
358 |
|
1598 | 359 |
sessionid = generate_session_id("leave-groupchats"); |
360 |
lm_message_node_set_attribute(command, "sessionid", sessionid); |
|
361 |
g_free(sessionid); |
|
362 |
sessionid = NULL; |
|
363 |
lm_message_node_set_attribute(command, "status", "executing"); |
|
364 |
||
365 |
x = lm_message_node_add_child(command, "x", NULL); |
|
366 |
lm_message_node_set_attributes(x, |
|
367 |
"type", "form", |
|
368 |
"xmlns", "jabber:x:data", |
|
369 |
NULL); |
|
370 |
||
371 |
lm_message_node_add_child(x, "title", "Leave groupchat(s)"); |
|
372 |
||
373 |
lm_message_node_add_child(x, "instructions", |
|
374 |
"What groupchats do you want to leave?"); |
|
375 |
||
376 |
field = lm_message_node_add_child(x, "field", NULL); |
|
377 |
lm_message_node_set_attributes(field, |
|
378 |
"type", "hidden", |
|
379 |
"var", "FORM_TYPE", |
|
380 |
NULL); |
|
381 |
||
382 |
lm_message_node_add_child(field, "value", |
|
383 |
"http://jabber.org/protocol/rc"); |
|
988
6e2bfd1ffded
Add ids to message stanzas if needed
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
384 |
|
1598 | 385 |
field = lm_message_node_add_child(x, "field", NULL); |
386 |
lm_message_node_set_attributes(field, |
|
387 |
"type", "list-multi", |
|
388 |
"var", "groupchats", |
|
389 |
"label", "Groupchats: ", |
|
390 |
NULL); |
|
391 |
lm_message_node_add_child(field, "required", NULL); |
|
392 |
||
393 |
foreach_buddy(ROSTER_TYPE_ROOM, &_callback_foreach_buddy_groupchat, field); |
|
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1701
diff
changeset
|
394 |
// TODO: return an error if we are not connected to groupchats |
1598 | 395 |
} else if (action && !strcmp(action, "cancel")) { |
396 |
lm_message_node_set_attribute(command, "status", "canceled"); |
|
397 |
} else { // (if sessionid and not canceled) |
|
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1701
diff
changeset
|
398 |
LmMessageNode *form = lm_message_node_find_xmlns(x, "jabber:x:data");// TODO |
1598 | 399 |
if (form) { |
400 |
LmMessageNode *field; |
|
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
989
diff
changeset
|
401 |
|
1598 | 402 |
lm_message_node_set_attribute(command, "status", "completed"); |
1729
e6e89b1d7831
Minor style and header updates
Mikael Berthe <mikael@lilotux.net>
parents:
1701
diff
changeset
|
403 |
// TODO: implement sth. like "field?var=groupchats" in xmlnode... |
1598 | 404 |
field = lm_message_node_get_child(form, "field"); |
405 |
while (field && strcmp("groupchats", |
|
406 |
lm_message_node_get_attribute(field, "var"))) |
|
407 |
field = field->next; |
|
408 |
||
1652
8036750d0169
Fix leave_groupchats remote command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1637
diff
changeset
|
409 |
if (field) |
8036750d0169
Fix leave_groupchats remote command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1637
diff
changeset
|
410 |
for (x = field->children ; x ; x = x->next) |
8036750d0169
Fix leave_groupchats remote command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1637
diff
changeset
|
411 |
{ |
8036750d0169
Fix leave_groupchats remote command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1637
diff
changeset
|
412 |
if (!strcmp (x->name, "value")) { |
8036750d0169
Fix leave_groupchats remote command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1637
diff
changeset
|
413 |
GList* b = buddy_search_jid(lm_message_node_get_value(x)); |
8036750d0169
Fix leave_groupchats remote command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1637
diff
changeset
|
414 |
if (b) |
8036750d0169
Fix leave_groupchats remote command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1637
diff
changeset
|
415 |
cmd_room_leave(b->data, "Requested by remote command"); |
8036750d0169
Fix leave_groupchats remote command
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1637
diff
changeset
|
416 |
} |
1598 | 417 |
} |
418 |
lm_message_node_add_dataform_result(command, |
|
419 |
"Groupchats have been left"); |
|
988
6e2bfd1ffded
Add ids to message stanzas if needed
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
420 |
} |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
421 |
} |
1598 | 422 |
if (sessionid) |
423 |
lm_message_node_set_attribute(command, "sessionid", sessionid); |
|
424 |
lm_connection_send(c, iq, NULL); |
|
425 |
lm_message_unref(iq); |
|
426 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
427 |
} |
|
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
428 |
|
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
429 |
LmHandlerResult handle_iq_commands(LmMessageHandler *h, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
430 |
LmConnection *c, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
431 |
LmMessage *m, gpointer ud) |
1598 | 432 |
{ |
433 |
const char *requester_jid = NULL; |
|
434 |
LmMessageNode *cmd; |
|
435 |
const struct adhoc_command *command; |
|
436 |
||
437 |
// mcabber has only partial XEP-0146 support... |
|
438 |
if (LM_MESSAGE_SUB_TYPE_SET != lm_message_get_sub_type(m)) |
|
439 |
return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; |
|
440 |
||
441 |
requester_jid = lm_message_get_from(m); |
|
988
6e2bfd1ffded
Add ids to message stanzas if needed
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
442 |
|
1598 | 443 |
cmd = lm_message_node_get_child(m->node, "command"); |
2210 | 444 |
if (!cmd) { |
445 |
//send_iq_error(c, m, XMPP_ERROR_BAD_REQUEST); |
|
446 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
447 |
} |
|
1598 | 448 |
if (jid_equal(lm_connection_get_jid(c), requester_jid)) { |
449 |
const char *action, *node; |
|
450 |
action = lm_message_node_get_attribute(cmd, "action"); |
|
451 |
node = lm_message_node_get_attribute(cmd, "node"); |
|
452 |
// action can be NULL, in which case it seems to take the default, |
|
453 |
// ie execute |
|
454 |
if (!action || !strcmp(action, "execute") || !strcmp(action, "cancel") |
|
455 |
|| !strcmp(action, "next") || !strcmp(action, "complete")) { |
|
456 |
for (command = adhoc_command_list; command->name; command++) { |
|
457 |
if (!strcmp(node, command->name)) |
|
458 |
command->callback(h, c, m, ud); |
|
459 |
} |
|
460 |
// "prev" action will get there, as we do not implement it, |
|
461 |
// and do not authorize it |
|
462 |
} else { |
|
463 |
LmMessage *r; |
|
464 |
LmMessageNode *err; |
|
465 |
r = lm_message_new_iq_error(m, XMPP_ERROR_BAD_REQUEST); |
|
2210 | 466 |
if (r) { |
467 |
err = lm_message_node_get_child(r->node, "error"); |
|
468 |
lm_message_node_set_attribute |
|
469 |
(lm_message_node_add_child(err, "malformed-action", NULL), |
|
470 |
"xmlns", NS_COMMANDS); |
|
471 |
lm_connection_send(c, r, NULL); |
|
472 |
lm_message_unref(r); |
|
473 |
} |
|
1598 | 474 |
} |
475 |
} else { |
|
476 |
send_iq_error(c, m, XMPP_ERROR_FORBIDDEN); |
|
477 |
} |
|
478 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
35 | 479 |
} |
480 |
||
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
989
diff
changeset
|
481 |
|
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
482 |
LmHandlerResult handle_iq_disco_items(LmMessageHandler *h, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
483 |
LmConnection *c, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
484 |
LmMessage *m, gpointer ud) |
990
35e7913affb7
Send events/chatstates notifications (JEP-22/JEP-85)
Mikael Berthe <mikael@lilotux.net>
parents:
989
diff
changeset
|
485 |
{ |
1598 | 486 |
LmMessageNode *query; |
2210 | 487 |
const char *node = NULL; |
1598 | 488 |
query = lm_message_node_get_child(m->node, "query"); |
2210 | 489 |
if (query) |
490 |
node = lm_message_node_get_attribute(query, "node"); |
|
1598 | 491 |
if (node) { |
492 |
if (!strcmp(node, NS_COMMANDS)) { |
|
493 |
return handle_iq_commands_list(NULL, c, m, ud); |
|
494 |
} else { |
|
495 |
send_iq_error(c, m, XMPP_ERROR_NOT_IMPLEMENTED); |
|
1091
10f9d6fcfeab
JEP85: Reset composing/paused state when a resource with higher prio comes up
Mikael Berthe <mikael@lilotux.net>
parents:
1072
diff
changeset
|
496 |
} |
1598 | 497 |
} else { |
498 |
// not sure about this one |
|
499 |
send_iq_error(c, m, XMPP_ERROR_NOT_IMPLEMENTED); |
|
205 | 500 |
} |
1598 | 501 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
1395
d431cd75eb53
Use bookmarked nickname when manually joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
1385
diff
changeset
|
502 |
} |
d431cd75eb53
Use bookmarked nickname when manually joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
1385
diff
changeset
|
503 |
|
d431cd75eb53
Use bookmarked nickname when manually joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
1385
diff
changeset
|
504 |
|
1600 | 505 |
void _disco_add_feature_helper(gpointer data, gpointer user_data) |
1163
2913310a7be6
Make /roster bookmark in the status buffer show all bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1161
diff
changeset
|
506 |
{ |
1600 | 507 |
LmMessageNode *node = user_data; |
508 |
lm_message_node_set_attribute |
|
509 |
(lm_message_node_add_child(node, "feature", NULL), "var", data); |
|
1016 | 510 |
} |
511 |
||
1600 | 512 |
// disco_info_set_caps(ansquery, entitycaps) |
513 |
// Add features attributes to ansquery. entitycaps should either be a |
|
514 |
// valid capabilities hash or NULL. If it is NULL, the node attribute won't |
|
515 |
// be added to the query child and Entity Capabilities will be announced |
|
516 |
// as a feature. |
|
1598 | 517 |
// Please change the entity version string if you modify mcabber disco |
518 |
// source code, so that it doesn't conflict with the upstream client. |
|
1600 | 519 |
static void disco_info_set_caps(LmMessageNode *ansquery, |
520 |
const char *entitycaps) |
|
1016 | 521 |
{ |
1600 | 522 |
if (entitycaps) { |
523 |
char *eversion; |
|
524 |
eversion = g_strdup_printf("%s#%s", MCABBER_CAPS_NODE, entitycaps); |
|
525 |
lm_message_node_set_attribute(ansquery, "node", eversion); |
|
526 |
g_free(eversion); |
|
527 |
} |
|
1016 | 528 |
|
1600 | 529 |
lm_message_node_set_attributes |
530 |
(lm_message_node_add_child(ansquery, "identity", NULL), |
|
531 |
"category", "client", |
|
532 |
"name", PACKAGE_STRING, |
|
533 |
"type", "pc", |
|
534 |
NULL); |
|
1016 | 535 |
|
1600 | 536 |
if (entitycaps) |
537 |
caps_foreach_feature(entitycaps, _disco_add_feature_helper, ansquery); |
|
1999
51f032d5ca22
Add support for XEP-0115 Entity Capabilities, with offline cache
Hermitifier
parents:
1919
diff
changeset
|
538 |
else |
1600 | 539 |
caps_foreach_feature(entity_version(xmpp_getstatus()), |
540 |
_disco_add_feature_helper, |
|
541 |
ansquery); |
|
1016 | 542 |
} |
543 |
||
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
544 |
LmHandlerResult handle_iq_disco_info(LmMessageHandler *h, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
545 |
LmConnection *c, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
546 |
LmMessage *m, gpointer ud) |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1042
diff
changeset
|
547 |
{ |
1598 | 548 |
LmMessage *r; |
549 |
LmMessageNode *query, *tmp; |
|
550 |
const char *node = NULL; |
|
1600 | 551 |
const char *param = NULL; |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1042
diff
changeset
|
552 |
|
1637
e38300775548
Do not reply to disco "result" IQ messages
Mikael Berthe <mikael@lilotux.net>
parents:
1615
diff
changeset
|
553 |
if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_RESULT) |
e38300775548
Do not reply to disco "result" IQ messages
Mikael Berthe <mikael@lilotux.net>
parents:
1615
diff
changeset
|
554 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
e38300775548
Do not reply to disco "result" IQ messages
Mikael Berthe <mikael@lilotux.net>
parents:
1615
diff
changeset
|
555 |
|
1598 | 556 |
r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT); |
557 |
query = lm_message_node_add_child(r->node, "query", NULL); |
|
558 |
lm_message_node_set_attribute(query, "xmlns", NS_DISCO_INFO); |
|
2303
4f3821bda633
LM: Use get_child in place of find_child
Mikael Berthe <mikael@lilotux.net>
parents:
2292
diff
changeset
|
559 |
tmp = lm_message_node_get_child(m->node, "query"); |
1600 | 560 |
if (tmp) { |
1598 | 561 |
node = lm_message_node_get_attribute(tmp, "node"); |
1600 | 562 |
param = node+strlen(MCABBER_CAPS_NODE)+1; |
563 |
} |
|
564 |
if (node && startswith(node, MCABBER_CAPS_NODE "#", FALSE)) |
|
565 |
disco_info_set_caps(query, param); // client#version |
|
566 |
else |
|
1598 | 567 |
// Basic discovery request |
1600 | 568 |
disco_info_set_caps(query, NULL); |
1347
07816313073b
Add an option 'otr' to enable OTR support in the configuration file
Mikael Berthe <mikael@lilotux.net>
parents:
1344
diff
changeset
|
569 |
|
1598 | 570 |
lm_connection_send(c, r, NULL); |
571 |
lm_message_unref(r); |
|
572 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
624
diff
changeset
|
573 |
} |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
624
diff
changeset
|
574 |
|
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
575 |
LmHandlerResult handle_iq_roster(LmMessageHandler *h, LmConnection *c, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
576 |
LmMessage *m, gpointer ud) |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
577 |
{ |
1598 | 578 |
LmMessageNode *y; |
579 |
const char *fjid, *name, *group, *sub, *ask; |
|
580 |
char *cleanalias; |
|
581 |
enum subscr esub; |
|
582 |
int need_refresh = FALSE; |
|
583 |
guint roster_type; |
|
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
584 |
|
2283
6e1ead98930d
Check origin of roster pushes
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
585 |
const gchar *from = lm_message_get_from(m); |
6e1ead98930d
Check origin of roster pushes
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
586 |
|
6e1ead98930d
Check origin of roster pushes
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
587 |
if (from) { |
2290 | 588 |
const gchar *self_jid = lm_connection_get_jid(c); |
589 |
gchar *servername = get_servername(self_jid, ""); |
|
590 |
if ((!jid_equal(self_jid, from)) && |
|
2283
6e1ead98930d
Check origin of roster pushes
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
591 |
(!servername || strcasecmp(from, servername))) { |
6e1ead98930d
Check origin of roster pushes
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
592 |
scr_LogPrint(LPRINT_LOGNORM, "Received invalid roster IQ request"); |
2290 | 593 |
g_free(servername); |
2283
6e1ead98930d
Check origin of roster pushes
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
594 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
6e1ead98930d
Check origin of roster pushes
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
595 |
} |
2290 | 596 |
g_free(servername); |
2283
6e1ead98930d
Check origin of roster pushes
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
597 |
} |
6e1ead98930d
Check origin of roster pushes
Mikael Berthe <mikael@lilotux.net>
parents:
2268
diff
changeset
|
598 |
|
2303
4f3821bda633
LM: Use get_child in place of find_child
Mikael Berthe <mikael@lilotux.net>
parents:
2292
diff
changeset
|
599 |
y = lm_message_node_get_child(lm_message_node_find_xmlns(m->node, NS_ROSTER), |
1701
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
600 |
"item"); |
44e023ad99ed
Add dummy handler for roster manipulation IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1668
diff
changeset
|
601 |
for ( ; y; y = y->next) { |
1598 | 602 |
char *name_tmp = NULL; |
864
a7b3409df6bc
MUC: Work around user server restart
Mikael Berthe <mikael@lilotux.net>
parents:
862
diff
changeset
|
603 |
|
1598 | 604 |
fjid = lm_message_node_get_attribute(y, "jid"); |
605 |
name = lm_message_node_get_attribute(y, "name"); |
|
606 |
sub = lm_message_node_get_attribute(y, "subscription"); |
|
607 |
ask = lm_message_node_get_attribute(y, "ask"); |
|
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
608 |
|
2303
4f3821bda633
LM: Use get_child in place of find_child
Mikael Berthe <mikael@lilotux.net>
parents:
2292
diff
changeset
|
609 |
if (lm_message_node_get_child(y, "group")) |
4f3821bda633
LM: Use get_child in place of find_child
Mikael Berthe <mikael@lilotux.net>
parents:
2292
diff
changeset
|
610 |
group = lm_message_node_get_value(lm_message_node_get_child(y, "group")); |
1598 | 611 |
else |
612 |
group = NULL; |
|
1396
8f9928839a36
Automatically unlock new rooms (suggested by Michael Weiser)
Mikael Berthe <mikael@lilotux.net>
parents:
1395
diff
changeset
|
613 |
|
1598 | 614 |
if (!fjid) |
615 |
continue; |
|
616 |
||
617 |
cleanalias = jidtodisp(fjid); |
|
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
618 |
|
1598 | 619 |
esub = sub_none; |
620 |
if (sub) { |
|
621 |
if (!strcmp(sub, "to")) esub = sub_to; |
|
622 |
else if (!strcmp(sub, "from")) esub = sub_from; |
|
623 |
else if (!strcmp(sub, "both")) esub = sub_both; |
|
624 |
else if (!strcmp(sub, "remove")) esub = sub_remove; |
|
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
625 |
} |
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
626 |
|
1598 | 627 |
if (esub == sub_remove) { |
628 |
roster_del_user(cleanalias); |
|
629 |
scr_LogPrint(LPRINT_LOGNORM, "Buddy <%s> has been removed " |
|
630 |
"from the roster", cleanalias); |
|
631 |
g_free(cleanalias); |
|
632 |
need_refresh = TRUE; |
|
633 |
continue; |
|
634 |
} |
|
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
635 |
|
1598 | 636 |
if (ask && !strcmp(ask, "subscribe")) |
637 |
esub |= sub_pending; |
|
638 |
||
639 |
if (!name) { |
|
640 |
if (!settings_opt_get_int("roster_hide_domain")) { |
|
641 |
name = cleanalias; |
|
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
642 |
} else { |
1598 | 643 |
char *p; |
644 |
name = name_tmp = g_strdup(cleanalias); |
|
645 |
p = strchr(name_tmp, JID_DOMAIN_SEPARATOR); |
|
646 |
if (p) *p = '\0'; |
|
581
ad07c868ff43
Tell the user when he or she has been kicked/banned
Mikael Berthe <mikael@lilotux.net>
parents:
580
diff
changeset
|
647 |
} |
583
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
648 |
} |
32ae027a3238
MUC: clean up departure message code
Mikael Berthe <mikael@lilotux.net>
parents:
581
diff
changeset
|
649 |
|
1598 | 650 |
// Tricky... :-\ My guess is that if there is no JID_DOMAIN_SEPARATOR, |
651 |
// this is an agent. |
|
652 |
if (strchr(cleanalias, JID_DOMAIN_SEPARATOR)) |
|
653 |
roster_type = ROSTER_TYPE_USER; |
|
654 |
else |
|
655 |
roster_type = ROSTER_TYPE_AGENT; |
|
1377
cd9182f0b5c7
Add /room setopt {print_status,auto_whois}
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
656 |
|
1598 | 657 |
roster_add_user(cleanalias, name, group, roster_type, esub, 1); |
579
0c67755e0fa7
Introduce a handle_presence_muc() function
Mikael Berthe <mikael@lilotux.net>
parents:
578
diff
changeset
|
658 |
|
1598 | 659 |
g_free(name_tmp); |
660 |
g_free(cleanalias); |
|
1446
49c8be874344
Add option 'ignore_self_presence'
Mikael Berthe <mikael@lilotux.net>
parents:
1439
diff
changeset
|
661 |
} |
49c8be874344
Add option 'ignore_self_presence'
Mikael Berthe <mikael@lilotux.net>
parents:
1439
diff
changeset
|
662 |
|
1919
fba12c1f6386
Send a result message when we receive a roster push
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
663 |
// Acknowledge IQ message |
fba12c1f6386
Send a result message when we receive a roster push
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
664 |
if (lm_message_get_sub_type(m) == LM_MESSAGE_SUB_TYPE_SET) { |
fba12c1f6386
Send a result message when we receive a roster push
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
665 |
LmMessage *result; |
fba12c1f6386
Send a result message when we receive a roster push
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
666 |
result = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT); |
fba12c1f6386
Send a result message when we receive a roster push
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
667 |
lm_connection_send(c, result, NULL); |
fba12c1f6386
Send a result message when we receive a roster push
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
668 |
lm_message_unref(result); |
fba12c1f6386
Send a result message when we receive a roster push
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
669 |
} |
fba12c1f6386
Send a result message when we receive a roster push
Mikael Berthe <mikael@lilotux.net>
parents:
1811
diff
changeset
|
670 |
|
2292
f181418db215
Replace global variable update_roster with scr_update_roster()
franky
parents:
2291
diff
changeset
|
671 |
scr_update_roster(); |
1598 | 672 |
if (need_refresh) |
1780
e4378fbab5d7
Major API cleanup - bump API to 4
Mikael Berthe <mikael@lilotux.net>
parents:
1729
diff
changeset
|
673 |
scr_update_buddy_window(); |
1598 | 674 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
675 |
} |
|
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
676 |
|
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
677 |
LmHandlerResult handle_iq_ping(LmMessageHandler *h, LmConnection *c, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
678 |
LmMessage *m, gpointer ud) |
1598 | 679 |
{ |
680 |
LmMessage *r; |
|
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
681 |
|
1598 | 682 |
r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT); |
683 |
lm_connection_send(c, r, NULL); |
|
684 |
lm_message_unref(r); |
|
685 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
686 |
} |
|
687 |
||
688 |
double seconds_since_last_use(void) |
|
689 |
{ |
|
690 |
return difftime(time(NULL), iqlast); |
|
691 |
} |
|
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
643
diff
changeset
|
692 |
|
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
693 |
LmHandlerResult handle_iq_last(LmMessageHandler *h, LmConnection *c, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
694 |
LmMessage *m, gpointer ud) |
1598 | 695 |
{ |
696 |
LmMessage *r; |
|
697 |
LmMessageNode *query; |
|
698 |
char *seconds; |
|
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
699 |
|
1598 | 700 |
if (!settings_opt_get_int("iq_hide_requests")) { |
701 |
scr_LogPrint(LPRINT_LOGNORM, "Received an IQ last time request from <%s>", |
|
702 |
lm_message_get_from(m)); |
|
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
703 |
} |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
704 |
|
1598 | 705 |
if (settings_opt_get_int("iq_last_disable") || |
706 |
(settings_opt_get_int("iq_last_disable_when_notavail") && |
|
707 |
xmpp_getstatus() == notavail)) |
|
708 |
{ |
|
709 |
send_iq_error(c, m, XMPP_ERROR_SERVICE_UNAVAILABLE); |
|
710 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
711 |
} |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
712 |
|
1598 | 713 |
r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT); |
714 |
query = lm_message_node_add_child(r->node, "query", NULL); |
|
1667
8af0e0ad20ad
Fix some more xmlns attributes in IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1666
diff
changeset
|
715 |
lm_message_node_set_attribute(query, "xmlns", NS_LAST); |
1598 | 716 |
seconds = g_strdup_printf("%.0f", seconds_since_last_use()); |
717 |
lm_message_node_set_attribute(query, "seconds", seconds); |
|
718 |
g_free(seconds); |
|
1236
f7b35b1c343d
Fix a roster bug when receiving a MUC invitation
Mikael Berthe <mikael@lilotux.net>
parents:
1215
diff
changeset
|
719 |
|
1598 | 720 |
lm_connection_send(c, r, NULL); |
721 |
lm_message_unref(r); |
|
722 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
1128 | 723 |
} |
724 |
||
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
725 |
LmHandlerResult handle_iq_version(LmMessageHandler *h, LmConnection *c, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
726 |
LmMessage *m, gpointer ud) |
1128 | 727 |
{ |
1598 | 728 |
LmMessage *r; |
729 |
LmMessageNode *query; |
|
1128 | 730 |
|
1598 | 731 |
if (!settings_opt_get_int("iq_hide_requests")) { |
732 |
scr_LogPrint(LPRINT_LOGNORM, "Received an IQ version request from <%s>", |
|
733 |
lm_message_get_from(m)); |
|
734 |
} |
|
2066
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
735 |
|
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
736 |
if (settings_opt_get_int("iq_version_hide")) { |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
737 |
send_iq_error(c, m, XMPP_ERROR_SERVICE_UNAVAILABLE); |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
738 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
1128 | 739 |
} |
1598 | 740 |
|
741 |
r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT); |
|
742 |
||
743 |
query = lm_message_node_add_child(r->node, "query", NULL); |
|
1666
68c57f52d05a
Fix iq version reply (issue #42, patch from foxfell)
Mikael Berthe <mikael@lilotux.net>
parents:
1665
diff
changeset
|
744 |
lm_message_node_set_attribute(query, "xmlns", NS_VERSION); |
1598 | 745 |
|
746 |
lm_message_node_add_child(query, "name", PACKAGE_NAME); |
|
2066
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
747 |
|
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
748 |
// MCabber version |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
749 |
if (!settings_opt_get_int("iq_version_hide_version")) { |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
750 |
char *ver = mcabber_version(); |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
751 |
lm_message_node_add_child(query, "version", ver); |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
752 |
g_free(ver); |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
753 |
} |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
754 |
|
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
755 |
// OS details |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
756 |
if (!settings_opt_get_int("iq_version_hide_os")) { |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
757 |
char *os; |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
758 |
struct utsname osinfo; |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
759 |
uname(&osinfo); |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
760 |
os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release, |
69699ba3010f
Add 'iq_version_hide', 'iq_version_hide_version'
Mikael Berthe <mikael@lilotux.net>
parents:
2065
diff
changeset
|
761 |
osinfo.machine); |
1598 | 762 |
lm_message_node_add_child(query, "os", os); |
763 |
g_free(os); |
|
764 |
} |
|
765 |
||
766 |
lm_connection_send(c, r, NULL); |
|
767 |
lm_message_unref(r); |
|
768 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
1128 | 769 |
} |
770 |
||
1598 | 771 |
// This function borrows some code from the Pidgin project |
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
772 |
LmHandlerResult handle_iq_time(LmMessageHandler *h, LmConnection *c, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
773 |
LmMessage *m, gpointer ud) |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
774 |
{ |
1598 | 775 |
LmMessage *r; |
776 |
LmMessageNode *query; |
|
777 |
char *buf, *utf8_buf; |
|
778 |
time_t now_t; |
|
779 |
struct tm *now; |
|
1528
4b4b3948420c
MUC fix: the topic couldn't be cleared
Mikael Berthe <mikael@lilotux.net>
parents:
1525
diff
changeset
|
780 |
|
1598 | 781 |
time(&now_t); |
782 |
||
783 |
if (!settings_opt_get_int("iq_hide_requests")) { |
|
784 |
scr_LogPrint(LPRINT_LOGNORM, "Received an IQ time request from <%s>", |
|
785 |
lm_message_get_from(m)); |
|
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
786 |
} |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
787 |
|
2067
79659eb4f66f
Rename 'iq_version_hide_time' to 'iq_time_hide'
Mikael Berthe <mikael@lilotux.net>
parents:
2066
diff
changeset
|
788 |
if (settings_opt_get_int("iq_time_hide")) { |
2065
c09fc3834c69
Add option 'iq_version_hide_time'
Mikael Berthe <mikael@lilotux.net>
parents:
2002
diff
changeset
|
789 |
send_iq_error(c, m, XMPP_ERROR_SERVICE_UNAVAILABLE); |
c09fc3834c69
Add option 'iq_version_hide_time'
Mikael Berthe <mikael@lilotux.net>
parents:
2002
diff
changeset
|
790 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
c09fc3834c69
Add option 'iq_version_hide_time'
Mikael Berthe <mikael@lilotux.net>
parents:
2002
diff
changeset
|
791 |
} |
c09fc3834c69
Add option 'iq_version_hide_time'
Mikael Berthe <mikael@lilotux.net>
parents:
2002
diff
changeset
|
792 |
|
1598 | 793 |
buf = g_new0(char, 512); |
794 |
||
795 |
r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT); |
|
796 |
query = lm_message_node_add_child(r->node, "query", NULL); |
|
1667
8af0e0ad20ad
Fix some more xmlns attributes in IQ responses
Mikael Berthe <mikael@lilotux.net>
parents:
1666
diff
changeset
|
797 |
lm_message_node_set_attribute(query, "xmlns", NS_TIME); |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
798 |
|
1598 | 799 |
now = gmtime(&now_t); |
1128 | 800 |
|
1598 | 801 |
strftime(buf, 512, "%Y%m%dT%T", now); |
802 |
lm_message_node_add_child(query, "utc", buf); |
|
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
803 |
|
1598 | 804 |
now = localtime(&now_t); |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
805 |
|
1598 | 806 |
strftime(buf, 512, "%Z", now); |
807 |
if ((utf8_buf = to_utf8(buf))) { |
|
808 |
lm_message_node_add_child(query, "tz", utf8_buf); |
|
809 |
g_free(utf8_buf); |
|
810 |
} |
|
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
811 |
|
1598 | 812 |
strftime(buf, 512, "%d %b %Y %T", now); |
813 |
if ((utf8_buf = to_utf8(buf))) { |
|
814 |
lm_message_node_add_child(query, "display", utf8_buf); |
|
815 |
g_free(utf8_buf); |
|
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
816 |
} |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
817 |
|
1598 | 818 |
lm_connection_send(c, r, NULL); |
819 |
lm_message_unref(r); |
|
820 |
g_free(buf); |
|
821 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
822 |
} |
|
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
823 |
|
1598 | 824 |
// This function borrows some code from the Pidgin project |
1604
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
825 |
LmHandlerResult handle_iq_time202(LmMessageHandler *h, LmConnection *c, |
351427ef0b4b
Remove #include's of C files
Mikael Berthe <mikael@lilotux.net>
parents:
1600
diff
changeset
|
826 |
LmMessage *m, gpointer ud) |
1598 | 827 |
{ |
828 |
LmMessage *r; |
|
829 |
LmMessageNode *query; |
|
830 |
char *buf, *utf8_buf; |
|
831 |
time_t now_t; |
|
832 |
struct tm *now; |
|
833 |
char const *sign; |
|
834 |
int diff = 0; |
|
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
835 |
|
1598 | 836 |
time(&now_t); |
837 |
||
838 |
if (!settings_opt_get_int("iq_hide_requests")) { |
|
839 |
scr_LogPrint(LPRINT_LOGNORM, "Received an IQ time request from <%s>", |
|
840 |
lm_message_get_from(m)); |
|
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
841 |
} |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
842 |
|
2067
79659eb4f66f
Rename 'iq_version_hide_time' to 'iq_time_hide'
Mikael Berthe <mikael@lilotux.net>
parents:
2066
diff
changeset
|
843 |
if (settings_opt_get_int("iq_time_hide")) { |
2065
c09fc3834c69
Add option 'iq_version_hide_time'
Mikael Berthe <mikael@lilotux.net>
parents:
2002
diff
changeset
|
844 |
send_iq_error(c, m, XMPP_ERROR_SERVICE_UNAVAILABLE); |
c09fc3834c69
Add option 'iq_version_hide_time'
Mikael Berthe <mikael@lilotux.net>
parents:
2002
diff
changeset
|
845 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
c09fc3834c69
Add option 'iq_version_hide_time'
Mikael Berthe <mikael@lilotux.net>
parents:
2002
diff
changeset
|
846 |
} |
c09fc3834c69
Add option 'iq_version_hide_time'
Mikael Berthe <mikael@lilotux.net>
parents:
2002
diff
changeset
|
847 |
|
1598 | 848 |
buf = g_new0(char, 512); |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
849 |
|
1598 | 850 |
r = lm_message_new_iq_from_query(m, LM_MESSAGE_SUB_TYPE_RESULT); |
851 |
query = lm_message_node_add_child(r->node, "time", NULL); |
|
852 |
lm_message_node_set_attribute(query, "xmlns", NS_XMPP_TIME); |
|
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
853 |
|
1598 | 854 |
now = localtime(&now_t); |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
855 |
|
1598 | 856 |
if (now->tm_isdst >= 0) { |
857 |
#if defined HAVE_TM_GMTOFF |
|
858 |
diff = now->tm_gmtoff; |
|
859 |
#elif defined HAVE_TIMEZONE |
|
860 |
tzset(); |
|
861 |
diff = -timezone; |
|
989
859ab76e5093
Send JEP-22 delivered messages
Mikael Berthe <mikael@lilotux.net>
parents:
988
diff
changeset
|
862 |
#endif |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
863 |
} |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
864 |
|
1598 | 865 |
if (diff < 0) { |
866 |
sign = "-"; |
|
867 |
diff = -diff; |
|
749
6c633adaae10
Use events system for subscription requests
Mikael Berthe <mikael@lilotux.net>
parents:
745
diff
changeset
|
868 |
} else { |
1598 | 869 |
sign = "+"; |
749
6c633adaae10
Use events system for subscription requests
Mikael Berthe <mikael@lilotux.net>
parents:
745
diff
changeset
|
870 |
} |
1598 | 871 |
diff /= 60; |
872 |
snprintf(buf, 512, "%c%02d:%02d", *sign, diff / 60, diff % 60); |
|
873 |
if ((utf8_buf = to_utf8(buf))) { |
|
874 |
lm_message_node_add_child(query, "tzo", utf8_buf); |
|
875 |
g_free(utf8_buf); |
|
1128 | 876 |
} |
877 |
||
1598 | 878 |
now = gmtime(&now_t); |
818
55cd45481a07
Fix a buddylist bug when receiving a subscription request
Mikael Berthe <mikael@lilotux.net>
parents:
793
diff
changeset
|
879 |
|
1598 | 880 |
strftime(buf, 512, "%Y-%m-%dT%TZ", now); |
881 |
lm_message_node_add_child(query, "utc", buf); |
|
611
ad737139a144
Improve subscription management
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
882 |
|
1598 | 883 |
lm_connection_send(c, r, NULL); |
884 |
lm_message_unref(r); |
|
885 |
g_free(buf); |
|
886 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
|
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
887 |
} |
1599 | 888 |
|
1615
171ae5a258fa
Add dummy vcard IQ handler
Mikael Berthe <mikael@lilotux.net>
parents:
1604
diff
changeset
|
889 |
LmHandlerResult handle_iq_vcard(LmMessageHandler *h, LmConnection *c, |
171ae5a258fa
Add dummy vcard IQ handler
Mikael Berthe <mikael@lilotux.net>
parents:
1604
diff
changeset
|
890 |
LmMessage *m, gpointer ud) |
171ae5a258fa
Add dummy vcard IQ handler
Mikael Berthe <mikael@lilotux.net>
parents:
1604
diff
changeset
|
891 |
{ |
171ae5a258fa
Add dummy vcard IQ handler
Mikael Berthe <mikael@lilotux.net>
parents:
1604
diff
changeset
|
892 |
send_iq_error(c, m, XMPP_ERROR_SERVICE_UNAVAILABLE); |
171ae5a258fa
Add dummy vcard IQ handler
Mikael Berthe <mikael@lilotux.net>
parents:
1604
diff
changeset
|
893 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
171ae5a258fa
Add dummy vcard IQ handler
Mikael Berthe <mikael@lilotux.net>
parents:
1604
diff
changeset
|
894 |
} |
171ae5a258fa
Add dummy vcard IQ handler
Mikael Berthe <mikael@lilotux.net>
parents:
1604
diff
changeset
|
895 |
|
1811 | 896 |
/* vim: set et cindent cinoptions=>2\:2(0 ts=2 sw=2: For Vim users... */ |