Merge Irssi 0.8.16-rc1
[silc.git] / apps / irssi / src / fe-common / core / fe-messages.c
1 /*
2  fe-messages.c : irssi
3
4     Copyright (C) 2000 Timo Sirainen
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License along
17     with this program; if not, write to the Free Software Foundation, Inc.,
18     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include "module.h"
22 #include "module-formats.h"
23 #include "signals.h"
24 #include "commands.h"
25 #include "levels.h"
26 #include "misc.h"
27 #include "special-vars.h"
28 #include "settings.h"
29
30 #include "servers.h"
31 #include "channels.h"
32 #include "nicklist.h"
33 #include "ignore.h"
34
35 #include "window-items.h"
36 #include "fe-queries.h"
37 #include "hilight-text.h"
38 #include "printtext.h"
39
40 #define ishighalnum(c) ((unsigned char) (c) >= 128 || i_isalnum(c))
41 #define isnickchar(a) \
42         (i_isalnum(a) || (a) == '`' || (a) == '-' || (a) == '_' || \
43         (a) == '[' || (a) == ']' || (a) == '{' || (a) == '}' || \
44         (a) == '|' || (a) == '\\' || (a) == '^')
45
46 GHashTable *printnicks;
47
48 /* convert _underlined_ and *bold* words (and phrases) to use real
49    underlining or bolding */
50 char *expand_emphasis(WI_ITEM_REC *item, const char *text)
51 {
52         GString *str;
53         char *ret;
54         int pos;
55
56         g_return_val_if_fail(text != NULL, NULL);
57
58         str = g_string_new(text);
59
60         for (pos = 0; pos < str->len; pos++) {
61                 char type, *bgn, *end;
62
63                 bgn = str->str + pos;
64
65                 if (*bgn == '*') 
66                         type = 2; /* bold */
67                 else if (*bgn == '_') 
68                         type = 31; /* underlined */
69                 else
70                         continue;
71
72                 /* check that the beginning marker starts a word, and
73                    that the matching end marker ends a word */
74                 if ((pos > 0 && bgn[-1] != ' ') || !ishighalnum(bgn[1]))
75                         continue;
76                 if ((end = strchr(bgn+1, *bgn)) == NULL)
77                         continue;
78                 if (!ishighalnum(end[-1]) || ishighalnum(end[1]) ||
79                     end[1] == type || end[1] == '*' || end[1] == '_')
80                         continue;
81
82                 if (IS_CHANNEL(item)) {
83                         /* check that this isn't a _nick_, we don't want to
84                            use emphasis on them. */
85                         int found;
86                         char c;
87                         char *end2; 
88
89                         /* check if _foo_ is a nick */
90                         c = end[1];
91                         end[1] = '\0';
92                         found = nicklist_find(CHANNEL(item), bgn) != NULL;
93                         end[1] = c;
94                         if (found) continue;
95                         
96                         /* check if the whole 'word' (e.g. "_foo_^") is a nick
97                            in "_foo_^ ", end will be the second _, end2 the ^ */
98                         end2 = end;
99                         while (isnickchar(end2[1]))
100                                 end2++;
101                         c = end2[1];
102                         end2[1] = '\0';
103                         found = nicklist_find(CHANNEL(item), bgn) != NULL;
104                         end2[1] = c;
105                         if (found) continue;
106                 }
107
108                 /* allow only *word* emphasis, not *multiple words* */
109                 if (!settings_get_bool("emphasis_multiword")) {
110                         char *c;
111                         for (c = bgn+1; c != end; c++) {
112                                 if (!ishighalnum(*c))
113                                         break;
114                         }
115                         if (c != end) continue;
116                 }
117
118                 if (settings_get_bool("emphasis_replace")) {
119                         *bgn = *end = type;
120                         pos += (end-bgn);
121                 } else {
122                         g_string_insert_c(str, pos, type);
123                         pos += (end - bgn) + 2;
124                         g_string_insert_c(str, pos++, type);
125                 }
126         }
127
128         ret = str->str;
129         g_string_free(str, FALSE);
130         return ret;
131 }
132
133 static char *channel_get_nickmode_rec(NICK_REC *nickrec)
134 {
135         char *emptystr;
136         char *nickmode;
137
138         if (!settings_get_bool("show_nickmode"))
139                 return g_strdup("");
140
141         emptystr = settings_get_bool("show_nickmode_empty") ? " " : "";
142
143         if (nickrec == NULL || nickrec->prefixes[0] == '\0')
144                 nickmode = g_strdup(emptystr);
145         else {
146                 nickmode = g_malloc(2);
147                 nickmode[0] = nickrec->prefixes[0];
148                 nickmode[1] = '\0';
149         }
150         return nickmode;
151 }
152
153 char *channel_get_nickmode(CHANNEL_REC *channel, const char *nick)
154 {
155         g_return_val_if_fail(nick != NULL, NULL);
156
157         return channel_get_nickmode_rec(channel == NULL ? NULL :
158                                         nicklist_find(channel, nick));
159 }
160
161 static void sig_message_public(SERVER_REC *server, const char *msg,
162                                const char *nick, const char *address,
163                                const char *target, NICK_REC *nickrec)
164 {
165         CHANNEL_REC *chanrec;
166         const char *printnick;
167         int for_me, print_channel, level;
168         char *nickmode, *color, *freemsg = NULL;
169         HILIGHT_REC *hilight;
170
171         /* NOTE: this may return NULL if some channel is just closed with
172            /WINDOW CLOSE and server still sends the few last messages */
173         chanrec = channel_find(server, target);
174         if (nickrec == NULL && chanrec != NULL)
175                 nickrec = nicklist_find(chanrec, nick);
176
177         for_me = !settings_get_bool("hilight_nick_matches") ? FALSE :
178                 nick_match_msg(chanrec, msg, server->nick);
179         hilight = for_me ? NULL :
180                 hilight_match_nick(server, target, nick, address, MSGLEVEL_PUBLIC, msg);
181         color = (hilight == NULL) ? NULL : hilight_get_color(hilight);
182
183         print_channel = chanrec == NULL ||
184                 !window_item_is_active((WI_ITEM_REC *) chanrec);
185         if (!print_channel && settings_get_bool("print_active_channel") &&
186             window_item_window((WI_ITEM_REC *) chanrec)->items->next != NULL)
187                 print_channel = TRUE;
188
189         level = MSGLEVEL_PUBLIC;
190         if (for_me)
191                 level |= MSGLEVEL_HILIGHT;
192
193         if (settings_get_bool("emphasis"))
194                 msg = freemsg = expand_emphasis((WI_ITEM_REC *) chanrec, msg);
195
196         /* get nick mode & nick what to print the msg with
197            (in case there's multiple identical nicks) */
198         nickmode = channel_get_nickmode_rec(nickrec);
199         printnick = nickrec == NULL ? nick :
200                 g_hash_table_lookup(printnicks, nickrec);
201         if (printnick == NULL)
202                 printnick = nick;
203
204         if (color != NULL) {
205                 /* highlighted nick */
206                 TEXT_DEST_REC dest;
207                 format_create_dest(&dest, server, target, level, NULL);
208                 hilight_update_text_dest(&dest,hilight);
209                 if (!print_channel) /* message to active channel in window */
210                         printformat_dest(&dest, TXT_PUBMSG_HILIGHT, color,
211                                          printnick, msg, nickmode);
212                 else /* message to not existing/active channel */
213                         printformat_dest(&dest, TXT_PUBMSG_HILIGHT_CHANNEL,
214                                          color, printnick, target, msg,
215                                          nickmode);
216         } else {
217                 if (!print_channel)
218                         printformat(server, target, level,
219                                     for_me ? TXT_PUBMSG_ME : TXT_PUBMSG,
220                                     printnick, msg, nickmode);
221                 else
222                         printformat(server, target, level,
223                                     for_me ? TXT_PUBMSG_ME_CHANNEL :
224                                     TXT_PUBMSG_CHANNEL,
225                                     printnick, target, msg, nickmode);
226         }                                               
227
228         g_free_not_null(nickmode);
229         g_free_not_null(freemsg);
230         g_free_not_null(color);
231 }
232
233 static void sig_message_private(SERVER_REC *server, const char *msg,
234                                 const char *nick, const char *address)
235 {
236         QUERY_REC *query;
237         char *freemsg = NULL;
238
239         query = query_find(server, nick);
240
241         if (settings_get_bool("emphasis"))
242                 msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg);
243
244         printformat(server, nick, MSGLEVEL_MSGS,
245                     query == NULL ? TXT_MSG_PRIVATE :
246                     TXT_MSG_PRIVATE_QUERY, nick, address, msg);
247
248         g_free_not_null(freemsg);
249 }
250
251 static void sig_message_own_public(SERVER_REC *server, const char *msg,
252                                    const char *target)
253 {
254         WINDOW_REC *window;
255         CHANNEL_REC *channel;
256         char *nickmode;
257         char *freemsg = NULL;
258         int print_channel;
259         channel = channel_find(server, target);
260         if (channel != NULL)
261                 target = channel->visible_name;
262
263         nickmode = channel_get_nickmode(channel, server->nick);
264
265         window = channel == NULL ? NULL :
266                 window_item_window((WI_ITEM_REC *) channel);
267
268         print_channel = window == NULL ||
269                 window->active != (WI_ITEM_REC *) channel;
270
271         if (!print_channel && settings_get_bool("print_active_channel") &&
272             window != NULL && g_slist_length(window->items) > 1)
273                 print_channel = TRUE;
274
275         if (settings_get_bool("emphasis"))
276                 msg = freemsg = expand_emphasis((WI_ITEM_REC *) channel, msg);
277
278         if (!print_channel) {
279                 printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
280                             TXT_OWN_MSG, server->nick, msg, nickmode);
281         } else {
282                 printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
283                             TXT_OWN_MSG_CHANNEL, server->nick, target, msg, nickmode);
284         }
285
286         g_free_not_null(nickmode);
287         g_free_not_null(freemsg);
288 }
289
290 static void sig_message_own_private(SERVER_REC *server, const char *msg,
291                                     const char *target, const char *origtarget)
292 {
293         QUERY_REC *query;
294         char *freemsg = NULL;
295
296         g_return_if_fail(server != NULL);
297         g_return_if_fail(msg != NULL);
298         if (target == NULL) {
299                 /* this should only happen if some special target failed and
300                    we should display some error message. currently the special
301                    targets are only ',' and '.'. */
302                 g_return_if_fail(strcmp(origtarget, ",") == 0 ||
303                                  strcmp(origtarget, ".") == 0);
304
305                 printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
306                             *origtarget == ',' ? TXT_NO_MSGS_GOT :
307                             TXT_NO_MSGS_SENT);
308                 signal_stop();
309                 return;
310         }
311
312         query = privmsg_get_query(server, target, TRUE, MSGLEVEL_MSGS);
313
314         if (settings_get_bool("emphasis"))
315                 msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg);
316
317         printformat(server, target,
318                     MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
319                     query == NULL ? TXT_OWN_MSG_PRIVATE :
320                     TXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);
321
322         g_free_not_null(freemsg);
323 }
324
325 static void sig_message_join(SERVER_REC *server, const char *channel,
326                              const char *nick, const char *address)
327 {
328         printformat(server, channel, MSGLEVEL_JOINS,
329                     TXT_JOIN, nick, address, channel);
330 }
331
332 static void sig_message_part(SERVER_REC *server, const char *channel,
333                              const char *nick, const char *address,
334                              const char *reason)
335 {
336         printformat(server, channel, MSGLEVEL_PARTS,
337                     TXT_PART, nick, address, channel, reason);
338 }
339
340 static void sig_message_quit(SERVER_REC *server, const char *nick,
341                              const char *address, const char *reason)
342 {
343         WINDOW_REC *window;
344         GString *chans;
345         GSList *tmp, *windows;
346         char *print_channel;
347         int once, count;
348
349         if (ignore_check(server, nick, address, NULL, reason, MSGLEVEL_QUITS))
350                 return;
351
352         print_channel = NULL;
353         once = settings_get_bool("show_quit_once");
354
355         count = 0; windows = NULL;
356         chans = g_string_new(NULL);
357         for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
358                 CHANNEL_REC *rec = tmp->data;
359
360                 if (!nicklist_find(rec, nick))
361                         continue;
362
363                 if (ignore_check(server, nick, address, rec->visible_name,
364                                  reason, MSGLEVEL_QUITS)) {
365                         count++;
366                         continue;
367                 }
368
369                 if (print_channel == NULL ||
370                     active_win->active == (WI_ITEM_REC *) rec)
371                         print_channel = rec->visible_name;
372
373                 if (once)
374                         g_string_append_printf(chans, "%s,", rec->visible_name);
375                 else {
376                         window = window_item_window((WI_ITEM_REC *) rec);
377                         if (g_slist_find(windows, window) == NULL) {
378                                 windows = g_slist_append(windows, window);
379                                 printformat(server, rec->visible_name,
380                                             MSGLEVEL_QUITS,
381                                             TXT_QUIT, nick, address, reason,
382                                             rec->visible_name);
383                         }
384                 }
385                 count++;
386         }
387         g_slist_free(windows);
388
389         if (!once) {
390                 /* check if you had query with the nick and
391                    display the quit there too */
392                 QUERY_REC *query = query_find(server, nick);
393                 if (query != NULL) {
394                         printformat(server, nick, MSGLEVEL_QUITS,
395                                     TXT_QUIT, nick, address, reason, "");
396                 }
397         }
398
399         if (once || count == 0) {
400                 if (chans->len > 0)
401                         g_string_truncate(chans, chans->len-1);
402                 printformat(server, print_channel, MSGLEVEL_QUITS,
403                             count <= 1 ? TXT_QUIT : TXT_QUIT_ONCE,
404                             nick, address, reason, chans->str);
405         }
406         g_string_free(chans, TRUE);
407 }
408
409 static void sig_message_kick(SERVER_REC *server, const char *channel,
410                              const char *nick, const char *kicker,
411                              const char *address, const char *reason)
412 {
413         printformat(server, channel, MSGLEVEL_KICKS,
414                     TXT_KICK, nick, channel, kicker, reason, address);
415 }
416
417 static void print_nick_change_channel(SERVER_REC *server, const char *channel,
418                                       const char *newnick, const char *oldnick,
419                                       const char *address,
420                                       int ownnick)
421 {
422         int level;
423
424         if (ignore_check(server, oldnick, address,
425                          channel, newnick, MSGLEVEL_NICKS))
426                 return;
427
428         level = MSGLEVEL_NICKS;
429         if (ownnick) level |= MSGLEVEL_NO_ACT;
430
431         printformat(server, channel, level,
432                     ownnick ? TXT_YOUR_NICK_CHANGED : TXT_NICK_CHANGED,
433                     oldnick, newnick, channel, address);
434 }
435
436 static void print_nick_change(SERVER_REC *server, const char *newnick,
437                               const char *oldnick, const char *address,
438                               int ownnick)
439 {
440         GSList *tmp, *windows;
441         int msgprint;
442
443         msgprint = FALSE;
444
445         /* Print to each channel where the nick is.
446            Don't print more than once to the same window. */
447         windows = NULL;
448         for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
449                 CHANNEL_REC *channel = tmp->data;
450                 WINDOW_REC *window =
451                         window_item_window((WI_ITEM_REC *) channel);
452
453                 if (nicklist_find(channel, newnick) == NULL ||
454                     g_slist_find(windows, window) != NULL)
455                         continue;
456
457                 windows = g_slist_append(windows, window);
458                 print_nick_change_channel(server, channel->visible_name,
459                                           newnick, oldnick, address, ownnick);
460                 msgprint = TRUE;
461         }
462
463         g_slist_free(windows);
464
465         if (!msgprint && ownnick) {
466                 printformat(server, NULL, MSGLEVEL_NICKS,
467                             TXT_YOUR_NICK_CHANGED, oldnick, newnick, "",
468                             address);
469         }
470 }
471
472 static void sig_message_nick(SERVER_REC *server, const char *newnick,
473                              const char *oldnick, const char *address)
474 {
475         print_nick_change(server, newnick, oldnick, address, FALSE);
476 }
477
478 static void sig_message_own_nick(SERVER_REC *server, const char *newnick,
479                                  const char *oldnick, const char *address)
480 {
481         if (!settings_get_bool("show_own_nickchange_once"))
482                 print_nick_change(server, newnick, oldnick, address, TRUE);
483         else {
484                 printformat(server, NULL, MSGLEVEL_NICKS,
485                             TXT_YOUR_NICK_CHANGED, oldnick, newnick, "",
486                             address);
487         }
488 }
489
490 static void sig_message_invite(SERVER_REC *server, const char *channel,
491                                const char *nick, const char *address)
492 {
493         char *str;
494
495         str = show_lowascii(channel);
496         printformat(server, NULL, MSGLEVEL_INVITES,
497                     TXT_INVITE, nick, str, address);
498         g_free(str);
499 }
500
501 static void sig_message_topic(SERVER_REC *server, const char *channel,
502                               const char *topic,
503                               const char *nick, const char *address)
504 {
505         printformat(server, channel, MSGLEVEL_TOPICS,
506                     *topic != '\0' ? TXT_NEW_TOPIC : TXT_TOPIC_UNSET,
507                     nick, channel, topic, address);
508 }
509
510 static int printnick_exists(NICK_REC *first, NICK_REC *ignore,
511                             const char *nick)
512 {
513         char *printnick;
514
515         while (first != NULL) {
516                 if (first != ignore) {
517                         printnick = g_hash_table_lookup(printnicks, first);
518                         if (printnick != NULL && strcmp(printnick, nick) == 0)
519                                 return TRUE;
520                 }
521
522                 first = first->next;
523         }
524
525         return FALSE;
526 }
527
528 static NICK_REC *printnick_find_original(NICK_REC *nick)
529 {
530         while (nick != NULL) {
531                 if (g_hash_table_lookup(printnicks, nick) == NULL)
532                         return nick;
533
534                 nick = nick->next;
535         }
536
537         return NULL;
538 }
539
540 static void sig_nicklist_new(CHANNEL_REC *channel, NICK_REC *nick)
541 {
542         NICK_REC *firstnick;
543         GString *newnick;
544         char *nickhost, *p;
545         int n;
546
547         if (nick->host == NULL)
548                 return;
549
550         firstnick = g_hash_table_lookup(channel->nicks, nick->nick);
551         if (firstnick->next == NULL)
552                 return;
553
554         if (nick == channel->ownnick) {
555                 /* own nick is being added, might be a nick change and
556                    someone else having the original nick already in use.. */
557                 nick = printnick_find_original(firstnick->next);
558                 if (nick == NULL)
559                         return; /* nope, we have it */
560         }
561
562         /* identical nick already exists, have to change it somehow.. */
563         p = strchr(nick->host, '@');
564         if (p == NULL) p = nick->host; else p++;
565
566         nickhost = g_strdup_printf("%s@%s", nick->nick, p);
567         p = strchr(nickhost+strlen(nick->nick), '.');
568         if (p != NULL) *p = '\0';
569
570         if (!printnick_exists(firstnick, nick, nickhost)) {
571                 /* use nick@host */
572                 g_hash_table_insert(printnicks, nick, nickhost);
573                 return;
574         }
575
576         newnick = g_string_new(NULL);
577         n = 2;
578         do {
579                 g_string_printf(newnick, "%s%d", nickhost, n);
580                 n++;
581         } while (printnick_exists(firstnick, nick, newnick->str));
582
583         g_hash_table_insert(printnicks, nick, newnick->str);
584         g_string_free(newnick, FALSE);
585         g_free(nickhost);
586 }
587
588 static void sig_nicklist_remove(CHANNEL_REC *channel, NICK_REC *nick)
589 {
590         char *nickname;
591
592         nickname = g_hash_table_lookup(printnicks, nick);
593         if (nickname != NULL) {
594                 g_free(nickname);
595                 g_hash_table_remove(printnicks, nick);
596         }
597 }
598
599 static void sig_nicklist_changed(CHANNEL_REC *channel, NICK_REC *nick)
600 {
601         sig_nicklist_remove(channel, nick);
602         sig_nicklist_new(channel, nick);
603 }
604
605 static void sig_channel_joined(CHANNEL_REC *channel)
606 {
607         NICK_REC *nick;
608         char *nickname;
609
610         /* channel->ownnick is set at this point - check if our own nick
611            has been changed, if it was set it back to the original nick and
612            change the previous original to something else */
613
614         nickname = g_hash_table_lookup(printnicks, channel->ownnick);
615         if (nickname == NULL)
616                 return;
617
618         g_free(nickname);
619         g_hash_table_remove(printnicks, channel->ownnick);
620
621         /* our own nick is guaranteed to be the first in list */
622         nick = channel->ownnick->next;
623         while (nick != NULL) {
624                 if (g_hash_table_lookup(printnicks, nick) == NULL) {
625                         sig_nicklist_new(channel, nick);
626                         break;
627                 }
628                 nick = nick->next;
629         }
630 }
631
632 static void g_hash_free_value(void *key, void *value)
633 {
634         g_free(value);
635 }
636
637 void fe_messages_init(void)
638 {
639         printnicks = g_hash_table_new((GHashFunc) g_direct_hash,
640                                       (GCompareFunc) g_direct_equal);
641
642         settings_add_bool("lookandfeel", "hilight_nick_matches", TRUE);
643         settings_add_bool("lookandfeel", "emphasis", TRUE);
644         settings_add_bool("lookandfeel", "emphasis_replace", FALSE);
645         settings_add_bool("lookandfeel", "emphasis_multiword", FALSE);
646         settings_add_bool("lookandfeel", "show_nickmode", TRUE);
647         settings_add_bool("lookandfeel", "show_nickmode_empty", TRUE);
648         settings_add_bool("lookandfeel", "print_active_channel", FALSE);
649         settings_add_bool("lookandfeel", "show_quit_once", FALSE);
650         settings_add_bool("lookandfeel", "show_own_nickchange_once", FALSE);
651
652         signal_add_last("message public", (SIGNAL_FUNC) sig_message_public);
653         signal_add_last("message private", (SIGNAL_FUNC) sig_message_private);
654         signal_add_last("message own_public", (SIGNAL_FUNC) sig_message_own_public);
655         signal_add_last("message own_private", (SIGNAL_FUNC) sig_message_own_private);
656         signal_add_last("message join", (SIGNAL_FUNC) sig_message_join);
657         signal_add_last("message part", (SIGNAL_FUNC) sig_message_part);
658         signal_add_last("message quit", (SIGNAL_FUNC) sig_message_quit);
659         signal_add_last("message kick", (SIGNAL_FUNC) sig_message_kick);
660         signal_add_last("message nick", (SIGNAL_FUNC) sig_message_nick);
661         signal_add_last("message own_nick", (SIGNAL_FUNC) sig_message_own_nick);
662         signal_add_last("message invite", (SIGNAL_FUNC) sig_message_invite);
663         signal_add_last("message topic", (SIGNAL_FUNC) sig_message_topic);
664
665         signal_add("nicklist new", (SIGNAL_FUNC) sig_nicklist_new);
666         signal_add("nicklist remove", (SIGNAL_FUNC) sig_nicklist_remove);
667         signal_add("nicklist changed", (SIGNAL_FUNC) sig_nicklist_changed);
668         signal_add("nicklist host changed", (SIGNAL_FUNC) sig_nicklist_new);
669         signal_add("channel joined", (SIGNAL_FUNC) sig_channel_joined);
670 }
671
672 void fe_messages_deinit(void)
673 {
674         g_hash_table_foreach(printnicks, (GHFunc) g_hash_free_value, NULL);
675         g_hash_table_destroy(printnicks);
676
677         signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
678         signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
679         signal_remove("message own_public", (SIGNAL_FUNC) sig_message_own_public);
680         signal_remove("message own_private", (SIGNAL_FUNC) sig_message_own_private);
681         signal_remove("message join", (SIGNAL_FUNC) sig_message_join);
682         signal_remove("message part", (SIGNAL_FUNC) sig_message_part);
683         signal_remove("message quit", (SIGNAL_FUNC) sig_message_quit);
684         signal_remove("message kick", (SIGNAL_FUNC) sig_message_kick);
685         signal_remove("message nick", (SIGNAL_FUNC) sig_message_nick);
686         signal_remove("message own_nick", (SIGNAL_FUNC) sig_message_own_nick);
687         signal_remove("message invite", (SIGNAL_FUNC) sig_message_invite);
688         signal_remove("message topic", (SIGNAL_FUNC) sig_message_topic);
689
690         signal_remove("nicklist new", (SIGNAL_FUNC) sig_nicklist_new);
691         signal_remove("nicklist remove", (SIGNAL_FUNC) sig_nicklist_remove);
692         signal_remove("nicklist changed", (SIGNAL_FUNC) sig_nicklist_changed);
693         signal_remove("nicklist host changed", (SIGNAL_FUNC) sig_nicklist_new);
694         signal_remove("channel joined", (SIGNAL_FUNC) sig_channel_joined);
695 }