Commit bc32662b authored by Raine Makelainen's avatar Raine Makelainen

[nemo-systemsettings] Add readonly autoConnect property to the Vpn model. Contributes to JB#41419

The autoConnect property of VpnModel is true if there's at least one
vpn connection that has autoConnect true.
parent d374ea09
......@@ -319,6 +319,7 @@ VpnModel::VpnModel(QObject *parent)
, credentials_(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/system/privileged/vpn-data"))
, provisioningOutputPath_(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/system/privileged/vpn-provisioning"))
, bestState_(VpnModel::Idle)
, autoConnect_(false)
{
qDBusRegisterMetaType<PathProperties>();
qDBusRegisterMetaType<PathPropertiesArray>();
......@@ -390,6 +391,11 @@ int VpnModel::bestState() const
return static_cast<int>(bestState_);
}
bool VpnModel::autoConnect() const
{
return autoConnect_;
}
void VpnModel::createConnection(const QVariantMap &createProperties)
{
const QString path(createProperties.value(QString("path")).toString());
......@@ -883,6 +889,16 @@ void VpnModel::updateConnection(VpnConnection *conn, const QVariantMap &updatePr
}
}
}
bool autoConnect = false;
for (int i = 0; i < count(); ++i) {
autoConnect = autoConnect || get<VpnConnection>(i)->autoConnect();
}
if (autoConnect_ != autoConnect) {
autoConnect_ = autoConnect;
autoConnectChanged();
}
}
QVariantMap VpnModel::processOpenVpnProvisioningFile(QFile &provisioningFile)
......
......@@ -51,6 +51,7 @@ class SYSTEMSETTINGS_EXPORT VpnModel : public ObjectListModel
Q_OBJECT
Q_PROPERTY(int bestState READ bestState NOTIFY bestStateChanged)
Q_PROPERTY(bool autoConnect READ autoConnect NOTIFY autoConnectChanged)
public:
enum ConnectionState {
......@@ -66,6 +67,7 @@ public:
virtual ~VpnModel();
int bestState() const;
bool autoConnect() const;
Q_INVOKABLE void createConnection(const QVariantMap &properties);
Q_INVOKABLE void modifyConnection(const QString &path, const QVariantMap &properties);
......@@ -88,6 +90,7 @@ public:
signals:
void bestStateChanged();
void autoConnectChanged();
void connectionStateChanged(const QString &path, int state);
private:
......@@ -130,6 +133,8 @@ private:
CredentialsRepository credentials_;
QString provisioningOutputPath_;
ConnectionState bestState_;
// True if there's one VPN that has autoConnect true
bool autoConnect_;
};
class SYSTEMSETTINGS_EXPORT VpnConnection : public QObject
......
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