~ubuntu-branches/ubuntu/lucid/konversation/lucid-updates

« back to all changes in this revision

Viewing changes to src/irc/server.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Modestas Vainius
  • Date: 2009-05-15 11:24:24 UTC
  • mfrom: (1.15.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 47.
  • Revision ID: james.westby@ubuntu.com-20090515112424-b74i26lciabf4qnk
Tags: 1.1.75+svn968012-1
* New upstream development snapshot:
  - Last Changed Author: hein
  - Last Changed Rev: 968012
  - Last Changed Date: 2009-05-14 21:03:55 +0300
* Update README.source.
* Use dh --quilt instead of custom patch handling, build depend on
  quilt 0.46-7~.
* Update patches to upstream changes.
* Update konversation.install: remove docs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
279
279
 
280
280
    KonversationApplication* konvApp = static_cast<KonversationApplication*>(kapp);
281
281
    connect(getOutputFilter(), SIGNAL(connectTo(Konversation::ConnectionFlag, const QString&,
282
 
                uint, const QString&, const QString&, const QString&, bool)),
 
282
                const QString&, const QString&, const QString&, const QString&, bool)),
283
283
            konvApp->getConnectionManager(), SLOT(connectTo(Konversation::ConnectionFlag,
284
 
                const QString&, uint, const QString&, const QString&, const QString&, bool)));
 
284
                const QString&, const QString&, const QString&, const QString&, const QString&, bool)));
285
285
    connect(konvApp->getDccTransferManager(), SIGNAL(newTransferQueued(DccTransfer*)),
286
286
            this, SLOT(slotNewDccTransferItemQueued(DccTransfer*)));
287
287
 
379
379
        updateConnectionState(Konversation::SSConnecting);
380
380
 
381
381
        m_autoIdentifyLock = false;
382
 
        m_ownIpByUserhost = QString();
 
382
        m_ownIpByUserhost.clear();
383
383
 
384
384
        resetQueues();
385
385
 
614
614
    QString reason;
615
615
    for(int i = 0; i < errors.size(); ++i)
616
616
    {
617
 
        reason += errors.at(i).errorString() + " ";
 
617
        reason += errors.at(i).errorString() + ' ';
618
618
    }
619
619
 
620
620
    //this message should be changed since sslError is called even after calling ignoreSslErrors()
621
 
    QString error = i18n("Could not connect to %1:%2 using SSL encryption.Maybe the server does not support SSL, or perhaps you have the wrong port? %3",
 
621
    QString error = i18n("Could not connect to %1:%2 using SSL encryption. Maybe the server does not support SSL, or perhaps you have the wrong port? %3",
622
622
        getConnectionSettings().server().host(),
623
623
        QString::number(getConnectionSettings().server().port()),
624
624
        reason);
822
822
        if (!getNickname().isEmpty())
823
823
            connectCommands.replace("%nick", getNickname());
824
824
 
825
 
        QStringList connectCommandsList = connectCommands.split(";", QString::SkipEmptyParts);
 
825
        QStringList connectCommandsList = connectCommands.split(';', QString::SkipEmptyParts);
826
826
        QStringList::iterator iter;
827
827
 
828
828
        for (iter = connectCommandsList.begin(); iter != connectCommandsList.end(); ++iter)
899
899
        if (m_rawLog)
900
900
        {
901
901
            QString toRaw = front;
902
 
            m_rawLog->appendRaw("&gt;&gt; " + toRaw.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace(QRegExp("\\s"), "&nbsp;"));
 
902
            m_rawLog->appendRaw("&gt;&gt; " + toRaw.replace('&',"&amp;").replace('<',"&lt;").replace('>',"&gt;").replace(QRegExp("\\s"), "&nbsp;"));
903
903
        }
904
904
        m_inputFilter.parseLine(front);
905
905
        m_processingIncoming = false;
922
922
    while (m_socket->canReadLine())
923
923
    {
924
924
        QByteArray line(m_socket->readLine());
925
 
        line.chop(1);//remove \n blowfish doesnt like it
 
925
        //remove \n blowfish doesn't like it
 
926
        int i = line.size()-1;
 
927
        while (line[i]=='\n' || line[i]=='\r') // since euIRC gets away with sending just \r, bet someone sends \n\r?
 
928
        {
 
929
            i--;
 
930
        }
 
931
        line.truncate(i+1);
926
932
        bufferLines.append(line);
927
933
    }
928
934
 
1091
1097
    // ex.: JIS7, eucJP, SJIS
1092
1098
    //int outlen=-1;
1093
1099
 
1094
 
    //leaving this done twice for now, i'm uncertain of the implications of not encoding other commands
 
1100
    //leaving this done twice for now, I'm uncertain of the implications of not encoding other commands
1095
1101
    QByteArray encoded = codec->fromUnicode(outputLine);
1096
1102
 
1097
1103
    QString blowfishKey;
1135
1141
    qint64 sout = m_socket->write(encoded, encoded.length());
1136
1142
 
1137
1143
    if (m_rawLog)
1138
 
        m_rawLog->appendRaw("&lt;&lt; " + outputLine.replace("&","&amp;").replace("<","&lt;").replace(">","&gt;"));
 
1144
        m_rawLog->appendRaw("&lt;&lt; " + outputLine.replace('&',"&amp;").replace('<',"&lt;").replace('>',"&gt;"));
1139
1145
 
1140
1146
    return sout;
1141
1147
}
1514
1520
 
