Debian Codegraph @

src/core/xep/muc-events.c

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*
2 * Copyright (C) 2007,2008,2009 Colin DIDIER
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 /*
19 * XEP-0045: Multi-User Chat
20 */
21
22 #include <stdlib.h>
23 #include <string.h>
24
25 #include "module.h"
26 #include "commands.h"
27 #include "misc.h"
28 #include "settings.h"
29 #include "signals.h"
30
31 #include "rosters-tools.h"
32 #include "tools.h"
33 #include "disco.h"
34 #include "muc.h"
35 #include "muc-nicklist.h"
36 #include "muc-affiliation.h"
37 #include "muc-role.h"
38
39 #define MAX_LONG_STRLEN ((sizeof(long) * CHAR_BIT + 2) / 3 + 1)
40
41 #define XMLNS_DATA_X "jabber:x:data"
42
43 void send_join(MUC_REC *);
44
45 static void
46 topic(MUC_REC *channel, const char *topic, const char *nickname)
47 {
48 if (channel->topic != NULL && topic != NULL
49 && strcmp(channel->topic, topic) == 0)
50 return;
51 g_free(channel->topic);
52 channel->topic = (topic != NULL && *topic != '\0') ?
53 g_strdup(topic) : NULL;
54 g_free(channel->topic_by);
55 channel->topic_by = g_strdup(nickname);
56 signal_emit("channel topic changed", 1, channel);
57 if (channel->joined && nickname != NULL && *nickname != '\0')
58 signal_emit("message topic", 5, channel->server, channel->name,
59 (channel->topic != NULL) ? channel->topic : "",
60 channel->topic_by, "");
61 else {
62 char *data = g_strconcat(" ", channel->name, " :",
63 (channel->topic != NULL) ? channel->topic : "", (void *)NULL);
64 signal_emit("event 332", 2, channel->server, data);
65 g_free(data);
66 }
67 }
68
69 static void
70 nick_changed(MUC_REC *channel, const char *oldnick, const char *newnick)
71 {
72 XMPP_NICK_REC *nick;
73
74 if ((nick = xmpp_nicklist_find(channel, oldnick)) == NULL)
75 return;
76 xmpp_nicklist_rename(channel, nick, oldnick, newnick);
77 if (channel->ownnick == NICK(nick))
78 signal_emit("message xmpp muc own_nick", 3,
79 channel, nick, oldnick);
80 else
81 signal_emit("message xmpp muc nick", 3,
82 channel, nick, oldnick);
83 }
84
85 static void
86 own_join(MUC_REC *channel, const char *nickname,
87 const char *full_jid, const char *affiliation, const char *role,
88 gboolean forced)
89 {
90 XMPP_NICK_REC *nick;
91
92 if (channel->joined)
93 return;
94 if ((nick = xmpp_nicklist_find(channel, nickname)) != NULL)
95 return;
96 nick = xmpp_nicklist_insert(channel, nickname, full_jid);
97 nicklist_set_own(CHANNEL(channel), NICK(nick));
98 channel->chanop = channel->ownnick->op;
99 xmpp_nicklist_set_modes(nick,
100 xmpp_nicklist_get_affiliation(affiliation),
101 xmpp_nicklist_get_role(role));
102 channel->names_got = TRUE;
103 channel->joined = TRUE;
104 signal_emit("message join", 4, channel->server, channel->name,
105 nick->nick, nick->host);
106 signal_emit("message xmpp muc mode", 4, channel,
107 nick->nick, nick->affiliation, nick->role);
108 signal_emit("channel joined", 1, channel);
109 signal_emit("channel sync", 1, channel);
110 channel_send_autocommands(CHANNEL(channel));
111 if (forced)
112 nick_changed(channel, channel->nick, nick->nick);
113 if (*channel->mode == '\0')
114 disco_request(channel->server, channel->name);
115 }
116
117 static void
118 nick_join(MUC_REC *channel, const char *nickname, const char *full_jid,
119 const char *affiliation, const char *role)
120 {
121 XMPP_NICK_REC *nick;
122
123 nick = xmpp_nicklist_insert(channel, nickname, full_jid);
124 xmpp_nicklist_set_modes(nick,
125 xmpp_nicklist_get_affiliation(affiliation),
126 xmpp_nicklist_get_role(role));
127 if (channel->names_got) {
128 signal_emit("message join", 4, channel->server, channel->name,
129 nick->nick, nick->host);
130 signal_emit("message xmpp muc mode", 4, channel,
131 nick->nick, nick->affiliation, nick->role);
132 }
133 }
134
135 static void
136 nick_mode(MUC_REC *channel, XMPP_NICK_REC *nick, const char *affiliation_str,
137 const char *role_str)
138 {
139 int affiliation, role;
140
141 affiliation = xmpp_nicklist_get_affiliation(affiliation_str);
142 role = xmpp_nicklist_get_role(role_str);
143 if (xmpp_nicklist_modes_changed(nick, affiliation, role)) {
144 xmpp_nicklist_set_modes(nick, affiliation, role);
145 signal_emit("message xmpp muc mode", 4, channel,
146 nick->nick, affiliation, role);
147 }
148 }
149
150 static void
151 own_event(MUC_REC *channel, const char *nickname, const char *full_jid,
152 const char *affiliation, const char *role, gboolean forced)
153 {
154 XMPP_NICK_REC *nick;
155
156 if ((nick = xmpp_nicklist_find(channel, nickname)) == NULL)
157 own_join(channel, nickname, full_jid, affiliation, role,
158 forced);
159 else
160 nick_mode(channel, nick, affiliation, role);
161 }
162
163 static void
164 nick_event(MUC_REC *channel, const char *nickname, const char *full_jid,
165 const char *affiliation, const char *role)
166 {
167 XMPP_NICK_REC *nick;
168
169 if ((nick = xmpp_nicklist_find(channel, nickname)) == NULL)
170 nick_join(channel, nickname, full_jid, affiliation, role);
171 else
172 nick_mode(channel, nick, affiliation, role);
173 }
174
175 static void
176 nick_part(MUC_REC *channel, const char *nickname, const char *reason)
177 {
178 XMPP_NICK_REC *nick;
179
180 if ((nick = xmpp_nicklist_find(channel, nickname)) == NULL)
181 return;
182 signal_emit("message part", 5, channel->server, channel->name,
183 nick->nick, nick->host, reason);
184 if (channel->ownnick == NICK(nick)) {
185 channel->left = TRUE;
186 channel_destroy(CHANNEL(channel));
187 } else
188 nicklist_remove(CHANNEL(channel), NICK(nick));
189 }
190
191 static void
192 nick_presence(MUC_REC *channel, const char *nickname, const char *show_str,
193 const char *status)
194 {
195 XMPP_NICK_REC *nick;
196 int show;
197
198 if ((nick = xmpp_nicklist_find(channel, nickname)) == NULL)
199 return;
200 show = xmpp_get_show(show_str);
201 if (xmpp_presence_changed(show, nick->show, status, nick->status,
202 0, 0)) {
203 xmpp_nicklist_set_presence(nick, show, status);
204 if (channel->joined && channel->ownnick != NICK(nick)) {
205 /* TODO eventually show event */
206 }
207 }
208 }
209
210 static void
211 nick_kicked(MUC_REC *channel, const char *nickname, const char *actor,
212 const char *reason)
213 {
214 XMPP_NICK_REC *nick;
215
216 if ((nick = xmpp_nicklist_find(channel, nickname)) == NULL)
217 return;
218 signal_emit("message kick", 6, channel->server, channel->name,
219 nick->nick, (actor != NULL) ? actor : channel->name, nick->host,
220 reason);
221 if (channel->ownnick == NICK(nick)) {
222 channel->kicked = TRUE;
223 channel_destroy(CHANNEL(channel));
224 } else
225 nicklist_remove(CHANNEL(channel), NICK(nick));
226 }
227
228 static void
229 error_message(MUC_REC *channel, const char *code)
230 {
231 int error;
232
233 error = code != NULL ? atoi(code) : MUC_ERROR_UNKNOWN;
234 switch (error) {
235 case MUC_ERROR_PASSWORD_INVALID_OR_MISSING:
236 signal_emit("xmpp muc error", 2, channel, "not allowed");
237 break;
238 }
239 }
240
241 static void
242 error_join(MUC_REC *channel, const char *code, const char *nick)
243 {
244 char *altnick;
245 int error;
246
247 if (nick != NULL && strcmp(nick, channel->nick) != 0)
248 return;
249 error = code != NULL ? atoi(code) : MUC_ERROR_UNKNOWN;
250 signal_emit("xmpp muc joinerror", 2, channel, GINT_TO_POINTER(error));
251 switch(error) {
252 case MUC_ERROR_USE_RESERVED_ROOM_NICK:
253 case MUC_ERROR_NICK_IN_USE:
254 /* rejoin with alternate nick */
255 altnick = (char *)settings_get_str("alternate_nick");
256 if (altnick != NULL && *altnick != '\0'
257 && strcmp(channel->nick, altnick) != 0) {
258 g_free(channel->nick);
259 channel->nick = g_strdup(altnick);
260 } else {
261 altnick = g_strdup_printf("%s_", channel->nick);
262 g_free(channel->nick);
263 channel->nick = altnick;
264 }
265 send_join(channel);
266 return; /* don't destroy the channel */
267 }
268 channel_destroy(CHANNEL(channel));
269 }
270
271 static void
272 error_presence(MUC_REC *channel, const char *code, const char *nick)
273 {
274 int error;
275
276 error = code != NULL ? atoi(code) : MUC_ERROR_UNKNOWN;
277 switch (error) {
278 case MUC_ERROR_NICK_IN_USE:
279 signal_emit("message xmpp muc nick in use", 2, channel, nick);
280 break;
281 }
282 }
283
284 static void
285 error_destroy(MUC_REC *channel, const char *code, const char *reason)
286 {
287 int error;
288
289 error = code != NULL ? atoi(code) : MUC_ERROR_UNKNOWN;
290 switch (error) {
291 case 403:
292 signal_emit("xmpp muc destroyerror", 2, channel, reason);
293 break;
294 }
295 }
296
297 static void
298 available(MUC_REC *channel, const char *from, LmMessage *lmsg)
299 {
300 LmMessageNode *node;
301 const char *item_affiliation, *item_role, *nick;
302 char *item_jid, *item_nick, *status;
303 gboolean own, forced, created;
304
305 item_affiliation = item_role = status = NULL;
306 item_jid = item_nick = NULL;
307 /* <x xmlns='http://jabber.org/protocol/muc#user'> */
•308 if ((node = lm_find_node(lmsg->node, "user:x", XMLNS ":user", XMLNS_MUC_USER)) == NULL &&
309 (node = lm_find_node(lmsg->node, "x", XMLNS, XMLNS_MUC_USER)) == NULL)
310 return;
311 /* <status code='110'/> */
•312 own = lm_find_node(node, "status", "code", "110") != NULL || lm_find_node(node, "user:status", "code", "110") != NULL ;
313 /* <status code='210'/> */
•314 forced = lm_find_node(node, "status", "code", "210") != NULL || lm_find_node(node, "user:status", "code", "210") != NULL;
315 /* <status code='201'/> */
•316 created = lm_find_node(node, "status", "code", "201") != NULL || lm_find_node(node, "user:status", "code", "201") != NULL;
317 if (created) {
318 char str[MAX_LONG_STRLEN], *data, *recoded;
319 LmMessage *lmsg;
320 LmMessageNode *query, *x;
321
322 /* Require instant room */
323 lmsg = lm_message_new_with_sub_type(channel->name, LM_MESSAGE_TYPE_IQ,
324 LM_MESSAGE_SUB_TYPE_GET);
325 recoded = xmpp_recode_out(channel->server->jid);
326 lm_message_node_set_attribute(lmsg->node, "from", recoded);
327 g_free(recoded);
328 query = lm_message_node_add_child(lmsg->node, "query", NULL);
329 lm_message_node_set_attribute(query, XMLNS, XMLNS_MUC_OWNER);
330 x = lm_message_node_add_child(query, "x", NULL);
331 lm_message_node_set_attribute(x, XMLNS, XMLNS_DATA_X);
332 lm_message_node_set_attribute(x, "type", "submit");
333 signal_emit("xmpp send iq", 2, channel->server, lmsg);
334 lm_message_unref(lmsg);
335
336 /* muc created */
337 g_snprintf(str, sizeof(str), "%ld", (long)time(NULL));
338 data = g_strconcat("_ ", channel->name, " ", str, (void *)NULL);
339 signal_emit("event 329", 2, channel->server, data);
340 g_free(data);
341 }
•342 LmMessageNode *parent = node;
343 if ((node = lm_message_node_get_child(parent, "user:item")) == NULL &&
344 (node = lm_message_node_get_child(parent, "item")) == NULL)
345 return;
346 /* <item affiliation='item_affiliation'
347 * role='item_role'
348 * jid='item_jid'
349 * nick='item_nick'/> */
350 item_affiliation = lm_message_node_get_attribute(node, "affiliation");
351 item_role = lm_message_node_get_attribute(node, "role");
352 item_jid = xmpp_recode_in( lm_message_node_get_attribute(node, "jid"));
353 item_nick = xmpp_recode_in( lm_message_node_get_attribute(node, "nick"));
354 nick = item_nick != NULL ? item_nick : from;
355 if (nick == NULL)
356 goto err;
357 if (own || strcmp(nick, channel->nick) == 0)
358 own_event(channel, nick, item_jid, item_affiliation, item_role,
359 forced);
360 else
361 nick_event(channel, nick, item_jid, item_affiliation, item_role);
362 /* <status>text</status> */
•363 if ((node = lm_message_node_get_child(lmsg->node, "user:status")) != NULL ||
364 (node = lm_message_node_get_child(lmsg->node, "status")) != NULL)
365 status = xmpp_recode_in(node->value);
366 /* <show>show</show> */
367 node = lm_message_node_get_child(lmsg->node, "show");
368 nick_presence(channel, nick, node != NULL ? node->value : NULL, status);
369 g_free(status);
370 err: g_free(item_jid);
371 g_free(item_nick);
372 }
373
374 static void
375 unavailable(MUC_REC *channel, const char *nick, LmMessage *lmsg)
376 {
377 LmMessageNode *node, *child;
378 const char *status_code;
379 char *reason, *actor, *item_nick, *status;
380
381 status_code = NULL;
382 reason = actor = item_nick = status = NULL;
383 /* <x xmlns='http://jabber.org/protocol/muc#user'> */
•384 if ((node = lm_find_node(lmsg->node, "user:x", XMLNS ":user",
385 XMLNS_MUC_USER)) != NULL ||
386 (node = lm_find_node(lmsg->node, "x", XMLNS,
387 XMLNS_MUC_USER)) != NULL)
388 {
389 /* <status code='status_code'/> */
•390 if ((child = lm_message_node_get_child(node, "user:status")) != NULL ||
391 (child = lm_message_node_get_child(node, "status")) != NULL)
392 status_code =
393 lm_message_node_get_attribute(child, "code");
394 /* <item nick='item_nick'> */
•395 LmMessageNode *parent = node;
396 if ((node = lm_message_node_get_child(parent, "user:item")) != NULL ||
397 (node = lm_message_node_get_child(parent, "item")) != NULL) {
398 item_nick = xmpp_recode_in(
399 lm_message_node_get_attribute(node, "nick"));
400 /* <reason>reason</reason> */
401 child = lm_message_node_get_child(node, "reason");
402 if (child != NULL)
403 reason = xmpp_recode_in(child->value);
404 /* <actor jid='actor'/> */
405 child = lm_message_node_get_child(node, "actor");
406 if (child != NULL)
407 actor = xmpp_recode_in(
408 lm_message_node_get_attribute(child, "jid"));
409 }
410 }
411 if (status_code != NULL) {
412 switch (atoi(status_code)) {
413 case 303: /* <status code='303'/> */
414 nick_changed(channel, nick, item_nick);
415 break;
416 case 307: /* kick: <status code='307'/> */
417 nick_kicked(channel, nick, actor, reason);
418 break;
419 case 301: /* ban: <status code='301'/> */
420 nick_kicked(channel, nick, actor, reason);
421 break;
422 }
423 } else {
424 /* <status>text</status> */
•425 if ((node = lm_message_node_get_child(lmsg->node, "user:status")) != NULL ||
426 (node = lm_message_node_get_child(lmsg->node, "status")) != NULL)
427 status = xmpp_recode_in(node->value);
428 nick_part(channel, nick, status);
429 g_free(status);
430 }
431 g_free(item_nick);
432 g_free(reason);
433 g_free(actor);
434 }
435
436 static void
437 admin(MUC_REC *channel, LmMessage *lmsg)
438 {
439 LmMessageNode *node, *query;
440 const char *item_affiliation, *item_role, *item_jid, *item_nick;
441 int affiliation, role;
442
443 if ((query = lm_find_node(lmsg->node, "query", XMLNS,
444 XMLNS_MUC_ADMIN)) == NULL)
445 return;
446
447 for (node = query->children; node != NULL; node = node->next) {
448 /* <item affiliation='item_affiliation'
449 * role='item_role'
450 * jid='item_jid'
451 * nick='item_nick'/> */
452 item_jid = xmpp_recode_in(lm_message_node_get_attribute(node,
453 "jid"));
454 item_affiliation = lm_message_node_get_attribute(node,
455 "affiliation");
456 item_nick = xmpp_recode_in(lm_message_node_get_attribute(node,
457 "nick"));
458 item_role = lm_message_node_get_attribute(node, "role");
459 affiliation = xmpp_nicklist_get_affiliation(item_affiliation);
460 if (item_role == NULL) {
461 /* affiliation query */
462 signal_emit("message xmpp muc affiliation", 4, channel,
463 item_jid, item_nick, affiliation);
464 } else {
465 role = xmpp_nicklist_get_role(item_role);
466 signal_emit("message xmpp muc mode", 4, channel,
467 item_nick, affiliation, role);
468 }
469 }
470 }
471
472 static void
473 invite(XMPP_SERVER_REC *server, const char *channame, LmMessageNode *node,
474 LmMessageNode *invite_node)
475 {
476 LmMessageNode *pass;
477 CHANNEL_SETUP_REC *setup;
478 const char *from;
479 char *inviter, *password, *joindata;
480
481 if ((from = lm_message_node_get_attribute(invite_node, "from")) == NULL)
482 return;
483 inviter = xmpp_recode_in(from);
484 pass = lm_message_node_get_child(node, "password");
485 password = pass != NULL ? xmpp_recode_in(pass->value) : NULL;
486 signal_emit("xmpp invite", 4, server, inviter, channame, password);
487 /* check if we're supposed to autojoin this muc */
488 setup = channel_setup_find(channame, server->connrec->chatnet);
489 if (setup != NULL && setup->autojoin
490 && settings_get_bool("join_auto_chans_on_invite")) {
491 joindata = password == NULL ?
492 g_strconcat("\"", channame, "\"", (void *)NULL)
493 : g_strconcat("\"", channame, "\" ",
494 password, (void *)NULL);
495 muc_join(server, joindata, TRUE);
496 g_free(joindata);
497 }
498 g_free(inviter);
499 g_free(password);
500 g_free(server->last_invite);
501 server->last_invite = g_strdup(channame);
502 }
503
504 static void
505 sig_recv_message(XMPP_SERVER_REC *server, LmMessage *lmsg, const int type,
506 const char *id, const char *from, const char *to)
507 {
508 MUC_REC *channel;
509 LmMessageNode *node, *child;
510 char *nick, *str;
511 gboolean action, own;
512
513 if ((channel = get_muc(server, from)) == NULL) {
514 /* Not a joined channel, search the MUC namespace */
515 /* <x xmlns='http://jabber.org/protocol/muc#user'> */
•516 if ((node = lm_find_node(lmsg->node, "user:x", XMLNS ":user",
517 XMLNS_MUC_USER)) == NULL &&
518 (node = lm_find_node(lmsg->node, "x", XMLNS,
519 XMLNS_MUC_USER)) == NULL)
520 return;
521 switch (type) {
522 case LM_MESSAGE_SUB_TYPE_NOT_SET:
523 case LM_MESSAGE_SUB_TYPE_NORMAL:
524 child = lm_message_node_get_child(node, "invite");
525 if (child != NULL)
526 invite(server, from, node, child);
527 break;
528 }
529 return;
530 }
531 nick = muc_extract_nick(from);
532 switch (type) {
533 case LM_MESSAGE_SUB_TYPE_ERROR:
534 node = lm_message_node_get_child(lmsg->node, "error");
535 if (node != NULL) {
536 /* TODO: extract error type and name -> XMLNS_STANZAS */
537 error_message(channel,
538 lm_message_node_get_attribute(node, "code"));
539 }
540 break;
541 case LM_MESSAGE_SUB_TYPE_GROUPCHAT:
542 node = lm_message_node_get_child(lmsg->node, "subject");
543 if (node != NULL) {
544 str = xmpp_recode_in(node->value);
545 topic(channel, str, nick);
546 g_free(str);
547 }
548 node = lm_message_node_get_child(lmsg->node, "body");
549 if (node != NULL && node->value != NULL) {
550 str = xmpp_recode_in(node->value);
551 if (nick != NULL) {
552 own = strcmp(nick, channel->nick) == 0;
553 action = g_ascii_strncasecmp(str, "/me ", 4) == 0;
554 if (action && own)
555 signal_emit("message xmpp own_action", 4,
556 server, str+4, channel->name,
557 GINT_TO_POINTER(SEND_TARGET_CHANNEL));
558 else if (action)
559 signal_emit("message xmpp action", 5,
560 server, str+4, nick, channel->name,
561 GINT_TO_POINTER(SEND_TARGET_CHANNEL));
562 else if (own)
563 signal_emit("message xmpp own_public", 3,
564 server, str, channel->name);
565 else
566 signal_emit("message public", 5,
567 server, str, nick, "", channel->name);
568 } else {
569 signal_emit("message xmpp room", 3,
570 server, str, channel->name);
571 }
572 g_free(str);
573 }
574 break;
575 }
576 g_free(nick);
577 }
578
579 static void
580 sig_recv_presence(XMPP_SERVER_REC *server, LmMessage *lmsg, const int type,
581 const char *id, const char *from, const char *to)
582 {
583 MUC_REC *channel;
584 LmMessageNode *node;
585 const char *code;
586 char *nick;
587
588 if ((channel = get_muc(server, from)) == NULL)
589 return;
590 nick = muc_extract_nick(from);
591 switch (type) {
592 case LM_MESSAGE_SUB_TYPE_ERROR:
593 node = lm_message_node_get_child(lmsg->node, "error");
594 if (node == NULL)
595 goto out;
596 /* TODO: extract error type and name -> XMLNS_STANZAS */
597 code = lm_message_node_get_attribute(node, "code");
598 if (!channel->joined)
599 error_join(channel, code, nick);
600 else
601 error_presence(channel, code, nick);
602 break;
603 case LM_MESSAGE_SUB_TYPE_AVAILABLE:
604 available(channel, nick, lmsg);
605 break;
606 case LM_MESSAGE_SUB_TYPE_UNAVAILABLE:
607 unavailable(channel, nick, lmsg);
608 break;
609 }
610
611 out:
612 g_free(nick);
613 }
614
615 static void
616 sig_recv_iq(XMPP_SERVER_REC *server, LmMessage *lmsg, const int type,
617 const char *id, const char *from, const char *to)
618 {
619 MUC_REC *channel;
620 LmMessageNode *node, *error, *text, *query;
621 const char *code;
622 char *reason;
623
624 if ((channel = get_muc(server, from)) == NULL)
625 return;
626
627 switch (type) {
628 case LM_MESSAGE_SUB_TYPE_ERROR:
629 error = lm_message_node_get_child(lmsg->node, "error");
630 if (error == NULL)
631 return;
632 code = lm_message_node_get_attribute(error, "code");
633
634 query = lm_find_node(lmsg->node, "query", XMLNS, XMLNS_MUC_OWNER);
635 if (query == NULL)
636 return;
637 for (node = query->children; node != NULL; node = node->next) {
638 if (strcmp(node->name, "destroy") == 0) {
639 text = lm_message_node_get_child(error, "text");
640 reason = xmpp_recode_in(text->value);
641 error_destroy(channel, code, reason);
642 g_free(reason);
643 }
644 }
645 break;
646 case LM_MESSAGE_SUB_TYPE_RESULT:
647 admin(channel, lmsg);
648 break;
649 }
650 }
651
652 void
653 muc_events_init(void)
654 {
655 signal_add("xmpp recv message", sig_recv_message);
656 signal_add("xmpp recv presence", sig_recv_presence);
657 signal_add("xmpp recv iq", sig_recv_iq);
658 }
659
660 void
661 muc_events_deinit(void)
662 {
663 signal_remove("xmpp recv message", sig_recv_message);
664 signal_remove("xmpp recv presence", sig_recv_presence);
665 signal_remove("xmpp recv iq", sig_recv_iq);
666 }