irssi-import / bugs.irssi.org

bugs.irssi.org archive
https://github.com/irssi/irssi/issues
0 stars 0 forks source link

Reconnection doesn't honour -! #737

Closed irssibot closed 14 years ago

irssibot commented 14 years ago

If you connect to a server with /connect -! , if a reconnection occurs, the connection record's no_autojoin_channels is not honoured and you are rejoined to all channels you were in at the point of disconnection.

irssibot commented 14 years ago

patch-src_irc_core_irc-servers-reconnect_c

--- src/irc/core/irc-servers-reconnect.c.orig   2009-07-09 08:51:19.000000000 +0100
+++ src/irc/core/irc-servers-reconnect.c    2009-07-09 11:53:10.000000000 +0100
@@ -59,7 +59,8 @@
        return;

    g_free_not_null(conn->channels);
-   conn->channels = irc_server_get_channels(server);
+   conn->channels = server->connrec->no_autojoin_channels ? NULL :
+            irc_server_get_channels(server);

    g_free_not_null(conn->usermode);
    conn->usermode = g_strdup(server->wanted_usermode);
irssibot commented 14 years ago
irssibot commented 14 years ago

There's two distinct issues here then - generically not rejoining any channels on reconnect (I'll submit a patch for that as a seperate item) and honouring -! across reconnects.

If a user /connect's with -! , I think there's a reasonable expectation that the auto-join channels aren't rejoined on a reconnection. Does this then mean that only auto-join channels shouldn't be rejoined and that manually joined channels should be rejoined? Or is it better to consider not rejoining any channels on reconnection (when -! is used)?

irssibot commented 14 years ago

Your reasonable expectation should already be the case (unless you joined the channels manually before reconnecting).

Correct me if I'm wrong here (but I even just tested it again to be really sure).

irssibot commented 14 years ago

I've just re-tested and you're right - I must have confused myself. My apologies for wasting your time.

irssibot commented 14 years ago

As per comments in #irssi, please find attached a patch which provides support for toggleable rejoin-channels-on-reconnect functionality.

irssibot commented 14 years ago

patch-channels-rejoin-on-reconnect.diff

--- src/irc/core/irc-servers-reconnect.c.orig   2010-03-24 03:27:41.000000000 +0000
+++ src/irc/core/irc-servers-reconnect.c    2010-03-24 03:30:26.000000000 +0000
@@ -59,7 +59,8 @@
        return;

    g_free_not_null(conn->channels);
-   conn->channels = irc_server_get_channels(server);
+   conn->channels = settings_get_bool("channels_rejoin_on_reconnect") ? 
+                 irc_server_get_channels(server) : NULL;

    g_free_not_null(conn->usermode);
    conn->usermode = g_strdup(server->wanted_usermode);
--- src/core/servers-reconnect.c.orig   2008-08-25 23:00:02.000000000 +0100
+++ src/core/servers-reconnect.c    2010-03-24 03:32:40.000000000 +0000
@@ -35,6 +35,7 @@
 static int reconnect_timeout_tag;
 static int reconnect_time;
 static int connect_timeout;
+static int channels_rejoin;

 void reconnect_save_status(SERVER_CONNECT_REC *conn, SERVER_REC *server)
 {
@@ -51,8 +52,11 @@
        /* XXX when is reconnect_save_status() called with
         * server->connected==FALSE? */
        g_free_not_null(conn->channels);
-       conn->channels = server->connrec->no_autojoin_channels ? NULL :
-           g_strdup(server->connrec->channels);
+       if (server->connrec->no_autojoin_channels || !channels_rejoin) {
+               conn->channels = NULL;
+               } else {
+                       conn->channels = g_strdup(server->connrec->channels);
+               }
    }

    signal_emit("server reconnect save status", 2, conn, server);
@@ -468,12 +472,14 @@
 {
    reconnect_time = settings_get_time("server_reconnect_time")/1000;
         connect_timeout = settings_get_time("server_connect_timeout")/1000;
+        channels_rejoin = settings_get_str("channels_rejoin_on_reconnect");
 }

 void servers_reconnect_init(void)
 {
    settings_add_time("server", "server_reconnect_time", "5min");
    settings_add_time("server", "server_connect_timeout", "5min");
+   settings_add_bool("servers", "channels_rejoin_on_reconnect", TRUE);

    reconnects = NULL;
    last_reconnect_tag = 0;
irssibot commented 14 years ago

Please ignore the previous patch - it contains a braindead typo (erroneously used settings_get_str instead of settings_get_bool).

irssibot commented 14 years ago

patch-channels-rejoin-on-reconnect.diff

--- src/irc/core/irc-servers-reconnect.c.orig   2010-03-24 03:27:41.000000000 +0000
+++ src/irc/core/irc-servers-reconnect.c    2010-03-24 03:30:26.000000000 +0000
@@ -59,7 +59,8 @@
        return;

    g_free_not_null(conn->channels);
-   conn->channels = irc_server_get_channels(server);
+   conn->channels = settings_get_bool("channels_rejoin_on_reconnect") ? 
+                 irc_server_get_channels(server) : NULL;

    g_free_not_null(conn->usermode);
    conn->usermode = g_strdup(server->wanted_usermode);
--- src/core/servers-reconnect.c.orig   2008-08-25 23:00:02.000000000 +0100
+++ src/core/servers-reconnect.c    2010-03-24 03:32:40.000000000 +0000
@@ -35,6 +35,7 @@
 static int reconnect_timeout_tag;
 static int reconnect_time;
 static int connect_timeout;
+static int channels_rejoin;

 void reconnect_save_status(SERVER_CONNECT_REC *conn, SERVER_REC *server)
 {
@@ -51,8 +52,11 @@
        /* XXX when is reconnect_save_status() called with
         * server->connected==FALSE? */
        g_free_not_null(conn->channels);
-       conn->channels = server->connrec->no_autojoin_channels ? NULL :
-           g_strdup(server->connrec->channels);
+       if (server->connrec->no_autojoin_channels || !channels_rejoin) {
+               conn->channels = NULL;
+               } else {
+                       conn->channels = g_strdup(server->connrec->channels);
+               }
    }

    signal_emit("server reconnect save status", 2, conn, server);
@@ -468,12 +472,14 @@
 {
    reconnect_time = settings_get_time("server_reconnect_time")/1000;
         connect_timeout = settings_get_time("server_connect_timeout")/1000;
+        channels_rejoin = settings_get_bool("channels_rejoin_on_reconnect");
 }

 void servers_reconnect_init(void)
 {
    settings_add_time("server", "server_reconnect_time", "5min");
    settings_add_time("server", "server_connect_timeout", "5min");
+   settings_add_bool("servers", "channels_rejoin_on_reconnect", TRUE);

    reconnects = NULL;
    last_reconnect_tag = 0;
irssibot commented 14 years ago

See also #639: it might be nice to have a setting with three possible values...

irssibot commented 14 years ago

Somewhat a duplicate of #639

irssibot commented 14 years ago

Duplicate of #639. See #639.