From 6d77cdc8b70bc6ac322f06db075b36f36b0639cf Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 14 Jun 2000 17:50:16 +0000 Subject: [PATCH] Read new server specific settings when reconnecting to new server. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@338 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/core/server-reconnect.c | 23 +++++++---------------- src/irc/core/server-setup.c | 30 +++++++++++++++++++----------- src/irc/core/server-setup.h | 3 +++ 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/irc/core/server-reconnect.c b/src/irc/core/server-reconnect.c index ea947133..832d55cd 100644 --- a/src/irc/core/server-reconnect.c +++ b/src/irc/core/server-reconnect.c @@ -86,11 +86,8 @@ static void sserver_connect(SETUP_SERVER_REC *rec, IRC_SERVER_CONNECT_REC *conn) { conn->address = g_strdup(rec->address); conn->port = rec->port; - conn->password = rec->password == NULL ? NULL : - g_strdup(rec->password); - if (rec->cmd_queue_speed > 0) - conn->cmd_queue_speed = rec->cmd_queue_speed; + server_setup_fill_conn(conn, rec); if (rec->last_connect > time(NULL)-reconnect_time) { /* can't reconnect this fast, wait.. */ server_reconnect_add(conn, rec->last_connect+reconnect_time); @@ -102,20 +99,14 @@ static void sserver_connect(SETUP_SERVER_REC *rec, IRC_SERVER_CONNECT_REC *conn) static void server_connect_copy_skeleton(IRC_SERVER_CONNECT_REC *dest, IRC_SERVER_CONNECT_REC *src) { - dest->proxy = src->proxy == NULL ? NULL : - g_strdup(src->proxy); + dest->proxy = g_strdup(src->proxy); dest->proxy_port = src->proxy_port; - dest->proxy_string = src->proxy_string == NULL ? NULL : - g_strdup(src->proxy_string); + dest->proxy_string = g_strdup(src->proxy_string); - dest->ircnet = src->ircnet == NULL ? NULL : - g_strdup(src->ircnet); - dest->nick = src->nick == NULL ? NULL : - g_strdup(src->nick); - dest->username = src->username == NULL ? NULL : - g_strdup(src->username); - dest->realname = src->realname == NULL ? NULL : - g_strdup(src->realname); + dest->ircnet = g_strdup(src->ircnet); + dest->nick = g_strdup(src->nick); + dest->username = g_strdup(src->username); + dest->realname = g_strdup(src->realname); if (src->own_ip != NULL) { dest->own_ip = g_new(IPADDR, 1); diff --git a/src/irc/core/server-setup.c b/src/irc/core/server-setup.c index 296a52b2..6e271887 100644 --- a/src/irc/core/server-setup.c +++ b/src/irc/core/server-setup.c @@ -74,6 +74,24 @@ static void conn_set_ip(IRC_SERVER_CONNECT_REC *conn, IPADDR **own_ip, const cha } } +/* Fill information to connection from server setup record */ +void server_setup_fill_conn(IRC_SERVER_CONNECT_REC *conn, SETUP_SERVER_REC *sserver) +{ + if (sserver->own_host != NULL) + conn_set_ip(conn, &sserver->own_ip, sserver->own_host); + sserver->last_connect = time(NULL); + + if (sserver->ircnet != NULL && conn->ircnet == NULL) + conn->ircnet = g_strdup(sserver->ircnet); + + if (sserver->password != NULL && conn->password == NULL) + conn->password = g_strdup(sserver->password); + if (sserver->cmd_queue_speed > 0) + conn->cmd_queue_speed = sserver->cmd_queue_speed; + if (sserver->max_cmds_at_once > 0) + conn->max_cmds_at_once = sserver->max_cmds_at_once; +} + /* Create server connection record. `address' is required, rest can be NULL */ static IRC_SERVER_CONNECT_REC * create_addr_conn(const char *address, int port, const char *password, @@ -116,17 +134,7 @@ create_addr_conn(const char *address, int port, const char *password, sserver = server_setup_find(address, -1); if (sserver == NULL) return conn; - if (sserver->own_host != NULL) - conn_set_ip(conn, &sserver->own_ip, sserver->own_host); - sserver->last_connect = time(NULL); - - if (sserver->ircnet) conn->ircnet = g_strdup(sserver->ircnet); - if (sserver->password && !conn->password) - conn->password = g_strdup(sserver->password); - if (sserver->cmd_queue_speed > 0) - conn->cmd_queue_speed = sserver->cmd_queue_speed; - if (sserver->max_cmds_at_once > 0) - conn->max_cmds_at_once = sserver->max_cmds_at_once; + server_setup_fill_conn(conn, sserver); /* fill the rest from IRC network settings */ ircnet = sserver->ircnet == NULL ? NULL : ircnet_find(sserver->ircnet); diff --git a/src/irc/core/server-setup.h b/src/irc/core/server-setup.h index 8fc6d378..5bd1587f 100644 --- a/src/irc/core/server-setup.h +++ b/src/irc/core/server-setup.h @@ -32,6 +32,9 @@ extern gboolean source_host_ok; /* Use source_host_ip .. */ IRC_SERVER_CONNECT_REC * irc_server_create_conn(const char *dest, int port, const char *password, const char *nick); +/* Fill information to connection from server setup record */ +void server_setup_fill_conn(IRC_SERVER_CONNECT_REC *conn, SETUP_SERVER_REC *sserver); + void server_setup_add(SETUP_SERVER_REC *rec); void server_setup_remove(SETUP_SERVER_REC *rec);