[Konversation-devel] [Bug 174143] New: Reconnect fails on password protected channels

Nach NachMS at gmail.com
Mon Nov 3 04:09:19 CET 2008


http://bugs.kde.org/show_bug.cgi?id=174143

           Summary: Reconnect fails on password protected channels
           Product: konversation
           Version: 1.1
          Platform: Debian testing
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
        AssignedTo: konversation-devel at kde.org
        ReportedBy: NachMS at gmail.com


Version:           1.1 (using KDE 3.5.10)
Compiler:          gcc version 4.3.2 (Debian 4.3.2-1) x86-64
OS:                Linux
Installed from:    Debian testing/unstable Packages

When one reconnects to a server (file -> reconnect), channels that require
passwords to enter fail to be rejoined, even though those channels are properly
auto joined when first connecting to that server.

I'm not sure why that is, but it seems that passwords aren't being saved in the
m_channelList structure in server.cpp.

I came up with a temporary patch to fix the problem, which replaces
updateAutoJoin() in the source of 1.1 (not SVN, didn't look at it).

------------------------------------------
static std::map<QString, QString> ChannelPasswords;

void Server::updateAutoJoin(Konversation::ChannelSettings channel)
{
    if (!channel.name().isEmpty())
    {
        setAutoJoin(true);
        setAutoJoinCommands(QStringList("JOIN " + channel.name() + " " +
channel.password()));
        return;
    }

    Konversation::ChannelList tmpList;

    if (m_channelList.isEmpty() && getServerGroup())
        tmpList = getServerGroup()->channelList();
    else
    {
        QPtrListIterator<Channel> it(m_channelList);
        Channel* channel;

        while ((channel = it.current()) != 0)
        {
            ++it;
            tmpList << channel->channelSettings();
        }
    }

    if (!tmpList.isEmpty())
    {
        setAutoJoin(true);

        QStringList channels;
        QStringList passwords;
        QStringList joinCommands;
        uint length = 0;

        Konversation::ChannelList::iterator it;

        for (it = tmpList.begin(); it != tmpList.end(); ++it)
        {
            QString channel = (*it).name();
            QString password = ((*it).password().isEmpty() ? "." :
(*it).password());

            //Save/Load passwords
            if (password != ".")
            {
              ChannelPasswords[channel] = password;
            }
            else if (ChannelPasswords.find(channel) != ChannelPasswords.end())
            {
              password = ChannelPasswords[channel];
            }

            int tempLen = channel.length();
            uint currentLength =
getIdentity()->getCodec()->fromUnicode(channel, tempLen).length();
            tempLen = password.length();
            currentLength += getIdentity()->getCodec()->fromUnicode(password,
tempLen).length();

            //Have to add length for commas, but no -1 for joined comma,
because last entry isn't joined yet
            if (length + currentLength + 6 + channels.count() +
passwords.count() >= 512) // 6: "JOIN " plus separating space between chans and
pws.
            {
                joinCommands << "JOIN " + channels.join(",") + " " +
passwords.join(",");

                channels.clear();
                passwords.clear();

                length = 0;
            }

            length += currentLength;

            channels << channel;
            passwords << password;
        }

        joinCommands << "JOIN " + channels.join(",") + " " +
passwords.join(",");

        setAutoJoinCommands(joinCommands);
    }
    else
        setAutoJoin(false);
}
------------------------------------------
This works by creating a map of channels to passwords (include <map>), and uses
the map. A proper fix should probably elsewhere. However, while writing this
patch, I noticed two other bugs in the code which I also fixed.

1) When splitting the line so it shouldn't exceed 512, the current channel is
on the old JOIN line and the new JOIN line.
2) Commas aren't taken into account in the length of the line.

Those are fixed, and code repetition is removed.


-- 
Configure bugmail: http://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Konversation-devel mailing list