1515
1521
void Server::requestUserhost(const QString& nicks)
1516
1522
{
1517
 
    const QStringList nicksList = nicks.split(" ", QString::SkipEmptyParts);
 
1523
    const QStringList nicksList = nicks.split(' ', QString::SkipEmptyParts);
1518
1524
    for(QStringList::ConstIterator it=nicksList.constBegin() ; it!=nicksList.constEnd() ; ++it)
1519
1525
        m_inputFilter.setAutomaticRequest("USERHOST", *it, true);
1520
1526
    queue("USERHOST "+nicks, LowPriority);
1707
1713
 
1708
1714
    //we want a clean filename to get rid of the mass """filename"""
1709
1715
    //NOTE: if a filename starts really with a ", it is escaped -> \" (2 chars)
1710
 
    //      but most clients doesnt support that and just replace it with a _
 
1716
    //      but most clients doen't support that and just replace it with a _
1711
1717
    while (cleanFileName.startsWith('\"') && cleanFileName.endsWith('\"'))
1712
1718
    {
1713
1719
        cleanFileName = cleanFileName.mid(1, cleanFileName.length() - 2);
2222
2228
    bool doChannelJoinedSignal = false;
2223
2229
    bool doWatchedNickChangedSignal = false;
2224
2230
    bool doChannelMembersChangedSignal = false;
2225
 
    QString lcNickname = nickname.toLower();
 
2231
    QString lcNickname(nickname.toLower());
2226
2232
    // Create NickInfo if not already created.
2227
2233
    NickInfoPtr nickInfo = getNickInfo(nickname);
2228
2234
    if (!nickInfo)
2305
2311
    bool doChannelUnjoinedSignal = false;
2306
2312
    bool doWatchedNickChangedSignal = false;
2307
2313
    bool doChannelMembersChangedSignal = false;
2308
 
    QString lcNickname = nickname.toLower();
 
2314
    QString lcNickname(nickname.toLower());
2309
2315
    // Create NickInfo if not already created.
2310
2316
    NickInfoPtr nickInfo = getNickInfo(nickname);
2311
2317
    if (!nickInfo)
2364
2370
    NickInfoPtr nickInfo = getNickInfo(nickname);
2365
2371
    if (!nickInfo)
2366
2372
    {
2367
 
        QString lcNickname = nickname.toLower();
 
2373
        QString lcNickname(nickname.toLower());
2368
2374
        nickInfo = new NickInfo(nickname, this);
2369
2375
        m_allNicks.insert(lcNickname, nickInfo);
2370
2376
    }
2399
2405
 
2400
2406
bool Server::setNickOffline(const QString& nickname)
2401
2407
{
2402
 
    QString lcNickname = nickname.toLower();
 
2408
    QString lcNickname(nickname.toLower());
2403
2409
    NickInfoPtr nickInfo = getNickInfo(lcNickname);
2404
2410
 
2405
2411
    bool wasOnline = nickInfo ? nickInfo->getPrintedOnline() : false;
2438
2444
 */
2439
2445
bool Server::deleteNickIfUnlisted(const QString &nickname)
2440
2446
{
2441
 
    QString lcNickname = nickname.toLower();
 
2447
    QString lcNickname(nickname.toLower());
2442
2448
    // Don't delete our own nickinfo.
2443
2449
    if (lcNickname == loweredNickname()) return false;
2444
2450
 
2477
2483
            // Note: Channel should not be empty because user's own nick should still be
2478
2484
            // in it, so do not need to delete empty channel here.
2479
2485
        }
 
2486
        else
 
2487
        {
 
2488
            kDebug() << "Error: Tried to remove nickname=" << nickname << " from joined channel=" << channelName;
 
2489
        }
2480
2490
    }
2481
2491
    else
2482
2492
    {
2492
2502
                // Caution: Any iterators across unjoinedChannels will be come invalid here.
2493
2503
                if (channel->isEmpty()) m_unjoinedChannels.remove(lcChannelName);
2494
2504
            }
 
2505
            else
 
2506
            {
 
2507
                kDebug() << "Error: Tried to remove nickname=" << nickname << " from unjoined channel=" << channelName;
 
2508
            }
2495
2509
        }
2496
2510
    }
2497
2511
    if (doSignal) emit channelMembersChanged(this, channelName, joined, true, nickname);
2590
2604
    if (nickInfo)
2591
2605
    {
2592
2606
        // Get existing lowercase nickname and rename nickname in the NickInfo object.
2593
 
        QString lcNickname = nickInfo->loweredNickname();
 
2607
        QString lcNickname(nickInfo->loweredNickname());
2594
2608
        nickInfo->setNickname(newname);
2595
2609
        nickInfo->setIdentified(false);
2596
 
        QString lcNewname = newname.toLower();
 
2610
        QString lcNewname(newname.toLower());
2597
2611
        // Rename the key in m_allNicks list.
2598
2612
        m_allNicks.remove(lcNickname);
2599
2613
        m_allNicks.insert(lcNewname, nickInfo);
2620
2634
    }
