diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/chatnets.c | 5 | ||||
-rw-r--r-- | src/core/modules.c | 1 | ||||
-rw-r--r-- | src/core/server-rec.h | 4 | ||||
-rw-r--r-- | src/core/servers-setup.c | 1 | ||||
-rw-r--r-- | src/fe-common/core/fe-queries.c | 10 | ||||
-rw-r--r-- | src/fe-common/core/fe-queries.h | 3 | ||||
-rw-r--r-- | src/fe-common/core/fe-server.c | 217 | ||||
-rw-r--r-- | src/fe-common/core/module-formats.c | 10 | ||||
-rw-r--r-- | src/fe-common/core/module-formats.h | 10 | ||||
-rw-r--r-- | src/fe-common/irc/fe-events.c | 60 | ||||
-rw-r--r-- | src/fe-common/irc/fe-irc-commands.c | 2 | ||||
-rw-r--r-- | src/fe-common/irc/fe-irc-server.c | 179 | ||||
-rw-r--r-- | src/fe-common/irc/fe-ircnet.c | 5 | ||||
-rw-r--r-- | src/fe-common/irc/module-formats.c | 16 | ||||
-rw-r--r-- | src/fe-common/irc/module-formats.h | 16 | ||||
-rw-r--r-- | src/fe-text/Makefile.am | 3 | ||||
-rw-r--r-- | src/fe-text/irssi.c | 2 | ||||
-rw-r--r-- | src/fe-text/statusbar-items.c | 4 | ||||
-rw-r--r-- | src/irc/core/irc-chatnets.c | 17 | ||||
-rw-r--r-- | src/irc/core/irc-core.c | 3 | ||||
-rw-r--r-- | src/irc/core/irc-servers.c | 3 | ||||
-rw-r--r-- | src/irc/core/irc-servers.h | 4 |
22 files changed, 324 insertions, 251 deletions
diff --git a/src/core/chatnets.c b/src/core/chatnets.c index 5b1b811d..465eaa66 100644 --- a/src/core/chatnets.c +++ b/src/core/chatnets.c @@ -54,7 +54,7 @@ void *chatnet_save(CHATNET_REC *chatnet, void *parentnode) CONFIG_NODE *node = parentnode; g_return_val_if_fail(parentnode != NULL, NULL); - g_return_val_if_fail(IS_CHATNET(chatnet), NULL); + g_return_val_if_fail(chatnet != NULL, NULL); node = config_node_section(node, chatnet->name, NODE_TYPE_BLOCK); iconfig_node_clear(node); @@ -83,7 +83,7 @@ void chatnet_remove(CHATNET_REC *chatnet) g_return_if_fail(IS_CHATNET(chatnet)); signal_emit("chatnet removed", 1, chatnet); - chatnet_destroy(chatnet); + chatnet_destroy(chatnet); } void chatnet_destroy(CHATNET_REC *chatnet) @@ -135,6 +135,7 @@ static void sig_connected(SERVER_REC *server) void chatnets_init(void) { + chatnets = NULL; signal_add("event connected", (SIGNAL_FUNC) sig_connected); } diff --git a/src/core/modules.c b/src/core/modules.c index 2c3acbd7..e95eaf2a 100644 --- a/src/core/modules.c +++ b/src/core/modules.c @@ -338,6 +338,7 @@ void module_unload(MODULE_REC *module) module_deinit(); g_free(deinitfunc); + signals_remove_module(module->name); g_module_close(module->gmodule); g_free(module->name); g_free(module); diff --git a/src/core/server-rec.h b/src/core/server-rec.h index 61aaa2d8..e9c069b7 100644 --- a/src/core/server-rec.h +++ b/src/core/server-rec.h @@ -36,6 +36,10 @@ int server_operator:1; int usermode_away:1; int banned:1; /* not allowed to connect to this server */ +time_t lag_sent; /* 0 or time when last lag query was sent to server */ +time_t lag_last_check; /* last time we checked lag */ +int lag; /* server lag in milliseconds */ + GSList *channels; GSList *queries; diff --git a/src/core/servers-setup.c b/src/core/servers-setup.c index 526854f3..17300930 100644 --- a/src/core/servers-setup.c +++ b/src/core/servers-setup.c @@ -385,6 +385,7 @@ static void server_setup_destroy(SERVER_SETUP_REC *rec) void server_setup_add(SERVER_SETUP_REC *rec) { + rec->type = module_get_uniq_id("SERVER SETUP", 0); if (g_slist_find(setupservers, rec) == NULL) setupservers = g_slist_append(setupservers, rec); server_setup_save(rec); diff --git a/src/fe-common/core/fe-queries.c b/src/fe-common/core/fe-queries.c index ffb83eb8..230f7dbb 100644 --- a/src/fe-common/core/fe-queries.c +++ b/src/fe-common/core/fe-queries.c @@ -31,10 +31,11 @@ #include "windows.h" #include "window-items.h" -static int queryclose_tag, query_auto_close; +static int queryclose_tag, query_auto_close, querycreate_level; /* Return query where to put the private message. */ -QUERY_REC *privmsg_get_query(SERVER_REC *server, const char *nick, int own) +QUERY_REC *privmsg_get_query(SERVER_REC *server, const char *nick, + int own, int level) { QUERY_REC *query; @@ -42,7 +43,7 @@ QUERY_REC *privmsg_get_query(SERVER_REC *server, const char *nick, int own) g_return_val_if_fail(nick != NULL, NULL); query = query_find(server, nick); - if (query == NULL && settings_get_bool("autocreate_query") && + if (query == NULL && (querycreate_level & level) != 0 && (!own || settings_get_bool("autocreate_own_query"))) query = query_create(server->chat_type, server, nick, TRUE); @@ -263,6 +264,7 @@ static int sig_query_autoclose(void) static void read_settings(void) { + querycreate_level = level2bits(settings_get_str("autocreate_query_level")); query_auto_close = settings_get_int("autoclose_query"); if (query_auto_close > 0 && queryclose_tag == -1) queryclose_tag = g_timeout_add(5000, (GSourceFunc) sig_query_autoclose, NULL); @@ -274,7 +276,7 @@ static void read_settings(void) void fe_queries_init(void) { - settings_add_bool("lookandfeel", "autocreate_query", TRUE); + settings_add_str("lookandfeel", "autocreate_query_level", "MSGS"); settings_add_bool("lookandfeel", "autocreate_own_query", TRUE); settings_add_int("lookandfeel", "autoclose_query", 0); diff --git a/src/fe-common/core/fe-queries.h b/src/fe-common/core/fe-queries.h index bc58b4e8..6db9cb44 100644 --- a/src/fe-common/core/fe-queries.h +++ b/src/fe-common/core/fe-queries.h @@ -4,7 +4,8 @@ #include "queries.h" /* Return query where to put the private message. */ -QUERY_REC *privmsg_get_query(SERVER_REC *server, const char *nick, int own); +QUERY_REC *privmsg_get_query(SERVER_REC *server, const char *nick, + int own, int level); void fe_queries_init(void); void fe_queries_deinit(void); diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index 5e5483a6..3c26c21e 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -20,13 +20,186 @@ #include "module.h" #include "signals.h" +#include "commands.h" #include "network.h" #include "levels.h" -#include "servers.h" #include "settings.h" +#include "chat-protocols.h" +#include "servers.h" +#include "servers-setup.h" +#include "servers-reconnect.h" + #include "module-formats.h" +static void print_servers(void) +{ + GSList *tmp; + + for (tmp = servers; tmp != NULL; tmp = tmp->next) { + SERVER_REC *rec = tmp->data; + + printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_LIST, + rec->tag, rec->connrec->address, rec->connrec->port, + rec->connrec->chatnet == NULL ? "" : rec->connrec->chatnet, rec->connrec->nick); + } +} + +static void print_lookup_servers(void) +{ + GSList *tmp; + for (tmp = lookup_servers; tmp != NULL; tmp = tmp->next) { + SERVER_REC *rec = tmp->data; + + printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_LOOKUP_LIST, + rec->tag, rec->connrec->address, rec->connrec->port, + rec->connrec->chatnet == NULL ? "" : rec->connrec->chatnet, rec->connrec->nick); + } +} + +static void print_reconnects(void) +{ + GSList *tmp; + char *tag, *next_connect; + int left; + + for (tmp = reconnects; tmp != NULL; tmp = tmp->next) { + RECONNECT_REC *rec = tmp->data; + SERVER_CONNECT_REC *conn = rec->conn; + + tag = g_strdup_printf("RECON-%d", rec->tag); + left = rec->next_connect-time(NULL); + next_connect = g_strdup_printf("%02d:%02d", left/60, left%60); + printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_RECONNECT_LIST, + tag, conn->address, conn->port, + conn->chatnet == NULL ? "" : conn->chatnet, + conn->nick, next_connect); + g_free(next_connect); + g_free(tag); + } +} + +/* SYNTAX: SERVER ADD [-auto | -noauto] [-host <hostname>] + [-cmdspeed <ms>] [-cmdmax <count>] [-port <port>] + <address> [<port> [<password>]] */ +static void cmd_server_add(const char *data) +{ + GHashTable *optlist; + SERVER_SETUP_REC *rec; + char *addr, *portstr, *password, *value; + void *free_arg; + int port; + + if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTIONS, + "server add", &optlist, &addr, &portstr, &password)) + return; + + if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + port = *portstr == '\0' ? 6667 : atoi(portstr); + + rec = server_setup_find_port(addr, port); + if (rec == NULL) { + signal_emit("server add create", 2, &rec, optlist); + if (rec == NULL) { + /* no chatnet option specified, use the first. */ + g_hash_table_insert(optlist, (char *) chat_protocol_get_chatnet(1), ""); + signal_emit("server add create", 2, &rec, optlist); + if (rec == NULL) { + /* bug? */ + cmd_params_free(free_arg); + return; + } + } + rec->address = g_strdup(addr); + rec->port = port; + } else { + value = g_hash_table_lookup(optlist, "port"); + if (value != NULL && *value != '\0') rec->port = atoi(value); + + if (*password != '\0') g_free_and_null(rec->password); + if (g_hash_table_lookup(optlist, "host")) { + g_free_and_null(rec->own_host); + rec->own_ip = NULL; + } + } + + if (g_hash_table_lookup(optlist, "auto")) rec->autoconnect = TRUE; + if (g_hash_table_lookup(optlist, "noauto")) rec->autoconnect = FALSE; + + if (*password != '\0' && strcmp(password, "-") != 0) rec->password = g_strdup(password); + value = g_hash_table_lookup(optlist, "host"); + if (value != NULL && *value != '\0') { + rec->own_host = g_strdup(value); + rec->own_ip = NULL; + } + + signal_emit("server add fill", 2, rec, optlist); + + server_setup_add(rec); + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_SETUPSERVER_ADDED, addr, port); + + cmd_params_free(free_arg); +} + +/* SYNTAX: SERVER REMOVE <address> [<port>] */ +static void cmd_server_remove(const char *data) +{ + SERVER_SETUP_REC *rec; + char *addr, *portstr; + void *free_arg; + int port; + + if (!cmd_get_params(data, &free_arg, 2, &addr, &portstr)) + return; + if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + port = *portstr == '\0' ? -1 : atoi(portstr); + + rec = server_setup_find_port(addr, port); + if (rec == NULL) + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_SETUPSERVER_NOT_FOUND, addr, port); + else { + server_setup_remove(rec); + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_SETUPSERVER_REMOVED, addr, port); + } + + cmd_params_free(free_arg); +} + +static void cmd_server(const char *data, SERVER_REC *server, void *item) +{ + GHashTable *optlist; + char *addr; + void *free_arg; + + if (*data == '\0') { + print_servers(); + print_lookup_servers(); + print_reconnects(); + + signal_stop(); + return; + } + + if (g_strncasecmp(data, "add ", 4) == 0 || + g_strncasecmp(data, "remove ", 7) == 0 || + g_strcasecmp(data, "list") == 0 || + g_strncasecmp(data, "list ", 5) == 0) { + command_runsub("server", data, server, item); + signal_stop(); + return; + } + + if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS, + "connect", &optlist, &addr)) + return; + + if (*addr == '\0' || strcmp(addr, "+") == 0) + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + if (*addr == '+') window_create(NULL, FALSE); + + cmd_params_free(free_arg); +} + static void sig_server_looking(SERVER_REC *server) { g_return_if_fail(server != NULL); @@ -85,22 +258,64 @@ static void sig_server_quit(SERVER_REC *server, const char *msg) IRCTXT_SERVER_QUIT, server->connrec->address, msg); } +static void sig_server_lag_disconnected(SERVER_REC *server) +{ + g_return_if_fail(server != NULL); + + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + IRCTXT_LAG_DISCONNECTED, server->connrec->address, time(NULL)-server->lag_sent); +} + +static void sig_server_reconnect_removed(RECONNECT_REC *reconnect) +{ + g_return_if_fail(reconnect != NULL); + + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + IRCTXT_RECONNECT_REMOVED, reconnect->conn->address, reconnect->conn->port, + reconnect->conn->chatnet == NULL ? "" : reconnect->conn->chatnet); +} + +static void sig_server_reconnect_not_found(const char *tag) +{ + g_return_if_fail(tag != NULL); + + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + IRCTXT_RECONNECT_NOT_FOUND, tag); +} + void fe_server_init(void) { + command_bind("server", NULL, (SIGNAL_FUNC) cmd_server); + command_bind("server add", NULL, (SIGNAL_FUNC) cmd_server_add); + command_bind("server remove", NULL, (SIGNAL_FUNC) cmd_server_remove); + command_set_options("server add", "auto noauto -host -cmdspeed -cmdmax -port"); + signal_add("server looking", (SIGNAL_FUNC) sig_server_looking); signal_add("server connecting", (SIGNAL_FUNC) sig_server_connecting); signal_add("server connected", (SIGNAL_FUNC) sig_server_connected); signal_add("server connect failed", (SIGNAL_FUNC) sig_connect_failed); signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected); signal_add("server quit", (SIGNAL_FUNC) sig_server_quit); + + signal_add("server lag disconnect", (SIGNAL_FUNC) sig_server_lag_disconnected); + signal_add("server reconnect remove", (SIGNAL_FUNC) sig_server_reconnect_removed); + signal_add("server reconnect not found", (SIGNAL_FUNC) sig_server_reconnect_not_found); } void fe_server_deinit(void) { + command_unbind("server", (SIGNAL_FUNC) cmd_server); + command_unbind("server add", (SIGNAL_FUNC) cmd_server_add); + command_unbind("server remove", (SIGNAL_FUNC) cmd_server_remove); + signal_remove("server looking", (SIGNAL_FUNC) sig_server_looking); signal_remove("server connecting", (SIGNAL_FUNC) sig_server_connecting); signal_remove("server connected", (SIGNAL_FUNC) sig_server_connected); signal_remove("server connect failed", (SIGNAL_FUNC) sig_connect_failed); signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected); signal_remove("server quit", (SIGNAL_FUNC) sig_server_quit); + + signal_remove("server lag disconnect", (SIGNAL_FUNC) sig_server_lag_disconnected); + signal_remove("server reconnect remove", (SIGNAL_FUNC) sig_server_reconnect_removed); + signal_remove("server reconnect not found", (SIGNAL_FUNC) sig_server_reconnect_not_found); } diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c index 3937b583..8670059f 100644 --- a/src/fe-common/core/module-formats.c +++ b/src/fe-common/core/module-formats.c @@ -46,9 +46,19 @@ FORMAT_REC fecommon_core_formats[] = { { "connection_established", "Connection to %_$0%_ established", 1, { 0 } }, { "cant_connect", "Unable to connect server %_$0%_ port %_$1%_ %K[%n$2%K]", 3, { 0, 1, 0 } }, { "connection_lost", "Connection lost to %_$0%_", 1, { 0 } }, + { "lag_disconnected", "No PONG reply from server %_$0%_ in $1 seconds, disconnecting", 2, { 0, 1 } }, + { "disconnected", "Disconnected from %_$0%_ %K[%n$1%K]", 2, { 0, 0 } }, { "server_quit", "Disconnecting from server $0: %K[%n$1%K]", 2, { 0, 0 } }, { "server_changed", "Changed to %_$2%_ server %_$1%_", 3, { 0, 0, 0 } }, { "unknown_server_tag", "Unknown server tag %_$0%_", 1, { 0 } }, + { "server_list", "%_$0%_: $1:$2 ($3)", 5, { 0, 0, 1, 0, 0 } }, + { "server_lookup_list", "%_$0%_: $1:$2 ($3) (connecting...)", 5, { 0, 0, 1, 0, 0 } }, + { "server_reconnect_list", "%_$0%_: $1:$2 ($3) ($5 left before reconnecting)", 6, { 0, 0, 1, 0, 0, 0 } }, + { "server_reconnect_removed", "Removed reconnection to server %_$0%_ port %_$1%_", 3, { 0, 1, 0 } }, + { "server_reconnect_not_found", "Reconnection tag %_$0%_ not found", 1, { 0 } }, + { "setupserver_added", "Server $0 saved", 2, { 0, 1 } }, + { "setupserver_removed", "Server $0 removed", 2, { 0, 1 } }, + { "setupserver_not_found", "Server $0 not found", 2, { 0, 1 } }, /* ---- */ { NULL, "Channels", 0 }, diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h index 86f27baf..41dcc1d5 100644 --- a/src/fe-common/core/module-formats.h +++ b/src/fe-common/core/module-formats.h @@ -23,9 +23,19 @@ enum { IRCTXT_CONNECTION_ESTABLISHED, IRCTXT_CANT_CONNECT, IRCTXT_CONNECTION_LOST, + IRCTXT_LAG_DISCONNECTED, + IRCTXT_DISCONNECTED, IRCTXT_SERVER_QUIT, IRCTXT_SERVER_CHANGED, IRCTXT_UNKNOWN_SERVER_TAG, + IRCTXT_SERVER_LIST, + IRCTXT_SERVER_LOOKUP_LIST, + IRCTXT_SERVER_RECONNECT_LIST, + IRCTXT_RECONNECT_REMOVED, + IRCTXT_RECONNECT_NOT_FOUND, + IRCTXT_SETUPSERVER_ADDED, + IRCTXT_SETUPSERVER_REMOVED, + IRCTXT_SETUPSERVER_NOT_FOUND, IRCTXT_FILL_3, diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c index 47f9b29f..09e4d121 100644 --- a/src/fe-common/irc/fe-events.c +++ b/src/fe-common/irc/fe-events.c @@ -98,7 +98,7 @@ static void print_channel_msg(IRC_SERVER_REC *server, const char *msg, static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr) { - WI_ITEM_REC *item; + QUERY_REC *query; char *params, *target, *msg; g_return_if_fail(data != NULL); @@ -113,9 +113,9 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char * print_channel_msg(server, msg, nick, addr, target); } else { /* private message */ - item = (WI_ITEM_REC *) privmsg_get_query(SERVER(server), nick, FALSE); + query = privmsg_get_query(SERVER(server), nick, FALSE, MSGLEVEL_MSGS); printformat(server, nick, MSGLEVEL_MSGS, - item == NULL ? IRCTXT_MSG_PRIVATE : IRCTXT_MSG_PRIVATE_QUERY, nick, addr, msg); + query == NULL ? IRCTXT_MSG_PRIVATE : IRCTXT_MSG_PRIVATE_QUERY, nick, addr, msg); } } @@ -127,7 +127,7 @@ static void event_privmsg(const char *data, IRC_SERVER_REC *server, const char * static void ctcp_msg_check_action(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr, const char *target) { - WI_ITEM_REC *item; + void *item; int level; g_return_if_fail(data != NULL); @@ -143,7 +143,7 @@ static void ctcp_msg_check_action(const char *data, IRC_SERVER_REC *server, if (ischannel(*target)) { /* channel action */ - item = (WI_ITEM_REC *) irc_channel_find(server, target); + item = irc_channel_find(server, target); if (window_item_is_active(item)) { /* message to active channel in window */ @@ -156,7 +156,7 @@ static void ctcp_msg_check_action(const char *data, IRC_SERVER_REC *server, } } else { /* private action */ - item = (WI_ITEM_REC *) privmsg_get_query(SERVER(server), nick, FALSE); + item = privmsg_get_query(SERVER(server), nick, FALSE, MSGLEVEL_MSGS); printformat(server, nick, level, item == NULL ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY, nick, addr == NULL ? "" : addr, data); @@ -185,16 +185,19 @@ static void event_notice(const char *data, IRC_SERVER_REC *server, const char *n op_notice = *target == '@' && ischannel(target[1]); if (op_notice) target++; + if (ignore_check(server, nick, addr, ischannel(*target) ? + target : NULL, msg, MSGLEVEL_NOTICES)) + return; + if (ischannel(*target)) { /* notice in some channel */ - if (!ignore_check(server, nick, addr, target, msg, MSGLEVEL_NOTICES)) - printformat(server, target, MSGLEVEL_NOTICES, - op_notice ? IRCTXT_NOTICE_PUBLIC_OPS : IRCTXT_NOTICE_PUBLIC, - nick, target, msg); + printformat(server, target, MSGLEVEL_NOTICES, + op_notice ? IRCTXT_NOTICE_PUBLIC_OPS : IRCTXT_NOTICE_PUBLIC, + nick, target, msg); } else { /* private notice */ - if (!ignore_check(server, nick, addr, NULL, msg, MSGLEVEL_NOTICES)) - printformat(server, nick, MSGLEVEL_NOTICES, IRCTXT_NOTICE_PRIVATE, nick, addr, msg); + privmsg_get_query(SERVER(server), nick, FALSE, MSGLEVEL_NOTICES); + printformat(server, nick, MSGLEVEL_NOTICES, IRCTXT_NOTICE_PRIVATE, nick, addr, msg); } } @@ -552,31 +555,6 @@ static void sig_whowas_event_end(const char *data, IRC_SERVER_REC *server, const g_free(params); } -static void sig_server_lag_disconnected(IRC_SERVER_REC *server) -{ - g_return_if_fail(server != NULL); - - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, - IRCTXT_LAG_DISCONNECTED, server->connrec->address, time(NULL)-server->lag_sent); -} - -static void sig_server_reconnect_removed(RECONNECT_REC *reconnect) -{ - g_return_if_fail(reconnect != NULL); - - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, - IRCTXT_RECONNECT_REMOVED, reconnect->conn->address, reconnect->conn->port, - reconnect->conn->chatnet == NULL ? "" : reconnect->conn->chatnet); -} - -static void sig_server_reconnect_not_found(const char *tag) -{ - g_return_if_fail(tag != NULL); - - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, - IRCTXT_RECONNECT_NOT_FOUND, tag); -} - static void event_received(const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr) { char *params, *cmd, *args, *ptr; @@ -625,10 +603,6 @@ void fe_events_init(void) signal_add("nickfind event whois", (SIGNAL_FUNC) event_nickfind_whois); signal_add("ban type changed", (SIGNAL_FUNC) event_ban_type_changed); signal_add("whowas event end", (SIGNAL_FUNC) sig_whowas_event_end); - - signal_add("server lag disconnect", (SIGNAL_FUNC) sig_server_lag_disconnected); - signal_add("server reconnect remove", (SIGNAL_FUNC) sig_server_reconnect_removed); - signal_add("server reconnect not found", (SIGNAL_FUNC) sig_server_reconnect_not_found); } void fe_events_deinit(void) @@ -656,8 +630,4 @@ void fe_events_deinit(void) signal_remove("nickfind event whois", (SIGNAL_FUNC) event_nickfind_whois); signal_remove("ban type changed", (SIGNAL_FUNC) event_ban_type_changed); signal_remove("whowas event end", (SIGNAL_FUNC) sig_whowas_event_end); - - signal_remove("server lag disconnect", (SIGNAL_FUNC) sig_server_lag_disconnected); - signal_remove("server reconnect remove", (SIGNAL_FUNC) sig_server_reconnect_removed); - signal_remove("server reconnect not found", (SIGNAL_FUNC) sig_server_reconnect_not_found); } diff --git a/src/fe-common/irc/fe-irc-commands.c b/src/fe-common/irc/fe-irc-commands.c index ce5fa2f6..7a522f89 100644 --- a/src/fe-common/irc/fe-irc-commands.c +++ b/src/fe-common/irc/fe-irc-commands.c @@ -118,7 +118,7 @@ static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item) else { /* private message */ - item = (WI_ITEM_REC *) privmsg_get_query(SERVER(server), target, TRUE); + item = (WI_ITEM_REC *) privmsg_get_query(SERVER(server), target, TRUE, MSGLEVEL_MSGS); printformat(server, target, MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT, item == NULL ? IRCTXT_OWN_MSG_PRIVATE : IRCTXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick); } diff --git a/src/fe-common/irc/fe-irc-server.c b/src/fe-common/irc/fe-irc-server.c index 85e40afd..ace02feb 100644 --- a/src/fe-common/irc/fe-irc-server.c +++ b/src/fe-common/irc/fe-irc-server.c @@ -33,132 +33,35 @@ #include "windows.h" -static void print_servers(void) +static void sig_server_add_create(IRC_SERVER_SETUP_REC **rec, + GHashTable *optlist) { - GSList *tmp; - - for (tmp = servers; tmp != NULL; tmp = tmp->next) { - SERVER_REC *rec = tmp->data; - - printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_LIST, - rec->tag, rec->connrec->address, rec->connrec->port, - rec->connrec->chatnet == NULL ? "" : rec->connrec->chatnet, rec->connrec->nick); - } -} + char *ircnet; -static void print_lookup_servers(void) -{ - GSList *tmp; - for (tmp = lookup_servers; tmp != NULL; tmp = tmp->next) { - SERVER_REC *rec = tmp->data; - - printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_LOOKUP_LIST, - rec->tag, rec->connrec->address, rec->connrec->port, - rec->connrec->chatnet == NULL ? "" : rec->connrec->chatnet, rec->connrec->nick); - } -} + ircnet = g_hash_table_lookup(optlist, "ircnet"); + if (ircnet == NULL) + return; -static void print_reconnects(void) -{ - GSList *tmp; - char *tag, *next_connect; - int left; - - for (tmp = reconnects; tmp != NULL; tmp = tmp->next) { - RECONNECT_REC *rec = tmp->data; - SERVER_CONNECT_REC *conn = rec->conn; - - tag = g_strdup_printf("RECON-%d", rec->tag); - left = rec->next_connect-time(NULL); - next_connect = g_strdup_printf("%02d:%02d", left/60, left%60); - printformat(NULL, NULL, MSGLEVEL_CRAP, IRCTXT_SERVER_RECONNECT_LIST, - tag, conn->address, conn->port, - conn->chatnet == NULL ? "" : conn->chatnet, - conn->nick, next_connect); - g_free(next_connect); - g_free(tag); - } + *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 cmd_server_add(const char *data) +static void sig_server_add_fill(IRC_SERVER_SETUP_REC *rec, + GHashTable *optlist) { - GHashTable *optlist; - IRC_SERVER_SETUP_REC *rec; - char *addr, *portstr, *password, *value; - void *free_arg; - int port; - - if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTIONS, - "server add", &optlist, &addr, &portstr, &password)) - return; - - if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - port = *portstr == '\0' ? 6667 : atoi(portstr); - - rec = IRC_SERVER_SETUP(server_setup_find_port(addr, port)); - if (rec == NULL) { - rec = g_new0(IRC_SERVER_SETUP_REC, 1); - rec->address = g_strdup(addr); - rec->port = port; - } else { - value = g_hash_table_lookup(optlist, "port"); - if (value != NULL && *value != '\0') rec->port = atoi(value); - - if (g_hash_table_lookup(optlist, "ircnet")) g_free_and_null(rec->chatnet); - if (*password != '\0') g_free_and_null(rec->password); - if (g_hash_table_lookup(optlist, "host")) { - g_free_and_null(rec->own_host); - rec->own_ip = NULL; - } - } + char *value; - if (g_hash_table_lookup(optlist, "auto")) rec->autoconnect = TRUE; - if (g_hash_table_lookup(optlist, "noauto")) rec->autoconnect = FALSE; - - if (*password != '\0' && strcmp(password, "-") != 0) rec->password = g_strdup(password); value = g_hash_table_lookup(optlist, "ircnet"); - if (value != NULL && *value != '\0') rec->chatnet = g_strdup(value); - value = g_hash_table_lookup(optlist, "host"); - if (value != NULL && *value != '\0') { - rec->own_host = g_strdup(value); - rec->own_ip = NULL; + if (value != NULL) { + g_free_and_null(rec->chatnet); + if (*value != '\0') rec->chatnet = g_strdup(value); } + value = g_hash_table_lookup(optlist, "cmdspeed"); if (value != NULL && *value != '\0') rec->cmd_queue_speed = atoi(value); value = g_hash_table_lookup(optlist, "cmdmax"); if (value != NULL && *value != '\0') rec->max_cmds_at_once = atoi(value); - - server_setup_add(SERVER_SETUP(rec)); - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_SETUPSERVER_ADDED, addr, port); - - cmd_params_free(free_arg); -} - -/* SYNTAX: SERVER REMOVE <address> [<port>] */ -static void cmd_server_remove(const char *data) -{ - SERVER_SETUP_REC *rec; - char *addr, *portstr; - void *free_arg; - int port; - - if (!cmd_get_params(data, &free_arg, 2, &addr, &portstr)) - return; - if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - port = *portstr == '\0' ? -1 : atoi(portstr); - - rec = server_setup_find_port(addr, port); - if (rec == NULL) - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_SETUPSERVER_NOT_FOUND, addr, port); - else { - server_setup_remove(rec); - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_SETUPSERVER_REMOVED, addr, port); - } - - cmd_params_free(free_arg); } /* SYNTAX: SERVER LIST */ @@ -172,6 +75,9 @@ static void cmd_server_list(const char *data) for (tmp = setupservers; tmp != NULL; tmp = tmp->next) { IRC_SERVER_SETUP_REC *rec = tmp->data; + if (!IS_IRC_SERVER_SETUP(rec)) + continue; + g_string_truncate(str, 0); if (rec->password != NULL) g_string_append(str, "(pass), "); @@ -194,55 +100,18 @@ static void cmd_server_list(const char *data) g_string_free(str, TRUE); } -static void cmd_server(const char *data, IRC_SERVER_REC *server, void *item) -{ - GHashTable *optlist; - char *addr; - void *free_arg; - - if (*data == '\0') { - print_servers(); - print_lookup_servers(); - print_reconnects(); - - signal_stop(); - return; - } - - if (g_strncasecmp(data, "add ", 4) == 0 || - g_strncasecmp(data, "remove ", 7) == 0 || - g_strcasecmp(data, "list") == 0 || - g_strncasecmp(data, "list ", 5) == 0) { - command_runsub("server", data, server, item); - signal_stop(); - return; - } - - if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS, - "connect", &optlist, &addr)) - return; - - if (*addr == '\0' || strcmp(addr, "+") == 0) - cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - if (*addr == '+') window_create(NULL, FALSE); - - cmd_params_free(free_arg); -} - void fe_irc_server_init(void) { - command_bind("server", NULL, (SIGNAL_FUNC) cmd_server); - command_bind("server add", NULL, (SIGNAL_FUNC) cmd_server_add); - command_bind("server remove", NULL, (SIGNAL_FUNC) cmd_server_remove); + 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); - command_set_options("server add", "auto noauto -ircnet -host -cmdspeed -cmdmax -port"); + command_set_options("server add", "-ircnet"); } void fe_irc_server_deinit(void) { - command_unbind("server", (SIGNAL_FUNC) cmd_server); - command_unbind("server add", (SIGNAL_FUNC) cmd_server_add); - command_unbind("server remove", (SIGNAL_FUNC) cmd_server_remove); + 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 f770fff6..090c8a61 100644 --- a/src/fe-common/irc/fe-ircnet.c +++ b/src/fe-common/irc/fe-ircnet.c @@ -39,6 +39,9 @@ static void cmd_ircnet_list(void) for (tmp = chatnets; tmp != NULL; tmp = tmp->next) { IRC_CHATNET_REC *rec = tmp->data; + if (!IS_IRCNET(rec)) + continue; + g_string_truncate(str, 0); if (rec->nick != NULL) g_string_sprintfa(str, "nick: %s, ", rec->nick); @@ -152,7 +155,7 @@ static void cmd_ircnet_remove(const char *data) printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_IRCNET_NOT_FOUND, data); else { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_IRCNET_REMOVED, data); - chatnet_destroy(CHATNET(rec)); + chatnet_remove(CHATNET(rec)); } } diff --git a/src/fe-common/irc/module-formats.c b/src/fe-common/irc/module-formats.c index 913d3ae9..18149994 100644 --- a/src/fe-common/irc/module-formats.c +++ b/src/fe-common/irc/module-formats.c @@ -27,19 +27,6 @@ FORMAT_REC fecommon_irc_formats[] = { /* ---- */ { NULL, "Server", 0 }, - { "lag_disconnected", "No PONG reply from server %_$0%_ in $1 seconds, disconnecting", 2, { 0, 1 } }, - { "disconnected", "Disconnected from %_$0%_ %K[%n$1%K]", 2, { 0, 0 } }, - { "server_list", "%_$0%_: $1:$2 ($3)", 5, { 0, 0, 1, 0, 0 } }, - { "server_lookup_list", "%_$0%_: $1:$2 ($3) (connecting...)", 5, { 0, 0, 1, 0, 0 } }, - { "server_reconnect_list", "%_$0%_: $1:$2 ($3) ($5 left before reconnecting)", 6, { 0, 0, 1, 0, 0, 0 } }, - { "server_reconnect_removed", "Removed reconnection to server %_$0%_ port %_$1%_", 3, { 0, 1, 0 } }, - { "server_reconnect_not_found", "Reconnection tag %_$0%_ not found", 1, { 0 } }, - { "setupserver_added", "Server $0 saved", 2, { 0, 1 } }, - { "setupserver_removed", "Server $0 removed", 2, { 0, 1 } }, - { "setupserver_not_found", "Server $0 not found", 2, { 0, 1 } }, - { "setupserver_header", "Server Port IRC Net Settings", 0 }, - { "setupserver_line", "%|$[!20]0 $[5]1 $[10]2 $3", 4, { 0, 1, 0, 0 } }, - { "setupserver_footer", "", 0 }, { "netsplit", "%RNetsplit%n %_$0%_ %_$1%_ quits: $2", 3, { 0, 0, 0 } }, { "netsplit_more", "%RNetsplit%n %_$0%_ %_$1%_ quits: $2 (+$3 more, use /NETSPLIT to show all of them)", 4, { 0, 0, 0, 1 } }, { "netsplit_join", "%CNetsplit%n over, joins: $0", 1, { 0 } }, @@ -54,6 +41,9 @@ FORMAT_REC fecommon_irc_formats[] = { { "ircnet_header", "Ircnets:", 0 }, { "ircnet_line", "$0: $1", 2, { 0, 0 } }, { "ircnet_footer", "", 0 }, + { "setupserver_header", "Server Port IRC Net Settings", 0 }, + { "setupserver_line", "%|$[!20]0 $[5]1 $[10]2 $3", 4, { 0, 1, 0, 0 } }, + { "setupserver_footer", "", 0 }, /* ---- */ { NULL, "Channels", 0 }, diff --git a/src/fe-common/irc/module-formats.h b/src/fe-common/irc/module-formats.h index e92757fc..9a49926e 100644 --- a/src/fe-common/irc/module-formats.h +++ b/src/fe-common/irc/module-formats.h @@ -5,19 +5,6 @@ enum { IRCTXT_FILL_1, - IRCTXT_LAG_DISCONNECTED, - IRCTXT_DISCONNECTED, - IRCTXT_SERVER_LIST, - IRCTXT_SERVER_LOOKUP_LIST, - IRCTXT_SERVER_RECONNECT_LIST, - IRCTXT_RECONNECT_REMOVED, - IRCTXT_RECONNECT_NOT_FOUND, - IRCTXT_SETUPSERVER_ADDED, - IRCTXT_SETUPSERVER_REMOVED, - IRCTXT_SETUPSERVER_NOT_FOUND, - IRCTXT_SETUPSERVER_HEADER, - IRCTXT_SETUPSERVER_LINE, - IRCTXT_SETUPSERVER_FOOTER, IRCTXT_NETSPLIT, IRCTXT_NETSPLIT_MORE, IRCTXT_NETSPLIT_JOIN, @@ -32,6 +19,9 @@ enum { IRCTXT_IRCNET_HEADER, IRCTXT_IRCNET_LINE, IRCTXT_IRCNET_FOOTER, + IRCTXT_SETUPSERVER_HEADER, + IRCTXT_SETUPSERVER_LINE, + IRCTXT_SETUPSERVER_FOOTER, IRCTXT_FILL_2, diff --git a/src/fe-text/Makefile.am b/src/fe-text/Makefile.am index a3ffadda..91058990 100644 --- a/src/fe-text/Makefile.am +++ b/src/fe-text/Makefile.am @@ -14,6 +14,9 @@ irssi_DEPENDENCIES = @COMMON_LIBS@ irssi_LDADD = \ @COMMON_LIBS@ \ + $(top_srcdir)/silc/src/core/.libs/libsilc.a \ + $(top_srcdir)/silc/src/fe-common/.libs/libfe_common_silc.a \ + $(top_srcdir)/silc/libsilc-client.a \ $(PROG_LIBS) \ $(PERL_LDFLAGS) \ $(CURSES_LIBS) diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c index ec7f979a..34237930 100644 --- a/src/fe-text/irssi.c +++ b/src/fe-text/irssi.c @@ -85,8 +85,10 @@ static void textui_init(void) irssi_gui = IRSSI_GUI_TEXT; core_init(); irc_init(); + silc_core_init(); fe_common_core_init(); fe_common_irc_init(); + fe_common_silc_init(); theme_register(gui_text_formats); signal_add("gui exit", (SIGNAL_FUNC) sig_exit); diff --git a/src/fe-text/statusbar-items.c b/src/fe-text/statusbar-items.c index ea7c8ed5..cb07c7e6 100644 --- a/src/fe-text/statusbar-items.c +++ b/src/fe-text/statusbar-items.c @@ -515,7 +515,7 @@ static void sig_statusbar_more_check(WINDOW_REC *window) static void statusbar_lag(SBAR_ITEM_REC *item, int ypos) { - IRC_SERVER_REC *server; + SERVER_REC *server; GString *str; int size_needed, lag_unknown; time_t now; @@ -523,7 +523,7 @@ static void statusbar_lag(SBAR_ITEM_REC *item, int ypos) now = time(NULL); str = g_string_new(NULL); - server = IRC_SERVER(active_win == NULL ? NULL : active_win->active_server); + server = active_win == NULL ? NULL : active_win->active_server; if (server == NULL || server->lag_last_check == 0) size_needed = 0; else if (server->lag_sent == 0 || now-server->lag_sent < 5) { diff --git a/src/irc/core/irc-chatnets.c b/src/irc/core/irc-chatnets.c index 4eda9401..0ccf121c 100644 --- a/src/irc/core/irc-chatnets.c +++ b/src/irc/core/irc-chatnets.c @@ -53,10 +53,10 @@ static void ircnet_save(IRC_CHATNET_REC *rec) { CONFIG_NODE *node; - g_return_if_fail(IS_IRC_CHATNET(rec)); + g_return_if_fail(rec != NULL); node = iconfig_node_traverse("ircnets", TRUE); - node = chatnet_save(CHATNET(rec), node); + node = chatnet_save((CHATNET_REC *) rec, node); if (rec->max_cmds_at_once > 0) config_node_set_int(node, "cmdmax", rec->max_cmds_at_once); @@ -90,16 +90,21 @@ void ircnet_create(IRC_CHATNET_REC *rec) rec->chat_type = IRC_PROTOCOL; ircnet_save(rec); - chatnet_create(CHATNET(rec)); + chatnet_create((CHATNET_REC *) rec); } static void read_ircnets(void) { CONFIG_NODE *node; - GSList *tmp; + GSList *tmp, *next; - while (chatnets != NULL) - chatnet_destroy(chatnets->data); + 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); diff --git a/src/irc/core/irc-core.c b/src/irc/core/irc-core.c index a6ff310a..657696ef 100644 --- a/src/irc/core/irc-core.c +++ b/src/irc/core/irc-core.c @@ -22,6 +22,7 @@ #include "chat-protocols.h" #include "irc-servers.h" +#include "irc-chatnets.h" #include "irc-channels.h" #include "irc-queries.h" @@ -52,6 +53,7 @@ void irc_core_init(void) { chat_protocol_register("IRC", "Internet Relay Chat", "ircnet"); + irc_chatnets_init(); irc_servers_init(); irc_channels_init(); irc_queries_init(); @@ -84,6 +86,7 @@ void irc_core_deinit(void) irc_channels_deinit(); irc_irc_deinit(); irc_servers_deinit(); + irc_chatnets_deinit(); chat_protocol_unregister("IRC"); } diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index d51f2af5..be6bd809 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -31,7 +31,6 @@ #include "queries.h" #include "irc.h" -#include "irc-chatnets.h" #include "irc-servers-setup.h" #include "irc-servers.h" #include "server-idle.h" @@ -396,7 +395,6 @@ void irc_servers_init(void) signal_add("event empty", (SIGNAL_FUNC) event_empty); irc_servers_setup_init(); - irc_chatnets_init(); irc_servers_reconnect_init(); servers_idle_init(); } @@ -422,7 +420,6 @@ void irc_servers_deinit(void) signal_remove("event empty", (SIGNAL_FUNC) event_empty); irc_servers_setup_deinit(); - irc_chatnets_deinit(); irc_servers_reconnect_deinit(); servers_idle_deinit(); } diff --git a/src/irc/core/irc-servers.h b/src/irc/core/irc-servers.h index 1541693f..0b66f27c 100644 --- a/src/irc/core/irc-servers.h +++ b/src/irc/core/irc-servers.h @@ -78,10 +78,6 @@ typedef struct { GHashTable *splits; /* For keeping track of netsplits */ GSList *split_servers; /* Servers that are currently in split */ - time_t lag_sent; /* 0 or time when last lag query was sent to server */ - time_t lag_last_check; /* last time we checked lag */ - int lag; /* server lag in milliseconds */ - GSList *rejoin_channels; /* try to join to these channels after a while - channels go here if they're "temporarily unavailable" because of netsplits */ |