Mercurial > ~mikael > mcabber > hg
annotate mcabber/src/jabglue.c @ 441:51b8f10cfeb8
Handle g_locale_from_utf8() failures
The biggest issue was that when a message couldn't be utf8-decoded,
the user was not notified of the failure, and sometimes didn't even
know a message had been sent to him...
I don't know if we can ask for a partial decoding, so the message isn't
displayed but an error message is now displayed.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Wed, 21 Sep 2005 22:05:43 +0200 |
parents | b44be19d6229 |
children | 5927c3bfba13 |
rev | line source |
---|---|
29 | 1 /* |
2 * jabglue.c -- Jabber protocol handling | |
393 | 3 * |
29 | 4 * Copyright (C) 2005 Mikael Berthe <bmikael@lists.lilotux.net> |
5 * Parts come from the centericq project: | |
6 * Copyright (C) 2002-2005 by Konstantin Klyagin <konst@konst.org.ua> | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or (at | |
11 * your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
21 * USA | |
22 */ | |
23 | |
237 | 24 #define _GNU_SOURCE /* We need glibc for strptime */ |
29 | 25 #include "../libjabber/jabber.h" |
26 #include "jabglue.h" | |
81 | 27 #include "roster.h" |
29 | 28 #include "screen.h" |
113 | 29 #include "hooks.h" |
29 | 30 #include "utils.h" |
294
871e53769084
Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
31 #include "settings.h" |
441
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
32 #include "hbuf.h" |
29 | 33 |
34 #define JABBERPORT 5222 | |
35 #define JABBERSSLPORT 5223 | |
36 | |
194 | 37 #define JABBER_AGENT_GROUP "Jabber Agents" |
38 | |
387
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
39 #define to_utf8(s) ((s) ? g_locale_to_utf8((s), -1, NULL,NULL,NULL) : NULL) |
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
40 #define from_utf8(s) ((s) ? g_locale_from_utf8((s), -1, NULL,NULL,NULL) : NULL) |
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
41 |
29 | 42 jconn jc; |
311
1d6b16d9c577
Make some global variables static
Mikael Berthe <mikael@lilotux.net>
parents:
300
diff
changeset
|
43 static time_t LastPingTime; |
1d6b16d9c577
Make some global variables static
Mikael Berthe <mikael@lilotux.net>
parents:
300
diff
changeset
|
44 static unsigned int KeepaliveDelay; |
272 | 45 static unsigned int prio; |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
46 static int s_id; |
31 | 47 static int regmode, regdone; |
116 | 48 static enum imstatus mystatus = offline; |
112 | 49 unsigned char online; |
29 | 50 |
353
3fe43f6daa5a
Make imstatus2char a null-terminated string
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
51 char imstatus2char[imstatus_size+1] = { |
3fe43f6daa5a
Make imstatus2char a null-terminated string
Mikael Berthe <mikael@lilotux.net>
parents:
325
diff
changeset
|
52 '_', 'o', 'i', 'f', 'd', 'n', 'a', '\0' |
46 | 53 }; |
54 | |
31 | 55 static enum { |
29 | 56 STATE_CONNECTING, |
57 STATE_GETAUTH, | |
58 STATE_SENDAUTH, | |
59 STATE_LOGGED | |
60 } jstate; | |
61 | |
62 | |
31 | 63 void statehandler(jconn, int); |
64 void packethandler(jconn, jpacket); | |
65 | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
66 static void logger(jconn j, int io, const char *buf) |
31 | 67 { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
68 scr_LogPrint(LPRINT_DEBUG, "%03s: %s", ((io == 0) ? "OUT" : "IN"), buf); |
31 | 69 } |
70 | |
113 | 71 /* |
29 | 72 static void jidsplit(const char *jid, char **user, char **host, |
73 char **res) | |
74 { | |
75 char *tmp, *ptr; | |
76 tmp = strdup(jid); | |
77 | |
78 if ((ptr = strchr(tmp, '/')) != NULL) { | |
79 *res = strdup(ptr+1); | |
80 *ptr = 0; | |
81 } else | |
82 *res = NULL; | |
83 | |
84 if ((ptr = strchr(tmp, '@')) != NULL) { | |
85 *host = strdup(ptr+1); | |
86 *ptr = 0; | |
87 } else | |
88 *host = NULL; | |
89 | |
90 *user = strdup(tmp); | |
91 free(tmp); | |
92 } | |
113 | 93 */ |
29 | 94 |
192 | 95 // jidtodisp(jid) |
96 // Strips the resource part from the jid | |
97 // The caller should g_free the result after use. | |
29 | 98 char *jidtodisp(const char *jid) |
99 { | |
100 char *ptr; | |
165 | 101 char *alias; |
102 | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
103 alias = g_strdup(jid); |
165 | 104 |
29 | 105 if ((ptr = strchr(alias, '/')) != NULL) { |
106 *ptr = 0; | |
107 } | |
108 return alias; | |
109 } | |
110 | |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
111 char *compose_jid(const char *username, const char *servername, |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
112 const char *resource) |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
113 { |
393 | 114 char *jid = g_new(char, 3 + |
115 strlen(username) + strlen(servername) + strlen(resource)); | |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
116 strcpy(jid, username); |
403
17aa60c6dc63
Allow a different server name than the jid domain name
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
117 if (!strchr(jid, '@')) { |
17aa60c6dc63
Allow a different server name than the jid domain name
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
118 strcat(jid, "@"); |
17aa60c6dc63
Allow a different server name than the jid domain name
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
119 strcat(jid, servername); |
17aa60c6dc63
Allow a different server name than the jid domain name
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
120 } |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
121 strcat(jid, "/"); |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
122 strcat(jid, resource); |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
123 return jid; |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
124 } |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
125 |
403
17aa60c6dc63
Allow a different server name than the jid domain name
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
126 jconn jb_connect(const char *jid, const char *server, unsigned int port, |
17aa60c6dc63
Allow a different server name than the jid domain name
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
127 int ssl, const char *pass) |
29 | 128 { |
129 if (!port) { | |
130 if (ssl) | |
131 port = JABBERSSLPORT; | |
132 else | |
133 port = JABBERPORT; | |
134 } | |
135 | |
357
e8adc3c96e68
Better messages for server connection states
Mikael Berthe <mikael@lilotux.net>
parents:
353
diff
changeset
|
136 jb_disconnect(); |
29 | 137 |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
138 s_id = 1; |
403
17aa60c6dc63
Allow a different server name than the jid domain name
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
139 jc = jab_new((char*)jid, (char*)pass, (char*)server, port, ssl); |
29 | 140 |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
141 /* These 3 functions can deal with a NULL jc, no worry... */ |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
142 jab_logger(jc, logger); |
29 | 143 jab_packet_handler(jc, &packethandler); |
144 jab_state_handler(jc, &statehandler); | |
145 | |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
146 if (jc && jc->user) { |
112 | 147 online = TRUE; |
29 | 148 jstate = STATE_CONNECTING; |
149 statehandler(0, -1); | |
150 jab_start(jc); | |
151 } | |
152 | |
153 return jc; | |
154 } | |
155 | |
156 void jb_disconnect(void) | |
157 { | |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
158 if (!jc) return; |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
159 |
416
48e7808c4191
Allow offline status message
Mikael Berthe <mikael@lilotux.net>
parents:
411
diff
changeset
|
160 // announce it to everyone else |
48e7808c4191
Allow offline status message
Mikael Berthe <mikael@lilotux.net>
parents:
411
diff
changeset
|
161 jb_setstatus(offline, ""); |
48e7808c4191
Allow offline status message
Mikael Berthe <mikael@lilotux.net>
parents:
411
diff
changeset
|
162 |
48e7808c4191
Allow offline status message
Mikael Berthe <mikael@lilotux.net>
parents:
411
diff
changeset
|
163 // announce it to the user |
29 | 164 statehandler(jc, JCONN_STATE_OFF); |
416
48e7808c4191
Allow offline status message
Mikael Berthe <mikael@lilotux.net>
parents:
411
diff
changeset
|
165 |
298
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
166 jab_delete(jc); |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
167 //free(jc); XXX |
35cda94e570d
Add /connect and /disconnect commands
Mikael Berthe <mikael@lilotux.net>
parents:
294
diff
changeset
|
168 jc = NULL; |
29 | 169 } |
170 | |
112 | 171 inline void jb_reset_keepalive() |
172 { | |
173 time(&LastPingTime); | |
174 } | |
175 | |
436 | 176 void jb_send_raw(const char *str) |
177 { | |
178 if (jc && online) | |
179 jab_send_raw(jc, str); | |
180 } | |
181 | |
29 | 182 void jb_keepalive() |
183 { | |
113 | 184 if (jc && online) |
112 | 185 jab_send_raw(jc, " \t "); |
186 jb_reset_keepalive(); | |
187 } | |
188 | |
189 void jb_set_keepalive_delay(unsigned int delay) | |
190 { | |
191 KeepaliveDelay = delay; | |
29 | 192 } |
193 | |
272 | 194 inline void jb_set_priority(unsigned int priority) |
195 { | |
196 prio = priority; | |
197 } | |
198 | |
29 | 199 void jb_main() |
200 { | |
201 xmlnode x, z; | |
202 char *cid; | |
203 | |
406 | 204 if (!online) { |
419 | 205 safe_usleep(10000); |
406 | 206 return; |
207 } | |
164 | 208 |
29 | 209 if (jc && jc->state == JCONN_STATE_CONNECTING) { |
419 | 210 safe_usleep(75000); |
29 | 211 jab_start(jc); |
212 return; | |
213 } | |
214 | |
31 | 215 jab_poll(jc, 50); |
29 | 216 |
217 if (jstate == STATE_CONNECTING) { | |
218 if (jc) { | |
219 x = jutil_iqnew(JPACKET__GET, NS_AUTH); | |
220 cid = jab_getid(jc); | |
221 xmlnode_put_attrib(x, "id", cid); | |
222 // id = atoi(cid); | |
223 | |
224 z = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "username"); | |
225 xmlnode_insert_cdata(z, jc->user->user, (unsigned) -1); | |
226 jab_send(jc, x); | |
227 xmlnode_free(x); | |
228 | |
229 jstate = STATE_GETAUTH; | |
230 } | |
231 | |
232 if (!jc || jc->state == JCONN_STATE_OFF) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
233 scr_LogPrint(LPRINT_LOGNORM, "Unable to connect to the server"); |
112 | 234 online = FALSE; |
29 | 235 } |
236 } | |
237 | |
238 if (!jc) { | |
239 statehandler(jc, JCONN_STATE_OFF); | |
240 } else if (jc->state == JCONN_STATE_OFF || jc->fd == -1) { | |
241 statehandler(jc, JCONN_STATE_OFF); | |
242 } | |
112 | 243 |
244 // Keepalive | |
245 if (KeepaliveDelay) { | |
246 time_t now; | |
247 time(&now); | |
248 if (now > LastPingTime + KeepaliveDelay) | |
249 jb_keepalive(); | |
250 } | |
29 | 251 } |
252 | |
116 | 253 inline enum imstatus jb_getstatus() |
254 { | |
255 return mystatus; | |
256 } | |
257 | |
294
871e53769084
Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
258 void jb_setstatus(enum imstatus st, const char *msg) |
29 | 259 { |
116 | 260 xmlnode x; |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
261 gchar *utf8_msg; |
116 | 262 |
164 | 263 if (!online) return; |
116 | 264 |
265 x = jutil_presnew(JPACKET__UNKNOWN, 0, 0); | |
29 | 266 |
267 switch(st) { | |
268 case away: | |
269 xmlnode_insert_cdata(xmlnode_insert_tag(x, "show"), "away", | |
270 (unsigned) -1); | |
271 break; | |
272 | |
273 case dontdisturb: | |
274 xmlnode_insert_cdata(xmlnode_insert_tag(x, "show"), "dnd", | |
275 (unsigned) -1); | |
276 break; | |
277 | |
278 case freeforchat: | |
279 xmlnode_insert_cdata(xmlnode_insert_tag(x, "show"), "chat", | |
280 (unsigned) -1); | |
281 break; | |
282 | |
283 case notavail: | |
284 xmlnode_insert_cdata(xmlnode_insert_tag(x, "show"), "xa", | |
285 (unsigned) -1); | |
286 break; | |
287 | |
288 case invisible: | |
289 xmlnode_put_attrib(x, "type", "invisible"); | |
290 break; | |
51 | 291 |
118 | 292 case offline: |
293 xmlnode_put_attrib(x, "type", "unavailable"); | |
294 break; | |
295 | |
51 | 296 default: |
297 break; | |
29 | 298 } |
299 | |
272 | 300 if (prio) { |
301 char strprio[8]; | |
302 snprintf(strprio, 8, "%u", prio); | |
29 | 303 xmlnode_insert_cdata(xmlnode_insert_tag(x, "priority"), |
272 | 304 strprio, (unsigned) -1); |
305 } | |
29 | 306 |
294
871e53769084
Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
307 if (!msg) |
871e53769084
Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
308 msg = settings_get_status_msg(st); |
29 | 309 |
387
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
310 utf8_msg = to_utf8(msg); |
321
59193965f2cb
Convert status messages to/from UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
319
diff
changeset
|
311 xmlnode_insert_cdata(xmlnode_insert_tag(x, "status"), utf8_msg, |
29 | 312 (unsigned) -1); |
313 | |
314 jab_send(jc, x); | |
315 xmlnode_free(x); | |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
316 g_free(utf8_msg); |
29 | 317 |
116 | 318 //sendvisibility(); ??? |
29 | 319 |
164 | 320 // We'll need to update the roster if we switch to/from offline because |
321 // we don't know the presences of buddies when offline... | |
322 if (mystatus == offline || st == offline) | |
323 update_roster = TRUE; | |
324 | |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
311
diff
changeset
|
325 hk_mystatuschange(0, mystatus, st, msg); |
116 | 326 mystatus = st; |
29 | 327 } |
328 | |
35 | 329 void jb_send_msg(const char *jid, const char *text) |
330 { | |
387
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
331 gchar *buffer = to_utf8(text); |
213 | 332 xmlnode x = jutil_msgnew(TMSG_CHAT, (char*)jid, 0, (char*)buffer); |
35 | 333 jab_send(jc, x); |
334 xmlnode_free(x); | |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
335 g_free(buffer); |
114 | 336 jb_reset_keepalive(); |
35 | 337 } |
338 | |
213 | 339 // Note: the caller should check the jid is correct |
244 | 340 void jb_addbuddy(const char *jid, const char *name, const char *group) |
124 | 341 { |
342 xmlnode x, y, z; | |
192 | 343 char *cleanjid; |
124 | 344 |
208 | 345 if (!online) return; |
124 | 346 |
347 // We don't check if the jabber user already exists in the roster, | |
348 // because it allows to re-ask for notification. | |
349 | |
350 //x = jutil_presnew(JPACKET__SUBSCRIBE, jid, NULL); | |
125 | 351 x = jutil_presnew(JPACKET__SUBSCRIBE, (char*)jid, "online"); |
124 | 352 jab_send(jc, x); |
353 xmlnode_free(x); | |
354 | |
355 x = jutil_iqnew(JPACKET__SET, NS_ROSTER); | |
356 y = xmlnode_get_tag(x, "query"); | |
357 z = xmlnode_insert_tag(y, "item"); | |
358 xmlnode_put_attrib(z, "jid", jid); | |
359 | |
244 | 360 if (name) { |
387
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
361 gchar *name_utf8 = to_utf8(name); |
244 | 362 z = xmlnode_insert_tag(z, "name"); |
363 xmlnode_insert_cdata(z, name_utf8, (unsigned) -1); | |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
364 g_free(name_utf8); |
244 | 365 } |
366 | |
124 | 367 if (group) { |
387
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
368 char *group_utf8 = to_utf8(group); |
124 | 369 z = xmlnode_insert_tag(z, "group"); |
213 | 370 xmlnode_insert_cdata(z, group_utf8, (unsigned) -1); |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
371 g_free(group_utf8); |
124 | 372 } |
373 | |
374 jab_send(jc, x); | |
375 xmlnode_free(x); | |
376 | |
192 | 377 cleanjid = jidtodisp(jid); |
244 | 378 roster_add_user(cleanjid, name, group, ROSTER_TYPE_USER); |
192 | 379 g_free(cleanjid); |
124 | 380 buddylist_build(); |
381 | |
244 | 382 update_roster = TRUE; |
124 | 383 } |
384 | |
205 | 385 void jb_delbuddy(const char *jid) |
386 { | |
387 xmlnode x, y, z; | |
388 char *cleanjid; | |
389 | |
390 if (!online) return; | |
391 | |
392 cleanjid = jidtodisp(jid); | |
393 | |
394 // If the current buddy is an agent, unsubscribe from it | |
395 if (roster_gettype(cleanjid) == ROSTER_TYPE_AGENT) { | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
396 scr_LogPrint(LPRINT_LOGNORM, "Unregistering from the %s agent", cleanjid); |
205 | 397 |
398 x = jutil_iqnew(JPACKET__SET, NS_REGISTER); | |
399 xmlnode_put_attrib(x, "to", cleanjid); | |
400 y = xmlnode_get_tag(x, "query"); | |
401 xmlnode_insert_tag(y, "remove"); | |
402 jab_send(jc, x); | |
403 xmlnode_free(x); | |
404 } | |
405 | |
406 // Unsubscribe this buddy from our presence notification | |
407 x = jutil_presnew(JPACKET__UNSUBSCRIBE, cleanjid, 0); | |
408 jab_send(jc, x); | |
409 xmlnode_free(x); | |
410 | |
411 // Ask for removal from roster | |
412 x = jutil_iqnew(JPACKET__SET, NS_ROSTER); | |
413 y = xmlnode_get_tag(x, "query"); | |
414 z = xmlnode_insert_tag(y, "item"); | |
415 xmlnode_put_attrib(z, "jid", cleanjid); | |
416 xmlnode_put_attrib(z, "subscription", "remove"); | |
417 jab_send(jc, x); | |
418 xmlnode_free(x); | |
419 | |
420 roster_del_user(cleanjid); | |
421 g_free(cleanjid); | |
422 buddylist_build(); | |
423 | |
424 update_roster = TRUE; | |
425 } | |
426 | |
208 | 427 void jb_updatebuddy(const char *jid, const char *name, const char *group) |
428 { | |
429 xmlnode x, y; | |
430 char *cleanjid; | |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
431 gchar *name_utf8; |
208 | 432 |
433 if (!online) return; | |
434 | |
435 // XXX We should check name's and group's correctness | |
436 | |
437 cleanjid = jidtodisp(jid); | |
387
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
438 name_utf8 = to_utf8(name); |
208 | 439 |
440 x = jutil_iqnew(JPACKET__SET, NS_ROSTER); | |
441 y = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "item"); | |
442 xmlnode_put_attrib(y, "jid", cleanjid); | |
213 | 443 xmlnode_put_attrib(y, "name", name_utf8); |
208 | 444 |
445 if (group) { | |
387
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
446 gchar *group_utf8 = to_utf8(group); |
208 | 447 y = xmlnode_insert_tag(y, "group"); |
213 | 448 xmlnode_insert_cdata(y, group_utf8, (unsigned) -1); |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
449 g_free(group_utf8); |
208 | 450 } |
451 | |
452 jab_send(jc, x); | |
453 xmlnode_free(x); | |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
454 g_free(name_utf8); |
208 | 455 g_free(cleanjid); |
456 } | |
457 | |
31 | 458 void postlogin() |
459 { | |
460 //int i; | |
461 | |
462 //flogged = TRUE; | |
463 //ourstatus = available; | |
464 | |
465 //setautostatus(jhook.manualstatus); | |
466 | |
294
871e53769084
Allow one status message per Jabber status
Mikael Berthe <mikael@lilotux.net>
parents:
277
diff
changeset
|
467 jb_setstatus(available, NULL); |
81 | 468 buddylist_build(); |
31 | 469 /* |
470 for (i = 0; i < clist.count; i++) { | |
471 c = (icqcontact *) clist.at(i); | |
472 | |
473 if (c->getdesc().pname == proto) | |
474 if (ischannel(c)) | |
475 if (c->getbasicinfo().requiresauth) | |
476 c->setstatus(available); | |
477 } | |
478 */ | |
479 | |
480 /* | |
481 agents.insert(agents.begin(), agent("vcard", "Jabber VCard", "", agent::atStandard)); | |
482 agents.begin()->params[agent::ptRegister].enabled = TRUE; | |
483 | |
484 string buf; | |
485 ifstream f(conf.getconfigfname("jabber-infoset").c_str()); | |
486 | |
487 if (f.is_open()) { | |
488 icqcontact *c = clist.get(contactroot); | |
489 | |
490 c->clear(); | |
491 icqcontact::basicinfo bi = c->getbasicinfo(); | |
492 icqcontact::reginfo ri = c->getreginfo(); | |
493 | |
494 ri.service = agents.begin()->name; | |
495 getstring(f, buf); c->setnick(buf); | |
496 getstring(f, buf); bi.email = buf; | |
497 getstring(f, buf); bi.fname = buf; | |
498 getstring(f, buf); bi.lname = buf; | |
499 f.close(); | |
500 | |
501 c->setbasicinfo(bi); | |
502 c->setreginfo(ri); | |
503 | |
504 sendupdateuserinfo(*c); | |
505 unlink(conf.getconfigfname("jabber-infoset").c_str()); | |
506 } | |
507 */ | |
508 } | |
509 | |
29 | 510 void gotloggedin(void) |
511 { | |
512 xmlnode x; | |
513 | |
514 x = jutil_iqnew(JPACKET__GET, NS_AGENTS); | |
515 xmlnode_put_attrib(x, "id", "Agent List"); | |
516 jab_send(jc, x); | |
517 xmlnode_free(x); | |
518 | |
519 x = jutil_iqnew(JPACKET__GET, NS_ROSTER); | |
520 xmlnode_put_attrib(x, "id", "Roster"); | |
521 jab_send(jc, x); | |
522 xmlnode_free(x); | |
523 } | |
524 | |
525 void gotroster(xmlnode x) | |
526 { | |
33 | 527 xmlnode y, z; |
29 | 528 |
529 for (y = xmlnode_get_tag(x, "item"); y; y = xmlnode_get_nextsibling(y)) { | |
530 const char *alias = xmlnode_get_attrib(y, "jid"); | |
51 | 531 //const char *sub = xmlnode_get_attrib(y, "subscription"); // TODO Not used |
29 | 532 const char *name = xmlnode_get_attrib(y, "name"); |
213 | 533 char *group = NULL; |
29 | 534 |
33 | 535 z = xmlnode_get_tag(y, "group"); |
536 if (z) group = xmlnode_get_data(z); | |
29 | 537 |
538 if (alias) { | |
35 | 539 char *buddyname; |
192 | 540 char *cleanalias = jidtodisp(alias); |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
541 gchar *name_noutf8 = NULL; |
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
542 gchar *group_noutf8 = NULL; |
213 | 543 |
441
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
544 buddyname = cleanalias; |
213 | 545 if (name) { |
387
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
546 name_noutf8 = from_utf8(name); |
441
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
547 if (name_noutf8) buddyname = name_noutf8; |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
548 } |
35 | 549 |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
550 if (group) |
387
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
551 group_noutf8 = from_utf8(group); |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
552 |
213 | 553 roster_add_user(cleanalias, buddyname, group_noutf8, ROSTER_TYPE_USER); |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
554 if (name_noutf8) g_free(name_noutf8); |
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
555 if (group_noutf8) g_free(group_noutf8); |
192 | 556 g_free(cleanalias); |
29 | 557 } |
558 } | |
559 | |
560 postlogin(); | |
561 } | |
562 | |
563 void gotmessage(char *type, const char *from, const char *body, | |
223 | 564 const char *enc, time_t timestamp) |
29 | 565 { |
113 | 566 char *jid; |
387
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
567 gchar *buffer = from_utf8(body); |
29 | 568 |
441
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
569 jid = jidtodisp(from); |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
570 |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
571 if (!buffer && body) { |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
572 scr_LogPrint(LPRINT_LOGNORM, "Decoding of message from <%s> has failed", |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
573 from); |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
574 scr_WriteIncomingMessage(jid, "Cannot display message: " |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
575 "UTF-8 conversion failure", |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
576 0, HBB_PREFIX_ERR | HBB_PREFIX_IN); |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
577 g_free(jid); |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
578 return; |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
579 } |
51b8f10cfeb8
Handle g_locale_from_utf8() failures
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
580 |
35 | 581 /* |
113 | 582 //char *u, *h, *r; |
583 //jidsplit(from, &u, &h, &r); | |
35 | 584 // Maybe we should remember the resource? |
585 if (r) | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
586 scr_LogPrint(LPRINT_NORMAL, |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
587 "There is an extra part in message (resource?): %s", r); |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
588 //scr_LogPrint(LPRINT_NORMAL, "Msg from <%s>, type=%s", |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
589 // jidtodisp(from), type); |
35 | 590 */ |
591 | |
325
ff6fb51bfd78
Handle "error" message type
Mikael Berthe <mikael@lilotux.net>
parents:
321
diff
changeset
|
592 hk_message_in(jid, timestamp, buffer, type); |
192 | 593 g_free(jid); |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
594 g_free(buffer); |
29 | 595 } |
596 | |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
597 const char *defaulterrormsg(int code) |
420
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
598 { |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
599 const char *desc; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
600 |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
601 switch(code) { |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
602 case 401: desc = "Unauthorized"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
603 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
604 case 302: desc = "Redirect"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
605 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
606 case 400: desc = "Bad request"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
607 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
608 case 402: desc = "Payment Required"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
609 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
610 case 403: desc = "Forbidden"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
611 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
612 case 404: desc = "Not Found"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
613 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
614 case 405: desc = "Not Allowed"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
615 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
616 case 406: desc = "Not Acceptable"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
617 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
618 case 407: desc = "Registration Required"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
619 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
620 case 408: desc = "Request Timeout"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
621 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
622 case 409: desc = "Conflict"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
623 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
624 case 500: desc = "Internal Server Error"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
625 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
626 case 501: desc = "Not Implemented"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
627 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
628 case 502: desc = "Remote Server Error"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
629 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
630 case 503: desc = "Service Unavailable"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
631 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
632 case 504: desc = "Remote Server Timeout"; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
633 break; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
634 default: |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
635 desc = NULL; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
636 } |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
637 |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
638 return desc; |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
639 } |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
640 |
430
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
641 // display_server_error(x) |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
642 // Display the error to the user |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
643 // x: error tag xmlnode pointer |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
644 void display_server_error(xmlnode x) |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
645 { |
430
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
646 const char *desc = NULL; |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
647 int code = 0; |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
648 char *s; |
430
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
649 const char *p; |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
650 |
430
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
651 /* RFC3920: |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
652 * The <error/> element: |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
653 * o MUST contain a child element corresponding to one of the defined |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
654 * stanza error conditions specified below; this element MUST be |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
655 * qualified by the 'urn:ietf:params:xml:ns:xmpp-stanzas' namespace. |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
656 */ |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
657 p = xmlnode_get_name(xmlnode_get_firstchild(x)); |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
658 if (p) |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
659 scr_LogPrint(LPRINT_LOGNORM, "Received error packet [%s]", p); |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
660 |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
661 // For backward compatibility |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
662 if ((s = xmlnode_get_attrib(x, "code")) != NULL) { |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
663 code = atoi(s); |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
664 // Default message |
430
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
665 desc = defaulterrormsg(code); |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
666 } |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
667 |
430
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
668 // Error tag data is better, if available |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
669 s = xmlnode_get_data(x); |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
670 if (s && *s) desc = s; |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
671 |
430
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
672 // And sometimes there is a text message |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
673 s = xmlnode_get_tag_data(x, "text"); |
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
674 if (s && *s) desc = s; // FIXME utf8?? |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
675 |
430
d03663d2e7d9
Display error messages as specified in RFC3920 (9.3)
Mikael Berthe <mikael@lilotux.net>
parents:
426
diff
changeset
|
676 scr_LogPrint(LPRINT_LOGNORM, "Error code from server: %d %s", code, desc); |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
677 } |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
678 |
31 | 679 void statehandler(jconn conn, int state) |
680 { | |
681 static int previous_state = -1; | |
682 | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
683 scr_LogPrint(LPRINT_DEBUG, "StateHandler called (state=%d).", state); |
31 | 684 |
685 switch(state) { | |
686 case JCONN_STATE_OFF: | |
192 | 687 if (previous_state != JCONN_STATE_OFF) |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
688 scr_LogPrint(LPRINT_LOGNORM, "[Jabber] Not connected to the server"); |
37 | 689 |
112 | 690 online = FALSE; |
159 | 691 mystatus = offline; |
164 | 692 roster_free(); |
693 update_roster = TRUE; | |
31 | 694 break; |
695 | |
696 case JCONN_STATE_CONNECTED: | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
697 scr_LogPrint(LPRINT_LOGNORM, "[Jabber] Connected to the server"); |
31 | 698 break; |
699 | |
700 case JCONN_STATE_AUTH: | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
701 scr_LogPrint(LPRINT_LOGNORM, "[Jabber] Authenticating to the server"); |
31 | 702 break; |
703 | |
704 case JCONN_STATE_ON: | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
705 scr_LogPrint(LPRINT_LOGNORM, "[Jabber] Communication with the server " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
706 "established"); |
112 | 707 online = TRUE; |
31 | 708 break; |
709 | |
35 | 710 case JCONN_STATE_CONNECTING: |
357
e8adc3c96e68
Better messages for server connection states
Mikael Berthe <mikael@lilotux.net>
parents:
353
diff
changeset
|
711 if (previous_state != state) |
408
73433860665c
Tune previous usleep() change
Mikael Berthe <mikael@lilotux.net>
parents:
407
diff
changeset
|
712 scr_LogPrint(LPRINT_LOGNORM, "[Jabber] Connecting to the server"); |
35 | 713 break; |
714 | |
31 | 715 default: |
716 break; | |
717 } | |
718 previous_state = state; | |
719 } | |
720 | |
721 void packethandler(jconn conn, jpacket packet) | |
722 { | |
91 | 723 char *p, *r; |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
724 const char *m, *rname; |
37 | 725 xmlnode x, y; |
31 | 726 char *from=NULL, *type=NULL, *body=NULL, *enc=NULL; |
727 char *ns=NULL; | |
728 char *id=NULL; | |
35 | 729 enum imstatus ust; |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
730 char bpprio; |
31 | 731 |
112 | 732 jb_reset_keepalive(); // reset keepalive delay |
31 | 733 jpacket_reset(packet); |
734 | |
735 p = xmlnode_get_attrib(packet->x, "from"); if (p) from = p; | |
736 p = xmlnode_get_attrib(packet->x, "type"); if (p) type = p; | |
737 | |
738 switch (packet->type) { | |
739 case JPACKET_MESSAGE: | |
52 | 740 { |
741 char *tmp = NULL; | |
223 | 742 time_t timestamp = 0; |
743 | |
52 | 744 x = xmlnode_get_tag(packet->x, "body"); |
745 p = xmlnode_get_data(x); if (p) body = p; | |
31 | 746 |
52 | 747 if ((x = xmlnode_get_tag(packet->x, "subject")) != NULL) |
748 if ((p = xmlnode_get_data(x)) != NULL) { | |
165 | 749 tmp = g_new(char, strlen(body)+strlen(p)+4); |
52 | 750 *tmp = '['; |
751 strcpy(tmp+1, p); | |
752 strcat(tmp, "]\n"); | |
753 strcat(tmp, body); | |
754 body = tmp; | |
755 } | |
756 | |
757 /* there can be multiple <x> tags. we're looking for one with | |
758 xmlns = jabber:x:encrypted */ | |
759 | |
420
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
760 x = xmlnode_get_firstchild(packet->x); |
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
761 for ( ; x; x = xmlnode_get_nextsibling(x)) { |
52 | 762 if ((p = xmlnode_get_name(x)) && !strcmp(p, "x")) |
763 if ((p = xmlnode_get_attrib(x, "xmlns")) && | |
764 !strcasecmp(p, "jabber:x:encrypted")) | |
765 if ((p = xmlnode_get_data(x)) != NULL) { | |
766 enc = p; | |
767 break; | |
768 } | |
31 | 769 } |
770 | |
223 | 771 // Timestamp? |
772 if ((x = xmlnode_get_tag(packet->x, "x")) != NULL) { | |
241 | 773 if ((p = xmlnode_get_attrib(x, "stamp")) != NULL) |
774 timestamp = from_iso8601(p, 1); | |
223 | 775 } |
776 | |
420
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
777 if (type && !strcmp(type, "error")) { |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
778 if ((x = xmlnode_get_tag(packet->x, "error")) != NULL) |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
779 display_server_error(x); |
420
04a0b450380b
Display error code/message when receiving a message packet with "error" type
Mikael Berthe <mikael@lilotux.net>
parents:
419
diff
changeset
|
780 } |
165 | 781 if (from && body) |
223 | 782 gotmessage(type, from, body, enc, timestamp); |
52 | 783 if (tmp) |
159 | 784 g_free(tmp); |
31 | 785 } |
786 break; | |
787 | |
788 case JPACKET_IQ: | |
789 if (!strcmp(type, "result")) { | |
790 | |
51 | 791 if ((p = xmlnode_get_attrib(packet->x, "id")) != NULL) { |
31 | 792 int iid = atoi(p); |
793 | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
794 scr_LogPrint(LPRINT_DEBUG, "iid = %d", iid); |
31 | 795 if (iid == s_id) { |
796 if (!regmode) { | |
797 if (jstate == STATE_GETAUTH) { | |
51 | 798 if ((x = xmlnode_get_tag(packet->x, "query")) != NULL) |
31 | 799 if (!xmlnode_get_tag(x, "digest")) { |
800 jc->sid = 0; | |
801 } | |
802 | |
803 s_id = atoi(jab_auth(jc)); | |
804 jstate = STATE_SENDAUTH; | |
805 } else { | |
806 gotloggedin(); | |
807 jstate = STATE_LOGGED; | |
808 } | |
809 } else { | |
810 regdone = TRUE; | |
811 } | |
812 return; | |
813 } | |
814 | |
815 if (!strcmp(p, "VCARDreq")) { | |
816 x = xmlnode_get_firstchild(packet->x); | |
817 if (!x) x = packet->x; | |
818 | |
819 //jhook.gotvcard(ic, x); TODO | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
820 scr_LogPrint(LPRINT_LOGNORM, "Got VCARD"); |
31 | 821 return; |
822 } else if (!strcmp(p, "versionreq")) { | |
823 // jhook.gotversion(ic, packet->x); TODO | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
824 scr_LogPrint(LPRINT_LOGNORM, "Got version"); |
31 | 825 return; |
826 } | |
827 } | |
828 | |
51 | 829 if ((x = xmlnode_get_tag(packet->x, "query")) != NULL) { |
31 | 830 p = xmlnode_get_attrib(x, "xmlns"); if (p) ns = p; |
831 | |
832 if (!strcmp(ns, NS_ROSTER)) { | |
833 gotroster(x); | |
834 } else if (!strcmp(ns, NS_AGENTS)) { | |
835 for (y = xmlnode_get_tag(x, "agent"); y; y = xmlnode_get_nextsibling(y)) { | |
836 const char *alias = xmlnode_get_attrib(y, "jid"); | |
837 | |
838 if (alias) { | |
839 const char *name = xmlnode_get_tag_data(y, "name"); | |
840 const char *desc = xmlnode_get_tag_data(y, "description"); | |
51 | 841 // const char *service = xmlnode_get_tag_data(y, "service"); TODO |
37 | 842 enum agtype atype = unknown; |
31 | 843 |
37 | 844 if (xmlnode_get_tag(y, "groupchat")) atype = groupchat; else |
845 if (xmlnode_get_tag(y, "transport")) atype = transport; else | |
846 if (xmlnode_get_tag(y, "search")) atype = search; | |
31 | 847 |
192 | 848 if (atype == transport) { |
849 char *cleanjid = jidtodisp(alias); | |
194 | 850 roster_add_user(cleanjid, NULL, JABBER_AGENT_GROUP, |
851 ROSTER_TYPE_AGENT); | |
192 | 852 g_free(cleanjid); |
853 } | |
31 | 854 if (alias && name && desc) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
855 scr_LogPrint(LPRINT_LOGNORM, "Agent: %s / %s / %s / type=%d", |
37 | 856 alias, name, desc, atype); |
31 | 857 |
37 | 858 if (atype == search) { |
31 | 859 x = jutil_iqnew (JPACKET__GET, NS_SEARCH); |
860 xmlnode_put_attrib(x, "to", alias); | |
861 xmlnode_put_attrib(x, "id", "Agent info"); | |
862 jab_send(conn, x); | |
863 xmlnode_free(x); | |
864 } | |
865 | |
866 if (xmlnode_get_tag(y, "register")) { | |
867 x = jutil_iqnew (JPACKET__GET, NS_REGISTER); | |
868 xmlnode_put_attrib(x, "to", alias); | |
869 xmlnode_put_attrib(x, "id", "Agent info"); | |
870 jab_send(conn, x); | |
871 xmlnode_free(x); | |
872 } | |
873 } | |
874 } | |
875 } | |
876 | |
37 | 877 /* |
31 | 878 if (find(jhook.agents.begin(), jhook.agents.end(), DEFAULT_CONFSERV) == jhook.agents.end()) |
879 jhook.agents.insert(jhook.agents.begin(), agent(DEFAULT_CONFSERV, DEFAULT_CONFSERV, | |
880 _("Default Jabber conference server"), agent::atGroupchat)); | |
881 | |
882 */ | |
883 } else if (!strcmp(ns, NS_SEARCH) || !strcmp(ns, NS_REGISTER)) { | |
884 p = xmlnode_get_attrib(packet->x, "id"); id = p ? p : (char*)""; | |
885 | |
886 if (!strcmp(id, "Agent info")) { | |
887 // jhook.gotagentinfo(packet->x); TODO | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
888 scr_LogPrint(LPRINT_LOGNORM, "Got agent info"); |
31 | 889 } else if (!strcmp(id, "Lookup")) { |
890 // jhook.gotsearchresults(packet->x); TODO | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
891 scr_LogPrint(LPRINT_LOGNORM, "Got search results"); |
31 | 892 } else if (!strcmp(id, "Register")) { |
893 x = jutil_iqnew(JPACKET__GET, NS_REGISTER); | |
894 xmlnode_put_attrib(x, "to", from); | |
895 xmlnode_put_attrib(x, "id", "Agent info"); | |
896 jab_send(conn, x); | |
897 xmlnode_free(x); | |
898 } | |
899 | |
900 } | |
901 } | |
902 } else if (!strcmp(type, "set")) { | |
903 } else if (!strcmp(type, "error")) { | |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
904 if ((x = xmlnode_get_tag(packet->x, "error")) != NULL) |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
905 display_server_error(x); |
31 | 906 } |
907 break; | |
908 | |
909 case JPACKET_PRESENCE: | |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
910 r = jidtodisp(from); |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
911 if (type && !strcmp(type, "error")) { |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
912 scr_LogPrint(LPRINT_LOGNORM, "Error presence packet from <%s>", r); |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
913 if ((x = xmlnode_get_tag(packet->x, "error")) != NULL) |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
914 display_server_error(x); |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
915 g_free(r); |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
916 break; |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
917 } |
31 | 918 |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
919 p = xmlnode_get_tag_data(packet->x, "priority"); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
920 if (p && *p) bpprio = (gchar)atoi(p); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
921 else bpprio = 0; |
31 | 922 |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
923 ust = available; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
924 p = xmlnode_get_tag_data(packet->x, "show"); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
925 if (p) { |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
926 if (!strcmp(p, "away")) ust = away; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
927 else if (!strcmp(p, "dnd")) ust = dontdisturb; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
928 else if (!strcmp(p, "xa")) ust = notavail; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
929 else if (!strcmp(p, "chat")) ust = freeforchat; |
31 | 930 } |
931 | |
321
59193965f2cb
Convert status messages to/from UTF-8
Mikael Berthe <mikael@lilotux.net>
parents:
319
diff
changeset
|
932 if (type && !strcmp(type, "unavailable")) |
35 | 933 ust = offline; |
31 | 934 |
221 | 935 if ((x = xmlnode_get_tag(packet->x, "status")) != NULL) |
387
2bbeef7b4fdd
Do non UTF8-encode/decode null pointers
Mikael Berthe <mikael@lilotux.net>
parents:
384
diff
changeset
|
936 p = from_utf8(xmlnode_get_data(x)); |
221 | 937 else |
938 p = NULL; | |
939 | |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
311
diff
changeset
|
940 // Call hk_statuschange() if status has changed or if the |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
311
diff
changeset
|
941 // status message is different |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
942 rname = strchr(from, '/'); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
943 if (rname) rname++; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
944 m = roster_getstatusmsg(r, rname); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
945 if ((ust != roster_getstatus(r, rname)) || (p && (!m || strcmp(p, m)))) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
436
diff
changeset
|
946 hk_statuschange(r, rname, bpprio, 0, ust, p); |
159 | 947 g_free(r); |
383
39c5da51b387
Remove utf8 files, use Glib
Mikael Berthe <mikael@lilotux.net>
parents:
374
diff
changeset
|
948 if (p) g_free(p); |
31 | 949 break; |
950 | |
951 case JPACKET_S10N: | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
952 scr_LogPrint(LPRINT_LOGNORM, "Received (un)subscription packet " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
953 "(type=%s)", ((type) ? type : "")); |
31 | 954 |
43 | 955 if (!strcmp(type, "subscribe")) { |
91 | 956 int isagent; |
957 r = jidtodisp(from); | |
958 isagent = (roster_gettype(r) & ROSTER_TYPE_AGENT) != 0; | |
159 | 959 g_free(r); |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
960 scr_LogPrint(LPRINT_LOGNORM, "isagent=%d", isagent); // XXX DBG |
91 | 961 if (!isagent) { |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
962 scr_LogPrint(LPRINT_LOGNORM, "<%s> wants to subscribe " |
43 | 963 "to your network presence updates", from); |
125 | 964 // FIXME we accept everybody... |
965 x = jutil_presnew(JPACKET__SUBSCRIBED, from, 0); | |
966 jab_send(jc, x); | |
967 xmlnode_free(x); | |
91 | 968 } else { |
969 x = jutil_presnew(JPACKET__SUBSCRIBED, from, 0); | |
31 | 970 jab_send(jc, x); |
971 xmlnode_free(x); | |
91 | 972 } |
43 | 973 } else if (!strcmp(type, "unsubscribe")) { |
974 x = jutil_presnew(JPACKET__UNSUBSCRIBED, from, 0); | |
31 | 975 jab_send(jc, x); |
976 xmlnode_free(x); | |
374
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
977 scr_LogPrint(LPRINT_LOGNORM, "<%s> has unsubscribed to " |
bd5638c21834
Improve logging system (traces)
Mikael Berthe <mikael@lilotux.net>
parents:
364
diff
changeset
|
978 "your presence updates", from); |
31 | 979 } |
980 break; | |
981 | |
982 default: | |
983 break; | |
984 } | |
985 } | |
986 |