diff options
author | Timo Sirainen <cras@irssi.org> | 2001-02-17 19:44:22 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-02-17 19:44:22 +0000 |
commit | be6ba53fa47bc546279a2575523281845fe80da9 (patch) | |
tree | 2f08f6281cfbd38a1df2abe4fe69ccfd6f208f51 /src | |
parent | 513e140bcebce617d6078a9532ab9976437c3ef6 (diff) | |
download | irssi-be6ba53fa47bc546279a2575523281845fe80da9.zip |
Config file: ircnets -> chatnets, added type = "chat protocol" to
chatnet config. Moved reading chatnets to core. Lots of other
multiprotocol updates.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1237 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
34 files changed, 526 insertions, 409 deletions
diff --git a/src/core/Makefile.am b/src/core/Makefile.am index cce6b945..0f1ff588 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -50,8 +50,9 @@ libcore_a_SOURCES = \ write-buffer.c structure_headers = \ - chatnet-rec.h \ channel-rec.h \ + channel-setup-rec.h \ + chatnet-rec.h \ query-rec.h \ server-rec.h \ server-setup-rec.h \ diff --git a/src/core/channel-setup-rec.h b/src/core/channel-setup-rec.h new file mode 100644 index 00000000..a0b28978 --- /dev/null +++ b/src/core/channel-setup-rec.h @@ -0,0 +1,12 @@ +int type; /* module_get_uniq_id("CHANNEL SETUP", 0) */ +int chat_type; /* chat_protocol_lookup(xx) */ + +char *name; +char *chatnet; +char *password; + +char *botmasks; +char *autosendcmd; + +unsigned int autojoin:1; +GHashTable *module_data; diff --git a/src/core/channels-setup.c b/src/core/channels-setup.c index 8733b3ed..a53bd3f3 100644 --- a/src/core/channels-setup.c +++ b/src/core/channels-setup.c @@ -23,49 +23,13 @@ #include "lib-config/iconfig.h" #include "settings.h" -#include "channels.h" -#include "channels-setup.h" +#include "chat-protocols.h" +#include "chatnets.h" #include "servers-setup.h" +#include "channels-setup.h" GSList *setupchannels; -static CHANNEL_SETUP_REC *channel_setup_read(CONFIG_NODE *node) -{ - CHANNEL_SETUP_REC *rec; - char *channel, *password, *botmasks, *autosendcmd; - - g_return_val_if_fail(node != NULL, NULL); - - channel = config_node_get_str(node, "name", NULL); - if (channel == NULL) { - /* missing information.. */ - return NULL; - } - - password = config_node_get_str(node, "password", NULL); - botmasks = config_node_get_str(node, "botmasks", NULL); - autosendcmd = config_node_get_str(node, "autosendcmd", NULL); - - rec = g_new(CHANNEL_SETUP_REC, 1); - rec->autojoin = config_node_get_bool(node, "autojoin", FALSE); - rec->name = g_strdup(channel); - rec->chatnet = g_strdup(config_node_get_str(node, "chatnet", NULL)); - if (rec->chatnet == NULL) /* FIXME: remove this after .98... */ { - rec->chatnet = g_strdup(config_node_get_str(node, "ircnet", NULL)); - if (rec->chatnet != NULL) { - iconfig_node_set_str(node, "chatnet", rec->chatnet); - iconfig_node_set_str(node, "ircnet", NULL); - } - } - rec->password = (password == NULL || *password == '\0') ? NULL : g_strdup(password); - rec->botmasks = (botmasks == NULL || *botmasks == '\0') ? NULL : g_strdup(botmasks); - rec->autosendcmd = (autosendcmd == NULL || *autosendcmd == '\0') ? NULL : g_strdup(autosendcmd); - - setupchannels = g_slist_append(setupchannels, rec); - signal_emit("channel setup created", 2, rec, node); - return rec; -} - static void channel_setup_save(CHANNEL_SETUP_REC *channel) { CONFIG_NODE *parentnode, *node; @@ -88,15 +52,7 @@ static void channel_setup_save(CHANNEL_SETUP_REC *channel) iconfig_node_set_str(node, "autosendcmd", channel->autosendcmd); } -static void channel_config_remove(CHANNEL_SETUP_REC *channel) -{ - CONFIG_NODE *node; - - node = iconfig_node_traverse("channels", FALSE); - if (node != NULL) iconfig_node_list_remove(node, g_slist_index(setupchannels, channel)); -} - -void channels_setup_create(CHANNEL_SETUP_REC *channel) +void channel_setup_create(CHANNEL_SETUP_REC *channel) { if (g_slist_find(setupchannels, channel) == NULL) setupchannels = g_slist_append(setupchannels, channel); @@ -105,28 +61,37 @@ void channels_setup_create(CHANNEL_SETUP_REC *channel) signal_emit("channel setup created", 1, channel); } -static void channels_setup_destroy_rec(CHANNEL_SETUP_REC *channel) +static void channel_config_remove(CHANNEL_SETUP_REC *channel) +{ + CONFIG_NODE *node; + + node = iconfig_node_traverse("channels", FALSE); + if (node != NULL) iconfig_node_list_remove(node, g_slist_index(setupchannels, channel)); +} + +static void channel_setup_destroy(CHANNEL_SETUP_REC *channel) { g_return_if_fail(channel != NULL); setupchannels = g_slist_remove(setupchannels, channel); signal_emit("channel setup destroyed", 1, channel); - g_free(channel->name); g_free_not_null(channel->chatnet); g_free_not_null(channel->password); g_free_not_null(channel->botmasks); g_free_not_null(channel->autosendcmd); + g_free(channel->name); g_free(channel); } -void channels_setup_destroy(CHANNEL_SETUP_REC *channel) +void channel_setup_remove(CHANNEL_SETUP_REC *channel) { channel_config_remove(channel); - channels_setup_destroy_rec(channel); + channel_setup_destroy(channel); } -CHANNEL_SETUP_REC *channels_setup_find(const char *channel, const char *chatnet) +CHANNEL_SETUP_REC *channel_setup_find(const char *channel, + const char *chatnet) { GSList *tmp; @@ -143,13 +108,52 @@ CHANNEL_SETUP_REC *channels_setup_find(const char *channel, const char *chatnet) return NULL; } +static CHANNEL_SETUP_REC *channel_setup_read(CONFIG_NODE *node) +{ + CHANNEL_SETUP_REC *rec; + CHATNET_REC *chatnetrec; + char *channel, *chatnet; + + g_return_val_if_fail(node != NULL, NULL); + + channel = config_node_get_str(node, "name", NULL); + chatnet = config_node_get_str(node, "chatnet", NULL); + if (chatnet == NULL) /* FIXME: remove this after .98... */ { + chatnet = g_strdup(config_node_get_str(node, "ircnet", NULL)); + if (chatnet != NULL) { + iconfig_node_set_str(node, "chatnet", chatnet); + iconfig_node_set_str(node, "ircnet", NULL); + } + } + + chatnetrec = chatnet == NULL ? NULL : chatnet_find(chatnet); + if (channel == NULL || chatnetrec == NULL) { + /* missing information.. */ + return NULL; + } + + rec = CHAT_PROTOCOL(chatnetrec)->create_channel_setup(); + rec->type = module_get_uniq_id("CHANNEL SETUP", 0); + rec->chat_type = CHAT_PROTOCOL(chatnetrec)->id; + rec->autojoin = config_node_get_bool(node, "autojoin", FALSE); + rec->name = g_strdup(channel); + rec->chatnet = g_strdup(chatnetrec != NULL ? chatnetrec->name : chatnet); + rec->password = g_strdup(config_node_get_str(node, "password", NULL)); + rec->botmasks = g_strdup(config_node_get_str(node, "botmasks", NULL)); + rec->autosendcmd = g_strdup(config_node_get_str(node, "autosendcmd", NULL)); + + setupchannels = g_slist_append(setupchannels, rec); + signal_emit("channel setup created", 2, rec, node); + return rec; +} + static void channels_read_config(void) { CONFIG_NODE *node; GSList *tmp; while (setupchannels != NULL) - channels_setup_destroy_rec(setupchannels->data); + channel_setup_destroy(setupchannels->data); /* Read channels */ node = iconfig_node_traverse("channels", FALSE); @@ -161,6 +165,7 @@ static void channels_read_config(void) void channels_setup_init(void) { + setupchannels = NULL; source_host_ok = FALSE; signal_add("setup reread", (SIGNAL_FUNC) channels_read_config); @@ -170,7 +175,7 @@ void channels_setup_init(void) void channels_setup_deinit(void) { while (setupchannels != NULL) - channels_setup_destroy(setupchannels->data); + channel_setup_destroy(setupchannels->data); signal_remove("setup reread", (SIGNAL_FUNC) channels_read_config); signal_remove("irssi init read settings", (SIGNAL_FUNC) channels_read_config); diff --git a/src/core/channels-setup.h b/src/core/channels-setup.h index b07d9a4f..423bccb2 100644 --- a/src/core/channels-setup.h +++ b/src/core/channels-setup.h @@ -3,16 +3,14 @@ #include "modules.h" -struct _CHANNEL_SETUP_REC { - char *name; - char *chatnet; - char *password; +#define CHANNEL_SETUP(server) \ + MODULE_CHECK_CAST(server, CHANNEL_SETUP_REC, type, "CHANNEL SETUP") - char *botmasks; - char *autosendcmd; +#define IS_CHANNEL_SETUP(server) \ + (CHANNEL_SETUP(server) ? TRUE : FALSE) - unsigned int autojoin:1; - GHashTable *module_data; +struct _CHANNEL_SETUP_REC { +#include "channel-setup-rec.h" }; extern GSList *setupchannels; @@ -20,11 +18,11 @@ extern GSList *setupchannels; void channels_setup_init(void); void channels_setup_deinit(void); -void channels_setup_create(CHANNEL_SETUP_REC *channel); -void channels_setup_destroy(CHANNEL_SETUP_REC *channel); +void channel_setup_create(CHANNEL_SETUP_REC *channel); +void channel_setup_remove(CHANNEL_SETUP_REC *channel); -CHANNEL_SETUP_REC *channels_setup_find(const char *channel, - const char *chatnet); +CHANNEL_SETUP_REC *channel_setup_find(const char *channel, + const char *chatnet); #define channel_chatnet_match(rec, chatnet) \ ((rec) == NULL || (rec)[0] == '\0' || \ diff --git a/src/core/channels.c b/src/core/channels.c index 9e18654e..1878dc02 100644 --- a/src/core/channels.c +++ b/src/core/channels.c @@ -30,21 +30,6 @@ GSList *channels; /* List of all channels */ -/* Create a new channel */ -CHANNEL_REC *channel_create(int chat_type, SERVER_REC *server, - const char *name, int automatic) -{ - CHANNEL_REC *channel; - - g_return_val_if_fail(server == NULL || IS_SERVER(server), NULL); - g_return_val_if_fail(name != NULL, NULL); - - channel = NULL; - signal_emit("channel create", 5, &channel, GINT_TO_POINTER(chat_type), - server, name, GINT_TO_POINTER(automatic)); - return channel; -} - void channel_init(CHANNEL_REC *channel, int automatic) { g_return_if_fail(channel != NULL); @@ -173,7 +158,7 @@ void channel_send_autocommands(CHANNEL_REC *channel) g_return_if_fail(IS_CHANNEL(channel)); - rec = channels_setup_find(channel->name, channel->server->connrec->chatnet); + rec = channel_setup_find(channel->name, channel->server->connrec->chatnet); if (rec == NULL || rec->autosendcmd == NULL || !*rec->autosendcmd) return; diff --git a/src/core/channels.h b/src/core/channels.h index b571a5d4..98b75ee0 100644 --- a/src/core/channels.h +++ b/src/core/channels.h @@ -18,10 +18,6 @@ struct _CHANNEL_REC { extern GSList *channels; -/* Create a new channel */ -CHANNEL_REC *channel_create(int chat_type, SERVER_REC *server, - const char *name, int automatic); - /* Create new channel record */ void channel_init(CHANNEL_REC *channel, int automatic); void channel_destroy(CHANNEL_REC *channel); diff --git a/src/core/chat-protocols.c b/src/core/chat-protocols.c index 2b3c3205..a8296f8a 100644 --- a/src/core/chat-protocols.c +++ b/src/core/chat-protocols.c @@ -19,12 +19,19 @@ */ #include "module.h" +#include "modules.h" #include "signals.h" #include "chat-protocols.h" -static int id_counter; +#include "chatnets.h" +#include "servers.h" +#include "servers-setup.h" +#include "channels-setup.h" + GSList *chat_protocols; +static CHAT_PROTOCOL_REC *default_proto; + void *chat_protocol_check_cast(void *object, int type_pos, const char *id) { return object == NULL || @@ -75,18 +82,48 @@ CHAT_PROTOCOL_REC *chat_protocol_find_id(int id) return NULL; } +CHAT_PROTOCOL_REC *chat_protocol_find_net(GHashTable *optlist) +{ + GSList *tmp; + + g_return_val_if_fail(optlist != NULL, NULL); + + for (tmp = chat_protocols; tmp != NULL; tmp = tmp->next) { + CHAT_PROTOCOL_REC *rec = tmp->data; + + if (g_hash_table_lookup(optlist, rec->chatnet) != NULL) + return rec; + } + + return NULL; +} + /* Register new chat protocol. */ -void chat_protocol_register(CHAT_PROTOCOL_REC *rec) +CHAT_PROTOCOL_REC *chat_protocol_register(CHAT_PROTOCOL_REC *rec) { - g_return_if_fail(rec != NULL); + CHAT_PROTOCOL_REC *newrec; + + g_return_val_if_fail(rec != NULL, NULL); + + newrec = chat_protocol_find(rec->name); + if (newrec == NULL) + newrec = g_new0(CHAT_PROTOCOL_REC, 1); + else if (rec->fullname != NULL) { + /* already registered */ + return newrec; + } + + memcpy(newrec, rec, sizeof(CHAT_PROTOCOL_REC)); + newrec->id = module_get_uniq_id_str("PROTOCOL", rec->name); + newrec->name = g_strdup(rec->name); - if (chat_protocol_find(rec->name) != NULL) - return; + chat_protocols = g_slist_append(chat_protocols, newrec); - rec->id = ++id_counter; - chat_protocols = g_slist_append(chat_protocols, rec); + if (default_proto == NULL) + chat_protocol_set_default(newrec); - signal_emit("chat protocol created", 1, rec); + signal_emit("chat protocol created", 1, newrec); + return newrec; } static void chat_protocol_destroy(CHAT_PROTOCOL_REC *rec) @@ -94,7 +131,15 @@ static void chat_protocol_destroy(CHAT_PROTOCOL_REC *rec) g_return_if_fail(rec != NULL); chat_protocols = g_slist_remove(chat_protocols, rec); + + if (default_proto == rec) { + chat_protocol_set_default(chat_protocols == NULL ? NULL : + chat_protocols->data); + } + signal_emit("chat protocol destroyed", 1, rec); + + g_free(rec->name); g_free(rec); } @@ -109,9 +154,64 @@ void chat_protocol_unregister(const char *name) if (rec != NULL) chat_protocol_destroy(rec); } +/* Default chat protocol to use */ +void chat_protocol_set_default(CHAT_PROTOCOL_REC *rec) +{ + default_proto = rec; +} + +CHAT_PROTOCOL_REC *chat_protocol_get_default(void) +{ + return default_proto; +} + +static CHATNET_REC *create_chatnet(void) +{ + return g_new0(CHATNET_REC, 1); +} + +static SERVER_SETUP_REC *create_server_setup(void) +{ + return g_new0(SERVER_SETUP_REC, 1); +} + +static CHANNEL_SETUP_REC *create_channel_setup(void) +{ + return g_new0(CHANNEL_SETUP_REC, 1); +} + +static SERVER_CONNECT_REC *create_server_connect(void) +{ + return g_new0(SERVER_CONNECT_REC, 1); +} + +/* Return "unknown chat protocol" record. Used when protocol name is + specified but it isn't registered yet. */ +CHAT_PROTOCOL_REC *chat_protocol_get_unknown(const char *name) +{ + CHAT_PROTOCOL_REC *rec, *newrec; + + g_return_val_if_fail(name != NULL, NULL); + + rec = chat_protocol_find(name); + if (rec != NULL) + return rec; + + rec = g_new0(CHAT_PROTOCOL_REC, 1); + rec->name = (char *) name; + rec->create_chatnet = create_chatnet; + rec->create_server_setup = create_server_setup; + rec->create_channel_setup = create_channel_setup; + rec->create_server_connect = create_server_connect; + + newrec = chat_protocol_register(rec); + g_free(rec); + return newrec; +} + void chat_protocols_init(void) { - id_counter = 0; + default_proto = NULL; chat_protocols = NULL; } diff --git a/src/core/chat-protocols.h b/src/core/chat-protocols.h index 3f614a50..a8467333 100644 --- a/src/core/chat-protocols.h +++ b/src/core/chat-protocols.h @@ -7,6 +7,15 @@ typedef struct { char *name; char *fullname; char *chatnet; + + CHATNET_REC *(*create_chatnet) (void); + SERVER_SETUP_REC *(*create_server_setup) (void); + CHANNEL_SETUP_REC *(*create_channel_setup) (void); + SERVER_CONNECT_REC *(*create_server_connect) (void); + + SERVER_REC *(*server_connect) (SERVER_CONNECT_REC *); + CHANNEL_REC *(*channel_create) (SERVER_REC *, const char *, int); + QUERY_REC *(*query_create) (const char *, const char *, int); } CHAT_PROTOCOL_REC; extern GSList *chat_protocols; @@ -16,8 +25,12 @@ extern GSList *chat_protocols; offsetof(cast, type_field), id)) void *chat_protocol_check_cast(void *object, int type_pos, const char *id); +#define CHAT_PROTOCOL(object) \ + ((object) == NULL ? chat_protocol_get_default() : \ + chat_protocol_find_id((object)->chat_type)) + /* Register new chat protocol. */ -void chat_protocol_register(CHAT_PROTOCOL_REC *rec); +CHAT_PROTOCOL_REC *chat_protocol_register(CHAT_PROTOCOL_REC *rec); /* Unregister chat protocol. */ void chat_protocol_unregister(const char *name); @@ -26,6 +39,15 @@ void chat_protocol_unregister(const char *name); int chat_protocol_lookup(const char *name); CHAT_PROTOCOL_REC *chat_protocol_find(const char *name); CHAT_PROTOCOL_REC *chat_protocol_find_id(int id); +CHAT_PROTOCOL_REC *chat_protocol_find_net(GHashTable *optlist); + +/* Default chat protocol to use */ +void chat_protocol_set_default(CHAT_PROTOCOL_REC *rec); +CHAT_PROTOCOL_REC *chat_protocol_get_default(void); + +/* Return "unknown chat protocol" record. Used when protocol name is + specified but it isn't registered yet. */ +CHAT_PROTOCOL_REC *chat_protocol_get_unknown(const char *name); void chat_protocols_init(void); void chat_protocols_deinit(void); diff --git a/src/core/chatnets.c b/src/core/chatnets.c index def9eb68..a2cff529 100644 --- a/src/core/chatnets.c +++ b/src/core/chatnets.c @@ -25,42 +25,36 @@ #include "lib-config/iconfig.h" #include "settings.h" +#include "chat-protocols.h" #include "chatnets.h" #include "servers.h" GSList *chatnets; /* list of available chat networks */ -void chatnet_read(CHATNET_REC *chatnet, CONFIG_NODE *node) +static void chatnet_config_save(CHATNET_REC *chatnet) { - g_return_if_fail(chatnet != NULL); - g_return_if_fail(node != NULL); - g_return_if_fail(node->key != NULL); - - chatnet->type = module_get_uniq_id("CHATNET", 0); - chatnet->name = g_strdup(node->key); - chatnet->nick = g_strdup(config_node_get_str(node, "nick", NULL)); - chatnet->username = g_strdup(config_node_get_str(node, "username", NULL)); - chatnet->realname = g_strdup(config_node_get_str(node, "realname", NULL)); - chatnet->own_host = g_strdup(config_node_get_str(node, "host", NULL)); - chatnet->autosendcmd = g_strdup(config_node_get_str(node, "autosendcmd", NULL)); - - chatnets = g_slist_append(chatnets, chatnet); -} - -CONFIG_NODE *chatnet_save(CHATNET_REC *chatnet, CONFIG_NODE *node) -{ - g_return_val_if_fail(node != NULL, NULL); - g_return_val_if_fail(chatnet != NULL, NULL); + CONFIG_NODE *node; + node = iconfig_node_traverse("chatnets", TRUE); node = config_node_section(node, chatnet->name, NODE_TYPE_BLOCK); iconfig_node_clear(node); + iconfig_node_set_str(node, "type", chat_protocol_find_id(chatnet->chat_type)->name); iconfig_node_set_str(node, "nick", chatnet->nick); iconfig_node_set_str(node, "username", chatnet->username); iconfig_node_set_str(node, "realname", chatnet->realname); iconfig_node_set_str(node, "host", chatnet->own_host); iconfig_node_set_str(node, "autosendcmd", chatnet->autosendcmd); - return node; + + signal_emit("chatnet saved", 2, chatnet, node); +} + +static void chatnet_config_remove(CHATNET_REC *chatnet) +{ + CONFIG_NODE *node; + + node = iconfig_node_traverse("chatnets", FALSE); + if (node != NULL) iconfig_node_set_str(node, chatnet->name, NULL); } void chatnet_create(CHATNET_REC *chatnet) @@ -71,6 +65,7 @@ void chatnet_create(CHATNET_REC *chatnet) if (g_slist_find(chatnets, chatnet) == NULL) chatnets = g_slist_append(chatnets, chatnet); + chatnet_config_save(chatnet); signal_emit("chatnet created", 1, chatnet); } @@ -79,6 +74,8 @@ void chatnet_remove(CHATNET_REC *chatnet) g_return_if_fail(IS_CHATNET(chatnet)); signal_emit("chatnet removed", 1, chatnet); + + chatnet_config_remove(chatnet); chatnet_destroy(chatnet); } @@ -89,16 +86,16 @@ void chatnet_destroy(CHATNET_REC *chatnet) chatnets = g_slist_remove(chatnets, chatnet); signal_emit("chatnet destroyed", 1, chatnet); - g_free(chatnet->name); g_free_not_null(chatnet->nick); g_free_not_null(chatnet->username); g_free_not_null(chatnet->realname); g_free_not_null(chatnet->own_host); g_free_not_null(chatnet->autosendcmd); + g_free(chatnet->name); g_free(chatnet); } -/* Find the irc network by name */ +/* Find the chat network by name */ CHATNET_REC *chatnet_find(const char *name) { GSList *tmp; @@ -129,17 +126,78 @@ static void sig_connected(SERVER_REC *server) eval_special_string(rec->autosendcmd, "", server, NULL); } +static void chatnet_read(CONFIG_NODE *node) +{ + CHAT_PROTOCOL_REC *proto; + CHATNET_REC *rec; + char *type; + + if (node == NULL || node->key == NULL) + return; + + type = config_node_get_str(node, "type", NULL); + proto = type == NULL ? NULL : chat_protocol_find(type); + if (proto == NULL) { + proto = type == NULL ? chat_protocol_get_default() : + chat_protocol_get_unknown(type); + } + + if (type == NULL) + iconfig_node_set_str(node, "type", proto->name); + + rec = proto->create_chatnet(); + rec->type = module_get_uniq_id("CHATNET", 0); + rec->chat_type = proto->id; + rec->name = g_strdup(node->key); + rec->nick = g_strdup(config_node_get_str(node, "nick", NULL)); + rec->username = g_strdup(config_node_get_str(node, "username", NULL)); + rec->realname = g_strdup(config_node_get_str(node, "realname", NULL)); + rec->own_host = g_strdup(config_node_get_str(node, "host", NULL)); + rec->autosendcmd = g_strdup(config_node_get_str(node, "autosendcmd", NULL)); + + chatnets = g_slist_append(chatnets, rec); + signal_emit("chatnet read", 2, rec, node); +} + +static void read_chatnets(void) +{ + CONFIG_NODE *node; + + while (chatnets != NULL) + chatnet_destroy(chatnets->data); + + node = iconfig_node_traverse("chatnets", FALSE); + if (node == NULL) { + /* FIXME: remove after .98 */ + node = iconfig_node_traverse("ircnets", FALSE); + if (node != NULL) { + /* very dirty method - doesn't update hashtables + but this will do temporarily.. */ + g_free(node->key); + node->key = g_strdup("chatnets"); + } + } + + if (node != NULL) + g_slist_foreach(node->value, (GFunc) chatnet_read, NULL); +} + void chatnets_init(void) { chatnets = NULL; + signal_add("event connected", (SIGNAL_FUNC) sig_connected); + signal_add("setup reread", (SIGNAL_FUNC) read_chatnets); + signal_add_first("irssi init read settings", (SIGNAL_FUNC) read_chatnets); } void chatnets_deinit(void) { while (chatnets != NULL) chatnet_destroy(chatnets->data); + module_uniq_destroy("CHATNET"); signal_remove("event connected", (SIGNAL_FUNC) sig_connected); - module_uniq_destroy("CHATNET"); + signal_remove("setup reread", (SIGNAL_FUNC) read_chatnets); + signal_remove("irssi init read settings", (SIGNAL_FUNC) read_chatnets); } diff --git a/src/core/chatnets.h b/src/core/chatnets.h index 8a17a451..2b78f64a 100644 --- a/src/core/chatnets.h +++ b/src/core/chatnets.h @@ -16,10 +16,6 @@ struct _CHATNET_REC { extern GSList *chatnets; /* list of available chat networks */ -/* read/save to configuration file */ -void chatnet_read(CHATNET_REC *chatnet, CONFIG_NODE *node); -CONFIG_NODE *chatnet_save(CHATNET_REC *chatnet, CONFIG_NODE *parentnode); - /* add the chatnet to chat networks list */ void chatnet_create(CHATNET_REC *chatnet); /* remove the chatnet from chat networks list */ @@ -27,7 +23,7 @@ void chatnet_remove(CHATNET_REC *chatnet); /* destroy the chatnet structure. doesn't remove from config file */ void chatnet_destroy(CHATNET_REC *chatnet); -/* Find the irc network by name */ +/* Find the chat network by name */ CHATNET_REC *chatnet_find(const char *name); void chatnets_init(void); diff --git a/src/core/log.c b/src/core/log.c index e61a537f..9d5b8592 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -224,7 +224,7 @@ void log_write_rec(LOG_REC *log, const char *str, int level) } LOG_ITEM_REC *log_item_find(LOG_REC *log, int type, const char *item, - SERVER_REC *server) + const char *servertag) { GSList *tmp; @@ -235,8 +235,8 @@ LOG_ITEM_REC *log_item_find(LOG_REC *log, int type, const char *item, LOG_ITEM_REC *rec = tmp->data; if (rec->type == type && g_strcasecmp(rec->name, item) == 0 && - (rec->servertag == NULL || (server != NULL && - g_strcasecmp(rec->servertag, server->tag) == 0))) + (rec->servertag == NULL || (servertag != NULL && + g_strcasecmp(rec->servertag, servertag) == 0))) return rec; } @@ -268,8 +268,9 @@ void log_file_write(SERVER_REC *server, const char *item, int level, if (rec->items == NULL) fallbacks = g_slist_append(fallbacks, rec); - else if (item != NULL && log_item_find(rec, LOG_ITEM_TARGET, - item, server) != NULL) + else if (item != NULL && + log_item_find(rec, LOG_ITEM_TARGET, item, + server->tag) != NULL) log_write_rec(rec, str, level); } @@ -367,20 +368,20 @@ LOG_REC *log_create_rec(const char *fname, int level) } void log_item_add(LOG_REC *log, int type, const char *name, - SERVER_REC *server) + const char *servertag) { LOG_ITEM_REC *rec; g_return_if_fail(log != NULL); g_return_if_fail(name != NULL); - if (log_item_find(log, type, name, server)) + if (log_item_find(log, type, name, servertag)) return; rec = g_new0(LOG_ITEM_REC, 1); rec->type = type; rec->name = g_strdup(name); - rec->servertag = server == NULL ? NULL : g_strdup(server->tag); + rec->servertag = g_strdup(servertag); log->items = g_slist_append(log->items, rec); } diff --git a/src/core/log.h b/src/core/log.h index bc4d6036..7361b6a0 100644 --- a/src/core/log.h +++ b/src/core/log.h @@ -38,10 +38,10 @@ void log_close(LOG_REC *log); LOG_REC *log_find(const char *fname); void log_item_add(LOG_REC *log, int type, const char *name, - SERVER_REC *server); + const char *servertag); void log_item_destroy(LOG_REC *log, LOG_ITEM_REC *item); LOG_ITEM_REC *log_item_find(LOG_REC *log, int type, const char *item, - SERVER_REC *server); + const char *servertag); void log_file_write(SERVER_REC *server, const char *item, int level, const char *str, int no_fallbacks); diff --git a/src/core/queries.c b/src/core/queries.c index 38a597ad..1888bfdc 100644 --- a/src/core/queries.c +++ b/src/core/queries.c @@ -27,20 +27,6 @@ GSList *queries; -/* Create a new query */ -QUERY_REC *query_create(int chat_type, const char *server_tag, - const char *nick, int automatic) -{ - QUERY_REC *query; - - g_return_val_if_fail(nick != NULL, NULL); - - query = NULL; - signal_emit("query create", 5, &query, GINT_TO_POINTER(chat_type), - server_tag, nick, GINT_TO_POINTER(automatic)); - return query; -} - void query_init(QUERY_REC *query, int automatic) { g_return_if_fail(query != NULL); diff --git a/src/core/queries.h b/src/core/queries.h index 7e5372be..77ef9c37 100644 --- a/src/core/queries.h +++ b/src/core/queries.h @@ -21,10 +21,6 @@ extern GSList *queries; void query_init(QUERY_REC *query, int automatic); void query_destroy(QUERY_REC *query); -/* Create a new query */ -QUERY_REC *query_create(int chat_type, const char *server_tag, - const char *nick, int automatic); - /* Find query by name, if `server' is NULL, search from all servers */ QUERY_REC *query_find(SERVER_REC *server, const char *nick); diff --git a/src/core/servers-setup.c b/src/core/servers-setup.c index 395edbf4..90fb3c51 100644 --- a/src/core/servers-setup.c +++ b/src/core/servers-setup.c @@ -24,9 +24,10 @@ #include "lib-config/iconfig.h" #include "settings.h" +#include "chat-protocols.h" +#include "chatnets.h" #include "servers.h" #include "servers-setup.h" -#include "chatnets.h" GSList *setupservers; @@ -164,9 +165,10 @@ static void server_setup_fill_chatnet(SERVER_CONNECT_REC *conn, } static SERVER_CONNECT_REC * -create_addr_conn(const char *address, int port, +create_addr_conn(int chat_type, const char *address, int port, const char *password, const char *nick) { + CHAT_PROTOCOL_REC *proto; SERVER_CONNECT_REC *conn; SERVER_SETUP_REC *sserver; CHATNET_REC *chatnet; @@ -174,19 +176,20 @@ create_addr_conn(const char *address, int port, g_return_val_if_fail(address != NULL, NULL); sserver = server_setup_find(address, port); - chatnet = sserver == NULL || sserver->chatnet == NULL ? NULL : - chatnet_find(sserver->chatnet); - conn = NULL; - signal_emit("server setup connect", 2, &conn, chatnet); - if (conn == NULL) { - /* no chat protocol wanted this server? */ - return NULL; - } + if (sserver != NULL) chat_type = sserver->chat_type; + + proto = chat_type >= 0 ? chat_protocol_find_id(chat_type) : + chat_protocol_get_default(); + + conn = proto->create_server_connect(); + conn->chat_type = proto->id; /* fill in the defaults */ server_setup_fill(conn, address, port); /* fill the rest from chat network settings */ + chatnet = sserver == NULL || sserver->chatnet == NULL ? NULL : + chatnet_find(sserver->chatnet); if (chatnet != NULL) server_setup_fill_chatnet(conn, chatnet); @@ -204,6 +207,7 @@ create_addr_conn(const char *address, int port, conn->nick = g_strdup(nick); } + signal_emit("server setup fill connect", 1, conn); return conn; } @@ -239,26 +243,27 @@ create_chatnet_conn(const char *dest, int port, } return bestrec == NULL ? NULL : - create_addr_conn(bestrec->address, 0, NULL, nick); + create_addr_conn(bestrec->chat_type, + bestrec->address, 0, NULL, nick); } /* Create server connection record. `dest' is required, rest can be NULL. `dest' is either a server address or chat network */ SERVER_CONNECT_REC * -server_create_conn(const char *dest, int port, +server_create_conn(int chat_type, const char *dest, int port, const char *password, const char *nick) { SERVER_CONNECT_REC *rec; g_return_val_if_fail(dest != NULL, NULL); - if (chatnet_find(dest)) { + if (chatnet_find(dest) != NULL) { rec = create_chatnet_conn(dest, port, password, nick); if (rec != NULL) return rec; } - return create_addr_conn(dest, port, password, nick); + return create_addr_conn(chat_type, dest, port, password, nick); } /* Find matching server from setup. Try to find record with a same port, @@ -296,6 +301,7 @@ SERVER_SETUP_REC *server_setup_find_port(const char *address, int port) static SERVER_SETUP_REC *server_setup_read(CONFIG_NODE *node) { SERVER_SETUP_REC *rec; + CHATNET_REC *chatnetrec; char *server, *chatnet; int port; @@ -322,21 +328,28 @@ static SERVER_SETUP_REC *server_setup_read(CONFIG_NODE *node) chatnet = config_node_get_str(node, "chatnet", NULL); } } - signal_emit("server setup read", 3, &rec, node, - chatnet == NULL ? NULL : chatnet_find(chatnet)); - if (rec == NULL) { - /* no chat protocol wanted this server? */ - return NULL; + + chatnetrec = chatnet == NULL ? NULL : chatnet_find(chatnet); + if (chatnetrec == NULL && chatnet != NULL) { + /* chat network not found, create it. */ + chatnetrec = chat_protocol_get_default()->create_chatnet(); + chatnetrec->chat_type = chat_protocol_get_default()->id; + chatnetrec->name = g_strdup(chatnet); + chatnet_create(chatnetrec); } + rec = CHAT_PROTOCOL(chatnetrec)->create_server_setup(); rec->type = module_get_uniq_id("SERVER SETUP", 0); - rec->chatnet = g_strdup(chatnet); + rec->chat_type = chatnetrec->chat_type; + rec->chatnet = g_strdup(chatnetrec->name); rec->address = g_strdup(server); rec->password = g_strdup(config_node_get_str(node, "password", NULL)); rec->port = port; rec->autoconnect = config_node_get_bool(node, "autoconnect", FALSE); rec->own_host = g_strdup(config_node_get_str(node, "own_host", NULL)); + signal_emit("server setup read", 2, rec, node); + setupservers = g_slist_append(setupservers, rec); return rec; } @@ -387,8 +400,8 @@ static void server_setup_destroy(SERVER_SETUP_REC *rec) g_free_not_null(rec->own_host); g_free_not_null(rec->own_ip); g_free_not_null(rec->chatnet); - g_free(rec->address); g_free_not_null(rec->password); + g_free(rec->address); g_free(rec); } @@ -443,6 +456,7 @@ void servers_setup_init(void) settings_add_int("proxy", "proxy_port", 6667); settings_add_str("proxy", "proxy_string", "CONNECT %s %d"); + setupservers = NULL; source_host_ip = NULL; read_settings(); diff --git a/src/core/servers-setup.h b/src/core/servers-setup.h index 55785e80..9e0c7b8d 100644 --- a/src/core/servers-setup.h +++ b/src/core/servers-setup.h @@ -27,7 +27,7 @@ void server_setup_fill_reconn(SERVER_CONNECT_REC *conn, /* Create server connection record. `dest' is required, rest can be NULL. `dest' is either a server address or chat network */ SERVER_CONNECT_REC * -server_create_conn(const char *dest, int port, +server_create_conn(int chat_type, const char *dest, int port, const char *password, const char *nick); /* Find matching server from setup. Try to find record with a same port, diff --git a/src/core/servers.c b/src/core/servers.c index 0972174d..a4e0966d 100644 --- a/src/core/servers.c +++ b/src/core/servers.c @@ -281,13 +281,9 @@ int server_start_connect(SERVER_REC *server) /* Connect to server */ SERVER_REC *server_connect(SERVER_CONNECT_REC *conn) { - SERVER_REC *server; - g_return_val_if_fail(IS_SERVER_CONNECT(conn), NULL); - server = NULL; - signal_emit("server connect", 2, &server, conn); - return server; + return CHAT_PROTOCOL(conn)->server_connect(conn); } static int server_remove_channels(SERVER_REC *server) diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c index e15742d6..e3941b2c 100644 --- a/src/fe-common/core/fe-channels.c +++ b/src/fe-common/core/fe-channels.c @@ -27,6 +27,8 @@ #include "misc.h" #include "settings.h" +#include "chat-protocols.h" +#include "chatnets.h" #include "channels.h" #include "channels-setup.h" #include "nicklist.h" @@ -232,6 +234,7 @@ static void cmd_channel(const char *data, SERVER_REC *server, WI_ITEM_REC *item) static void cmd_channel_add(const char *data) { GHashTable *optlist; + CHATNET_REC *chatnetrec; CHANNEL_SETUP_REC *rec; char *botarg, *botcmdarg, *chatnet, *channel, *password; void *free_arg; @@ -240,14 +243,23 @@ static void cmd_channel_add(const char *data) "channel add", &optlist, &channel, &chatnet, &password)) return; + if (*chatnet == '\0' || *channel == '\0') + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + + chatnetrec = chatnet_find(chatnet); + if (chatnetrec == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + TXT_UNKNOWN_CHATNET, chatnet); + cmd_params_free(free_arg); + return; + } + botarg = g_hash_table_lookup(optlist, "bots"); botcmdarg = g_hash_table_lookup(optlist, "botcmd"); - if (*chatnet == '\0' || *channel == '\0') - cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - rec = channels_setup_find(channel, chatnet); + rec = channel_setup_find(channel, chatnet); if (rec == NULL) { - rec = g_new0(CHANNEL_SETUP_REC, 1); + rec = CHAT_PROTOCOL(chatnetrec)->create_channel_setup(); rec->name = g_strdup(channel); rec->chatnet = g_strdup(chatnet); } else { @@ -260,8 +272,12 @@ static void cmd_channel_add(const char *data) if (botarg != NULL && *botarg != '\0') rec->botmasks = g_strdup(botarg); if (botcmdarg != NULL && *botcmdarg != '\0') rec->autosendcmd = g_strdup(botcmdarg); if (*password != '\0' && strcmp(password, "-") != 0) rec->password = g_strdup(password); - channels_setup_create(rec); - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_CHANSETUP_ADDED, channel, chatnet); + + signal_emit("channel add fill", 2, rec, optlist); + + channel_setup_create(rec); + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + TXT_CHANSETUP_ADDED, channel, chatnet); cmd_params_free(free_arg); } @@ -278,12 +294,12 @@ static void cmd_channel_remove(const char *data) if (*chatnet == '\0' || *channel == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - rec = channels_setup_find(channel, chatnet); + rec = channel_setup_find(channel, chatnet); if (rec == NULL) printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_CHANSETUP_NOT_FOUND, channel, chatnet); else { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_CHANSETUP_REMOVED, channel, chatnet); - channels_setup_destroy(rec); + channel_setup_remove(rec); } cmd_params_free(free_arg); } @@ -317,6 +333,10 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) g_free(stripped); g_free(format); + if (settings_get_int("names_max_width") > 0 && + max_width > settings_get_int("names_max_width")) + max_width = settings_get_int("names_max_width"); + /* remove width of timestamp from max_width */ format_create_dest(&dest, channel->server, channel->name, MSGLEVEL_CLIENTCRAP, NULL); @@ -329,10 +349,6 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist) } /* calculate columns */ - if (settings_get_int("names_max_width") > 0 && - max_width > settings_get_int("names_max_width")) - max_width = settings_get_int("names_max_width"); - cols = get_max_column_count(nicklist, get_nick_length, max_width, settings_get_int("names_max_columns"), item_extra, 3, &columns, &rows); diff --git a/src/fe-common/core/fe-common-core.c b/src/fe-common/core/fe-common-core.c index f01825bd..38de0d65 100644 --- a/src/fe-common/core/fe-common-core.c +++ b/src/fe-common/core/fe-common-core.c @@ -212,8 +212,12 @@ void glog_func(const char *log_domain, GLogLevelFlags log_level, break; } - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, - TXT_GLIB_ERROR, reason, message); + if (windows == NULL) + fprintf(stderr, "GLib %s: %s", reason, message); + else { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, + TXT_GLIB_ERROR, reason, message); + } } void fe_common_core_finish_init(void) diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c index a0ea9760..4278f6a9 100644 --- a/src/fe-common/core/fe-log.c +++ b/src/fe-common/core/fe-log.c @@ -48,7 +48,7 @@ static THEME_REC *log_theme; static int skip_next_printtext; static const char *log_theme_name; -static void log_add_targets(LOG_REC *log, const char *targets) +static void log_add_targets(LOG_REC *log, const char *targets, const char *tag) { char **tmp, **items; @@ -58,15 +58,16 @@ static void log_add_targets(LOG_REC *log, const char *targets) items = g_strsplit(targets, " ", -1); for (tmp = items; *tmp != NULL; tmp++) - log_item_add(log, LOG_ITEM_TARGET, *tmp, NULL); + log_item_add(log, LOG_ITEM_TARGET, *tmp, tag); g_strfreev(items); } -/* SYNTAX: LOG OPEN [-noopen] [-autoopen] [-targets <targets>] - [-window] <fname> [<levels>] */ +/* SYNTAX: LOG OPEN [-noopen] [-autoopen] [-window] [-<server tag>] + [-targets <targets>] <fname> [<levels>] */ static void cmd_log_open(const char *data) { + SERVER_REC *server; GHashTable *optlist; char *targetarg, *fname, *levels; void *free_arg; @@ -74,7 +75,8 @@ static void cmd_log_open(const char *data) LOG_REC *log; int level; - if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST, + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST | + PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_OPTIONS, "log open", &optlist, &fname, &levels)) return; if (*fname == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); @@ -82,14 +84,17 @@ static void cmd_log_open(const char *data) level = level2bits(levels); log = log_create_rec(fname, level != 0 ? level : MSGLEVEL_ALL); + /* -<server tag> */ + server = cmd_options_get_server("join", optlist, NULL); + if (g_hash_table_lookup(optlist, "window")) { /* log by window ref# */ ltoa(window, active_win->refnum); - log_item_add(log, LOG_ITEM_WINDOW_REFNUM, window, NULL); + log_item_add(log, LOG_ITEM_WINDOW_REFNUM, window, server->tag); } else { targetarg = g_hash_table_lookup(optlist, "targets"); if (targetarg != NULL && *targetarg != '\0') - log_add_targets(log, targetarg); + log_add_targets(log, targetarg, server->tag); } if (g_hash_table_lookup(optlist, "autoopen")) @@ -217,7 +222,7 @@ static void cmd_log(const char *data, SERVER_REC *server, void *item) } static LOG_REC *logs_find_item(int type, const char *item, - SERVER_REC *server, LOG_ITEM_REC **ret_item) + const char *servertag, LOG_ITEM_REC **ret_item) { LOG_ITEM_REC *logitem; GSList *tmp; @@ -225,7 +230,7 @@ static LOG_REC *logs_find_item(int type, const char *item, for (tmp = logs; tmp != NULL; tmp = tmp->next) { LOG_REC *log = tmp->data; - logitem = log_item_find(log, type, item, server); + logitem = log_item_find(log, type, item, servertag); if (logitem != NULL) { if (ret_item != NULL) *ret_item = logitem; return log; @@ -338,12 +343,13 @@ static void autologs_close_all(void) } } -static void autolog_open(void *server, const char *target) +static void autolog_open(SERVER_REC *server, const char *target) { LOG_REC *log; - char *fname, *dir, *fixed_target; + char *fname, *dir, *fixed_target, *tag; - log = logs_find_item(LOG_ITEM_TARGET, target, server, NULL); + tag = server == NULL ? NULL : server->tag; + log = logs_find_item(LOG_ITEM_TARGET, target, tag, NULL); if (log != NULL && !log->failed) { log_start_logging(log); return; @@ -359,7 +365,7 @@ static void autolog_open(void *server, const char *target) if (log_find(fname) == NULL) { log = log_create_rec(fname, autolog_level); - log_item_add(log, LOG_ITEM_TARGET, target, server); + log_item_add(log, LOG_ITEM_TARGET, target, tag); dir = g_dirname(log->real_fname); mkpath(dir, LOG_DIR_CREATE_MODE); @@ -372,7 +378,8 @@ static void autolog_open(void *server, const char *target) g_free(fname); } -static void autolog_open_check(void *server, const char *target, int level) +static void autolog_open_check(SERVER_REC *server, const char *target, + int level) { char **targets, **tmp; @@ -410,7 +417,7 @@ static void log_single_line(WINDOW_REC *window, void *server, } } -static void log_line(WINDOW_REC *window, void *server, +static void log_line(WINDOW_REC *window, SERVER_REC *server, const char *target, int level, const char *text) { char **lines, **tmp; @@ -513,7 +520,9 @@ static void sig_window_item_destroy(WINDOW_REC *window, WI_ITEM_REC *item) { LOG_REC *log; - log = logs_find_item(LOG_ITEM_TARGET, item->name, item->server, NULL); + log = logs_find_item(LOG_ITEM_TARGET, item->name, + item->server == NULL ? NULL : + item->server->tag, NULL); if (log != NULL && log->temp) log_close(log); } diff --git a/src/fe-common/core/fe-queries.c b/src/fe-common/core/fe-queries.c index 68c67eb8..ce614c89 100644 --- a/src/fe-common/core/fe-queries.c +++ b/src/fe-common/core/fe-queries.c @@ -23,9 +23,10 @@ #include "modules.h" #include "signals.h" #include "commands.h" +#include "levels.h" #include "settings.h" -#include "levels.h" +#include "chat-protocols.h" #include "queries.h" #include "fe-windows.h" @@ -46,8 +47,8 @@ QUERY_REC *privmsg_get_query(SERVER_REC *server, const char *nick, query = query_find(server, nick); if (query == NULL && (querycreate_level & level) != 0 && (!own || settings_get_bool("autocreate_own_query"))) { - query = query_create(server->chat_type, server->tag, - nick, TRUE); + query = CHAT_PROTOCOL(server)-> + query_create(server->tag, nick, TRUE); } return query; @@ -228,7 +229,7 @@ static void cmd_query(const char *data, SERVER_REC *server, WI_ITEM_REC *item) query = query_find(server, nick); if (query == NULL) - query_create(server->chat_type, server->tag, nick, FALSE); + CHAT_PROTOCOL(server)->query_create(server->tag, nick, FALSE); else { /* query already existed - set query active / move it to this window */ diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index 2184bc58..d96dcfe1 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -1,7 +1,7 @@ /* fe-server.c : irssi - Copyright (C) 1999 Timo Sirainen + Copyright (C) 1999-2001 Timo Sirainen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ #include "settings.h" #include "chat-protocols.h" +#include "chatnets.h" #include "servers.h" #include "servers-setup.h" #include "servers-reconnect.h" @@ -80,9 +81,29 @@ static void print_reconnects(void) } } -/* SYNTAX: SERVER ADD [-auto | -noauto] [-host <hostname>] - [-cmdspeed <ms>] [-cmdmax <count>] [-port <port>] - <address> [<port> [<password>]] */ +static SERVER_SETUP_REC *create_server_setup(GHashTable *optlist) +{ + CHAT_PROTOCOL_REC *rec; + SERVER_SETUP_REC *server; + char *chatnet; + + rec = chat_protocol_find_net(optlist); + if (rec == NULL) + rec = chat_protocol_get_default(); + else { + chatnet = g_hash_table_lookup(optlist, rec->chatnet); + if (chatnet_find(chatnet) == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + TXT_UNKNOWN_CHATNET, chatnet); + return NULL; + } + } + + server = rec->create_server_setup(); + server->chat_type = rec->id; + return server; +} + static void cmd_server_add(const char *data) { GHashTable *optlist; @@ -100,16 +121,10 @@ static void cmd_server_add(const char *data) rec = server_setup_find_port(addr, port); if (rec == NULL) { - signal_emit("server add create", 2, &rec, optlist); + rec = create_server_setup(optlist); if (rec == NULL) { - /* no chatnet option specified, use the first. */ - g_hash_table_insert(optlist, chat_protocol_find_id(1)->name, ""); - signal_emit("server add create", 2, &rec, optlist); - if (rec == NULL) { - /* bug? */ - cmd_params_free(free_arg); - return; - } + cmd_params_free(free_arg); + return; } rec->address = g_strdup(addr); rec->port = port; @@ -137,7 +152,8 @@ static void cmd_server_add(const char *data) signal_emit("server add fill", 2, rec, optlist); server_setup_add(rec); - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_SETUPSERVER_ADDED, addr, port); + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + TXT_SETUPSERVER_ADDED, addr, port); cmd_params_free(free_arg); } diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index 6c1dd5bc..9694b541 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -207,6 +207,7 @@ FORMAT_REC fecommon_core_formats[] = { /* ---- */ { NULL, "Misc", 0 }, + { "unknown_chatnet", "Unknown chat network: $0", 1, { 0 } }, { "not_toggle", "Value must be either ON, OFF or TOGGLE", 0 }, { "perl_error", "Perl error: $0", 1, { 0 } }, { "bind_key", "$[10]0 $1 $2", 3, { 0, 0, 0 } }, diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h index ae2a80e1..3126ba54 100644 --- a/src/fe-common/core/module-formats.h +++ b/src/fe-common/core/module-formats.h @@ -173,6 +173,7 @@ enum { TXT_FILL_13, + TXT_UNKNOWN_CHATNET, TXT_NOT_TOGGLE, TXT_PERL_ERROR, TXT_BIND_KEY, diff --git a/src/fe-common/core/window-save.c b/src/fe-common/core/window-save.c index 62423719..3626cc83 100644 --- a/src/fe-common/core/window-save.c +++ b/src/fe-common/core/window-save.c @@ -53,8 +53,7 @@ static void sig_window_restore_item(WINDOW_REC *window, const char *type, rec->sticky = TRUE; } else if (g_strcasecmp(type, "QUERY") == 0 && chat_type != NULL) { /* create query immediately */ - query_create(chat_protocol_lookup(chat_type), - tag, name, TRUE); + chat_protocol_find(chat_type)->query_create(tag, name, TRUE); } } diff --git a/src/fe-common/irc/fe-irc-server.c b/src/fe-common/irc/fe-irc-server.c index 36452183..a2ce1c0e 100644 --- a/src/fe-common/irc/fe-irc-server.c +++ b/src/fe-common/irc/fe-irc-server.c @@ -34,20 +34,9 @@ #include "fe-windows.h" #include "printtext.h" -static void sig_server_add_create(IRC_SERVER_SETUP_REC **rec, - GHashTable *optlist) -{ - char *ircnet; - - ircnet = g_hash_table_lookup(optlist, "ircnet"); - if (ircnet == NULL) - return; - - *rec = g_new0(IRC_SERVER_SETUP_REC, 1); - (*rec)->chat_type = chat_protocol_lookup("IRC"); - signal_stop(); -} - +/* SYNTAX: SERVER ADD [-auto | -noauto] [-ircnet <ircnet>] [-host <hostname>] + [-cmdspeed <ms>] [-cmdmax <count>] [-port <port>] + <address> [<port> [<password>]] */ static void sig_server_add_fill(IRC_SERVER_SETUP_REC *rec, GHashTable *optlist) { @@ -107,7 +96,6 @@ static void cmd_server_list(const char *data) void fe_irc_server_init(void) { - signal_add("server add create", (SIGNAL_FUNC) sig_server_add_create); signal_add("server add fill", (SIGNAL_FUNC) sig_server_add_fill); command_bind("server list", NULL, (SIGNAL_FUNC) cmd_server_list); @@ -116,7 +104,6 @@ void fe_irc_server_init(void) void fe_irc_server_deinit(void) { - signal_remove("server add create", (SIGNAL_FUNC) sig_server_add_create); signal_remove("server add fill", (SIGNAL_FUNC) sig_server_add_fill); command_unbind("server list", (SIGNAL_FUNC) cmd_server_list); } diff --git a/src/fe-common/irc/fe-ircnet.c b/src/fe-common/irc/fe-ircnet.c index cd7e5480..96092869 100644 --- a/src/fe-common/irc/fe-ircnet.c +++ b/src/fe-common/irc/fe-ircnet.c @@ -79,11 +79,11 @@ static void cmd_ircnet_list(void) printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_IRCNET_FOOTER); } -/* SYNTAX: IRCNET ADD [-kicks <count>] [-msgs <count>] [-modes <count>] - [-whois <count>] [-cmdspeed <ms>] [-cmdmax <count>] - [-querychans <count>] [-nick <nick>] [-user <user>] - [-realname <name>] [-host <host>] [-autosendcmd <cmd>] - <name> */ +/* SYNTAX: IRCNET ADD [-nick <nick>] [-user <user>] [-realname <name>] + [-host <host>] [-autosendcmd <cmd>] + [-querychans <count>] [-whois <count>] [-msgs <count>] + [-kicks <count>] [-modes <count>] + [-cmdspeed <ms>] [-cmdmax <count>] <name> */ static void cmd_ircnet_add(const char *data) { GHashTable *optlist; @@ -176,6 +176,7 @@ static void cmd_ircnet(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *it void fe_ircnet_init(void) { command_bind("ircnet", NULL, (SIGNAL_FUNC) cmd_ircnet); + command_bind("ircnet list", NULL, (SIGNAL_FUNC) cmd_ircnet_list); command_bind("ircnet add", NULL, (SIGNAL_FUNC) cmd_ircnet_add); command_bind("ircnet remove", NULL, (SIGNAL_FUNC) cmd_ircnet_remove); @@ -185,6 +186,7 @@ void fe_ircnet_init(void) void fe_ircnet_deinit(void) { command_unbind("ircnet", (SIGNAL_FUNC) cmd_ircnet); + command_unbind("ircnet list", (SIGNAL_FUNC) cmd_ircnet_list); command_unbind("ircnet add", (SIGNAL_FUNC) cmd_ircnet_add); command_unbind("ircnet remove", (SIGNAL_FUNC) cmd_ircnet_remove); } diff --git a/src/irc/core/irc-channels.c b/src/irc/core/irc-channels.c index bdef9468..a083c9d0 100644 --- a/src/irc/core/irc-channels.c +++ b/src/irc/core/irc-channels.c @@ -62,22 +62,6 @@ IRC_CHANNEL_REC *irc_channel_create(IRC_SERVER_REC *server, return rec; } -static void sig_channel_create(IRC_CHANNEL_REC **channel, - void *chat_type, IRC_SERVER_REC *server, - const char *name, void *automatic) -{ - if (chat_protocol_lookup("IRC") != GPOINTER_TO_INT(chat_type)) - return; - - g_return_if_fail(server == NULL || IS_IRC_SERVER(server)); - g_return_if_fail(channel != NULL); - g_return_if_fail(name != NULL); - - *channel = irc_channel_create(server, name, - GPOINTER_TO_INT(automatic)); - signal_stop(); -} - static void sig_channel_destroyed(IRC_CHANNEL_REC *channel) { if (!IS_IRC_CHANNEL(channel)) @@ -93,11 +77,11 @@ static void sig_channel_destroyed(IRC_CHANNEL_REC *channel) #define get_join_key(key) \ (((key) == NULL || *(key) == '\0') ? "x" : (key)) -static void irc_channels_join(SERVER_REC *server, const char *data, +static void irc_channels_join(IRC_SERVER_REC *server, const char *data, int automatic) { CHANNEL_SETUP_REC *schannel; - CHANNEL_REC *chanrec; + IRC_CHANNEL_REC *chanrec; GString *outchans, *outkeys; char *channels, *keys, *key; char **chanlist, **keylist, **tmp, **tmpkey, *channel, *channame; @@ -124,9 +108,9 @@ static void irc_channels_join(SERVER_REC *server, const char *data, channel = ischannel(**tmp) ? g_strdup(*tmp) : g_strdup_printf("#%s", *tmp); - chanrec = channel_find(server, channel); + chanrec = irc_channel_find(server, channel); if (chanrec == NULL) { - schannel = channels_setup_find(channel, server->connrec->chatnet); + schannel = channel_setup_find(channel, server->connrec->chatnet); g_string_sprintfa(outchans, "%s,", channel); if (*tmpkey != NULL && **tmpkey != '\0') @@ -140,8 +124,8 @@ static void irc_channels_join(SERVER_REC *server, const char *data, g_string_sprintfa(outkeys, "%s,", get_join_key(key)); channame = channel + (channel[0] == '!' && channel[1] == '!'); - chanrec = channel_create(server->chat_type, server, - channame, automatic); + chanrec = irc_channel_create(server, channame, + automatic); if (key != NULL) chanrec->key = g_strdup(key); } g_free(channel); @@ -197,12 +181,12 @@ static void sig_server_looking(SERVER_REC *server) return; server->channel_find_func = irc_channel_find_server; - server->channels_join = irc_channels_join; + server->channels_join = (void (*) (SERVER_REC *, const char *, int)) + irc_channels_join; } void irc_channels_init(void) { - signal_add("channel create", (SIGNAL_FUNC) sig_channel_create); signal_add("server looking", (SIGNAL_FUNC) sig_server_looking); signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed); @@ -220,7 +204,6 @@ void irc_channels_init(void) void irc_channels_deinit(void) { - signal_remove("channel create", (SIGNAL_FUNC) sig_channel_create); signal_remove("server looking", (SIGNAL_FUNC) sig_server_looking); signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed); diff --git a/src/irc/core/irc-chatnets.c b/src/irc/core/irc-chatnets.c index 40c4cae1..4ebf71f6 100644 --- a/src/irc/core/irc-chatnets.c +++ b/src/irc/core/irc-chatnets.c @@ -20,23 +20,23 @@ #include "module.h" #include "signals.h" -#include "servers.h" -#include "chatnets.h" -#include "special-vars.h" #include "lib-config/iconfig.h" #include "settings.h" #include "irc-chatnets.h" -static void ircnet_read(CONFIG_NODE *node) +void ircnet_create(IRC_CHATNET_REC *rec) { - IRC_CHATNET_REC *rec; - - if (node == NULL || node->key == NULL) - return; + g_return_if_fail(rec != NULL); - rec = g_new0(IRC_CHATNET_REC, 1); rec->chat_type = IRC_PROTOCOL; + chatnet_create(CHATNET(rec)); +} + +static void sig_chatnet_read(IRC_CHATNET_REC *rec, CONFIG_NODE *node) +{ + if (!IS_IRC_CHATNET(rec)) + return; rec->max_cmds_at_once = config_node_get_int(node, "cmdmax", 0); rec->cmd_queue_speed = config_node_get_int(node, "cmdspeed", 0); @@ -46,18 +46,12 @@ static void ircnet_read(CONFIG_NODE *node) rec->max_msgs = config_node_get_int(node, "max_msgs", 0); rec->max_modes = config_node_get_int(node, "max_modes", 0); rec->max_whois = config_node_get_int(node, "max_whois", 0); - - chatnet_read((CHATNET_REC *) rec, node); } -static void ircnet_save(IRC_CHATNET_REC *rec) +static void sig_chatnet_saved(IRC_CHATNET_REC *rec, CONFIG_NODE *node) { - CONFIG_NODE *node; - - g_return_if_fail(rec != NULL); - - node = iconfig_node_traverse("ircnets", TRUE); - node = chatnet_save((CHATNET_REC *) rec, node); + if (!IS_IRC_CHATNET(rec)) + return; if (rec->max_cmds_at_once > 0) iconfig_node_set_int(node, "cmdmax", rec->max_cmds_at_once); @@ -76,63 +70,14 @@ static void ircnet_save(IRC_CHATNET_REC *rec) iconfig_node_set_int(node, "max_whois", rec->max_whois); } -static void ircnet_remove(IRC_CHATNET_REC *rec) -{ - CONFIG_NODE *node; - - g_return_if_fail(IS_IRC_CHATNET(rec)); - - node = iconfig_node_traverse("ircnets", FALSE); - if (node != NULL) iconfig_node_set_str(node, rec->name, NULL); -} - -void ircnet_create(IRC_CHATNET_REC *rec) -{ - g_return_if_fail(rec != NULL); - - rec->chat_type = IRC_PROTOCOL; - - ircnet_save(rec); - chatnet_create((CHATNET_REC *) rec); -} - -static void read_ircnets(void) -{ - CONFIG_NODE *node; - GSList *tmp, *next; - - for (tmp = chatnets; tmp != NULL; tmp = next) { - CHATNET_REC *rec = tmp->data; - - next = tmp->next; - if (IS_IRCNET(rec)) - chatnet_destroy(rec); - } - - /* read ircnets */ - node = iconfig_node_traverse("ircnets", FALSE); - if (node != NULL) { - for (tmp = node->value; tmp != NULL; tmp = tmp->next) - ircnet_read(tmp->data); - } -} - -static void sig_chatnet_removed(IRC_CHATNET_REC *rec) -{ - if (IS_IRC_CHATNET(rec)) - ircnet_remove(rec); -} - void irc_chatnets_init(void) { - read_ircnets(); - - signal_add("chatnet removed", (SIGNAL_FUNC) sig_chatnet_removed); - signal_add("setup reread", (SIGNAL_FUNC) read_ircnets); + signal_add("chatnet read", (SIGNAL_FUNC) sig_chatnet_read); + signal_add("chatnet saved", (SIGNAL_FUNC) sig_chatnet_saved); } void irc_chatnets_deinit(void) { - signal_remove("chatnet removed", (SIGNAL_FUNC) sig_chatnet_removed); - signal_remove("setup reread", (SIGNAL_FUNC) read_ircnets); + signal_remove("chatnet read", (SIGNAL_FUNC) sig_chatnet_read); + signal_remove("chatnet saved", (SIGNAL_FUNC) sig_chatnet_saved); } diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c index 3c32b3ec..44abb416 100644 --- a/src/irc/core/irc-commands.c +++ b/src/irc/core/irc-commands.c @@ -78,7 +78,7 @@ static SERVER_REC *irc_connect_server(const char *data) *password = '\0'; /* connect to server */ - conn = server_create_conn(addr, atoi(portstr), password, nick); + conn = server_create_conn(-1, addr, atoi(portstr), password, nick); if (g_hash_table_lookup(optlist, "6") != NULL) conn->family = AF_INET6; else if (g_hash_table_lookup(optlist, "4") != NULL) diff --git a/src/irc/core/irc-core.c b/src/irc/core/irc-core.c index 0dc19443..6671c33a 100644 --- a/src/irc/core/irc-core.c +++ b/src/irc/core/irc-core.c @@ -26,6 +26,9 @@ #include "irc-channels.h" #include "irc-queries.h" +#include "irc-servers-setup.h" +#include "channels-setup.h" + #include "ctcp.h" #include "irc.h" #include "netsplit.h" @@ -45,6 +48,26 @@ void irc_log_deinit(void); void lag_init(void); void lag_deinit(void); +static CHATNET_REC *create_chatnet(void) +{ + return g_malloc0(sizeof(IRC_CHATNET_REC)); +} + +static SERVER_SETUP_REC *create_server_setup(void) +{ + return g_malloc0(sizeof(IRC_SERVER_SETUP_REC)); +} + +static CHANNEL_SETUP_REC *create_channel_setup(void) +{ + return g_malloc0(sizeof(CHANNEL_SETUP_REC)); +} + +static SERVER_CONNECT_REC *create_server_connect(void) +{ + return g_malloc0(sizeof(IRC_SERVER_CONNECT_REC)); +} + void irc_core_init(void) { CHAT_PROTOCOL_REC *rec; @@ -54,7 +77,22 @@ void irc_core_init(void) rec->fullname = "Internet Relay Chat"; rec->chatnet = "ircnet"; + rec->create_chatnet = create_chatnet; + rec->create_server_setup = create_server_setup; + rec->create_channel_setup = create_channel_setup; + rec->create_server_connect = create_server_connect; + + rec->server_connect = (SERVER_REC *(*) (SERVER_CONNECT_REC *)) + irc_server_connect; + rec->channel_create = + (CHANNEL_REC *(*) (SERVER_REC *, const char *, int)) + irc_channel_create; + rec->query_create = + (QUERY_REC *(*) (const char *, const char *, int)) + irc_query_create; + chat_protocol_register(rec); + g_free(rec); irc_chatnets_init(); irc_servers_init(); diff --git a/src/irc/core/irc-queries.c b/src/irc/core/irc-queries.c index 2204f2c3..87aed832 100644 --- a/src/irc/core/irc-queries.c +++ b/src/irc/core/irc-queries.c @@ -40,21 +40,6 @@ QUERY_REC *irc_query_create(const char *server_tag, return rec; } -static void sig_query_create(QUERY_REC **query, - void *chat_type, const char *server_tag, - const char *nick, void *automatic) -{ - if (chat_protocol_lookup("IRC") != GPOINTER_TO_INT(chat_type)) - return; - - g_return_if_fail(query != NULL); - g_return_if_fail(nick != NULL); - - *query = irc_query_create(server_tag, nick, - GPOINTER_TO_INT(automatic)); - signal_stop(); -} - static void event_privmsg(IRC_SERVER_REC *server, const char *data, const char *nick, const char *address) { @@ -92,14 +77,12 @@ static void event_nick(SERVER_REC *server, const char *data, void irc_queries_init(void) { - signal_add("query create", (SIGNAL_FUNC) sig_query_create); signal_add_last("event privmsg", (SIGNAL_FUNC) event_privmsg); signal_add("event nick", (SIGNAL_FUNC) event_nick); } void irc_queries_deinit(void) { - signal_remove("query create", (SIGNAL_FUNC) sig_query_create); signal_remove("event privmsg", (SIGNAL_FUNC) event_privmsg); signal_remove("event nick", (SIGNAL_FUNC) event_nick); } diff --git a/src/irc/core/irc-servers-setup.c b/src/irc/core/irc-servers-setup.c index ec07420e..536ea310 100644 --- a/src/irc/core/irc-servers-setup.c +++ b/src/irc/core/irc-servers-setup.c @@ -45,23 +45,12 @@ static void sig_server_setup_fill_reconn(IRC_SERVER_CONNECT_REC *conn, conn->max_query_chans = sserver->max_query_chans; } -/* Create server connection record. `address' is required, rest can be NULL */ -static void sig_server_create_conn(SERVER_CONNECT_REC **conn, - IRC_CHATNET_REC *ircnet) +static void sig_server_setup_fill_connect(IRC_SERVER_CONNECT_REC *conn) { - IRC_SERVER_CONNECT_REC *rec; - - g_return_if_fail(conn != NULL); - - if (ircnet != NULL && !IS_IRCNET(ircnet)) + if (!IS_IRC_SERVER_CONNECT(conn)) return; - rec = g_new0(IRC_SERVER_CONNECT_REC, 1); - rec->chat_type = IRC_PROTOCOL; - rec->alternate_nick = g_strdup(settings_get_str("alternate_nick")); - - *conn = (SERVER_CONNECT_REC *) rec; - signal_stop(); + conn->alternate_nick = g_strdup(settings_get_str("alternate_nick")); } static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn, @@ -140,27 +129,17 @@ static void init_userinfo(void) } } -static void sig_server_setup_read(SERVER_SETUP_REC **setuprec, - CONFIG_NODE *node, - IRC_CHATNET_REC *chatnet) +static void sig_server_setup_read(IRC_SERVER_SETUP_REC *rec, CONFIG_NODE *node) { - IRC_SERVER_SETUP_REC *rec; - - g_return_if_fail(setuprec != NULL); + g_return_if_fail(rec != NULL); g_return_if_fail(node != NULL); - if (chatnet != NULL && !IS_IRCNET(chatnet)) + if (!IS_IRC_SERVER_SETUP(rec)) return; - rec = g_new0(IRC_SERVER_SETUP_REC, 1); - rec->chat_type = IRC_PROTOCOL; - rec->max_cmds_at_once = config_node_get_int(node, "cmds_max_at_once", 0); rec->cmd_queue_speed = config_node_get_int(node, "cmd_queue_speed", 0); rec->max_query_chans = config_node_get_int(node, "max_query_chans", 0); - - *setuprec = (SERVER_SETUP_REC *) rec; - signal_stop(); } static void sig_server_setup_saved(IRC_SERVER_SETUP_REC *rec, @@ -184,7 +163,7 @@ void irc_servers_setup_init(void) init_userinfo(); signal_add("server setup fill reconn", (SIGNAL_FUNC) sig_server_setup_fill_reconn); - signal_add("server setup connect", (SIGNAL_FUNC) sig_server_create_conn); + signal_add("server setup fill connect", (SIGNAL_FUNC) sig_server_setup_fill_connect); signal_add("server setup fill chatnet", (SIGNAL_FUNC) sig_server_setup_fill_chatnet); signal_add("server setup read", (SIGNAL_FUNC) sig_server_setup_read); signal_add("server setup saved", (SIGNAL_FUNC) sig_server_setup_saved); @@ -193,7 +172,7 @@ void irc_servers_setup_init(void) void irc_servers_setup_deinit(void) { signal_remove("server setup fill reconn", (SIGNAL_FUNC) sig_server_setup_fill_reconn); - signal_remove("server setup connect", (SIGNAL_FUNC) sig_server_create_conn); + signal_remove("server setup fill connect", (SIGNAL_FUNC) sig_server_setup_fill_connect); signal_remove("server setup fill chatnet", (SIGNAL_FUNC) sig_server_setup_fill_chatnet); signal_remove("server setup read", (SIGNAL_FUNC) sig_server_setup_read); signal_remove("server setup saved", (SIGNAL_FUNC) sig_server_setup_saved); diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index 680f0c68..fd212a7d 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -177,17 +177,6 @@ IRC_SERVER_REC *irc_server_connect(IRC_SERVER_CONNECT_REC *conn) return server; } -static void sig_server_connect(IRC_SERVER_REC **server, - IRC_SERVER_CONNECT_REC *conn) -{ - g_return_if_fail(server != NULL); - if (!IS_IRC_SERVER_CONNECT(conn)) - return; - - *server = irc_server_connect(conn); - signal_stop(); -} - static void sig_connected(IRC_SERVER_REC *server) { if (!IS_IRC_SERVER(server)) @@ -452,7 +441,6 @@ void irc_servers_init(void) cmd_tag = g_timeout_add(500, (GSourceFunc) servers_cmd_timeout, NULL); signal_add("server connect free", (SIGNAL_FUNC) sig_server_connect_free); - signal_add("server connect", (SIGNAL_FUNC) sig_server_connect); signal_add_first("server looking", (SIGNAL_FUNC) sig_server_looking); signal_add_first("server connected", (SIGNAL_FUNC) sig_connected); signal_add_last("server disconnected", (SIGNAL_FUNC) sig_disconnected); @@ -480,7 +468,6 @@ void irc_servers_deinit(void) g_source_remove(cmd_tag); signal_remove("server connect free", (SIGNAL_FUNC) sig_server_connect_free); - signal_remove("server connect", (SIGNAL_FUNC) sig_server_connect); signal_remove("server looking", (SIGNAL_FUNC) sig_server_looking); signal_remove("server connected", (SIGNAL_FUNC) sig_connected); signal_remove("server disconnected", (SIGNAL_FUNC) sig_disconnected); |