-INIT_SYNCABLE_OBJECT(CoreNetwork)
-CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session)
- : Network(networkid, session),
- _coreSession(session),
- _userInputHandler(new CoreUserInputHandler(this)),
- _autoReconnectCount(0),
- _quitRequested(false),
-
- _previousConnectionAttemptFailed(false),
- _lastUsedServerIndex(0),
-
- _lastPingTime(0),
- _pingCount(0),
- _requestedUserModes('-')
-{
- _autoReconnectTimer.setSingleShot(true);
- _socketCloseTimer.setSingleShot(true);
- connect(&_socketCloseTimer, SIGNAL(timeout()), this, SLOT(socketCloseTimeout()));
-
- setPingInterval(networkConfig()->pingInterval());
- connect(&_pingTimer, SIGNAL(timeout()), this, SLOT(sendPing()));
-
- setAutoWhoDelay(networkConfig()->autoWhoDelay());
- setAutoWhoInterval(networkConfig()->autoWhoInterval());
-
- QHash<QString, QString> channels = coreSession()->persistentChannels(networkId());
- foreach(QString chan, channels.keys()) {
- _channelKeys[chan.toLower()] = channels[chan];
- }
-
- connect(networkConfig(), SIGNAL(pingTimeoutEnabledSet(bool)), SLOT(enablePingTimeout(bool)));
- connect(networkConfig(), SIGNAL(pingIntervalSet(int)), SLOT(setPingInterval(int)));
- connect(networkConfig(), SIGNAL(autoWhoEnabledSet(bool)), SLOT(setAutoWhoEnabled(bool)));
- connect(networkConfig(), SIGNAL(autoWhoIntervalSet(int)), SLOT(setAutoWhoInterval(int)));
- connect(networkConfig(), SIGNAL(autoWhoDelaySet(int)), SLOT(setAutoWhoDelay(int)));
-
- connect(&_autoReconnectTimer, SIGNAL(timeout()), this, SLOT(doAutoReconnect()));
- connect(&_autoWhoTimer, SIGNAL(timeout()), this, SLOT(sendAutoWho()));
- connect(&_autoWhoCycleTimer, SIGNAL(timeout()), this, SLOT(startAutoWhoCycle()));
- connect(&_tokenBucketTimer, SIGNAL(timeout()), this, SLOT(fillBucketAndProcessQueue()));
-
- connect(&socket, SIGNAL(connected()), this, SLOT(socketInitialized()));
- connect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
- connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)));
- connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
- connect(&socket, SIGNAL(readyRead()), this, SLOT(socketHasData()));
+CoreNetwork::CoreNetwork(const NetworkId& networkid, CoreSession* session)
+ : Network(networkid, session)
+ , _coreSession(session)
+ , _userInputHandler(new CoreUserInputHandler(this))
+ , _metricsServer(Core::instance()->metricsServer())
+ , _autoReconnectCount(0)
+ , _quitRequested(false)
+ , _disconnectExpected(false)
+ , _previousConnectionAttemptFailed(false)
+ , _lastUsedServerIndex(0)
+ , _requestedUserModes('-')
+{
+ // Check if raw IRC logging is enabled
+ _debugLogRawIrc = (Quassel::isOptionSet("debug-irc") || Quassel::isOptionSet("debug-irc-id"));
+ _debugLogRawNetId = Quassel::optionValue("debug-irc-id").toInt();
+
+ _autoReconnectTimer.setSingleShot(true);
+ connect(&_socketCloseTimer, &QTimer::timeout, this, &CoreNetwork::onSocketCloseTimeout);
+
+ setPingInterval(networkConfig()->pingInterval());
+ connect(&_pingTimer, &QTimer::timeout, this, &CoreNetwork::sendPing);
+
+ setAutoWhoDelay(networkConfig()->autoWhoDelay());
+ setAutoWhoInterval(networkConfig()->autoWhoInterval());
+
+ QHash<QString, QString> channels = coreSession()->persistentChannels(networkId());
+ for (const QString& chan : channels.keys()) {
+ _channelKeys[chan.toLower()] = channels[chan];
+ }
+
+ QHash<QString, QByteArray> bufferCiphers = coreSession()->bufferCiphers(networkId());
+ for (const QString& buffer : bufferCiphers.keys()) {
+ storeChannelCipherKey(buffer.toLower(), bufferCiphers[buffer]);
+ }
+
+ connect(networkConfig(), &NetworkConfig::pingTimeoutEnabledSet, this, &CoreNetwork::enablePingTimeout);
+ connect(networkConfig(), &NetworkConfig::pingIntervalSet, this, &CoreNetwork::setPingInterval);
+ connect(networkConfig(), &NetworkConfig::autoWhoEnabledSet, this, &CoreNetwork::setAutoWhoEnabled);
+ connect(networkConfig(), &NetworkConfig::autoWhoIntervalSet, this, &CoreNetwork::setAutoWhoInterval);
+ connect(networkConfig(), &NetworkConfig::autoWhoDelaySet, this, &CoreNetwork::setAutoWhoDelay);
+
+ connect(&_autoReconnectTimer, &QTimer::timeout, this, &CoreNetwork::doAutoReconnect);
+ connect(&_autoWhoTimer, &QTimer::timeout, this, &CoreNetwork::sendAutoWho);
+ connect(&_autoWhoCycleTimer, &QTimer::timeout, this, &CoreNetwork::startAutoWhoCycle);
+ connect(&_tokenBucketTimer, &QTimer::timeout, this, &CoreNetwork::checkTokenBucket);
+
+ connect(&socket, &QAbstractSocket::connected, this, &CoreNetwork::onSocketInitialized);
+ connect(&socket, selectOverload<QAbstractSocket::SocketError>(&QAbstractSocket::error), this, &CoreNetwork::onSocketError);
+ connect(&socket, &QAbstractSocket::stateChanged, this, &CoreNetwork::onSocketStateChanged);
+ connect(&socket, &QIODevice::readyRead, this, &CoreNetwork::onSocketHasData);