addition of silc.css
[runtime.git] / apps / irssi / src / fe-common / core / fe-ignore-messages.c
1 /*
2  fe-ignore-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
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "module.h"
22 #include "signals.h"
23 #include "levels.h"
24 #include "ignore.h"
25
26 static void sig_message_public(SERVER_REC *server, const char *msg,
27                                const char *nick, const char *address,
28                                const char *target)
29 {
30         if (ignore_check(server, nick, address, target, msg, MSGLEVEL_PUBLIC))
31                 signal_stop();
32 }
33
34 static void sig_message_private(SERVER_REC *server, const char *msg,
35                                 const char *nick, const char *address)
36 {
37         if (ignore_check(server, nick, address, NULL, msg, MSGLEVEL_MSGS))
38                 signal_stop();
39 }
40
41 static void sig_message_join(SERVER_REC *server, const char *channel,
42                              const char *nick, const char *address)
43 {
44         if (ignore_check(server, nick, address, channel, NULL, MSGLEVEL_JOINS))
45                 signal_stop();
46 }
47
48 static void sig_message_part(SERVER_REC *server, const char *channel,
49                              const char *nick, const char *address,
50                              const char *reason)
51 {
52         if (ignore_check(server, nick, address, channel, NULL, MSGLEVEL_PARTS))
53                 signal_stop();
54 }
55
56 static void sig_message_quit(SERVER_REC *server, const char *nick,
57                              const char *address, const char *reason)
58 {
59         if (ignore_check(server, nick, address, NULL, reason, MSGLEVEL_QUITS))
60                 signal_stop();
61 }
62
63 static void sig_message_kick(SERVER_REC *server, const char *channel,
64                              const char *nick, const char *kicker,
65                              const char *address, const char *reason)
66 {
67         if (ignore_check(server, kicker, address,
68                          channel, reason, MSGLEVEL_KICKS))
69                 signal_stop();
70 }
71
72 static void sig_message_nick(SERVER_REC *server, const char *newnick,
73                              const char *oldnick, const char *address)
74 {
75         if (ignore_check(server, oldnick, address,
76                          NULL, NULL, MSGLEVEL_NICKS) ||
77             ignore_check(server, newnick, address,
78                          NULL, NULL, MSGLEVEL_NICKS))
79                 signal_stop();
80 }
81
82 static void sig_message_own_nick(SERVER_REC *server, const char *newnick,
83                                  const char *oldnick, const char *address)
84 {
85         if (ignore_check(server, oldnick, address, NULL, NULL, MSGLEVEL_NICKS))
86                 signal_stop();
87 }
88
89 static void sig_message_invite(SERVER_REC *server, const char *channel,
90                                const char *nick, const char *address)
91 {
92         if (*channel == '\0' ||
93             ignore_check(server, nick, address,
94                          channel, NULL, MSGLEVEL_INVITES))
95                 signal_stop();
96 }
97
98 static void sig_message_topic(SERVER_REC *server, const char *channel,
99                               const char *topic,
100                               const char *nick, const char *address)
101 {
102         if (ignore_check(server, nick, address,
103                          channel, topic, MSGLEVEL_TOPICS))
104                 signal_stop();
105 }
106
107 void fe_ignore_messages_init(void)
108 {
109         signal_add_first("message public", (SIGNAL_FUNC) sig_message_public);
110         signal_add_first("message private", (SIGNAL_FUNC) sig_message_private);
111         signal_add_first("message join", (SIGNAL_FUNC) sig_message_join);
112         signal_add_first("message part", (SIGNAL_FUNC) sig_message_part);
113         signal_add_first("message quit", (SIGNAL_FUNC) sig_message_quit);
114         signal_add_first("message kick", (SIGNAL_FUNC) sig_message_kick);
115         signal_add_first("message nick", (SIGNAL_FUNC) sig_message_nick);
116         signal_add_first("message own_nick", (SIGNAL_FUNC) sig_message_own_nick);
117         signal_add_first("message invite", (SIGNAL_FUNC) sig_message_invite);
118         signal_add_first("message topic", (SIGNAL_FUNC) sig_message_topic);
119 }
120
121 void fe_ignore_messages_deinit(void)
122 {
123         signal_remove("message public", (SIGNAL_FUNC) sig_message_public);
124         signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
125         signal_remove("message join", (SIGNAL_FUNC) sig_message_join);
126         signal_remove("message part", (SIGNAL_FUNC) sig_message_part);
127         signal_remove("message quit", (SIGNAL_FUNC) sig_message_quit);
128         signal_remove("message kick", (SIGNAL_FUNC) sig_message_kick);
129         signal_remove("message nick", (SIGNAL_FUNC) sig_message_nick);
130         signal_remove("message own_nick", (SIGNAL_FUNC) sig_message_own_nick);
131         signal_remove("message invite", (SIGNAL_FUNC) sig_message_invite);
132         signal_remove("message topic", (SIGNAL_FUNC) sig_message_topic);
133 }