mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
Try to keep the number after server tag always the same when there's
multiple connections to the same server. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1540 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
bd7cc25590
commit
7773aabb2c
@ -9,6 +9,7 @@ int proxy_port;
|
||||
char *proxy_string, *proxy_password;
|
||||
|
||||
unsigned short family; /* 0 = don't care, AF_INET or AF_INET6 */
|
||||
char *tag; /* try to keep this tag when connected to server */
|
||||
char *address;
|
||||
int port;
|
||||
char *chatnet;
|
||||
|
@ -37,6 +37,9 @@ static int reconnect_time;
|
||||
|
||||
void reconnect_save_status(SERVER_CONNECT_REC *conn, SERVER_REC *server)
|
||||
{
|
||||
g_free_not_null(conn->tag);
|
||||
conn->tag = g_strdup(server->tag);
|
||||
|
||||
g_free_not_null(conn->away_reason);
|
||||
conn->away_reason = !server->usermode_away ? NULL :
|
||||
g_strdup(server->away_reason);
|
||||
@ -133,6 +136,8 @@ server_connect_copy_skeleton(SERVER_CONNECT_REC *src, int connect_info)
|
||||
dest->proxy_string = g_strdup(src->proxy_string);
|
||||
dest->proxy_password = g_strdup(src->proxy_password);
|
||||
|
||||
dest->tag = g_strdup(src->tag);
|
||||
|
||||
if (connect_info) {
|
||||
dest->family = src->family;
|
||||
dest->address = g_strdup(src->address);
|
||||
@ -224,7 +229,7 @@ static void sig_reconnect(SERVER_REC *server)
|
||||
}
|
||||
|
||||
/* always try to first connect to the first on the list where we
|
||||
haven't got unsuccessful connection attempts for the last half
|
||||
haven't got unsuccessful connection attempts for the past half
|
||||
an hour. */
|
||||
|
||||
now = time(NULL);
|
||||
@ -385,13 +390,11 @@ static void cmd_reconnect(const char *data, SERVER_REC *server)
|
||||
static void cmd_disconnect(const char *data, SERVER_REC *server)
|
||||
{
|
||||
RECONNECT_REC *rec;
|
||||
int tag;
|
||||
|
||||
if (g_strncasecmp(data, "RECON-", 6) != 0)
|
||||
return; /* handle only reconnection removing */
|
||||
|
||||
rec = sscanf(data+6, "%d", &tag) == 1 && tag > 0 ?
|
||||
reconnect_find_tag(tag) : NULL;
|
||||
rec = reconnect_find_tag(atoi(data+6));
|
||||
|
||||
if (rec == NULL)
|
||||
signal_emit("server reconnect not found", 1, data);
|
||||
|
@ -107,6 +107,17 @@ static char *server_create_tag(SERVER_CONNECT_REC *conn)
|
||||
g_strdup(conn->chatnet) :
|
||||
server_create_address_tag(conn->address);
|
||||
|
||||
if (conn->tag != NULL && server_find_tag(conn->tag) == NULL &&
|
||||
strncmp(conn->tag, tag, strlen(tag)) == 0) {
|
||||
/* use the existing tag if it begins with the same ID -
|
||||
this is useful when you have several connections to
|
||||
same server and you want to keep the same tags with
|
||||
the servers (or it would cause problems when rejoining
|
||||
/LAYOUT SAVEd channels). */
|
||||
return g_strdup(conn->tag);
|
||||
}
|
||||
|
||||
|
||||
/* then just append numbers after tag until unused is found.. */
|
||||
str = g_string_new(tag);
|
||||
for (num = 2; server_find_tag(str->str) != NULL; num++)
|
||||
@ -410,6 +421,7 @@ void server_connect_free(SERVER_CONNECT_REC *conn)
|
||||
g_free_not_null(conn->proxy_string);
|
||||
g_free_not_null(conn->proxy_password);
|
||||
|
||||
g_free_not_null(conn->tag);
|
||||
g_free_not_null(conn->address);
|
||||
g_free_not_null(conn->chatnet);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user