X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fnetworkconnection.cpp;h=760dcb3c7d2666fd17753f2a8a73527edcd0b294;hp=ab4531149c1f11a903fc7595078c61e900ec86ae;hb=7942d6e0e0c29f870b471e44df6ba172732ef43a;hpb=b2f26944f3b4109d22bb1571aed2a7e2e9efbb5a diff --git a/src/core/networkconnection.cpp b/src/core/networkconnection.cpp index ab453114..760dcb3c 100644 --- a/src/core/networkconnection.cpp +++ b/src/core/networkconnection.cpp @@ -29,7 +29,6 @@ #include "ircchannel.h" #include "ircuser.h" -#include "network.h" #include "identity.h" #include "ircserverhandler.h" @@ -59,17 +58,15 @@ NetworkConnection::NetworkConnection(Network *network, CoreSession *session) // TokenBucket to avaid sending too much at once _messagesPerSecond(1), _burstSize(5), - _tokenBucket(5), // init with a full bucket - - // TODO: - // should be 510 (2 bytes are added when writing to the socket) - // maxMsgSize is 510 minus the hostmask which will be added by the server - _maxMsgSize(450) + _tokenBucket(5) // init with a full bucket { _autoReconnectTimer.setSingleShot(true); _socketCloseTimer.setSingleShot(true); connect(&_socketCloseTimer, SIGNAL(timeout()), this, SLOT(socketCloseTimeout())); - + + _pingTimer.setInterval(60000); + connect(&_pingTimer, SIGNAL(timeout()), this, SLOT(sendPing())); + _autoWhoTimer.setInterval(_autoWhoDelay * 1000); _autoWhoCycleTimer.setInterval(_autoWhoInterval * 1000); @@ -220,6 +217,8 @@ void NetworkConnection::networkInitialized(const QString ¤tServer) { network()->setConnected(true); emit connected(networkId()); + _pingTimer.start(); + if(_autoWhoEnabled) { _autoWhoCycleTimer.start(); _autoWhoTimer.start(); @@ -375,6 +374,7 @@ void NetworkConnection::socketCloseTimeout() { } void NetworkConnection::socketDisconnected() { + _pingTimer.stop(); _autoWhoCycleTimer.stop(); _autoWhoTimer.stop(); _autoWhoQueue.clear(); @@ -441,7 +441,10 @@ int NetworkConnection::lastParamOverrun(const QString &cmd, const QListme(); - int maxLen = 512 - serverEncode(me->nick()).count() - serverEncode(me->user()).count() - serverEncode(me->host()).count() - cmd.toAscii().count() - 6; + int maxLen = 480 - cmd.toAscii().count(); // educated guess in case we don't know us (yet?) + + if(me) + maxLen = 512 - serverEncode(me->nick()).count() - serverEncode(me->user()).count() - serverEncode(me->host()).count() - cmd.toAscii().count() - 6; if(!params.isEmpty()) { for(int i = 0; i < params.count() - 1; i++) { @@ -501,26 +504,13 @@ void NetworkConnection::putCmd(const QString &cmd, const QList ¶ if(!params.isEmpty()) msg += " :" + params.last(); - if(cmd == "PRIVMSG" && params.count() > 1) { - QByteArray msghead = "PRIVMSG " + params[0].toByteArray() + " :"; - - while (msg.size() > _maxMsgSize) { - QByteArray splitter(" .,-"); - int splitPosition = 0; - for(int i = 0; i < splitter.size(); i++) { - splitPosition = qMax(splitPosition, msg.lastIndexOf(splitter[i], _maxMsgSize)); - } - if(splitPosition < 300) { - splitPosition = _maxMsgSize; - } - putRawLine(msg.left(splitPosition)); - msg = msghead + msg.mid(splitPosition); - } - } - putRawLine(msg); } +void NetworkConnection::sendPing() { + userInputHandler()->handlePing(BufferInfo(), QString()); +} + void NetworkConnection::sendAutoWho() { while(!_autoWhoQueue.isEmpty()) { QString chan = _autoWhoQueue.takeFirst();