Merge branch 'new-dbus' into 'dbus-interface'
add wifi list sort && dbus interface See merge request kylin-desktop/kylin-nm!188
This commit is contained in:
commit
0d23cc614a
|
@ -365,7 +365,9 @@ void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & devIface,
|
|||
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (!isHidden && wifiNet.isNull()) {
|
||||
qDebug() << "addAndActiveWirelessConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -456,7 +458,9 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapM
|
|||
if (!isHidden) {
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull()) {
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTlsConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -510,7 +514,9 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEap
|
|||
{
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull()) {
|
||||
qDebug() << "addAndActiveWirelessEnterPrisePeapConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -562,7 +568,9 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
|
|||
if (!isHidden) {
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull()) {
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT activateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
#include "kywirelessnetresource.h"
|
||||
|
||||
static bool subWifiListSort(const KyWirelessNetItem info1, const KyWirelessNetItem info2)
|
||||
{
|
||||
if (info1.m_isConfigured == info2.m_isConfigured) {
|
||||
return info1.m_signalStrength >info2.m_signalStrength;
|
||||
}
|
||||
return info1.m_isConfigured;
|
||||
}
|
||||
|
||||
static void wifiListSort(QList<KyWirelessNetItem> &list)
|
||||
{
|
||||
qSort(list.begin(), list.end(), subWifiListSort);
|
||||
}
|
||||
|
||||
KyWirelessNetResource::KyWirelessNetResource(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
@ -32,6 +45,11 @@ bool KyWirelessNetResource::getAllDeviceWifiNetwork(QMap<QString,QList<KyWireles
|
|||
if (m_WifiNetworkList.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
QMap<QString, QList<KyWirelessNetItem> >::iterator iter = m_WifiNetworkList.begin();
|
||||
while (iter != m_WifiNetworkList.end()) {
|
||||
wifiListSort(m_WifiNetworkList[iter.key()]);
|
||||
iter++;
|
||||
}
|
||||
map = m_WifiNetworkList;
|
||||
return true;
|
||||
}
|
||||
|
@ -45,6 +63,7 @@ bool KyWirelessNetResource::getDeviceWifiNetwork(QString devIfaceName, QList<KyW
|
|||
if (!m_WifiNetworkList.contains(devIfaceName)) {
|
||||
return false;
|
||||
} else {
|
||||
wifiListSort(m_WifiNetworkList[devIfaceName]);
|
||||
wirelessNetResource = m_WifiNetworkList[devIfaceName];
|
||||
return true;
|
||||
}
|
||||
|
@ -77,21 +96,17 @@ void KyWirelessNetResource::getWirelessActiveConnection(NetworkManager::ActiveCo
|
|||
map.clear();
|
||||
activeConnectionList.clear();
|
||||
activeConnectionList = m_networkResourceInstance->m_activeConns;
|
||||
if (activeConnectionList.isEmpty())
|
||||
{
|
||||
if (activeConnectionList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectionPtr = nullptr;
|
||||
for (; index < activeConnectionList.size(); index++)
|
||||
{
|
||||
for (; index < activeConnectionList.size(); index++) {
|
||||
activeConnectionPtr = activeConnectionList.at(index);
|
||||
if (NetworkManager::ConnectionSettings::ConnectionType::Wireless != activeConnectionPtr->type())
|
||||
{
|
||||
if (NetworkManager::ConnectionSettings::ConnectionType::Wireless != activeConnectionPtr->type()) {
|
||||
continue;
|
||||
}
|
||||
if (state != activeConnectionPtr->state())
|
||||
{
|
||||
if (state != activeConnectionPtr->state()) {
|
||||
continue;
|
||||
}
|
||||
QString ssid;
|
||||
|
@ -130,14 +145,12 @@ void KyWirelessNetResource::kyWirelessNetItemListInit()
|
|||
if (devIface.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
KyWirelessNetItem item(net);
|
||||
if (!m_WifiNetworkList.contains(devIface)){
|
||||
QList<KyWirelessNetItem> list;
|
||||
KyWirelessNetItem item(net);
|
||||
list.append(item);
|
||||
m_WifiNetworkList.insert(devIface,list);
|
||||
} else {
|
||||
KyWirelessNetItem item(net);
|
||||
m_WifiNetworkList[devIface].append(item);
|
||||
}
|
||||
}
|
||||
|
@ -147,14 +160,12 @@ void KyWirelessNetResource::kyWirelessNetItemListInit()
|
|||
|
||||
QString KyWirelessNetResource::getDeviceIFace(NetworkManager::WirelessNetwork::Ptr net)
|
||||
{
|
||||
if (net.isNull())
|
||||
{
|
||||
if (net.isNull()) {
|
||||
return "";
|
||||
}
|
||||
QString devUni = net->device();
|
||||
NetworkManager::Device::Ptr dev = m_networkResourceInstance->findDeviceUni(devUni);
|
||||
if (dev.isNull())
|
||||
{
|
||||
if (dev.isNull()) {
|
||||
qDebug() << "KyWirelessNetResource: can't find " << net->ssid() << " find in device list";
|
||||
return "";
|
||||
}
|
||||
|
@ -194,22 +205,18 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::WirelessNetwork::P
|
|||
void KyWirelessNetResource::onWifiNetworkAdded(QString devIfaceName, QString ssid)
|
||||
{
|
||||
NetworkManager::WirelessNetwork::Ptr wifi = nullptr;
|
||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
||||
{
|
||||
if (net->ssid() == ssid && m_networkResourceInstance->findDeviceUni(net->device())->interfaceName() == devIfaceName )
|
||||
{
|
||||
for (auto const & net : m_networkResourceInstance->m_wifiNets) {
|
||||
if (net->ssid() == ssid && m_networkResourceInstance->findDeviceUni(net->device())->interfaceName() == devIfaceName) {
|
||||
wifi = net;
|
||||
}
|
||||
}
|
||||
|
||||
if (wifi.isNull())
|
||||
{
|
||||
if (wifi.isNull()) {
|
||||
return;
|
||||
}
|
||||
KyWirelessNetItem item(wifi);
|
||||
|
||||
if (m_WifiNetworkList.contains(devIfaceName))
|
||||
{
|
||||
if (m_WifiNetworkList.contains(devIfaceName)) {
|
||||
m_WifiNetworkList[devIfaceName].append(item);
|
||||
} else {
|
||||
QList<KyWirelessNetItem> list;
|
||||
|
@ -222,19 +229,15 @@ void KyWirelessNetResource::onWifiNetworkAdded(QString devIfaceName, QString ssi
|
|||
|
||||
void KyWirelessNetResource::onWifiNetworkRemoved(QString devIfaceName, QString ssid)
|
||||
{
|
||||
if (m_WifiNetworkList.contains(devIfaceName))
|
||||
{
|
||||
if (m_WifiNetworkList.contains(devIfaceName)) {
|
||||
int index = 0;
|
||||
for ( ; index < m_WifiNetworkList.value(devIfaceName).size(); index++)
|
||||
{
|
||||
if ( m_WifiNetworkList[devIfaceName].at(index).m_NetSsid == ssid)
|
||||
{
|
||||
for ( ; index < m_WifiNetworkList.value(devIfaceName).size(); index++) {
|
||||
if ( m_WifiNetworkList[devIfaceName].at(index).m_NetSsid == ssid) {
|
||||
m_WifiNetworkList[devIfaceName].removeAt(index);
|
||||
}
|
||||
}
|
||||
//remove后为空则删除
|
||||
if (m_WifiNetworkList.value(devIfaceName).isEmpty())
|
||||
{
|
||||
if (m_WifiNetworkList.value(devIfaceName).isEmpty()) {
|
||||
m_WifiNetworkList.remove(devIfaceName);
|
||||
}
|
||||
emit wifiNetworkRemove(devIfaceName,ssid);
|
||||
|
@ -248,29 +251,24 @@ void KyWirelessNetResource::onWifiNetworkPropertyChange(NetworkManager::Wireless
|
|||
}
|
||||
|
||||
QString devIface = m_networkResourceInstance->findDeviceUni(net->device())->interfaceName();
|
||||
if (m_WifiNetworkList.contains(devIface))
|
||||
{
|
||||
if (m_WifiNetworkList.contains(devIface)) {
|
||||
QList<KyWirelessNetItem>::iterator iter = m_WifiNetworkList[devIface].begin();
|
||||
while (iter != m_WifiNetworkList[devIface].end())
|
||||
{
|
||||
if (iter->m_NetSsid == net->ssid())
|
||||
{
|
||||
while (iter != m_WifiNetworkList[devIface].end()) {
|
||||
if (iter->m_NetSsid == net->ssid()) {
|
||||
qDebug()<<"recive properity changed signal, sender is" << iter->m_NetSsid;
|
||||
if (iter->m_signalStrength != net->signalStrength())
|
||||
{
|
||||
if (iter->m_signalStrength != net->signalStrength()) {
|
||||
iter->m_signalStrength = net->signalStrength();
|
||||
emit signalStrengthChange(devIface, net->ssid(), iter->m_signalStrength);
|
||||
}
|
||||
|
||||
if (iter->m_bssid != net->referenceAccessPoint()->hardwareAddress())
|
||||
{
|
||||
if (iter->m_bssid != net->referenceAccessPoint()->hardwareAddress()) {
|
||||
iter->m_bssid = net->referenceAccessPoint()->hardwareAddress();
|
||||
emit bssidChange(devIface, net->ssid(), iter->m_bssid);
|
||||
}
|
||||
|
||||
QString secuType = enumToQstring(net->referenceAccessPoint()->capabilities(), net->referenceAccessPoint()->wpaFlags(), net->referenceAccessPoint()->rsnFlags());
|
||||
if (iter->m_secuType != secuType)
|
||||
{
|
||||
QString secuType = enumToQstring(net->referenceAccessPoint()->capabilities(),
|
||||
net->referenceAccessPoint()->wpaFlags(), net->referenceAccessPoint()->rsnFlags());
|
||||
if (iter->m_secuType != secuType) {
|
||||
iter->m_secuType = secuType;
|
||||
emit secuTypeChange(devIface, net->ssid(), secuType);
|
||||
}
|
||||
|
@ -291,44 +289,33 @@ void KyWirelessNetResource::onWifiNetworkDeviceDisappear()
|
|||
bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info)
|
||||
{
|
||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
||||
if (conn.isNull())
|
||||
{
|
||||
if (conn.isNull()) {
|
||||
qDebug() << "modifyEnterPriseInfoTls connection missing";
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
if (security_sett.isNull())
|
||||
{
|
||||
if (security_sett.isNull()) {
|
||||
qDebug() << "don't have WirelessSecurity connection";
|
||||
return false;
|
||||
}
|
||||
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap)
|
||||
{
|
||||
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
|
||||
return false;
|
||||
}
|
||||
NetworkManager::Security8021xSetting::Ptr setting = conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
if (setting.isNull())
|
||||
{
|
||||
if (setting.isNull()) {
|
||||
qDebug() << "don't have Security8021x connection";
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTls);
|
||||
setting->setEapMethods(list);
|
||||
setting->setIdentity(info.identity);
|
||||
if(!info.domain.isEmpty())
|
||||
{
|
||||
setting->setDomainSuffixMatch(info.domain);
|
||||
}
|
||||
setting->setCaPath(info.caCertPath);
|
||||
setting->setClientCertificate(info.clientCertPath.toLocal8Bit());
|
||||
setting->setPrivateKey(info.clientPrivateKey.toLocal8Bit());
|
||||
setting->setPrivateKeyPassword(info.clientPrivateKeyPWD);
|
||||
info.identity = setting->identity();
|
||||
info.domain = setting->domainSuffixMatch();
|
||||
|
||||
conn->update(conn->settings()->toMap());
|
||||
info.caCertPath = setting->caPath();
|
||||
info.clientCertPath = setting->clientCertificate();
|
||||
info.clientPrivateKey = QString(setting->privateKey());
|
||||
info.clientPrivateKeyPWD = setting->privateKeyPassword();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -336,26 +323,22 @@ bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsIn
|
|||
bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info)
|
||||
{
|
||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
||||
if (conn.isNull())
|
||||
{
|
||||
if (conn.isNull()) {
|
||||
qDebug() << "getEnterPriseInfoPeap connection missing";
|
||||
return false;
|
||||
}
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
if (security_sett.isNull())
|
||||
{
|
||||
if (security_sett.isNull()) {
|
||||
qDebug() << "don't have WirelessSecurity connection";
|
||||
return false;
|
||||
}
|
||||
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap)
|
||||
{
|
||||
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
|
||||
qDebug() << "keyMgmt not WpaEap " << security_sett->keyMgmt();
|
||||
return false;
|
||||
}
|
||||
NetworkManager::Security8021xSetting::Ptr setting = conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap))
|
||||
{
|
||||
if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap)) {
|
||||
qDebug() << "don't have Security8021x connection";
|
||||
return false;
|
||||
}
|
||||
|
@ -370,28 +353,24 @@ bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeap
|
|||
bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info)
|
||||
{
|
||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
||||
if (conn.isNull())
|
||||
{
|
||||
if (conn.isNull()) {
|
||||
qDebug() << "modifyEnterPriseInfoTtls connection missing";
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
if (security_sett.isNull())
|
||||
{
|
||||
if (security_sett.isNull()) {
|
||||
qDebug() << "don't have WirelessSecurity connection";
|
||||
return false;
|
||||
}
|
||||
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap)
|
||||
{
|
||||
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
|
||||
qDebug() << "not wpaeap"<<security_sett->keyMgmt();
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr setting = conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls))
|
||||
{
|
||||
if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls)) {
|
||||
qDebug() << "don't have Security8021x connection";
|
||||
return false;
|
||||
}
|
||||
|
@ -400,8 +379,7 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls
|
|||
info.authNoEapMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod();
|
||||
|
||||
info.authType = KyTtlsAuthMethod::AUTH_EAP;
|
||||
if (info.authEapMethod != KyAuthEapMethodUnknown)
|
||||
{
|
||||
if (info.authEapMethod != KyAuthEapMethodUnknown) {
|
||||
info.authType = KyTtlsAuthMethod::AUTH_EAP;
|
||||
} else {
|
||||
info.authType = KyTtlsAuthMethod::AUTH_NO_EAP;
|
||||
|
@ -417,14 +395,12 @@ void KyWirelessNetResource::onConnectionAdd(QString uuid)
|
|||
{
|
||||
qDebug() << "onConnectionAdd " << uuid;
|
||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
||||
if (conn.isNull())
|
||||
{
|
||||
if (conn.isNull()) {
|
||||
qDebug() << "onConnectionAdd can not find connection" << uuid;
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr sett= conn->settings();
|
||||
if (sett->connectionType() != NetworkManager::ConnectionSettings::ConnectionType::Wireless)
|
||||
{
|
||||
if (sett->connectionType() != NetworkManager::ConnectionSettings::ConnectionType::Wireless) {
|
||||
return;
|
||||
}
|
||||
NetworkManager::WirelessSetting::Ptr wireless_sett = sett->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
|
@ -469,8 +445,7 @@ void KyWirelessNetResource::onConnectionRemove(QString path)
|
|||
while (iter != m_WifiNetworkList.end())
|
||||
{
|
||||
qDebug() << iter.key();
|
||||
for(int i = 0; i < iter.value().size(); i++)
|
||||
{
|
||||
for(int i = 0; i < iter.value().size(); i++) {
|
||||
qDebug() << iter.value().at(i).m_connDbusPath;
|
||||
if (iter.value().at(i).m_connDbusPath == path)
|
||||
{
|
||||
|
@ -504,14 +479,13 @@ void KyWirelessNetResource::onConnectionUpdate(QString uuid)
|
|||
{
|
||||
qDebug() << "onConnectionUpdate " << uuid;
|
||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
||||
if (conn.isNull())
|
||||
{
|
||||
if (conn.isNull()) {
|
||||
qDebug() << "onConnectionAdd can not find connection" << uuid;
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr sett= conn->settings();
|
||||
if (sett->connectionType() != NetworkManager::ConnectionSettings::ConnectionType::Wireless)
|
||||
{
|
||||
if (sett->connectionType() != NetworkManager::ConnectionSettings::ConnectionType::Wireless) {
|
||||
return;
|
||||
}
|
||||
m_WifiNetworkList.clear();
|
||||
|
|
|
@ -17,6 +17,61 @@
|
|||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
const QByteArray GSETTINGS_SCHEMA_KYLIN_NM = "org.ukui.kylin-nm.switch";
|
||||
const QString KEY_WIRELESS_SWITCH = "wirelessswitch";
|
||||
const QString KEY_WIRED_SWITCH = "wiredswitch";
|
||||
|
||||
void saveDeviceEnableState(QString deviceName, bool enable)
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("CARDEABLE");
|
||||
m_settings->setValue(deviceName, enable);
|
||||
m_settings->endGroup();
|
||||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
bool getDeviceEnableState(QMap<QString, bool> &map)
|
||||
{
|
||||
if (!QFile::exists(CONFIG_FILE_PATH)) {
|
||||
return false;
|
||||
}
|
||||
map.clear();
|
||||
|
||||
KyNetworkDeviceResourse * kdr = new KyNetworkDeviceResourse();
|
||||
QStringList wiredDevList,wirelessDevList;
|
||||
wiredDevList.clear();
|
||||
wirelessDevList.clear();
|
||||
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("CARDEABLE");
|
||||
|
||||
kdr->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDevList);
|
||||
if (!wiredDevList.isEmpty()) {
|
||||
for (int i = 0; i < wiredDevList.size(); ++i) {
|
||||
bool enable = m_settings->value(wiredDevList.at(i), true).toBool();
|
||||
map.insert(wiredDevList.at(i), enable);
|
||||
}
|
||||
}
|
||||
|
||||
kdr->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDevList);
|
||||
if (!wirelessDevList.isEmpty()) {
|
||||
for (int i = 0; i < wirelessDevList.size(); ++i) {
|
||||
bool enable = m_settings->value(wirelessDevList.at(i), true).toBool();
|
||||
map.insert(wirelessDevList.at(i), enable);
|
||||
}
|
||||
}
|
||||
|
||||
m_settings->endGroup();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
delete kdr;
|
||||
kdr = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of adaptor class DbusAdaptor
|
||||
*/
|
||||
|
@ -25,7 +80,11 @@ DbusAdaptor::DbusAdaptor(MainWindow *parent)
|
|||
: QDBusAbstractAdaptor(parent)
|
||||
{
|
||||
// constructor
|
||||
qDBusRegisterMetaType<QVector<QStringList>>();
|
||||
qDBusRegisterMetaType<QMap<QString, bool> >();
|
||||
qDBusRegisterMetaType<WirelessInfo>();
|
||||
qDBusRegisterMetaType<WiredInfo>();
|
||||
qDBusRegisterMetaType<QList<WirelessInfo> >();
|
||||
qDBusRegisterMetaType<QList<WiredInfo> >();
|
||||
//setAutoRelaySignals(true)后会自动转发mainwindow发出的同名信号,因此不必再额外写一个转发
|
||||
setAutoRelaySignals(true);
|
||||
}
|
||||
|
@ -35,21 +94,135 @@ DbusAdaptor::~DbusAdaptor()
|
|||
// destructor
|
||||
}
|
||||
|
||||
void DbusAdaptor::showMainWindow()
|
||||
//无线列表
|
||||
QList<WirelessInfo> DbusAdaptor::getWirelessList(QString devName)
|
||||
{
|
||||
parent()->showMainwindow();
|
||||
|
||||
}
|
||||
|
||||
void DbusAdaptor::showPb(QString type, QString name)
|
||||
//有线列表
|
||||
QList<WiredInfo> DbusAdaptor::getWiredList(QString devName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DbusAdaptor::requestRefreshWifiList()
|
||||
//有线开关
|
||||
void DbusAdaptor::setWiredSwitchEnable(bool enable)
|
||||
{
|
||||
//todo mainwindow调用backend 对开关 打开/关闭
|
||||
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) {
|
||||
QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM);
|
||||
gsetting->set(KEY_WIRED_SWITCH, enable);
|
||||
} else {
|
||||
qDebug()<<"isSchemaInstalled false";
|
||||
}
|
||||
}
|
||||
|
||||
QVector<QStringList> DbusAdaptor::getWifiList()
|
||||
//无线开关
|
||||
void DbusAdaptor::setWirelessSwitchEnable(bool enable)
|
||||
{
|
||||
return QVector<QStringList>();
|
||||
//todo mainwindow调用backend 对开关 打开/关闭
|
||||
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) {
|
||||
QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM);
|
||||
gsetting->set(KEY_WIRELESS_SWITCH, enable);
|
||||
delete gsetting;
|
||||
gsetting = nullptr;
|
||||
} else {
|
||||
qDebug()<<"isSchemaInstalled false";
|
||||
}
|
||||
}
|
||||
|
||||
//启用/禁用网卡
|
||||
void DbusAdaptor::setDeviceEnable(QString devName, bool enable)
|
||||
{
|
||||
saveDeviceEnableState(devName, enable);
|
||||
}
|
||||
|
||||
//设置默认网卡
|
||||
void DbusAdaptor::setDefaultWiredDevice(QString deviceName)
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wired");
|
||||
m_settings->setValue(key, deviceName);
|
||||
m_settings->endGroup();
|
||||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
parent()->setWiredDefaultDevice(deviceName);
|
||||
return;
|
||||
}
|
||||
|
||||
QString DbusAdaptor::getDefaultWiredDevice()
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wired");
|
||||
QString deviceName = m_settings->value(key, "").toString();
|
||||
m_settings->endGroup();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
void DbusAdaptor::setDefaultWirelessDevice(QString deviceName)
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wireless");
|
||||
m_settings->setValue(key, deviceName);
|
||||
m_settings->endGroup();
|
||||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
parent()->setWirelessDefaultDevice(deviceName);
|
||||
return;
|
||||
}
|
||||
|
||||
QString DbusAdaptor::getDefaultWirelessDevice()
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wireless");
|
||||
QString deviceName = m_settings->value(key, "").toString();
|
||||
m_settings->endGroup();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
//连接 根据网卡类型 参数2 为ssid/uuid
|
||||
void DbusAdaptor::activateConnect(QString devName, QString ssid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//断开连接 根据网卡类型 参数2 为ssid/uuid
|
||||
void DbusAdaptor::deActivateConnect(QString devName, QString ssid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//获取设备列表和启用/禁用状态
|
||||
QMap<QString, bool> DbusAdaptor::getDeviceListAndEnabled()
|
||||
{
|
||||
QMap<QString, bool> map;
|
||||
map.clear();
|
||||
getDeviceEnableState(map);
|
||||
return map;
|
||||
}
|
||||
|
||||
//唤起属性页 根据网卡类型 参数2 为ssid/uuid
|
||||
void DbusAdaptor::showPropertyWidget(QString devName, QString ssid)
|
||||
{
|
||||
//todo
|
||||
//parent()->showPropertyWidget(devName,ssid);
|
||||
}
|
||||
|
||||
//唤起新建有线连接界面
|
||||
void DbusAdaptor::showCreateWiredConnectWidget(QString devName, QString connectionName)
|
||||
{
|
||||
//todo
|
||||
//parent()->showCreateWiredConnectWidget(devName,connectionName);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include <QtCore/QObject>
|
||||
#include <QtDBus/QtDBus>
|
||||
#include <QtDBus/QDBusMetaType>
|
||||
|
||||
#include "../dbus-interface/kylinnetworkdeviceresource.h"
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QByteArray;
|
||||
//template<class T> class QList;
|
||||
|
@ -31,28 +33,61 @@ QT_END_NAMESPACE
|
|||
|
||||
#include "new-mainwindow.h"
|
||||
|
||||
class WiredInfo
|
||||
{
|
||||
QString connName;
|
||||
QString uuid;
|
||||
|
||||
friend QDBusArgument&operator <<(QDBusArgument&argument, const WiredInfo&arg)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument << arg.connName;
|
||||
argument << arg.uuid;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
friend const QDBusArgument &operator >>(const QDBusArgument &argument, WiredInfo &arg)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument >> arg.connName;
|
||||
argument >> arg.uuid;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
};
|
||||
Q_DECLARE_METATYPE(WiredInfo)
|
||||
|
||||
class WirelessInfo
|
||||
{
|
||||
QString ssid;
|
||||
uint signalStrength;
|
||||
bool bSecu;
|
||||
|
||||
friend QDBusArgument&operator <<(QDBusArgument&argument, const WirelessInfo&arg)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument << arg.ssid;
|
||||
argument << arg.signalStrength;
|
||||
argument << arg.bSecu;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
friend const QDBusArgument &operator >>(const QDBusArgument&argument, WirelessInfo&arg)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument >> arg.ssid;
|
||||
argument >> arg.signalStrength;
|
||||
argument >> arg.bSecu;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
};
|
||||
Q_DECLARE_METATYPE(WirelessInfo)
|
||||
|
||||
class DbusAdaptor: public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "com.kylin.network")
|
||||
Q_CLASSINFO("D-Bus Introspection", ""
|
||||
" <interface name=\"com.kylin.network\">\n"
|
||||
" <method name=\"showMainWindow\"/>\n"
|
||||
" <method name=\"requestRefreshWifiList\"/>\n"
|
||||
" <method name=\"getWifiList\">\n"
|
||||
" <arg type=\"av\" direction=\"out\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"showPb\">\n"
|
||||
" <arg direction=\"in\" name=\"type\" type=\"s\"/>\n"
|
||||
" <arg direction=\"in\" name=\"name\" type=\"s\"/>\n"
|
||||
" </method>\n"
|
||||
" <signal name=\"getWifiListFinished\"/>\n"
|
||||
" <signal name=\"configurationChanged\"/>\n"
|
||||
" <signal name=\"wiredConnectionAdded\"/>\n"
|
||||
" <signal name=\"wiredConnectionRemoved\"/>\n"
|
||||
" <signal name=\"actWiredConnectionChanged\"/>\n"
|
||||
" </interface>\n"
|
||||
"")
|
||||
public:
|
||||
DbusAdaptor(MainWindow *parent);
|
||||
virtual ~DbusAdaptor();
|
||||
|
@ -62,16 +97,36 @@ public:
|
|||
|
||||
public: // PROPERTIES
|
||||
public Q_SLOTS: // METHODS
|
||||
void showMainWindow();
|
||||
void showPb(QString type, QString name);
|
||||
void requestRefreshWifiList();
|
||||
QVector<QStringList> getWifiList();
|
||||
//无线列表
|
||||
QList<WirelessInfo> getWirelessList(QString devName);
|
||||
//有线列表
|
||||
QList<WiredInfo> getWiredList(QString devName);
|
||||
//有线开关
|
||||
Q_NOREPLY void setWiredSwitchEnable(bool enable);
|
||||
//无线开关
|
||||
Q_NOREPLY void setWirelessSwitchEnable(bool enable);
|
||||
//启用/禁用网卡
|
||||
Q_NOREPLY void setDeviceEnable(QString devName, bool enable);
|
||||
//设置默认网卡
|
||||
Q_NOREPLY void setDefaultWiredDevice(QString deviceName);
|
||||
QString getDefaultWiredDevice();
|
||||
Q_NOREPLY void setDefaultWirelessDevice(QString deviceName);
|
||||
QString getDefaultWirelessDevice();
|
||||
//连接 根据网卡类型 参数2 为ssid/uuid
|
||||
Q_NOREPLY void activateConnect(QString devName, QString ssid);
|
||||
//断开连接 根据网卡类型 参数2 为ssid/uuid
|
||||
Q_NOREPLY void deActivateConnect(QString devName, QString ssid);
|
||||
//获取设备列表和启用/禁用状态
|
||||
QMap<QString, bool> getDeviceListAndEnabled();
|
||||
//唤起属性页 根据网卡类型 参数2 为ssid/uuid
|
||||
Q_NOREPLY void showPropertyWidget(QString devName, QString ssid);
|
||||
//唤起新建有线连接界面
|
||||
Q_NOREPLY void showCreateWiredConnectWidget(QString devName, QString connectionName);
|
||||
Q_SIGNALS: // SIGNALS
|
||||
void getWifiListFinished();
|
||||
void configurationChanged();
|
||||
void wiredConnectionAdded();
|
||||
void wiredConnectionRemoved();
|
||||
void actWiredConnectionChanged();
|
||||
void listUpdate(QString devName);
|
||||
void deviceUpdate();
|
||||
//仅失败,若成功直接发listUpdate
|
||||
void activateFinish(QString devName, QString ssid);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#include "new-mainwindow.h"
|
||||
#include "customstyle.h"
|
||||
#include "lanpage.h"
|
||||
#include "wlanpage.h"
|
||||
#include <KWindowEffects>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
@ -42,6 +40,22 @@ void MainWindow::hideMainwindow()
|
|||
this->hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::setWiredDefaultDevice 设置有线设备默认网卡
|
||||
*/
|
||||
void MainWindow::setWiredDefaultDevice(QString deviceName)
|
||||
{
|
||||
m_lanWidget->updateDefaultDevice(deviceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::hideMainwindow 设置无线设备默认网卡
|
||||
*/
|
||||
void MainWindow::setWirelessDefaultDevice(QString deviceName)
|
||||
{
|
||||
m_wlanWidget->updateDefaultDevice(deviceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::firstlyStart 一级启动,执行重要且不耗时的启动操作
|
||||
*/
|
||||
|
@ -94,8 +108,8 @@ void MainWindow::initUI()
|
|||
m_centralWidget = new QTabWidget(this);
|
||||
this->setCentralWidget(m_centralWidget);
|
||||
m_centralWidget->tabBar()->setFixedWidth(this->width());
|
||||
LanPage * m_lanWidget = new LanPage(m_centralWidget);
|
||||
WlanPage * m_wlanWidget = new WlanPage(m_centralWidget);
|
||||
m_lanWidget = new LanPage(m_centralWidget);
|
||||
m_wlanWidget = new WlanPage(m_centralWidget);
|
||||
m_centralWidget->addTab(m_lanWidget, QIcon::fromTheme("network-wired-connected-symbolic", QIcon::fromTheme("network-wired-symbolic", QIcon(":/res/l/network-online.svg"))), tr("LAN"));
|
||||
m_centralWidget->addTab(m_wlanWidget, QIcon::fromTheme("network-wireless-signal-excellent-symbolic", QIcon(":/res/x/wifi-list-bg.svg")), tr("WLAN"));
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QDBusInterface>
|
||||
#include "lanpage.h"
|
||||
#include "wlanpage.h"
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
|
@ -18,6 +20,8 @@ public:
|
|||
void showMainwindow();
|
||||
void hideMainwindow();
|
||||
|
||||
void setWiredDefaultDevice(QString deviceName);
|
||||
void setWirelessDefaultDevice(QString deviceName);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
@ -42,6 +46,9 @@ private:
|
|||
//主窗口的主要构成控件
|
||||
QTabWidget * m_centralWidget = nullptr;
|
||||
|
||||
LanPage * m_lanWidget = nullptr;
|
||||
WlanPage * m_wlanWidget = nullptr;
|
||||
|
||||
//监听主题的Gsettings
|
||||
QGSettings * m_styleGsettings = nullptr;
|
||||
|
||||
|
|
|
@ -587,8 +587,6 @@ void NmDemo::getWifiList()
|
|||
m_wnr->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Deactivated, actMap);
|
||||
appendDebugLog("getWirelessActiveConnection Deactivated " +QString::number(actMap.size()));
|
||||
|
||||
return;
|
||||
|
||||
QMap<QString, QList<KyWirelessNetItem> > map;
|
||||
if (!m_wnr->getAllDeviceWifiNetwork(map))
|
||||
{
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#include "lanpage.h"
|
||||
#include <QSettings>
|
||||
|
||||
LanPage::LanPage(QWidget *parent) : TabPage(parent)
|
||||
{
|
||||
initDevice();
|
||||
initLanUI();
|
||||
}
|
||||
|
||||
|
||||
void LanPage::initLanUI()
|
||||
{
|
||||
m_titleLabel->setText(tr("LAN"));
|
||||
|
@ -19,3 +22,33 @@ void LanPage::initLanUI()
|
|||
m_inactivatedNetListWidget->setSpacing(NET_LIST_SPACING);
|
||||
m_inactivatedNetListWidget->setFrameShape(QFrame::Shape::NoFrame);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief WlanPage::initDevice 初始化默认网卡
|
||||
*/
|
||||
void LanPage::initDevice()
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wired");
|
||||
QString deviceName = m_settings->value(key, "").toString();
|
||||
if (deviceName.isEmpty()) {
|
||||
qDebug() << "initDevice but defalut wired card is null";
|
||||
QStringList list;
|
||||
list.empty();
|
||||
m_device->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, list);
|
||||
if (!list.isEmpty()) {
|
||||
deviceName = list.at(0);
|
||||
m_settings->setValue(key, deviceName);
|
||||
}
|
||||
}
|
||||
updateDefaultDevice(deviceName);
|
||||
qDebug() << "[LanPage] initDevice defaultDevice = " << deviceName;
|
||||
|
||||
m_settings->endGroup();
|
||||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define LANPAGE_H
|
||||
|
||||
#include "tabpage.h"
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
|
||||
class LanPage : public TabPage
|
||||
{
|
||||
|
@ -10,10 +11,11 @@ public:
|
|||
explicit LanPage(QWidget *parent = nullptr);
|
||||
~LanPage()=default;
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
KyNetworkDeviceResourse *m_device = nullptr;
|
||||
|
||||
void initLanUI();
|
||||
void initDevice();//初始化默认设备
|
||||
};
|
||||
|
||||
#endif // LANPAGE_H
|
||||
|
|
|
@ -74,3 +74,15 @@ void TabPage::initUI()
|
|||
m_mainLayout->addWidget(m_inactivatedNetDivider);
|
||||
m_mainLayout->addWidget(m_settingsFrame);
|
||||
}
|
||||
|
||||
void TabPage::updateDefaultDevice(QString &deviceName)
|
||||
{
|
||||
qDebug() << "updateDefaultDevice" << deviceName;
|
||||
defaultDevice = deviceName;
|
||||
}
|
||||
|
||||
QString TabPage::getDefaultDevice()
|
||||
{
|
||||
qDebug() << "getDefaultDevice" << defaultDevice;
|
||||
return defaultDevice;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include <QLabel>
|
||||
#include <QScrollArea>
|
||||
#include <QListWidget>
|
||||
#include <QDir>
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
|
||||
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||
#define MAIN_LAYOUT_SPACING 0
|
||||
|
@ -21,6 +23,8 @@
|
|||
#define SETTINGS_LAYOUT_MARGINS 24,16,24,16
|
||||
#define TRANSPARENT_COLOR QColor(0,0,0,0)
|
||||
|
||||
const QString CONFIG_FILE_PATH = QDir::homePath() + "/.config/ukui/kylin-nm.conf";
|
||||
|
||||
class TabPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -28,10 +32,14 @@ public:
|
|||
explicit TabPage(QWidget *parent = nullptr);
|
||||
~TabPage();
|
||||
|
||||
void updateDefaultDevice(QString &deviceName);
|
||||
QString getDefaultDevice();
|
||||
|
||||
signals:
|
||||
|
||||
protected:
|
||||
void initUI();
|
||||
virtual void initDevice() = 0;//初始化默认设备
|
||||
QVBoxLayout * m_mainLayout = nullptr;
|
||||
QFrame * m_titleFrame = nullptr;
|
||||
QHBoxLayout * m_titleLayout = nullptr;
|
||||
|
@ -56,6 +64,8 @@ protected:
|
|||
QHBoxLayout * m_settingsLayout = nullptr;
|
||||
QLabel * m_settingsLabel = nullptr;
|
||||
|
||||
QString defaultDevice = "";
|
||||
|
||||
};
|
||||
|
||||
#endif // TABPAGE_H
|
||||
|
|
|
@ -4,10 +4,13 @@
|
|||
#include <QEvent>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
|
||||
WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
|
||||
{
|
||||
m_resource = new KyWirelessNetResource(this);
|
||||
m_device = new KyNetworkDeviceResourse(this);
|
||||
initDevice();
|
||||
initWlanUI();
|
||||
initConnections();
|
||||
getActiveWlan();
|
||||
|
@ -75,6 +78,34 @@ void WlanPage::initConnections()
|
|||
connect(m_resource, &KyWirelessNetResource::wifiNetworkUpdate, this, &WlanPage::onWlanUpdated);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WlanPage::initDevice 初始化默认网卡
|
||||
*/
|
||||
void WlanPage::initDevice()
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wireless");
|
||||
QString deviceName = m_settings->value(key, "").toString();
|
||||
if (deviceName.isEmpty()) {
|
||||
qDebug() << "initDevice but defalut wireless card is null";
|
||||
QStringList list;
|
||||
list.empty();
|
||||
m_device->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, list);
|
||||
if (!list.isEmpty()) {
|
||||
deviceName = list.at(0);
|
||||
m_settings->setValue(key, deviceName);
|
||||
}
|
||||
}
|
||||
updateDefaultDevice(deviceName);
|
||||
qDebug() << "[WlanPage] initDevice defaultDevice = " << deviceName;
|
||||
m_settings->endGroup();
|
||||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief WlanPage::getActiveWlan 获取所有已激活连接
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "tabpage.h"
|
||||
#include "kywirelessnetresource.h"
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
|
||||
//#define SCROLLAREA_HEIGHT 150
|
||||
#define MORE_TEXT_MARGINS 16,0,0,0
|
||||
|
||||
|
@ -13,6 +15,8 @@ public:
|
|||
explicit WlanPage(QWidget *parent = nullptr);
|
||||
~WlanPage() = default;
|
||||
|
||||
void setDefaultDevice(QString deviceName) {defaultDevice = deviceName;}
|
||||
|
||||
signals:
|
||||
|
||||
protected:
|
||||
|
@ -21,6 +25,7 @@ protected:
|
|||
private:
|
||||
void initWlanUI();
|
||||
void initConnections();
|
||||
void initDevice();//初始化默认设备
|
||||
void getActiveWlan();
|
||||
void getAllWlan();
|
||||
QMap<QString, QListWidgetItem*> m_itemsMap;
|
||||
|
@ -31,8 +36,10 @@ private:
|
|||
QLabel * m_hiddenWlanLabel = nullptr;
|
||||
|
||||
QString m_activatedWlanSSid;
|
||||
QString defaultDevice = "";
|
||||
|
||||
KyWirelessNetResource *m_resource = nullptr;
|
||||
KyNetworkDeviceResourse *m_device = nullptr;
|
||||
|
||||
private slots:
|
||||
void onWlanAdded(QString interface, KyWirelessNetItem &item);
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<schemalist gettext-domain="kylin-nm">
|
||||
<schema id="org.ukui.kylin-nm.switch" path="/org/ukui/kylin-nm/switch/">
|
||||
<key type="b" name="wirelessswitch">
|
||||
<default>true</default>
|
||||
<summary>wireless switch</summary>
|
||||
<description>Wireless switch.true is open,false is close.</description>
|
||||
</key>
|
||||
<key type="b" name="wiredswitch">
|
||||
<default>true</default>
|
||||
<summary>wired switch</summary>
|
||||
<description>Wired switch.true is open,false is close.</description>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
|
@ -17,7 +17,7 @@ CONFIG += qt warn_on
|
|||
#CONFIG += release
|
||||
CONFIG += link_pkgconfig
|
||||
|
||||
PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0
|
||||
PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0 gsettings-qt
|
||||
|
||||
INCLUDEPATH += /usr/include/KF5/NetworkManagerQt
|
||||
|
||||
|
@ -27,9 +27,12 @@ target.path = /usr/bin
|
|||
target.source += $$TARGET
|
||||
desktop.path = /etc/xdg/autostart/
|
||||
desktop.files = kylin-nm.desktop
|
||||
gschema.files = org.ukui.kylin-nm.switch.gschema.xml
|
||||
gschema.path = /usr/share/glib-2.0/schemas/
|
||||
|
||||
INSTALLS += target \
|
||||
desktop \
|
||||
gschema \
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||
|
@ -63,3 +66,6 @@ unix {
|
|||
MOC_DIR = .moc
|
||||
OBJECTS_DIR = .obj
|
||||
}
|
||||
|
||||
DISTFILES += \
|
||||
org.ukui.kylin-nm.switch.gschema.xml
|
||||
|
|
Loading…
Reference in New Issue