update wireless method
This commit is contained in:
parent
1d83f9e335
commit
f04143660c
|
@ -70,6 +70,7 @@ SOURCES += \
|
|||
src/backend/dbus-interface/kylinnetworkresourcemanager.cpp \
|
||||
src/backend/dbus-interface/kylinvpnconnectitem.cpp \
|
||||
src/backend/dbus-interface/kylinwiredconnectoperation.cpp \
|
||||
src/backend/dbus-interface/kylinwirelessconnectsetting.cpp \
|
||||
src/backend/dbus-interface/kywirelessconnectoperation.cpp \
|
||||
src/backend/dbus-interface/kywirelessnetitem.cpp \
|
||||
src/backend/dbus-interface/kywirelessnetresource.cpp \
|
||||
|
@ -121,6 +122,7 @@ HEADERS += \
|
|||
src/backend/dbus-interface/kylinnetworkresourcemanager.h \
|
||||
src/backend/dbus-interface/kylinvpnconnectitem.h \
|
||||
src/backend/dbus-interface/kylinwiredconnectoperation.h \
|
||||
src/backend/dbus-interface/kylinwirelessconnectsetting.h \
|
||||
src/backend/dbus-interface/kywirelessconnectoperation.h \
|
||||
src/backend/dbus-interface/kywirelessnetitem.h \
|
||||
src/backend/dbus-interface/kywirelessnetresource.h \
|
||||
|
|
|
@ -1,23 +1,9 @@
|
|||
#include "kyenterpricesettinginfo.h"
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr KyEnterPriceSettingInfo::assembleEapMethodTlsSettings(KyEapMethodTlsInfo &info,
|
||||
bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
||||
void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &info)
|
||||
{
|
||||
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
|
||||
settings->setId(info.connName);
|
||||
settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||
settings->setAutoconnect(isAutoConnect);
|
||||
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
||||
settings->setGatewayPingTimeout(0);
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
wifi_sett->setInitialized(true);
|
||||
wifi_sett->setSsid(info.connName.toUtf8());
|
||||
wifi_sett->setSecurity("802-11-wireless-security");
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= settings->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTls);
|
||||
|
@ -34,35 +20,22 @@ NetworkManager::ConnectionSettings::Ptr KyEnterPriceSettingInfo::assembleEapMeth
|
|||
QByteArray cliPriKeyEndWithNull(info.clientPrivateKey.toUtf8() + '\0');
|
||||
wifi_8021x_sett->setPrivateKey(cliPriKeyEndWithNull);
|
||||
wifi_8021x_sett->setPrivateKeyPassword(info.clientPrivateKeyPWD);
|
||||
wifi_8021x_sett->setPrivateKeyPasswordFlags(secretFlags);
|
||||
wifi_8021x_sett->setPrivateKeyPasswordFlags(info.m_privateKeyPWDFlag);
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
||||
|
||||
return settings;
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr KyEnterPriceSettingInfo::assembleEapMethodPeapSettings(KyEapMethodPeapInfo &info,
|
||||
bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
||||
void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &info)
|
||||
{
|
||||
qDebug() << "assembleEapMethodPeapSettings";
|
||||
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
|
||||
settings->setId(info.connName);
|
||||
settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||
settings->setAutoconnect(isAutoConnect);
|
||||
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
||||
settings->setGatewayPingTimeout(0);
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
wifi_sett->setInitialized(true);
|
||||
wifi_sett->setSsid(info.connName.toUtf8());
|
||||
wifi_sett->setSecurity("802-11-wireless-security");
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= settings->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap);
|
||||
|
@ -71,36 +44,21 @@ NetworkManager::ConnectionSettings::Ptr KyEnterPriceSettingInfo::assembleEapMeth
|
|||
wifi_8021x_sett->setPhase2AuthEapMethod((NetworkManager::Security8021xSetting::AuthEapMethod)info.phase2AuthMethod);
|
||||
wifi_8021x_sett->setIdentity(info.userName);
|
||||
wifi_8021x_sett->setPassword(info.userPWD);
|
||||
wifi_8021x_sett->setPrivateKeyPasswordFlags(secretFlags);
|
||||
wifi_8021x_sett->setPasswordFlags(info.m_passwdFlag);
|
||||
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
||||
security_sett->setAuthAlg(NetworkManager::WirelessSecuritySetting::Open);
|
||||
|
||||
return settings;
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr KyEnterPriceSettingInfo::assembleEapMethodTtlsSettings(KyEapMethodTtlsInfo &info,
|
||||
bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
||||
void assembleEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &info)
|
||||
{
|
||||
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
|
||||
settings->setId(info.connName);
|
||||
settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||
settings->setAutoconnect(isAutoConnect);
|
||||
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
||||
settings->setGatewayPingTimeout(0);
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
wifi_sett->setInitialized(true);
|
||||
wifi_sett->setSsid(info.connName.toUtf8());
|
||||
wifi_sett->setSecurity("802-11-wireless-security");
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= settings->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls);
|
||||
|
@ -115,12 +73,91 @@ NetworkManager::ConnectionSettings::Ptr KyEnterPriceSettingInfo::assembleEapMeth
|
|||
}
|
||||
wifi_8021x_sett->setIdentity(info.userName);
|
||||
wifi_8021x_sett->setPassword(info.userPWD);
|
||||
wifi_8021x_sett->setPrivateKeyPasswordFlags(secretFlags);
|
||||
wifi_8021x_sett->setPasswordFlags(info.m_passwdFlag);
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
||||
|
||||
return settings;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void modifyEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo)
|
||||
{
|
||||
NetworkManager::Security8021xSetting::Ptr setting = connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
setting->setInitialized(true);
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTls);
|
||||
setting->setEapMethods(list);
|
||||
setting->setIdentity(tlsInfo.identity);
|
||||
if(!tlsInfo.domain.isEmpty())
|
||||
{
|
||||
setting->setDomainSuffixMatch(tlsInfo.domain);
|
||||
}
|
||||
if (tlsInfo.bNeedCa)
|
||||
{
|
||||
QByteArray caCerEndWithNull(tlsInfo.caCertPath.toUtf8() + '\0');
|
||||
setting->setCaCertificate(caCerEndWithNull);
|
||||
}
|
||||
|
||||
QByteArray cliCertEndWithNull(tlsInfo.clientCertPath.toUtf8() + '\0');
|
||||
setting->setClientCertificate(cliCertEndWithNull);
|
||||
QByteArray cliPriKeyEndWithNull(tlsInfo.clientPrivateKey.toUtf8() + '\0');
|
||||
setting->setPrivateKey(cliPriKeyEndWithNull);
|
||||
setting->setPrivateKeyPasswordFlags(tlsInfo.m_privateKeyPWDFlag);
|
||||
if(tlsInfo.bChanged)
|
||||
{
|
||||
setting->setPrivateKeyPassword(tlsInfo.clientPrivateKeyPWD);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo)
|
||||
{
|
||||
qDebug() << "assembleEapMethodPeapSettings";
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
wifi_8021x_sett->setInitialized(true);
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap);
|
||||
wifi_8021x_sett->setInitialized(true);
|
||||
wifi_8021x_sett->setEapMethods(list);
|
||||
wifi_8021x_sett->setPhase2AuthEapMethod((NetworkManager::Security8021xSetting::AuthEapMethod)peapInfo.phase2AuthMethod);
|
||||
wifi_8021x_sett->setIdentity(peapInfo.userName);
|
||||
if(peapInfo.bChanged)
|
||||
{
|
||||
wifi_8021x_sett->setPassword(peapInfo.userPWD);
|
||||
}
|
||||
wifi_8021x_sett->setPasswordFlags(peapInfo.m_passwdFlag);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo)
|
||||
{
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls);
|
||||
wifi_8021x_sett->setInitialized(true);
|
||||
wifi_8021x_sett->setEapMethods(list);
|
||||
if (ttlsInfo.authType == KyTtlsAuthMethod::AUTH_EAP)
|
||||
{
|
||||
wifi_8021x_sett->setPhase2AuthEapMethod((NetworkManager::Security8021xSetting::AuthEapMethod)ttlsInfo.authEapMethod);//gtc md5 mschapv2 otp tls
|
||||
} else if (ttlsInfo.authType == KyTtlsAuthMethod::AUTH_NO_EAP)
|
||||
{
|
||||
wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)ttlsInfo.authNoEapMethod);//chap md5 mschapv2 pap gtc mschap otp tls
|
||||
}
|
||||
wifi_8021x_sett->setIdentity(ttlsInfo.userName);
|
||||
if(ttlsInfo.bChanged)
|
||||
{
|
||||
wifi_8021x_sett->setPassword(ttlsInfo.userPWD);
|
||||
}
|
||||
wifi_8021x_sett->setPasswordFlags(ttlsInfo.m_passwdFlag);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -7,14 +7,17 @@
|
|||
class KyEapMethodTlsInfo
|
||||
{
|
||||
public:
|
||||
QString connName;
|
||||
QString identity;
|
||||
QString domain;
|
||||
QString devIfaceName;
|
||||
QString caCertPath;
|
||||
bool bNeedCa;
|
||||
QString clientCertPath;
|
||||
QString clientPrivateKey;
|
||||
QString clientPrivateKeyPWD;
|
||||
NetworkManager::Setting::SecretFlags m_privateKeyPWDFlag;
|
||||
// only valid when update
|
||||
bool bChanged;
|
||||
};
|
||||
|
||||
typedef enum{
|
||||
|
@ -29,10 +32,12 @@ typedef enum{
|
|||
class KyEapMethodPeapInfo
|
||||
{
|
||||
public:
|
||||
QString connName;
|
||||
KyEapMethodPeapAuth phase2AuthMethod;
|
||||
QString userName;
|
||||
QString userPWD;
|
||||
NetworkManager::Setting::SecretFlags m_passwdFlag;
|
||||
// only valid when update
|
||||
bool bChanged;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
@ -65,24 +70,22 @@ enum KyTtlsAuthMethod
|
|||
class KyEapMethodTtlsInfo
|
||||
{
|
||||
public:
|
||||
QString connName;
|
||||
KyTtlsAuthMethod authType;
|
||||
KyEapMethodTtlsAuth authEapMethod;
|
||||
KyNoEapMethodTtlsAuth authNoEapMethod;
|
||||
QString userName;
|
||||
QString userPWD;
|
||||
NetworkManager::Setting::SecretFlags m_passwdFlag;
|
||||
// only valid when update
|
||||
bool bChanged;
|
||||
};
|
||||
|
||||
class KyEnterPriceSettingInfo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KyEnterPriceSettingInfo(QObject *parent = nullptr);
|
||||
void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &);
|
||||
void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &);
|
||||
void assembleEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &);
|
||||
|
||||
static NetworkManager::ConnectionSettings::Ptr assembleEapMethodTlsSettings(KyEapMethodTlsInfo &, bool, NetworkManager::Setting::SecretFlags);
|
||||
static NetworkManager::ConnectionSettings::Ptr assembleEapMethodPeapSettings(KyEapMethodPeapInfo &, bool, NetworkManager::Setting::SecretFlags);
|
||||
static NetworkManager::ConnectionSettings::Ptr assembleEapMethodTtlsSettings(KyEapMethodTtlsInfo &, bool, NetworkManager::Setting::SecretFlags);
|
||||
|
||||
};
|
||||
void modifyEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &);
|
||||
void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &);
|
||||
void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &);
|
||||
|
||||
#endif // KYENTERPRICESETTINGINFO_H
|
||||
|
|
|
@ -101,21 +101,9 @@ void KyConnectOperation::createConnect(KyConnectSetting &connectSettingsInfo)
|
|||
return;
|
||||
}
|
||||
|
||||
void KyConnectOperation::updateConnect(const QString &connectUuid, const KyConnectSetting &connectSettingsInfo)
|
||||
void KyConnectOperation::updateConnect(NetworkManager::ConnectionSettings::Ptr connectionSettings, const KyConnectSetting &connectSettingsInfo)
|
||||
{
|
||||
qDebug()<<"update connect"<<connectUuid;
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(connectUuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + connectUuid;
|
||||
qWarning()<<errorMessage;
|
||||
Q_EMIT updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
connectionSettings->setId(connectSettingsInfo.m_connectName);
|
||||
connectionSettings->setInterfaceName(connectSettingsInfo.m_ifaceName);
|
||||
qDebug()<<"update connect"<<connectionSettings->uuid();
|
||||
|
||||
NetworkManager::Ipv4Setting::Ptr ipv4Setting = connectionSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
||||
ipv4SettingSet(ipv4Setting, connectSettingsInfo);
|
||||
|
@ -126,8 +114,6 @@ void KyConnectOperation::updateConnect(const QString &connectUuid, const KyConne
|
|||
// NetworkManager::WiredSetting::Ptr wiredSetting = connectionSettings->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>();
|
||||
// wiredSetting->setInitialized(true);
|
||||
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
|
@ -149,12 +135,11 @@ void KyConnectOperation::deleteConnect(const QString &connectUuid)
|
|||
return ;
|
||||
}
|
||||
|
||||
void KyConnectOperation::activateConnection(const QString connectUuid)
|
||||
void KyConnectOperation::activateConnection(const QString connectUuid, const QString deviceName)
|
||||
{
|
||||
QString connectPath = "";
|
||||
QString deviceIdentifier = "";
|
||||
QString connectName = "";
|
||||
QString deviceName = "";
|
||||
QString specificObject = "";
|
||||
NetworkManager::Connection::Ptr connectPtr = nullptr;
|
||||
|
||||
|
@ -178,24 +163,23 @@ void KyConnectOperation::activateConnection(const QString connectUuid)
|
|||
#endif
|
||||
connectPath = connectPtr->path();
|
||||
connectName = connectPtr->name();
|
||||
deviceName = connectPtr->settings()->interfaceName();
|
||||
// deviceName = connectPtr->settings()->interfaceName();
|
||||
|
||||
for (auto const & dev : m_networkResourceInstance->m_devices) {
|
||||
for (auto const & dev_conn : dev->availableConnections()) {
|
||||
if (dev_conn == connectPtr) {
|
||||
deviceIdentifier = dev->uni();
|
||||
deviceName = dev->interfaceName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
// for (auto const & dev : m_networkResourceInstance->m_devices) {
|
||||
// for (auto const & dev_conn : dev->availableConnections()) {
|
||||
// if (dev_conn == connectPtr) {
|
||||
// deviceIdentifier = dev->uni();
|
||||
// deviceName = dev->interfaceName();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceInterface(deviceName);
|
||||
if (!dev.isNull()) {
|
||||
deviceIdentifier = dev->uni();
|
||||
}
|
||||
|
||||
if (deviceIdentifier.isEmpty() && !deviceName.isEmpty()) {
|
||||
auto dev = m_networkResourceInstance->findDeviceInterface(deviceName);
|
||||
if (!dev.isNull()) {
|
||||
deviceIdentifier = dev->uni();
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceIdentifier.isEmpty()) {
|
||||
QString errorMessage = tr("device Identifier is empty, its name") + deviceName;
|
||||
|
|
|
@ -13,9 +13,9 @@ public:
|
|||
|
||||
public:
|
||||
void createConnect(KyConnectSetting &connectSettingsInfo);
|
||||
void updateConnect(const QString &connectUuid, const KyConnectSetting &connectSettingsInfo);
|
||||
void updateConnect(NetworkManager::ConnectionSettings::Ptr connectionSettings, const KyConnectSetting &connectSettingsInfo);
|
||||
void deleteConnect(const QString &connectUuid);
|
||||
void activateConnection(const QString connectUuid);
|
||||
void activateConnection(const QString connectUuid, const QString deviceName);
|
||||
void deactivateConnection(const QString activeConnectName, const QString &activeConnectUuid);
|
||||
|
||||
public:
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "kylinconnectsetting.h"
|
||||
#include <QDebug>
|
||||
|
||||
KyConnectSetting::KyConnectSetting(QObject *parent) : QObject(parent)
|
||||
KyConnectSetting::KyConnectSetting(/*QObject *parent) : QObject(parent*/)
|
||||
{
|
||||
m_connectName = "";
|
||||
m_ifaceName = "";
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
//#include <QObject>
|
||||
|
||||
#include <NetworkManagerQt/AdslDevice>
|
||||
#include <NetworkManagerQt/WiredDevice>
|
||||
|
@ -39,11 +39,11 @@ typedef enum {
|
|||
IPADDRESS_V6,
|
||||
}KyIpAddressType;
|
||||
|
||||
class KyConnectSetting : public QObject
|
||||
class KyConnectSetting/* : public QObject*/
|
||||
{
|
||||
Q_OBJECT
|
||||
// Q_OBJECT
|
||||
public:
|
||||
explicit KyConnectSetting(QObject *parent = nullptr);
|
||||
/* explicit*/ KyConnectSetting(/*QObject *parent = nullptr*/);
|
||||
~KyConnectSetting();
|
||||
|
||||
public:
|
||||
|
|
|
@ -5,7 +5,8 @@ KyNetworkDeviceResourse::KyNetworkDeviceResourse(QObject *parent) : QObject(pare
|
|||
{
|
||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
|
||||
m_activeConnectUuidList.clear();
|
||||
// m_activeConnectUuidList.clear();
|
||||
m_activeConnectUuidMap.clear();
|
||||
//TODO::get uuid from settings for system reboot;
|
||||
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceAdd, this, &KyNetworkDeviceResourse::deviceAdd);
|
||||
|
@ -155,7 +156,8 @@ void KyNetworkDeviceResourse::disconnectDevice()
|
|||
return;
|
||||
}
|
||||
|
||||
m_activeConnectUuidList.clear();
|
||||
// m_activeConnectUuidList.clear();
|
||||
m_activeConnectUuidMap.clear();
|
||||
|
||||
for (int index = 0; index < networkDeviceList.size(); ++index) {
|
||||
NetworkManager::Device::Ptr networkDevicePtr = networkDeviceList.at(index);
|
||||
|
@ -164,7 +166,8 @@ void KyNetworkDeviceResourse::disconnectDevice()
|
|||
NetworkManager::ActiveConnection::Ptr activeConnectPtr = networkDevicePtr->activeConnection();
|
||||
QString activeConnectUuid = activeConnectPtr->uuid();
|
||||
if (!activeConnectUuid.isEmpty()) {
|
||||
m_activeConnectUuidList<<activeConnectUuid;
|
||||
// m_activeConnectUuidList<<activeConnectUuid;
|
||||
m_activeConnectUuidMap.insert(networkDevicePtr->interfaceName(),activeConnectUuid);
|
||||
//TODO:save uuid for system reboot.
|
||||
}
|
||||
networkDevicePtr->disconnectInterface();
|
||||
|
@ -185,10 +188,13 @@ void KyNetworkDeviceResourse::setDeviceAutoConnect()
|
|||
return;
|
||||
}
|
||||
|
||||
for (int index = 0; index < m_activeConnectUuidList.size(); ++index) {
|
||||
QString connectUuid = m_activeConnectUuidList.at(index);
|
||||
wiredOperation.activateConnection(connectUuid);
|
||||
qDebug()<<"[KyNetworkDeviceResourse]" << "active connect uuid"<< connectUuid;
|
||||
QMap<QString, QString>::iterator iter = m_activeConnectUuidMap.begin();
|
||||
while (iter != m_activeConnectUuidMap.end())
|
||||
{
|
||||
qDebug() << "Iterator " << iter.key() << ":" << iter.value();
|
||||
wiredOperation.activateConnection(iter.key(), iter.value());
|
||||
qDebug()<<"[KyNetworkDeviceResourse]" << "active connect uuid "<< iter.key() << " device " << iter.value();
|
||||
iter++;
|
||||
}
|
||||
|
||||
for (int index = 0; index < networkDeviceList.size(); ++index) {
|
||||
|
|
|
@ -37,5 +37,6 @@ private:
|
|||
KyWiredConnectOperation wiredOperation;
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
QStringList m_activeConnectUuidList;
|
||||
QMap<QString , QString> m_activeConnectUuidMap;
|
||||
};
|
||||
#endif // KYLINNETORKDEVICERESOURCE_H
|
||||
|
|
|
@ -69,8 +69,19 @@ void KyWiredConnectOperation::createWiredConnect(KyConnectSetting &connectSettin
|
|||
void KyWiredConnectOperation::updateWiredConnect(const QString &connectUuid, const KyConnectSetting &connectSettingsInfo)
|
||||
{
|
||||
qDebug()<<"update connect"<<connectUuid;
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(connectUuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + connectUuid;
|
||||
qWarning()<<errorMessage;
|
||||
emit updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
updateConnect(connectUuid, connectSettingsInfo);
|
||||
NetworkManager::ConnectionSettings::Ptr connectSettingPtr = connectPtr->settings();
|
||||
updateConnect(connectSettingPtr, connectSettingsInfo);
|
||||
|
||||
connectPtr->update(connectSettingPtr->toMap());
|
||||
|
||||
return ;
|
||||
}
|
||||
|
@ -84,9 +95,9 @@ void KyWiredConnectOperation::deleteWiredConnect(const QString &connectUuid)
|
|||
return ;
|
||||
}
|
||||
|
||||
void KyWiredConnectOperation::activateWiredConnection(const QString connectUuid)
|
||||
void KyWiredConnectOperation::activateWiredConnection(const QString connectUuid, const QString devName)
|
||||
{
|
||||
activateConnection(connectUuid);
|
||||
activateConnection(connectUuid, devName);
|
||||
return ;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ public:
|
|||
void createWiredConnect(KyConnectSetting &connectSettingsInfo);
|
||||
void updateWiredConnect(const QString &connectUuid, const KyConnectSetting &connectSettingsInfo);
|
||||
void deleteWiredConnect(const QString &connectUuid);
|
||||
void activateWiredConnection(const QString connectUuid);
|
||||
void activateWiredConnection(const QString connectUuid, const QString devName);
|
||||
void activateVpnConnection(const QString connectUuid);
|
||||
void deactivateWiredConnection(const QString activeConnectName, const QString &activeConnectUuid);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
#include "kylinwirelessconnectsetting.h"
|
||||
|
||||
//KyWirelessConnectSetting::KyWirelessConnectSetting()
|
||||
//{
|
||||
// m_ssid = "";
|
||||
// isAutoConnect = false;
|
||||
// m_psk = "";
|
||||
//}
|
||||
|
||||
//KyWirelessConnectSetting::~KyWirelessConnectSetting()
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr assembleWirelessSettings(const KyWirelessConnectSetting &connSettingInfo)
|
||||
{
|
||||
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
|
||||
settings->setId(connSettingInfo.m_connectName);
|
||||
settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||
settings->setAutoconnect(connSettingInfo.isAutoConnect);
|
||||
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
||||
settings->setGatewayPingTimeout(0);
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
wifi_sett->setInitialized(true);
|
||||
wifi_sett->setSsid(connSettingInfo.m_ssid.toUtf8());
|
||||
wifi_sett->setSecurity("802-11-wireless-security");
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)connSettingInfo.m_type);
|
||||
if (KyKeyMgmt::SAE == connSettingInfo.m_type || KyKeyMgmt::WpaPsk == connSettingInfo.m_type)
|
||||
{
|
||||
security_sett->setPsk(connSettingInfo.m_psk);
|
||||
security_sett->setPskFlags(connSettingInfo.m_secretFlag);
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
void ipv4SettingSet(NetworkManager::Ipv4Setting::Ptr &ipv4Setting, const KyWirelessConnectSetting &connectSettingsInfo)
|
||||
{
|
||||
ipv4Setting->setInitialized(true);
|
||||
|
||||
if (CONFIG_IP_DHCP == connectSettingsInfo.m_ipv4ConfigIpType) {
|
||||
ipv4Setting->setMethod(NetworkManager::Ipv4Setting::Automatic);
|
||||
return;
|
||||
} else {
|
||||
ipv4Setting->setMethod(NetworkManager::Ipv4Setting::Manual);
|
||||
}
|
||||
|
||||
if (!connectSettingsInfo.m_ipv4Dns.empty()) {
|
||||
ipv4Setting->setDns(connectSettingsInfo.m_ipv4Dns);
|
||||
}
|
||||
|
||||
if (!connectSettingsInfo.m_ipv4Address.empty()) {
|
||||
ipv4Setting->setAddresses(connectSettingsInfo.m_ipv4Address);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
void ipv6SettingSet(NetworkManager::Ipv6Setting::Ptr &ipv6Setting, const KyWirelessConnectSetting &connectSettingsInfo)
|
||||
{
|
||||
ipv6Setting->setInitialized(true);
|
||||
|
||||
if (CONFIG_IP_DHCP == connectSettingsInfo.m_ipv6ConfigIpType) {
|
||||
ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic);
|
||||
return;
|
||||
}
|
||||
|
||||
ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Manual);
|
||||
if (!connectSettingsInfo.m_ipv6Dns.empty()) {
|
||||
ipv6Setting->setDns(connectSettingsInfo.m_ipv6Dns);
|
||||
}
|
||||
|
||||
if (!connectSettingsInfo.m_ipv6Address.empty()) {
|
||||
ipv6Setting->setAddresses(connectSettingsInfo.m_ipv6Address);
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
void setIpv4AndIpv6Setting(NetworkManager::ConnectionSettings::Ptr connSetting, const KyWirelessConnectSetting &connSettingInfo)
|
||||
{
|
||||
KyConnectOperation kco;
|
||||
NetworkManager::Ipv4Setting::Ptr ipv4Setting = connSetting->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
||||
kco.ipv4SettingSet(ipv4Setting, connSettingInfo);
|
||||
|
||||
NetworkManager::Ipv6Setting::Ptr ipv6Setting = connSetting->setting(NetworkManager::Setting::Ipv6).dynamicCast<NetworkManager::Ipv6Setting>();
|
||||
kco.KyConnectOperation::ipv6SettingSet(ipv6Setting, connSettingInfo);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef KYLINWIRELESSCONNECTSETTING_H
|
||||
#define KYLINWIRELESSCONNECTSETTING_H
|
||||
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include "kylinconnectsetting.h"
|
||||
#include "kylinwiredconnectoperation.h"
|
||||
|
||||
|
||||
enum KyKeyMgmt {
|
||||
Unknown = -1,
|
||||
Wep, Ieee8021x,
|
||||
WpaNone,
|
||||
WpaPsk,
|
||||
WpaEap,
|
||||
SAE
|
||||
};
|
||||
|
||||
enum KyEapMethodType {
|
||||
TLS,
|
||||
PEAP,
|
||||
TTLS,
|
||||
};
|
||||
|
||||
class KyWirelessConnectSetting : public KyConnectSetting
|
||||
{
|
||||
// Q_OBJECT
|
||||
|
||||
public:
|
||||
QString m_ssid;
|
||||
bool isAutoConnect;
|
||||
QString m_psk;
|
||||
NetworkManager::Setting::SecretFlags m_secretFlag;
|
||||
KyKeyMgmt m_type;
|
||||
//only if m_type == WpaEap
|
||||
KyEapMethodType m_eapMethodType;
|
||||
};
|
||||
|
||||
//配置connectSettings
|
||||
NetworkManager::ConnectionSettings::Ptr assembleWirelessSettings(const KyWirelessConnectSetting &connSettingInfo);
|
||||
//配置IPV4&&IPV6
|
||||
void setIpv4AndIpv6Setting(NetworkManager::ConnectionSettings::Ptr connSetting, const KyWirelessConnectSetting &connSettingInfo);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // KYLINWIRELESSCONNECTSETTING_H
|
|
@ -1,5 +1,7 @@
|
|||
#include "kywirelessconnectoperation.h"
|
||||
|
||||
#include <networkmanagerqt/wirelesssecuritysetting.h>
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr assembleWpaXPskSettings(NetworkManager::AccessPoint::Ptr accessPoint, QString &psk, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlag)
|
||||
{
|
||||
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
|
||||
|
@ -27,52 +29,11 @@ NetworkManager::ConnectionSettings::Ptr assembleWpaXPskSettings(NetworkManager::
|
|||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
|
||||
}
|
||||
security_sett->setPsk(psk);
|
||||
security_sett->setPskFlags(secretFlag);
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr assembleWpaXPskHiddenSettings(QString &ssid, KySecuType &type, QString &psk, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlag)
|
||||
{
|
||||
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
|
||||
settings->setId(ssid);
|
||||
settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||
settings->setAutoconnect(isAutoConnect);
|
||||
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
||||
settings->setGatewayPingTimeout(0);
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
wifi_sett->setInitialized(true);
|
||||
wifi_sett->setSsid(ssid.toUtf8());
|
||||
wifi_sett->setHidden(true);
|
||||
wifi_sett->setSecurity("802-11-wireless-security");
|
||||
|
||||
if (type != KySecuType::NONE)
|
||||
{
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
switch (type) {
|
||||
case KySecuType::WPA_AND_WPA2_PERSONAL:
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
|
||||
security_sett->setPskFlags(secretFlag);
|
||||
break;
|
||||
case KySecuType::WPA_AND_WPA2_ENTERPRISE:
|
||||
//TODO:隐藏企业wifi
|
||||
break;
|
||||
case KySecuType::WPA2_AND_WPA3_PERSONAL:
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::SAE);
|
||||
security_sett->setPskFlags(secretFlag);
|
||||
break;
|
||||
default:
|
||||
qDebug() << " unsupport security type";
|
||||
break;
|
||||
}
|
||||
|
||||
security_sett->setPsk(psk);
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
KyWirelessConnectOperation::KyWirelessConnectOperation(QObject *parent) : KyConnectOperation(parent)
|
||||
{
|
||||
|
@ -87,7 +48,7 @@ KyWirelessConnectOperation::~KyWirelessConnectOperation()
|
|||
|
||||
void KyWirelessConnectOperation::activeWirelessConnect(QString devIfaceName, QString connUuid)
|
||||
{
|
||||
activateConnection(connUuid);
|
||||
activateConnection(connUuid, devIfaceName);
|
||||
return;
|
||||
#if 0
|
||||
NetworkManager::Connection::Ptr conn;
|
||||
|
@ -118,154 +79,269 @@ void KyWirelessConnectOperation::activeWirelessConnect(QString devIfaceName, QSt
|
|||
qWarning() << QStringLiteral("activation of connection failed: %1").arg(watcher->error().message());
|
||||
emit connectFail(connUuid, devIfaceName, "Internal error");
|
||||
}
|
||||
qDebug() << "5";
|
||||
watcher->deleteLater();
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::deactivateWirelessConnection(const QString activeConnectName, const QString &activeConnectUuid)
|
||||
void KyWirelessConnectOperation::deActivateWirelessConnection(const QString activeConnectName, const QString &activeConnectUuid)
|
||||
{
|
||||
deactivateConnection(activeConnectName, activeConnectUuid);
|
||||
return;
|
||||
}
|
||||
|
||||
//void KyWirelessConnectOperation::activeWirelessConnectWithPwd(QString devIfaceName, QString connUuid, QString psk)
|
||||
//{
|
||||
|
||||
// //todo:
|
||||
// NetworkManager::Connection::Ptr conn;
|
||||
// conn = m_networkResourceInstance->getConnect(connUuid);
|
||||
// if (conn.isNull())
|
||||
// {
|
||||
// qDebug() <<"get failed";
|
||||
// emit connectFail(connUuid, devIfaceName, "connection do not exist");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
// = conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
// security_sett->setPsk(psk);
|
||||
|
||||
|
||||
// conn->update(conn->settings()->toMap());
|
||||
|
||||
|
||||
// QString conn_uni;
|
||||
// QString dev_uni;
|
||||
// QString spec_object;
|
||||
// auto dev = m_networkResourceInstance->findDeviceInterface(devIfaceName);
|
||||
// if (dev.isNull())
|
||||
// {
|
||||
// emit connectFail(conn->name(), devIfaceName, "devIface not exist");
|
||||
// return;
|
||||
// }
|
||||
// dev_uni = dev->uni();
|
||||
// conn_uni = conn->path();
|
||||
// QDBusPendingCallWatcher * watcher;
|
||||
// watcher = new QDBusPendingCallWatcher{NetworkManager::activateConnection(conn_uni, dev_uni, spec_object), this};
|
||||
// connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
// if (watcher->isError() || !watcher->isValid())
|
||||
// {
|
||||
// qWarning() << QStringLiteral("activation of connection failed: %1").arg(watcher->error().message());
|
||||
// emit connectFail(connUuid, devIfaceName, "Internal error");
|
||||
// }
|
||||
// watcher->deleteLater();
|
||||
// });
|
||||
//}
|
||||
|
||||
void KyWirelessConnectOperation::deActiveWirelessConnect(QString &uuid)
|
||||
//普通wifi
|
||||
void KyWirelessConnectOperation::addConnect(const KyWirelessConnectSetting &connSettingInfo)
|
||||
{
|
||||
int index = 0;
|
||||
NetworkManager::ActiveConnection::Ptr activateConnectPtr = nullptr;
|
||||
NetworkManager::ConnectionSettings::Ptr connSetting = assembleWirelessSettings(connSettingInfo);
|
||||
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
|
||||
|
||||
qDebug()<<"deactivetate connect uuid "<<uuid;
|
||||
for (index = 0; index < m_networkResourceInstance->m_activeConns.size(); ++index) {
|
||||
activateConnectPtr = m_networkResourceInstance->m_activeConns.at(index);
|
||||
if (activateConnectPtr->uuid() == uuid) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= m_networkResourceInstance->m_activeConns.size()) {
|
||||
qWarning()<<"it can not find the activate connect uuid "<<uuid;
|
||||
emit disConnectFail(uuid,"no","connection do not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << __FUNCTION__ <<"dead active connection path:"<< activateConnectPtr->path();
|
||||
|
||||
QDBusPendingReply<> reply = NetworkManager::deactivateConnection(activateConnectPtr->path());
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
qWarning() << QStringLiteral("deactivation of connection failed");
|
||||
emit disConnectFail(uuid, "no", "Internal error");
|
||||
QString errorMessage = tr("create wireless connection failed: ") + watcher->error().message();
|
||||
qWarning()<<errorMessage;
|
||||
emit this->createConnectionError(errorMessage);
|
||||
} else {
|
||||
qDebug()<<"create wireless connect complete";
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
//tls
|
||||
void KyWirelessConnectOperation::addTlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTlsInfo &tlsInfo)
|
||||
{
|
||||
NetworkManager::ConnectionSettings::Ptr connSetting = assembleWirelessSettings(connSettingInfo);
|
||||
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
|
||||
assembleEapMethodTlsSettings(connSetting, tlsInfo);
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = tr("create wireless tls connection failed: ") + watcher->error().message();
|
||||
qWarning()<<errorMessage;
|
||||
emit this->createConnectionError(errorMessage);
|
||||
} else {
|
||||
qDebug()<<"create wireless connect complete";
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
//peap
|
||||
void KyWirelessConnectOperation::addPeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPeapInfo &peapInfo)
|
||||
{
|
||||
NetworkManager::ConnectionSettings::Ptr connSetting = assembleWirelessSettings(connSettingInfo);
|
||||
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
|
||||
assembleEapMethodPeapSettings(connSetting, peapInfo);
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = tr("create wireless peap connection failed: ") + watcher->error().message();
|
||||
qWarning()<<errorMessage;
|
||||
emit this->createConnectionError(errorMessage);
|
||||
} else {
|
||||
qDebug()<<"create wireless connect complete";
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & ssid, QString & devIface,
|
||||
QString psk, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
||||
void KyWirelessConnectOperation::addTtlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTtlsInfo &ttlsInfo)
|
||||
{
|
||||
qDebug() << "addAndActiveWirelessConnect" << ssid << devIface <<psk;
|
||||
NetworkManager::ConnectionSettings::Ptr connSetting = assembleWirelessSettings(connSettingInfo);
|
||||
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
|
||||
assembleEapMethodTtlsSettings(connSetting, ttlsInfo);
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = tr("create wireless ttls connection failed: ") + watcher->error().message();
|
||||
qWarning()<<errorMessage;
|
||||
emit this->createConnectionError(errorMessage);
|
||||
} else {
|
||||
qDebug()<<"create wireless connect complete";
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateWirelessPersonalConnect(const QString &uuid, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + uuid;
|
||||
qWarning()<<errorMessage;
|
||||
emit updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
|
||||
//更新ipv4 ipv6信息
|
||||
updateConnect(connectionSettings, connSettingInfo);
|
||||
|
||||
KyKeyMgmt oldType = getConnectKeyMgmt(connectionSettings);
|
||||
if (Unknown == oldType)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (connSettingInfo.m_type != WpaNone && connSettingInfo.m_type != connSettingInfo.m_type && oldType != SAE)
|
||||
{
|
||||
qDebug() << "updateWirelessPersonalConnect " << connSettingInfo.m_type << " not support";
|
||||
return;
|
||||
}
|
||||
|
||||
updateWirelessSecu(connectionSettings, connSettingInfo, bPwdChange);
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsInfo, const KyWirelessConnectSetting &connSettingInfo)
|
||||
{
|
||||
if(connSettingInfo.m_type != WpaEap)
|
||||
{
|
||||
QString errorMessage = tr("eapType is not wpa-eap");
|
||||
qWarning()<<errorMessage;
|
||||
emit updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + uuid;
|
||||
qWarning()<<errorMessage;
|
||||
emit updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
//更新ipv4 ipv6信息
|
||||
updateConnect(connectionSettings, connSettingInfo);
|
||||
|
||||
//是否默认连接
|
||||
updateWirelessSecu(connectionSettings, connSettingInfo);
|
||||
modifyEapMethodTlsSettings(connectionSettings, tlsInfo);
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo, const KyWirelessConnectSetting &connSettingInfo)
|
||||
{
|
||||
if(connSettingInfo.m_type != WpaEap)
|
||||
{
|
||||
QString errorMessage = tr("eapType is not wpa-eap");
|
||||
qWarning()<<errorMessage;
|
||||
emit updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + uuid;
|
||||
qWarning()<<errorMessage;
|
||||
emit updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
//更新ipv4 ipv6信息
|
||||
updateConnect(connectionSettings, connSettingInfo);
|
||||
|
||||
//是否默认连接
|
||||
updateWirelessSecu(connectionSettings, connSettingInfo);
|
||||
modifyEapMethodPeapSettings(connectionSettings, peapInfo);
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo, const KyWirelessConnectSetting &connSettingInfo)
|
||||
{
|
||||
if(connSettingInfo.m_type != WpaEap)
|
||||
{
|
||||
QString errorMessage = tr("eapType is not wpa-eap");
|
||||
qWarning()<<errorMessage;
|
||||
emit updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (nullptr == connectPtr) {
|
||||
QString errorMessage = tr("it can not find connection") + uuid;
|
||||
qWarning()<<errorMessage;
|
||||
emit updateConnectionError(errorMessage);
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
//更新ipv4 ipv6信息
|
||||
updateConnect(connectionSettings, connSettingInfo);
|
||||
|
||||
//是否默认连接
|
||||
updateWirelessSecu(connectionSettings, connSettingInfo);
|
||||
modifyEapMethodTtlsSettings(connectionSettings, ttlsInfo);
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
return;
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & devIface,KyWirelessConnectSetting &connSettingInfo,bool isHidden)
|
||||
{
|
||||
qDebug() << "addAndActiveWirelessConnect" << connSettingInfo.m_ssid << devIface <<connSettingInfo.m_psk;
|
||||
QString conn_uni;
|
||||
QString dev_uni;
|
||||
QString conn_name;
|
||||
QString dev_name;
|
||||
QString spec_object;
|
||||
NMVariantMapMap map_settings;
|
||||
bool bFind = false;
|
||||
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = nullptr;
|
||||
|
||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (!isHidden && wifiNet.isNull())
|
||||
{
|
||||
auto dev = m_networkResourceInstance->findDeviceUni(net->device());
|
||||
if (dev == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (dev->type() != NetworkManager::Device::Wifi || dev->interfaceName() != devIface)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (ssid == net->ssid())
|
||||
{
|
||||
wifiNet = net;
|
||||
bFind = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFind)
|
||||
{
|
||||
qDebug() << "addAndActiveWirelessConnect can not find " << ssid << " in " << devIface;
|
||||
qDebug() << "addAndActiveWirelessConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
return;
|
||||
}
|
||||
|
||||
auto access_point = wifiNet->referenceAccessPoint();
|
||||
qDebug() << "addAndActiveWirelessConnect find " << connSettingInfo.m_ssid << " in " << devIface << " or hide";
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||
if (dev.isNull())
|
||||
{
|
||||
emit connectFail(ssid, devIface, "devIface not exist");
|
||||
emit andAndActivateConnectionError("can not find device");
|
||||
return;
|
||||
}
|
||||
auto spec_dev = dev->as<NetworkManager::WirelessDevice>();
|
||||
Q_ASSERT(nullptr != spec_dev);
|
||||
conn_uni = access_point->uni();
|
||||
conn_name = access_point->ssid();
|
||||
dev_name = dev->interfaceName();
|
||||
|
||||
qDebug() << "addAndActiveWirelessConnect device " << devIface << " exist";
|
||||
dev_uni = dev->uni();
|
||||
|
||||
spec_object = conn_uni;
|
||||
NetworkManager::WirelessSecurityType sec_type = NetworkManager::findBestWirelessSecurity(spec_dev->wirelessCapabilities()
|
||||
, true, (spec_dev->mode() == NetworkManager::WirelessDevice::Adhoc)
|
||||
, access_point->capabilities(), access_point->wpaFlags(), access_point->rsnFlags());
|
||||
|
||||
qDebug() << "findBestWirelessSecurity type "<< sec_type;
|
||||
switch (sec_type)
|
||||
auto spec_dev = dev->as<NetworkManager::WirelessDevice>();
|
||||
qDebug() << dev_uni;
|
||||
if (!isHidden)
|
||||
{
|
||||
qDebug() << "start assemble";
|
||||
auto access_point = wifiNet->referenceAccessPoint();
|
||||
qDebug() << "1";
|
||||
conn_uni = access_point->uni();
|
||||
qDebug() << "2";
|
||||
conn_name = access_point->ssid();
|
||||
qDebug() << "3";
|
||||
spec_object = conn_uni;
|
||||
qDebug() << "start findBestWirelessSecurity";
|
||||
NetworkManager::WirelessSecurityType sec_type = NetworkManager::findBestWirelessSecurity(spec_dev->wirelessCapabilities()
|
||||
, true, (spec_dev->mode() == NetworkManager::WirelessDevice::Adhoc)
|
||||
, access_point->capabilities(), access_point->wpaFlags(), access_point->rsnFlags());
|
||||
|
||||
qDebug() << "findBestWirelessSecurity type "<< sec_type;
|
||||
|
||||
switch (sec_type)
|
||||
{
|
||||
case NetworkManager::UnknownSecurity:
|
||||
qWarning() << QStringLiteral("unknown security to use for '%1'").arg(conn_name);
|
||||
case NetworkManager::NoneSecurity:
|
||||
|
@ -273,7 +349,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & ssid, QSt
|
|||
break;
|
||||
case NetworkManager::WpaPsk:
|
||||
case NetworkManager::Wpa2Psk:
|
||||
if (NetworkManager::ConnectionSettings::Ptr settings = assembleWpaXPskSettings(access_point, psk, isAutoConnect ,secretFlags))
|
||||
if (NetworkManager::ConnectionSettings::Ptr settings = assembleWpaXPskSettings(access_point, connSettingInfo.m_psk, connSettingInfo.isAutoConnect ,connSettingInfo.m_secretFlag))
|
||||
{
|
||||
map_settings = settings->toMap();
|
||||
} else
|
||||
|
@ -284,56 +360,26 @@ void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & ssid, QSt
|
|||
break;
|
||||
//TODO: other types...
|
||||
default:
|
||||
qDebug() << "not support";
|
||||
qDebug() << "addAndActiveWirelessConnect not support";
|
||||
break;
|
||||
}
|
||||
|
||||
qDebug() << dev_uni;
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid())
|
||||
{
|
||||
qDebug() << "activation of connection failed " << watcher->error().message();
|
||||
emit connectFail(ssid, devIface, "Internal error");
|
||||
}
|
||||
watcher->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessHiddenConnect(KySecuType &type, QString &ssid, QString &devIface,
|
||||
QString &psk, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
||||
{
|
||||
qDebug() << "addAndActiveWirelessHiddenConnect";
|
||||
QString conn_uni;
|
||||
QString dev_uni;
|
||||
QString conn_name;
|
||||
QString dev_name;
|
||||
QString spec_object;
|
||||
NMVariantMapMap map_settings;
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||
if (dev.isNull())
|
||||
{
|
||||
emit connectFail(ssid, devIface, "devIface not exist");
|
||||
return;
|
||||
qDebug() << "finish assemble";
|
||||
} else {
|
||||
qDebug() << "start assembleWirelessSettings";
|
||||
map_settings = assembleWirelessSettings(connSettingInfo)->toMap();
|
||||
qDebug() << "finish assembleWirelessSettings";
|
||||
}
|
||||
dev_name = dev->interfaceName();
|
||||
dev_uni = dev->uni();
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr settings = assembleWpaXPskHiddenSettings(ssid, type, psk, isAutoConnect, secretFlags);
|
||||
map_settings = settings->toMap();
|
||||
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid())
|
||||
{
|
||||
qDebug() << "activation of connection failed " << watcher->error().message();
|
||||
emit connectFail(ssid, devIface, "Internal error");
|
||||
QString errorMessage = watcher->error().message();
|
||||
qDebug() << "activation of connection failed " << errorMessage;
|
||||
emit andAndActivateConnectionError(errorMessage);
|
||||
}
|
||||
watcher->deleteLater();
|
||||
watcher->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -350,42 +396,21 @@ void KyWirelessConnectOperation::requestWirelessScan()
|
|||
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo &info, QString & devIface,
|
||||
bool isHidden, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo &info, KyWirelessConnectSetting &connSettingInfo,
|
||||
QString & devIface, bool isHidden)
|
||||
{
|
||||
QString conn_uni;
|
||||
QString dev_uni;
|
||||
QString conn_name;
|
||||
QString dev_name;
|
||||
QString spec_object;
|
||||
NMVariantMapMap map_settings;
|
||||
bool bFind = false;
|
||||
|
||||
if (!isHidden)
|
||||
{
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = nullptr;
|
||||
|
||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull())
|
||||
{
|
||||
auto dev = m_networkResourceInstance->findDeviceUni(net->device());
|
||||
if (dev == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (dev->type() != NetworkManager::Device::Wifi || dev->interfaceName() != devIface)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (info.connName == net->ssid())
|
||||
{
|
||||
wifiNet = net;
|
||||
bFind = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFind)
|
||||
{
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTlsConnect can not find " << info.connName << " in " << devIface;
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTlsConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -398,16 +423,17 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapM
|
|||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||
if (dev.isNull())
|
||||
{
|
||||
emit connectFail(info.connName, devIface, "devIface not exist");
|
||||
emit andAndActivateConnectionError("can not find device");
|
||||
return;
|
||||
}
|
||||
dev_name = dev->interfaceName();
|
||||
dev_uni = dev->uni();
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr settings = KyEnterPriceSettingInfo::assembleEapMethodTlsSettings(info, isAutoConnect, secretFlags);
|
||||
NetworkManager::ConnectionSettings::Ptr settings = assembleWirelessSettings(connSettingInfo);
|
||||
assembleEapMethodTlsSettings(settings, info);
|
||||
|
||||
if(settings.isNull())
|
||||
{
|
||||
qDebug() << "assembleEapMethodPeapSettings failed";
|
||||
qDebug() << "assembleEapMethodTlsSettings failed";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -418,51 +444,31 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapM
|
|||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid())
|
||||
{
|
||||
qDebug() << "activation of connection failed " << watcher->error().message();
|
||||
emit connectFail(info.connName, devIface, "Internal error");
|
||||
QString errorMessage = watcher->error().message();
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTlsConnect failed " << errorMessage;
|
||||
emit andAndActivateConnectionError(errorMessage);
|
||||
}
|
||||
watcher->deleteLater();
|
||||
watcher->deleteLater();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEapMethodPeapInfo &info, QString &devIface,
|
||||
bool isHidden, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEapMethodPeapInfo &info, KyWirelessConnectSetting &connSettingInfo,
|
||||
QString & devIface, bool isHidden)
|
||||
{
|
||||
qDebug() <<"addAndActiveWirelessEnterPrisePeapConnect";
|
||||
QString conn_uni;
|
||||
QString dev_uni;
|
||||
QString conn_name;
|
||||
QString dev_name;
|
||||
QString spec_object;
|
||||
NMVariantMapMap map_settings;
|
||||
bool bFind = false;
|
||||
|
||||
if (!isHidden)
|
||||
{
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = nullptr;
|
||||
|
||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull())
|
||||
{
|
||||
auto dev = m_networkResourceInstance->findDeviceUni(net->device());
|
||||
if (dev == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (dev->type() != NetworkManager::Device::Wifi || dev->interfaceName() != devIface)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (info.connName == net->ssid())
|
||||
{
|
||||
wifiNet = net;
|
||||
bFind = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFind)
|
||||
{
|
||||
qDebug() << "addAndActiveWirelessEnterPrisePeapConnect can not find " << info.connName << " in " << devIface;
|
||||
qDebug() << "addAndActiveWirelessEnterPrisePeapConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -476,19 +482,19 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEap
|
|||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||
if (dev.isNull())
|
||||
{
|
||||
emit connectFail(info.connName, devIface, "devIface not exist");
|
||||
emit andAndActivateConnectionError("can not find device");
|
||||
return;
|
||||
}
|
||||
dev_name = dev->interfaceName();
|
||||
dev_uni = dev->uni();
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr settings = KyEnterPriceSettingInfo::assembleEapMethodPeapSettings(info, isAutoConnect, secretFlags);
|
||||
NetworkManager::ConnectionSettings::Ptr settings = assembleWirelessSettings(connSettingInfo);
|
||||
assembleEapMethodPeapSettings(settings, info);
|
||||
|
||||
if(settings.isNull())
|
||||
{
|
||||
qDebug() << "assembleEapMethodPeapSettings failed";
|
||||
return;
|
||||
}
|
||||
|
||||
map_settings = settings->toMap();
|
||||
|
||||
QDBusPendingCallWatcher * watcher;
|
||||
|
@ -496,50 +502,30 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEap
|
|||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid())
|
||||
{
|
||||
qDebug() << "activation of connection failed " << watcher->error().message();
|
||||
emit connectFail(info.connName, devIface, "Internal error");
|
||||
QString errorMessage = watcher->error().message();
|
||||
qDebug() << "addAndActiveWirelessEnterPrisePeapConnect failed " << errorMessage;
|
||||
emit andAndActivateConnectionError(errorMessage);
|
||||
}
|
||||
watcher->deleteLater();
|
||||
watcher->deleteLater();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &info, QString &devIface,
|
||||
bool isHidden, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &info, KyWirelessConnectSetting &connSettingInfo,
|
||||
QString & devIface, bool isHidden)
|
||||
{
|
||||
QString conn_uni;
|
||||
QString dev_uni;
|
||||
QString conn_name;
|
||||
QString dev_name;
|
||||
QString spec_object;
|
||||
NMVariantMapMap map_settings;
|
||||
bool bFind = false;
|
||||
|
||||
if (!isHidden)
|
||||
{
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = nullptr;
|
||||
|
||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull())
|
||||
{
|
||||
auto dev = m_networkResourceInstance->findDeviceUni(net->device());
|
||||
if (dev == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (dev->type() != NetworkManager::Device::Wifi || dev->interfaceName() != devIface)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (info.connName == net->ssid())
|
||||
{
|
||||
wifiNet = net;
|
||||
bFind = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFind)
|
||||
{
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTlsConnect can not find " << info.connName << " in " << devIface;
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -552,16 +538,17 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
|
|||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||
if (dev.isNull())
|
||||
{
|
||||
emit connectFail(info.connName, devIface, "devIface not exist");
|
||||
emit andAndActivateConnectionError("can not find device");
|
||||
return;
|
||||
}
|
||||
dev_name = dev->interfaceName();
|
||||
dev_uni = dev->uni();
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr settings = KyEnterPriceSettingInfo::assembleEapMethodTtlsSettings(info, isAutoConnect, secretFlags);
|
||||
NetworkManager::ConnectionSettings::Ptr settings = assembleWirelessSettings(connSettingInfo);
|
||||
assembleEapMethodTtlsSettings(settings, info);
|
||||
|
||||
if(settings.isNull())
|
||||
{
|
||||
qDebug() << "assembleEapMethodPeapSettings failed";
|
||||
qDebug() << "assembleEapMethodTtlsSettings failed";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -572,10 +559,11 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
|
|||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid())
|
||||
{
|
||||
qDebug() << "activation of connection failed " << watcher->error().message();
|
||||
emit connectFail(info.connName, devIface, "Internal error");
|
||||
QString errorMessage = watcher->error().message();
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect failed " << errorMessage;
|
||||
emit andAndActivateConnectionError(errorMessage);
|
||||
}
|
||||
watcher->deleteLater();
|
||||
watcher->deleteLater();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -601,7 +589,58 @@ bool KyWirelessConnectOperation::getConnSecretFlags(QString &connUuid, NetworkMa
|
|||
}
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
flag = security_sett->pskFlags();
|
||||
return true;
|
||||
}
|
||||
|
||||
//private
|
||||
NetworkManager::WirelessNetwork::Ptr KyWirelessConnectOperation::checkWifiNetExist(QString ssid, QString devName)
|
||||
{
|
||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
||||
{
|
||||
auto dev = m_networkResourceInstance->findDeviceUni(net->device());
|
||||
if (dev == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (dev->type() != NetworkManager::Device::Wifi || dev->interfaceName() != devName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (ssid == net->ssid())
|
||||
{
|
||||
return net;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
KyKeyMgmt KyWirelessConnectOperation::getConnectKeyMgmt(NetworkManager::ConnectionSettings::Ptr connSettingPtr)
|
||||
{
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
|
||||
if(security_sett.isNull())
|
||||
{
|
||||
return KyKeyMgmt::Unknown;
|
||||
}
|
||||
return (KyKeyMgmt)security_sett->keyMgmt();
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::updateWirelessSecu(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange)
|
||||
{
|
||||
connSettingPtr->setAutoconnect(connSettingInfo.isAutoConnect);
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
|
||||
KyKeyMgmt type = connSettingInfo.m_type;
|
||||
security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)type);
|
||||
if (bPwdChange)
|
||||
{
|
||||
security_sett->setPsk(connSettingInfo.m_psk);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
#define KYWIRELESSCONNECTOPERATION_H
|
||||
|
||||
#include <QObject>
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include "kyenterpricesettinginfo.h"
|
||||
#include "kylinconnectoperation.h"
|
||||
#include "kylinwirelessconnectsetting.h"
|
||||
#include "kyenterpricesettinginfo.h"
|
||||
|
||||
enum KySecuType {
|
||||
NONE = 0,
|
||||
|
@ -20,32 +21,55 @@ public:
|
|||
explicit KyWirelessConnectOperation(QObject *parent = nullptr);
|
||||
~KyWirelessConnectOperation();
|
||||
|
||||
//无线开关
|
||||
void setWirelessEnabled(bool enabled);
|
||||
bool getWirelessEnabled();
|
||||
|
||||
bool getConnSecretFlags(QString &, NetworkManager::Setting::SecretFlags &);
|
||||
//获取密码保存策略
|
||||
bool getConnSecretFlags(QString &connUuid, NetworkManager::Setting::SecretFlags &);
|
||||
|
||||
//激活连接
|
||||
void activeWirelessConnect(QString , QString);
|
||||
void deactivateWirelessConnection(const QString activeConnectName, const QString &activeConnectUuid);
|
||||
//todo:
|
||||
// void activeWirelessConnectWithPwd(QString , QString, QString);
|
||||
void deActiveWirelessConnect(QString &);
|
||||
void addAndActiveWirelessConnect(QString &, QString &, QString, bool, NetworkManager::Setting::SecretFlags);
|
||||
void requestWirelessScan();
|
||||
//仅普通隐藏wifi
|
||||
void addAndActiveWirelessHiddenConnect(KySecuType &, QString &, QString &, QString &, bool, NetworkManager::Setting::SecretFlags flags = 0);
|
||||
//企业wifi
|
||||
void addAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo &, QString &, bool, bool, NetworkManager::Setting::SecretFlags flags = 0);
|
||||
void addAndActiveWirelessEnterPrisePeapConnect(KyEapMethodPeapInfo &, QString &, bool, bool, NetworkManager::Setting::SecretFlags flags = 0);
|
||||
void addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &, QString &, bool, bool, NetworkManager::Setting::SecretFlags flags = 0);
|
||||
//断开连接
|
||||
void deActivateWirelessConnection(const QString activeConnectName, const QString &activeConnectUuid);
|
||||
//新增普通连接
|
||||
void addConnect(const KyWirelessConnectSetting &connSettingInfo);
|
||||
//新增TLS连接
|
||||
void addTlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTlsInfo &tlsinfo);
|
||||
//新增PEAP连接
|
||||
void addPeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPeapInfo &peapInfo);
|
||||
//新增TTLS连接
|
||||
void addTtlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTtlsInfo &ttlsInfo);
|
||||
//新增连接并激活(普通wifi)
|
||||
void addAndActiveWirelessConnect(QString & devIface,KyWirelessConnectSetting &connSettingInfo,bool isHidden);
|
||||
|
||||
//新增连接并激活(企业wifi)
|
||||
void addAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo &info, KyWirelessConnectSetting &connSettingInfo,
|
||||
QString & devIface, bool isHidden);
|
||||
void addAndActiveWirelessEnterPrisePeapConnect(KyEapMethodPeapInfo &info, KyWirelessConnectSetting &connSettingInfo,
|
||||
QString & devIface, bool isHidden);
|
||||
void addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &info, KyWirelessConnectSetting &connSettingInfo,
|
||||
QString & devIface, bool isHidden);
|
||||
|
||||
//连接修改(安全改为个人/None)
|
||||
void updateWirelessPersonalConnect(const QString &uuid, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange);
|
||||
//连接修改(安全改为改为企业)
|
||||
void updateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsinfo, const KyWirelessConnectSetting &connSettingInfo);
|
||||
void updateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo, const KyWirelessConnectSetting &connSettingInfo);
|
||||
void updateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo, const KyWirelessConnectSetting &connSettingInfo);
|
||||
|
||||
//申请扫描
|
||||
void requestWirelessScan();
|
||||
|
||||
signals:
|
||||
void connectFail(QString, QString, QString);//连接失败信号
|
||||
void disConnectFail(QString, QString, QString);
|
||||
void wifinEnabledChanged(bool);
|
||||
void andAndActivateConnectionError(QString errorMessage);
|
||||
|
||||
private:
|
||||
NetworkManager::WirelessNetwork::Ptr checkWifiNetExist(QString ssid, QString devName);
|
||||
void updateWirelessSecu(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange = false);
|
||||
KyKeyMgmt getConnectKeyMgmt(NetworkManager::ConnectionSettings::Ptr connSettingPtr);
|
||||
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
|
||||
};
|
||||
|
|
|
@ -23,12 +23,14 @@ public:
|
|||
QString m_bssid;
|
||||
int m_signalStrength;
|
||||
uint m_frequency;
|
||||
QString m_secuType;
|
||||
|
||||
//only for m_isConfiged = true
|
||||
bool m_isConfigured;
|
||||
QString m_connName;
|
||||
QString m_connDbusPath;
|
||||
QString m_secuType;
|
||||
// NetworkManager::AccessPoint::WpaFlags m_wpaFlag;
|
||||
// NetworkManager::AccessPoint::WpaFlags m_rsnFlag;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
|
|
|
@ -49,6 +49,25 @@ bool KyWirelessNetResource::getDeviceWifiNetwork(QString devIfaceName, QList<KyW
|
|||
}
|
||||
}
|
||||
|
||||
bool KyWirelessNetResource::getWifiNetwork(QString &devIfaceName,QString &ssid, KyWirelessNetItem &KyWirelessNetResource)
|
||||
{
|
||||
onWifiNetworkDeviceDisappear();
|
||||
if (!m_WifiNetworkList.contains(devIfaceName))
|
||||
{
|
||||
return false;
|
||||
} else {
|
||||
for (int index = 0; m_WifiNetworkList[devIfaceName].size(); index ++)
|
||||
{
|
||||
if (m_WifiNetworkList[devIfaceName].at(index).m_NetSsid == ssid)
|
||||
{
|
||||
KyWirelessNetResource = m_WifiNetworkList[devIfaceName].at(index);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KyWirelessNetResource::getWirelessActiveConnection(QMap<QString,QStringList> &map)
|
||||
{
|
||||
int index = 0;
|
||||
|
@ -379,7 +398,6 @@ bool KyWirelessNetResource::modifyEnterPriseInfoPeap(QString &uuid, KyEapMethodP
|
|||
return false;
|
||||
}
|
||||
|
||||
info.connName = conn->name();
|
||||
info.phase2AuthMethod = (KyEapMethodPeapAuth)setting->phase2AuthEapMethod();
|
||||
info.userName = setting->identity();
|
||||
info.userPWD = setting->password();
|
||||
|
@ -414,7 +432,6 @@ bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeap
|
|||
return false;
|
||||
}
|
||||
|
||||
info.connName = conn->name();
|
||||
info.phase2AuthMethod = (KyEapMethodPeapAuth)setting->phase2AuthEapMethod();
|
||||
info.userName = setting->identity();
|
||||
info.userPWD = setting->password();
|
||||
|
@ -503,7 +520,6 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls
|
|||
return false;
|
||||
}
|
||||
|
||||
info.connName = conn->name();
|
||||
info.authEapMethod = (KyEapMethodTtlsAuth)setting->phase2AuthEapMethod();
|
||||
info.authNoEapMethod = (KyNoEapMethodTtlsAuth)setting->phase2AuthMethod();
|
||||
|
||||
|
|
|
@ -17,16 +17,17 @@ public:
|
|||
~KyWirelessNetResource();
|
||||
|
||||
//ui层调用接口
|
||||
bool getWifiNetwork(QString &devIfaceName,QString &ssid, KyWirelessNetItem &KyWirelessNetResource);
|
||||
bool getAllDeviceWifiNetwork(QMap<QString,QList<KyWirelessNetItem> > &map);
|
||||
bool getDeviceWifiNetwork(QString devIfaceName, QList<KyWirelessNetItem> &KyWirelessNetResource);
|
||||
|
||||
bool modifyEnterPriseInfoTls(QString &, KyEapMethodTlsInfo &);
|
||||
bool modifyEnterPriseInfoPeap(QString &, KyEapMethodPeapInfo &);
|
||||
bool modifyEnterPriseInfoTtls(QString &, KyEapMethodTtlsInfo &);
|
||||
bool modifyEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info);
|
||||
bool modifyEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info);
|
||||
bool modifyEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info);
|
||||
|
||||
bool getEnterPriseInfoTls(QString &, KyEapMethodTlsInfo &);
|
||||
bool getEnterPriseInfoPeap(QString &, KyEapMethodPeapInfo &);
|
||||
bool getEnterPriseInfoTtls(QString &, KyEapMethodTtlsInfo &);
|
||||
bool getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info);
|
||||
bool getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info);
|
||||
bool getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info);
|
||||
|
||||
bool getWirelessActiveConnection(QMap<QString, QStringList> &map);
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "wireless-security/dlghidewifi.h"
|
||||
#include "sysdbusregister.h"
|
||||
#include "kylinwiredwidget.h"
|
||||
#include "nmdemo.h"
|
||||
|
||||
#include <algorithm>//sort函数包含的头文件
|
||||
|
||||
|
@ -139,6 +140,9 @@ void MainWindow::secondaryStart()
|
|||
|
||||
qDebug()<<"Init ksnm...";
|
||||
this->ksnm = new KSimpleNM();
|
||||
|
||||
NmDemo* a = new NmDemo(this);
|
||||
a->show();
|
||||
#if 0
|
||||
connect(ksnm, SIGNAL(getLanListFinished(QStringList)), this, SLOT(getLanListDone(QStringList)));
|
||||
connect(ksnm, SIGNAL(getWifiListFinished(QStringList)), this, SLOT(getWifiListDone(QStringList)));
|
||||
|
|
|
@ -33,8 +33,9 @@ NmDemo::NmDemo(QWidget *parent) : QDialog(parent)
|
|||
|
||||
//init ptr
|
||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
m_wco = new KyWirelessConnectOperation();
|
||||
m_wco = new KyWirelessConnectOperation(this);
|
||||
m_wnr = new KyWirelessNetResource(this);
|
||||
m_acr = new KyActiveConnectResourse(this);
|
||||
m_timer = new QTimer(this);
|
||||
|
||||
initUi();
|
||||
|
@ -132,8 +133,14 @@ void NmDemo::initConnect()
|
|||
connect(enableButton, &QPushButton::clicked, this, &NmDemo::onEnableClick);
|
||||
connect(disableButton, &QPushButton::clicked, this, &NmDemo::onDisableClick);
|
||||
//连接变化
|
||||
connect(m_wco, &KyWirelessConnectOperation::connectFail, this, &NmDemo::onWcoSignals);
|
||||
connect(m_wco, &KyWirelessConnectOperation::disConnectFail, this, &NmDemo::onWcoSignals);
|
||||
|
||||
|
||||
connect(m_wco, &KyWirelessConnectOperation::createConnectionError, this, &NmDemo::onWcoSignals);
|
||||
connect(m_wco, &KyWirelessConnectOperation::updateConnectionError, this, &NmDemo::onWcoSignals);
|
||||
connect(m_wco, &KyWirelessConnectOperation::deleteConnectionError, this, &NmDemo::onWcoSignals);
|
||||
connect(m_wco, &KyWirelessConnectOperation::activateConnectionError, this, &NmDemo::onWcoSignals);
|
||||
connect(m_wco, &KyWirelessConnectOperation::deactivateConnectionError, this, &NmDemo::onWcoSignals);
|
||||
connect(m_wco, &KyWirelessConnectOperation::andAndActivateConnectionError, this, &NmDemo::onWcoSignals);
|
||||
|
||||
//列表变化
|
||||
connect(m_wnr, &KyWirelessNetResource::bssidChange, this ,&NmDemo::onBssidChange);
|
||||
|
@ -145,10 +152,11 @@ void NmDemo::initConnect()
|
|||
connect(m_wnr, &KyWirelessNetResource::wifiNetworkAdd, this ,&NmDemo::onWifiNetworkAdd);
|
||||
connect(m_wnr, &KyWirelessNetResource::wifiNetworkRemove, this ,&NmDemo::onWifiNetworkRemove);
|
||||
|
||||
//connect(m_networkResourceInstance, &KyNetworkResourceManager::activeConnectionAdd, this, &NmDemo::onActiveConnectionAdd);
|
||||
//connect(m_networkResourceInstance, &KyNetworkResourceManager::activeConnectionUpdate, this, &NmDemo::onActiveConnectionUpdate);
|
||||
//connect(m_networkResourceInstance, &KyNetworkResourceManager::activeConnectionRemove, this, &NmDemo::onActiveConnectionRemove);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::activeConnectionsReset, this, &NmDemo::onActiveConnectionsReset);
|
||||
connect(m_acr, &KyActiveConnectResourse::stateChangeReason, this, [this](QString uuid,
|
||||
NetworkManager::ActiveConnection::State state,
|
||||
NetworkManager::ActiveConnection::Reason reason){
|
||||
appendDebugLog(QString("%1 %2 %3").arg(uuid).arg(state).arg(reason));
|
||||
});
|
||||
}
|
||||
|
||||
void NmDemo::initTimer()
|
||||
|
@ -163,9 +171,9 @@ void NmDemo::initTimer()
|
|||
}
|
||||
|
||||
|
||||
void NmDemo::onWcoSignals(QString ssid, QString devIFace, QString reason)
|
||||
void NmDemo::onWcoSignals(QString errorMessage)
|
||||
{
|
||||
appendDebugLog(ssid + " connect or disconnect faild because " + reason);
|
||||
appendDebugLog(errorMessage);
|
||||
}
|
||||
|
||||
void NmDemo::onBssidChange(QString devIface, QString ssid, QString bssid)
|
||||
|
@ -245,10 +253,11 @@ void NmDemo::onConnectClicked()
|
|||
}
|
||||
if (isEnterPirse)
|
||||
{
|
||||
qDebug() <<"EnterPrice";
|
||||
return;
|
||||
if(!isNew)
|
||||
{
|
||||
KyEapMethodPeapInfo a;
|
||||
a.connName = ssid;
|
||||
a.phase2AuthMethod = AuthEapMethodPeapMschapv2;
|
||||
a.userName = "steve";
|
||||
a.userPWD = "testing";
|
||||
|
@ -263,31 +272,35 @@ void NmDemo::onConnectClicked()
|
|||
return;
|
||||
} else {
|
||||
KyEapMethodTtlsInfo c;
|
||||
c.connName = ssid;
|
||||
c.authType = AUTH_NO_EAP;
|
||||
c.authNoEapMethod = AuthMethodTtlsMschapv2;
|
||||
c.userName = "steve";
|
||||
c.userPWD = "testing";
|
||||
appendDebugLog("addAndActiveWirelessEnterPriseTtlsConnect...");
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect";
|
||||
m_wco->addAndActiveWirelessEnterPriseTtlsConnect(c, devIface, isHidden, true, 0);
|
||||
// m_wco->addAndActiveWirelessEnterPriseTtlsConnect(c, devIface, isHidden, true, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
KySecuType secuType = WPA_AND_WPA2_PERSONAL;
|
||||
if (isHidden)
|
||||
{
|
||||
appendDebugLog("addAndActiveWirelessHiddenConnect...");
|
||||
m_wco->addAndActiveWirelessHiddenConnect(secuType, ssid, devIface, pwd, true, 0);
|
||||
return;
|
||||
}
|
||||
if (isNew)
|
||||
{
|
||||
appendDebugLog("addAndActiveWirelessConnect...");
|
||||
m_wco->addAndActiveWirelessConnect(ssid, devIface, pwd, true, 0);
|
||||
KyWirelessConnectSetting a;
|
||||
a.m_connectName = ssid;
|
||||
a.m_ssid = ssid;
|
||||
a.isAutoConnect = true;
|
||||
a.m_psk = pwd;
|
||||
a.m_secretFlag = NetworkManager::Setting::None;
|
||||
a.m_type = WpaPsk;
|
||||
|
||||
|
||||
m_wco->addAndActiveWirelessConnect(devIface,a, isHidden);
|
||||
} else {
|
||||
appendDebugLog("activeWirelessConnectWithPwd...");
|
||||
m_wco->activeWirelessConnect(devIface,uuid);
|
||||
NetworkManager::Setting::SecretFlags c;
|
||||
m_wco->getConnSecretFlags(uuid, c);
|
||||
appendDebugLog(QString("%1").arg(c));
|
||||
// appendDebugLog("activeWirelessConnect...");
|
||||
// m_wco->activeWirelessConnect(devIface,uuid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +332,7 @@ void NmDemo::onDisConnectClicked()
|
|||
return;
|
||||
}
|
||||
appendDebugLog("deActiveWirelessConnect " + ssid);
|
||||
m_wco->deActiveWirelessConnect(uuid);
|
||||
m_wco->deActivateWirelessConnection(ssid, uuid);
|
||||
}
|
||||
|
||||
void NmDemo::onModifyClicked()
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "backend/dbus-interface/kylinnetworkresourcemanager.h"
|
||||
#include "backend/dbus-interface/kywirelessconnectoperation.h"
|
||||
#include "backend/dbus-interface/kywirelessnetresource.h"
|
||||
#include "backend/dbus-interface/kylinwirelessconnectsetting.h"
|
||||
#include "backend/dbus-interface/kylinactiveconnectresource.h"
|
||||
|
||||
class NmDemo : public QDialog
|
||||
{
|
||||
|
@ -37,6 +39,7 @@ public:
|
|||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
KyWirelessConnectOperation *m_wco;
|
||||
KyWirelessNetResource *m_wnr;
|
||||
KyActiveConnectResourse *m_acr;
|
||||
|
||||
private:
|
||||
QTimer *m_timer;
|
||||
|
@ -53,7 +56,7 @@ private:
|
|||
void getWifiList();
|
||||
|
||||
public slots:
|
||||
void onWcoSignals(QString, QString, QString);
|
||||
void onWcoSignals(QString);
|
||||
void onBssidChange(QString, QString, QString);
|
||||
void onSecuTypeChange(QString, QString, QString);
|
||||
void onSignalStrengthChange(QString, QString, int);
|
||||
|
|
|
@ -477,8 +477,8 @@ void OneLancForm::toConnectWiredNetwork()
|
|||
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
|
||||
t->start();
|
||||
*/
|
||||
|
||||
m_wiredConnectOperation->activateWiredConnection(uuidName);
|
||||
QString devName = "enp2s0";
|
||||
m_wiredConnectOperation->activateWiredConnection(uuidName, devName);
|
||||
}
|
||||
|
||||
//点击列表中item扩展后显示信息的位置时,执行该函数,用于显示网络配置界面
|
||||
|
|
Loading…
Reference in New Issue