diff options
author | Timo Sirainen <cras@irssi.org> | 2000-09-06 21:30:56 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-09-06 21:30:56 +0000 |
commit | 2d1ac3059a0d9df1ef2420080d642d04fac8934d (patch) | |
tree | 5c66799e1d332349b978970c419e570b07d45e40 /src/fe-common/irc | |
parent | 008ec45db2af71143951785285d7127ccf94f241 (diff) | |
download | irssi-2d1ac3059a0d9df1ef2420080d642d04fac8934d.zip |
/set autocreate_query -> /set autocreate_query_level
fixes to /ircnet, /server and /channel commands
other updates and fixes
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@649 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/irc')
-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 |
6 files changed, 50 insertions, 228 deletions
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, |