summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-03-04 03:25:21 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-03-04 03:25:21 +0000
commitcf376ba806431a355c29486f1250953295f880e7 (patch)
treeb4da8c4b733ea4c2453761b95890dcd65e191805
parent0be624272c2d57e027be919428b99b2ffe15827b (diff)
downloadirssi-cf376ba806431a355c29486f1250953295f880e7.zip
Send "chat protocol deinit" signal when protocol is being
deinitialized. Servers and reconnections are automatically disconnected for the protocol when it's being deinitialized. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1341 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--src/core/servers-reconnect.c20
-rw-r--r--src/core/servers.c28
-rw-r--r--src/irc/core/irc-core.c2
-rw-r--r--src/irc/core/irc-servers.c5
4 files changed, 43 insertions, 12 deletions
diff --git a/src/core/servers-reconnect.c b/src/core/servers-reconnect.c
index 3f51bfda..0f50ad75 100644
--- a/src/core/servers-reconnect.c
+++ b/src/core/servers-reconnect.c
@@ -392,6 +392,19 @@ static void cmd_disconnect(const char *data, SERVER_REC *server)
signal_stop();
}
+static void sig_chat_protocol_deinit(CHAT_PROTOCOL_REC *proto)
+{
+ GSList *tmp, *next;
+
+ for (tmp = reconnects; tmp != NULL; tmp = next) {
+ RECONNECT_REC *rec = tmp->data;
+
+ next = tmp->next;
+ if (rec->conn->chat_type == proto->id)
+ server_reconnect_destroy(rec, TRUE);
+ }
+}
+
static void read_settings(void)
{
reconnect_time = settings_get_int("server_reconnect_time");
@@ -410,7 +423,9 @@ void servers_reconnect_init(void)
signal_add("server connect failed", (SIGNAL_FUNC) sig_reconnect);
signal_add("server disconnected", (SIGNAL_FUNC) sig_reconnect);
signal_add("event connected", (SIGNAL_FUNC) sig_connected);
+ signal_add("chat protocol deinit", (SIGNAL_FUNC) sig_chat_protocol_deinit);
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
+
command_bind("rmreconns", NULL, (SIGNAL_FUNC) cmd_rmreconns);
command_bind("reconnect", NULL, (SIGNAL_FUNC) cmd_reconnect);
command_bind_first("disconnect", NULL, (SIGNAL_FUNC) cmd_disconnect);
@@ -420,13 +435,12 @@ void servers_reconnect_deinit(void)
{
g_source_remove(reconnect_timeout_tag);
- while (reconnects != NULL)
- server_reconnect_destroy(reconnects->data, TRUE);
-
signal_remove("server connect failed", (SIGNAL_FUNC) sig_reconnect);
signal_remove("server disconnected", (SIGNAL_FUNC) sig_reconnect);
signal_remove("event connected", (SIGNAL_FUNC) sig_connected);
+ signal_remove("chat protocol deinit", (SIGNAL_FUNC) sig_chat_protocol_deinit);
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
+
command_unbind("rmreconns", (SIGNAL_FUNC) cmd_rmreconns);
command_unbind("reconnect", (SIGNAL_FUNC) cmd_reconnect);
command_unbind("disconnect", (SIGNAL_FUNC) cmd_disconnect);
diff --git a/src/core/servers.c b/src/core/servers.c
index 6ad9b711..02fda4d9 100644
--- a/src/core/servers.c
+++ b/src/core/servers.c
@@ -28,6 +28,8 @@
#include "rawlog.h"
#include "settings.h"
+
+#include "chat-protocols.h"
#include "servers.h"
#include "servers-reconnect.h"
#include "servers-redirect.h"
@@ -490,11 +492,32 @@ SERVER_REC *cmd_options_get_server(const char *cmd,
return server;
}
+static void disconnect_servers(GSList *servers, int chat_type)
+{
+ GSList *tmp, *next;
+
+ for (tmp = servers; tmp != NULL; tmp = next) {
+ SERVER_REC *rec = tmp->data;
+
+ next = tmp->next;
+ if (rec->chat_type == chat_type)
+ server_disconnect(rec);
+ }
+}
+
+static void sig_chat_protocol_deinit(CHAT_PROTOCOL_REC *proto)
+{
+ disconnect_servers(servers, proto->id);
+ disconnect_servers(lookup_servers, proto->id);
+}
+
void servers_init(void)
{
settings_add_bool("server", "resolve_prefer_ipv6", FALSE);
lookup_servers = servers = NULL;
+ signal_add("chat protocol deinit", (SIGNAL_FUNC) sig_chat_protocol_deinit);
+
servers_reconnect_init();
servers_redirect_init();
servers_setup_init();
@@ -502,10 +525,7 @@ void servers_init(void)
void servers_deinit(void)
{
- while (servers != NULL)
- server_disconnect(servers->data);
- while (lookup_servers != NULL)
- server_connect_failed(lookup_servers->data, NULL);
+ signal_remove("chat protocol deinit", (SIGNAL_FUNC) sig_chat_protocol_deinit);
servers_setup_deinit();
servers_redirect_deinit();
diff --git a/src/irc/core/irc-core.c b/src/irc/core/irc-core.c
index 6671c33a..cce9d0d7 100644
--- a/src/irc/core/irc-core.c
+++ b/src/irc/core/irc-core.c
@@ -111,6 +111,8 @@ void irc_core_init(void)
void irc_core_deinit(void)
{
+ signal_emit("chat protocol deinit", 1, chat_protocol_find("IRC"));
+
irc_log_deinit();
irc_expandos_deinit();
irc_rawlog_deinit();
diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c
index 425552fd..82e1dd0c 100644
--- a/src/irc/core/irc-servers.c
+++ b/src/irc/core/irc-servers.c
@@ -461,11 +461,6 @@ void irc_servers_init(void)
void irc_servers_deinit(void)
{
- while (servers != NULL)
- server_disconnect(servers->data);
- while (lookup_servers != NULL)
- server_disconnect(lookup_servers->data);
-
g_source_remove(cmd_tag);
signal_remove("server connect free", (SIGNAL_FUNC) sig_server_connect_free);