Commit d9a5317a authored by jpetrell's avatar jpetrell

[vpn] Store VPN types in generic strings instead of hard-coded enums. Contributes to JB#40883

parent 813b0e9a
......@@ -48,14 +48,6 @@ QHash<QString, QList<QPair<QVariant, QVariant> > > propertyConversions()
{
QHash<QString, QList<QPair<QVariant, QVariant> > > rv;
QList<QPair<QVariant, QVariant> > types;
types.push_back(qMakePair(QVariant::fromValue(QString("openvpn")), QVariant::fromValue(static_cast<int>(VpnModel::OpenVPN))));
types.push_back(qMakePair(QVariant::fromValue(QString("openconnect")), QVariant::fromValue(static_cast<int>(VpnModel::OpenConnect))));
types.push_back(qMakePair(QVariant::fromValue(QString("vpnc")), QVariant::fromValue(static_cast<int>(VpnModel::VPNC))));
types.push_back(qMakePair(QVariant::fromValue(QString("l2tp")), QVariant::fromValue(static_cast<int>(VpnModel::L2TP))));
types.push_back(qMakePair(QVariant::fromValue(QString("pptp")), QVariant::fromValue(static_cast<int>(VpnModel::PPTP))));
rv.insert(QString("type"), types);
QList<QPair<QVariant, QVariant> > states;
states.push_back(qMakePair(QVariant::fromValue(QString("idle")), QVariant::fromValue(static_cast<int>(VpnModel::Idle))));
states.push_back(qMakePair(QVariant::fromValue(QString("failure")), QVariant::fromValue(static_cast<int>(VpnModel::Failure))));
......@@ -733,13 +725,13 @@ QVariantMap VpnModel::connectionSettings(const QString &path)
return rv;
}
QVariantMap VpnModel::processProvisioningFile(const QString &path, ConnectionType type)
QVariantMap VpnModel::processProvisioningFile(const QString &path, const QString &type)
{
QVariantMap rv;
QFile provisioningFile(path);
if (provisioningFile.open(QIODevice::ReadOnly)) {
if (type == OpenVPN) {
if (type == QString("openvpn")) {
rv = processOpenVpnProvisioningFile(provisioningFile);
} else {
qWarning() << "Provisioning not currently supported for VPN type:" << type;
......@@ -1109,7 +1101,7 @@ VpnConnection::VpnConnection(const QString &path)
: QObject(0)
, path_(path)
, state_(static_cast<int>(VpnModel::Disconnect))
, type_(static_cast<int>(VpnModel::OpenVPN))
, type_("openvpn")
{
}
......@@ -50,7 +50,6 @@ class SYSTEMSETTINGS_EXPORT VpnModel : public ObjectListModel
{
Q_OBJECT
Q_ENUMS(ConnectionState)
Q_ENUMS(ConnectionType)
Q_PROPERTY(int bestState READ bestState NOTIFY bestStateChanged)
......@@ -63,14 +62,6 @@ public:
Disconnect,
};
enum ConnectionType {
OpenVPN,
OpenConnect,
VPNC,
L2TP,
PPTP,
};
explicit VpnModel(QObject *parent = 0);
virtual ~VpnModel();
......@@ -93,7 +84,7 @@ public:
Q_INVOKABLE QVariantMap connectionSettings(const QString &path);
Q_INVOKABLE QVariantMap processProvisioningFile(const QString &path, ConnectionType type);
Q_INVOKABLE QVariantMap processProvisioningFile(const QString &path, const QString &type);
VpnConnection *connection(const QString &path) const;
......@@ -167,7 +158,7 @@ class SYSTEMSETTINGS_EXPORT VpnConnection : public QObject
Q_PROPERTY(bool automaticUpDown READ automaticUpDown WRITE setAutomaticUpDown NOTIFY automaticUpDownChanged)
Q_PROPERTY(bool storeCredentials READ storeCredentials WRITE setStoreCredentials NOTIFY storeCredentialsChanged)
Q_PROPERTY(int state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(int type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(bool immutable READ immutable WRITE setImmutable NOTIFY immutableChanged)
Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged)
Q_PROPERTY(QVariantMap iPv4 READ iPv4 WRITE setIPv4 NOTIFY iPv4Changed)
......@@ -203,8 +194,8 @@ public:
int state() const { return state_; }
void setState(int state) { updateMember(&VpnConnection::state_, state, &VpnConnection::stateChanged); }
int type() const { return type_; }
void setType(int type) { updateMember(&VpnConnection::type_, type, &VpnConnection::typeChanged); }
QString type() const { return type_; }
void setType(const QString &type) { updateMember(&VpnConnection::type_, type, &VpnConnection::typeChanged); }
bool immutable() const { return immutable_; }
void setImmutable(bool immutable) { updateMember(&VpnConnection::immutable_, immutable, &VpnConnection::immutableChanged); }
......@@ -262,7 +253,7 @@ private:
QString path_;
QString name_;
int state_;
int type_;
QString type_;
QString host_;
QString domain_;
QString networks_;
......@@ -279,6 +270,5 @@ private:
};
Q_DECLARE_METATYPE(VpnModel::ConnectionState)
Q_DECLARE_METATYPE(VpnModel::ConnectionType)
#endif
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