Commit 97fd9546 authored by Raine Makelainen's avatar Raine Makelainen

Merge branch 'jb48087' into 'master'

[settings-vpn] Remove obsoleted signal from use. Contributes to JB#48087

See merge request mer-core/nemo-qml-plugin-systemsettings!128
parents 2b7582e4 8f579391
......@@ -49,8 +49,16 @@ const auto legacyDefaultDomain(QStringLiteral("merproject.org"));
int numericValue(VpnConnection::ConnectionState state)
{
return (state == VpnConnection::Ready ? 3 :
(state == VpnConnection::Configuration ? 2 :
(state == VpnConnection::Failure ? 1 : 0)));
(state == VpnConnection::Configuration ? 2 : 0));
}
VpnConnection::ConnectionState getMaxState(VpnConnection::ConnectionState newState, VpnConnection::ConnectionState oldState)
{
if (numericValue(newState) > numericValue(oldState)) {
return newState;
}
return oldState;
}
} // end anonymous namespace
......@@ -71,7 +79,6 @@ SettingsVpnModel::SettingsVpnModel(QObject* parent)
connect(manager, &VpnManager::connectionAdded, this, &SettingsVpnModel::connectionAdded, Qt::UniqueConnection);
connect(manager, &VpnManager::connectionRemoved, this, &SettingsVpnModel::connectionRemoved, Qt::UniqueConnection);
connect(manager, &VpnManager::connectionsRefreshed, this, &SettingsVpnModel::connectionsRefreshed, Qt::UniqueConnection);
connect(manager, &VpnManager::connectionsClearingAll, this, &SettingsVpnModel::connectionsClearingAll, Qt::UniqueConnection);
}
SettingsVpnModel::~SettingsVpnModel()
......@@ -321,25 +328,22 @@ void SettingsVpnModel::connectionRemoved(const QString &path)
}
}
void SettingsVpnModel::connectionsClearingAll()
{
qCDebug(lcVpnLog) << "VPN clearing all connections";
QVector<VpnConnection*> connections = vpnManager()->connections();
for (VpnConnection *conn : connections) {
disconnect(conn, 0, this, 0);
}
}
void SettingsVpnModel::connectionsRefreshed()
{
qCDebug(lcVpnLog) << "VPN connections refreshed";
QVector<VpnConnection*> connections = vpnManager()->connections();
// Check to see if the best state has changed
VpnConnection::ConnectionState maxState = VpnConnection::Idle;
for (VpnConnection *conn : connections) {
connect(conn, &VpnConnection::nameChanged, this, &SettingsVpnModel::updatedConnectionPosition, Qt::UniqueConnection);
connect(conn, &VpnConnection::connectedChanged, this, &SettingsVpnModel::connectedChanged, Qt::UniqueConnection);
connect(conn, &VpnConnection::stateChanged, this, &SettingsVpnModel::stateChanged, Qt::UniqueConnection);
maxState = getMaxState(conn->state(), maxState);
}
updateBestState(maxState);
}
void SettingsVpnModel::stateChanged()
......@@ -349,17 +353,8 @@ void SettingsVpnModel::stateChanged()
emit connectionStateChanged(conn->path(), conn->state());
// Check to see if the best state has changed
VpnConnection::ConnectionState maxState = VpnConnection::Idle;
for (VpnConnection *conn : connections()) {
VpnConnection::ConnectionState state(conn->state());
if (numericValue(state) > numericValue(maxState)) {
maxState = state;
}
}
if (bestState_ != maxState) {
bestState_ = maxState;
emit bestStateChanged();
}
VpnConnection::ConnectionState maxState = getMaxState(conn->state(), VpnConnection::Idle);
updateBestState(maxState);
}
// ==========================================================================
......@@ -841,3 +836,11 @@ QVariantMap SettingsVpnModel::processOpenVpnProvisioningFile(QFile &provisioning
return rv;
}
void SettingsVpnModel::updateBestState(VpnConnection::ConnectionState maxState)
{
if (bestState_ != maxState) {
bestState_ = maxState;
emit bestStateChanged();
}
}
......@@ -98,11 +98,11 @@ private:
virtual void orderConnections(QVector<VpnConnection*> &connections) override;
bool compareConnections(const VpnConnection *i, const VpnConnection *j);
QVariantMap processOpenVpnProvisioningFile(QFile &provisioningFile);
void updateBestState(VpnConnection::ConnectionState maxState);
private Q_SLOTS:
void connectionAdded(const QString &path);
void connectionRemoved(const QString &path);
void connectionsClearingAll();
void connectionsRefreshed();
void updatedConnectionPosition();
void connectedChanged();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment