Merge branch 'dbus-terface' into kylin-nm-dbus-renpj
This commit is contained in:
commit
1033455505
|
@ -1,6 +1,7 @@
|
||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
CONFIG += ordered
|
CONFIG += ordered \
|
||||||
|
qt
|
||||||
|
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
src \
|
src \
|
||||||
|
@ -9,3 +10,5 @@ TRANSLATIONS += \
|
||||||
translations/kylin-nm_zh_CN.ts \
|
translations/kylin-nm_zh_CN.ts \
|
||||||
translations/kylin-nm_tr.ts \
|
translations/kylin-nm_tr.ts \
|
||||||
translations/kylin-nm_bo.ts
|
translations/kylin-nm_bo.ts
|
||||||
|
|
||||||
|
QT += widgets
|
||||||
|
|
|
@ -50,7 +50,6 @@
|
||||||
<file>res/s/conning-a/6.png</file>
|
<file>res/s/conning-a/6.png</file>
|
||||||
<file>res/s/conning-a/7.png</file>
|
<file>res/s/conning-a/7.png</file>
|
||||||
<file>res/s/conning-a/8.png</file>
|
<file>res/s/conning-a/8.png</file>
|
||||||
<file>qss/style.qss</file>
|
|
||||||
<file>res/g/close_black.png</file>
|
<file>res/g/close_black.png</file>
|
||||||
<file>res/g/close_white.png</file>
|
<file>res/g/close_white.png</file>
|
||||||
<file>res/s/conning-s/1.png</file>
|
<file>res/s/conning-s/1.png</file>
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
QScrollBar:vertical{margin:0px 2px 0px 2px;width:10px;background:rgba(48,48,51,0);border-radius:6px;}
|
|
||||||
QScrollBar::up-arrow:vertical{height:0px;}
|
|
||||||
QScrollBar::sub-line:vertical{border:0px solid;height:0px}
|
|
||||||
QScrollBar::sub-page:vertical{background:transparent;}
|
|
||||||
QScrollBar::handle:vertical{width:6px;background:rgba(72,72,76,1);border-radius:3px;}
|
|
||||||
QScrollBar::handle:vertical:hover{width:6px;background:rgba(97,97,102,1);border-radius:3px;}
|
|
||||||
QScrollBar::handle:vertical:pressed{width:6px;background:rgba(133,133,140,1);border-radius:3px;}
|
|
||||||
QScrollBar::add-page:vertical{background:transparent;}
|
|
||||||
QScrollBar::add-line:vertical{border:0px solid;height:0px}
|
|
||||||
QScrollBar::down-arrow:vertical{height:0px;}
|
|
|
@ -1,23 +1,9 @@
|
||||||
#include "kyenterpricesettinginfo.h"
|
#include "kyenterpricesettinginfo.h"
|
||||||
|
|
||||||
NetworkManager::ConnectionSettings::Ptr KyEnterPriceSettingInfo::assembleEapMethodTlsSettings(KyEapMethodTlsInfo &info,
|
void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &info)
|
||||||
bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
|
||||||
{
|
{
|
||||||
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
|
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;
|
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTls);
|
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTls);
|
||||||
|
@ -34,73 +20,45 @@ NetworkManager::ConnectionSettings::Ptr KyEnterPriceSettingInfo::assembleEapMeth
|
||||||
QByteArray cliPriKeyEndWithNull(info.clientPrivateKey.toUtf8() + '\0');
|
QByteArray cliPriKeyEndWithNull(info.clientPrivateKey.toUtf8() + '\0');
|
||||||
wifi_8021x_sett->setPrivateKey(cliPriKeyEndWithNull);
|
wifi_8021x_sett->setPrivateKey(cliPriKeyEndWithNull);
|
||||||
wifi_8021x_sett->setPrivateKeyPassword(info.clientPrivateKeyPWD);
|
wifi_8021x_sett->setPrivateKeyPassword(info.clientPrivateKeyPWD);
|
||||||
wifi_8021x_sett->setPrivateKeyPasswordFlags(secretFlags);
|
wifi_8021x_sett->setPrivateKeyPasswordFlags(info.m_privateKeyPWDFlag);
|
||||||
|
|
||||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
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->setInitialized(true);
|
||||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
||||||
|
|
||||||
return settings;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkManager::ConnectionSettings::Ptr KyEnterPriceSettingInfo::assembleEapMethodPeapSettings(KyEapMethodPeapInfo &info,
|
void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &info)
|
||||||
bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
|
||||||
{
|
{
|
||||||
qDebug() << "assembleEapMethodPeapSettings";
|
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
|
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;
|
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap);
|
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap);
|
||||||
wifi_8021x_sett->setInitialized(true);
|
wifi_8021x_sett->setInitialized(true);
|
||||||
wifi_8021x_sett->setEapMethods(list);
|
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->setIdentity(info.userName);
|
||||||
wifi_8021x_sett->setPassword(info.userPWD);
|
wifi_8021x_sett->setPassword(info.userPWD);
|
||||||
wifi_8021x_sett->setPrivateKeyPasswordFlags(secretFlags);
|
wifi_8021x_sett->setPasswordFlags(info.m_passwdFlag);
|
||||||
|
|
||||||
|
|
||||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
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->setInitialized(true);
|
||||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
||||||
security_sett->setAuthAlg(NetworkManager::WirelessSecuritySetting::Open);
|
return;
|
||||||
|
|
||||||
return settings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkManager::ConnectionSettings::Ptr KyEnterPriceSettingInfo::assembleEapMethodTtlsSettings(KyEapMethodTtlsInfo &info,
|
void assembleEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &info)
|
||||||
bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
|
||||||
{
|
{
|
||||||
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
|
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;
|
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls);
|
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls);
|
||||||
|
@ -115,12 +73,91 @@ NetworkManager::ConnectionSettings::Ptr KyEnterPriceSettingInfo::assembleEapMeth
|
||||||
}
|
}
|
||||||
wifi_8021x_sett->setIdentity(info.userName);
|
wifi_8021x_sett->setIdentity(info.userName);
|
||||||
wifi_8021x_sett->setPassword(info.userPWD);
|
wifi_8021x_sett->setPassword(info.userPWD);
|
||||||
wifi_8021x_sett->setPrivateKeyPasswordFlags(secretFlags);
|
wifi_8021x_sett->setPasswordFlags(info.m_passwdFlag);
|
||||||
|
|
||||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
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->setInitialized(true);
|
||||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
|
||||||
|
return;
|
||||||
return settings;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,55 +10,52 @@
|
||||||
class KyEapMethodTlsInfo
|
class KyEapMethodTlsInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString connName;
|
|
||||||
QString identity;
|
QString identity;
|
||||||
QString domain;
|
QString domain;
|
||||||
QString devIfaceName;
|
QString devIfaceName;
|
||||||
QString caCertPath;
|
QString caCertPath;
|
||||||
|
bool bNeedCa;
|
||||||
QString clientCertPath;
|
QString clientCertPath;
|
||||||
QString clientPrivateKey;
|
QString clientPrivateKey;
|
||||||
QString clientPrivateKeyPWD;
|
QString clientPrivateKeyPWD;
|
||||||
|
NetworkManager::Setting::SecretFlags m_privateKeyPWDFlag;
|
||||||
|
// only valid when update
|
||||||
|
bool bChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
KyAuthEapMethodUnknown = 0,
|
||||||
|
KyAuthEapMethodMd5,
|
||||||
|
KyAuthEapMethodMschapv2,
|
||||||
|
KyAuthEapMethodOtp,
|
||||||
|
KyAuthEapMethodGtc,
|
||||||
|
KyAuthEapMethodTls
|
||||||
|
} KyEapMethodAuth;
|
||||||
|
|
||||||
typedef enum{
|
typedef enum{
|
||||||
AuthEapMethodPeapUnknown = 0,
|
KyAuthMethodUnknown = 0,
|
||||||
AuthEapMethodPeapMd5,
|
KyAuthMethodPap,
|
||||||
AuthEapMethodPeapMschapv2,
|
KyAuthMethodChap,
|
||||||
AuthEapMethodPeapOtp,
|
KyAuthMethodMschap,
|
||||||
AuthEapMethodPeapGtc,
|
KyAuthMethodMschapv2,
|
||||||
AuthEapMethodPeapTls
|
KyAuthMethodGtc,
|
||||||
} KyEapMethodPeapAuth;
|
KyAuthMethodOtp,
|
||||||
|
KyAuthMethodMd5,
|
||||||
|
KyAuthMethodTls
|
||||||
|
} KyNoEapMethodAuth;
|
||||||
|
|
||||||
|
|
||||||
class KyEapMethodPeapInfo
|
class KyEapMethodPeapInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString connName;
|
KyNoEapMethodAuth phase2AuthMethod;
|
||||||
KyEapMethodPeapAuth phase2AuthMethod;
|
|
||||||
QString userName;
|
QString userName;
|
||||||
QString userPWD;
|
QString userPWD;
|
||||||
|
NetworkManager::Setting::SecretFlags m_passwdFlag;
|
||||||
|
// only valid when update
|
||||||
|
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
|
enum KyTtlsAuthMethod
|
||||||
{
|
{
|
||||||
AUTH_EAP,
|
AUTH_EAP,
|
||||||
|
@ -68,24 +65,22 @@ enum KyTtlsAuthMethod
|
||||||
class KyEapMethodTtlsInfo
|
class KyEapMethodTtlsInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString connName;
|
|
||||||
KyTtlsAuthMethod authType;
|
KyTtlsAuthMethod authType;
|
||||||
KyEapMethodTtlsAuth authEapMethod;
|
KyEapMethodAuth authEapMethod;
|
||||||
KyNoEapMethodTtlsAuth authNoEapMethod;
|
KyNoEapMethodAuth authNoEapMethod;
|
||||||
QString userName;
|
QString userName;
|
||||||
QString userPWD;
|
QString userPWD;
|
||||||
|
NetworkManager::Setting::SecretFlags m_passwdFlag;
|
||||||
|
// only valid when update
|
||||||
|
bool bChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KyEnterPriceSettingInfo : public QObject
|
void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &);
|
||||||
{
|
void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &);
|
||||||
Q_OBJECT
|
void assembleEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &);
|
||||||
public:
|
|
||||||
explicit KyEnterPriceSettingInfo(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
static NetworkManager::ConnectionSettings::Ptr assembleEapMethodTlsSettings(KyEapMethodTlsInfo &, bool, NetworkManager::Setting::SecretFlags);
|
void modifyEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &);
|
||||||
static NetworkManager::ConnectionSettings::Ptr assembleEapMethodPeapSettings(KyEapMethodPeapInfo &, bool, NetworkManager::Setting::SecretFlags);
|
void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &);
|
||||||
static NetworkManager::ConnectionSettings::Ptr assembleEapMethodTtlsSettings(KyEapMethodTtlsInfo &, bool, NetworkManager::Setting::SecretFlags);
|
void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &);
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // KYENTERPRICESETTINGINFO_H
|
#endif // KYENTERPRICESETTINGINFO_H
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
#include "kylinactiveconnectresource.h"
|
#include "kylinactiveconnectresource.h"
|
||||||
|
#include "kywirelessconnectoperation.h"
|
||||||
|
|
||||||
#include <NetworkManagerQt/IpConfig>
|
#include <NetworkManagerQt/IpConfig>
|
||||||
#include <NetworkManagerQt/Dhcp4Config>
|
#include <NetworkManagerQt/Dhcp4Config>
|
||||||
|
@ -206,6 +207,21 @@ KyWiredConnectItem *KyActiveConnectResourse::getWiredActiveConnectItem(NetworkMa
|
||||||
|
|
||||||
#endif
|
#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(
|
void KyActiveConnectResourse::getActiveConnectIp(
|
||||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||||
QString &ipv4Address,
|
QString &ipv4Address,
|
||||||
|
@ -240,13 +256,28 @@ void KyActiveConnectResourse::getActiveConnectIp(
|
||||||
return;
|
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,
|
void KyActiveConnectResourse::getActiveConnectDns(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||||
QList<QHostAddress> &ipv4Dns,
|
QList<QHostAddress> &ipv4Dns,
|
||||||
QList<QHostAddress> &ipv6Dns)
|
QList<QHostAddress> &ipv6Dns)
|
||||||
{
|
{
|
||||||
qDebug()<<"[KyActiveConnectResourse]"<<"get active connect nameservice info";
|
qDebug()<<"[KyActiveConnectResourse]"<<"get active connect nameservice info";
|
||||||
|
|
||||||
NetworkManager::IpConfig ipv4Config =activeConnectPtr->ipV4Config();
|
NetworkManager::IpConfig ipv4Config = activeConnectPtr->ipV4Config();
|
||||||
if (ipv4Config.isValid()) {
|
if (ipv4Config.isValid()) {
|
||||||
ipv4Dns = ipv4Config.nameservers();
|
ipv4Dns = ipv4Config.nameservers();
|
||||||
} else {
|
} else {
|
||||||
|
@ -440,9 +471,10 @@ KyApConnectItem *KyActiveConnectResourse::getApActiveConnectItem(NetworkManager:
|
||||||
apConnectItem->m_connectUuid = activeConnectPtr->uuid();
|
apConnectItem->m_connectUuid = activeConnectPtr->uuid();
|
||||||
apConnectItem->m_ifaceName = settingPtr->interfaceName();
|
apConnectItem->m_ifaceName = settingPtr->interfaceName();
|
||||||
|
|
||||||
NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
|
//NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
|
||||||
= settingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
// = settingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||||
apConnectItem->m_password = wirelessSecuritySetting->psk();
|
KyWirelessConnectOperation wirelessOperation;
|
||||||
|
apConnectItem->m_password = wirelessOperation.getPsk(apConnectItem->m_connectUuid);
|
||||||
|
|
||||||
return apConnectItem;
|
return apConnectItem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,13 @@ public:
|
||||||
void getActiveConnectionList(QString deviceName,
|
void getActiveConnectionList(QString deviceName,
|
||||||
NetworkManager::ConnectionSettings::ConnectionType connectionType,
|
NetworkManager::ConnectionSettings::ConnectionType connectionType,
|
||||||
QList<KyConnectItem *> &connectItemList);
|
QList<KyConnectItem *> &connectItemList);
|
||||||
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
void getActiveConnectIpInfo(const QString &uuid,
|
||||||
QString &ipv4Address,
|
QString &ipv4Address,
|
||||||
QString &ipv6Address);
|
QString &ipv6Address);
|
||||||
void getActiveConnectDns(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
void getActiveConnectDnsInfo(const QString &uuid,
|
||||||
QList<QHostAddress> &ipv4Dns,
|
QList<QHostAddress> &ipv4Dns,
|
||||||
QList<QHostAddress> &ipv6Dns);
|
QList<QHostAddress> &ipv6Dns);
|
||||||
|
|
||||||
//void getWiredActivateConnect(QList<KyWiredConnectItem *> &wiredActiveConnectItemList);
|
//void getWiredActivateConnect(QList<KyWiredConnectItem *> &wiredActiveConnectItemList);
|
||||||
void getVpnActivateConnect(QList<KyVpnConnectItem *> &vpnActiveConnectItemList);
|
void getVpnActivateConnect(QList<KyVpnConnectItem *> &vpnActiveConnectItemList);
|
||||||
void getBtActivateConnect(QList<KyBluetoothConnectItem *> &btActiveConnectItemList);
|
void getBtActivateConnect(QList<KyBluetoothConnectItem *> &btActiveConnectItemList);
|
||||||
|
@ -34,6 +35,13 @@ public:
|
||||||
void getApActivateConnect(QList<KyApConnectItem *> &apConnectItemList);
|
void getApActivateConnect(QList<KyApConnectItem *> &apConnectItemList);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||||
|
QString &ipv4Address,
|
||||||
|
QString &ipv6Address);
|
||||||
|
void getActiveConnectDns(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||||
|
QList<QHostAddress> &ipv4Dns,
|
||||||
|
QList<QHostAddress> &ipv6Dns);
|
||||||
|
|
||||||
KyConnectItem *getActiveConnectionItem(NetworkManager::ActiveConnection::Ptr activeConnectPtr);
|
KyConnectItem *getActiveConnectionItem(NetworkManager::ActiveConnection::Ptr activeConnectPtr);
|
||||||
|
|
||||||
// KyWiredConnectItem *getWiredActiveConnectItem(NetworkManager::ActiveConnection::Ptr activeConnectPtr);
|
// KyWiredConnectItem *getWiredActiveConnectItem(NetworkManager::ActiveConnection::Ptr activeConnectPtr);
|
||||||
|
|
|
@ -65,6 +65,7 @@ void KyConnectOperation::ipv6SettingSet(
|
||||||
|
|
||||||
if (CONFIG_IP_DHCP == connectSettingsInfo.m_ipv6ConfigIpType) {
|
if (CONFIG_IP_DHCP == connectSettingsInfo.m_ipv6ConfigIpType) {
|
||||||
ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic);
|
ipv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic);
|
||||||
|
ipv6Setting->setPrivacy(NetworkManager::Ipv6Setting::Disabled);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +78,8 @@ void KyConnectOperation::ipv6SettingSet(
|
||||||
ipv6Setting->setAddresses(connectSettingsInfo.m_ipv6Address);
|
ipv6Setting->setAddresses(connectSettingsInfo.m_ipv6Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,31 +94,24 @@ void KyConnectOperation::connectSettingSet(
|
||||||
if (!connectSettingsInfo.m_ifaceName.isEmpty()) {
|
if (!connectSettingsInfo.m_ifaceName.isEmpty()) {
|
||||||
connectionSettings->setInterfaceName(connectSettingsInfo.m_ifaceName);
|
connectionSettings->setInterfaceName(connectSettingsInfo.m_ifaceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KyConnectOperation::setAutoConnect(NetworkManager::ConnectionSettings::Ptr &connectSetting,
|
||||||
|
bool bAutoConnect)
|
||||||
|
{
|
||||||
|
connectSetting->setAutoconnect(bAutoConnect);
|
||||||
|
}
|
||||||
|
|
||||||
void KyConnectOperation::createConnect(KyConnectSetting &connectSettingsInfo)
|
void KyConnectOperation::createConnect(KyConnectSetting &connectSettingsInfo)
|
||||||
{
|
{
|
||||||
qDebug()<<"create connect need to do";
|
qDebug()<<"create connect need to do";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KyConnectOperation::updateConnect(const QString &connectUuid, const KyConnectSetting &connectSettingsInfo)
|
void KyConnectOperation::updateConnect(NetworkManager::ConnectionSettings::Ptr connectionSettings, const KyConnectSetting &connectSettingsInfo)
|
||||||
{
|
{
|
||||||
qDebug()<<"update connect"<<connectUuid;
|
qDebug()<<"update connect"<<connectionSettings->uuid();
|
||||||
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);
|
|
||||||
|
|
||||||
NetworkManager::Ipv4Setting::Ptr ipv4Setting = connectionSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
NetworkManager::Ipv4Setting::Ptr ipv4Setting = connectionSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
||||||
ipv4SettingSet(ipv4Setting, connectSettingsInfo);
|
ipv4SettingSet(ipv4Setting, connectSettingsInfo);
|
||||||
|
@ -126,8 +122,6 @@ void KyConnectOperation::updateConnect(const QString &connectUuid, const KyConne
|
||||||
// NetworkManager::WiredSetting::Ptr wiredSetting = connectionSettings->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>();
|
// NetworkManager::WiredSetting::Ptr wiredSetting = connectionSettings->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>();
|
||||||
// wiredSetting->setInitialized(true);
|
// wiredSetting->setInitialized(true);
|
||||||
|
|
||||||
connectPtr->update(connectionSettings->toMap());
|
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,12 +143,11 @@ void KyConnectOperation::deleteConnect(const QString &connectUuid)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KyConnectOperation::activateConnection(const QString connectUuid)
|
void KyConnectOperation::activateConnection(const QString connectUuid, const QString deviceName)
|
||||||
{
|
{
|
||||||
QString connectPath = "";
|
QString connectPath = "";
|
||||||
QString deviceIdentifier = "";
|
QString deviceIdentifier = "";
|
||||||
QString connectName = "";
|
QString connectName = "";
|
||||||
QString deviceName = "";
|
|
||||||
QString specificObject = "";
|
QString specificObject = "";
|
||||||
NetworkManager::Connection::Ptr connectPtr = nullptr;
|
NetworkManager::Connection::Ptr connectPtr = nullptr;
|
||||||
|
|
||||||
|
@ -178,24 +171,23 @@ void KyConnectOperation::activateConnection(const QString connectUuid)
|
||||||
#endif
|
#endif
|
||||||
connectPath = connectPtr->path();
|
connectPath = connectPtr->path();
|
||||||
connectName = connectPtr->name();
|
connectName = connectPtr->name();
|
||||||
deviceName = connectPtr->settings()->interfaceName();
|
// deviceName = connectPtr->settings()->interfaceName();
|
||||||
|
|
||||||
for (auto const & dev : m_networkResourceInstance->m_devices) {
|
// for (auto const & dev : m_networkResourceInstance->m_devices) {
|
||||||
for (auto const & dev_conn : dev->availableConnections()) {
|
// for (auto const & dev_conn : dev->availableConnections()) {
|
||||||
if (dev_conn == connectPtr) {
|
// if (dev_conn == connectPtr) {
|
||||||
deviceIdentifier = dev->uni();
|
// deviceIdentifier = dev->uni();
|
||||||
deviceName = dev->interfaceName();
|
// deviceName = dev->interfaceName();
|
||||||
break;
|
// 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()) {
|
if (deviceIdentifier.isEmpty()) {
|
||||||
QString errorMessage = tr("device Identifier is empty, its name") + deviceName;
|
QString errorMessage = tr("device Identifier is empty, its name") + deviceName;
|
||||||
|
|
|
@ -13,9 +13,9 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void createConnect(KyConnectSetting &connectSettingsInfo);
|
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 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);
|
void deactivateConnection(const QString activeConnectName, const QString &activeConnectUuid);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -26,6 +26,8 @@ public:
|
||||||
const KyConnectSetting &connectSettingsInfo);
|
const KyConnectSetting &connectSettingsInfo);
|
||||||
void ipv6SettingSet(NetworkManager::Ipv6Setting::Ptr &ipv6Setting,
|
void ipv6SettingSet(NetworkManager::Ipv6Setting::Ptr &ipv6Setting,
|
||||||
const KyConnectSetting &connectSettingsInfo);
|
const KyConnectSetting &connectSettingsInfo);
|
||||||
|
void setAutoConnect(NetworkManager::ConnectionSettings::Ptr &connectSetting,
|
||||||
|
bool bAutoConnect);
|
||||||
inline void errorProcess(QString errorMessage);
|
inline void errorProcess(QString errorMessage);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
|
||||||
#include "kylinconnectresource.h"
|
#include "kylinconnectresource.h"
|
||||||
|
#include "kywirelessconnectoperation.h"
|
||||||
|
|
||||||
#include <NetworkManagerQt/Ipv4Setting>
|
#include <NetworkManagerQt/Ipv4Setting>
|
||||||
#include <NetworkManagerQt/Ipv6Setting>
|
#include <NetworkManagerQt/Ipv6Setting>
|
||||||
#include <NetworkManagerQt/VpnConnection>
|
#include <NetworkManagerQt/VpnConnection>
|
||||||
|
@ -479,9 +481,10 @@ KyApConnectItem *KyConnectResourse::getApConnectItem(NetworkManager::Connection:
|
||||||
apConnectItem->m_connectUuid = connectPtr->uuid();
|
apConnectItem->m_connectUuid = connectPtr->uuid();
|
||||||
apConnectItem->m_ifaceName = settingPtr->interfaceName();
|
apConnectItem->m_ifaceName = settingPtr->interfaceName();
|
||||||
|
|
||||||
NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
|
//NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
|
||||||
= settingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
// = settingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||||
apConnectItem->m_password = wirelessSecuritySetting->psk();
|
KyWirelessConnectOperation wirelessOperation;
|
||||||
|
apConnectItem->m_password = wirelessOperation.getPsk(apConnectItem->m_connectUuid);// wirelessSecuritySetting->psk();
|
||||||
|
|
||||||
return apConnectItem;
|
return apConnectItem;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "kylinconnectsetting.h"
|
#include "kylinconnectsetting.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
KyConnectSetting::KyConnectSetting(QObject *parent) : QObject(parent)
|
KyConnectSetting::KyConnectSetting(/*QObject *parent) : QObject(parent*/)
|
||||||
{
|
{
|
||||||
m_connectName = "";
|
m_connectName = "";
|
||||||
m_ifaceName = "";
|
m_ifaceName = "";
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QObject>
|
//#include <QObject>
|
||||||
|
|
||||||
#include <NetworkManagerQt/AdslDevice>
|
#include <NetworkManagerQt/AdslDevice>
|
||||||
#include <NetworkManagerQt/WiredDevice>
|
#include <NetworkManagerQt/WiredDevice>
|
||||||
|
@ -39,11 +39,11 @@ typedef enum {
|
||||||
IPADDRESS_V6,
|
IPADDRESS_V6,
|
||||||
}KyIpAddressType;
|
}KyIpAddressType;
|
||||||
|
|
||||||
class KyConnectSetting : public QObject
|
class KyConnectSetting/* : public QObject*/
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
// Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit KyConnectSetting(QObject *parent = nullptr);
|
/* explicit*/ KyConnectSetting(/*QObject *parent = nullptr*/);
|
||||||
~KyConnectSetting();
|
~KyConnectSetting();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -5,7 +5,8 @@ KyNetworkDeviceResourse::KyNetworkDeviceResourse(QObject *parent) : QObject(pare
|
||||||
{
|
{
|
||||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||||
|
|
||||||
m_activeConnectUuidList.clear();
|
// m_activeConnectUuidList.clear();
|
||||||
|
m_activeConnectUuidMap.clear();
|
||||||
//TODO::get uuid from settings for system reboot;
|
//TODO::get uuid from settings for system reboot;
|
||||||
|
|
||||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceAdd, this, &KyNetworkDeviceResourse::deviceAdd);
|
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceAdd, this, &KyNetworkDeviceResourse::deviceAdd);
|
||||||
|
@ -155,7 +156,8 @@ void KyNetworkDeviceResourse::disconnectDevice()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_activeConnectUuidList.clear();
|
// m_activeConnectUuidList.clear();
|
||||||
|
m_activeConnectUuidMap.clear();
|
||||||
|
|
||||||
for (int index = 0; index < networkDeviceList.size(); ++index) {
|
for (int index = 0; index < networkDeviceList.size(); ++index) {
|
||||||
NetworkManager::Device::Ptr networkDevicePtr = networkDeviceList.at(index);
|
NetworkManager::Device::Ptr networkDevicePtr = networkDeviceList.at(index);
|
||||||
|
@ -164,7 +166,8 @@ void KyNetworkDeviceResourse::disconnectDevice()
|
||||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr = networkDevicePtr->activeConnection();
|
NetworkManager::ActiveConnection::Ptr activeConnectPtr = networkDevicePtr->activeConnection();
|
||||||
QString activeConnectUuid = activeConnectPtr->uuid();
|
QString activeConnectUuid = activeConnectPtr->uuid();
|
||||||
if (!activeConnectUuid.isEmpty()) {
|
if (!activeConnectUuid.isEmpty()) {
|
||||||
m_activeConnectUuidList<<activeConnectUuid;
|
// m_activeConnectUuidList<<activeConnectUuid;
|
||||||
|
m_activeConnectUuidMap.insert(networkDevicePtr->interfaceName(),activeConnectUuid);
|
||||||
//TODO:save uuid for system reboot.
|
//TODO:save uuid for system reboot.
|
||||||
}
|
}
|
||||||
networkDevicePtr->disconnectInterface();
|
networkDevicePtr->disconnectInterface();
|
||||||
|
@ -185,10 +188,13 @@ void KyNetworkDeviceResourse::setDeviceAutoConnect()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int index = 0; index < m_activeConnectUuidList.size(); ++index) {
|
QMap<QString, QString>::iterator iter = m_activeConnectUuidMap.begin();
|
||||||
QString connectUuid = m_activeConnectUuidList.at(index);
|
while (iter != m_activeConnectUuidMap.end())
|
||||||
wiredOperation.activateConnection(connectUuid);
|
{
|
||||||
qDebug()<<"[KyNetworkDeviceResourse]" << "active connect uuid"<< connectUuid;
|
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) {
|
for (int index = 0; index < networkDeviceList.size(); ++index) {
|
||||||
|
|
|
@ -37,5 +37,6 @@ private:
|
||||||
KyWiredConnectOperation wiredOperation;
|
KyWiredConnectOperation wiredOperation;
|
||||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||||
QStringList m_activeConnectUuidList;
|
QStringList m_activeConnectUuidList;
|
||||||
|
QMap<QString , QString> m_activeConnectUuidMap;
|
||||||
};
|
};
|
||||||
#endif // KYLINNETORKDEVICERESOURCE_H
|
#endif // KYLINNETORKDEVICERESOURCE_H
|
||||||
|
|
|
@ -69,8 +69,19 @@ void KyWiredConnectOperation::createWiredConnect(KyConnectSetting &connectSettin
|
||||||
void KyWiredConnectOperation::updateWiredConnect(const QString &connectUuid, const KyConnectSetting &connectSettingsInfo)
|
void KyWiredConnectOperation::updateWiredConnect(const QString &connectUuid, const KyConnectSetting &connectSettingsInfo)
|
||||||
{
|
{
|
||||||
qDebug()<<"update connect"<<connectUuid;
|
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 ;
|
return ;
|
||||||
}
|
}
|
||||||
|
@ -84,9 +95,9 @@ void KyWiredConnectOperation::deleteWiredConnect(const QString &connectUuid)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KyWiredConnectOperation::activateWiredConnection(const QString connectUuid)
|
void KyWiredConnectOperation::activateWiredConnection(const QString connectUuid, const QString devName)
|
||||||
{
|
{
|
||||||
activateConnection(connectUuid);
|
activateConnection(connectUuid, devName);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
void createWiredConnect(KyConnectSetting &connectSettingsInfo);
|
void createWiredConnect(KyConnectSetting &connectSettingsInfo);
|
||||||
void updateWiredConnect(const QString &connectUuid, const KyConnectSetting &connectSettingsInfo);
|
void updateWiredConnect(const QString &connectUuid, const KyConnectSetting &connectSettingsInfo);
|
||||||
void deleteWiredConnect(const QString &connectUuid);
|
void deleteWiredConnect(const QString &connectUuid);
|
||||||
void activateWiredConnection(const QString connectUuid);
|
void activateWiredConnection(const QString connectUuid, const QString devName);
|
||||||
void activateVpnConnection(const QString connectUuid);
|
void activateVpnConnection(const QString connectUuid);
|
||||||
void deactivateWiredConnection(const QString activeConnectName, const QString &activeConnectUuid);
|
void deactivateWiredConnection(const QString activeConnectName, const QString &activeConnectUuid);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#include "kywirelessconnectoperation.h"
|
#include "kywirelessconnectoperation.h"
|
||||||
|
|
||||||
NetworkManager::ConnectionSettings::Ptr assembleWpaXPskSettings(NetworkManager::AccessPoint::Ptr accessPoint, QString &psk, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlag)
|
#include <networkmanagerqt/wirelesssecuritysetting.h>
|
||||||
|
|
||||||
|
#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}};
|
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
|
||||||
settings->setId(accessPoint->ssid());
|
settings->setId(accessPoint->ssid());
|
||||||
|
@ -26,54 +30,40 @@ NetworkManager::ConnectionSettings::Ptr assembleWpaXPskSettings(NetworkManager::
|
||||||
{
|
{
|
||||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
|
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk);
|
||||||
}
|
}
|
||||||
security_sett->setPsk(psk);
|
if (!psk.isEmpty())
|
||||||
|
{
|
||||||
|
security_sett->setPsk(psk);
|
||||||
|
}
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetworkManager::ConnectionSettings::Ptr assembleWirelessSettings(const KyWirelessConnectSetting &connSettingInfo)
|
||||||
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}};
|
NetworkManager::ConnectionSettings::Ptr settings{new NetworkManager::ConnectionSettings{NetworkManager::ConnectionSettings::Wireless}};
|
||||||
settings->setId(ssid);
|
settings->setId(connSettingInfo.m_connectName);
|
||||||
settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid());
|
||||||
settings->setAutoconnect(isAutoConnect);
|
settings->setAutoconnect(connSettingInfo.isAutoConnect);
|
||||||
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
||||||
settings->setGatewayPingTimeout(0);
|
settings->setGatewayPingTimeout(0);
|
||||||
|
|
||||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||||
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||||
wifi_sett->setInitialized(true);
|
wifi_sett->setInitialized(true);
|
||||||
wifi_sett->setSsid(ssid.toUtf8());
|
wifi_sett->setSsid(connSettingInfo.m_ssid.toUtf8());
|
||||||
wifi_sett->setHidden(true);
|
|
||||||
wifi_sett->setSecurity("802-11-wireless-security");
|
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);
|
||||||
|
security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)connSettingInfo.m_type);
|
||||||
|
if (KyKeyMgmt::SAE == connSettingInfo.m_type || KyKeyMgmt::WpaPsk == connSettingInfo.m_type)
|
||||||
{
|
{
|
||||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
security_sett->setPsk(connSettingInfo.m_psk);
|
||||||
= 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;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
KyWirelessConnectOperation::KyWirelessConnectOperation(QObject *parent) : KyConnectOperation(parent)
|
KyWirelessConnectOperation::KyWirelessConnectOperation(QObject *parent) : KyConnectOperation(parent)
|
||||||
{
|
{
|
||||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||||
|
@ -87,7 +77,7 @@ KyWirelessConnectOperation::~KyWirelessConnectOperation()
|
||||||
|
|
||||||
void KyWirelessConnectOperation::activeWirelessConnect(QString devIfaceName, QString connUuid)
|
void KyWirelessConnectOperation::activeWirelessConnect(QString devIfaceName, QString connUuid)
|
||||||
{
|
{
|
||||||
activateConnection(connUuid);
|
activateConnection(connUuid, devIfaceName);
|
||||||
return;
|
return;
|
||||||
#if 0
|
#if 0
|
||||||
NetworkManager::Connection::Ptr conn;
|
NetworkManager::Connection::Ptr conn;
|
||||||
|
@ -118,154 +108,293 @@ void KyWirelessConnectOperation::activeWirelessConnect(QString devIfaceName, QSt
|
||||||
qWarning() << QStringLiteral("activation of connection failed: %1").arg(watcher->error().message());
|
qWarning() << QStringLiteral("activation of connection failed: %1").arg(watcher->error().message());
|
||||||
emit connectFail(connUuid, devIfaceName, "Internal error");
|
emit connectFail(connUuid, devIfaceName, "Internal error");
|
||||||
}
|
}
|
||||||
qDebug() << "5";
|
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void KyWirelessConnectOperation::deactivateWirelessConnection(const QString activeConnectName, const QString &activeConnectUuid)
|
void KyWirelessConnectOperation::deActivateWirelessConnection(const QString activeConnectName, const QString &activeConnectUuid)
|
||||||
{
|
{
|
||||||
deactivateConnection(activeConnectName, activeConnectUuid);
|
deactivateConnection(activeConnectName, activeConnectUuid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void KyWirelessConnectOperation::activeWirelessConnectWithPwd(QString devIfaceName, QString connUuid, QString psk)
|
//普通wifi
|
||||||
//{
|
void KyWirelessConnectOperation::addConnect(const KyWirelessConnectSetting &connSettingInfo)
|
||||||
|
|
||||||
// //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)
|
|
||||||
{
|
{
|
||||||
int index = 0;
|
NetworkManager::ConnectionSettings::Ptr connSetting = assembleWirelessSettings(connSettingInfo);
|
||||||
NetworkManager::ActiveConnection::Ptr activateConnectPtr = nullptr;
|
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
|
||||||
|
|
||||||
qDebug()<<"deactivetate connect uuid "<<uuid;
|
QDBusPendingCallWatcher * watcher;
|
||||||
for (index = 0; index < m_networkResourceInstance->m_activeConns.size(); ++index) {
|
watcher = new QDBusPendingCallWatcher{NetworkManager::addConnection(connSetting->toMap()), this};
|
||||||
activateConnectPtr = m_networkResourceInstance->m_activeConns.at(index);
|
connect(watcher, &QDBusPendingCallWatcher::finished, [this](QDBusPendingCallWatcher * watcher) {
|
||||||
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) {
|
|
||||||
if (watcher->isError() || !watcher->isValid()) {
|
if (watcher->isError() || !watcher->isValid()) {
|
||||||
qWarning() << QStringLiteral("deactivation of connection failed");
|
QString errorMessage = tr("create wireless connection failed: ") + watcher->error().message();
|
||||||
emit disConnectFail(uuid, "no", "Internal error");
|
qWarning()<<errorMessage;
|
||||||
|
emit this->createConnectionError(errorMessage);
|
||||||
|
} else {
|
||||||
|
qDebug()<<"create wireless connect complete";
|
||||||
}
|
}
|
||||||
watcher->deleteLater();
|
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,
|
void KyWirelessConnectOperation::addTtlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTtlsInfo &ttlsInfo)
|
||||||
QString psk, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
|
||||||
{
|
{
|
||||||
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::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 =
|
||||||
|
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();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateWirelessSecu(connectionSettings, connSettingInfo, bPwdChange);
|
||||||
|
connectPtr->update(connectionSettings->toMap());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KyWirelessConnectOperation::updateWirelessEnterPriseTlsConnect(const QString &uuid, const KyEapMethodTlsInfo &tlsInfo)
|
||||||
|
{
|
||||||
|
NetworkManager::Connection::Ptr connectPtr =
|
||||||
|
NetworkManager::findConnectionByUuid(uuid);
|
||||||
|
if (connectPtr.isNull()) {
|
||||||
|
QString errorMessage = tr("it can not find connection") + uuid;
|
||||||
|
qWarning()<<errorMessage;
|
||||||
|
emit updateConnectionError(errorMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||||
|
|
||||||
|
setWirelessSecuWpaXEap(connectionSettings);
|
||||||
|
modifyEapMethodTlsSettings(connectionSettings, tlsInfo);
|
||||||
|
connectPtr->update(connectionSettings->toMap());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KyWirelessConnectOperation::updateWirelessEnterPrisePeapConnect(const QString &uuid, const KyEapMethodPeapInfo &peapInfo)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
|
||||||
|
setWirelessSecuWpaXEap(connectionSettings);
|
||||||
|
modifyEapMethodPeapSettings(connectionSettings, peapInfo);
|
||||||
|
connectPtr->update(connectionSettings->toMap());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KyWirelessConnectOperation::updateWirelessEnterPriseTtlsConnect(const QString &uuid, const KyEapMethodTtlsInfo &ttlsInfo)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
|
||||||
|
setWirelessSecuWpaXEap(connectionSettings);
|
||||||
|
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 conn_uni;
|
||||||
QString dev_uni;
|
QString dev_uni;
|
||||||
QString conn_name;
|
QString conn_name;
|
||||||
QString dev_name;
|
|
||||||
QString spec_object;
|
QString spec_object;
|
||||||
NMVariantMapMap map_settings;
|
NMVariantMapMap map_settings;
|
||||||
bool bFind = false;
|
|
||||||
|
|
||||||
NetworkManager::WirelessNetwork::Ptr wifiNet = nullptr;
|
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||||
|
if (!isHidden && wifiNet.isNull())
|
||||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
|
||||||
{
|
{
|
||||||
auto dev = m_networkResourceInstance->findDeviceUni(net->device());
|
qDebug() << "addAndActiveWirelessConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||||
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;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto access_point = wifiNet->referenceAccessPoint();
|
qDebug() << "addAndActiveWirelessConnect find " << connSettingInfo.m_ssid << " in " << devIface << " or hide";
|
||||||
|
|
||||||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||||
if (dev.isNull())
|
if (dev.isNull())
|
||||||
{
|
{
|
||||||
emit connectFail(ssid, devIface, "devIface not exist");
|
emit andAndActivateConnectionError("can not find device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto spec_dev = dev->as<NetworkManager::WirelessDevice>();
|
|
||||||
Q_ASSERT(nullptr != spec_dev);
|
qDebug() << "addAndActiveWirelessConnect device " << devIface << " exist";
|
||||||
conn_uni = access_point->uni();
|
|
||||||
conn_name = access_point->ssid();
|
|
||||||
dev_name = dev->interfaceName();
|
|
||||||
dev_uni = dev->uni();
|
dev_uni = dev->uni();
|
||||||
|
auto spec_dev = dev->as<NetworkManager::WirelessDevice>();
|
||||||
spec_object = conn_uni;
|
qDebug() << dev_uni;
|
||||||
NetworkManager::WirelessSecurityType sec_type = NetworkManager::findBestWirelessSecurity(spec_dev->wirelessCapabilities()
|
if (!isHidden)
|
||||||
, true, (spec_dev->mode() == NetworkManager::WirelessDevice::Adhoc)
|
|
||||||
, access_point->capabilities(), access_point->wpaFlags(), access_point->rsnFlags());
|
|
||||||
|
|
||||||
qDebug() << "findBestWirelessSecurity type "<< sec_type;
|
|
||||||
switch (sec_type)
|
|
||||||
{
|
{
|
||||||
|
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:
|
case NetworkManager::UnknownSecurity:
|
||||||
qWarning() << QStringLiteral("unknown security to use for '%1'").arg(conn_name);
|
qWarning() << QStringLiteral("unknown security to use for '%1'").arg(conn_name);
|
||||||
case NetworkManager::NoneSecurity:
|
case NetworkManager::NoneSecurity:
|
||||||
|
@ -273,7 +402,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & ssid, QSt
|
||||||
break;
|
break;
|
||||||
case NetworkManager::WpaPsk:
|
case NetworkManager::WpaPsk:
|
||||||
case NetworkManager::Wpa2Psk:
|
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))
|
||||||
{
|
{
|
||||||
map_settings = settings->toMap();
|
map_settings = settings->toMap();
|
||||||
} else
|
} else
|
||||||
|
@ -284,54 +413,27 @@ void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & ssid, QSt
|
||||||
break;
|
break;
|
||||||
//TODO: other types...
|
//TODO: other types...
|
||||||
default:
|
default:
|
||||||
qDebug() << "not support";
|
qDebug() << "addAndActiveWirelessConnect not support";
|
||||||
break;
|
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,
|
qDebug() << "finish assemble";
|
||||||
QString &psk, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
} else {
|
||||||
{
|
qDebug() << "start assembleWirelessSettings";
|
||||||
qDebug() << "addAndActiveWirelessHiddenConnect";
|
map_settings = assembleWirelessSettings(connSettingInfo)->toMap();
|
||||||
QString dev_uni;
|
qDebug() << "finish assembleWirelessSettings";
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
dev_name = dev->interfaceName();
|
|
||||||
dev_uni = dev->uni();
|
|
||||||
|
|
||||||
NetworkManager::ConnectionSettings::Ptr settings = assembleWpaXPskHiddenSettings(ssid, type, psk, isAutoConnect, secretFlags);
|
|
||||||
map_settings = settings->toMap();
|
|
||||||
|
|
||||||
|
|
||||||
QDBusPendingCallWatcher * watcher;
|
QDBusPendingCallWatcher * watcher;
|
||||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
||||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||||
if (watcher->isError() || !watcher->isValid())
|
if (watcher->isError() || !watcher->isValid())
|
||||||
{
|
{
|
||||||
qDebug() << "activation of connection failed " << watcher->error().message();
|
QString errorMessage = watcher->error().message();
|
||||||
emit connectFail(ssid, devIface, "Internal error");
|
qDebug() << "activation of connection failed " << errorMessage;
|
||||||
|
emit andAndActivateConnectionError(errorMessage);
|
||||||
}
|
}
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,42 +450,21 @@ void KyWirelessConnectOperation::requestWirelessScan()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo &info, QString & devIface,
|
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo &info, KyWirelessConnectSetting &connSettingInfo,
|
||||||
bool isHidden, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
QString & devIface, bool isHidden)
|
||||||
{
|
{
|
||||||
QString conn_uni;
|
QString conn_uni;
|
||||||
QString dev_uni;
|
QString dev_uni;
|
||||||
QString conn_name;
|
QString conn_name;
|
||||||
QString dev_name;
|
|
||||||
QString spec_object;
|
QString spec_object;
|
||||||
NMVariantMapMap map_settings;
|
NMVariantMapMap map_settings;
|
||||||
bool bFind = false;
|
|
||||||
|
|
||||||
if (!isHidden)
|
if (!isHidden)
|
||||||
{
|
{
|
||||||
NetworkManager::WirelessNetwork::Ptr wifiNet = nullptr;
|
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||||
|
if (wifiNet.isNull())
|
||||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
|
||||||
{
|
{
|
||||||
auto dev = m_networkResourceInstance->findDeviceUni(net->device());
|
qDebug() << "addAndActiveWirelessEnterPriseTlsConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||||
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;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,16 +477,17 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapM
|
||||||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||||
if (dev.isNull())
|
if (dev.isNull())
|
||||||
{
|
{
|
||||||
emit connectFail(info.connName, devIface, "devIface not exist");
|
emit andAndActivateConnectionError("can not find device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dev_name = dev->interfaceName();
|
|
||||||
dev_uni = dev->uni();
|
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())
|
if(settings.isNull())
|
||||||
{
|
{
|
||||||
qDebug() << "assembleEapMethodPeapSettings failed";
|
qDebug() << "assembleEapMethodTlsSettings failed";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,51 +498,31 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapM
|
||||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||||
if (watcher->isError() || !watcher->isValid())
|
if (watcher->isError() || !watcher->isValid())
|
||||||
{
|
{
|
||||||
qDebug() << "activation of connection failed " << watcher->error().message();
|
QString errorMessage = watcher->error().message();
|
||||||
emit connectFail(info.connName, devIface, "Internal error");
|
qDebug() << "addAndActiveWirelessEnterPriseTlsConnect failed " << errorMessage;
|
||||||
|
emit andAndActivateConnectionError(errorMessage);
|
||||||
}
|
}
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEapMethodPeapInfo &info, QString &devIface,
|
void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEapMethodPeapInfo &info, KyWirelessConnectSetting &connSettingInfo,
|
||||||
bool isHidden, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
QString & devIface, bool isHidden)
|
||||||
{
|
{
|
||||||
qDebug() <<"addAndActiveWirelessEnterPrisePeapConnect";
|
qDebug() <<"addAndActiveWirelessEnterPrisePeapConnect";
|
||||||
QString conn_uni;
|
QString conn_uni;
|
||||||
QString dev_uni;
|
QString dev_uni;
|
||||||
QString conn_name;
|
QString conn_name;
|
||||||
QString dev_name;
|
|
||||||
QString spec_object;
|
QString spec_object;
|
||||||
NMVariantMapMap map_settings;
|
NMVariantMapMap map_settings;
|
||||||
bool bFind = false;
|
|
||||||
|
|
||||||
if (!isHidden)
|
if (!isHidden)
|
||||||
{
|
{
|
||||||
NetworkManager::WirelessNetwork::Ptr wifiNet = nullptr;
|
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||||
|
if (wifiNet.isNull())
|
||||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
|
||||||
{
|
{
|
||||||
auto dev = m_networkResourceInstance->findDeviceUni(net->device());
|
qDebug() << "addAndActiveWirelessEnterPrisePeapConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||||
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;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,19 +536,19 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEap
|
||||||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||||
if (dev.isNull())
|
if (dev.isNull())
|
||||||
{
|
{
|
||||||
emit connectFail(info.connName, devIface, "devIface not exist");
|
emit andAndActivateConnectionError("can not find device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dev_name = dev->interfaceName();
|
|
||||||
dev_uni = dev->uni();
|
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())
|
if(settings.isNull())
|
||||||
{
|
{
|
||||||
qDebug() << "assembleEapMethodPeapSettings failed";
|
qDebug() << "assembleEapMethodPeapSettings failed";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
map_settings = settings->toMap();
|
map_settings = settings->toMap();
|
||||||
|
|
||||||
QDBusPendingCallWatcher * watcher;
|
QDBusPendingCallWatcher * watcher;
|
||||||
|
@ -494,50 +556,30 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEap
|
||||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||||
if (watcher->isError() || !watcher->isValid())
|
if (watcher->isError() || !watcher->isValid())
|
||||||
{
|
{
|
||||||
qDebug() << "activation of connection failed " << watcher->error().message();
|
QString errorMessage = watcher->error().message();
|
||||||
emit connectFail(info.connName, devIface, "Internal error");
|
qDebug() << "addAndActiveWirelessEnterPrisePeapConnect failed " << errorMessage;
|
||||||
|
emit andAndActivateConnectionError(errorMessage);
|
||||||
}
|
}
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &info, QString &devIface,
|
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &info, KyWirelessConnectSetting &connSettingInfo,
|
||||||
bool isHidden, bool isAutoConnect, NetworkManager::Setting::SecretFlags secretFlags)
|
QString & devIface, bool isHidden)
|
||||||
{
|
{
|
||||||
QString conn_uni;
|
QString conn_uni;
|
||||||
QString dev_uni;
|
QString dev_uni;
|
||||||
QString conn_name;
|
QString conn_name;
|
||||||
QString dev_name;
|
|
||||||
QString spec_object;
|
QString spec_object;
|
||||||
NMVariantMapMap map_settings;
|
NMVariantMapMap map_settings;
|
||||||
bool bFind = false;
|
|
||||||
|
|
||||||
if (!isHidden)
|
if (!isHidden)
|
||||||
{
|
{
|
||||||
NetworkManager::WirelessNetwork::Ptr wifiNet = nullptr;
|
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||||
|
if (wifiNet.isNull())
|
||||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
|
||||||
{
|
{
|
||||||
auto dev = m_networkResourceInstance->findDeviceUni(net->device());
|
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||||
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;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,16 +592,17 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
|
||||||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||||
if (dev.isNull())
|
if (dev.isNull())
|
||||||
{
|
{
|
||||||
emit connectFail(info.connName, devIface, "devIface not exist");
|
emit andAndActivateConnectionError("can not find device");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dev_name = dev->interfaceName();
|
|
||||||
dev_uni = dev->uni();
|
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())
|
if(settings.isNull())
|
||||||
{
|
{
|
||||||
qDebug() << "assembleEapMethodPeapSettings failed";
|
qDebug() << "assembleEapMethodTtlsSettings failed";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,10 +613,11 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
|
||||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||||
if (watcher->isError() || !watcher->isValid())
|
if (watcher->isError() || !watcher->isValid())
|
||||||
{
|
{
|
||||||
qDebug() << "activation of connection failed " << watcher->error().message();
|
QString errorMessage = watcher->error().message();
|
||||||
emit connectFail(info.connName, devIface, "Internal error");
|
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect failed " << errorMessage;
|
||||||
|
emit andAndActivateConnectionError(errorMessage);
|
||||||
}
|
}
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +643,7 @@ bool KyWirelessConnectOperation::getConnSecretFlags(QString &connUuid, NetworkMa
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
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();
|
flag = security_sett->pskFlags();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -678,9 +722,10 @@ void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QS
|
||||||
NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(apUuid);
|
NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(apUuid);
|
||||||
if (nullptr == connectPtr) {
|
if (nullptr == connectPtr) {
|
||||||
NetworkManager::Device::Ptr devicePtr = m_networkResourceInstance->findDeviceInterface(apDevice);
|
NetworkManager::Device::Ptr devicePtr = m_networkResourceInstance->findDeviceInterface(apDevice);
|
||||||
if (devicePtr.isNull())
|
if (devicePtr.isNull()) {
|
||||||
{
|
QString errorMsg ="active wifi ap failed," + apDevice + "is not existed";
|
||||||
emit connectFail(apName, apDevice, "devIface not exist");
|
qWarning()<< errorMsg;
|
||||||
|
emit andAndActivateConnectionError(errorMsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,16 +737,16 @@ void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QS
|
||||||
QDBusPendingCallWatcher * watcher;
|
QDBusPendingCallWatcher * watcher;
|
||||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(apConnectSettingPtr->toMap(), deviceIdentifier, specificObject), this};
|
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(apConnectSettingPtr->toMap(), deviceIdentifier, specificObject), this};
|
||||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||||
if (watcher->isError() || !watcher->isValid())
|
if (watcher->isError() || !watcher->isValid()) {
|
||||||
{
|
QString errorMsg = "activation connection failed," + watcher->error().message();
|
||||||
qDebug() << "activation of connection failed " << watcher->error().message();
|
qWarning() << errorMsg;
|
||||||
emit connectFail(apName, apDevice, "Internal error");
|
emit andAndActivateConnectionError(errorMsg);
|
||||||
}
|
}
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
updateWirelessApSetting(connectPtr, apName, apPassword, apDevice);
|
updateWirelessApSetting(connectPtr, apName, apPassword, apDevice);
|
||||||
activateConnection(apUuid);
|
activateConnection(apUuid, apDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -712,3 +757,75 @@ void KyWirelessConnectOperation::deactiveWirelessAp(const QString apName, const
|
||||||
deactivateConnection(apName, apUuid);
|
deactivateConnection(apName, apUuid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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(const QString &uuid)
|
||||||
|
{
|
||||||
|
NetworkManager::Connection::Ptr connectPtr =
|
||||||
|
NetworkManager::findConnectionByUuid(uuid);
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
qDebug() << "updateWirelessSecu " << connSettingInfo.m_type;
|
||||||
|
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||||
|
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||||
|
|
||||||
|
KyKeyMgmt type = connSettingInfo.m_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);
|
||||||
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define KYWIRELESSCONNECTOPERATION_H
|
#define KYWIRELESSCONNECTOPERATION_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "kylinnetworkresourcemanager.h"
|
|
||||||
#include "kyenterpricesettinginfo.h"
|
#include "kyenterpricesettinginfo.h"
|
||||||
#include "kylinconnectoperation.h"
|
#include "kylinconnectoperation.h"
|
||||||
|
#include "kyenterpricesettinginfo.h"
|
||||||
|
|
||||||
enum KySecuType {
|
enum KySecuType {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
|
@ -13,6 +13,36 @@ enum KySecuType {
|
||||||
WPA2_AND_WPA3_PERSONAL
|
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
|
class KyWirelessConnectOperation : public KyConnectOperation
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -20,24 +50,56 @@ public:
|
||||||
explicit KyWirelessConnectOperation(QObject *parent = nullptr);
|
explicit KyWirelessConnectOperation(QObject *parent = nullptr);
|
||||||
~KyWirelessConnectOperation();
|
~KyWirelessConnectOperation();
|
||||||
|
|
||||||
|
//无线开关
|
||||||
void setWirelessEnabled(bool enabled);
|
void setWirelessEnabled(bool enabled);
|
||||||
bool getWirelessEnabled();
|
bool getWirelessEnabled();
|
||||||
|
|
||||||
bool getConnSecretFlags(QString &, NetworkManager::Setting::SecretFlags &);
|
//获取密码保存策略
|
||||||
|
bool getConnSecretFlags(QString &connUuid, NetworkManager::Setting::SecretFlags &);
|
||||||
|
|
||||||
|
//获取KeyMgmt
|
||||||
|
KyKeyMgmt getConnectKeyMgmt(const QString &uuid);
|
||||||
|
|
||||||
|
//激活连接
|
||||||
void activeWirelessConnect(QString , QString);
|
void activeWirelessConnect(QString , QString);
|
||||||
void deactivateWirelessConnection(const QString activeConnectName, const QString &activeConnectUuid);
|
//断开连接
|
||||||
//todo:
|
void deActivateWirelessConnection(const QString activeConnectName, const QString &activeConnectUuid);
|
||||||
// void activeWirelessConnectWithPwd(QString , QString, QString);
|
//新增普通连接
|
||||||
void deActiveWirelessConnect(QString &);
|
void addConnect(const KyWirelessConnectSetting &connSettingInfo);
|
||||||
void addAndActiveWirelessConnect(QString &, QString &, QString, bool, NetworkManager::Setting::SecretFlags);
|
//新增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);
|
||||||
|
//属性页 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);
|
||||||
|
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();
|
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 activeWirelessAp(const QString apUuid, const QString apName, const QString apPassword, const QString apDevice);
|
void activeWirelessAp(const QString apUuid, const QString apName, const QString apPassword, const QString apDevice);
|
||||||
void deactiveWirelessAp(const QString apName, const QString apUuid);
|
void deactiveWirelessAp(const QString apName, const QString apUuid);
|
||||||
|
@ -48,12 +110,17 @@ private:
|
||||||
const QString apName, const QString apPassword, const QString apDevice);
|
const QString apName, const QString apPassword, const QString apDevice);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connectFail(QString, QString, QString);//连接失败信号
|
|
||||||
void disConnectFail(QString, QString, QString);
|
|
||||||
void wifinEnabledChanged(bool);
|
void wifinEnabledChanged(bool);
|
||||||
|
void andAndActivateConnectionError(QString errorMessage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
NetworkManager::WirelessNetwork::Ptr checkWifiNetExist(QString ssid, QString devName);
|
||||||
|
void updateWirelessSecu(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange = false);
|
||||||
|
void setIpv4AndIpv6Setting(NetworkManager::ConnectionSettings::Ptr connSetting, const KyConnectSetting &connSettingInfo);
|
||||||
|
void setWirelessSecuWpaXEap(NetworkManager::ConnectionSettings::Ptr connSettingPtr);
|
||||||
|
|
||||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,12 +23,14 @@ public:
|
||||||
QString m_bssid;
|
QString m_bssid;
|
||||||
int m_signalStrength;
|
int m_signalStrength;
|
||||||
uint m_frequency;
|
uint m_frequency;
|
||||||
|
QString m_secuType;
|
||||||
|
|
||||||
|
//only for m_isConfiged = true
|
||||||
bool m_isConfigured;
|
bool m_isConfigured;
|
||||||
QString m_connName;
|
QString m_connName;
|
||||||
QString m_connDbusPath;
|
QString m_connDbusPath;
|
||||||
QString m_secuType;
|
|
||||||
// NetworkManager::AccessPoint::WpaFlags m_wpaFlag;
|
|
||||||
// NetworkManager::AccessPoint::WpaFlags m_rsnFlag;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||||
|
|
|
@ -27,8 +27,7 @@ KyWirelessNetResource::~KyWirelessNetResource()
|
||||||
bool KyWirelessNetResource::getAllDeviceWifiNetwork(QMap<QString,QList<KyWirelessNetItem> > &map)
|
bool KyWirelessNetResource::getAllDeviceWifiNetwork(QMap<QString,QList<KyWirelessNetItem> > &map)
|
||||||
{
|
{
|
||||||
onWifiNetworkDeviceDisappear();
|
onWifiNetworkDeviceDisappear();
|
||||||
if (m_WifiNetworkList.isEmpty())
|
if (m_WifiNetworkList.isEmpty()) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
map = m_WifiNetworkList;
|
map = m_WifiNetworkList;
|
||||||
|
@ -37,18 +36,36 @@ bool KyWirelessNetResource::getAllDeviceWifiNetwork(QMap<QString,QList<KyWireles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool KyWirelessNetResource::getDeviceWifiNetwork(QString devIfaceName, QList<KyWirelessNetItem> &list)
|
bool KyWirelessNetResource::getDeviceWifiNetwork(QString devIfaceName, QList<KyWirelessNetItem> &wirelessNetResource)
|
||||||
{
|
{
|
||||||
onWifiNetworkDeviceDisappear();
|
onWifiNetworkDeviceDisappear();
|
||||||
if (!m_WifiNetworkList.contains(devIfaceName))
|
|
||||||
{
|
if (!m_WifiNetworkList.contains(devIfaceName)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
list = m_WifiNetworkList[devIfaceName];
|
wirelessNetResource = m_WifiNetworkList[devIfaceName];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KyWirelessNetResource::getWifiNetwork(QString &devIfaceName, QString &ssid, KyWirelessNetItem &wirelessNetResource)
|
||||||
|
{
|
||||||
|
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) {
|
||||||
|
wirelessNetResource = m_WifiNetworkList[devIfaceName].at(index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool KyWirelessNetResource::getWirelessActiveConnection(QMap<QString,QStringList> &map)
|
bool KyWirelessNetResource::getWirelessActiveConnection(QMap<QString,QStringList> &map)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -77,8 +94,7 @@ bool KyWirelessNetResource::getWirelessActiveConnection(QMap<QString,QStringList
|
||||||
}
|
}
|
||||||
QString ssid;
|
QString ssid;
|
||||||
QString ifaceName = getDeviceIFace(activeConnectionPtr,ssid);
|
QString ifaceName = getDeviceIFace(activeConnectionPtr,ssid);
|
||||||
if (map.contains(ifaceName))
|
if (map.contains(ifaceName)) {
|
||||||
{
|
|
||||||
map[ifaceName].append(ssid);
|
map[ifaceName].append(ssid);
|
||||||
} else {
|
} else {
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
@ -89,30 +105,30 @@ bool KyWirelessNetResource::getWirelessActiveConnection(QMap<QString,QStringList
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection::Ptr actConn, QString &ssid)
|
QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection::Ptr actConn,
|
||||||
|
QString &wirelessNetResourcessid)
|
||||||
{
|
{
|
||||||
if (actConn.isNull())
|
if (actConn.isNull()) {
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkManager::Connection::Ptr conn = actConn->connection();
|
NetworkManager::Connection::Ptr conn = actConn->connection();
|
||||||
NetworkManager::ConnectionSettings::Ptr sett = conn->settings();
|
NetworkManager::ConnectionSettings::Ptr sett = conn->settings();
|
||||||
ssid = sett->id();
|
wirelessNetResourcessid = sett->id();
|
||||||
|
|
||||||
return sett->interfaceName();
|
return sett->interfaceName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KyWirelessNetResource::kyWirelessNetItemListInit()
|
void KyWirelessNetResource::kyWirelessNetItemListInit()
|
||||||
{
|
{
|
||||||
qDebug() << m_networkResourceInstance->m_wifiNets.size();
|
qDebug() << m_networkResourceInstance->m_wifiNets.size();
|
||||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
for (auto const & net : m_networkResourceInstance->m_wifiNets) {
|
||||||
{
|
|
||||||
QString devIface = getDeviceIFace(net);
|
QString devIface = getDeviceIFace(net);
|
||||||
if (devIface.isEmpty())
|
if (devIface.isEmpty()) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!m_WifiNetworkList.contains(devIface))
|
|
||||||
{
|
if (!m_WifiNetworkList.contains(devIface)){
|
||||||
QList<KyWirelessNetItem> list;
|
QList<KyWirelessNetItem> list;
|
||||||
KyWirelessNetItem item(net);
|
KyWirelessNetItem item(net);
|
||||||
list.append(item);
|
list.append(item);
|
||||||
|
@ -122,6 +138,8 @@ void KyWirelessNetResource::kyWirelessNetItemListInit()
|
||||||
m_WifiNetworkList[devIface].append(item);
|
m_WifiNetworkList[devIface].append(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KyWirelessNetResource::getDeviceIFace(NetworkManager::WirelessNetwork::Ptr net)
|
QString KyWirelessNetResource::getDeviceIFace(NetworkManager::WirelessNetwork::Ptr net)
|
||||||
|
@ -195,7 +213,8 @@ void KyWirelessNetResource::onWifiNetworkAdded(QString devIfaceName, QString ssi
|
||||||
list.append(item);
|
list.append(item);
|
||||||
m_WifiNetworkList.insert(devIfaceName,list);
|
m_WifiNetworkList.insert(devIfaceName,list);
|
||||||
}
|
}
|
||||||
emit wifiNetworkAdd(devIfaceName,item);
|
|
||||||
|
emit wifiNetworkAdd(devIfaceName, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KyWirelessNetResource::onWifiNetworkRemoved(QString devIfaceName, QString ssid)
|
void KyWirelessNetResource::onWifiNetworkRemoved(QString devIfaceName, QString ssid)
|
||||||
|
@ -221,36 +240,38 @@ void KyWirelessNetResource::onWifiNetworkRemoved(QString devIfaceName, QString s
|
||||||
|
|
||||||
void KyWirelessNetResource::onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net)
|
void KyWirelessNetResource::onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net)
|
||||||
{
|
{
|
||||||
if (nullptr == net)
|
if (nullptr == net) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString devIface = m_networkResourceInstance->findDeviceUni(net->device())->interfaceName();
|
QString devIface = m_networkResourceInstance->findDeviceUni(net->device())->interfaceName();
|
||||||
if (m_WifiNetworkList.contains(devIface))
|
if (m_WifiNetworkList.contains(devIface))
|
||||||
{
|
{
|
||||||
QList<KyWirelessNetItem>::iterator iter = m_WifiNetworkList[devIface].begin();
|
QList<KyWirelessNetItem>::iterator iter = m_WifiNetworkList[devIface].begin();
|
||||||
while (iter != m_WifiNetworkList[devIface].end())
|
while (iter != m_WifiNetworkList[devIface].end())
|
||||||
{
|
{
|
||||||
|
|
||||||
if (iter->m_NetSsid == net->ssid())
|
if (iter->m_NetSsid == net->ssid())
|
||||||
{
|
{
|
||||||
qDebug() << iter->m_NetSsid;
|
qDebug()<<"recive properity changed signal, sender is" << iter->m_NetSsid;
|
||||||
if (iter->m_signalStrength != net->signalStrength())
|
if (iter->m_signalStrength != net->signalStrength())
|
||||||
{
|
{
|
||||||
iter->m_signalStrength = net->signalStrength();
|
iter->m_signalStrength = net->signalStrength();
|
||||||
emit signalStrengthChange(devIface, net->ssid(), iter->m_signalStrength);
|
emit signalStrengthChange(devIface, net->ssid(), iter->m_signalStrength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iter->m_bssid != net->referenceAccessPoint()->hardwareAddress())
|
if (iter->m_bssid != net->referenceAccessPoint()->hardwareAddress())
|
||||||
{
|
{
|
||||||
iter->m_bssid = net->referenceAccessPoint()->hardwareAddress();
|
iter->m_bssid = net->referenceAccessPoint()->hardwareAddress();
|
||||||
emit bssidChange(devIface, net->ssid(), iter->m_bssid);
|
emit bssidChange(devIface, net->ssid(), iter->m_bssid);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString secuType = enumToQstring(net->referenceAccessPoint()->capabilities(), net->referenceAccessPoint()->wpaFlags(), net->referenceAccessPoint()->rsnFlags());
|
QString secuType = enumToQstring(net->referenceAccessPoint()->capabilities(), net->referenceAccessPoint()->wpaFlags(), net->referenceAccessPoint()->rsnFlags());
|
||||||
if (iter->m_secuType != secuType)
|
if (iter->m_secuType != secuType)
|
||||||
{
|
{
|
||||||
iter->m_secuType = secuType;
|
iter->m_secuType = secuType;
|
||||||
emit secuTypeChange(devIface, net->ssid(), secuType);
|
emit secuTypeChange(devIface, net->ssid(), secuType);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
iter++;
|
iter++;
|
||||||
|
@ -264,50 +285,6 @@ void KyWirelessNetResource::onWifiNetworkDeviceDisappear()
|
||||||
kyWirelessNetItemListInit();
|
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)
|
bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info)
|
||||||
{
|
{
|
||||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
||||||
|
@ -316,6 +293,7 @@ bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsIn
|
||||||
qDebug() << "modifyEnterPriseInfoTls connection missing";
|
qDebug() << "modifyEnterPriseInfoTls connection missing";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||||
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||||
if (security_sett.isNull())
|
if (security_sett.isNull())
|
||||||
|
@ -352,47 +330,12 @@ bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsIn
|
||||||
return true;
|
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.connName = conn->name();
|
|
||||||
info.phase2AuthMethod = (KyEapMethodPeapAuth)setting->phase2AuthEapMethod();
|
|
||||||
info.userName = setting->identity();
|
|
||||||
info.userPWD = setting->password();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info)
|
bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info)
|
||||||
{
|
{
|
||||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
||||||
if (conn.isNull())
|
if (conn.isNull())
|
||||||
{
|
{
|
||||||
qDebug() << "modifyEnterPriseInfoPeap connection missing";
|
qDebug() << "getEnterPriseInfoPeap connection missing";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||||
|
@ -414,66 +357,13 @@ bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeap
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
info.connName = conn->name();
|
info.phase2AuthMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod();
|
||||||
info.phase2AuthMethod = (KyEapMethodPeapAuth)setting->phase2AuthEapMethod();
|
|
||||||
info.userName = setting->identity();
|
info.userName = setting->identity();
|
||||||
info.userPWD = setting->password();
|
info.userPWD = setting->password();
|
||||||
|
|
||||||
return true;
|
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)
|
bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info)
|
||||||
{
|
{
|
||||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
||||||
|
@ -503,12 +393,11 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
info.connName = conn->name();
|
info.authEapMethod = (KyEapMethodAuth)setting->phase2AuthEapMethod();
|
||||||
info.authEapMethod = (KyEapMethodTtlsAuth)setting->phase2AuthEapMethod();
|
info.authNoEapMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod();
|
||||||
info.authNoEapMethod = (KyNoEapMethodTtlsAuth)setting->phase2AuthMethod();
|
|
||||||
|
|
||||||
info.authType = KyTtlsAuthMethod::AUTH_EAP;
|
info.authType = KyTtlsAuthMethod::AUTH_EAP;
|
||||||
if (info.authEapMethod != AuthEapMethodTtlsUnknown)
|
if (info.authEapMethod != KyAuthEapMethodUnknown)
|
||||||
{
|
{
|
||||||
info.authType = KyTtlsAuthMethod::AUTH_EAP;
|
info.authType = KyTtlsAuthMethod::AUTH_EAP;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -17,16 +17,13 @@ public:
|
||||||
~KyWirelessNetResource();
|
~KyWirelessNetResource();
|
||||||
|
|
||||||
//ui层调用接口
|
//ui层调用接口
|
||||||
bool getAllDeviceWifiNetwork(QMap<QString,QList<KyWirelessNetItem> > &map);
|
bool getWifiNetwork(QString &devIfaceName, QString &ssid, KyWirelessNetItem &wirelessNetResource);
|
||||||
bool getDeviceWifiNetwork(QString devIfaceName, QList<KyWirelessNetItem> &KyWirelessNetResource);
|
bool getAllDeviceWifiNetwork(QMap<QString, QList<KyWirelessNetItem> > &map);
|
||||||
|
bool getDeviceWifiNetwork(QString devIfaceName, QList<KyWirelessNetItem> &wirelessNetResource);
|
||||||
|
|
||||||
bool modifyEnterPriseInfoTls(QString &, KyEapMethodTlsInfo &);
|
bool getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info);
|
||||||
bool modifyEnterPriseInfoPeap(QString &, KyEapMethodPeapInfo &);
|
bool getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info);
|
||||||
bool modifyEnterPriseInfoTtls(QString &, KyEapMethodTtlsInfo &);
|
bool getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info);
|
||||||
|
|
||||||
bool getEnterPriseInfoTls(QString &, KyEapMethodTlsInfo &);
|
|
||||||
bool getEnterPriseInfoPeap(QString &, KyEapMethodPeapInfo &);
|
|
||||||
bool getEnterPriseInfoTtls(QString &, KyEapMethodTtlsInfo &);
|
|
||||||
|
|
||||||
bool getWirelessActiveConnection(QMap<QString, QStringList> &map);
|
bool getWirelessActiveConnection(QMap<QString, QStringList> &map);
|
||||||
|
|
||||||
|
@ -34,7 +31,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void kyWirelessNetItemListInit();
|
void kyWirelessNetItemListInit();
|
||||||
QString getDeviceIFace(NetworkManager::WirelessNetwork::Ptr net);
|
QString getDeviceIFace(NetworkManager::WirelessNetwork::Ptr net);
|
||||||
QString getDeviceIFace(NetworkManager::ActiveConnection::Ptr actConn, QString &KyWirelessNetResourcessid);
|
QString getDeviceIFace(NetworkManager::ActiveConnection::Ptr actConn, QString &wirelessNetResourcessid);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onWifiNetworkAdded(QString, QString);
|
void onWifiNetworkAdded(QString, QString);
|
||||||
|
@ -56,7 +53,7 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||||
QMap<QString,QList<KyWirelessNetItem> > m_WifiNetworkList;
|
QMap<QString, QList<KyWirelessNetItem> > m_WifiNetworkList;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,8 @@ DbusAdaptor::DbusAdaptor(MainWindow *parent)
|
||||||
{
|
{
|
||||||
// constructor
|
// constructor
|
||||||
qDBusRegisterMetaType<QVector<QStringList>>();
|
qDBusRegisterMetaType<QVector<QStringList>>();
|
||||||
|
//setAutoRelaySignals(true)后会自动转发mainwindow发出的同名信号,因此不必再额外写一个转发
|
||||||
setAutoRelaySignals(true);
|
setAutoRelaySignals(true);
|
||||||
//setAutoRelaySignals(true)后会自动转发同名信号,因此不必再额外像如下代码一样写一个转发
|
|
||||||
// connect(parent, &MainWindow::getWifiListFinished, this, [ = ]() {
|
|
||||||
// QDBusMessage msg = QDBusMessage::createSignal("/com/kylin/network", "com.kylin.network", "getWifiListFinished");
|
|
||||||
// QDBusConnection::sessionBus().send(msg);
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DbusAdaptor::~DbusAdaptor()
|
DbusAdaptor::~DbusAdaptor()
|
||||||
|
@ -41,24 +37,19 @@ DbusAdaptor::~DbusAdaptor()
|
||||||
|
|
||||||
void DbusAdaptor::showMainWindow()
|
void DbusAdaptor::showMainWindow()
|
||||||
{
|
{
|
||||||
// handle method call com.kylin.weather.showMainWindow
|
parent()->showMainwindow();
|
||||||
//edited the code manually by lixiang
|
|
||||||
//parent()->handleIconClicked();
|
|
||||||
parent()->on_showWindowAction();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DbusAdaptor::showPb(QString type, QString name)
|
void DbusAdaptor::showPb(QString type, QString name)
|
||||||
{
|
{
|
||||||
parent()->showPb(type, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DbusAdaptor::requestRefreshWifiList()
|
void DbusAdaptor::requestRefreshWifiList()
|
||||||
{
|
{
|
||||||
parent()->requestRefreshWifiList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QStringList> DbusAdaptor::getWifiList()
|
QVector<QStringList> DbusAdaptor::getWifiList()
|
||||||
{
|
{
|
||||||
return parent()->dbus_wifiList;
|
return QVector<QStringList>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ QT_END_NAMESPACE
|
||||||
* Adaptor class for interface com.kylin.weather
|
* Adaptor class for interface com.kylin.weather
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mainwindow.h"//added the code manually by lixiang
|
#include "new-mainwindow.h"
|
||||||
|
|
||||||
class DbusAdaptor: public QDBusAbstractAdaptor
|
class DbusAdaptor: public QDBusAbstractAdaptor
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,7 @@ void quitThread(QThread *thread)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent)
|
KylinDBus::KylinDBus(OldMainWindow *mainWindow, QObject *parent) :QObject(parent)
|
||||||
{
|
{
|
||||||
this->mw = mainWindow;
|
this->mw = mainWindow;
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,14 @@
|
||||||
#define WIFI_CONNECTED 2
|
#define WIFI_CONNECTED 2
|
||||||
#define WIFI_DISCONNECTED 3
|
#define WIFI_DISCONNECTED 3
|
||||||
|
|
||||||
class MainWindow;
|
class OldMainWindow;
|
||||||
class Utils;
|
class Utils;
|
||||||
|
|
||||||
class KylinDBus : public QObject
|
class KylinDBus : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit KylinDBus(MainWindow *mw = 0, QObject *parent = nullptr);
|
explicit KylinDBus(OldMainWindow *mw = 0, QObject *parent = nullptr);
|
||||||
~KylinDBus();
|
~KylinDBus();
|
||||||
|
|
||||||
void getObjectPath();
|
void getObjectPath();
|
||||||
|
@ -134,7 +134,7 @@ public slots:
|
||||||
void requestScanWifi();
|
void requestScanWifi();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWindow *mw;
|
OldMainWindow *mw;
|
||||||
Utils *mUtils;
|
Utils *mUtils;
|
||||||
QThread *mUtilsThread;
|
QThread *mUtilsThread;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,152 @@
|
||||||
|
#include "customstyle.h"
|
||||||
|
|
||||||
|
CustomStyle::CustomStyle(const QString &proxyStyleName) : QProxyStyle (proxyStyleName)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize CustomStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case CT_TabBarTab: {
|
||||||
|
QSize size(0,40);
|
||||||
|
if (const QStyleOptionTab *tab= qstyleoption_cast<const QStyleOptionTab *>(option)) {
|
||||||
|
switch (tab->shape) {
|
||||||
|
case QTabBar::RoundedNorth:
|
||||||
|
case QTabBar::RoundedSouth: {
|
||||||
|
return size + QSize(50,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QTabBar::RoundedWest:
|
||||||
|
case QTabBar::RoundedEast: {
|
||||||
|
return size + QSize(0,50);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QProxyStyle::sizeFromContents(type, option, contentsSize, widget);
|
||||||
|
}
|
||||||
|
void CustomStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
||||||
|
{
|
||||||
|
// switch (element) {
|
||||||
|
// case CE_TabBarTab: {
|
||||||
|
// if (QStyle::State_Selected != option->state) {
|
||||||
|
// painter->save();
|
||||||
|
// painter->setBrush(QColor(0,0,0,0));
|
||||||
|
// painter->drawRect(widget->rect());
|
||||||
|
//// painter->setOpacity(0.1);
|
||||||
|
// painter->restore();
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// default: {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return QProxyStyle::drawControl(element, option, painter, widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
//void CustomStyle::drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::drawComplexControl(control, option, painter, widget);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CustomStyle::drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment, const QPixmap &pixmap) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::drawItemPixmap(painter, rectangle, alignment, pixmap);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CustomStyle::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::drawItemText(painter, rectangle, alignment, palette, enabled, text, textRole);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CustomStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::drawPrimitive(element, option, painter, widget);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//QPixmap CustomStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::generatedIconPixmap(iconMode, pixmap, option);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//QStyle::SubControl CustomStyle::hitTestComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, const QPoint &position, const QWidget *widget) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::hitTestComplexControl(control, option, position, widget);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//QRect CustomStyle::itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::itemPixmapRect(rectangle, alignment, pixmap);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//QRect CustomStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::itemTextRect(metrics, rectangle, alignment, enabled, text);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//int CustomStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::pixelMetric(metric, option, widget);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CustomStyle::polish(QWidget *widget)
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::polish(widget);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CustomStyle::polish(QApplication *application)
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::polish(application);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CustomStyle::polish(QPalette &palette)
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::polish(palette);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CustomStyle::unpolish(QWidget *widget)
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::unpolish(widget);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void CustomStyle::unpolish(QApplication *application)
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::unpolish(application);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//QIcon CustomStyle::standardIcon(QStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::standardIcon(standardIcon, option, widget);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//QPalette CustomStyle::standardPalette() const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::standardPalette();
|
||||||
|
//}
|
||||||
|
|
||||||
|
//int CustomStyle::styleHint(QStyle::StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::styleHint(hint, option, widget, returnData);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//QRect CustomStyle::subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl, const QWidget *widget) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::subControlRect(control, option, subControl, widget);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//QRect CustomStyle::subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget) const
|
||||||
|
//{
|
||||||
|
// return QProxyStyle::subElementRect(element, option, widget);
|
||||||
|
//}
|
|
@ -0,0 +1,47 @@
|
||||||
|
#ifndef CUSTOMSTYLE_H
|
||||||
|
#define CUSTOMSTYLE_H
|
||||||
|
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QProxyStyle>
|
||||||
|
#include <QStyleFactory>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPainterPath>
|
||||||
|
#include <QStyleOptionSlider>
|
||||||
|
|
||||||
|
class CustomStyle : public QProxyStyle
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit CustomStyle(const QString &proxyStyleName = "windows");
|
||||||
|
~CustomStyle() = default;
|
||||||
|
virtual QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget = nullptr) const;
|
||||||
|
virtual void drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const;
|
||||||
|
// virtual void drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const;
|
||||||
|
|
||||||
|
// virtual void drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment, const QPixmap &pixmap) const;
|
||||||
|
// virtual void drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
|
||||||
|
|
||||||
|
// virtual void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const;
|
||||||
|
// virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const;
|
||||||
|
// virtual QStyle::SubControl hitTestComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, const QPoint &position, const QWidget *widget = nullptr) const;
|
||||||
|
// virtual QRect itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const;
|
||||||
|
// virtual QRect itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const;
|
||||||
|
// //virtual int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget);
|
||||||
|
// virtual int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const;
|
||||||
|
|
||||||
|
// virtual void polish(QWidget *widget);
|
||||||
|
// virtual void polish(QApplication *application);
|
||||||
|
// virtual void polish(QPalette &palette);
|
||||||
|
// virtual void unpolish(QWidget *widget);
|
||||||
|
// virtual void unpolish(QApplication *application);
|
||||||
|
|
||||||
|
// virtual QIcon standardIcon(QStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
|
||||||
|
// virtual QPalette standardPalette() const;
|
||||||
|
|
||||||
|
// virtual int styleHint(QStyle::StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const;
|
||||||
|
// virtual QRect subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl, const QWidget *widget = nullptr) const;
|
||||||
|
// virtual QRect subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget = nullptr) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CUSTOMSTYLE_H
|
|
@ -1,31 +1,32 @@
|
||||||
INCLUDEPATH += $$PWD
|
INCLUDEPATH += $$PWD
|
||||||
include(tools/tools.pri)
|
include(tools/tools.pri)
|
||||||
include(wireless-security/wireless-security.pri)
|
include(wireless-security/wireless-security.pri)
|
||||||
|
include(xatom/xatom.pri)
|
||||||
|
include(tab-pages/tab-pages.pri)
|
||||||
|
include(list-items/list-items.pri)
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
$$PWD/confform.ui \
|
$$PWD/confform.ui \
|
||||||
$$PWD/mainwindow.ui \
|
$$PWD/mainwindow.ui \
|
||||||
$$PWD/oneconnform.ui \
|
|
||||||
$$PWD/onelancform.ui \
|
|
||||||
$$PWD/wificonfigdialog.ui \
|
$$PWD/wificonfigdialog.ui \
|
||||||
$$PWD/wpawifidialog.ui
|
$$PWD/wpawifidialog.ui
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/confform.h \
|
$$PWD/confform.h \
|
||||||
|
$$PWD/customstyle.h \
|
||||||
$$PWD/kylinwiredwidget.h \
|
$$PWD/kylinwiredwidget.h \
|
||||||
$$PWD/mainwindow.h \
|
$$PWD/mainwindow.h \
|
||||||
$$PWD/nmdemo.h \
|
$$PWD/nmdemo.h \
|
||||||
$$PWD/oneconnform.h \
|
|
||||||
$$PWD/onelancform.h \
|
|
||||||
$$PWD/wificonfigdialog.h \
|
$$PWD/wificonfigdialog.h \
|
||||||
$$PWD/wpawifidialog.h
|
$$PWD/wpawifidialog.h \
|
||||||
|
$$PWD/new-mainwindow.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/confform.cpp \
|
$$PWD/confform.cpp \
|
||||||
|
$$PWD/customstyle.cpp \
|
||||||
$$PWD/kylinwiredwidget.cpp \
|
$$PWD/kylinwiredwidget.cpp \
|
||||||
$$PWD/mainwindow.cpp \
|
$$PWD/mainwindow.cpp \
|
||||||
$$PWD/nmdemo.cpp \
|
$$PWD/nmdemo.cpp \
|
||||||
$$PWD/oneconnform.cpp \
|
|
||||||
$$PWD/onelancform.cpp \
|
|
||||||
$$PWD/wificonfigdialog.cpp \
|
$$PWD/wificonfigdialog.cpp \
|
||||||
$$PWD/wpawifidialog.cpp
|
$$PWD/wpawifidialog.cpp \
|
||||||
|
$$PWD/new-mainwindow.cpp
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
$$PWD/oneconnform.ui \
|
||||||
|
$$PWD/onelancform.ui
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/listitem.h \
|
||||||
|
$$PWD/oneconnform.h \
|
||||||
|
$$PWD/onelancform.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/listitem.cpp \
|
||||||
|
$$PWD/oneconnform.cpp \
|
||||||
|
$$PWD/onelancform.cpp
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "listitem.h"
|
||||||
|
|
||||||
|
ListItem::ListItem()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef LISTITEM_H
|
||||||
|
#define LISTITEM_H
|
||||||
|
#include <QFrame>
|
||||||
|
|
||||||
|
class ListItem : public QFrame
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ListItem();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LISTITEM_H
|
|
@ -34,7 +34,7 @@
|
||||||
#include <QDBusObjectPath>
|
#include <QDBusObjectPath>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
|
||||||
OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *confForm, KSimpleNM *ksnm) :
|
OneConnForm::OneConnForm(QWidget *parent, OldMainWindow *mainWindow, ConfForm *confForm, KSimpleNM *ksnm) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::OneConnForm)
|
ui(new Ui::OneConnForm)
|
||||||
{
|
{
|
||||||
|
@ -154,7 +154,7 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
|
||||||
this->waitTimer = new QTimer(this);
|
this->waitTimer = new QTimer(this);
|
||||||
connect(waitTimer, SIGNAL(timeout()), this, SLOT(waitAnimStep()));
|
connect(waitTimer, SIGNAL(timeout()), this, SLOT(waitAnimStep()));
|
||||||
|
|
||||||
connect(mw, &MainWindow::reConnectWifi, this, [ = ](const QString& uuid) {
|
connect(mw, &OldMainWindow::reConnectWifi, this, [ = ](const QString& uuid) {
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
QThread *t = new QThread();
|
QThread *t = new QThread();
|
||||||
BackThread *bt = new BackThread();
|
BackThread *bt = new BackThread();
|
||||||
|
@ -168,12 +168,12 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(mw, &MainWindow::startReconnectWifi, this, [ = ](const QString &ssid) {
|
connect(mw, &OldMainWindow::startReconnectWifi, this, [ = ](const QString &ssid) {
|
||||||
if (ssid == this->wifiName && !this->isWaiting) {
|
if (ssid == this->wifiName && !this->isWaiting) {
|
||||||
this->startWifiWaiting(true);
|
this->startWifiWaiting(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(mw, &MainWindow::stopReconnectWifi, this, [ = ](const QString &ssid, const int &result) {
|
connect(mw, &OldMainWindow::stopReconnectWifi, this, [ = ](const QString &ssid, const int &result) {
|
||||||
if (ssid == this->wifiName) {
|
if (ssid == this->wifiName) {
|
||||||
qDebug()<<"Reconnect "<<ssid<<" finished. result="<<result;
|
qDebug()<<"Reconnect "<<ssid<<" finished. result="<<result;
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
|
@ -184,7 +184,7 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(mw, &MainWindow::wifiClicked, this, [ = ](QString name) {
|
connect(mw, &OldMainWindow::wifiClicked, this, [ = ](QString name) {
|
||||||
if (QString::compare(name, this->wifiName) == 0 && !this->isActive) {
|
if (QString::compare(name, this->wifiName) == 0 && !this->isActive) {
|
||||||
on_btnConn_clicked();
|
on_btnConn_clicked();
|
||||||
}
|
}
|
|
@ -52,7 +52,7 @@
|
||||||
#define Y_LINE_BIG_EXTEND 137
|
#define Y_LINE_BIG_EXTEND 137
|
||||||
#define X_LINE_BIG_EXTEND 2
|
#define X_LINE_BIG_EXTEND 2
|
||||||
|
|
||||||
class MainWindow;
|
class OldMainWindow;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class OneConnForm;
|
class OneConnForm;
|
||||||
|
@ -63,7 +63,7 @@ class OneConnForm : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit OneConnForm(QWidget *parent = 0, MainWindow *mw = 0, ConfForm *confForm = 0, KSimpleNM *ksnm = 0);
|
explicit OneConnForm(QWidget *parent = 0, OldMainWindow *mw = 0, ConfForm *confForm = 0, KSimpleNM *ksnm = 0);
|
||||||
~OneConnForm();
|
~OneConnForm();
|
||||||
|
|
||||||
// category:1->normal protocol 1->wifi 6 2->wifi 6+
|
// category:1->normal protocol 1->wifi 6 2->wifi 6+
|
||||||
|
@ -157,7 +157,7 @@ private:
|
||||||
bool m_connWithPwd = true; //是否使用密码连接
|
bool m_connWithPwd = true; //是否使用密码连接
|
||||||
|
|
||||||
Ui::OneConnForm *ui = nullptr;
|
Ui::OneConnForm *ui = nullptr;
|
||||||
MainWindow *mw = nullptr;
|
OldMainWindow *mw = nullptr;
|
||||||
ConfForm *cf = nullptr;
|
ConfForm *cf = nullptr;
|
||||||
KSimpleNM *ks = nullptr;
|
KSimpleNM *ks = nullptr;
|
||||||
bool hasPwd;
|
bool hasPwd;
|
|
@ -477,8 +477,8 @@ void OneLancForm::toConnectWiredNetwork()
|
||||||
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
|
connect(bt, SIGNAL(btFinish()), t, SLOT(quit()));
|
||||||
t->start();
|
t->start();
|
||||||
*/
|
*/
|
||||||
|
QString devName = "enp2s0";
|
||||||
m_wiredConnectOperation->activateWiredConnection(uuidName);
|
m_wiredConnectOperation->activateWiredConnection(uuidName, devName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//点击列表中item扩展后显示信息的位置时,执行该函数,用于显示网络配置界面
|
//点击列表中item扩展后显示信息的位置时,执行该函数,用于显示网络配置界面
|
|
@ -53,7 +53,7 @@
|
||||||
#define Y_LINE_EXTEND 161
|
#define Y_LINE_EXTEND 161
|
||||||
#define X_LINE_EXTEND 2
|
#define X_LINE_EXTEND 2
|
||||||
|
|
||||||
class MainWindow;
|
class OldMainWindow;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class OneLancForm;
|
class OneLancForm;
|
||||||
|
@ -121,7 +121,7 @@ private:
|
||||||
int countCurrentTime;
|
int countCurrentTime;
|
||||||
|
|
||||||
Ui::OneLancForm *ui = nullptr;
|
Ui::OneLancForm *ui = nullptr;
|
||||||
MainWindow *mw = nullptr;
|
OldMainWindow *mw = nullptr;
|
||||||
ConfForm *cf = nullptr;
|
ConfForm *cf = nullptr;
|
||||||
KSimpleNM *ks = nullptr;
|
KSimpleNM *ks = nullptr;
|
||||||
KyWiredConnectOperation *m_wiredConnectOperation = nullptr;
|
KyWiredConnectOperation *m_wiredConnectOperation = nullptr;
|
File diff suppressed because it is too large
Load Diff
|
@ -123,13 +123,13 @@ namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class OldMainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = 0);
|
explicit OldMainWindow(QWidget *parent = 0);
|
||||||
~MainWindow();
|
~OldMainWindow();
|
||||||
|
|
||||||
void justShowTrayIcon();
|
void justShowTrayIcon();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,307 @@
|
||||||
|
#include "new-mainwindow.h"
|
||||||
|
#include "customstyle.h"
|
||||||
|
#include "lanpage.h"
|
||||||
|
#include "wlanpage.h"
|
||||||
|
#include <KWindowEffects>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDBusReply>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
|
#define MAINWINDOW_WIDTH 420
|
||||||
|
#define MAINWINDOW_HEIGHT 456
|
||||||
|
#define THEME_SCHAME "org.ukui.style"
|
||||||
|
#define COLOR_THEME "styleName"
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||||
|
{
|
||||||
|
firstlyStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::showMainwindow show主窗口,同时也作为dbus接口提供给外部组件调用
|
||||||
|
*/
|
||||||
|
void MainWindow::showMainwindow()
|
||||||
|
{
|
||||||
|
if (!m_loadFinished) {
|
||||||
|
m_secondaryStartTimer->stop();
|
||||||
|
secondaryStart();
|
||||||
|
}
|
||||||
|
this->resetWindowPosition();
|
||||||
|
this->showNormal();
|
||||||
|
this->raise();
|
||||||
|
this->activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::hideMainwindow 隐藏主页面时要进行的操作,后续可以添加到此函数
|
||||||
|
*/
|
||||||
|
void MainWindow::hideMainwindow()
|
||||||
|
{
|
||||||
|
this->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::firstlyStart 一级启动,执行重要且不耗时的启动操作
|
||||||
|
*/
|
||||||
|
void MainWindow::firstlyStart()
|
||||||
|
{
|
||||||
|
initWindowProperties();
|
||||||
|
initUI();
|
||||||
|
initWindowTheme();
|
||||||
|
initTrayIcon();
|
||||||
|
installEventFilter(this);
|
||||||
|
m_secondaryStartTimer = new QTimer(this);
|
||||||
|
connect(m_secondaryStartTimer, &QTimer::timeout, this, [ = ]() {
|
||||||
|
m_secondaryStartTimer->stop();
|
||||||
|
secondaryStart();//满足条件后执行比较耗时的二级启动
|
||||||
|
});
|
||||||
|
m_secondaryStartTimer->start(5 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::secondaryStart 二级启动,可以将较耗时的初始化操作放到此处执行
|
||||||
|
*/
|
||||||
|
void MainWindow::secondaryStart()
|
||||||
|
{
|
||||||
|
if (m_loadFinished)
|
||||||
|
return;
|
||||||
|
m_loadFinished = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::initWindowProperties 初始化一些窗口属性
|
||||||
|
*/
|
||||||
|
void MainWindow::initWindowProperties()
|
||||||
|
{
|
||||||
|
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
|
this->setWindowTitle(tr("kylin-nm"));
|
||||||
|
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")));
|
||||||
|
//绘制毛玻璃特效
|
||||||
|
this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT);
|
||||||
|
QPainterPath path;
|
||||||
|
auto rect = this->rect();
|
||||||
|
path.addRoundedRect(rect, 6, 6);
|
||||||
|
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::initUI 初始化窗口内控件
|
||||||
|
*/
|
||||||
|
void MainWindow::initUI()
|
||||||
|
{
|
||||||
|
m_centralWidget = new QTabWidget(this);
|
||||||
|
this->setCentralWidget(m_centralWidget);
|
||||||
|
m_centralWidget->tabBar()->setFixedWidth(this->width());
|
||||||
|
LanPage * m_lanWidget = new LanPage(m_centralWidget);
|
||||||
|
WlanPage * m_wlanWidget = new WlanPage(m_centralWidget);
|
||||||
|
m_centralWidget->addTab(m_lanWidget, QIcon::fromTheme("network-wired-connected-symbolic", QIcon::fromTheme("network-wired-symbolic", QIcon(":/res/l/network-online.svg"))), tr("LAN"));
|
||||||
|
m_centralWidget->addTab(m_wlanWidget, QIcon::fromTheme("network-wireless-signal-excellent-symbolic", QIcon(":/res/x/wifi-list-bg.svg")), tr("WLAN"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::initTrayIcon 初始化托盘图标和托盘右键菜单
|
||||||
|
*/
|
||||||
|
void MainWindow::initTrayIcon()
|
||||||
|
{
|
||||||
|
m_trayIcon = new QSystemTrayIcon();
|
||||||
|
m_trayIconMenu = new QMenu();
|
||||||
|
m_showMainwindowAction = new QAction(tr("Show MainWindow"),this);
|
||||||
|
m_showSettingsAction = new QAction(tr("Settings"),this);
|
||||||
|
|
||||||
|
m_trayIcon->setToolTip(QString(tr("kylin-nm")));
|
||||||
|
m_showSettingsAction->setIcon(QIcon::fromTheme("document-page-setup-symbolic", QIcon(":/res/x/setup.png")) );
|
||||||
|
m_trayIconMenu->addAction(m_showMainwindowAction);
|
||||||
|
m_trayIconMenu->addAction(m_showSettingsAction);
|
||||||
|
m_trayIcon->setContextMenu(m_trayIconMenu);
|
||||||
|
m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic"));
|
||||||
|
|
||||||
|
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::onTrayIconActivated);
|
||||||
|
connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled);
|
||||||
|
connect(m_showSettingsAction, &QAction::triggered, this, &MainWindow::onShowSettingsActionTriggled);
|
||||||
|
m_trayIcon->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::resetWindowPosition 重新计算窗口位置
|
||||||
|
*/
|
||||||
|
void MainWindow::resetWindowPosition()
|
||||||
|
{
|
||||||
|
#define MARGIN 4
|
||||||
|
#define PANEL_TOP 1
|
||||||
|
#define PANEL_LEFT 2
|
||||||
|
#define PANEL_RIGHT 3
|
||||||
|
//#define PANEL_BOTTOM 4
|
||||||
|
if (!m_positionInterface) {
|
||||||
|
m_positionInterface = new QDBusInterface("org.ukui.panel",
|
||||||
|
"/panel/position",
|
||||||
|
"org.ukui.panel",
|
||||||
|
QDBusConnection::sessionBus());
|
||||||
|
}
|
||||||
|
QDBusReply<QVariantList> reply = m_positionInterface->call("GetPrimaryScreenGeometry");
|
||||||
|
//reply获取的参数共5个,分别是 主屏可用区域的起点x坐标,主屏可用区域的起点y坐标,主屏可用区域的宽度,主屏可用区域高度,任务栏位置
|
||||||
|
if (!m_positionInterface->isValid() || !reply.isValid() || reply.value().size() < 5) {
|
||||||
|
qCritical() << QDBusConnection::sessionBus().lastError().message();
|
||||||
|
this->setGeometry(0, 0, this->width(), this->height());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QVariantList position_list = reply.value();
|
||||||
|
int position = position_list.at(4).toInt();
|
||||||
|
switch(position){
|
||||||
|
case PANEL_TOP:
|
||||||
|
//任务栏位于上方
|
||||||
|
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
|
||||||
|
position_list.at(1).toInt() + MARGIN,
|
||||||
|
this->width(), this->height());
|
||||||
|
break;
|
||||||
|
//任务栏位于左边
|
||||||
|
case PANEL_LEFT:
|
||||||
|
this->setGeometry(position_list.at(0).toInt() + MARGIN,
|
||||||
|
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
|
||||||
|
this->width(), this->height());
|
||||||
|
break;
|
||||||
|
//任务栏位于右边
|
||||||
|
case PANEL_RIGHT:
|
||||||
|
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
|
||||||
|
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
|
||||||
|
this->width(), this->height());
|
||||||
|
break;
|
||||||
|
//任务栏位于下方
|
||||||
|
default:
|
||||||
|
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
|
||||||
|
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
|
||||||
|
this->width(), this->height());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
qDebug() << " Position of ukui-panel is " << position << "; Position of mainwindow is " << this->geometry() << "." << Q_FUNC_INFO << __LINE__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::resetTrayIconTool 重新获取网络连接状态并重新设置图标和tooltip
|
||||||
|
*/
|
||||||
|
void MainWindow::resetTrayIconTool()
|
||||||
|
{
|
||||||
|
//ZJP_TODO 检测当前连接的是有线还是无线,是否可用,设置图标和tooltip,图标最好提前define
|
||||||
|
// int connectivity = objKyDBus->getNetworkConectivity();
|
||||||
|
// qDebug() << "Value of current network Connectivity property : "<< connectivity;
|
||||||
|
// switch (connectivity) {
|
||||||
|
// case UnknownConnectivity:
|
||||||
|
// case Portal:
|
||||||
|
// case Limited:
|
||||||
|
// setTrayIcon(iconLanOnlineNoInternet);
|
||||||
|
// trayIcon->setToolTip(QString(tr("Network Connected But Can Not Access Internet")));
|
||||||
|
// break;
|
||||||
|
// case NoConnectivity:
|
||||||
|
// case Full:
|
||||||
|
// setTrayIcon(iconLanOnline);
|
||||||
|
// trayIcon->setToolTip(QString(tr("kylin-nm")));
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
qDebug() << "Has set tray icon to be XXX." << Q_FUNC_INFO << __LINE__;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::initWindowTheme 初始化窗口主题并创建信号槽
|
||||||
|
*/
|
||||||
|
void MainWindow::initWindowTheme()
|
||||||
|
{
|
||||||
|
const QByteArray style_id(THEME_SCHAME);
|
||||||
|
if (QGSettings::isSchemaInstalled(style_id)) {
|
||||||
|
m_styleGsettings = new QGSettings(style_id);
|
||||||
|
resetWindowTheme();
|
||||||
|
connect(m_styleGsettings, &QGSettings::changed, this, &MainWindow::onThemeChanged);
|
||||||
|
} else {
|
||||||
|
qWarning() << "Gsettings interface \"org.ukui.style\" is not exist!" << Q_FUNC_INFO << __LINE__;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::resetWindowTheme 读取和设置窗口主题
|
||||||
|
*/
|
||||||
|
void MainWindow::resetWindowTheme()
|
||||||
|
{
|
||||||
|
if (!m_styleGsettings) { return; }
|
||||||
|
QString currentTheme = m_styleGsettings->get(COLOR_THEME).toString();
|
||||||
|
auto app = static_cast<QApplication*>(QCoreApplication::instance());
|
||||||
|
if(currentTheme == "ukui-dark" || currentTheme == "ukui-black"){
|
||||||
|
app->setStyle(new CustomStyle("ukui-dark"));
|
||||||
|
qDebug() << "Has set color theme to ukui-dark." << Q_FUNC_INFO << __LINE__;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
app->setStyle(new CustomStyle("ukui-light"));
|
||||||
|
qDebug() << "Has set color theme to ukui-light." << Q_FUNC_INFO << __LINE__;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::showControlCenter 打开控制面板网络界面
|
||||||
|
*/
|
||||||
|
void MainWindow::showControlCenter()
|
||||||
|
{
|
||||||
|
QProcess process;
|
||||||
|
process.startDetached("ukui-control-center --netconnect");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::onTrayIconActivated 点击托盘图标的槽函数
|
||||||
|
*/
|
||||||
|
void MainWindow::onTrayIconActivated()
|
||||||
|
{
|
||||||
|
if (this->isVisible()) {
|
||||||
|
qDebug() << "Received signal of tray icon activated, will hide mainwindow." << Q_FUNC_INFO << __LINE__;
|
||||||
|
hideMainwindow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qDebug() << "Received signal of tray icon activated, will show mainwindow." << Q_FUNC_INFO << __LINE__;
|
||||||
|
this->showMainwindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onShowMainwindowActionTriggled()
|
||||||
|
{
|
||||||
|
showMainwindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onShowSettingsActionTriggled()
|
||||||
|
{
|
||||||
|
showControlCenter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onThemeChanged(const QString &key)
|
||||||
|
{
|
||||||
|
if (key == COLOR_THEME) {
|
||||||
|
qDebug() << "Received signal of theme changed, will reset theme." << Q_FUNC_INFO << __LINE__;
|
||||||
|
resetWindowTheme();
|
||||||
|
} else {
|
||||||
|
qDebug() << "Received signal of theme changed, key=" << key << " will do nothing." << Q_FUNC_INFO << __LINE__;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::keyPressEvent 按esc键关闭主界面
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if (event->key() == Qt::Key_Escape) {
|
||||||
|
hideMainwindow();
|
||||||
|
}
|
||||||
|
return QWidget::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MainWindow::eventFilter 事件过滤器
|
||||||
|
* @param watched
|
||||||
|
* @param event
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::ActivationChange) {
|
||||||
|
if(QApplication::activeWindow() != this) {
|
||||||
|
hideMainwindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QMainWindow::eventFilter(watched,event);
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
#ifndef MAINWINDOW_H
|
||||||
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QGSettings/QGSettings>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
|
||||||
|
class MainWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
|
void showMainwindow();
|
||||||
|
void hideMainwindow();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent *event);
|
||||||
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void firstlyStart(); //一级启动
|
||||||
|
void secondaryStart(); //二级启动
|
||||||
|
bool m_loadFinished = false; //是否二级启动已执行完
|
||||||
|
QTimer * m_secondaryStartTimer = nullptr; //执行二级启动的倒计时
|
||||||
|
void initWindowProperties();
|
||||||
|
void initUI();
|
||||||
|
void initTrayIcon();
|
||||||
|
void resetTrayIconTool();
|
||||||
|
void initWindowTheme();
|
||||||
|
void resetWindowTheme();
|
||||||
|
void showControlCenter();
|
||||||
|
|
||||||
|
//主窗口的主要构成控件
|
||||||
|
QTabWidget * m_centralWidget = nullptr;
|
||||||
|
|
||||||
|
//监听主题的Gsettings
|
||||||
|
QGSettings * m_styleGsettings = nullptr;
|
||||||
|
|
||||||
|
//获取和重置窗口位置
|
||||||
|
void resetWindowPosition();
|
||||||
|
QDBusInterface * m_positionInterface = nullptr;
|
||||||
|
|
||||||
|
//托盘图标,托盘图标右键菜单
|
||||||
|
QSystemTrayIcon * m_trayIcon = nullptr;
|
||||||
|
QMenu * m_trayIconMenu = nullptr;
|
||||||
|
QAction * m_showMainwindowAction = nullptr;
|
||||||
|
QAction * m_showSettingsAction = nullptr;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onTrayIconActivated();
|
||||||
|
void onShowMainwindowActionTriggled();
|
||||||
|
void onShowSettingsActionTriggled();
|
||||||
|
void onThemeChanged(const QString &key);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MAINWINDOW_H
|
|
@ -33,8 +33,10 @@ NmDemo::NmDemo(QWidget *parent) : QDialog(parent)
|
||||||
|
|
||||||
//init ptr
|
//init ptr
|
||||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||||
m_wco = new KyWirelessConnectOperation();
|
m_wco = new KyWirelessConnectOperation(this);
|
||||||
m_wnr = new KyWirelessNetResource(this);
|
m_wnr = new KyWirelessNetResource(this);
|
||||||
|
m_acr = new KyActiveConnectResourse(this);
|
||||||
|
m_cr = new KyConnectResourse(this);
|
||||||
m_timer = new QTimer(this);
|
m_timer = new QTimer(this);
|
||||||
|
|
||||||
initUi();
|
initUi();
|
||||||
|
@ -71,6 +73,8 @@ void NmDemo::initUi()
|
||||||
enableButton->setText("Enable");
|
enableButton->setText("Enable");
|
||||||
disableButton = new QPushButton(this);
|
disableButton = new QPushButton(this);
|
||||||
disableButton->setText("Disable");
|
disableButton->setText("Disable");
|
||||||
|
addButton = new QPushButton(this);
|
||||||
|
addButton->setText("Add");
|
||||||
wifiList = new QTextEdit(this);
|
wifiList = new QTextEdit(this);
|
||||||
debugLog = new QTextEdit(this);
|
debugLog = new QTextEdit(this);
|
||||||
ssidText = new QLineEdit(this);
|
ssidText = new QLineEdit(this);
|
||||||
|
@ -89,6 +93,7 @@ void NmDemo::initUi()
|
||||||
refreshButton->setGeometry( 5, 5, 80, 30);
|
refreshButton->setGeometry( 5, 5, 80, 30);
|
||||||
connectButton->setGeometry(105, 5, 80, 30);
|
connectButton->setGeometry(105, 5, 80, 30);
|
||||||
disConnectButton->setGeometry(205, 5, 80, 30);
|
disConnectButton->setGeometry(205, 5, 80, 30);
|
||||||
|
addButton->setGeometry(305, 5 ,80 ,30);
|
||||||
modifyButton->setGeometry(5, 55, 80, 30);
|
modifyButton->setGeometry(5, 55, 80, 30);
|
||||||
enableButton->setGeometry(105, 55, 80, 30);
|
enableButton->setGeometry(105, 55, 80, 30);
|
||||||
disableButton->setGeometry(205, 55, 80, 30);
|
disableButton->setGeometry(205, 55, 80, 30);
|
||||||
|
@ -131,9 +136,17 @@ void NmDemo::initConnect()
|
||||||
connect(modifyButton, &QPushButton::clicked, this, &NmDemo::onModifyClicked);
|
connect(modifyButton, &QPushButton::clicked, this, &NmDemo::onModifyClicked);
|
||||||
connect(enableButton, &QPushButton::clicked, this, &NmDemo::onEnableClick);
|
connect(enableButton, &QPushButton::clicked, this, &NmDemo::onEnableClick);
|
||||||
connect(disableButton, &QPushButton::clicked, this, &NmDemo::onDisableClick);
|
connect(disableButton, &QPushButton::clicked, this, &NmDemo::onDisableClick);
|
||||||
|
connect(addButton, &QPushButton::clicked, this, &NmDemo::onAddClick);
|
||||||
|
|
||||||
//连接变化
|
//连接变化
|
||||||
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);
|
connect(m_wnr, &KyWirelessNetResource::bssidChange, this ,&NmDemo::onBssidChange);
|
||||||
|
@ -145,10 +158,11 @@ void NmDemo::initConnect()
|
||||||
connect(m_wnr, &KyWirelessNetResource::wifiNetworkAdd, this ,&NmDemo::onWifiNetworkAdd);
|
connect(m_wnr, &KyWirelessNetResource::wifiNetworkAdd, this ,&NmDemo::onWifiNetworkAdd);
|
||||||
connect(m_wnr, &KyWirelessNetResource::wifiNetworkRemove, this ,&NmDemo::onWifiNetworkRemove);
|
connect(m_wnr, &KyWirelessNetResource::wifiNetworkRemove, this ,&NmDemo::onWifiNetworkRemove);
|
||||||
|
|
||||||
//connect(m_networkResourceInstance, &KyNetworkResourceManager::activeConnectionAdd, this, &NmDemo::onActiveConnectionAdd);
|
connect(m_acr, &KyActiveConnectResourse::stateChangeReason, this, [this](QString uuid,
|
||||||
//connect(m_networkResourceInstance, &KyNetworkResourceManager::activeConnectionUpdate, this, &NmDemo::onActiveConnectionUpdate);
|
NetworkManager::ActiveConnection::State state,
|
||||||
//connect(m_networkResourceInstance, &KyNetworkResourceManager::activeConnectionRemove, this, &NmDemo::onActiveConnectionRemove);
|
NetworkManager::ActiveConnection::Reason reason){
|
||||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::activeConnectionsReset, this, &NmDemo::onActiveConnectionsReset);
|
appendDebugLog(QString("%1 %2 %3").arg(uuid).arg(state).arg(reason));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void NmDemo::initTimer()
|
void NmDemo::initTimer()
|
||||||
|
@ -163,9 +177,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)
|
void NmDemo::onBssidChange(QString devIface, QString ssid, QString bssid)
|
||||||
|
@ -245,48 +259,48 @@ void NmDemo::onConnectClicked()
|
||||||
}
|
}
|
||||||
if (isEnterPirse)
|
if (isEnterPirse)
|
||||||
{
|
{
|
||||||
|
qDebug() <<"EnterPrice";
|
||||||
|
return;
|
||||||
if(!isNew)
|
if(!isNew)
|
||||||
{
|
{
|
||||||
KyEapMethodPeapInfo a;
|
KyEapMethodPeapInfo a;
|
||||||
a.connName = ssid;
|
a.phase2AuthMethod = KyAuthMethodMschapv2;
|
||||||
a.phase2AuthMethod = AuthEapMethodPeapMschapv2;
|
|
||||||
a.userName = "steve";
|
a.userName = "steve";
|
||||||
a.userPWD = "testing";
|
a.userPWD = "testing";
|
||||||
appendDebugLog("modifyEnterPriseInfoPeap");
|
appendDebugLog("modifyEnterPriseInfoPeap");
|
||||||
if (!(m_wnr->modifyEnterPriseInfoPeap(uuid,a)))
|
|
||||||
{
|
|
||||||
appendDebugLog("modifyEnterPriseInfoPeap fail");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
appendDebugLog("activeWirelessConnect...");
|
appendDebugLog("activeWirelessConnect...");
|
||||||
m_wco->activeWirelessConnect(devIface,uuid);
|
m_wco->activeWirelessConnect(devIface,uuid);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
KyEapMethodTtlsInfo c;
|
KyEapMethodTtlsInfo c;
|
||||||
c.connName = ssid;
|
|
||||||
c.authType = AUTH_NO_EAP;
|
c.authType = AUTH_NO_EAP;
|
||||||
c.authNoEapMethod = AuthMethodTtlsMschapv2;
|
c.authNoEapMethod = KyAuthMethodMschapv2;
|
||||||
c.userName = "steve";
|
c.userName = "steve";
|
||||||
c.userPWD = "testing";
|
c.userPWD = "testing";
|
||||||
appendDebugLog("addAndActiveWirelessEnterPriseTtlsConnect...");
|
appendDebugLog("addAndActiveWirelessEnterPriseTtlsConnect...");
|
||||||
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect";
|
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect";
|
||||||
m_wco->addAndActiveWirelessEnterPriseTtlsConnect(c, devIface, isHidden, true, 0);
|
// m_wco->addAndActiveWirelessEnterPriseTtlsConnect(c, devIface, isHidden, true, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KySecuType secuType = WPA_AND_WPA2_PERSONAL;
|
|
||||||
if (isHidden)
|
|
||||||
{
|
|
||||||
appendDebugLog("addAndActiveWirelessHiddenConnect...");
|
|
||||||
m_wco->addAndActiveWirelessHiddenConnect(secuType, ssid, devIface, pwd, true, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isNew)
|
if (isNew)
|
||||||
{
|
{
|
||||||
appendDebugLog("addAndActiveWirelessConnect...");
|
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_type = WpaPsk;
|
||||||
|
|
||||||
|
|
||||||
|
m_wco->addAndActiveWirelessConnect(devIface,a, isHidden);
|
||||||
} else {
|
} else {
|
||||||
appendDebugLog("activeWirelessConnectWithPwd...");
|
// NetworkManager::Setting::SecretFlags c;
|
||||||
|
// m_wco->getConnSecretFlags(uuid, c);
|
||||||
|
// appendDebugLog(QString("%1").arg(c));
|
||||||
|
appendDebugLog("activeWirelessConnect...");
|
||||||
m_wco->activeWirelessConnect(devIface,uuid);
|
m_wco->activeWirelessConnect(devIface,uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,13 +333,117 @@ void NmDemo::onDisConnectClicked()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
appendDebugLog("deActiveWirelessConnect " + ssid);
|
appendDebugLog("deActiveWirelessConnect " + ssid);
|
||||||
m_wco->deActiveWirelessConnect(uuid);
|
m_wco->deActivateWirelessConnection(ssid, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NmDemo::onModifyClicked()
|
void NmDemo::onModifyClicked()
|
||||||
{
|
{
|
||||||
appendDebugLog("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()
|
void NmDemo::onEnableClick()
|
||||||
|
@ -340,6 +458,29 @@ void NmDemo::onDisableClick()
|
||||||
m_wco->setWirelessEnabled(false);
|
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)
|
void NmDemo::appendDebugLog(QString log)
|
||||||
{
|
{
|
||||||
QTimeZone timeZone(QString::fromLatin1(QTimeZone::systemTimeZoneId()).toLatin1());
|
QTimeZone timeZone(QString::fromLatin1(QTimeZone::systemTimeZoneId()).toLatin1());
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
#include "backend/dbus-interface/kylinnetworkresourcemanager.h"
|
#include "backend/dbus-interface/kylinnetworkresourcemanager.h"
|
||||||
#include "backend/dbus-interface/kywirelessconnectoperation.h"
|
#include "backend/dbus-interface/kywirelessconnectoperation.h"
|
||||||
#include "backend/dbus-interface/kywirelessnetresource.h"
|
#include "backend/dbus-interface/kywirelessnetresource.h"
|
||||||
|
#include "backend/dbus-interface/kylinactiveconnectresource.h"
|
||||||
|
#include "backend/dbus-interface/kylinconnectresource.h"
|
||||||
|
#include "backend/dbus-interface/kylinactiveconnectresource.h"
|
||||||
|
|
||||||
class NmDemo : public QDialog
|
class NmDemo : public QDialog
|
||||||
{
|
{
|
||||||
|
@ -23,6 +26,7 @@ public:
|
||||||
QPushButton *modifyButton;
|
QPushButton *modifyButton;
|
||||||
QPushButton *enableButton;
|
QPushButton *enableButton;
|
||||||
QPushButton *disableButton;
|
QPushButton *disableButton;
|
||||||
|
QPushButton *addButton;
|
||||||
QTextEdit *wifiList;
|
QTextEdit *wifiList;
|
||||||
QTextEdit *debugLog;
|
QTextEdit *debugLog;
|
||||||
QLabel *ssidLabel;
|
QLabel *ssidLabel;
|
||||||
|
@ -37,6 +41,8 @@ public:
|
||||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||||
KyWirelessConnectOperation *m_wco;
|
KyWirelessConnectOperation *m_wco;
|
||||||
KyWirelessNetResource *m_wnr;
|
KyWirelessNetResource *m_wnr;
|
||||||
|
KyActiveConnectResourse *m_acr;
|
||||||
|
KyConnectResourse *m_cr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer *m_timer;
|
QTimer *m_timer;
|
||||||
|
@ -52,8 +58,10 @@ private:
|
||||||
void appendDebugLog(QString);
|
void appendDebugLog(QString);
|
||||||
void getWifiList();
|
void getWifiList();
|
||||||
|
|
||||||
|
void showIpv4Ipv6DnsInfo(const QString &uuid, KyConnectSetting &sett);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onWcoSignals(QString, QString, QString);
|
void onWcoSignals(QString);
|
||||||
void onBssidChange(QString, QString, QString);
|
void onBssidChange(QString, QString, QString);
|
||||||
void onSecuTypeChange(QString, QString, QString);
|
void onSecuTypeChange(QString, QString, QString);
|
||||||
void onSignalStrengthChange(QString, QString, int);
|
void onSignalStrengthChange(QString, QString, int);
|
||||||
|
@ -68,6 +76,7 @@ public slots:
|
||||||
void onModifyClicked();
|
void onModifyClicked();
|
||||||
void onEnableClick();
|
void onEnableClick();
|
||||||
void onDisableClick();
|
void onDisableClick();
|
||||||
|
void onAddClick();
|
||||||
|
|
||||||
void onActiveConnectionAdd(NetworkManager::ActiveConnection::Ptr conn);
|
void onActiveConnectionAdd(NetworkManager::ActiveConnection::Ptr conn);
|
||||||
void onActiveConnectionUpdate(NetworkManager::ActiveConnection * conn);
|
void onActiveConnectionUpdate(NetworkManager::ActiveConnection * conn);
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
#include "lanpage.h"
|
||||||
|
|
||||||
|
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||||
|
#define MAIN_LAYOUT_SPACING 0
|
||||||
|
#define TITLE_FRAME_HEIGHT 52
|
||||||
|
#define TITLE_LAYOUT_MARGINS 24,0,0,0
|
||||||
|
#define LAN_LAYOUT_MARGINS 8,8,8,8
|
||||||
|
#define LAN_LAYOUT_SPACING 8
|
||||||
|
#define LAN_LIST_SPACING 2
|
||||||
|
#define TEXT_MARGINS 16,0,0,0
|
||||||
|
//#define SCROLL_AREA_HEIGHT 200
|
||||||
|
#define SETTINGS_LAYOUT_MARGINS 24,16,24,16
|
||||||
|
|
||||||
|
LanPage::LanPage(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
initUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
LanPage::~LanPage()
|
||||||
|
{
|
||||||
|
delete m_titleDivider;
|
||||||
|
delete m_activatedLanDivider;
|
||||||
|
delete m_inactivatedLanDivider;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LanPage::initUI()
|
||||||
|
{
|
||||||
|
m_mainLayout = new QVBoxLayout(this);
|
||||||
|
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||||
|
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
|
||||||
|
this->setLayout(m_mainLayout);
|
||||||
|
|
||||||
|
m_titleFrame = new QFrame(this);
|
||||||
|
m_titleFrame->setFixedHeight(TITLE_FRAME_HEIGHT);
|
||||||
|
m_titleLayout = new QHBoxLayout(m_titleFrame);
|
||||||
|
m_titleLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
|
||||||
|
m_titleLabel = new QLabel(m_titleFrame);
|
||||||
|
m_titleLabel->setText(tr("LAN"));
|
||||||
|
m_lanSwitch = new SwitchButton(m_titleFrame);
|
||||||
|
m_titleLayout->addWidget(m_titleLabel);
|
||||||
|
m_titleLayout->addStretch();
|
||||||
|
m_titleLayout->addWidget(m_lanSwitch);
|
||||||
|
m_titleDivider = new Divider(this);
|
||||||
|
|
||||||
|
m_activatedLanFrame = new QFrame(this);
|
||||||
|
m_activatedLanLayout = new QVBoxLayout(m_activatedLanFrame);
|
||||||
|
m_activatedLanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
|
||||||
|
m_activatedLanLayout->setSpacing(LAN_LAYOUT_SPACING);
|
||||||
|
m_activatedLanLabel = new QLabel(m_activatedLanFrame);
|
||||||
|
m_activatedLanLabel->setContentsMargins(TEXT_MARGINS);
|
||||||
|
m_activatedLanLabel->setText(tr("Activated LAN"));
|
||||||
|
m_activatedLanListWidget = new QListWidget(m_activatedLanFrame);
|
||||||
|
m_activatedLanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||||
|
m_activatedLanListWidget->setSpacing(LAN_LIST_SPACING);
|
||||||
|
m_activatedLanLayout->addWidget(m_activatedLanLabel);
|
||||||
|
m_activatedLanLayout->addWidget(m_activatedLanListWidget);
|
||||||
|
m_activatedLanDivider = new Divider(this);
|
||||||
|
|
||||||
|
m_inactivatedLanFrame = new QFrame(this);
|
||||||
|
m_inactivatedLanLayout = new QVBoxLayout(m_inactivatedLanFrame);
|
||||||
|
m_inactivatedLanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
|
||||||
|
m_inactivatedLanLayout->setSpacing(LAN_LAYOUT_SPACING);
|
||||||
|
m_inactivatedLanFrame->setLayout(m_inactivatedLanLayout);
|
||||||
|
m_inactivatedLanLabel = new QLabel(m_inactivatedLanFrame);
|
||||||
|
m_inactivatedLanLabel->setContentsMargins(TEXT_MARGINS);
|
||||||
|
m_inactivatedLanLabel->setText(tr("Inactivated LAN"));
|
||||||
|
m_inactivatedLanListArea = new QScrollArea(m_inactivatedLanFrame);
|
||||||
|
m_inactivatedLanListWidget = new QListWidget(m_inactivatedLanListArea);
|
||||||
|
m_inactivatedLanListArea->setWidget(m_inactivatedLanListWidget);
|
||||||
|
m_inactivatedLanListArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
m_inactivatedLanListArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
|
m_inactivatedLanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||||
|
m_inactivatedLanListWidget->setSpacing(LAN_LIST_SPACING);
|
||||||
|
// m_inactivated_lan_list_area->setFixedHeight(SCROLL_AREA_HEIGHT);
|
||||||
|
m_inactivatedLanLayout->addWidget(m_inactivatedLanLabel);
|
||||||
|
m_inactivatedLanLayout->addWidget(m_inactivatedLanListArea);
|
||||||
|
m_inactivatedLanDivider = new Divider(this);
|
||||||
|
|
||||||
|
m_settingsFrame = new QFrame(this);
|
||||||
|
m_settingsLayout = new QHBoxLayout(m_settingsFrame);
|
||||||
|
m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS);
|
||||||
|
m_settingsLabel = new QLabel(m_settingsFrame);
|
||||||
|
m_settingsLabel->setText(tr("Settings"));
|
||||||
|
m_settingsLayout->addWidget(m_settingsLabel);
|
||||||
|
m_settingsFrame->setLayout(m_settingsLayout);
|
||||||
|
|
||||||
|
m_mainLayout->addWidget(m_titleFrame);
|
||||||
|
m_mainLayout->addWidget(m_titleDivider);
|
||||||
|
m_mainLayout->addWidget(m_activatedLanFrame);
|
||||||
|
m_mainLayout->addWidget(m_activatedLanDivider);
|
||||||
|
m_mainLayout->addWidget(m_inactivatedLanFrame);
|
||||||
|
m_mainLayout->addWidget(m_inactivatedLanDivider);
|
||||||
|
m_mainLayout->addWidget(m_settingsFrame);
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
#ifndef LANPAGE_H
|
||||||
|
#define LANPAGE_H
|
||||||
|
|
||||||
|
#include "divider.h"
|
||||||
|
#include "switchbutton.h"
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
|
class LanPage : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LanPage(QWidget *parent = nullptr);
|
||||||
|
~LanPage();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initUI();
|
||||||
|
QVBoxLayout * m_mainLayout = nullptr;
|
||||||
|
QFrame * m_titleFrame = nullptr;
|
||||||
|
QHBoxLayout * m_titleLayout = nullptr;
|
||||||
|
QLabel * m_titleLabel = nullptr;
|
||||||
|
SwitchButton * m_lanSwitch = nullptr;
|
||||||
|
Divider * m_titleDivider = nullptr;
|
||||||
|
|
||||||
|
QFrame * m_activatedLanFrame = nullptr;
|
||||||
|
QVBoxLayout * m_activatedLanLayout = nullptr;
|
||||||
|
QLabel * m_activatedLanLabel = nullptr;
|
||||||
|
QListWidget * m_activatedLanListWidget = nullptr;
|
||||||
|
Divider * m_activatedLanDivider = nullptr;
|
||||||
|
|
||||||
|
QFrame * m_inactivatedLanFrame = nullptr;
|
||||||
|
QVBoxLayout * m_inactivatedLanLayout = nullptr;
|
||||||
|
QLabel * m_inactivatedLanLabel = nullptr;
|
||||||
|
QScrollArea * m_inactivatedLanListArea = nullptr;
|
||||||
|
QListWidget * m_inactivatedLanListWidget = nullptr;
|
||||||
|
Divider * m_inactivatedLanDivider = nullptr;
|
||||||
|
|
||||||
|
QFrame * m_settingsFrame = nullptr;
|
||||||
|
QHBoxLayout * m_settingsLayout = nullptr;
|
||||||
|
QLabel * m_settingsLabel = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LANPAGE_H
|
|
@ -0,0 +1,10 @@
|
||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/lanpage.h \
|
||||||
|
$$PWD/wlanpage.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/lanpage.cpp \
|
||||||
|
$$PWD/wlanpage.cpp
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
#include "wlanpage.h"
|
||||||
|
#include <QEvent>
|
||||||
|
|
||||||
|
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||||
|
#define MAIN_LAYOUT_SPACING 0
|
||||||
|
#define TITLE_FRAME_HEIGHT 52
|
||||||
|
#define TITLE_LAYOUT_MARGINS 24,0,0,0
|
||||||
|
#define LAN_LAYOUT_MARGINS 8,8,8,8
|
||||||
|
#define LAN_LAYOUT_SPACING 8
|
||||||
|
#define LAN_LIST_SPACING 2
|
||||||
|
#define TEXT_MARGINS 16,0,0,0
|
||||||
|
//#define SCROLL_AREA_HEIGHT 200
|
||||||
|
#define SETTINGS_LAYOUT_MARGINS 24,16,24,16
|
||||||
|
|
||||||
|
WlanPage::WlanPage(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
initUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
WlanPage::~WlanPage()
|
||||||
|
{
|
||||||
|
delete m_titleDivider;
|
||||||
|
delete m_activatedWlanDivider;
|
||||||
|
delete m_inactivatedWlanDivider;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WlanPage::eventFilter(QObject *w, QEvent *e)
|
||||||
|
{
|
||||||
|
if (e->type() == QEvent::MouseButtonPress) {
|
||||||
|
if (w == m_hiddenWlanLabel) {
|
||||||
|
//ZJP_TODO 打开隐藏WiFi添加弹窗
|
||||||
|
} else if (w == m_settingsLabel) {
|
||||||
|
//ZJP_TODO 打开控制面板
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QWidget::eventFilter(w,e);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WlanPage::initUI()
|
||||||
|
{
|
||||||
|
m_mainLayout = new QVBoxLayout(this);
|
||||||
|
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||||
|
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
|
||||||
|
this->setLayout(m_mainLayout);
|
||||||
|
|
||||||
|
m_titleFrame = new QFrame(this);
|
||||||
|
m_titleFrame->setFixedHeight(TITLE_FRAME_HEIGHT);
|
||||||
|
m_titleLayout = new QHBoxLayout(m_titleFrame);
|
||||||
|
m_titleLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
|
||||||
|
m_titleLabel = new QLabel(m_titleFrame);
|
||||||
|
m_titleLabel->setText(tr("WLAN"));
|
||||||
|
m_lanSwitch = new SwitchButton(m_titleFrame);
|
||||||
|
m_titleLayout->addWidget(m_titleLabel);
|
||||||
|
m_titleLayout->addStretch();
|
||||||
|
m_titleLayout->addWidget(m_lanSwitch);
|
||||||
|
m_titleDivider = new Divider(this);
|
||||||
|
|
||||||
|
m_activatedWlanFrame = new QFrame(this);
|
||||||
|
m_activatedWlanLayout = new QVBoxLayout(m_activatedWlanFrame);
|
||||||
|
m_activatedWlanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
|
||||||
|
m_activatedWlanLayout->setSpacing(LAN_LAYOUT_SPACING);
|
||||||
|
m_activatedWlanLabel = new QLabel(m_activatedWlanFrame);
|
||||||
|
m_activatedWlanLabel->setContentsMargins(TEXT_MARGINS);
|
||||||
|
m_activatedWlanLabel->setText(tr("Activated WLAN"));
|
||||||
|
m_activatedWlanListWidget = new QListWidget(m_activatedWlanFrame);
|
||||||
|
m_activatedWlanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||||
|
m_activatedWlanListWidget->setSpacing(LAN_LIST_SPACING);
|
||||||
|
m_activatedWlanLayout->addWidget(m_activatedWlanLabel);
|
||||||
|
m_activatedWlanLayout->addWidget(m_activatedWlanListWidget);
|
||||||
|
m_activatedWlanDivider = new Divider(this);
|
||||||
|
|
||||||
|
m_inactivatedWlanFrame = new QFrame(this);
|
||||||
|
m_inactivatedWlanLayout = new QVBoxLayout(m_inactivatedWlanFrame);
|
||||||
|
m_inactivatedWlanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
|
||||||
|
m_inactivatedWlanLayout->setSpacing(LAN_LAYOUT_SPACING);
|
||||||
|
m_inactivatedWlanFrame->setLayout(m_inactivatedWlanLayout);
|
||||||
|
m_inactivatedWlanLabel = new QLabel(m_inactivatedWlanFrame);
|
||||||
|
m_inactivatedWlanLabel->setContentsMargins(TEXT_MARGINS);
|
||||||
|
m_inactivatedWlanLabel->setText(tr("Inactivated WLAN"));
|
||||||
|
m_inactivatedWlanListArea = new QScrollArea(m_inactivatedWlanFrame);
|
||||||
|
m_inactivatedWlanListArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
m_inactivatedWlanListArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
|
m_inactivatedWlanListAreaCentralWidget = new QFrame(m_inactivatedWlanListArea);
|
||||||
|
m_inactivatedWlanListArea->setWidget(m_inactivatedWlanListAreaCentralWidget);
|
||||||
|
m_inactivatedWlanListAreaLayout = new QVBoxLayout(m_inactivatedWlanListAreaCentralWidget);
|
||||||
|
m_inactivatedWlanListAreaCentralWidget->setLayout(m_inactivatedWlanListAreaLayout);
|
||||||
|
m_inactivatedWlanListAreaLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||||
|
m_inactivatedWlanListWidget = new QListWidget(m_inactivatedWlanListAreaCentralWidget);
|
||||||
|
m_inactivatedWlanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||||
|
m_inactivatedWlanListWidget->setSpacing(LAN_LIST_SPACING);
|
||||||
|
m_hiddenWlanWidget = new QFrame(m_inactivatedWlanListAreaCentralWidget);
|
||||||
|
m_hiddenWlanLayout = new QHBoxLayout(m_hiddenWlanWidget);
|
||||||
|
m_hiddenWlanLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||||
|
m_hiddenWlanLabel = new QLabel(m_hiddenWlanWidget);
|
||||||
|
m_hiddenWlanLabel->setText(tr("More..."));
|
||||||
|
m_hiddenWlanLayout->addWidget(m_hiddenWlanLabel);
|
||||||
|
m_hiddenWlanLayout->addStretch();
|
||||||
|
m_inactivatedWlanListAreaLayout->addWidget(m_inactivatedWlanListWidget);
|
||||||
|
m_inactivatedWlanListAreaLayout->addWidget(m_hiddenWlanWidget);
|
||||||
|
|
||||||
|
// m_inactivated_lan_list_area->setFixedHeight(SCROLL_AREA_HEIGHT);
|
||||||
|
m_inactivatedWlanLayout->addWidget(m_inactivatedWlanLabel);
|
||||||
|
m_inactivatedWlanLayout->addWidget(m_inactivatedWlanListArea);
|
||||||
|
m_inactivatedWlanDivider = new Divider(this);
|
||||||
|
|
||||||
|
m_settingsFrame = new QFrame(this);
|
||||||
|
m_settingsLayout = new QHBoxLayout(m_settingsFrame);
|
||||||
|
m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS);
|
||||||
|
m_settingsLabel = new QLabel(m_settingsFrame);
|
||||||
|
m_settingsLabel->setText(tr("Settings"));
|
||||||
|
m_settingsLayout->addWidget(m_settingsLabel);
|
||||||
|
m_settingsFrame->setLayout(m_settingsLayout);
|
||||||
|
|
||||||
|
m_mainLayout->addWidget(m_titleFrame);
|
||||||
|
m_mainLayout->addWidget(m_titleDivider);
|
||||||
|
m_mainLayout->addWidget(m_activatedWlanFrame);
|
||||||
|
m_mainLayout->addWidget(m_activatedWlanDivider);
|
||||||
|
m_mainLayout->addWidget(m_inactivatedWlanFrame);
|
||||||
|
m_mainLayout->addWidget(m_inactivatedWlanDivider);
|
||||||
|
m_mainLayout->addWidget(m_settingsFrame);
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
#ifndef WLANPAGE_H
|
||||||
|
#define WLANPAGE_H
|
||||||
|
|
||||||
|
#include "divider.h"
|
||||||
|
#include "switchbutton.h"
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QListWidget>
|
||||||
|
|
||||||
|
class WlanPage : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit WlanPage(QWidget *parent = nullptr);
|
||||||
|
~WlanPage();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject *watched, QEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initUI();
|
||||||
|
QVBoxLayout * m_mainLayout = nullptr;
|
||||||
|
QFrame * m_titleFrame = nullptr;
|
||||||
|
QHBoxLayout * m_titleLayout = nullptr;
|
||||||
|
QLabel * m_titleLabel = nullptr;
|
||||||
|
SwitchButton * m_lanSwitch = nullptr;
|
||||||
|
Divider * m_titleDivider = nullptr;
|
||||||
|
|
||||||
|
QFrame * m_activatedWlanFrame = nullptr;
|
||||||
|
QVBoxLayout * m_activatedWlanLayout = nullptr;
|
||||||
|
QLabel *m_activatedWlanLabel = nullptr;
|
||||||
|
QListWidget * m_activatedWlanListWidget = nullptr;
|
||||||
|
Divider * m_activatedWlanDivider = nullptr;
|
||||||
|
|
||||||
|
QFrame * m_inactivatedWlanFrame = nullptr;
|
||||||
|
QVBoxLayout * m_inactivatedWlanLayout = nullptr;
|
||||||
|
QLabel * m_inactivatedWlanLabel = nullptr;
|
||||||
|
QScrollArea * m_inactivatedWlanListArea = nullptr;
|
||||||
|
QFrame * m_inactivatedWlanListAreaCentralWidget = nullptr;
|
||||||
|
QVBoxLayout * m_inactivatedWlanListAreaLayout = nullptr;
|
||||||
|
QListWidget * m_inactivatedWlanListWidget = nullptr;
|
||||||
|
QFrame * m_hiddenWlanWidget = nullptr;
|
||||||
|
QHBoxLayout * m_hiddenWlanLayout = nullptr;
|
||||||
|
QLabel * m_hiddenWlanLabel = nullptr;
|
||||||
|
Divider * m_inactivatedWlanDivider = nullptr;
|
||||||
|
|
||||||
|
QFrame * m_settingsFrame = nullptr;
|
||||||
|
QHBoxLayout * m_settingsLayout = nullptr;
|
||||||
|
QLabel * m_settingsLabel = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // WLANPAGE_H
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include "divider.h"
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
Divider::Divider(QWidget * parent) : QFrame(parent)
|
||||||
|
{
|
||||||
|
this->setFixedHeight(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Divider::paintEvent(QPaintEvent * e)
|
||||||
|
{
|
||||||
|
QPainter p(this);
|
||||||
|
p.save();
|
||||||
|
p.setBrush(this->palette().color(QPalette::Text));
|
||||||
|
p.setPen(Qt::transparent);
|
||||||
|
p.setOpacity(0.3);
|
||||||
|
p.drawRoundedRect(this->rect(), 6, 6);
|
||||||
|
p.restore();
|
||||||
|
return QFrame::paintEvent(e);
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef DIVIDER_H
|
||||||
|
#define DIVIDER_H
|
||||||
|
#include <QFrame>
|
||||||
|
|
||||||
|
class Divider : public QFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Divider(QWidget * parent = nullptr);
|
||||||
|
~Divider() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIVIDER_H
|
|
@ -0,0 +1,30 @@
|
||||||
|
#include "infobutton.h"
|
||||||
|
#include <QEvent>
|
||||||
|
|
||||||
|
InfoButton::InfoButton(QWidget *parent) : QPushButton(parent)
|
||||||
|
{
|
||||||
|
initUI();
|
||||||
|
installEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InfoButton::initUI()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void InfoButton::enterEvent(QEvent *)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void InfoButton::leaveEvent(QEvent *)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InfoButton::eventFilter(QObject *w, QEvent *e)
|
||||||
|
{
|
||||||
|
if(e->type() == QEvent::MouseButtonPress) {
|
||||||
|
}
|
||||||
|
return QPushButton::eventFilter(w, e);
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef INFOBUTTON_H
|
||||||
|
#define INFOBUTTON_H
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
class InfoButton : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit InfoButton(QWidget * parent = nullptr);
|
||||||
|
~InfoButton() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initUI();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void enterEvent(QEvent *event);
|
||||||
|
virtual void leaveEvent(QEvent *event);
|
||||||
|
bool eventFilter(QObject *watched, QEvent *event);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INFOBUTTON_H
|
|
@ -0,0 +1,53 @@
|
||||||
|
#include "netbutton.h"
|
||||||
|
|
||||||
|
NetButton::NetButton(bool isActivated, QWidget *parent) : QPushButton(parent)
|
||||||
|
{
|
||||||
|
connect(this, &NetButton::requestStartLoading, this, &NetButton::onLoadingStarted);
|
||||||
|
connect(this, &NetButton::requestStopLoading, this, &NetButton::onLoadingStopped);
|
||||||
|
m_isActivated = isActivated;
|
||||||
|
this->setAutoFillBackground(false);
|
||||||
|
m_iconLabel = new QLabel(this);
|
||||||
|
m_iconLabel->setScaledContents(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetButton::startLoading()
|
||||||
|
{
|
||||||
|
emit this->requestStartLoading();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetButton::stopLoading()
|
||||||
|
{
|
||||||
|
emit this->requestStopLoading();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetButton::setPressed()
|
||||||
|
{
|
||||||
|
//ZJP_TODO 设置颜色为点击颜色,注意区分已连接/未连接
|
||||||
|
if (m_isActivated)
|
||||||
|
;
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetButton::setReleased()
|
||||||
|
{
|
||||||
|
//ZJP_TODO 设置颜色为未点击颜色,注意区分已连接/未连接
|
||||||
|
if (m_isActivated)
|
||||||
|
;
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetButton::setButtonIcon(QIcon *icon)
|
||||||
|
{
|
||||||
|
if (!icon) { return; }
|
||||||
|
m_iconLabel->setPixmap(icon->pixmap(this->size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetButton::onLoadingStarted()
|
||||||
|
{
|
||||||
|
//ZJP_TODO 开始播放转圈动画
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetButton::onLoadingStopped()
|
||||||
|
{
|
||||||
|
//ZJP_TODO 停止播放转圈动画
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef NETBUTTON_H
|
||||||
|
#define NETBUTTON_H
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QLabel>
|
||||||
|
#define ACTIVATED true
|
||||||
|
#define INACTIVATED false
|
||||||
|
|
||||||
|
class NetButton : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
NetButton(bool isActivated = INACTIVATED, QWidget * parent = nullptr);
|
||||||
|
~NetButton() = default;
|
||||||
|
void startLoading();
|
||||||
|
void stopLoading();
|
||||||
|
void setPressed();
|
||||||
|
void setReleased();
|
||||||
|
void setButtonIcon(QIcon *);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void requestStartLoading();
|
||||||
|
void requestStopLoading();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_isActivated = INACTIVATED;
|
||||||
|
QLabel * m_iconLabel = nullptr;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onLoadingStarted();
|
||||||
|
void onLoadingStopped();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NETBUTTON_H
|
|
@ -1,10 +1,16 @@
|
||||||
INCLUDEPATH += $$PWD
|
INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
$$PWD/divider.h \
|
||||||
|
$$PWD/infobutton.h \
|
||||||
$$PWD/loadingdiv.h \
|
$$PWD/loadingdiv.h \
|
||||||
|
$$PWD/netbutton.h \
|
||||||
$$PWD/switchbutton.h
|
$$PWD/switchbutton.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
$$PWD/divider.cpp \
|
||||||
|
$$PWD/infobutton.cpp \
|
||||||
$$PWD/loadingdiv.cpp \
|
$$PWD/loadingdiv.cpp \
|
||||||
|
$$PWD/netbutton.cpp \
|
||||||
$$PWD/switchbutton.cpp
|
$$PWD/switchbutton.cpp
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
DlgHideWifi::DlgHideWifi(int type, MainWindow *mainWindow, QWidget *parent) :
|
DlgHideWifi::DlgHideWifi(int type, OldMainWindow *mainWindow, QWidget *parent) :
|
||||||
isUsed(type),
|
isUsed(type),
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::DlgHideWifi)
|
ui(new Ui::DlgHideWifi)
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
class MainWindow;
|
class OldMainWindow;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DlgHideWifi;
|
class DlgHideWifi;
|
||||||
|
@ -36,7 +36,7 @@ class DlgHideWifi : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DlgHideWifi(int type, MainWindow *mw = 0, QWidget *parent = 0);
|
explicit DlgHideWifi(int type, OldMainWindow *mw = 0, QWidget *parent = 0);
|
||||||
~DlgHideWifi();
|
~DlgHideWifi();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -67,7 +67,7 @@ signals:
|
||||||
private:
|
private:
|
||||||
Ui::DlgHideWifi *ui;
|
Ui::DlgHideWifi *ui;
|
||||||
int isUsed;//=0 current wifi not used before; >=1 used
|
int isUsed;//=0 current wifi not used before; >=1 used
|
||||||
MainWindow *mw;
|
OldMainWindow *mw;
|
||||||
QString strWifiname;
|
QString strWifiname;
|
||||||
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss;
|
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
DlgHideWifiEapPeap::DlgHideWifiEapPeap(int type, int beUsed, MainWindow *mainWindow, QWidget *parent) :
|
DlgHideWifiEapPeap::DlgHideWifiEapPeap(int type, int beUsed, OldMainWindow *mainWindow, QWidget *parent) :
|
||||||
WepOrWpa(type),
|
WepOrWpa(type),
|
||||||
isUsed(beUsed),
|
isUsed(beUsed),
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
class MainWindow;
|
class OldMainWindow;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DlgHideWifiEapPeap;
|
class DlgHideWifiEapPeap;
|
||||||
|
@ -34,7 +34,7 @@ class DlgHideWifiEapPeap : public QDialog
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//type: 0是动态 WEP, 1是企业wpa, beUsed:是否是之前已经连接过多网络
|
//type: 0是动态 WEP, 1是企业wpa, beUsed:是否是之前已经连接过多网络
|
||||||
explicit DlgHideWifiEapPeap(int type, int beUsed, MainWindow *mw = 0, QWidget *parent = 0);
|
explicit DlgHideWifiEapPeap(int type, int beUsed, OldMainWindow *mw = 0, QWidget *parent = 0);
|
||||||
~DlgHideWifiEapPeap();
|
~DlgHideWifiEapPeap();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -74,7 +74,7 @@ private:
|
||||||
Ui::DlgHideWifiEapPeap *ui;
|
Ui::DlgHideWifiEapPeap *ui;
|
||||||
int WepOrWpa = 0;//0 WEP;1 WPA
|
int WepOrWpa = 0;//0 WEP;1 WPA
|
||||||
int isUsed;//=0 current wifi not used before; >=1 used
|
int isUsed;//=0 current wifi not used before; >=1 used
|
||||||
MainWindow *mw;
|
OldMainWindow *mw;
|
||||||
|
|
||||||
void mousePressEvent(QMouseEvent *event);
|
void mousePressEvent(QMouseEvent *event);
|
||||||
void mouseReleaseEvent(QMouseEvent *event);
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
DlgHideWifiEapTls::DlgHideWifiEapTls(int type, int beUsed, MainWindow *mainWindow, QWidget *parent) :
|
DlgHideWifiEapTls::DlgHideWifiEapTls(int type, int beUsed, OldMainWindow *mainWindow, QWidget *parent) :
|
||||||
WepOrWpa(type),
|
WepOrWpa(type),
|
||||||
isUsed(beUsed),
|
isUsed(beUsed),
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
class MainWindow;
|
class OldMainWindow;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DlgHideWifiEapTls;
|
class DlgHideWifiEapTls;
|
||||||
|
@ -33,7 +33,7 @@ class DlgHideWifiEapTls : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DlgHideWifiEapTls(int type, int beUsed, MainWindow *mw = 0, QWidget *parent = 0);
|
explicit DlgHideWifiEapTls(int type, int beUsed, OldMainWindow *mw = 0, QWidget *parent = 0);
|
||||||
~DlgHideWifiEapTls();
|
~DlgHideWifiEapTls();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -77,7 +77,7 @@ private:
|
||||||
Ui::DlgHideWifiEapTls *ui;
|
Ui::DlgHideWifiEapTls *ui;
|
||||||
int WepOrWpa = 0;//0 WEP;1WPA
|
int WepOrWpa = 0;//0 WEP;1WPA
|
||||||
int isUsed;//=0 current wifi not used before; >=1 used
|
int isUsed;//=0 current wifi not used before; >=1 used
|
||||||
MainWindow *mw;
|
OldMainWindow *mw;
|
||||||
|
|
||||||
void mousePressEvent(QMouseEvent *event);
|
void mousePressEvent(QMouseEvent *event);
|
||||||
void mouseReleaseEvent(QMouseEvent *event);
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
|
|
||||||
DlgHideWifiWpa::DlgHideWifiWpa(int type, MainWindow *mainWindow, QWidget *parent) :
|
DlgHideWifiWpa::DlgHideWifiWpa(int type, OldMainWindow *mainWindow, QWidget *parent) :
|
||||||
isUsed(type),
|
isUsed(type),
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::DlgHideWifiWpa)
|
ui(new Ui::DlgHideWifiWpa)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
class MainWindow;
|
class OldMainWindow;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class DlgHideWifiWpa;
|
class DlgHideWifiWpa;
|
||||||
|
@ -35,7 +35,7 @@ class DlgHideWifiWpa : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DlgHideWifiWpa(int type, MainWindow *mw = 0, QWidget *parent = 0);
|
explicit DlgHideWifiWpa(int type, OldMainWindow *mw = 0, QWidget *parent = 0);
|
||||||
~DlgHideWifiWpa();
|
~DlgHideWifiWpa();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -74,7 +74,7 @@ signals:
|
||||||
private:
|
private:
|
||||||
Ui::DlgHideWifiWpa *ui;
|
Ui::DlgHideWifiWpa *ui;
|
||||||
int isUsed;//=0 current wifi not used before; >=1 used
|
int isUsed;//=0 current wifi not used before; >=1 used
|
||||||
MainWindow *mw;
|
OldMainWindow *mw;
|
||||||
QString strWifiname;
|
QString strWifiname;
|
||||||
QString strWifiPassword;
|
QString strWifiPassword;
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ void UpConnThread::run() {
|
||||||
emit connRes(res);
|
emit connRes(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
WpaWifiDialog::WpaWifiDialog(QWidget *parent, MainWindow *mainWindow, QString conname) :
|
WpaWifiDialog::WpaWifiDialog(QWidget *parent, OldMainWindow *mainWindow, QString conname) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::WpaWifiDialog)
|
ui(new Ui::WpaWifiDialog)
|
||||||
{
|
{
|
||||||
|
@ -99,7 +99,7 @@ WpaWifiDialog::WpaWifiDialog(QWidget *parent, MainWindow *mainWindow, QString co
|
||||||
checkConnectBtnIsEnabled();
|
checkConnectBtnIsEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
WpaWifiDialog::WpaWifiDialog(QWidget *parent, MainWindow *mw, WifiConfig *wifiConfig)
|
WpaWifiDialog::WpaWifiDialog(QWidget *parent, OldMainWindow *mw, WifiConfig *wifiConfig)
|
||||||
{
|
{
|
||||||
if (wifiConfig) {
|
if (wifiConfig) {
|
||||||
m_wifiConfig = wifiConfig;
|
m_wifiConfig = wifiConfig;
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
#define WINDOW_HEIGHT_TLP 670
|
#define WINDOW_HEIGHT_TLP 670
|
||||||
#define WINDOW_HEIGHT_ELSE 360
|
#define WINDOW_HEIGHT_ELSE 360
|
||||||
|
|
||||||
class MainWindow;
|
class OldMainWindow;
|
||||||
|
|
||||||
typedef QList<QObject*> QObjectList;
|
typedef QList<QObject*> QObjectList;
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ class WpaWifiDialog : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WpaWifiDialog(QWidget *parent = nullptr, MainWindow *mw = 0, QString conname = 0);
|
explicit WpaWifiDialog(QWidget *parent = nullptr, OldMainWindow *mw = 0, QString conname = 0);
|
||||||
explicit WpaWifiDialog(QWidget *parent = nullptr, MainWindow *mw = 0, WifiConfig *wifiConfig = nullptr);
|
explicit WpaWifiDialog(QWidget *parent = nullptr, OldMainWindow *mw = 0, WifiConfig *wifiConfig = nullptr);
|
||||||
~WpaWifiDialog();
|
~WpaWifiDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -133,7 +133,7 @@ private:
|
||||||
QStringList user_list;
|
QStringList user_list;
|
||||||
QString key_mgmt = "wpa-eap";
|
QString key_mgmt = "wpa-eap";
|
||||||
|
|
||||||
MainWindow *mw;
|
OldMainWindow *mw;
|
||||||
QObjectList m_frameList;
|
QObjectList m_frameList;
|
||||||
|
|
||||||
void setEditorEnable(bool is_checking); //设置是否禁用输入
|
void setEditorEnable(bool is_checking); //设置是否禁用输入
|
||||||
|
|
|
@ -0,0 +1,210 @@
|
||||||
|
/*
|
||||||
|
* KWin Style UKUI
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: Yue Lan <lanyue@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "xatom-helper.h"
|
||||||
|
#include <limits.h>
|
||||||
|
#include <QX11Info>
|
||||||
|
#include <X11/X.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
|
static XAtomHelper *global_instance = nullptr;
|
||||||
|
|
||||||
|
XAtomHelper *XAtomHelper::getInstance()
|
||||||
|
{
|
||||||
|
if(!global_instance)
|
||||||
|
global_instance = new XAtomHelper;
|
||||||
|
return global_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool XAtomHelper::isFrameLessWindow(int winId)
|
||||||
|
{
|
||||||
|
auto hints = getInstance()->getWindowMotifHint(winId);
|
||||||
|
if(hints.flags == MWM_HINTS_DECORATIONS && hints.functions == 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool XAtomHelper::isWindowDecorateBorderOnly(int winId)
|
||||||
|
{
|
||||||
|
return isWindowMotifHintDecorateBorderOnly(getInstance()->getWindowMotifHint(winId));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool XAtomHelper::isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint) {
|
||||||
|
bool isDeco = false;
|
||||||
|
if(hint.flags & MWM_HINTS_DECORATIONS && hint.flags != MWM_HINTS_DECORATIONS) {
|
||||||
|
if(hint.decorations == MWM_DECOR_BORDER)
|
||||||
|
isDeco = true;
|
||||||
|
}
|
||||||
|
return isDeco;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool XAtomHelper::isUKUICsdSupported()
|
||||||
|
{
|
||||||
|
// fixme:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool XAtomHelper::isUKUIDecorationWindow(int winId)
|
||||||
|
{
|
||||||
|
if(m_ukuiDecorationAtion == None)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Atom type;
|
||||||
|
int format;
|
||||||
|
ulong nitems;
|
||||||
|
ulong bytes_after;
|
||||||
|
uchar *data;
|
||||||
|
|
||||||
|
bool isUKUIDecoration = false;
|
||||||
|
|
||||||
|
XGetWindowProperty(QX11Info::display(), winId, m_ukuiDecorationAtion,
|
||||||
|
0, LONG_MAX, false,
|
||||||
|
m_ukuiDecorationAtion, &type,
|
||||||
|
&format, &nitems,
|
||||||
|
&bytes_after, &data);
|
||||||
|
|
||||||
|
if(type == m_ukuiDecorationAtion) {
|
||||||
|
if(nitems == 1) {
|
||||||
|
isUKUIDecoration = data[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isUKUIDecoration;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnityCorners XAtomHelper::getWindowBorderRadius(int winId)
|
||||||
|
{
|
||||||
|
UnityCorners corners;
|
||||||
|
|
||||||
|
Atom type;
|
||||||
|
int format;
|
||||||
|
ulong nitems;
|
||||||
|
ulong bytes_after;
|
||||||
|
uchar *data;
|
||||||
|
|
||||||
|
if(m_unityBorderRadiusAtom != None) {
|
||||||
|
XGetWindowProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom,
|
||||||
|
0, LONG_MAX, false,
|
||||||
|
XA_CARDINAL, &type,
|
||||||
|
&format, &nitems,
|
||||||
|
&bytes_after, &data);
|
||||||
|
|
||||||
|
if(type == XA_CARDINAL) {
|
||||||
|
if(nitems == 4) {
|
||||||
|
corners.topLeft = static_cast<ulong>(data[0]);
|
||||||
|
corners.topRight = static_cast<ulong>(data[1 * sizeof(ulong)]);
|
||||||
|
corners.bottomLeft = static_cast<ulong>(data[2 * sizeof(ulong)]);
|
||||||
|
corners.bottomRight = static_cast<ulong>(data[3 * sizeof(ulong)]);
|
||||||
|
}
|
||||||
|
XFree(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return corners;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XAtomHelper::setWindowBorderRadius(int winId, const UnityCorners &data)
|
||||||
|
{
|
||||||
|
if(m_unityBorderRadiusAtom == None)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ulong corners[4] = {data.topLeft, data.topRight, data.bottomLeft, data.bottomRight};
|
||||||
|
|
||||||
|
XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL,
|
||||||
|
32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof(corners) / sizeof(corners[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void XAtomHelper::setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight)
|
||||||
|
{
|
||||||
|
if(m_unityBorderRadiusAtom == None)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ulong corners[4] = {(ulong)topLeft, (ulong)topRight, (ulong)bottomLeft, (ulong)bottomRight};
|
||||||
|
|
||||||
|
XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL,
|
||||||
|
32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof(corners) / sizeof(corners[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void XAtomHelper::setUKUIDecoraiontHint(int winId, bool set)
|
||||||
|
{
|
||||||
|
if(m_ukuiDecorationAtion == None)
|
||||||
|
return;
|
||||||
|
|
||||||
|
XChangeProperty(QX11Info::display(), winId, m_ukuiDecorationAtion, m_ukuiDecorationAtion, 32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &set, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void XAtomHelper::setWindowMotifHint(int winId, const MotifWmHints &hints)
|
||||||
|
{
|
||||||
|
if(m_unityBorderRadiusAtom == None)
|
||||||
|
return;
|
||||||
|
|
||||||
|
XChangeProperty(QX11Info::display(), winId, m_motifWMHintsAtom, m_motifWMHintsAtom,
|
||||||
|
32, XCB_PROP_MODE_REPLACE, (const unsigned char *)&hints, sizeof(MotifWmHints) / sizeof(ulong));
|
||||||
|
}
|
||||||
|
|
||||||
|
MotifWmHints XAtomHelper::getWindowMotifHint(int winId)
|
||||||
|
{
|
||||||
|
MotifWmHints hints;
|
||||||
|
|
||||||
|
if(m_unityBorderRadiusAtom == None)
|
||||||
|
return hints;
|
||||||
|
|
||||||
|
uchar *data;
|
||||||
|
Atom type;
|
||||||
|
int format;
|
||||||
|
ulong nitems;
|
||||||
|
ulong bytes_after;
|
||||||
|
|
||||||
|
XGetWindowProperty(QX11Info::display(), winId, m_motifWMHintsAtom,
|
||||||
|
0, sizeof(MotifWmHints) / sizeof(long), false, AnyPropertyType, &type,
|
||||||
|
&format, &nitems, &bytes_after, &data);
|
||||||
|
|
||||||
|
if(type == None) {
|
||||||
|
return hints;
|
||||||
|
} else {
|
||||||
|
hints = *(MotifWmHints *)data;
|
||||||
|
XFree(data);
|
||||||
|
}
|
||||||
|
return hints;
|
||||||
|
}
|
||||||
|
|
||||||
|
XAtomHelper::XAtomHelper(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
if(!QX11Info::isPlatformX11())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_motifWMHintsAtom = XInternAtom(QX11Info::display(), "_MOTIF_WM_HINTS", true);
|
||||||
|
m_unityBorderRadiusAtom = XInternAtom(QX11Info::display(), "_UNITY_GTK_BORDER_RADIUS", false);
|
||||||
|
m_ukuiDecorationAtion = XInternAtom(QX11Info::display(), "_KWIN_UKUI_DECORAION", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Atom XAtomHelper::registerUKUICsdNetWmSupportAtom()
|
||||||
|
{
|
||||||
|
// fixme:
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XAtomHelper::unregisterUKUICsdNetWmSupportAtom()
|
||||||
|
{
|
||||||
|
// fixme:
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* KWin Style UKUI
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: Yue Lan <lanyue@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XATOMHELPER_H
|
||||||
|
#define XATOMHELPER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <NETWM>
|
||||||
|
|
||||||
|
struct UnityCorners {
|
||||||
|
ulong topLeft = 0;
|
||||||
|
ulong topRight = 0;
|
||||||
|
ulong bottomLeft = 0;
|
||||||
|
ulong bottomRight = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ulong flags = 0;
|
||||||
|
ulong functions = 0;
|
||||||
|
ulong decorations = 0;
|
||||||
|
long input_mode = 0;
|
||||||
|
ulong status = 0;
|
||||||
|
} MotifWmHints, MwmHints;
|
||||||
|
|
||||||
|
#define MWM_HINTS_FUNCTIONS (1L << 0)
|
||||||
|
#define MWM_HINTS_DECORATIONS (1L << 1)
|
||||||
|
#define MWM_HINTS_INPUT_MODE (1L << 2)
|
||||||
|
#define MWM_HINTS_STATUS (1L << 3)
|
||||||
|
|
||||||
|
#define MWM_FUNC_ALL (1L << 0)
|
||||||
|
#define MWM_FUNC_RESIZE (1L << 1)
|
||||||
|
#define MWM_FUNC_MOVE (1L << 2)
|
||||||
|
#define MWM_FUNC_MINIMIZE (1L << 3)
|
||||||
|
#define MWM_FUNC_MAXIMIZE (1L << 4)
|
||||||
|
#define MWM_FUNC_CLOSE (1L << 5)
|
||||||
|
|
||||||
|
#define MWM_DECOR_ALL (1L << 0)
|
||||||
|
#define MWM_DECOR_BORDER (1L << 1)
|
||||||
|
#define MWM_DECOR_RESIZEH (1L << 2)
|
||||||
|
#define MWM_DECOR_TITLE (1L << 3)
|
||||||
|
#define MWM_DECOR_MENU (1L << 4)
|
||||||
|
#define MWM_DECOR_MINIMIZE (1L << 5)
|
||||||
|
#define MWM_DECOR_MAXIMIZE (1L << 6)
|
||||||
|
|
||||||
|
#define MWM_INPUT_MODELESS 0
|
||||||
|
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
|
||||||
|
#define MWM_INPUT_SYSTEM_MODAL 2
|
||||||
|
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
|
||||||
|
#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
|
||||||
|
|
||||||
|
#define MWM_TEAROFF_WINDOW (1L<<0)
|
||||||
|
|
||||||
|
namespace UKUI {
|
||||||
|
class Decoration;
|
||||||
|
}
|
||||||
|
|
||||||
|
class XAtomHelper : public QObject
|
||||||
|
{
|
||||||
|
// friend class UKUI::Decoration;
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
static XAtomHelper *getInstance();
|
||||||
|
|
||||||
|
static bool isFrameLessWindow(int winId);
|
||||||
|
|
||||||
|
static bool isWindowDecorateBorderOnly(int winId);
|
||||||
|
static bool isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint);
|
||||||
|
bool isUKUICsdSupported();
|
||||||
|
bool isUKUIDecorationWindow(int winId);
|
||||||
|
|
||||||
|
UnityCorners getWindowBorderRadius(int winId);
|
||||||
|
void setWindowBorderRadius(int winId, const UnityCorners &data);
|
||||||
|
void setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight);
|
||||||
|
void setUKUIDecoraiontHint(int winId, bool set = true);
|
||||||
|
|
||||||
|
void setWindowMotifHint(int winId, const MotifWmHints &hints);
|
||||||
|
MotifWmHints getWindowMotifHint(int winId);
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit XAtomHelper(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
Atom registerUKUICsdNetWmSupportAtom();
|
||||||
|
void unregisterUKUICsdNetWmSupportAtom();
|
||||||
|
|
||||||
|
Atom m_motifWMHintsAtom = None;
|
||||||
|
Atom m_unityBorderRadiusAtom = None;
|
||||||
|
Atom m_ukuiDecorationAtion = None;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // XATOMHELPER_H
|
|
@ -0,0 +1,7 @@
|
||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/xatom-helper.h \
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/xatom-helper.cpp \
|
|
@ -15,4 +15,4 @@ Type=Application
|
||||||
OnlyShowIn=UKUI
|
OnlyShowIn=UKUI
|
||||||
X-UKUI-AutoRestart=true
|
X-UKUI-AutoRestart=true
|
||||||
NoDisplay=true
|
NoDisplay=true
|
||||||
X-UKUI-Autostart-Phase=Desktop
|
X-UKUI-Autostart-Phase=Application
|
||||||
|
|
38
src/main.cpp
38
src/main.cpp
|
@ -16,19 +16,21 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mainwindow.h"
|
//#include "mainwindow.h"
|
||||||
|
#include "new-mainwindow.h" //ZJP_TODO 载入新的主窗口
|
||||||
#include "ksimplenm.h"
|
#include "ksimplenm.h"
|
||||||
#include "kylin-network-interface.h"
|
#include "kylin-network-interface.h"
|
||||||
#include "wireless-security/dlghidewifi.h"
|
#include "wireless-security/dlghidewifi.h"
|
||||||
#include "dbusadaptor.h"
|
#include "dbusadaptor.h"
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
//#include <QApplication>
|
|
||||||
#include "qt-single-application.h"
|
#include "qt-single-application.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
|
#include "xatom-helper.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LOG_IDENT "ukui_kylin_nm"
|
#define LOG_IDENT "ukui_kylin_nm"
|
||||||
|
|
||||||
|
@ -97,13 +99,6 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
qDebug()<<"Kylin Network Manager Is Already Launched";
|
qDebug()<<"Kylin Network Manager Is Already Launched";
|
||||||
|
|
||||||
int loopNum = 0;
|
|
||||||
while (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
|
||||||
if (loopNum == 15) return 1;
|
|
||||||
qDebug()<<"I couldn't detect any system tray on this system now";
|
|
||||||
loopNum += 1;
|
|
||||||
sleep(1);
|
|
||||||
}
|
|
||||||
QApplication::setQuitOnLastWindowClosed(false);
|
QApplication::setQuitOnLastWindowClosed(false);
|
||||||
|
|
||||||
// Internationalization
|
// Internationalization
|
||||||
|
@ -111,7 +106,6 @@ int main(int argc, char *argv[])
|
||||||
QTranslator trans_global;
|
QTranslator trans_global;
|
||||||
if (locale == "zh_CN") {
|
if (locale == "zh_CN") {
|
||||||
trans_global.load(":/translations/kylin-nm_zh_CN.qm");
|
trans_global.load(":/translations/kylin-nm_zh_CN.qm");
|
||||||
//trans_global.load(":/translations/kylin-nm_bo.qm");
|
|
||||||
a.installTranslator(&trans_global);
|
a.installTranslator(&trans_global);
|
||||||
}
|
}
|
||||||
if (locale == "tr_TR") {
|
if (locale == "tr_TR") {
|
||||||
|
@ -121,7 +115,17 @@ int main(int argc, char *argv[])
|
||||||
qDebug()<<"Translations Are Already Loaded";
|
qDebug()<<"Translations Are Already Loaded";
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
qDebug()<<"Mainwindow is Already Registered";
|
w.setProperty("useStyleWindowManager", false); //禁用拖动
|
||||||
|
//设置窗口无边框,阴影
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
|
MotifWmHints window_hints;
|
||||||
|
window_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
||||||
|
window_hints.functions = MWM_FUNC_ALL;
|
||||||
|
window_hints.decorations = MWM_DECOR_BORDER;
|
||||||
|
XAtomHelper::getInstance()->setWindowMotifHint(w.winId(), window_hints);
|
||||||
|
#else
|
||||||
|
w.setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
|
||||||
|
#endif
|
||||||
|
|
||||||
DbusAdaptor adaptor(&w);
|
DbusAdaptor adaptor(&w);
|
||||||
Q_UNUSED(adaptor);
|
Q_UNUSED(adaptor);
|
||||||
|
@ -130,16 +134,6 @@ int main(int argc, char *argv[])
|
||||||
if (!connection.registerService("com.kylin.network") || !connection.registerObject("/com/kylin/network", &w)) {
|
if (!connection.registerService("com.kylin.network") || !connection.registerObject("/com/kylin/network", &w)) {
|
||||||
qCritical() << "QDbus register service failed reason:" << connection.lastError();
|
qCritical() << "QDbus register service failed reason:" << connection.lastError();
|
||||||
}
|
}
|
||||||
// QDBusInterface iface("com.kylin.network",
|
|
||||||
// "/com/kylin/network",
|
|
||||||
// "com.kylin.network",
|
|
||||||
// connection);
|
|
||||||
// iface.call("showMainWindow");
|
|
||||||
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
w.justShowTrayIcon();
|
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue