method update

This commit is contained in:
jzxc95 2021-08-13 15:09:56 +08:00
parent cd5de86c3c
commit 54cd2ca9e6
15 changed files with 410 additions and 394 deletions

View File

@ -14,7 +14,6 @@ HEADERS += \
$$PWD/kylinnetworkresourcemanager.h \
$$PWD/kylinvpnconnectitem.h \
$$PWD/kylinwiredconnectoperation.h \
$$PWD/kylinwirelessconnectsetting.h \
$$PWD/kywirelessconnectoperation.h \
$$PWD/kywirelessnetitem.h \
$$PWD/kywirelessnetresource.h
@ -33,7 +32,6 @@ SOURCES += \
$$PWD/kylinnetworkresourcemanager.cpp \
$$PWD/kylinvpnconnectitem.cpp \
$$PWD/kylinwiredconnectoperation.cpp \
$$PWD/kylinwirelessconnectsetting.cpp \
$$PWD/kywirelessconnectoperation.cpp \
$$PWD/kywirelessnetitem.cpp \
$$PWD/kywirelessnetresource.cpp

View File

@ -41,7 +41,7 @@ void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connS
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap);
wifi_8021x_sett->setInitialized(true);
wifi_8021x_sett->setEapMethods(list);
wifi_8021x_sett->setPhase2AuthEapMethod((NetworkManager::Security8021xSetting::AuthEapMethod)info.phase2AuthMethod);
wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)info.phase2AuthMethod);
wifi_8021x_sett->setIdentity(info.userName);
wifi_8021x_sett->setPassword(info.userPWD);
wifi_8021x_sett->setPasswordFlags(info.m_passwdFlag);
@ -126,7 +126,7 @@ void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSet
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->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)peapInfo.phase2AuthMethod);
wifi_8021x_sett->setIdentity(peapInfo.userName);
if(peapInfo.bChanged)
{

View File

@ -20,19 +20,32 @@ public:
bool bChanged;
};
typedef enum {
KyAuthEapMethodUnknown = 0,
KyAuthEapMethodMd5,
KyAuthEapMethodMschapv2,
KyAuthEapMethodOtp,
KyAuthEapMethodGtc,
KyAuthEapMethodTls
} KyEapMethodAuth;
typedef enum{
AuthEapMethodPeapUnknown = 0,
AuthEapMethodPeapMd5,
AuthEapMethodPeapMschapv2,
AuthEapMethodPeapOtp,
AuthEapMethodPeapGtc,
AuthEapMethodPeapTls
} KyEapMethodPeapAuth;
KyAuthMethodUnknown = 0,
KyAuthMethodPap,
KyAuthMethodChap,
KyAuthMethodMschap,
KyAuthMethodMschapv2,
KyAuthMethodGtc,
KyAuthMethodOtp,
KyAuthMethodMd5,
KyAuthMethodTls
} KyNoEapMethodAuth;
class KyEapMethodPeapInfo
{
public:
KyEapMethodPeapAuth phase2AuthMethod;
KyNoEapMethodAuth phase2AuthMethod;
QString userName;
QString userPWD;
NetworkManager::Setting::SecretFlags m_passwdFlag;
@ -40,27 +53,6 @@ public:
bool bChanged;
};
typedef enum {
AuthEapMethodTtlsUnknown = 0,
AuthEapMethodTtlsMd5,
AuthEapMethodTtlsMschapv2,
AuthEapMethodTtlsOtp,
AuthEapMethodTtlsGtc,
AuthEapMethodTtlsTls
} KyEapMethodTtlsAuth;
typedef enum{
AuthMethodTtlsUnknown = 0,
AuthMethodTtlsPap,
AuthMethodTtlsChap,
AuthMethodTtlsMschap,
AuthMethodTtlsMschapv2,
AuthMethodTtlsGtc,
AuthMethodTtlsOtp,
AuthMethodTtlsMd5,
AuthMethodTtlsTls
} KyNoEapMethodTtlsAuth;
enum KyTtlsAuthMethod
{
AUTH_EAP,
@ -71,8 +63,8 @@ class KyEapMethodTtlsInfo
{
public:
KyTtlsAuthMethod authType;
KyEapMethodTtlsAuth authEapMethod;
KyNoEapMethodTtlsAuth authNoEapMethod;
KyEapMethodAuth authEapMethod;
KyNoEapMethodAuth authNoEapMethod;
QString userName;
QString userPWD;
NetworkManager::Setting::SecretFlags m_passwdFlag;

View File

@ -206,6 +206,21 @@ KyWiredConnectItem *KyActiveConnectResourse::getWiredActiveConnectItem(NetworkMa
#endif
void KyActiveConnectResourse::getActiveConnectIpInfo(
const QString &connectUuid,
QString &ipv4Address,
QString &ipv6Address)
{
NetworkManager::ActiveConnection::Ptr activeConnectPtr =
m_networkResourceInstance->getActiveConnect(connectUuid);
if (activeConnectPtr.isNull()) {
qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< connectUuid;
return;
}
getActiveConnectIp(activeConnectPtr, ipv4Address, ipv6Address);
}
void KyActiveConnectResourse::getActiveConnectIp(
NetworkManager::ActiveConnection::Ptr activeConnectPtr,
QString &ipv4Address,
@ -240,13 +255,28 @@ void KyActiveConnectResourse::getActiveConnectIp(
return;
}
void KyActiveConnectResourse::getActiveConnectDnsInfo(
const QString &connectUuid,
QList<QHostAddress> &ipv4Dns,
QList<QHostAddress> &ipv6Dns)
{
NetworkManager::ActiveConnection::Ptr activeConnectPtr =
m_networkResourceInstance->getActiveConnect(connectUuid);
if (activeConnectPtr.isNull()) {
qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< connectUuid;
return;
}
getActiveConnectDns(activeConnectPtr, ipv4Dns, ipv6Dns);
}
void KyActiveConnectResourse::getActiveConnectDns(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
QList<QHostAddress> &ipv4Dns,
QList<QHostAddress> &ipv6Dns)
{
qDebug()<<"[KyActiveConnectResourse]"<<"get active connect nameservice info";
NetworkManager::IpConfig ipv4Config =activeConnectPtr->ipV4Config();
NetworkManager::IpConfig ipv4Config = activeConnectPtr->ipV4Config();
if (ipv4Config.isValid()) {
ipv4Dns = ipv4Config.nameservers();
} else {

View File

@ -20,17 +20,25 @@ public:
void getActiveConnectionList(QString deviceName,
NetworkManager::ConnectionSettings::ConnectionType connectionType,
QList<KyConnectItem *> &connectItemList);
void getActiveConnectIpInfo(const QString &uuid,
QString &ipv4Address,
QString &ipv6Address);
void getActiveConnectDnsInfo(const QString &uuid,
QList<QHostAddress> &ipv4Dns,
QList<QHostAddress> &ipv6Dns);
//void getWiredActivateConnect(QList<KyWiredConnectItem *> &wiredActiveConnectItemList);
void getVpnActivateConnect(QList<KyVpnConnectItem *> &vpnActiveConnectItemList);
void getBtActivateConnect(QList<KyBluetoothConnectItem *> &btActiveConnectItemList);
private:
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
QString &ipv4Address,
QString &ipv6Address);
void getActiveConnectDns(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
QList<QHostAddress> &ipv4Dns,
QList<QHostAddress> &ipv6Dns);
//void getWiredActivateConnect(QList<KyWiredConnectItem *> &wiredActiveConnectItemList);
void getVpnActivateConnect(QList<KyVpnConnectItem *> &vpnActiveConnectItemList);
void getBtActivateConnect(QList<KyBluetoothConnectItem *> &btActiveConnectItemList);
private:
KyConnectItem *getActiveConnectionItem(NetworkManager::ActiveConnection::Ptr activeConnectPtr);
// KyWiredConnectItem *getWiredActiveConnectItem(NetworkManager::ActiveConnection::Ptr activeConnectPtr);

View File

@ -65,6 +65,7 @@ void KyConnectOperation::ipv6SettingSet(
if (CONFIG_IP_DHCP == connectSettingsInfo.m_ipv6ConfigIpType) {
ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic);
ipv6Setting->setPrivacy(NetworkManager::Ipv6Setting::Disabled);
return;
}
@ -77,6 +78,8 @@ void KyConnectOperation::ipv6SettingSet(
ipv6Setting->setAddresses(connectSettingsInfo.m_ipv6Address);
}
return ;
}
@ -91,10 +94,15 @@ void KyConnectOperation::connectSettingSet(
if (!connectSettingsInfo.m_ifaceName.isEmpty()) {
connectionSettings->setInterfaceName(connectSettingsInfo.m_ifaceName);
}
return;
}
void KyConnectOperation::setAutoConnect(NetworkManager::ConnectionSettings::Ptr &connectSetting,
bool bAutoConnect)
{
connectSetting->setAutoconnect(bAutoConnect);
}
void KyConnectOperation::createConnect(KyConnectSetting &connectSettingsInfo)
{
qDebug()<<"create connect need to do";

View File

@ -26,6 +26,8 @@ public:
const KyConnectSetting &connectSettingsInfo);
void ipv6SettingSet(NetworkManager::Ipv6Setting::Ptr &ipv6Setting,
const KyConnectSetting &connectSettingsInfo);
void setAutoConnect(NetworkManager::ConnectionSettings::Ptr &connectSetting,
bool bAutoConnect);
inline void errorProcess(QString errorMessage);
signals:

View File

@ -1,92 +0,0 @@
#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);
}

View File

@ -1,47 +0,0 @@
#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

View File

@ -2,7 +2,9 @@
#include <networkmanagerqt/wirelesssecuritysetting.h>
NetworkManager::ConnectionSettings::Ptr assembleWpaXPskSettings(NetworkManager::AccessPoint::Ptr accessPoint, QString &psk, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlag)
#define PSK_SETTING_NAME "802-11-wireless-security"
NetworkManager::ConnectionSettings::Ptr assembleWpaXPskSettings(NetworkManager::AccessPoint::Ptr accessPoint, QString &psk, bool isAutoConnect)
{
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
settings->setId(accessPoint->ssid());
@ -28,11 +30,38 @@ NetworkManager::ConnectionSettings::Ptr assembleWpaXPskSettings(NetworkManager::
{
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
}
security_sett->setPsk(psk);
security_sett->setPskFlags(secretFlag);
if (!psk.isEmpty())
{
security_sett->setPsk(psk);
}
return settings;
}
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);
}
return settings;
}
KyWirelessConnectOperation::KyWirelessConnectOperation(QObject *parent) : KyConnectOperation(parent)
@ -178,6 +207,69 @@ void KyWirelessConnectOperation::addTtlsConnect(const KyWirelessConnectSetting &
return;
}
void KyWirelessConnectOperation::setWirelessAutoConnect(const QString &uuid, bool bAutoConnect)
{
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();
setAutoConnect(connectionSettings, bAutoConnect);
connectPtr->update(connectionSettings->toMap());
return;
}
void KyWirelessConnectOperation::deleteWirelessConnect(const QString &connectUuid)
{
qDebug()<<"delete wireless connect uuid " << connectUuid;
deleteConnect(connectUuid);
return ;
}
QString KyWirelessConnectOperation::getPsk(const QString &connectUuid)
{
NetworkManager::Connection::Ptr connectPtr =
NetworkManager::findConnectionByUuid(connectUuid);
if (connectPtr.isNull()) {
QString errorMessage = tr("it can not find connection") + connectUuid;
qWarning()<<errorMessage;
return "";
}
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PSK_SETTING_NAME);
QMap<QString,QVariantMap> map(reply.value());
if (map.contains("802-11-wireless-security") && map.value("802-11-wireless-security").contains("psk"))
{
QString psk = map.value("802-11-wireless-security").value("psk").toString();
return psk;
}
return "";
}
void KyWirelessConnectOperation::updateIpv4AndIpv6SettingInfo(const QString &uuid, const KyConnectSetting &connectSettingsInfo)
{
qDebug()<<"updateIpv4AndIpv6SettingInfo wireless connect uuid " << uuid;
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();
setIpv4AndIpv6Setting(connectionSettings,connectSettingsInfo);
connectPtr->update(connectionSettings->toMap());
return;
}
void KyWirelessConnectOperation::updateWirelessPersonalConnect(const QString &uuid, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange)
{
NetworkManager::Connection::Ptr connectPtr =
@ -190,16 +282,7 @@ void KyWirelessConnectOperation::updateWirelessPersonalConnect(const QString &uu
}
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)
if (connSettingInfo.m_type != Unknown &&connSettingInfo.m_type != WpaNone && connSettingInfo.m_type != WpaPsk && connSettingInfo.m_type != SAE)
{
qDebug() << "updateWirelessPersonalConnect " << connSettingInfo.m_type << " not support";
return;
@ -210,43 +293,26 @@ void KyWirelessConnectOperation::updateWirelessPersonalConnect(const QString &uu
return;
}
void KyWirelessConnectOperation::updateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsInfo, const KyWirelessConnectSetting &connSettingInfo)
void KyWirelessConnectOperation::updateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsInfo)
{
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) {
if (connectPtr.isNull()) {
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);
setWirelessSecuWpaXEap(connectionSettings);
modifyEapMethodTlsSettings(connectionSettings, tlsInfo);
connectPtr->update(connectionSettings->toMap());
return;
}
void KyWirelessConnectOperation::updateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo, const KyWirelessConnectSetting &connSettingInfo)
void KyWirelessConnectOperation::updateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo)
{
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) {
@ -256,25 +322,15 @@ void KyWirelessConnectOperation::updateWirelessEnterPrisePeapConnect(const QStri
return;
}
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
//更新ipv4 ipv6信息
updateConnect(connectionSettings, connSettingInfo);
//是否默认连接
updateWirelessSecu(connectionSettings, connSettingInfo);
setWirelessSecuWpaXEap(connectionSettings);
modifyEapMethodPeapSettings(connectionSettings, peapInfo);
connectPtr->update(connectionSettings->toMap());
return;
}
void KyWirelessConnectOperation::updateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo, const KyWirelessConnectSetting &connSettingInfo)
void KyWirelessConnectOperation::updateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo)
{
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) {
@ -284,11 +340,8 @@ void KyWirelessConnectOperation::updateWirelessEnterPriseTtlsConnect(const QStri
return;
}
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
//更新ipv4 ipv6信息
updateConnect(connectionSettings, connSettingInfo);
//是否默认连接
updateWirelessSecu(connectionSettings, connSettingInfo);
setWirelessSecuWpaXEap(connectionSettings);
modifyEapMethodTtlsSettings(connectionSettings, ttlsInfo);
connectPtr->update(connectionSettings->toMap());
return;
@ -349,7 +402,7 @@ qDebug() << dev_uni;
break;
case NetworkManager::WpaPsk:
case NetworkManager::Wpa2Psk:
if (NetworkManager::ConnectionSettings::Ptr settings = assembleWpaXPskSettings(access_point, connSettingInfo.m_psk, connSettingInfo.isAutoConnect ,connSettingInfo.m_secretFlag))
if (NetworkManager::ConnectionSettings::Ptr settings = assembleWpaXPskSettings(access_point, connSettingInfo.m_psk, connSettingInfo.isAutoConnect))
{
map_settings = settings->toMap();
} else
@ -616,31 +669,52 @@ NetworkManager::WirelessNetwork::Ptr KyWirelessConnectOperation::checkWifiNetExi
return nullptr;
}
KyKeyMgmt KyWirelessConnectOperation::getConnectKeyMgmt(NetworkManager::ConnectionSettings::Ptr connSettingPtr)
KyKeyMgmt KyWirelessConnectOperation::getConnectKeyMgmt(const QString &uuid)
{
NetworkManager::WirelessSecuritySetting::Ptr security_sett
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
NetworkManager::Connection::Ptr connectPtr =
NetworkManager::findConnectionByUuid(uuid);
if(security_sett.isNull())
{
return KyKeyMgmt::Unknown;
}
NetworkManager::WirelessSecuritySetting::Ptr security_sett
= connectPtr->settings()->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);
qDebug() << "updateWirelessSecu " << connSettingInfo.m_type;
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);
qDebug() << "set keyMgmt " << type;
// security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)type);
if (bPwdChange)
{
qDebug() << "get psk " << security_sett->psk();
security_sett->setPsk(connSettingInfo.m_psk);
}
return;
}
void KyWirelessConnectOperation::setWirelessSecuWpaXEap(NetworkManager::ConnectionSettings::Ptr connSettingPtr)
{
NetworkManager::WirelessSecuritySetting::Ptr security_sett
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::KeyMgmt::WpaEap);
return;
}
void KyWirelessConnectOperation::setIpv4AndIpv6Setting(NetworkManager::ConnectionSettings::Ptr connSetting, const KyConnectSetting &connSettingInfo)
{
NetworkManager::Ipv4Setting::Ptr ipv4Setting = connSetting->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
ipv4SettingSet(ipv4Setting, connSettingInfo);
NetworkManager::Ipv6Setting::Ptr ipv6Setting = connSetting->setting(NetworkManager::Setting::Ipv6).dynamicCast<NetworkManager::Ipv6Setting>();
ipv6SettingSet(ipv6Setting, connSettingInfo);
}

View File

@ -4,7 +4,6 @@
#include <QObject>
#include "kyenterpricesettinginfo.h"
#include "kylinconnectoperation.h"
#include "kylinwirelessconnectsetting.h"
#include "kyenterpricesettinginfo.h"
enum KySecuType {
@ -14,6 +13,36 @@ enum KySecuType {
WPA2_AND_WPA3_PERSONAL
};
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;
};
class KyWirelessConnectOperation : public KyConnectOperation
{
Q_OBJECT
@ -28,6 +57,9 @@ public:
//获取密码保存策略
bool getConnSecretFlags(QString &connUuid, NetworkManager::Setting::SecretFlags &);
//获取KeyMgmt
KyKeyMgmt getConnectKeyMgmt(const QString &uuid);
//激活连接
void activeWirelessConnect(QString , QString);
//断开连接
@ -51,12 +83,22 @@ public:
void addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &info, KyWirelessConnectSetting &connSettingInfo,
QString & devIface, bool isHidden);
//属性页 page1 AutoConnect
void setWirelessAutoConnect(const QString &uuid, bool bAutoConnect);
//属性页 page2 page3 ipv6
void updateIpv4AndIpv6SettingInfo(const QString &uuid, const KyConnectSetting &connectSettingsInfo);
//属性页 page4 wifi Security
//连接修改(安全改为个人/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 updateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsinfo);
void updateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo);
void updateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo);
//忘记
void deleteWirelessConnect(const QString &connectUuid);
//获取密码
QString getPsk(const QString &connectUuid);
//申请扫描
void requestWirelessScan();
@ -68,7 +110,8 @@ signals:
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);
void setIpv4AndIpv6Setting(NetworkManager::ConnectionSettings::Ptr connSetting, const KyConnectSetting &connSettingInfo);
void setWirelessSecuWpaXEap(NetworkManager::ConnectionSettings::Ptr connSettingPtr);
KyNetworkResourceManager *m_networkResourceInstance = nullptr;

View File

@ -283,50 +283,6 @@ void KyWirelessNetResource::onWifiNetworkDeviceDisappear()
kyWirelessNetItemListInit();
}
bool KyWirelessNetResource::modifyEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info)
{
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
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())
{
qDebug() << "don't have WirelessSecurity connection";
return false;
}
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())
{
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);
conn->update(conn->settings()->toMap());
return true;
}
bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info)
{
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
@ -371,46 +327,12 @@ bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsIn
return true;
}
bool KyWirelessNetResource::modifyEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info)
{
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
if (conn.isNull())
{
qDebug() << "modifyEnterPriseInfoPeap connection missing";
return false;
}
NetworkManager::WirelessSecuritySetting::Ptr security_sett
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
if (security_sett.isNull())
{
qDebug() << "don't have WirelessSecurity connection";
return false;
}
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::EapMethodTls))
{
qDebug() << "don't have Security8021x connection";
return false;
}
info.phase2AuthMethod = (KyEapMethodPeapAuth)setting->phase2AuthEapMethod();
info.userName = setting->identity();
info.userPWD = setting->password();
return true;
}
bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info)
{
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
if (conn.isNull())
{
qDebug() << "modifyEnterPriseInfoPeap connection missing";
qDebug() << "getEnterPriseInfoPeap connection missing";
return false;
}
NetworkManager::WirelessSecuritySetting::Ptr security_sett
@ -432,65 +354,13 @@ bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeap
return false;
}
info.phase2AuthMethod = (KyEapMethodPeapAuth)setting->phase2AuthEapMethod();
info.phase2AuthMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod();
info.userName = setting->identity();
info.userPWD = setting->password();
return true;
}
bool KyWirelessNetResource::modifyEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info)
{
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
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())
{
qDebug() << "don't have WirelessSecurity connection";
return false;
}
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())
{
qDebug() << "don't have Security8021x connection";
return false;
}
qDebug() << setting->identity() << setting->eapMethods() << setting->password() << setting->phase2AuthEapMethod();
QList<NetworkManager::Security8021xSetting::EapMethod> list;
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls);
setting->setEapMethods(list);
if (info.authType == KyTtlsAuthMethod::AUTH_EAP)
{
setting->setPhase2AuthEapMethod((NetworkManager::Security8021xSetting::AuthEapMethod)info.authEapMethod);//gtc md5 mschapv2 otp tls
setting->setPhase2AuthMethod(NetworkManager::Security8021xSetting::AuthMethod::AuthMethodUnknown);
} else if (info.authType == KyTtlsAuthMethod::AUTH_NO_EAP) {
setting->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)info.authNoEapMethod);//chap md5 mschapv2 pap gtc mschap otp tls
setting->setPhase2AuthEapMethod(NetworkManager::Security8021xSetting::AuthEapMethod::AuthEapMethodUnknown);
}
setting->setIdentity(info.userName);
setting->setPassword(info.userPWD);
conn->update(conn->settings()->toMap());
qDebug() << setting->identity() << setting->eapMethods() << setting->password() << setting->phase2AuthEapMethod();
qDebug() << "set success";
return true;
}
bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info)
{
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
@ -520,11 +390,11 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls
return false;
}
info.authEapMethod = (KyEapMethodTtlsAuth)setting->phase2AuthEapMethod();
info.authNoEapMethod = (KyNoEapMethodTtlsAuth)setting->phase2AuthMethod();
info.authEapMethod = (KyEapMethodAuth)setting->phase2AuthEapMethod();
info.authNoEapMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod();
info.authType = KyTtlsAuthMethod::AUTH_EAP;
if (info.authEapMethod != AuthEapMethodTtlsUnknown)
if (info.authEapMethod != KyAuthEapMethodUnknown)
{
info.authType = KyTtlsAuthMethod::AUTH_EAP;
} else {

View File

@ -21,10 +21,6 @@ public:
bool getAllDeviceWifiNetwork(QMap<QString,QList<KyWirelessNetItem> > &map);
bool getDeviceWifiNetwork(QString devIfaceName, QList<KyWirelessNetItem> &KyWirelessNetResource);
bool modifyEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info);
bool modifyEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info);
bool modifyEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info);
bool getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info);
bool getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info);
bool getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info);

