Пример #1
0
void CoreConnection::solidNetworkStatusChanged(Solid::Networking::Status status)
{
    CoreConnectionSettings s;
    if (s.networkDetectionMode() != CoreConnectionSettings::UseSolid)
        return;

    switch (status) {
    case Solid::Networking::Unknown:
    case Solid::Networking::Connected:
        //qDebug() << "Solid: Network status changed to connected or unknown";
        if (state() == Disconnected) {
            if (_wantReconnect && s.autoReconnect()) {
                reconnectToCore();
            }
        }
        break;
    case Solid::Networking::Disconnecting:
    case Solid::Networking::Unconnected:
        if (state() != Disconnected && !isLocalConnection())
            disconnectFromCore(tr("Network is down"), true);
        break;
    default:
        break;
    }
}
Пример #2
0
void CoreConnection::networkDetectionModeChanged(const QVariant &vmode)
{
    CoreConnectionSettings s;
    CoreConnectionSettings::NetworkDetectionMode mode = (CoreConnectionSettings::NetworkDetectionMode)vmode.toInt();
    if (mode == CoreConnectionSettings::UsePingTimeout)
        Client::signalProxy()->setMaxHeartBeatCount(s.pingTimeoutInterval() / 30);
    else {
        Client::signalProxy()->setMaxHeartBeatCount(-1);
    }
}
Пример #3
0
void CoreConnection::reconnectTimeout()
{
    if (!_peer) {
        CoreConnectionSettings s;
        if (_wantReconnect && s.autoReconnect()) {
            // If using QNetworkConfigurationManager, we don't want to reconnect if we're offline
            if (s.networkDetectionMode() == CoreConnectionSettings::UseQNetworkConfigurationManager) {
               if (!_qNetworkConfigurationManager->isOnline()) {
                    return;
               }
            }
            reconnectToCore();
        }
    }
}
Пример #4
0
void CoreConnection::init()
{
    Client::signalProxy()->setHeartBeatInterval(30);
    connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), SIGNAL(lagUpdated(int)));

    _reconnectTimer.setSingleShot(true);
    connect(&_reconnectTimer, SIGNAL(timeout()), SLOT(reconnectTimeout()));

    _qNetworkConfigurationManager = new QNetworkConfigurationManager(this);
    connect(_qNetworkConfigurationManager, SIGNAL(onlineStateChanged(bool)), SLOT(onlineStateChanged(bool)));

    CoreConnectionSettings s;
    s.initAndNotify("PingTimeoutInterval", this, SLOT(pingTimeoutIntervalChanged(QVariant)), 60);
    s.initAndNotify("ReconnectInterval", this, SLOT(reconnectIntervalChanged(QVariant)), 60);
    s.notify("NetworkDetectionMode", this, SLOT(networkDetectionModeChanged(QVariant)));
    networkDetectionModeChanged(s.networkDetectionMode());
}
Пример #5
0
void CoreConnection::init()
{
    Client::signalProxy()->setHeartBeatInterval(30);
    connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), SIGNAL(lagUpdated(int)));

    _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

    CoreConnectionSettings s;
    s.initAndNotify("PingTimeoutInterval", this, SLOT(pingTimeoutIntervalChanged(QVariant)), 60);
    s.initAndNotify("ReconnectInterval", this, SLOT(reconnectIntervalChanged(QVariant)), 60);
    s.notify("NetworkDetectionMode", this, SLOT(networkDetectionModeChanged(QVariant)));
    networkDetectionModeChanged(s.networkDetectionMode());
}
Пример #6
0
void CoreConnection::reconnectTimeout()
{
    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) {
                    return;
                }
            }
#endif /* HAVE_KDE */

            reconnectToCore();
        }
    }
}
Пример #7
0
void CoreConnection::onlineStateChanged(bool isOnline)
{
    CoreConnectionSettings s;
    if (s.networkDetectionMode() != CoreConnectionSettings::UseQNetworkConfigurationManager)
        return;

    if(isOnline) {
        // qDebug() << "QNetworkConfigurationManager reports Online";
        if (state() == Disconnected) {
            if (_wantReconnect && s.autoReconnect()) {
                reconnectToCore();
            }
        }
    } else {
        // qDebug() << "QNetworkConfigurationManager reports Offline";
        if (state() != Disconnected && !isLocalConnection())
            disconnectFromCore(tr("Network is down"), true);
    }
}
Пример #8
0
void CoreConnection::resetConnection(bool wantReconnect)
{
    if (_resetting)
        return;
    _resetting = true;

    _wantReconnect = wantReconnect;

    if (_authHandler) {
        disconnect(_authHandler, 0, this, 0);
        _authHandler->close();
        _authHandler->deleteLater();
        _authHandler = 0;
    }

    if (_peer) {
        disconnect(_peer, 0, this, 0);
        // peer belongs to the sigproxy and thus gets deleted by it
        _peer->close();
        _peer = 0;
    }

    _netsToSync.clear();
    _numNetsToSync = 0;

    setProgressMaximum(-1); // disable
    setState(Disconnected);
    emit lagUpdated(-1);

    emit connectionMsg(tr("Disconnected from core."));
    emit encrypted(false);
    setState(Disconnected);

    // initiate if a reconnect if appropriate
    CoreConnectionSettings s;
    if (wantReconnect && s.autoReconnect()) {
        _reconnectTimer.start();
    }

    _resetting = false;
}
Пример #9
0
void CoreConnection::pingTimeoutIntervalChanged(const QVariant &interval)
{
    CoreConnectionSettings s;
    if (s.networkDetectionMode() == CoreConnectionSettings::UsePingTimeout)
        Client::signalProxy()->setMaxHeartBeatCount(interval.toInt() / 30);  // interval is 30 seconds
}
void CoreConnectionSettingsPage::save() {
  _detectionMode = modeFromRadioButtons();
  CoreConnectionSettings s;
  s.setNetworkDetectionMode(_detectionMode);
  SettingsPage::save();
}
void CoreConnectionSettingsPage::load() {
  CoreConnectionSettings s;
  _detectionMode = s.networkDetectionMode();
  setRadioButtons(_detectionMode);
  SettingsPage::load();
}