Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / silc / core / silc-servers-reconnect.c
1 /*
2  silc-servers-reconnect.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
24 #include "silc-servers.h"
25
26 static void sig_server_reconnect_save_status(SILC_SERVER_CONNECT_REC *conn,
27                                              SILC_SERVER_REC *server)
28 {
29         if (!IS_SILC_SERVER_CONNECT(conn) || !IS_SILC_SERVER(server))
30                 return;
31
32         g_free_not_null(conn->channels);
33         conn->channels = silc_server_get_channels(server);
34 }
35
36 static void sig_server_connect_copy(SERVER_CONNECT_REC **dest,
37                                     SILC_SERVER_CONNECT_REC *src)
38 {
39         SILC_SERVER_CONNECT_REC *rec;
40
41         g_return_if_fail(dest != NULL);
42         if (!IS_SILC_SERVER_CONNECT(src))
43                 return;
44
45         rec = g_new0(SILC_SERVER_CONNECT_REC, 1);
46         rec->chat_type = SILC_PROTOCOL;
47         *dest = (SERVER_CONNECT_REC *) rec;
48 }
49
50 void silc_servers_reconnect_init(void)
51 {
52         signal_add("server reconnect save status", (SIGNAL_FUNC) sig_server_reconnect_save_status);
53         signal_add("server connect copy", (SIGNAL_FUNC) sig_server_connect_copy);
54 }
55
56 void silc_servers_reconnect_deinit(void)
57 {
58         signal_remove("server reconnect save status", (SIGNAL_FUNC) sig_server_reconnect_save_status);
59         signal_remove("server connect copy", (SIGNAL_FUNC) sig_server_connect_copy);
60 }