View File

@ -36,6 +36,7 @@ NmDemo::NmDemo(QWidget *parent) : QDialog(parent)
m_wco = new KyWirelessConnectOperation(this);
m_wnr = new KyWirelessNetResource(this);
m_acr = new KyActiveConnectResourse(this);
m_cr = new KyConnectResourse(this);
m_timer = new QTimer(this);
initUi();
@ -72,6 +73,8 @@ void NmDemo::initUi()
enableButton->setText("Enable");
disableButton = new QPushButton(this);
disableButton->setText("Disable");
addButton = new QPushButton(this);
addButton->setText("Add");
wifiList = new QTextEdit(this);
debugLog = new QTextEdit(this);
ssidText = new QLineEdit(this);
@ -90,6 +93,7 @@ void NmDemo::initUi()
refreshButton->setGeometry( 5, 5, 80, 30);
connectButton->setGeometry(105, 5, 80, 30);
disConnectButton->setGeometry(205, 5, 80, 30);
addButton->setGeometry(305, 5 ,80 ,30);
modifyButton->setGeometry(5, 55, 80, 30);
enableButton->setGeometry(105, 55, 80, 30);
disableButton->setGeometry(205, 55, 80, 30);
@ -132,6 +136,8 @@ void NmDemo::initConnect()
connect(modifyButton, &QPushButton::clicked, this, &NmDemo::onModifyClicked);
connect(enableButton, &QPushButton::clicked, this, &NmDemo::onEnableClick);
connect(disableButton, &QPushButton::clicked, this, &NmDemo::onDisableClick);
connect(addButton, &QPushButton::clicked, this, &NmDemo::onAddClick);
//连接变化
@ -258,22 +264,18 @@ void NmDemo::onConnectClicked()
if(!isNew)
{
KyEapMethodPeapInfo a;
a.phase2AuthMethod = AuthEapMethodPeapMschapv2;
a.phase2AuthMethod = KyAuthMethodMschapv2;
a.userName = "steve";
a.userPWD = "testing";
appendDebugLog("modifyEnterPriseInfoPeap");
if (!(m_wnr->modifyEnterPriseInfoPeap(uuid,a)))
{
appendDebugLog("modifyEnterPriseInfoPeap fail");
return;
}
appendDebugLog("activeWirelessConnect...");
m_wco->activeWirelessConnect(devIface,uuid);
return;
} else {
KyEapMethodTtlsInfo c;
c.authType = AUTH_NO_EAP;
c.authNoEapMethod = AuthMethodTtlsMschapv2;
c.authNoEapMethod = KyAuthMethodMschapv2;
c.userName = "steve";
c.userPWD = "testing";
appendDebugLog("addAndActiveWirelessEnterPriseTtlsConnect...");
@ -290,7 +292,6 @@ void NmDemo::onConnectClicked()
a.m_ssid = ssid;
a.isAutoConnect = true;
a.m_psk = pwd;
a.m_secretFlag = NetworkManager::Setting::None;
a.m_type = WpaPsk;
@ -338,7 +339,111 @@ void NmDemo::onDisConnectClicked()
void NmDemo::onModifyClicked()
{
appendDebugLog("onModifyClicked...");
//TODO
QString ssid = ssidText->text();
QString devIface = ifaceNameText->text();
QString uuid;
bool isFind = false;
QList<KyWirelessNetItem> list;
m_wnr->getDeviceWifiNetwork(devIface, list);
QList<KyWirelessNetItem>::iterator iter = list.begin();
while (iter != list.end())
{
if (iter->m_NetSsid == ssid)
{
if (iter->m_isConfigured == true)
{
isFind = true;
uuid = iter->m_connectUuid;
break;
}
}
iter++;
}
if (!isFind)
{
return;
}
QString psk = m_wco->getPsk(uuid);
appendDebugLog(ssid +" getPsk is " + psk);
return;
appendDebugLog("getConnectKeyMgmt" + QString::number(m_wco->getConnectKeyMgmt(uuid)));
KyWirelessConnectSetting wcs;
wcs.m_type = SAE;
m_wco->updateWirelessPersonalConnect(uuid, wcs ,true);
appendDebugLog("getConnectKeyMgmt" + QString::number(m_wco->getConnectKeyMgmt(uuid)));
return;
m_wco->setWirelessAutoConnect(uuid, false);
return;
KyConnectSetting sett;
showIpv4Ipv6DnsInfo(uuid, sett);
sett.m_ipv4ConfigIpType = CONFIG_IP_MANUAL;
sett.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL);
sett.m_ipv4Address.clear();
QStringList ipv4DnsList;
ipv4DnsList << "1.1.1.1";
QString a("192.168.1.17"),b("255.255.255.0"),c("192.168.1.0");
sett.ipv4AddressConstruct(a, b, c, ipv4DnsList);
// sett.setIpConfigType(IPADDRESS_V6, CONFIG_IP_MANUAL);
// QStringList ipv6DnsList;
// ipv6DnsList << "1.1.1.1";
// QString d("1.1.1.1"),e("1.1.1.1"),f("1.1.1.1");
// sett.ipv6AddressConstruct(d, e, f, ipv6DnsList);
m_wco->updateIpv4AndIpv6SettingInfo(uuid, sett);
showIpv4Ipv6DnsInfo(uuid, sett);
}
void NmDemo::showIpv4Ipv6DnsInfo(const QString &uuid, KyConnectSetting &settInfo)
{
m_cr->getConnectionSetting(uuid, settInfo);
appendDebugLog("connect setting info:");
appendDebugLog("connect name " + settInfo.m_connectName);
appendDebugLog("iface name " + settInfo.m_ifaceName);
appendDebugLog("ipv4 type " + QString::number(settInfo.m_ipv4ConfigIpType));
for (int index = 0 ; index < settInfo.m_ipv4Address.size(); index++) {
appendDebugLog("ipv4 address " + settInfo.m_ipv4Address.at(index).ip().toString());
appendDebugLog("ipv4 gate way " + settInfo.m_ipv4Address.at(index).gateway().toString());
appendDebugLog("ipv4 net mask " + settInfo.m_ipv4Address.at(index).netmask().toString());
}
for (int index = 0; index < settInfo.m_ipv4Dns.size(); ++index) {
appendDebugLog("ipv4 dns " + settInfo.m_ipv4Dns.at(index).toString());
}
appendDebugLog("ipv6 type " + QString::number(settInfo.m_ipv6ConfigIpType));
for (int index = 0 ; index < settInfo.m_ipv6Address.size(); index++) {
appendDebugLog("ipv6 address " + settInfo.m_ipv6Address.at(index).ip().toString());
appendDebugLog("ipv6 gate way " + settInfo.m_ipv6Address.at(index).gateway().toString());
appendDebugLog("ipv6 net mask " + settInfo.m_ipv6Address.at(index).netmask().toString());
}
for (int index = 0; index < settInfo.m_ipv6Dns.size(); ++index) {
appendDebugLog("ipv6 dns " + settInfo.m_ipv6Dns.at(index).toString());
}
QString ipv4,ipv6;
QList<QHostAddress> ipv4Dns,ipv6Dns;
ipv4Dns.clear();
ipv6Dns.clear();
m_acr->getActiveConnectIpInfo(uuid, ipv4, ipv6);
appendDebugLog("Dynamic ipv4 address " + ipv4);
appendDebugLog("Dynamic ipv6 address " + ipv6);
m_acr->getActiveConnectDnsInfo(uuid, ipv4Dns, ipv6Dns);
appendDebugLog(QString::number(ipv4Dns.size()) + QString::number(ipv6Dns.size()));
for (int index = 0 ; index < ipv4Dns.size(); index++) {
appendDebugLog("Dynamic ipv4 dns " + ipv4Dns.at(index).toString());
}
for (int index = 0 ; index < ipv6Dns.size(); index++) {
appendDebugLog("Dynamic ipv6 dns " + ipv6Dns.at(index).toString());
}
}
void NmDemo::onEnableClick()
@ -353,6 +458,29 @@ void NmDemo::onDisableClick()
m_wco->setWirelessEnabled(false);
}
void NmDemo::onAddClick()
{
appendDebugLog("onAddClick...");
KyWirelessConnectSetting sett;
sett.m_connectName = "zsx";
sett.m_ssid = "zsxsz";
sett.isAutoConnect = false;
sett.m_psk = "123456zsx";
sett.m_type = Wep;
//ipv4
sett.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL);
QString ipv4Address("192.168.1.17"), ipv4NetMask("255.255.255.0"), ipv4GateWay("192.168.1.0");
QStringList list;
list << "127.17.50.100";
sett.ipv4AddressConstruct(ipv4Address, ipv4NetMask, ipv4GateWay, list);
// m_wco->addConnect(sett);
KyEapMethodPeapInfo peap;
peap.phase2AuthMethod = KyAuthMethodMschapv2;
peap.userName = "steve";
peap.userPWD = "testing";
m_wco->addPeapConnect(sett,peap);
}
void NmDemo::appendDebugLog(QString log)
{
QTimeZone timeZone(QString::fromLatin1(QTimeZone::systemTimeZoneId()).toLatin1());

View File

@ -11,7 +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"
#include "backend/dbus-interface/kylinconnectresource.h"
#include "backend/dbus-interface/kylinactiveconnectresource.h"
class NmDemo : public QDialog
@ -25,6 +26,7 @@ public:
QPushButton *modifyButton;
QPushButton *enableButton;
QPushButton *disableButton;
QPushButton *addButton;
QTextEdit *wifiList;
QTextEdit *debugLog;
QLabel *ssidLabel;
@ -40,6 +42,7 @@ public:
KyWirelessConnectOperation *m_wco;
KyWirelessNetResource *m_wnr;
KyActiveConnectResourse *m_acr;
KyConnectResourse *m_cr;
private:
QTimer *m_timer;
@ -55,6 +58,8 @@ private:
void appendDebugLog(QString);
void getWifiList();
void showIpv4Ipv6DnsInfo(const QString &uuid, KyConnectSetting &sett);
public slots:
void onWcoSignals(QString);
void onBssidChange(QString, QString, QString);
@ -71,6 +76,7 @@ public slots:
void onModifyClicked();
void onEnableClick();
void onDisableClick();
void onAddClick();
void onActiveConnectionAdd(NetworkManager::ActiveConnection::Ptr conn);
void onActiveConnectionUpdate(NetworkManager::ActiveConnection * conn);