[PATCH] Re-join channels after explicit disconnect

Development of XChat itself. Talk about code, patches and other technical stuff. No feature requests!
Formal bug reports should go to http://xchat.org/cvs/#bugs instead.
This forum is for developers writing xchat code, not end-user questions.

[PATCH] Re-join channels after explicit disconnect

Postby jellyfish » 08 Oct 2010 20:07

This feature - let's call it a feature instead of a bug :) - has been annoying me for a while.

In my case, I let the XChat window (almost) always opened (with the current set of channel tabs still opened) even after I disconnect, so I can suspend the machine, turn it off, get some sleep and the next day I can open it in the state it was. The only problem is that after a reconnect, XChat will not automatically join the channel tabs that are currently opened. I think it should always join all the channels again, the same way it does when you reconnect without a prior explicit "disconnect" command.

Anyway, that is my use case. So I decided to fix this.

After some search I was able to find this issue was already reported before (https://bugs.launchpad.net/ubuntu/+source/xchat/+bug/215078 and http://sourceforge.net/tracker/index.php?func=detail&aid=1405961&group_id=239&atid=100239), but I wasn't able to find any solution.

The steps I used and was always able to reproduce this issue are reported in https://bugs.launchpad.net/ubuntu/+source/xchat/+bug/215078/comments/7, quoted here:

1. Connect to server, autojoin #testchannel.
2. /quit - disconnects.
3. /reconnect - reconnects, does NOT autojoin #testchannel.

So I decided to patch this myself, and it worked. I didn't test it extensively, it simply worked as expected in my case, where I connect to one server only (Freenode). This might be useful for a bunch of other users, and the ones who reported it. I just hope my patch is correct and won't break anything else.



Code: Select all
diff -urN xchat-cur/src/common/server.c xchat-new/src/common/server.c
--- xchat-cur/src/common/server.c   2010-10-08 15:51:45.000000000 -0300
+++ xchat-new/src/common/server.c   2010-10-08 15:52:23.000000000 -0300
@@ -1143,8 +1143,15 @@
            /* print "Disconnected" to each window using this server */
            EMIT_SIGNAL (XP_TE_DISCON, sess, errorstring (err), NULL, NULL, NULL, 0);

-        if (!sess->channel[0] || sess->type == SESS_CHANNEL)
+        if (!sess->channel[0])
+        {
            clear_channel (sess);
+        }
+        else if (sess->type == SESS_CHANNEL)
+        {
+           strcpy (sess->willjoinchannel, sess->channel);
+           clear_channel (sess);
+        }
      list = list->next;
Posts: 1
Joined: 08 Oct 2010 19:11

Re: [PATCH] Re-join channels after explicit disconnect

Postby bviktor » 20 Oct 2010 22:31

will this work in multiple network scenarios too?
Posts: 59
Joined: 04 Oct 2010 19:41

Re: [PATCH] Re-join channels after explicit disconnect

Postby LifeIsPain » 22 Oct 2010 06:52

So I finally did get around to testing out the patch and confirming what I thought, and that would be that this patch won't work. And because such a statement can't be left alone, here is why.

This behavior (setting the willjoinchannel on manual disconnect) is only going to be applicable in one scenario, when joining the same network that was previously joined. If the user is disconnecting and then joining some other network, they probably don't want to join all the channels they were on in the first network.

  • User joins NetworkA
  • User joins #channel1,#channel2,#staffchannel
  • User types /discon
  • User types /server NetworkB
  • User is now automatically joined to #channel1,#channel2,#staffchannel
  • User now complains about privacy and joining the #staffchannel on the wrong network
3 channels may not be much and could be closed fairly easily, but still, this is a privacy issue for many. But now consider what happens if they user had joined 50 channels on the other network. Now they will disconnect, connect to another network, join all those channels and find that most of them aren't in use now. Even so, they now have also joined the auto join channels for the second network.

And in one more example of why this isn't a good idea, if you are disconnected from a network and hit Connect from the network list, XChat will use the current network group to rejoin, thus joining all those channels.

Verifying that it is the same network should be done if using willjoinchannel. But the connected server stuct will have already been replaced by the time the rejoins are suppose to happen. As such, you would need extra variables for the previous network connected to. Even then, multiple distinct networks could share the same name.

Now you could create a new command other than discon which would store the channels, but I don't believe doing just a normal /discon (or selecting Server -> Disconnect) should automatically join all of the same channels again.
User avatar
Posts: 522
Joined: 25 Aug 2005 06:36

Re: [PATCH] Re-join channels after explicit disconnect

Postby ikt » 06 Mar 2011 19:19

LifeIsPain wrote:And in one more example of why this isn't a good idea, if you are disconnected from a network and hit Connect from the network list, XChat will use the current network group to rejoin, thus joining all those channels.

That sounds like a fault of xchat, it shouldn't be using a current server window to connect to a server, it should be opening a new server window.
Posts: 1
Joined: 06 Mar 2011 19:04

Return to Development

Who is online

Users browsing this forum: No registered users and 0 guests