/***************************************************************************
- * Copyright (C) 2005-2014 by the Quassel Project *
+ * Copyright (C) 2005-2018 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
_reconnectTimer.setSingleShot(true);
connect(&_reconnectTimer, SIGNAL(timeout()), SLOT(reconnectTimeout()));
-#ifdef HAVE_KDE
- connect(Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)),
- SLOT(solidNetworkStatusChanged(Solid::Networking::Status)));
-#endif
+ _qNetworkConfigurationManager = new QNetworkConfigurationManager(this);
+ connect(_qNetworkConfigurationManager, SIGNAL(onlineStateChanged(bool)), SLOT(onlineStateChanged(bool)));
CoreConnectionSettings s;
s.initAndNotify("PingTimeoutInterval", this, SLOT(pingTimeoutIntervalChanged(QVariant)), 60);
if (!_peer) {
CoreConnectionSettings s;
if (_wantReconnect && s.autoReconnect()) {
-#ifdef HAVE_KDE
- // If using Solid, we don't want to reconnect if we're offline
- if (s.networkDetectionMode() == CoreConnectionSettings::UseSolid) {
- if (Solid::Networking::status() != Solid::Networking::Connected
- && Solid::Networking::status() != Solid::Networking::Unknown) {
+ // If using QNetworkConfigurationManager, we don't want to reconnect if we're offline
+ if (s.networkDetectionMode() == CoreConnectionSettings::UseQNetworkConfigurationManager) {
+ if (!_qNetworkConfigurationManager->isOnline()) {
return;
- }
+ }
}
-#endif /* HAVE_KDE */
-
reconnectToCore();
}
}
}
-#ifdef HAVE_KDE
-
-void CoreConnection::solidNetworkStatusChanged(Solid::Networking::Status status)
+void CoreConnection::onlineStateChanged(bool isOnline)
{
CoreConnectionSettings s;
- if (s.networkDetectionMode() != CoreConnectionSettings::UseSolid)
+ if (s.networkDetectionMode() != CoreConnectionSettings::UseQNetworkConfigurationManager)
return;
- switch (status) {
- case Solid::Networking::Unknown:
- case Solid::Networking::Connected:
- //qDebug() << "Solid: Network status changed to connected or unknown";
+ if(isOnline) {
+ // qDebug() << "QNetworkConfigurationManager reports Online";
if (state() == Disconnected) {
if (_wantReconnect && s.autoReconnect()) {
reconnectToCore();
}
}
- break;
- case Solid::Networking::Disconnecting:
- case Solid::Networking::Unconnected:
+ } else {
+ // qDebug() << "QNetworkConfigurationManager reports Offline";
if (state() != Disconnected && !isLocalConnection())
disconnectFromCore(tr("Network is down"), true);
- break;
- default:
- break;
}
}
-#endif
+
+QPointer<Peer> CoreConnection::peer() const
+{
+ if (_peer) {
+ return _peer;
+ }
+ return _authHandler ? _authHandler->peer() : nullptr;
+}
+
bool CoreConnection::isEncrypted() const
{
return false;
if (currentAccount().isInternal())
return true;
- if (_peer->isLocal())
- return true;
+ if (_authHandler)
+ return _authHandler->isLocal();
+ if (_peer)
+ return _peer->isLocal();
return false;
}
if (state != _state) {
_state = state;
emit stateChanged(state);
+ if (state == Connected)
+ _wantReconnect = true;
if (state == Disconnected)
emit disconnected();
}
return;
}
- resetConnection(false);
-
if (currentAccount().isInternal()) {
if (Quassel::runMode() != Quassel::Monolithic) {
qWarning() << "Cannot connect to internal core in client-only mode!";
return;
}
- emit startInternalCore();
InternalPeer *peer = new InternalPeer();
_peer = peer;
Client::instance()->signalProxy()->addPeer(peer); // sigproxy will take ownership
+ emit connectionMsg(tr("Initializing..."));
emit connectToInternalCore(peer);
setState(Connected);
-
return;
}
connect(_authHandler, SIGNAL(errorPopup(QString)), SIGNAL(connectionErrorPopup(QString)), Qt::QueuedConnection);
connect(_authHandler, SIGNAL(statusMessage(QString)), SIGNAL(connectionMsg(QString)));
connect(_authHandler, SIGNAL(encrypted(bool)), SIGNAL(encrypted(bool)));
- connect(_authHandler, SIGNAL(startCoreSetup(QVariantList)), SIGNAL(startCoreSetup(QVariantList)));
+ connect(_authHandler, SIGNAL(startCoreSetup(QVariantList, QVariantList)), SIGNAL(startCoreSetup(QVariantList, QVariantList)));
connect(_authHandler, SIGNAL(coreSetupFailed(QString)), SIGNAL(coreSetupFailed(QString)));
connect(_authHandler, SIGNAL(coreSetupSuccessful()), SIGNAL(coreSetupSuccess()));
connect(_authHandler, SIGNAL(userAuthenticationRequired(CoreAccount*,bool*,QString)), SIGNAL(userAuthenticationRequired(CoreAccount*,bool*,QString)));
void CoreConnection::internalSessionStateReceived(const Protocol::SessionState &sessionState)
{
updateProgress(100, 100);
-
- Client::setCoreFeatures(Quassel::features()); // mono connection...
-
setState(Synchronizing);
syncToCore(sessionState);
}