diff options
author | Timo Sirainen <cras@irssi.org> | 2001-02-10 02:02:26 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-02-10 02:02:26 +0000 |
commit | e4f7d55ce941bf33b1d23d7c21e6beb9fb69aba0 (patch) | |
tree | b69359528adf2716cf3d4a765d3f0f7767565be7 /src/fe-common/irc/dcc | |
parent | 118f9a11ebfc521198d39fd3048ad462ace696ed (diff) | |
download | irssi-e4f7d55ce941bf33b1d23d7c21e6beb9fb69aba0.zip |
DCC cleanups - split DCC_REC to CHAT|GET|SEND_DCC_RECs. Plugins should
now be able to add whatever new DCC types.
Nick changes affect DCC chats. /WHOIS without parameters works properly
in DCC CHAT queries.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1194 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/irc/dcc')
-rw-r--r-- | src/fe-common/irc/dcc/Makefile.am | 4 | ||||
-rw-r--r-- | src/fe-common/irc/dcc/fe-dcc-chat.c | 404 | ||||
-rw-r--r-- | src/fe-common/irc/dcc/fe-dcc-get.c | 126 | ||||
-rw-r--r-- | src/fe-common/irc/dcc/fe-dcc-send.c | 143 | ||||
-rw-r--r-- | src/fe-common/irc/dcc/fe-dcc.c | 559 | ||||
-rw-r--r-- | src/fe-common/irc/dcc/fe-dcc.h | 6 |
6 files changed, 727 insertions, 515 deletions
diff --git a/src/fe-common/irc/dcc/Makefile.am b/src/fe-common/irc/dcc/Makefile.am index 38f7dbc1..42317341 100644 --- a/src/fe-common/irc/dcc/Makefile.am +++ b/src/fe-common/irc/dcc/Makefile.am @@ -8,12 +8,16 @@ INCLUDES = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/core/ \ -I$(top_srcdir)/src/irc/core/ \ + -I$(top_srcdir)/src/irc/dcc/ \ -I$(top_srcdir)/src/fe-common/core/ \ -DHELPDIR=\""$(datadir)/irssi/help"\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" libfe_common_irc_dcc_la_SOURCES = \ fe-dcc.c \ + fe-dcc-chat.c \ + fe-dcc-get.c \ + fe-dcc-send.c \ module-formats.c noinst_HEADERS = \ diff --git a/src/fe-common/irc/dcc/fe-dcc-chat.c b/src/fe-common/irc/dcc/fe-dcc-chat.c new file mode 100644 index 00000000..aa8a0eb6 --- /dev/null +++ b/src/fe-common/irc/dcc/fe-dcc-chat.c @@ -0,0 +1,404 @@ +/* + fe-dcc-chat.c : irssi + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "module.h" +#include "signals.h" +#include "commands.h" +#include "levels.h" +#include "settings.h" + +#include "irc.h" +#include "irc-queries.h" +#include "dcc-chat.h" + +#include "module-formats.h" +#include "printtext.h" +#include "fe-messages.h" + +#include "chat-completion.h" + +static int autocreate_dccquery; + +static void dcc_request(CHAT_DCC_REC *dcc) +{ + if (!IS_DCC_CHAT(dcc)) return; + + printformat(dcc->server, NULL, MSGLEVEL_DCC, + ischannel(*dcc->target) ? IRCTXT_DCC_CHAT_CHANNEL : + IRCTXT_DCC_CHAT, dcc->id, dcc->addrstr, + dcc->port, dcc->target); +} + +static void dcc_connected(CHAT_DCC_REC *dcc) +{ + char *sender; + + if (!IS_DCC_CHAT(dcc)) return; + + sender = g_strconcat("=", dcc->id, NULL); + printformat(dcc->server, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_CHAT_CONNECTED, + dcc->id, dcc->addrstr, dcc->port); + + if (query_find(NULL, sender) == NULL) { + if (!autocreate_dccquery) + completion_last_message_add(sender); + else + irc_query_create(dcc->server == NULL ? NULL : + dcc->server->tag, sender, TRUE); + } + g_free(sender); +} + +static void dcc_closed(CHAT_DCC_REC *dcc) +{ + char *sender; + + if (!IS_DCC_CHAT(dcc)) return; + + sender = g_strconcat("=", dcc->id, NULL); + printformat(dcc->server, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_CHAT_DISCONNECTED, dcc->id); + g_free(sender); +} + +static void dcc_chat_msg(CHAT_DCC_REC *dcc, const char *msg) +{ + QUERY_REC *query; + char *sender, *freemsg; + + g_return_if_fail(IS_DCC_CHAT(dcc)); + g_return_if_fail(msg != NULL); + + sender = g_strconcat("=", dcc->id, NULL); + query = query_find(NULL, sender); + + if (settings_get_bool("emphasis")) + msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg); + else + freemsg = NULL; + + if (query_find(NULL, sender) == NULL) + completion_last_message_add(sender); + printformat(NULL, sender, MSGLEVEL_DCCMSGS, + query != NULL ? IRCTXT_DCC_MSG_QUERY : + IRCTXT_DCC_MSG, dcc->id, msg); + + g_free_not_null(freemsg); + g_free(sender); +} + +static void dcc_chat_action(const char *msg, CHAT_DCC_REC *dcc) +{ + char *sender; + + g_return_if_fail(IS_DCC_CHAT(dcc)); + g_return_if_fail(msg != NULL); + + sender = g_strconcat("=", dcc->id, NULL); + if (query_find(NULL, sender) == NULL) + completion_last_message_add(sender); + printformat(NULL, sender, MSGLEVEL_DCCMSGS, + IRCTXT_ACTION_DCC, dcc->id, msg); + g_free(sender); +} + +static void dcc_chat_ctcp(const char *msg, CHAT_DCC_REC *dcc) +{ + char *sender; + + g_return_if_fail(IS_DCC_CHAT(dcc)); + g_return_if_fail(msg != NULL); + + sender = g_strconcat("=", dcc->id, NULL); + printformat(NULL, sender, MSGLEVEL_DCC, + IRCTXT_DCC_CTCP, dcc->id, msg); + g_free(sender); +} + +static void dcc_error_ctcp(const char *type, const char *data, + const char *nick, const char *addr, + const char *target) +{ + printformat(NULL, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_INVALID_CTCP, type, nick, addr, target); +} + +static void dcc_unknown_ctcp(IRC_SERVER_REC *server, const char *data, + const char *nick, const char *addr, + const char *target, CHAT_DCC_REC *chat) +{ + char *type, *args; + void *free_arg; + + g_return_if_fail(data != NULL); + + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, + &type, &args)) + return; + + printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_UNKNOWN_CTCP, + type, nick, args); + cmd_params_free(free_arg); +} + +static void dcc_unknown_reply(IRC_SERVER_REC *server, const char *data, + const char *nick) +{ + char *type, *args; + void *free_arg; + + g_return_if_fail(data != NULL); + + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, + &type, &args)) + return; + + printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_UNKNOWN_REPLY, + type, nick, args); + cmd_params_free(free_arg); +} + +static void sig_dcc_destroyed(CHAT_DCC_REC *dcc) +{ + QUERY_REC *query; + char *nick; + + if (!IS_DCC_CHAT(dcc)) return; + + nick = g_strconcat("=", dcc->id, NULL); + query = query_find(NULL, nick); + if (query != NULL) { + /* DCC chat closed, close the query with it. */ + if (dcc->connection_lost) query->unwanted = TRUE; + query_destroy(query); + } else { + /* remove nick from msg completion + since it won't work anymore */ + completion_last_message_remove(nick); + } + + g_free(nick); +} + +static void sig_query_destroyed(QUERY_REC *query) +{ + CHAT_DCC_REC *dcc; + + if (*query->name != '=') + return; + + dcc = dcc_chat_find_id(query->name+1); + if (dcc != NULL && !dcc->destroyed) { + /* DCC query window closed, close the dcc chat too. */ + dcc_close(DCC(dcc)); + } +} + +static void dcc_error_close_not_found(const char *type, const char *nick, + const char *fname) +{ + g_return_if_fail(type != NULL); + g_return_if_fail(nick != NULL); + if (g_strcasecmp(type, "GET") != 0) return; + + printformat(NULL, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_CHAT_NOT_FOUND, nick); +} + +static void sig_dcc_list_print(CHAT_DCC_REC *dcc) +{ + if (!IS_DCC_CHAT(dcc)) return; + + printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_LIST_LINE_CHAT, + dcc->id, "CHAT"); +} + +static void cmd_msg(const char *data) +{ + QUERY_REC *query; + CHAT_DCC_REC *dcc; + char *text, *target; + void *free_arg; + + g_return_if_fail(data != NULL); + + if (*data != '=') { + /* handle only DCC messages */ + return; + } + + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, + &target, &text)) + return; + + dcc = dcc_chat_find_id(target+1); + if (dcc == NULL || dcc->sendbuf == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, + IRCTXT_DCC_CHAT_NOT_FOUND, target+1); + } else { + query = query_find(NULL, target); + + printformat(NULL, target, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT, + query != NULL ? IRCTXT_OWN_DCC_QUERY : + IRCTXT_OWN_DCC, dcc->mynick, target+1, text); + if (query == NULL) + completion_last_message_add(target); + } + + cmd_params_free(free_arg); +} + +static void cmd_me(const char *data, SERVER_REC *server, WI_ITEM_REC *item) +{ + CHAT_DCC_REC *dcc; + + g_return_if_fail(data != NULL); + + dcc = item_get_dcc(item); + if (dcc == NULL) return; + + printformat(NULL, item->name, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT, + IRCTXT_OWN_DCC_ACTION_QUERY, dcc->mynick, item->name, data); +} + +static void cmd_action(const char *data, SERVER_REC *server, WI_ITEM_REC *item) +{ + QUERY_REC *query; + CHAT_DCC_REC *dcc; + char *target, *text; + void *free_arg; + + g_return_if_fail(data != NULL); + + if (*data != '=') { + /* handle only DCC actions */ + return; + } + + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, + &target, &text)) + return; + if (*target == '\0' || *text == '\0') + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + + dcc = dcc_chat_find_id(target+1); + if (dcc == NULL || dcc->sendbuf == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, + IRCTXT_DCC_CHAT_NOT_FOUND, target+1); + } else { + query = query_find(NULL, target); + + printformat(NULL, target, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT, + query != NULL ? IRCTXT_OWN_DCC_ACTION_QUERY : + IRCTXT_OWN_DCC_ACTION, dcc->mynick, target, text); + if (query == NULL) + completion_last_message_add(target); + } + cmd_params_free(free_arg); +} + +static void cmd_ctcp(const char *data, SERVER_REC *server) +{ + CHAT_DCC_REC *dcc; + char *target, *ctcpcmd, *ctcpdata; + void *free_arg; + + g_return_if_fail(data != NULL); + if (server == NULL || !server->connected) + cmd_return_error(CMDERR_NOT_CONNECTED); + + if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, + &target, &ctcpcmd, &ctcpdata)) + return; + if (*target == '\0' || *ctcpcmd == '\0') + cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); + + if (*target != '=') { + /* handle only DCC CTCPs */ + cmd_params_free(free_arg); + return; + } + + dcc = dcc_chat_find_id(target+1); + if (dcc == NULL || dcc->sendbuf == NULL) { + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, + IRCTXT_DCC_CHAT_NOT_FOUND, target+1); + } else { + g_strup(ctcpcmd); + printformat(server, target, MSGLEVEL_DCC, IRCTXT_OWN_DCC_CTCP, + target, ctcpcmd, ctcpdata); + } + + cmd_params_free(free_arg); +} + +static void read_settings(void) +{ + int level; + + level = level2bits(settings_get_str("autocreate_query_level")); + autocreate_dccquery = (level & MSGLEVEL_DCCMSGS) != 0; +} + +void fe_dcc_chat_init(void) +{ + read_settings(); + signal_add("dcc request", (SIGNAL_FUNC) dcc_request); + signal_add("dcc connected", (SIGNAL_FUNC) dcc_connected); + signal_add("dcc closed", (SIGNAL_FUNC) dcc_closed); + signal_add("dcc chat message", (SIGNAL_FUNC) dcc_chat_msg); + signal_add("dcc ctcp action", (SIGNAL_FUNC) dcc_chat_action); + signal_add("default dcc ctcp", (SIGNAL_FUNC) dcc_chat_ctcp); + signal_add("dcc error ctcp", (SIGNAL_FUNC) dcc_error_ctcp); + signal_add("default ctcp msg dcc", (SIGNAL_FUNC) dcc_unknown_ctcp); + signal_add("default ctcp reply dcc", (SIGNAL_FUNC) dcc_unknown_reply); + signal_add("dcc destroyed", (SIGNAL_FUNC) sig_dcc_destroyed); + signal_add("query destroyed", (SIGNAL_FUNC) sig_query_destroyed); + signal_add("dcc list print", (SIGNAL_FUNC) sig_dcc_list_print); + command_bind("msg", NULL, (SIGNAL_FUNC) cmd_msg); + command_bind("me", NULL, (SIGNAL_FUNC) cmd_me); + command_bind("action", NULL, (SIGNAL_FUNC) cmd_action); + command_bind("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp); + signal_add("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found); + signal_add("setup changed", (SIGNAL_FUNC) read_settings); +} + +void fe_dcc_chat_deinit(void) +{ + signal_remove("dcc request", (SIGNAL_FUNC) dcc_request); + signal_remove("dcc connected", (SIGNAL_FUNC) dcc_connected); + signal_remove("dcc closed", (SIGNAL_FUNC) dcc_closed); + signal_remove("dcc chat message", (SIGNAL_FUNC) dcc_chat_msg); + signal_remove("dcc ctcp action", (SIGNAL_FUNC) dcc_chat_action); + signal_remove("default dcc ctcp", (SIGNAL_FUNC) dcc_chat_ctcp); + signal_remove("dcc error ctcp", (SIGNAL_FUNC) dcc_error_ctcp); + signal_remove("default ctcp msg dcc", (SIGNAL_FUNC) dcc_unknown_ctcp); + signal_remove("default ctcp reply dcc", (SIGNAL_FUNC) dcc_unknown_reply); + signal_remove("dcc destroyed", (SIGNAL_FUNC) sig_dcc_destroyed); + signal_remove("query destroyed", (SIGNAL_FUNC) sig_query_destroyed); + signal_remove("dcc list print", (SIGNAL_FUNC) sig_dcc_list_print); + command_unbind("msg", (SIGNAL_FUNC) cmd_msg); + command_unbind("me", (SIGNAL_FUNC) cmd_me); + command_unbind("action", (SIGNAL_FUNC) cmd_action); + command_unbind("ctcp", (SIGNAL_FUNC) cmd_ctcp); + signal_remove("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found); + signal_remove("setup changed", (SIGNAL_FUNC) read_settings); +} diff --git a/src/fe-common/irc/dcc/fe-dcc-get.c b/src/fe-common/irc/dcc/fe-dcc-get.c new file mode 100644 index 00000000..b402ee3e --- /dev/null +++ b/src/fe-common/irc/dcc/fe-dcc-get.c @@ -0,0 +1,126 @@ +/* + fe-dcc-get.c : irssi + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "module.h" +#include "signals.h" +#include "levels.h" + +#include "irc.h" +#include "dcc-file.h" +#include "dcc-get.h" + +#include "module-formats.h" +#include "printtext.h" + +#include "fe-dcc.h" + +static void dcc_request(GET_DCC_REC *dcc) +{ + if (!IS_DCC_GET(dcc)) return; + + printformat(dcc->server, NULL, MSGLEVEL_DCC, + ischannel(*dcc->target) ? IRCTXT_DCC_SEND_CHANNEL : + IRCTXT_DCC_SEND, dcc->nick, dcc->addrstr, + dcc->port, dcc->arg, dcc->size, dcc->target); +} + +static void dcc_connected(GET_DCC_REC *dcc) +{ + if (!IS_DCC_GET(dcc)) return; + + printformat(dcc->server, NULL, MSGLEVEL_DCC, IRCTXT_DCC_GET_CONNECTED, + dcc->arg, dcc->nick, dcc->addrstr, dcc->port); +} + +static void dcc_closed(GET_DCC_REC *dcc) +{ + double kbs; + time_t secs; + + if (!IS_DCC_GET(dcc)) return; + + secs = dcc->starttime == 0 ? -1 : time(NULL)-dcc->starttime; + kbs = (double) (dcc->transfd-dcc->skipped) / + (secs == 0 ? 1 : secs) / 1024.0; + + if (secs == -1) { + /* aborted */ + printformat(dcc->server, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_GET_ABORTED, dcc->arg, dcc->nick); + } else { + printformat(dcc->server, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_GET_COMPLETE, dcc->arg, + dcc->transfd/1024, dcc->nick, (long) secs, kbs); + } +} + +static void dcc_error_file_create(GET_DCC_REC *dcc, const char *fname) +{ + printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CANT_CREATE, fname); +} + + +static void dcc_error_get_not_found(const char *nick) +{ + g_return_if_fail(nick != NULL); + + printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_GET_NOT_FOUND, nick); +} + +static void dcc_error_close_not_found(const char *type, const char *nick, + const char *fname) +{ + g_return_if_fail(type != NULL); + g_return_if_fail(nick != NULL); + g_return_if_fail(fname != NULL); + if (g_strcasecmp(type, "GET") != 0) return; + + if (fname == '\0') fname = "(ANY)"; + printformat(NULL, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_GET_NOT_FOUND, nick, fname); +} + +static void sig_dcc_list_print(GET_DCC_REC *dcc) +{ + if (IS_DCC_GET(dcc)) + dcc_list_print_file((FILE_DCC_REC *) dcc); +} + +void fe_dcc_get_init(void) +{ + signal_add("dcc request", (SIGNAL_FUNC) dcc_request); + signal_add("dcc connected", (SIGNAL_FUNC) dcc_connected); + signal_add("dcc closed", (SIGNAL_FUNC) dcc_closed); + signal_add("dcc error file create", (SIGNAL_FUNC) dcc_error_file_create); + signal_add("dcc error get not found", (SIGNAL_FUNC) dcc_error_get_not_found); + signal_add("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found); + signal_add("dcc list print", (SIGNAL_FUNC) sig_dcc_list_print); +} + +void fe_dcc_get_deinit(void) +{ + signal_remove("dcc request", (SIGNAL_FUNC) dcc_request); + signal_remove("dcc connected", (SIGNAL_FUNC) dcc_connected); + signal_remove("dcc closed", (SIGNAL_FUNC) dcc_closed); + signal_remove("dcc error file create", (SIGNAL_FUNC) dcc_error_file_create); + signal_remove("dcc error get not found", (SIGNAL_FUNC) dcc_error_get_not_found); + signal_remove("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found); + signal_remove("dcc list print", (SIGNAL_FUNC) sig_dcc_list_print); +} diff --git a/src/fe-common/irc/dcc/fe-dcc-send.c b/src/fe-common/irc/dcc/fe-dcc-send.c new file mode 100644 index 00000000..715fa80f --- /dev/null +++ b/src/fe-common/irc/dcc/fe-dcc-send.c @@ -0,0 +1,143 @@ +/* + fe-dcc-send.c : irssi + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "module.h" +#include "signals.h" +#include "levels.h" + +#include "dcc-file.h" +#include "dcc-send.h" + +#include "module-formats.h" +#include "printtext.h" +#include "completion.h" + +#include "fe-dcc.h" + +static void dcc_connected(SEND_DCC_REC *dcc) +{ + if (!IS_DCC_SEND(dcc)) return; + + printformat(dcc->server, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_SEND_CONNECTED, + dcc->arg, dcc->nick, dcc->addrstr, dcc->port); +} + +static void dcc_closed(SEND_DCC_REC *dcc) +{ + double kbs; + time_t secs; + + if (!IS_DCC_SEND(dcc)) return; + + secs = dcc->starttime == 0 ? -1 : time(NULL)-dcc->starttime; + kbs = (double) (dcc->transfd-dcc->skipped) / + (secs == 0 ? 1 : secs) / 1024.0; + + if (secs == -1) { + /* aborted */ + printformat(dcc->server, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_SEND_ABORTED, + dcc->arg, dcc->nick); + } else { + printformat(dcc->server, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_SEND_COMPLETE, + dcc->arg, dcc->transfd/1024, dcc->nick, + (long) secs, kbs); + } +} + +static void dcc_error_file_not_found(const char *nick, const char *fname) +{ + g_return_if_fail(nick != NULL); + g_return_if_fail(fname != NULL); + + printformat(NULL, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_SEND_FILE_NOT_FOUND, fname); +} + +static void dcc_error_send_exists(const char *nick, const char *fname) +{ + g_return_if_fail(nick != NULL); + g_return_if_fail(fname != NULL); + + printformat(NULL, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_SEND_EXISTS, fname, nick); +} + +static void dcc_error_close_not_found(const char *type, const char *nick, + const char *fname) +{ + g_return_if_fail(type != NULL); + g_return_if_fail(nick != NULL); + g_return_if_fail(fname != NULL); + if (g_strcasecmp(type, "SEND") != 0) return; + + if (fname == '\0') fname = "(ANY)"; + printformat(NULL, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_SEND_NOT_FOUND, nick, fname); +} + +static void sig_dcc_send_complete(GList **list, WINDOW_REC *window, + const char *word, const char *line, + int *want_space) +{ + g_return_if_fail(list != NULL); + g_return_if_fail(word != NULL); + g_return_if_fail(line != NULL); + + if (*line == '\0' || strchr(line, ' ') != NULL) + return; + + /* completing filename parameter for /DCC SEND */ + *list = filename_complete(word); + if (*list != NULL) { + *want_space = FALSE; + signal_stop(); + } +} + +static void sig_dcc_list_print(SEND_DCC_REC *dcc) +{ + if (IS_DCC_SEND(dcc)) + dcc_list_print_file((FILE_DCC_REC *) dcc); +} + +void fe_dcc_send_init(void) +{ + signal_add("dcc connected", (SIGNAL_FUNC) dcc_connected); + signal_add("dcc closed", (SIGNAL_FUNC) dcc_closed); + signal_add("dcc error file not found", (SIGNAL_FUNC) dcc_error_file_not_found); + signal_add("dcc error send exists", (SIGNAL_FUNC) dcc_error_send_exists); + signal_add("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found); + signal_add("complete command dcc send", (SIGNAL_FUNC) sig_dcc_send_complete); + signal_add("dcc list print", (SIGNAL_FUNC) sig_dcc_list_print); +} + +void fe_dcc_send_deinit(void) +{ + signal_remove("dcc connected", (SIGNAL_FUNC) dcc_connected); + signal_remove("dcc closed", (SIGNAL_FUNC) dcc_closed); + signal_remove("dcc error file not found", (SIGNAL_FUNC) dcc_error_file_not_found); + signal_remove("dcc error send exists", (SIGNAL_FUNC) dcc_error_send_exists); + signal_remove("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found); + signal_remove("complete command dcc send", (SIGNAL_FUNC) sig_dcc_send_complete); + signal_remove("dcc list print", (SIGNAL_FUNC) sig_dcc_list_print); +} diff --git a/src/fe-common/irc/dcc/fe-dcc.c b/src/fe-common/irc/dcc/fe-dcc.c index 4301715a..c347b48a 100644 --- a/src/fe-common/irc/dcc/fe-dcc.c +++ b/src/fe-common/irc/dcc/fe-dcc.c @@ -1,7 +1,7 @@ /* fe-dcc.c : irssi - Copyright (C) 1999-2000 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 @@ -22,192 +22,35 @@ #include "signals.h" #include "commands.h" #include "network.h" -#include "settings.h" - #include "levels.h" -#include "irc.h" -#include "channels.h" -#include "irc-queries.h" - -#include "irc/dcc/dcc-chat.h" -#include "completion.h" -#include "chat-completion.h" -#include "themes.h" -#include "fe-windows.h" +#include "dcc-chat.h" +#include "dcc-file.h" +#include "dcc-get.h" +#include "dcc-send.h" #include "module-formats.h" #include "printtext.h" -#include "fe-messages.h" - -static int autocreate_dccquery; - -static void dcc_connected(DCC_REC *dcc) -{ - char *sender; - - g_return_if_fail(dcc != NULL); - - switch (dcc->type) { - case DCC_TYPE_CHAT: - sender = g_strconcat("=", dcc->chat_id, NULL); - printformat(dcc->server, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_CHAT_CONNECTED, - dcc->chat_id, dcc->addrstr, dcc->port); - if (query_find(NULL, sender) == NULL) { - if (!autocreate_dccquery) - completion_last_message_add(sender); - else - irc_query_create(dcc->server == NULL ? NULL : - dcc->server->tag, - sender, TRUE); - } - g_free(sender); - break; - case DCC_TYPE_SEND: - printformat(dcc->server, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_SEND_CONNECTED, - dcc->arg, dcc->nick, dcc->addrstr, dcc->port); - break; - case DCC_TYPE_GET: - printformat(dcc->server, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_GET_CONNECTED, - dcc->arg, dcc->nick, dcc->addrstr, dcc->port); - break; - } -} - -static void dcc_rejected(DCC_REC *dcc) -{ - g_return_if_fail(dcc != NULL); - - printformat(dcc->server, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CLOSE, - dcc_type2str(dcc->type), dcc->nick, dcc->arg); -} - -static void dcc_closed(DCC_REC *dcc) -{ - char *sender; - double kbs; - time_t secs; - - g_return_if_fail(dcc != NULL); - - secs = dcc->starttime == 0 ? -1 : time(NULL)-dcc->starttime; - kbs = (double) (dcc->transfd-dcc->skipped) / - (secs == 0 ? 1 : secs) / 1024.0; - - switch (dcc->type) { - case DCC_TYPE_CHAT: - sender = g_strconcat("=", dcc->chat_id, NULL); - printformat(dcc->server, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_CHAT_DISCONNECTED, dcc->chat_id); - g_free(sender); - break; - case DCC_TYPE_SEND: - if (secs == -1) { - /* aborted */ - printformat(dcc->server, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_SEND_ABORTED, - dcc->arg, dcc->nick); - } else { - printformat(dcc->server, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_SEND_COMPLETE, - dcc->arg, dcc->transfd/1024, dcc->nick, - (long) secs, kbs); - } - break; - case DCC_TYPE_GET: - if (secs == -1) { - /* aborted */ - printformat(dcc->server, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_GET_ABORTED, - dcc->arg, dcc->nick); - } else { - printformat(dcc->server, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_GET_COMPLETE, - dcc->arg, dcc->transfd/1024, dcc->nick, - (long) secs, kbs); - } - break; - } -} - -static void dcc_chat_action(const char *msg, DCC_REC *dcc) -{ - char *sender; - - g_return_if_fail(dcc != NULL); - g_return_if_fail(msg != NULL); - - sender = g_strconcat("=", dcc->chat_id, NULL); - if (query_find(NULL, sender) == NULL) - completion_last_message_add(sender); - printformat(NULL, sender, MSGLEVEL_DCCMSGS, - IRCTXT_ACTION_DCC, dcc->chat_id, msg); - g_free(sender); -} - -static void dcc_chat_ctcp(const char *msg, DCC_REC *dcc) -{ - char *sender; - - g_return_if_fail(dcc != NULL); - g_return_if_fail(msg != NULL); - - sender = g_strconcat("=", dcc->chat_id, NULL); - printformat(NULL, sender, MSGLEVEL_DCC, - IRCTXT_DCC_CTCP, dcc->chat_id, msg); - g_free(sender); -} - -static void dcc_chat_msg(DCC_REC *dcc, const char *msg) -{ - QUERY_REC *query; - char *sender, *freemsg; - - g_return_if_fail(dcc != NULL); - g_return_if_fail(msg != NULL); - - sender = g_strconcat("=", dcc->chat_id, NULL); - query = query_find(NULL, sender); +#include "themes.h" - if (settings_get_bool("emphasis")) - msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg); - else - freemsg = NULL; +void fe_dcc_chat_init(void); +void fe_dcc_chat_deinit(void); - if (query_find(NULL, sender) == NULL) - completion_last_message_add(sender); - printformat(NULL, sender, MSGLEVEL_DCCMSGS, - query != NULL ? IRCTXT_DCC_MSG_QUERY : - IRCTXT_DCC_MSG, dcc->chat_id, msg); +void fe_dcc_get_init(void); +void fe_dcc_get_deinit(void); - g_free_not_null(freemsg); - g_free(sender); -} +void fe_dcc_send_init(void); +void fe_dcc_send_deinit(void); static void dcc_request(DCC_REC *dcc) { - g_return_if_fail(dcc != NULL); + char *service; - switch (dcc->type) { - case DCC_TYPE_CHAT: - printformat(dcc->server, NULL, MSGLEVEL_DCC, - ischannel(*dcc->target) ? IRCTXT_DCC_CHAT_CHANNEL : - IRCTXT_DCC_CHAT, dcc->chat_id, dcc->addrstr, - dcc->port, dcc->target); - break; - case DCC_TYPE_GET: - printformat(dcc->server, NULL, MSGLEVEL_DCC, - ischannel(*dcc->target) ? IRCTXT_DCC_SEND_CHANNEL : - IRCTXT_DCC_SEND, dcc->nick, dcc->addrstr, - dcc->port, dcc->arg, dcc->size, dcc->target); - break; - } + g_return_if_fail(dcc != NULL); if (dcc->port < 1024) { - char *service = net_getservbyport(dcc->port); + /* warn about connecting to lowports */ + service = net_getservbyport(dcc->port); printformat(dcc->server, NULL, MSGLEVEL_DCC, IRCTXT_DCC_LOWPORT, dcc->port, @@ -215,44 +58,20 @@ static void dcc_request(DCC_REC *dcc) } } -static void dcc_error_connect(DCC_REC *dcc) +static void dcc_rejected(DCC_REC *dcc) { g_return_if_fail(dcc != NULL); - printformat(dcc->server, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_CONNECT_ERROR, dcc->addrstr, dcc->port); + printformat(dcc->server, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CLOSE, + dcc_type2str(dcc->type), dcc->nick, dcc->arg); } -static void dcc_error_file_create(DCC_REC *dcc, const char *fname) +static void dcc_error_connect(DCC_REC *dcc) { g_return_if_fail(dcc != NULL); - printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_CANT_CREATE, fname); -} - -static void dcc_error_file_not_found(const char *nick, const char *fname) -{ - g_return_if_fail(nick != NULL); - g_return_if_fail(fname != NULL); - - printformat(NULL, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_SEND_FILE_NOT_FOUND, fname); -} - -static void dcc_error_get_not_found(const char *nick) -{ - g_return_if_fail(nick != NULL); - - printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_GET_NOT_FOUND, nick); -} - -static void dcc_error_send_exists(const char *nick, const char *fname) -{ - g_return_if_fail(nick != NULL); - g_return_if_fail(fname != NULL); - - printformat(NULL, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_SEND_EXISTS, fname, nick); + printformat(dcc->server, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_CONNECT_ERROR, dcc->addrstr, dcc->port); } static void dcc_error_unknown_type(const char *type) @@ -262,258 +81,30 @@ static void dcc_error_unknown_type(const char *type) printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_UNKNOWN_TYPE, type); } -static void dcc_error_close_not_found(const char *type, const char *nick, - const char *fname) -{ - g_return_if_fail(type != NULL); - g_return_if_fail(nick != NULL); - g_return_if_fail(fname != NULL); - - if (fname == '\0') fname = "(ANY)"; - switch (dcc_str2type(type)) { - case DCC_TYPE_CHAT: - printformat(NULL, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_CHAT_NOT_FOUND, nick); - break; - case DCC_TYPE_SEND: - printformat(NULL, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_SEND_NOT_FOUND, nick, fname); - break; - case DCC_TYPE_GET: - printformat(NULL, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_GET_NOT_FOUND, nick, fname); - break; - } -} - -static void dcc_error_ctcp(const char *type, const char *data, - const char *nick, const char *addr, - const char *target) -{ - printformat(NULL, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_INVALID_CTCP, type, nick, addr, target); -} - -static void dcc_unknown_ctcp(IRC_SERVER_REC *server, const char *data, - const char *nick, const char *addr, - const char *target, DCC_REC *chat) +void dcc_list_print_file(FILE_DCC_REC *dcc) { - char *type, *args; - void *free_arg; - - g_return_if_fail(data != NULL); - - if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, - &type, &args)) - return; - - printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_UNKNOWN_CTCP, - type, nick, args); - cmd_params_free(free_arg); -} - -static void dcc_unknown_reply(IRC_SERVER_REC *server, const char *data, - const char *nick) -{ - char *type, *args; - void *free_arg; - - g_return_if_fail(data != NULL); - - if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, - &type, &args)) - return; - - printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_UNKNOWN_REPLY, - type, nick, args); - cmd_params_free(free_arg); -} - -static void sig_dcc_destroyed(DCC_REC *dcc) -{ - QUERY_REC *query; - char *nick; - - if (dcc->type != DCC_TYPE_CHAT) - return; - - nick = g_strconcat("=", dcc->chat_id, NULL); - - query = query_find(NULL, nick); - if (query != NULL) { - /* DCC chat closed, close the query with it. */ - if (dcc->connection_lost) query->unwanted = TRUE; - query_destroy(query); - } else { - /* remove nick from msg completion - since it won't work anymore */ - completion_last_message_remove(nick); - } - - g_free(nick); -} - -static void sig_query_destroyed(QUERY_REC *query) -{ - DCC_REC *dcc; - - if (*query->name != '=') - return; - - dcc = dcc_chat_find_id(query->name+1); - if (dcc != NULL && !dcc->destroyed) { - /* DCC query window closed, close the dcc chat too. */ - signal_emit("dcc closed", 1, dcc); - dcc_destroy(dcc); - } -} - -static void cmd_msg(const char *data) -{ - QUERY_REC *query; - DCC_REC *dcc; - char *text, *target; - void *free_arg; - - g_return_if_fail(data != NULL); - - if (*data != '=') { - /* handle only DCC messages */ - return; - } - - if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, - &target, &text)) - return; - - dcc = dcc_chat_find_id(target+1); - if (dcc == NULL || dcc->sendbuf == NULL) { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, - IRCTXT_DCC_CHAT_NOT_FOUND, target+1); - } else { - query = query_find(NULL, target); - - printformat(NULL, target, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT, - query != NULL ? IRCTXT_OWN_DCC_QUERY : - IRCTXT_OWN_DCC, dcc->mynick, target+1, text); - if (query == NULL) - completion_last_message_add(target); - } - - cmd_params_free(free_arg); -} - -static void cmd_me(const char *data, SERVER_REC *server, WI_ITEM_REC *item) -{ - DCC_REC *dcc; - - g_return_if_fail(data != NULL); - - dcc = item_get_dcc(item); - if (dcc == NULL) return; - - printformat(NULL, item->name, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT, - IRCTXT_OWN_DCC_ACTION_QUERY, dcc->mynick, item->name, data); -} - -static void cmd_action(const char *data, SERVER_REC *server, WI_ITEM_REC *item) -{ - QUERY_REC *query; - DCC_REC *dcc; - char *target, *text; - void *free_arg; - - g_return_if_fail(data != NULL); - - if (*data != '=') { - /* handle only DCC actions */ - return; - } - - if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, - &target, &text)) - return; - if (*target == '\0' || *text == '\0') - cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - - dcc = dcc_chat_find_id(target+1); - if (dcc == NULL || dcc->sendbuf == NULL) { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, - IRCTXT_DCC_CHAT_NOT_FOUND, target+1); - } else { - query = query_find(NULL, target); - - printformat(NULL, target, MSGLEVEL_DCCMSGS | MSGLEVEL_NOHILIGHT, - query != NULL ? IRCTXT_OWN_DCC_ACTION_QUERY : - IRCTXT_OWN_DCC_ACTION, dcc->mynick, target, text); - if (query == NULL) - completion_last_message_add(target); - } - cmd_params_free(free_arg); -} - -static void cmd_ctcp(const char *data, SERVER_REC *server) -{ - DCC_REC *dcc; - char *target, *ctcpcmd, *ctcpdata; - void *free_arg; - - g_return_if_fail(data != NULL); - if (server == NULL || !server->connected) - cmd_return_error(CMDERR_NOT_CONNECTED); - - if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST, - &target, &ctcpcmd, &ctcpdata)) - return; - if (*target == '\0' || *ctcpcmd == '\0') - cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - - if (*target != '=') { - /* handle only DCC CTCPs */ - cmd_params_free(free_arg); - return; - } + time_t going; - dcc = dcc_chat_find_id(target+1); - if (dcc == NULL || dcc->sendbuf == NULL) { - printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, - IRCTXT_DCC_CHAT_NOT_FOUND, target+1); - } else { - g_strup(ctcpcmd); - printformat(server, target, MSGLEVEL_DCC, IRCTXT_OWN_DCC_CTCP, - target, ctcpcmd, ctcpdata); - } + going = time(NULL) - dcc->starttime; + if (going == 0) going = 1; /* no division by zeros :) */ - cmd_params_free(free_arg); + printformat(NULL, NULL, MSGLEVEL_DCC, + IRCTXT_DCC_LIST_LINE_FILE, + dcc->nick, dcc_type2str(dcc->type), + dcc->transfd/1024, dcc->size/1024, + dcc->size == 0 ? 0 : (int)((double)dcc->transfd/(double)dcc->size*100.0), + (double) (dcc->transfd-dcc->skipped)/going/1024, dcc->arg); } static void cmd_dcc_list(const char *data) { GSList *tmp; - time_t going; g_return_if_fail(data != NULL); printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_LIST_HEADER); - for (tmp = dcc_conns; tmp != NULL; tmp = tmp->next) { - DCC_REC *dcc = tmp->data; - - going = time(NULL) - dcc->starttime; - if (going == 0) going = 1; /* no division by zeros :) */ - - if (dcc->type == DCC_TYPE_CHAT) { - printformat(NULL, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_LIST_LINE_CHAT, - dcc->chat_id, dcc_type2str(dcc->type)); - } else { - printformat(NULL, NULL, MSGLEVEL_DCC, - IRCTXT_DCC_LIST_LINE_FILE, - dcc->nick, dcc_type2str(dcc->type), - dcc->transfd/1024, dcc->size/1024, - dcc->size == 0 ? 0 : (int)((double)dcc->transfd/(double)dcc->size*100.0), - (double) (dcc->transfd-dcc->skipped)/going/1024, dcc->arg); - } - } + for (tmp = dcc_conns; tmp != NULL; tmp = tmp->next) + signal_emit("dcc list print", 1, tmp->data); printformat(NULL, NULL, MSGLEVEL_DCC, IRCTXT_DCC_LIST_FOOTER); } @@ -525,96 +116,34 @@ static void cmd_dcc(const char *data) } } -static void sig_dcc_send_complete(GList **list, WINDOW_REC *window, - const char *word, const char *line, - int *want_space) -{ - g_return_if_fail(list != NULL); - g_return_if_fail(word != NULL); - g_return_if_fail(line != NULL); - - if (*line == '\0' || strchr(line, ' ') != NULL) - return; - - /* completing filename parameter for /DCC SEND */ - *list = filename_complete(word); - if (*list != NULL) { - *want_space = FALSE; - signal_stop(); - } -} - -static void read_settings(void) -{ - int level; - - level = level2bits(settings_get_str("autocreate_query_level")); - autocreate_dccquery = (level & MSGLEVEL_DCCMSGS) != 0; -} - void fe_irc_dcc_init(void) { - signal_add("dcc connected", (SIGNAL_FUNC) dcc_connected); - signal_add("dcc rejected", (SIGNAL_FUNC) dcc_rejected); - signal_add("dcc closed", (SIGNAL_FUNC) dcc_closed); - signal_add("dcc chat message", (SIGNAL_FUNC) dcc_chat_msg); - signal_add("dcc ctcp action", (SIGNAL_FUNC) dcc_chat_action); - signal_add("default dcc ctcp", (SIGNAL_FUNC) dcc_chat_ctcp); + fe_dcc_chat_init(); + fe_dcc_get_init(); + fe_dcc_send_init(); + signal_add("dcc request", (SIGNAL_FUNC) dcc_request); + signal_add("dcc rejected", (SIGNAL_FUNC) dcc_rejected); signal_add("dcc error connect", (SIGNAL_FUNC) dcc_error_connect); - signal_add("dcc error file create", (SIGNAL_FUNC) dcc_error_file_create); - signal_add("dcc error file not found", (SIGNAL_FUNC) dcc_error_file_not_found); - signal_add("dcc error get not found", (SIGNAL_FUNC) dcc_error_get_not_found); - signal_add("dcc error send exists", (SIGNAL_FUNC) dcc_error_send_exists); signal_add("dcc error unknown type", (SIGNAL_FUNC) dcc_error_unknown_type); - signal_add("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found); - signal_add("dcc error ctcp", (SIGNAL_FUNC) dcc_error_ctcp); - signal_add("default ctcp msg dcc", (SIGNAL_FUNC) dcc_unknown_ctcp); - signal_add("default ctcp reply dcc", (SIGNAL_FUNC) dcc_unknown_reply); - signal_add("dcc destroyed", (SIGNAL_FUNC) sig_dcc_destroyed); - signal_add("query destroyed", (SIGNAL_FUNC) sig_query_destroyed); - signal_add("complete command dcc send", (SIGNAL_FUNC) sig_dcc_send_complete); - signal_add("setup changed", (SIGNAL_FUNC) read_settings); - command_bind("msg", NULL, (SIGNAL_FUNC) cmd_msg); - command_bind("me", NULL, (SIGNAL_FUNC) cmd_me); - command_bind("action", NULL, (SIGNAL_FUNC) cmd_action); - command_bind("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp); command_bind("dcc", NULL, (SIGNAL_FUNC) cmd_dcc); command_bind("dcc list", NULL, (SIGNAL_FUNC) cmd_dcc_list); theme_register(fecommon_irc_dcc_formats); - read_settings(); } void fe_irc_dcc_deinit(void) { + fe_dcc_chat_deinit(); + fe_dcc_get_deinit(); + fe_dcc_send_deinit(); + theme_unregister(); - signal_remove("dcc connected", (SIGNAL_FUNC) dcc_connected); - signal_remove("dcc rejected", (SIGNAL_FUNC) dcc_rejected); - signal_remove("dcc closed", (SIGNAL_FUNC) dcc_closed); - signal_remove("dcc chat message", (SIGNAL_FUNC) dcc_chat_msg); - signal_remove("dcc ctcp action", (SIGNAL_FUNC) dcc_chat_action); - signal_remove("default dcc ctcp", (SIGNAL_FUNC) dcc_chat_ctcp); signal_remove("dcc request", (SIGNAL_FUNC) dcc_request); + signal_remove("dcc rejected", (SIGNAL_FUNC) dcc_rejected); signal_remove("dcc error connect", (SIGNAL_FUNC) dcc_error_connect); - signal_remove("dcc error file create", (SIGNAL_FUNC) dcc_error_file_create); - signal_remove("dcc error file not found", (SIGNAL_FUNC) dcc_error_file_not_found); - signal_remove("dcc error get not found", (SIGNAL_FUNC) dcc_error_get_not_found); - signal_remove("dcc error send exists", (SIGNAL_FUNC) dcc_error_send_exists); signal_remove("dcc error unknown type", (SIGNAL_FUNC) dcc_error_unknown_type); - signal_remove("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found); - signal_remove("dcc error ctcp", (SIGNAL_FUNC) dcc_error_ctcp); - signal_remove("default ctcp msg dcc", (SIGNAL_FUNC) dcc_unknown_ctcp); - signal_remove("default ctcp reply dcc", (SIGNAL_FUNC) dcc_unknown_reply); - signal_remove("dcc destroyed", (SIGNAL_FUNC) sig_dcc_destroyed); - signal_remove("query destroyed", (SIGNAL_FUNC) sig_query_destroyed); - signal_remove("complete command dcc send", (SIGNAL_FUNC) sig_dcc_send_complete); - signal_remove("setup changed", (SIGNAL_FUNC) read_settings); - command_unbind("msg", (SIGNAL_FUNC) cmd_msg); - command_unbind("me", (SIGNAL_FUNC) cmd_me); - command_unbind("action", (SIGNAL_FUNC) cmd_action); - command_unbind("ctcp", (SIGNAL_FUNC) cmd_ctcp); command_unbind("dcc", (SIGNAL_FUNC) cmd_dcc); command_unbind("dcc list", (SIGNAL_FUNC) cmd_dcc_list); } diff --git a/src/fe-common/irc/dcc/fe-dcc.h b/src/fe-common/irc/dcc/fe-dcc.h new file mode 100644 index 00000000..728efe27 --- /dev/null +++ b/src/fe-common/irc/dcc/fe-dcc.h @@ -0,0 +1,6 @@ +#ifndef __FE_DCC_H +#define __FE_DCC_H + +void dcc_list_print_file(FILE_DCC_REC *dcc); + +#endif |