diff --git a/libs/editor/settings/setting_p.h b/libs/editor/settings/setting_p.h new file mode 100644 index 00000000..7dd1163e --- /dev/null +++ b/libs/editor/settings/setting_p.h @@ -0,0 +1,31 @@ +/* + Copyright 2018 Jan Grulich + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +#include "setting.h" + +class SettingPrivate +{ +public: + explicit SettingPrivate(const NetworkManager::Setting::Ptr &setting, NetworkManager::Setting::SettingType type) + : type(type) + { Q_UNUSED(setting);} + NetworkManager::Setting::SettingType type; +}; + diff --git a/libs/editor/settings/wirelesssetting.cpp b/libs/editor/settings/wirelesssetting.cpp new file mode 100644 index 00000000..61ea1f2f --- /dev/null +++ b/libs/editor/settings/wirelesssetting.cpp @@ -0,0 +1,186 @@ +/* + Copyright 2018 Jan Grulich + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +#include "setting_p.h" +#include "wirelesssetting.h" + +#include + +class WirelessSettingPrivate : public SettingPrivate +{ +public: + explicit WirelessSettingPrivate(const NetworkManager::Setting::Ptr &setting, NetworkManager::Setting::SettingType type) + : SettingPrivate(setting, type) + { + wirelessSetting = setting.dynamicCast(); + } + NetworkManager::WirelessSetting::Ptr wirelessSetting; +}; + +WirelessSetting::WirelessSetting(const NetworkManager::Setting::Ptr &setting, QObject *parent) + : Setting(setting, parent) + , d_ptr(new WirelessSettingPrivate(setting, setting->type())) +{ +} + +WirelessSetting::~WirelessSetting() +{ + delete d_ptr; +} + +// void WirelessSetting::loadConfig(const NetworkManager::Setting::Ptr &setting) +// { +// } +// +// QVariantMap WirelessSetting::setting() const +// { +// return QVariantMap(); +// } + +QString WirelessSetting::ssid() const +{ + Q_D(const WirelessSetting); + + return QString::fromUtf8(d->wirelessSetting->ssid()); +} + +void WirelessSetting::setSsid(const QString &ssid) +{ + Q_D(WirelessSetting); + + d->wirelessSetting->setSsid(ssid.toUtf8()); +} + +uint WirelessSetting::mode() const +{ + Q_D(const WirelessSetting); + + return d->wirelessSetting->mode(); +} + +void WirelessSetting::setMode(uint mode) +{ + Q_D(WirelessSetting); + + d->wirelessSetting->setMode((NetworkManager::WirelessSetting::NetworkMode) mode); +} + +QString WirelessSetting::bssid() const +{ + Q_D(const WirelessSetting); + + return NetworkManager::macAddressAsString(d->wirelessSetting->bssid()); +} + +void WirelessSetting::setBssid(const QString &bssid) +{ + Q_D(WirelessSetting); + + d->wirelessSetting->setBssid(bssid.toUtf8()); +} + +uint WirelessSetting::band() const +{ + Q_D(const WirelessSetting); + + return d->wirelessSetting->band(); +} + +void WirelessSetting::setBand(uint band) +{ + Q_D(WirelessSetting); + + d->wirelessSetting->setBand((NetworkManager::WirelessSetting::FrequencyBand) band); +} + +uint WirelessSetting::channel() const +{ + Q_D(const WirelessSetting); + + return d->wirelessSetting->channel(); +} + +void WirelessSetting::setChannel(uint channel) +{ + Q_D(WirelessSetting); + + d->wirelessSetting->setChannel(channel); +} + +QString WirelessSetting::macAddress() const +{ + Q_D(const WirelessSetting); + + return NetworkManager::macAddressAsString(d->wirelessSetting->macAddress()); +} + +void WirelessSetting::setMacAddress(const QString &macAddress) +{ + Q_D(WirelessSetting); + + d->wirelessSetting->setMacAddress(NetworkManager::macAddressFromString(macAddress)); +} + +QString WirelessSetting::assignedMacAddress() const +{ + Q_D(const WirelessSetting); + + return d->wirelessSetting->assignedMacAddress(); +} + +void WirelessSetting::setAssignedMacAddress(const QString &assignedMacAddress) +{ + Q_D(WirelessSetting); + + d->wirelessSetting->setAssignedMacAddress(assignedMacAddress); +} + +uint WirelessSetting::mtu() const +{ + Q_D(const WirelessSetting); + + return d->wirelessSetting->mtu(); +} + +void WirelessSetting::setMtu(uint mtu) +{ + Q_D(WirelessSetting); + + d->wirelessSetting->setMtu(mtu); +} + +bool WirelessSetting::hidden() const +{ + Q_D(const WirelessSetting); + + return d->wirelessSetting->hidden(); +} + +void WirelessSetting::setHidden(bool hidden) +{ + Q_D(WirelessSetting); + + d->wirelessSetting->setHidden(hidden); +} + +bool WirelessSetting::isValid() const +{ + return true; +} diff --git a/libs/editor/settings/wirelesssetting.h b/libs/editor/settings/wirelesssetting.h new file mode 100644 index 00000000..17718139 --- /dev/null +++ b/libs/editor/settings/wirelesssetting.h @@ -0,0 +1,94 @@ +/* + Copyright 2018 Jan Grulich + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +#ifndef PLASMA_NM_WIRELESS_SETTING_H +#define PLASMA_NM_WIRELESS_SETTING_H + +#include "setting.h" + +class QObject; + +class WirelessSettingPrivate; + +#include + +class WirelessSetting : public Setting +{ + Q_OBJECT + Q_PROPERTY(QString ssid READ ssid WRITE setSsid) + Q_PROPERTY(uint mode READ mode WRITE setMode) + Q_PROPERTY(QString bssid READ bssid WRITE setBssid) + Q_PROPERTY(uint band READ band WRITE setBand) + Q_PROPERTY(uint channel READ channel WRITE setChannel) + Q_PROPERTY(QString macAddress READ macAddress WRITE setMacAddress) + Q_PROPERTY(QString assignedMacAddress READ assignedMacAddress WRITE setAssignedMacAddress) + Q_PROPERTY(uint mtu READ mtu WRITE setMtu) + Q_PROPERTY(bool hidden READ hidden WRITE setHidden) +public: + explicit WirelessSetting(const NetworkManager::Setting::Ptr &setting = NetworkManager::WirelessSetting::Ptr(), QObject *parent = nullptr); + virtual ~WirelessSetting(); + +// virtual void loadConfig(const NetworkManager::Setting::Ptr &setting) override; +// virtual void loadSecrets(const NetworkManager::Setting::Ptr &setting) = 0; + +// virtual QVariantMap setting() const override; + + QString ssid() const; + void setSsid(const QString &ssid); + + uint mode() const; + void setMode(uint mode); + + QString bssid() const; + void setBssid(const QString &bssid); + + uint band() const; + void setBand(uint band); + + uint channel() const; + void setChannel(uint channel); + + QString macAddress() const; + void setMacAddress(const QString &macAddress); + + QString assignedMacAddress() const; + void setAssignedMacAddress(const QString &assignedMacAddress); + + uint mtu() const; + void setMtu(uint mtu); + + bool hidden() const; + void setHidden(bool hidden); + + bool isValid() const override; + +Q_SIGNALS: + void changed(); + void validityChanged(bool valid); + +protected: + WirelessSettingPrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(WirelessSetting) + +}; + +#endif // PLASMA_NM_WIRELESS_SETTING_H