2 fe-silc-channels.c : irssi
4 Copyright (C) 2000 Timo Sirainen
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.
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.
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
26 #include "special-vars.h"
29 #include "silc-servers.h"
31 #include "window-items.h"
32 #include "hilight-text.h"
33 #include "printtext.h"
34 #include "module-formats.h"
36 void sig_message_appears(SILC_SERVER_REC *server, const char *channel,
37 const char *oldnick, const char *newnick,
40 printformat_module("fe-common/silc", server, channel, MSGLEVEL_NICKS,
41 SILCTXT_CHANNEL_APPEARS, oldnick, newnick,
45 /* FIXME: convert identifier */
46 void sig_message_channel_pubkeys(SILC_SERVER_REC *server,
47 SilcChannelEntry channel_entry,
48 SilcBuffer channel_pubkeys)
51 SilcArgumentPayload chpks;
53 SilcUInt32 pk_len, type;
55 char *fingerprint, *babbleprint;
57 SilcPublicKeyIdentifier ident;
59 if (channel_pubkeys == NULL) {
60 printformat_module("fe-common/silc", server, NULL,
61 MSGLEVEL_CRAP, SILCTXT_CHANNEL_PK_NO_LIST,
62 channel_entry->channel_name);
66 printformat_module("fe-common/silc", server, NULL,
67 MSGLEVEL_CRAP, SILCTXT_CHANNEL_PK_LIST,
68 channel_entry->channel_name);
70 SILC_GET16_MSB(argc, channel_pubkeys->data);
71 chpks = silc_argument_payload_parse(channel_pubkeys->data + 2,
72 channel_pubkeys->len - 2, argc);
76 pk = silc_argument_get_first_arg(chpks, &type, &pk_len);
78 fingerprint = silc_hash_fingerprint(NULL, pk + 4, pk_len - 4);
79 babbleprint = silc_hash_babbleprint(NULL, pk + 4, pk_len - 4);
80 silc_pkcs_public_key_payload_decode(pk, pk_len, &pubkey);
81 ident = silc_pkcs_decode_identifier(pubkey->identifier);
83 printformat_module("fe-common/silc", server, NULL,
84 MSGLEVEL_CRAP, SILCTXT_CHANNEL_PK_LIST_ENTRY,
85 c++, channel_entry->channel_name,
86 type == 0x00 ? "Added" : "Removed",
87 ident->realname ? ident->realname : "",
88 fingerprint, babbleprint);
90 silc_free(fingerprint);
91 silc_free(babbleprint);
92 silc_pkcs_public_key_free(pubkey);
93 silc_pkcs_free_identifier(ident);
94 pk = silc_argument_get_next_arg(chpks, &type, &pk_len);
97 silc_argument_payload_free(chpks);
100 void sig_message_generic(SILC_SERVER_REC *server, const char *target,
101 int msglevel, const char *msg)
103 printtext(server, target, msglevel, "%s", msg);
106 void sig_cmode_changed(SILC_SERVER_REC *server, const char *channel,
107 const char *mode, const char *nick)
109 printformat_module("fe-common/silc", server, channel, MSGLEVEL_MODES,
110 SILCTXT_CHANNEL_CMODE, channel,
111 mode ? mode : "removed all",
115 void sig_cumode_changed(SILC_SERVER_REC *server, const char *channel,
117 const char *mode, const char *nick)
119 printformat_module("fe-common/silc", server, channel, MSGLEVEL_MODES,
120 SILCTXT_CHANNEL_CUMODE, channel, who,
121 mode ? mode : "removed all",
125 void sig_channel_founder(SILC_SERVER_REC *server, const char *channel,
128 printformat_module("fe-common/silc", server, channel, MSGLEVEL_CRAP,
129 SILCTXT_CHANNEL_FOUNDER, channel, nick);
132 void sig_quieted(SILC_SERVER_REC *server, const char *channel)
134 printformat_module("fe-common/silc", server, channel, MSGLEVEL_CRAP,
135 SILCTXT_CHANNEL_QUIETED, channel);
138 void sig_motd(SILC_SERVER_REC *server, const char *motd)
140 printtext_multiline(server, NULL, MSGLEVEL_CRAP, "%s", motd);
143 void fe_silc_channels_init(void)
145 signal_add("message silc appears",
146 (SIGNAL_FUNC) sig_message_appears);
147 signal_add("message silc pubkeys",
148 (SIGNAL_FUNC) sig_message_channel_pubkeys);
149 signal_add("message silc generic",
150 (SIGNAL_FUNC) sig_message_generic);
151 signal_add("message silc cmode",
152 (SIGNAL_FUNC) sig_cmode_changed);
153 signal_add("message silc cumode",
154 (SIGNAL_FUNC) sig_cumode_changed);
155 signal_add("message silc founder",
156 (SIGNAL_FUNC) sig_channel_founder);
157 signal_add("message silc quieted",
158 (SIGNAL_FUNC) sig_quieted);
159 signal_add("message silc motd",
160 (SIGNAL_FUNC) sig_motd);
163 void fe_silc_channels_deinit(void)
165 signal_remove("message silc appears",
166 (SIGNAL_FUNC) sig_message_appears);
167 signal_remove("message silc pubkeys",
168 (SIGNAL_FUNC) sig_message_channel_pubkeys);
169 signal_remove("message silc generic",
170 (SIGNAL_FUNC) sig_message_generic);
171 signal_remove("message silc cmode",
172 (SIGNAL_FUNC) sig_cmode_changed);
173 signal_remove("message silc cumode",
174 (SIGNAL_FUNC) sig_cumode_changed);
175 signal_remove("message silc founder",
176 (SIGNAL_FUNC) sig_channel_founder);
177 signal_remove("message silc quieted",
178 (SIGNAL_FUNC) sig_quieted);
179 signal_remove("message silc motd",
180 (SIGNAL_FUNC) sig_motd);