From ba80576b1eeae5c0ca2c4ac3f7ea7542b7829dee Mon Sep 17 00:00:00 2001 From: Emanuele Giaquinta Date: Mon, 19 May 2008 21:55:04 +0000 Subject: [PATCH] Remove some global variables used to store settings values, instead get the values when needed. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4836 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/irc/dcc/fe-dcc-chat.c | 16 +++------------- src/irc/dcc/dcc-get.c | 13 ++----------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/fe-common/irc/dcc/fe-dcc-chat.c b/src/fe-common/irc/dcc/fe-dcc-chat.c index 5621580f..f8c2d8c3 100644 --- a/src/fe-common/irc/dcc/fe-dcc-chat.c +++ b/src/fe-common/irc/dcc/fe-dcc-chat.c @@ -38,8 +38,6 @@ void fe_dcc_chat_messages_init(void); void fe_dcc_chat_messages_deinit(void); -static int autocreate_dccquery; - static void dcc_request(CHAT_DCC_REC *dcc) { if (!IS_DCC_CHAT(dcc)) return; @@ -62,6 +60,9 @@ static void dcc_connected(CHAT_DCC_REC *dcc) dcc->id, dcc->addrstr, dcc->port); if (query_find(NULL, sender) == NULL) { + int level = settings_get_level("autocreate_query_level"); + int autocreate_dccquery = (level & MSGLEVEL_DCCMSGS) != 0; + if (!autocreate_dccquery) completion_last_message_add(sender); else @@ -336,17 +337,8 @@ static void cmd_ctcp(const char *data, SERVER_REC *server) cmd_params_free(free_arg); } -static void read_settings(void) -{ - int level; - - level = settings_get_level("autocreate_query_level"); - autocreate_dccquery = (level & MSGLEVEL_DCCMSGS) != 0; -} - void fe_dcc_chat_init(void) { - read_settings(); fe_dcc_chat_messages_init(); signal_add("dcc request", (SIGNAL_FUNC) dcc_request); @@ -366,7 +358,6 @@ void fe_dcc_chat_init(void) 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) @@ -390,5 +381,4 @@ void fe_dcc_chat_deinit(void) 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/irc/dcc/dcc-get.c b/src/irc/dcc/dcc-get.c index e8e67731..87d4cfb6 100644 --- a/src/irc/dcc/dcc-get.c +++ b/src/irc/dcc/dcc-get.c @@ -30,8 +30,6 @@ #include "dcc-get.h" #include "dcc-send.h" -static int dcc_file_create_mode; - GET_DCC_REC *dcc_get_create(IRC_SERVER_REC *server, CHAT_DCC_REC *chat, const char *nick, const char *arg) { @@ -206,6 +204,8 @@ void sig_dccget_connected(GET_DCC_REC *dcc) } if (dcc->get_type != DCC_GET_RESUME) { + int dcc_file_create_mode = octal2dec(settings_get_int("dcc_file_create_mode")); + /* we want to overwrite the file, remove it here. if it gets created after this, we'll fail. */ unlink(dcc->file); @@ -572,12 +572,6 @@ static void cmd_dcc_get(const char *data) cmd_dcc_receive(data, dcc_get_connect, dcc_get_passive); } -static void read_settings(void) -{ - dcc_file_create_mode = - octal2dec(settings_get_int("dcc_file_create_mode")); -} - void dcc_get_init(void) { dcc_register_type("GET"); @@ -585,10 +579,8 @@ void dcc_get_init(void) settings_add_str("dcc", "dcc_download_path", "~"); settings_add_int("dcc", "dcc_file_create_mode", 644); - read_settings(); signal_add("dcc destroyed", (SIGNAL_FUNC) sig_dcc_destroyed); signal_add("ctcp msg dcc send", (SIGNAL_FUNC) ctcp_msg_dcc_send); - signal_add("setup changed", (SIGNAL_FUNC) read_settings); command_bind("dcc get", NULL, (SIGNAL_FUNC) cmd_dcc_get); } @@ -597,6 +589,5 @@ void dcc_get_deinit(void) dcc_unregister_type("GET"); signal_remove("dcc destroyed", (SIGNAL_FUNC) sig_dcc_destroyed); signal_remove("ctcp msg dcc send", (SIGNAL_FUNC) ctcp_msg_dcc_send); - signal_remove("setup changed", (SIGNAL_FUNC) read_settings); command_unbind("dcc get", (SIGNAL_FUNC) cmd_dcc_get); }