From 57493acd39f63c20407c098730936a582fd47c51 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 8 Mar 2001 00:24:27 +0000 Subject: [PATCH] /CONNECT -ircnet didn't load ircnet specific settings correctly git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1363 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/chat-commands.c | 12 ++++-------- src/core/servers-setup.c | 28 +++++++++++++++++----------- src/core/servers-setup.h | 3 ++- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/core/chat-commands.c b/src/core/chat-commands.c index eece8dde..e14aa6b0 100644 --- a/src/core/chat-commands.c +++ b/src/core/chat-commands.c @@ -63,8 +63,10 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr) proto = chat_protocol_find_net(optlist); /* connect to server */ - conn = server_create_conn(proto != NULL ? proto->id : -1, - addr, atoi(portstr), password, nick); + chatnet = proto == NULL ? NULL : + g_hash_table_lookup(optlist, proto->chatnet); + conn = server_create_conn(proto != NULL ? proto->id : -1, addr, + atoi(portstr), chatnet, password, nick); if (proto == NULL) proto = chat_protocol_find_id(conn->chat_type); @@ -81,12 +83,6 @@ static SERVER_CONNECT_REC *get_server_connect(const char *data, int *plus_addr) else if (g_hash_table_lookup(optlist, "4") != NULL) conn->family = AF_INET; - chatnet = g_hash_table_lookup(optlist, proto->chatnet); - if (chatnet != NULL) { - g_free_not_null(conn->chatnet); - conn->chatnet = g_strdup(chatnet); - } - host = g_hash_table_lookup(optlist, "host"); if (host != NULL && *host != '\0') { IPADDR ip4, ip6; diff --git a/src/core/servers-setup.c b/src/core/servers-setup.c index a273f86f..a2baa3c2 100644 --- a/src/core/servers-setup.c +++ b/src/core/servers-setup.c @@ -189,12 +189,13 @@ static void server_setup_fill_chatnet(SERVER_CONNECT_REC *conn, static SERVER_CONNECT_REC * create_addr_conn(int chat_type, const char *address, int port, - const char *password, const char *nick) + const char *chatnet, const char *password, + const char *nick) { CHAT_PROTOCOL_REC *proto; SERVER_CONNECT_REC *conn; SERVER_SETUP_REC *sserver; - CHATNET_REC *chatnet; + CHATNET_REC *chatnetrec; g_return_val_if_fail(address != NULL, NULL); @@ -210,16 +211,19 @@ create_addr_conn(int chat_type, const char *address, int port, chat_protocol_get_default(); conn = proto->create_server_connect(); - conn->chat_type = proto->id; + conn->chat_type = proto->id; + if (chatnet != NULL && *chatnet != '\0') + conn->chatnet = g_strdup(chatnet); /* fill in the defaults */ server_setup_fill(conn, address, port); /* fill the rest from chat network settings */ - chatnet = sserver == NULL || sserver->chatnet == NULL ? NULL : - chatnet_find(sserver->chatnet); - if (chatnet != NULL) - server_setup_fill_chatnet(conn, chatnet); + chatnetrec = chatnet != NULL ? chatnet_find(chatnet) : + (sserver == NULL || sserver->chatnet == NULL ? NULL : + chatnet_find(sserver->chatnet)); + if (chatnetrec != NULL) + server_setup_fill_chatnet(conn, chatnetrec); /* fill the information from setup */ if (sserver != NULL) @@ -271,15 +275,16 @@ create_chatnet_conn(const char *dest, int port, } return bestrec == NULL ? NULL : - create_addr_conn(bestrec->chat_type, - bestrec->address, 0, NULL, nick); + create_addr_conn(bestrec->chat_type, bestrec->address, 0, + dest, NULL, nick); } /* Create server connection record. `dest' is required, rest can be NULL. `dest' is either a server address or chat network */ SERVER_CONNECT_REC * server_create_conn(int chat_type, const char *dest, int port, - const char *password, const char *nick) + const char *chatnet, const char *password, + const char *nick) { SERVER_CONNECT_REC *rec; @@ -291,7 +296,8 @@ server_create_conn(int chat_type, const char *dest, int port, return rec; } - return create_addr_conn(chat_type, dest, port, password, nick); + return create_addr_conn(chat_type, dest, port, + chatnet, password, nick); } /* Find matching server from setup. Try to find record with a same port, diff --git a/src/core/servers-setup.h b/src/core/servers-setup.h index d1a8bdd9..d0807d11 100644 --- a/src/core/servers-setup.h +++ b/src/core/servers-setup.h @@ -28,7 +28,8 @@ void server_setup_fill_reconn(SERVER_CONNECT_REC *conn, `dest' is either a server address or chat network */ SERVER_CONNECT_REC * server_create_conn(int chat_type, const char *dest, int port, - const char *password, const char *nick); + const char *chatnet, const char *password, + const char *nick); /* Find matching server from setup. Try to find record with a same port, but fallback to any server with the same address. */