#include "ircchannel.h"
#include "ircuser.h"
-#include "network.h"
#include "identity.h"
#include "ircserverhandler.h"
_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);
network()->setConnected(true);
emit connected(networkId());
+ _pingTimer.start();
+
if(_autoWhoEnabled) {
_autoWhoCycleTimer.start();
_autoWhoTimer.start();
}
void NetworkConnection::socketDisconnected() {
+ _pingTimer.stop();
_autoWhoCycleTimer.stop();
_autoWhoTimer.stop();
_autoWhoQueue.clear();
// that means that the last message can be as long as:
// 512 - nicklen - userlen - hostlen - commandlen - sum(param[0]..param[n-1])) - 2 (for CRLF) - 4 (":!@" + 1space between prefix and command) - max(paramcount - 1, 0) (space for simple params) - 2 (space and colon for last param)
IrcUser *me = network()->me();
- 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++) {
putRawLine(msg);
}
+void NetworkConnection::sendPing() {
+ userInputHandler()->handlePing(BufferInfo(), QString());
+}
+
void NetworkConnection::sendAutoWho() {
while(!_autoWhoQueue.isEmpty()) {
QString chan = _autoWhoQueue.takeFirst();