mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
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
This commit is contained in:
parent
0be624272c
commit
cf376ba806
@ -392,6 +392,19 @@ static void cmd_disconnect(const char *data, SERVER_REC *server)
|
|||||||
signal_stop();
|
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)
|
static void read_settings(void)
|
||||||
{
|
{
|
||||||
reconnect_time = settings_get_int("server_reconnect_time");
|
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 connect failed", (SIGNAL_FUNC) sig_reconnect);
|
||||||
signal_add("server disconnected", (SIGNAL_FUNC) sig_reconnect);
|
signal_add("server disconnected", (SIGNAL_FUNC) sig_reconnect);
|
||||||
signal_add("event connected", (SIGNAL_FUNC) sig_connected);
|
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);
|
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
||||||
|
|
||||||
command_bind("rmreconns", NULL, (SIGNAL_FUNC) cmd_rmreconns);
|
command_bind("rmreconns", NULL, (SIGNAL_FUNC) cmd_rmreconns);
|
||||||
command_bind("reconnect", NULL, (SIGNAL_FUNC) cmd_reconnect);
|
command_bind("reconnect", NULL, (SIGNAL_FUNC) cmd_reconnect);
|
||||||
command_bind_first("disconnect", NULL, (SIGNAL_FUNC) cmd_disconnect);
|
command_bind_first("disconnect", NULL, (SIGNAL_FUNC) cmd_disconnect);
|
||||||
@ -420,13 +435,12 @@ void servers_reconnect_deinit(void)
|
|||||||
{
|
{
|
||||||
g_source_remove(reconnect_timeout_tag);
|
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 connect failed", (SIGNAL_FUNC) sig_reconnect);
|
||||||
signal_remove("server disconnected", (SIGNAL_FUNC) sig_reconnect);
|
signal_remove("server disconnected", (SIGNAL_FUNC) sig_reconnect);
|
||||||
signal_remove("event connected", (SIGNAL_FUNC) sig_connected);
|
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);
|
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||||
|
|
||||||
command_unbind("rmreconns", (SIGNAL_FUNC) cmd_rmreconns);
|
command_unbind("rmreconns", (SIGNAL_FUNC) cmd_rmreconns);
|
||||||
command_unbind("reconnect", (SIGNAL_FUNC) cmd_reconnect);
|
command_unbind("reconnect", (SIGNAL_FUNC) cmd_reconnect);
|
||||||
command_unbind("disconnect", (SIGNAL_FUNC) cmd_disconnect);
|
command_unbind("disconnect", (SIGNAL_FUNC) cmd_disconnect);
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include "rawlog.h"
|
#include "rawlog.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "chat-protocols.h"
|
||||||
#include "servers.h"
|
#include "servers.h"
|
||||||
#include "servers-reconnect.h"
|
#include "servers-reconnect.h"
|
||||||
#include "servers-redirect.h"
|
#include "servers-redirect.h"
|
||||||
@ -490,11 +492,32 @@ SERVER_REC *cmd_options_get_server(const char *cmd,
|
|||||||
return server;
|
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)
|
void servers_init(void)
|
||||||
{
|
{
|
||||||
settings_add_bool("server", "resolve_prefer_ipv6", FALSE);
|
settings_add_bool("server", "resolve_prefer_ipv6", FALSE);
|
||||||
lookup_servers = servers = NULL;
|
lookup_servers = servers = NULL;
|
||||||
|
|
||||||
|
signal_add("chat protocol deinit", (SIGNAL_FUNC) sig_chat_protocol_deinit);
|
||||||
|
|
||||||
servers_reconnect_init();
|
servers_reconnect_init();
|
||||||
servers_redirect_init();
|
servers_redirect_init();
|
||||||
servers_setup_init();
|
servers_setup_init();
|
||||||
@ -502,10 +525,7 @@ void servers_init(void)
|
|||||||
|
|
||||||
void servers_deinit(void)
|
void servers_deinit(void)
|
||||||
{
|
{
|
||||||
while (servers != NULL)
|
signal_remove("chat protocol deinit", (SIGNAL_FUNC) sig_chat_protocol_deinit);
|
||||||
server_disconnect(servers->data);
|
|
||||||
while (lookup_servers != NULL)
|
|
||||||
server_connect_failed(lookup_servers->data, NULL);
|
|
||||||
|
|
||||||
servers_setup_deinit();
|
servers_setup_deinit();
|
||||||
servers_redirect_deinit();
|
servers_redirect_deinit();
|
||||||
|
@ -111,6 +111,8 @@ void irc_core_init(void)
|
|||||||
|
|
||||||
void irc_core_deinit(void)
|
void irc_core_deinit(void)
|
||||||
{
|
{
|
||||||
|
signal_emit("chat protocol deinit", 1, chat_protocol_find("IRC"));
|
||||||
|
|
||||||
irc_log_deinit();
|
irc_log_deinit();
|
||||||
irc_expandos_deinit();
|
irc_expandos_deinit();
|
||||||
irc_rawlog_deinit();
|
irc_rawlog_deinit();
|
||||||
|
@ -461,11 +461,6 @@ void irc_servers_init(void)
|
|||||||
|
|
||||||
void irc_servers_deinit(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);
|
g_source_remove(cmd_tag);
|
||||||
|
|
||||||
signal_remove("server connect free", (SIGNAL_FUNC) sig_server_connect_free);
|
signal_remove("server connect free", (SIGNAL_FUNC) sig_server_connect_free);
|
||||||
|
Loading…
Reference in New Issue
Block a user