2621
2635
    else
2622
2636
    {
2623
 
        kDebug() << "server::renameNickInfo() was called for newname='" << newname << "' but nickInfo is null";
 
2637
        kDebug() << "was called for newname='" << newname << "' but nickInfo is null";
2624
2638
    }
2625
2639
}
2626
2640
 
2627
2641
Channel* Server::nickJoinsChannel(const QString &channelName, const QString &nickname, const QString &hostmask)
2628
2642
{
2629
 
    Channel* outChannel=getChannelByName(channelName);
 
2643
    Channel* outChannel = getChannelByName(channelName);
2630
2644
    if(outChannel)
2631
2645
    {
2632
2646
        // Update NickInfo.
2645
2659
void Server::addHostmaskToNick(const QString& sourceNick, const QString& sourceHostmask)
2646
2660
{
2647
2661
    // Update NickInfo.
2648
 
    NickInfoPtr nickInfo=getNickInfo(sourceNick);
 
2662
    NickInfoPtr nickInfo = getNickInfo(sourceNick);
2649
2663
    if (nickInfo)
2650
2664
    {
2651
2665
        if ((nickInfo->getHostmask() != sourceHostmask) && !sourceHostmask.isEmpty())
2657
2671
 
2658
2672
Channel* Server::removeNickFromChannel(const QString &channelName, const QString &nickname, const QString &reason, bool quit)
2659
2673
{
2660
 
    Channel* outChannel=getChannelByName(channelName);
 
2674
    Channel* outChannel = getChannelByName(channelName);
2661
2675
    if(outChannel)
2662
2676
    {
 
2677
        outChannel->flushPendingNicks();
2663
2678
        ChannelNickPtr channelNick = getChannelNick(channelName, nickname);
2664
 
        if(channelNick) outChannel->removeNick(channelNick,reason,quit);
 
2679
        if(channelNick)
 
2680
        {
 
2681
            outChannel->removeNick(channelNick,reason,quit);
 
2682
        }
2665
2683
    }
2666
2684
 
2667
2685
    // Remove the nick from the channel.
2680
2698
 
2681
2699
void Server::nickWasKickedFromChannel(const QString &channelName, const QString &nickname, const QString &kicker, const QString &reason)
2682
2700
{
2683
 
    Channel* outChannel=getChannelByName(channelName);
 
2701
    Channel* outChannel = getChannelByName(channelName);
2684
2702
    if(outChannel)
2685
2703
    {
 
2704
        outChannel->flushPendingNicks();
2686
2705
        ChannelNickPtr channelNick = getChannelNick(channelName, nickname);
2687
2706
 
2688
2707
        if(channelNick)
2698
2717
{
2699
2718
    foreach (Channel* channel, m_channelList)
2700
2719
    {
 
2720
        channel->flushPendingNicks();
2701
2721
        // Check if nick is in this channel or not.
2702
2722
        if(channel->getNickByName(nickname))
2703
2723
            removeNickFromChannel(channel->getName(),nickname,reason,true);
2743
2763
        // Rename the nick in every channel they are in
2744
2764
        foreach (Channel* channel, m_channelList)
2745
2765
        {
 
2766
            channel->flushPendingNicks();
 
2767
 
2746
2768
            // All we do is notify that the nick has been renamed.. we haven't actually renamed it yet
2747
2769
            // Note that NickPanel has already updated, so pass new nick to getNickByName.
2748
2770
            if (channel->getNickByName(newNick)) channel->nickRenamed(nickname, *nickInfo);
3044
3066
    {
3045
3067
        setAutoJoin(true);
3046
3068
 
3047
 
        setAutoJoinCommands(QStringList("JOIN " + channel.name() + " " + channel.password()));
 
3069
        setAutoJoinCommands(QStringList("JOIN " + channel.name() + ' ' + channel.password()));
3048
3070
 
3049
3071
        return;
3050
3072
    }
3089
3111
            {
3090
3112
                if (passwords.last() == ".") passwords.pop_back();
3091
3113
 
3092
 
                joinCommands << "JOIN " + channels.join(",") + " " + passwords.join(",");
 
3114
                joinCommands << "JOIN " + channels.join(",") + ' ' + passwords.join(",");
3093
3115
 
3094
3116
                channels.clear();
3095
3117
                passwords.clear();
3106
3128
 
3107
3129
        if (passwords.last() == ".") passwords.pop_back();
3108
3130
 
3109
 
        joinCommands << "JOIN " + channels.join(",") + " " + passwords.join(",");
 
3131
        joinCommands << "JOIN " + channels.join(",") + ' ' + passwords.join(",");
3110
3132
 
3111
3133
        setAutoJoinCommands(joinCommands);
3112
3134
    }
3257
3279
    }
3258
3280
    else
3259
3281
    {
3260
 
        m_awayReason = QString();
 
3282
        m_awayReason.clear();
3261
3283
 
3262
3284
        emit awayState(false);
3263
3285