diff options
Diffstat (limited to 'src/irc/core/irc-servers.c')
-rw-r--r-- | src/irc/core/irc-servers.c | 50 |
1 files changed, 16 insertions, 34 deletions
diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index f905a862..3117e345 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -214,7 +214,6 @@ static void server_init(IRC_SERVER_REC *server) { IRC_SERVER_CONNECT_REC *conn; char *address, *ptr, *username, *cmd; - GTimeVal now; g_return_if_fail(server != NULL); @@ -289,9 +288,8 @@ static void server_init(IRC_SERVER_REC *server) /* prevent the queue from sending too early, we have a max cut off of 120 secs */ /* this will reset to 1 sec after we get the 001 event */ - g_get_current_time(&now); - memcpy(&((IRC_SERVER_REC *)server)->wait_cmd, &now, sizeof(GTimeVal)); - ((IRC_SERVER_REC *)server)->wait_cmd.tv_sec += 120; + g_get_current_time(&server->wait_cmd); + g_time_val_add(&server->wait_cmd, 120 * G_USEC_PER_SEC); } SERVER_REC *irc_server_init_connect(SERVER_CONNECT_REC *conn) @@ -312,7 +310,7 @@ SERVER_REC *irc_server_init_connect(SERVER_CONNECT_REC *conn) if (server->connrec->port <= 0) { server->connrec->port = - server->connrec->use_ssl ? 6697 : 6667; + server->connrec->use_tls ? 6697 : 6667; } server->cmd_queue_speed = ircconn->cmd_queue_speed > 0 ? @@ -330,7 +328,7 @@ SERVER_REC *irc_server_init_connect(SERVER_CONNECT_REC *conn) ircconn->max_whois : DEFAULT_MAX_WHOIS; server->max_msgs_in_cmd = ircconn->max_msgs > 0 ? ircconn->max_msgs : DEFAULT_MAX_MSGS; - server->connrec->use_ssl = conn->use_ssl; + server->connrec->use_tls = conn->use_tls; modes_server_init(server); @@ -448,6 +446,8 @@ static void sig_disconnected(IRC_SERVER_REC *server) gslist_free_full(server->cap_queue, (GDestroyNotify) g_free); server->cap_queue = NULL; + g_free_and_null(server->sasl_buffer); + /* these are dynamically allocated only if isupport was sent */ g_hash_table_foreach(server->isupport, (GHFunc) isupport_destroy_hash, server); @@ -537,7 +537,7 @@ void irc_server_send_data(IRC_SERVER_REC *server, const char *data, int len) server->wait_cmd.tv_sec = 0; else { memcpy(&server->wait_cmd, &server->last_cmd, sizeof(GTimeVal)); - server->wait_cmd.tv_sec += 2 + len/100; + g_time_val_add(&server->wait_cmd, (2 + len/100) * G_USEC_PER_SEC); } } @@ -625,39 +625,25 @@ char *irc_server_get_channels(IRC_SERVER_REC *server) GString *chans, *keys; char *ret; int use_keys; - char *rejoin_channels_mode; + int rejoin_channels_mode; g_return_val_if_fail(server != NULL, FALSE); - rejoin_channels_mode = g_strdup(settings_get_str("rejoin_channels_on_reconnect")); + rejoin_channels_mode = settings_get_choice("rejoin_channels_on_reconnect"); - if (rejoin_channels_mode == NULL || - (g_ascii_strcasecmp(rejoin_channels_mode, "on") != 0 && - g_ascii_strcasecmp(rejoin_channels_mode, "off") != 0 && - g_ascii_strcasecmp(rejoin_channels_mode, "auto") != 0)) { - g_warning("Invalid value for 'rejoin_channels_on_reconnect', valid values are 'on', 'off', 'auto', using 'on' as default value."); - g_free(rejoin_channels_mode); - rejoin_channels_mode = g_strdup("on"); - } + /* do we want to rejoin channels in the first place? */ + if(rejoin_channels_mode == 0) + return g_strdup(""); chans = g_string_new(NULL); keys = g_string_new(NULL); use_keys = FALSE; - /* do we want to rejoin channels in the first place? */ - if(g_ascii_strcasecmp(rejoin_channels_mode, "off") == 0) { - g_string_free(chans, TRUE); - g_string_free(keys, TRUE); - g_free(rejoin_channels_mode); - return g_strdup(""); - } - /* get currently joined channels */ for (tmp = server->channels; tmp != NULL; tmp = tmp->next) { CHANNEL_REC *channel = tmp->data; CHANNEL_SETUP_REC *setup = channel_setup_find(channel->name, channel->server->connrec->chatnet); - if ((setup != NULL && setup->autojoin && g_ascii_strcasecmp(rejoin_channels_mode, "auto") == 0) || - g_ascii_strcasecmp(rejoin_channels_mode, "on") == 0) { + if ((setup != NULL && setup->autojoin && rejoin_channels_mode == 2) || rejoin_channels_mode == 1) { g_string_append_printf(chans, "%s,", channel->name); g_string_append_printf(keys, "%s,", channel->key == NULL ? "x" : channel->key); if (channel->key != NULL) @@ -670,8 +656,7 @@ char *irc_server_get_channels(IRC_SERVER_REC *server) REJOIN_REC *rec = tmp->data; CHANNEL_SETUP_REC *setup = channel_setup_find(rec->channel, server->tag); - if ((setup != NULL && setup->autojoin && g_ascii_strcasecmp(rejoin_channels_mode, "auto") == 0) || - g_ascii_strcasecmp(rejoin_channels_mode, "on") == 0) { + if ((setup != NULL && setup->autojoin && rejoin_channels_mode == 2) || rejoin_channels_mode == 1) { g_string_append_printf(chans, "%s,", rec->channel); g_string_append_printf(keys, "%s,", rec->key == NULL ? "x" : rec->key); @@ -689,7 +674,6 @@ char *irc_server_get_channels(IRC_SERVER_REC *server) ret = chans->str; g_string_free(chans, FALSE); g_string_free(keys, TRUE); - g_free(rejoin_channels_mode); return ret; } @@ -697,7 +681,6 @@ char *irc_server_get_channels(IRC_SERVER_REC *server) static void event_connected(IRC_SERVER_REC *server, const char *data, const char *from) { char *params, *nick; - GTimeVal now; g_return_if_fail(server != NULL); @@ -720,8 +703,7 @@ static void event_connected(IRC_SERVER_REC *server, const char *data, const char server->real_connect_time = time(NULL); /* let the queue send now that we are identified */ - g_get_current_time(&now); - memcpy(&server->wait_cmd, &now, sizeof(GTimeVal)); + g_get_current_time(&server->wait_cmd); if (server->connrec->usermode != NULL) { /* Send the user mode, before the autosendcmd. @@ -1035,7 +1017,7 @@ void irc_server_init_isupport(IRC_SERVER_REC *server) void irc_servers_init(void) { - settings_add_str("servers", "rejoin_channels_on_reconnect", "on"); + settings_add_choice("servers", "rejoin_channels_on_reconnect", 1, "off;on;auto"); settings_add_str("misc", "usermode", DEFAULT_USER_MODE); settings_add_str("misc", "split_line_start", ""); settings_add_str("misc", "split_line_end", ""); |