Merge branch '2303-eap' into 'yhkylin/v101'

新增企业网类型LEAP PWD FAST

See merge request kylinos-src/kylin-nm!148
This commit is contained in:
赵世旭 2023-04-21 02:18:45 +00:00
commit f86de2446c
15 changed files with 1375 additions and 141 deletions

View File

@ -193,3 +193,147 @@ void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSet
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
return;
}
void assembleEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo)
{
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
QList<NetworkManager::Security8021xSetting::EapMethod> list;
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodLeap);
wifi_8021x_sett->setInitialized(true);
wifi_8021x_sett->setEapMethods(list);
wifi_8021x_sett->setIdentity(leapInfo.m_userName);
wifi_8021x_sett->setPassword(leapInfo.m_userPwd);
wifi_8021x_sett->setPasswordFlags(leapInfo.m_passwdFlag);
NetworkManager::WirelessSecuritySetting::Ptr security_sett
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
security_sett->setInitialized(true);
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
return;
}
void assembleEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo)
{
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
QList<NetworkManager::Security8021xSetting::EapMethod> list;
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPwd);
wifi_8021x_sett->setInitialized(true);
wifi_8021x_sett->setEapMethods(list);
wifi_8021x_sett->setIdentity(pwdInfo.m_userName);
wifi_8021x_sett->setPassword(pwdInfo.m_userPwd);
wifi_8021x_sett->setPasswordFlags(pwdInfo.m_passwdFlag);
NetworkManager::WirelessSecuritySetting::Ptr security_sett
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
security_sett->setInitialized(true);
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
return;
}
void assembleEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo)
{
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
= connSettingPtr->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
QList<NetworkManager::Security8021xSetting::EapMethod> list;
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodFast);
wifi_8021x_sett->setInitialized(true);
wifi_8021x_sett->setEapMethods(list);
wifi_8021x_sett->setAnonymousIdentity(fastInfo.m_anonIdentity);
if (fastInfo.m_allowAutoPacFlag) {
wifi_8021x_sett->setPhase1FastProvisioning((NetworkManager::Security8021xSetting::FastProvisioning)fastInfo.m_pacProvisioning);
} else {
wifi_8021x_sett->setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioning::FastProvisioningDisabled);
}
QByteArray pacEndWithNull("file://" + fastInfo.m_pacFilePath.toUtf8() + '\0');
wifi_8021x_sett->setPacFile(pacEndWithNull);
wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)fastInfo.m_authMethod);
wifi_8021x_sett->setIdentity(fastInfo.m_userName);
wifi_8021x_sett->setPassword(fastInfo.m_userPwd);
wifi_8021x_sett->setPasswordFlags(fastInfo.m_passwdFlag);
NetworkManager::WirelessSecuritySetting::Ptr security_sett
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
security_sett->setInitialized(true);
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap);
return;
}
void modifyEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo)
{
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::EapMethodLeap);
wifi_8021x_sett->setEapMethods(list);
wifi_8021x_sett->setIdentity(leapInfo.m_userName);
if(leapInfo.bChanged)
{
wifi_8021x_sett->setPassword(leapInfo.m_userPwd);
}
wifi_8021x_sett->setPasswordFlags(leapInfo.m_passwdFlag);
QByteArray caCerEndWithNull("");
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
return;
}
void modifyEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo)
{
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::EapMethodPwd);
wifi_8021x_sett->setEapMethods(list);
wifi_8021x_sett->setIdentity(pwdInfo.m_userName);
if(pwdInfo.bChanged)
{
wifi_8021x_sett->setPassword(pwdInfo.m_userPwd);
}
wifi_8021x_sett->setPasswordFlags(pwdInfo.m_passwdFlag);
QByteArray caCerEndWithNull("");
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
return;
}
void modifyEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo)
{
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::EapMethodFast);
wifi_8021x_sett->setEapMethods(list);
wifi_8021x_sett->setAnonymousIdentity(fastInfo.m_anonIdentity);
if (fastInfo.m_allowAutoPacFlag) {
wifi_8021x_sett->setPhase1FastProvisioning((NetworkManager::Security8021xSetting::FastProvisioning)fastInfo.m_pacProvisioning);
} else {
wifi_8021x_sett->setPhase1FastProvisioning(NetworkManager::Security8021xSetting::FastProvisioning::FastProvisioningDisabled);
}
QByteArray pacEndWithNull("file://" + fastInfo.m_pacFilePath.toUtf8() + '\0');
wifi_8021x_sett->setPacFile(pacEndWithNull);
wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)fastInfo.m_authMethod);
wifi_8021x_sett->setIdentity(fastInfo.m_userName);
if(fastInfo.bChanged)
{
wifi_8021x_sett->setPassword(fastInfo.m_userPwd);
}
wifi_8021x_sett->setPasswordFlags(fastInfo.m_passwdFlag);
return;
}

View File

@ -30,6 +30,9 @@ enum KyEapMethodType {
TLS = 0,
PEAP,
TTLS,
LEAP,
PWD,
FAST
};
class KyEapMethodTlsInfo
@ -154,12 +157,99 @@ public:
}
};
typedef enum {
KyFastProvisioningUnknown = -1,
KyFastProvisioningDisabled,
KyFastProvisioningAllowUnauthenticated,
KyFastProvisioningAllowAuthenticated,
KyFastProvisioningAllowBoth
}KyFastProvisioning;
class KyEapMethodLeapInfo
{
public:
QString m_userName;
QString m_userPwd;
NetworkManager::Setting::SecretFlags m_passwdFlag;
// only valid when update
bool bChanged;
inline bool operator == (const KyEapMethodLeapInfo& info) const
{
if (this->m_userName == info.m_userName
&& this->m_userPwd == info.m_userPwd
&& this->m_passwdFlag == info.m_passwdFlag) {
return true;
} else {
return false;
}
}
};
class KyEapMethodPwdInfo
{
public:
QString m_userName;
QString m_userPwd;
NetworkManager::Setting::SecretFlags m_passwdFlag;
// only valid when update
bool bChanged;
inline bool operator == (const KyEapMethodPwdInfo& info) const
{
if (this->m_userName == info.m_userName
&& this->m_userPwd == info.m_userPwd
&& this->m_passwdFlag == info.m_passwdFlag) {
return true;
} else {
return false;
}
}
};
class KyEapMethodFastInfo
{
public:
QString m_anonIdentity;
KyFastProvisioning m_pacProvisioning;
bool m_allowAutoPacFlag;
QString m_pacFilePath;
KyNoEapMethodAuth m_authMethod;
QString m_userName;
QString m_userPwd;
NetworkManager::Setting::SecretFlags m_passwdFlag;
// only valid when update
bool bChanged;
inline bool operator == (const KyEapMethodFastInfo& info) const
{
if (this->m_anonIdentity == info.m_anonIdentity
&& this->m_pacProvisioning == info.m_pacProvisioning
&& this->m_allowAutoPacFlag == info.m_allowAutoPacFlag
&& this->m_pacFilePath == info.m_pacFilePath
&& this->m_authMethod == info.m_authMethod
&& this->m_userName == info.m_userName
&& this->m_userPwd == info.m_userPwd
&& this->m_passwdFlag == info.m_passwdFlag) {
return true;
} else {
return false;
}
}
};
void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo);
void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo);
void assembleEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo);
void assembleEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo);
void assembleEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo);
void assembleEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo);
void modifyEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo);
void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo);
void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo);
void modifyEapMethodLeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodLeapInfo &leapInfo);
void modifyEapMethodPwdSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPwdInfo &pwdInfo);
void modifyEapMethodFastSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodFastInfo &fastInfo);
#endif // KYENTERPRICESETTINGINFO_H

View File

@ -297,6 +297,109 @@ void KyWirelessConnectOperation::addTtlsConnect(const KyWirelessConnectSetting &
return;
}
//leap
void KyWirelessConnectOperation::addLeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodLeapInfo &leapInfo)
{
NetworkManager::WirelessNetwork::Ptr wifiNet =
checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName);
if (wifiNet.isNull()) {
QString errorMessage = "the ssid " + connSettingInfo.m_ssid
+ " is not exsit in " + connSettingInfo.m_ifaceName;
qWarning() << errorMessage;
Q_EMIT createConnectionError(errorMessage);
return;
}
NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint();
NetworkManager::ConnectionSettings::Ptr connSetting =
assembleWirelessSettings(accessPointPtr, connSettingInfo, false);
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
assembleEapMethodLeapSettings(connSetting, leapInfo);
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 leap connection failed: ") + watcher->error().message();
qWarning()<<errorMessage;
Q_EMIT this->createConnectionError(errorMessage);
} else {
qDebug()<<"create wireless connect complete";
}
watcher->deleteLater();
});
return;
}
//pwd
void KyWirelessConnectOperation::addPwdConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPwdInfo &pwdInfo)
{
NetworkManager::WirelessNetwork::Ptr wifiNet =
checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName);
if (wifiNet.isNull()) {
QString errorMessage = "the ssid " + connSettingInfo.m_ssid
+ " is not exsit in " + connSettingInfo.m_ifaceName;
qWarning() << errorMessage;
Q_EMIT createConnectionError(errorMessage);
return;
}
NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint();
NetworkManager::ConnectionSettings::Ptr connSetting =
assembleWirelessSettings(accessPointPtr, connSettingInfo, false);
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
assembleEapMethodPwdSettings(connSetting, pwdInfo);
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 pwd connection failed: ") + watcher->error().message();
qWarning()<<errorMessage;
Q_EMIT this->createConnectionError(errorMessage);
} else {
qDebug()<<"create wireless connect complete";
}
watcher->deleteLater();
});
return;
}
//fast
void KyWirelessConnectOperation::addFastConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodFastInfo &fastInfo)
{
NetworkManager::WirelessNetwork::Ptr wifiNet =
checkWifiNetExist(connSettingInfo.m_ssid, connSettingInfo.m_ifaceName);
if (wifiNet.isNull()) {
QString errorMessage = "the ssid " + connSettingInfo.m_ssid
+ " is not exsit in " + connSettingInfo.m_ifaceName;
qWarning() << errorMessage;
Q_EMIT createConnectionError(errorMessage);
return;
}
NetworkManager::AccessPoint::Ptr accessPointPtr = wifiNet->referenceAccessPoint();
NetworkManager::ConnectionSettings::Ptr connSetting =
assembleWirelessSettings(accessPointPtr, connSettingInfo, false);
setIpv4AndIpv6Setting(connSetting, connSettingInfo);
assembleEapMethodFastSettings(connSetting, fastInfo);
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 fast connection failed: ") + watcher->error().message();
qWarning()<<errorMessage;
Q_EMIT this->createConnectionError(errorMessage);
} else {
qDebug()<<"create wireless connect complete";
}
watcher->deleteLater();
});
}
void KyWirelessConnectOperation::setWirelessAutoConnect(const QString &uuid, bool bAutoConnect)
{
NetworkManager::Connection::Ptr connectPtr =
@ -482,6 +585,60 @@ void KyWirelessConnectOperation::updateWirelessEnterPriseTtlsConnect(const QStri
return;
}
void KyWirelessConnectOperation::updateWirelessEnterPriseLeapConnect(const QString &uuid, const KyEapMethodLeapInfo &leapInfo)
{
NetworkManager::Connection::Ptr connectPtr =
NetworkManager::findConnectionByUuid(uuid);
if (nullptr == connectPtr) {
QString errorMessage = tr("it can not find connection") + uuid;
qWarning()<<errorMessage;
Q_EMIT updateConnectionError(errorMessage);
return;
}
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
setWirelessSecuWpaXEap(connectionSettings);
modifyEapMethodLeapSettings(connectionSettings, leapInfo);
connectPtr->update(connectionSettings->toMap());
return;
}
void KyWirelessConnectOperation::updateWirelessEnterPrisePwdConnect(const QString &uuid, const KyEapMethodPwdInfo &pwdInfo)
{
NetworkManager::Connection::Ptr connectPtr =
NetworkManager::findConnectionByUuid(uuid);
if (nullptr == connectPtr) {
QString errorMessage = tr("it can not find connection") + uuid;
qWarning()<<errorMessage;
Q_EMIT updateConnectionError(errorMessage);
return;
}
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
setWirelessSecuWpaXEap(connectionSettings);
modifyEapMethodPwdSettings(connectionSettings, pwdInfo);
connectPtr->update(connectionSettings->toMap());
return;
}
void KyWirelessConnectOperation::updateWirelessEnterPriseFastConnect(const QString &uuid, const KyEapMethodFastInfo &fastInfo)
{
NetworkManager::Connection::Ptr connectPtr =
NetworkManager::findConnectionByUuid(uuid);
if (nullptr == connectPtr) {
QString errorMessage = tr("it can not find connection") + uuid;
qWarning()<<errorMessage;
Q_EMIT updateConnectionError(errorMessage);
return;
}
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
setWirelessSecuWpaXEap(connectionSettings);
modifyEapMethodFastSettings(connectionSettings, fastInfo);
connectPtr->update(connectionSettings->toMap());
return;
}
void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & devIface,KyWirelessConnectSetting &connSettingInfo,bool isHidden)
{
qDebug() << "addAndActiveWirelessConnect" << connSettingInfo.m_ssid << devIface <<connSettingInfo.m_psk;
@ -745,6 +902,162 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
});
}
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseLeapConnect(KyEapMethodLeapInfo &info, KyWirelessConnectSetting &connSettingInfo, QString &devIface, bool isHidden)
{
QString conn_uni;
QString dev_uni;
QString spec_object;
NMVariantMapMap map_settings;
NetworkManager::AccessPoint::Ptr accessPointPtr = nullptr;
if (!isHidden) {
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
if (wifiNet.isNull()) {
QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface;
qWarning()<<errorMessage;
Q_EMIT activateConnectionError(errorMessage);
return;
}
accessPointPtr = wifiNet->referenceAccessPoint();
conn_uni = accessPointPtr->uni();
spec_object = conn_uni;
}
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
if (dev.isNull()) {
Q_EMIT addAndActivateConnectionError("can not find device");
return;
}
dev_uni = dev->uni();
NetworkManager::ConnectionSettings::Ptr settings =
assembleWirelessSettings(accessPointPtr, connSettingInfo, isHidden);
assembleEapMethodLeapSettings(settings, info);
if(settings.isNull()) {
qDebug() << "assembleEapMethodLeapSettings failed";
return;
}
map_settings = settings->toMap();
QDBusPendingCallWatcher * watcher;
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
if (watcher->isError() || !watcher->isValid()) {
QString errorMessage = watcher->error().message();
qDebug() << "addAndActiveWirelessEnterPriseLeapConnect failed " << errorMessage;
Q_EMIT addAndActivateConnectionError(errorMessage);
}
watcher->deleteLater();
});
}
void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePwdConnect(KyEapMethodPwdInfo &info, KyWirelessConnectSetting &connSettingInfo, QString &devIface, bool isHidden)
{
QString conn_uni;
QString dev_uni;
QString spec_object;
NMVariantMapMap map_settings;
NetworkManager::AccessPoint::Ptr accessPointPtr = nullptr;
if (!isHidden) {
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
if (wifiNet.isNull()) {
QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface;
qWarning()<<errorMessage;
Q_EMIT activateConnectionError(errorMessage);
return;
}
accessPointPtr = wifiNet->referenceAccessPoint();
conn_uni = accessPointPtr->uni();
spec_object = conn_uni;
}
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
if (dev.isNull()) {
Q_EMIT addAndActivateConnectionError("can not find device");
return;
}
dev_uni = dev->uni();
NetworkManager::ConnectionSettings::Ptr settings =
assembleWirelessSettings(accessPointPtr, connSettingInfo, isHidden);
assembleEapMethodPwdSettings(settings, info);
if(settings.isNull()) {
qDebug() << "assembleEapMethodPwdSettings failed";
return;
}
map_settings = settings->toMap();
QDBusPendingCallWatcher * watcher;
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
if (watcher->isError() || !watcher->isValid()) {
QString errorMessage = watcher->error().message();
qDebug() << "addAndActiveWirelessEnterPrisePwdConnect failed " << errorMessage;
Q_EMIT addAndActivateConnectionError(errorMessage);
}
watcher->deleteLater();
});
}
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseFastConnect(KyEapMethodFastInfo &info, KyWirelessConnectSetting &connSettingInfo, QString &devIface, bool isHidden)
{
QString conn_uni;
QString dev_uni;
QString spec_object;
NMVariantMapMap map_settings;
NetworkManager::AccessPoint::Ptr accessPointPtr = nullptr;
if (!isHidden) {
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
if (wifiNet.isNull()) {
QString errorMessage = "the ssid " + connSettingInfo.m_ssid + " is not exsit in " + devIface;
qWarning()<<errorMessage;
Q_EMIT activateConnectionError(errorMessage);
return;
}
accessPointPtr = wifiNet->referenceAccessPoint();
conn_uni = accessPointPtr->uni();
spec_object = conn_uni;
}
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
if (dev.isNull()) {
Q_EMIT addAndActivateConnectionError("can not find device");
return;
}
dev_uni = dev->uni();
NetworkManager::ConnectionSettings::Ptr settings =
assembleWirelessSettings(accessPointPtr, connSettingInfo, isHidden);
assembleEapMethodFastSettings(settings, info);
if(settings.isNull()) {
qDebug() << "assembleEapMethodFastSettings failed";
return;
}
map_settings = settings->toMap();
QDBusPendingCallWatcher * watcher;
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
if (watcher->isError() || !watcher->isValid()) {
QString errorMessage = watcher->error().message();
qDebug() << "addAndActiveWirelessEnterPriseFastConnect failed " << errorMessage;
Q_EMIT addAndActivateConnectionError(errorMessage);
}
watcher->deleteLater();
});
}
//无线网络开关设置
void KyWirelessConnectOperation::setWirelessEnabled(bool enabled)
{
@ -1109,6 +1422,12 @@ bool KyWirelessConnectOperation::getEnterpiseEapMethod(const QString &uuid, KyEa
type = PEAP;
} else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls)) {
type = TTLS;
} else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodLeap)) {
type = LEAP;
} else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPwd)) {
type = PWD;
} else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodFast)) {
type = FAST;
}
return true;

View File

@ -99,6 +99,12 @@ public:
void addPeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPeapInfo &peapInfo);
//新增TTLS连接
void addTtlsConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodTtlsInfo &ttlsInfo);
//新增LEAP连接
void addLeapConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodLeapInfo &leapInfo);
//新增PWD连接
void addPwdConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodPwdInfo &pwdInfo);
//新增FAST连接
void addFastConnect(const KyWirelessConnectSetting &connSettingInfo, const KyEapMethodFastInfo &fastInfo);
//新增连接并激活(普通wifi)
void addAndActiveWirelessConnect(QString & devIface,KyWirelessConnectSetting &connSettingInfo,bool isHidden);
@ -109,6 +115,12 @@ public:
QString & devIface, bool isHidden);
void addAndActiveWirelessEnterPriseTtlsConnect(KyEapMethodTtlsInfo &info, KyWirelessConnectSetting &connSettingInfo,
QString & devIface, bool isHidden);
void addAndActiveWirelessEnterPriseLeapConnect(KyEapMethodLeapInfo &info, KyWirelessConnectSetting &connSettingInfo,
QString & devIface, bool isHidden);
void addAndActiveWirelessEnterPrisePwdConnect(KyEapMethodPwdInfo &info, KyWirelessConnectSetting &connSettingInfo,
QString & devIface, bool isHidden);
void addAndActiveWirelessEnterPriseFastConnect(KyEapMethodFastInfo &info, KyWirelessConnectSetting &connSettingInfo,
QString & devIface, bool isHidden);
//属性页 page1 AutoConnect
void setWirelessAutoConnect(const QString &uuid, bool bAutoConnect);
//属性页 page2 page3 ipv6
@ -120,6 +132,9 @@ public:
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 updateWirelessEnterPriseLeapConnect(const QString &uuid, const KyEapMethodLeapInfo &leapInfo);
void updateWirelessEnterPrisePwdConnect(const QString &uuid, const KyEapMethodPwdInfo &pwdInfo);
void updateWirelessEnterPriseFastConnect(const QString &uuid, const KyEapMethodFastInfo &fastInfo);
//忘记
void deleteWirelessConnect(const QString &connectUuid);
//获取密码

View File

@ -626,6 +626,119 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls
return true;
}
bool KyWirelessNetResource::getEnterPriseInfoLeap(QString &uuid, KyEapMethodLeapInfo &info)
{
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
if (conn.isNull()) {
qDebug()<< LOG_FLAG << "getEnterPriseInfoLeap connection missing";
return false;
}
NetworkManager::WirelessSecuritySetting::Ptr security_sett
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
if (security_sett.isNull()) {
qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection";
return false;
}
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
qDebug()<< LOG_FLAG << "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::EapMethodLeap)) {
qDebug()<< LOG_FLAG << "don't have Security8021x connection";
return false;
}
info.m_userName = setting->identity();
info.m_passwdFlag = setting->passwordFlags();
if (!info.m_passwdFlag) {
info.m_userPwd = m_operation->get8021xPassword(conn->uuid());
}
return true;
}
bool KyWirelessNetResource::getEnterPriseInfoPwd(QString &uuid, KyEapMethodPwdInfo &info)
{
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
if (conn.isNull()) {
qDebug()<< LOG_FLAG << "getEnterPriseInfoPwd connection missing";
return false;
}
NetworkManager::WirelessSecuritySetting::Ptr security_sett
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
if (security_sett.isNull()) {
qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection";
return false;
}
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
qDebug()<< LOG_FLAG << "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::EapMethodPwd)) {
qDebug()<< LOG_FLAG << "don't have Security8021x connection";
return false;
}
info.m_userName = setting->identity();
info.m_passwdFlag = setting->passwordFlags();
if (!info.m_passwdFlag) {
info.m_userPwd = m_operation->get8021xPassword(conn->uuid());
}
return true;
}
bool KyWirelessNetResource::getEnterPriseInfoFast(QString &uuid, KyEapMethodFastInfo &info)
{
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
if (conn.isNull()) {
qDebug()<< LOG_FLAG << "getEnterPriseInfoFast connection missing";
return false;
}
NetworkManager::WirelessSecuritySetting::Ptr security_sett
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
if (security_sett.isNull()) {
qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection";
return false;
}
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
qDebug()<< LOG_FLAG << "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::EapMethodFast)) {
qDebug()<< LOG_FLAG << "don't have Security8021x connection";
return false;
}
info.m_anonIdentity = setting->anonymousIdentity();
info.m_pacProvisioning = (KyFastProvisioning)setting->phase1FastProvisioning();
info.m_pacFilePath = setting->pacFile();
if (info.m_pacFilePath.left(7) == "file://") {
info.m_pacFilePath = info.m_pacFilePath.mid(7);
}
info.m_authMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod();
info.m_userName = setting->identity();
info.m_passwdFlag = setting->passwordFlags();
if (!info.m_passwdFlag) {
info.m_userPwd = m_operation->get8021xPassword(conn->uuid());
}
return true;
}
void KyWirelessNetResource::onConnectionAdd(QString uuid)
{
qDebug() << LOG_FLAG << "onConnectionAdd " << uuid;

View File

@ -46,6 +46,9 @@ public:
bool getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info);
bool getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info);
bool getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info);
bool getEnterPriseInfoLeap(QString &uuid, KyEapMethodLeapInfo &info);
bool getEnterPriseInfoPwd(QString &uuid, KyEapMethodPwdInfo &info);
bool getEnterPriseInfoFast(QString &uuid, KyEapMethodFastInfo &info);
void getWirelessActiveConnection(NetworkManager::ActiveConnection::State state, QMap<QString, QStringList> &map);
bool getActiveWirelessNetItem(QString deviceName, KyWirelessNetItem &wirelessNetItem);

View File

@ -23,8 +23,7 @@
#include "xatom-helper.h"
#define MAIN_SIZE_EXPAND 480,580
#define MAIN_SIZE_NARROW 480,484
#define PEAP_SCRO_HEIGHT 390
#define TLS_SCRO_HEIGHT 590
#define SCROAREA_WIDTH 480
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define CENTER_LAYOUT_MARGINS 24, 16, 24, 8
#define BUTTON_LAYOUT_MARGINS 24, 24, 24, 24
@ -127,7 +126,12 @@ void EnterpriseWlanDialog::initUI()
m_enterWlanScrollArea = new QScrollArea(this);
m_enterWlanScrollArea->setFrameShape(QFrame::NoFrame);
m_enterWlanScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_centerWidget->setFixedWidth(SCROAREA_WIDTH);
m_enterWlanScrollArea->setFixedWidth(SCROAREA_WIDTH);
m_enterWlanScrollArea->setWidget(m_centerWidget);
m_enterWlanScrollArea->setWidgetResizable(true);
QPalette pal = m_enterWlanScrollArea->palette();
pal.setBrush(QPalette::Base, QColor(0,0,0,0));
m_enterWlanScrollArea->setPalette(pal);
@ -256,6 +260,15 @@ void EnterpriseWlanDialog::onBtnConnectClicked()
} else if (eapType == KyEapMethodType::TTLS) {
m_securityPage->updateTtlsChange(m_info.ttlsInfo);
m_connectOperation->addAndActiveWirelessEnterPriseTtlsConnect(m_info.ttlsInfo, connetSetting, m_deviceName, false);
} else if (eapType == KyEapMethodType::LEAP) {
m_securityPage->updateLeapChange(m_info.leapInfo);
m_connectOperation->addAndActiveWirelessEnterPriseLeapConnect(m_info.leapInfo, connetSetting, m_deviceName, false);
} else if (eapType == KyEapMethodType::PWD) {
m_securityPage->updatePwdChange(m_info.pwdInfo);
m_connectOperation->addAndActiveWirelessEnterPrisePwdConnect(m_info.pwdInfo, connetSetting, m_deviceName, false);
} else if (eapType == KyEapMethodType::FAST) {
m_securityPage->updateFastChange(m_info.fastInfo);
m_connectOperation->addAndActiveWirelessEnterPriseFastConnect(m_info.fastInfo, connetSetting, m_deviceName, false);
} else {
qWarning() << "Connect enterprise wlan failed!(Unknown eap type)" << Q_FUNC_INFO << __LINE__;
}
@ -270,21 +283,36 @@ void EnterpriseWlanDialog::onEapTypeChanged(const KyEapMethodType &type)
m_resource->getEnterPriseInfoTls(m_wirelessNetItem.m_connectUuid, m_info.tlsInfo);
}
this->setFixedSize(MAIN_SIZE_EXPAND);
// m_centerWidget->setFixedHeight(TLS_SCRO_HEIGHT);
break;
case KyEapMethodType::PEAP:
if (m_wirelessNetItem.m_connectUuid.isEmpty()) {
m_resource->getEnterPriseInfoPeap(m_wirelessNetItem.m_connectUuid, m_info.peapInfo);
}
this->setFixedSize(MAIN_SIZE_NARROW);
// m_centerWidget->setFixedHeight(PEAP_SCRO_HEIGHT);
break;
case KyEapMethodType::TTLS:
if (!m_wirelessNetItem.m_connectUuid.isEmpty()) {
m_resource->getEnterPriseInfoTtls(m_wirelessNetItem.m_connectUuid, m_info.ttlsInfo);
}
this->setFixedSize(MAIN_SIZE_NARROW);
// m_centerWidget->setFixedHeight(PEAP_SCRO_HEIGHT);
break;
case KyEapMethodType::LEAP:
if (!m_wirelessNetItem.m_connectUuid.isEmpty()) {
m_resource->getEnterPriseInfoLeap(m_wirelessNetItem.m_connectUuid, m_info.leapInfo);
}
this->setFixedSize(MAIN_SIZE_NARROW);
break;
case KyEapMethodType::PWD:
if (!m_wirelessNetItem.m_connectUuid.isEmpty()) {
m_resource->getEnterPriseInfoPwd(m_wirelessNetItem.m_connectUuid, m_info.pwdInfo);
}
this->setFixedSize(MAIN_SIZE_NARROW);
break;
case KyEapMethodType::FAST:
if (!m_wirelessNetItem.m_connectUuid.isEmpty()) {
m_resource->getEnterPriseInfoFast(m_wirelessNetItem.m_connectUuid, m_info.fastInfo);
}
this->setFixedSize(MAIN_SIZE_EXPAND);
break;
default:
break;

View File

@ -55,6 +55,19 @@ enum TtlsInnerType
GTC_EAP
};
enum FastInnerType
{
GTC_FAST = 0,
MSCHAPV2_FAST,
};
enum PacProvisioningInnerType
{
ANON = 0,
AUTHEN,
BOTH,
};
class LineEdit : public QLineEdit
{
Q_OBJECT
@ -106,6 +119,9 @@ public:
KyEapMethodTlsInfo tlsInfo;
KyEapMethodPeapInfo peapInfo;
KyEapMethodTtlsInfo ttlsInfo;
KyEapMethodLeapInfo leapInfo;
KyEapMethodPwdInfo pwdInfo;
KyEapMethodFastInfo fastInfo;
};
static void setFramePalette(QFrame *widget, QPalette &pal) {

View File

@ -25,7 +25,7 @@
#define COLOR_THEME "styleName"
#define WINDOW_WIDTH 480
#define MIN_WINDOW_HEIGHT 368
#define PEAP_WINDOW_HEIGHT 524
#define EAPMIN_WINDOW_HEIGHT 524
#define TLS_WINDOW_HEIGHT 580
#define LAYOUT_MARGINS 0, 0, 0, 0
#define TOP_LAYOUT_MARGINS 24, 12, 24, 16
@ -35,9 +35,7 @@
#define LABEL_MIN_WIDTH 146
#define LABEL_MAX_WIDTH 434
#define MAX_NAME_LENGTH 32
#define PSK_SCRO_HEIGHT 182
#define PEAP_SCRO_HEIGHT 340
#define TLS_SCRO_HEIGHT 560
#define SCROAREA_WIDTH 480
#define MEDIUM_WEIGHT_VALUE 57
JoinHiddenWiFiPage::JoinHiddenWiFiPage(QString devName, KDialog *parent)
@ -49,7 +47,6 @@ JoinHiddenWiFiPage::JoinHiddenWiFiPage(QString devName, KDialog *parent)
initUI();
initComponent();
setFixedWidth(WINDOW_WIDTH);
setAttribute(Qt::WA_DeleteOnClose);
setJoinBtnEnable();
@ -121,8 +118,11 @@ void JoinHiddenWiFiPage::initUI()
m_centerVBoxLayout->addWidget(ssidWidget);
m_centerVBoxLayout->addSpacing(LAYOUT_SPACING);
m_centerVBoxLayout->addWidget(m_secuWidget);
m_centerVBoxLayout->addStretch();
m_centerWidget->setFixedWidth(SCROAREA_WIDTH);
m_hiddenWifiScrollArea->setFixedWidth(SCROAREA_WIDTH);
m_hiddenWifiScrollArea->setWidget(m_centerWidget);
m_hiddenWifiScrollArea->setWidgetResizable(true);
//底部按钮
m_bottomLayout = new QHBoxLayout(m_bottomWidget);
@ -149,7 +149,7 @@ void JoinHiddenWiFiPage::initUI()
this->setWindowTitle(tr("Find and Join Wi-Fi"));
this->setWindowIcon(QIcon::fromTheme("kylin-network"));
this->setFixedWidth(WINDOW_WIDTH);
this->setFixedHeight(MIN_WINDOW_HEIGHT);
onPaletteChanged();
}
@ -215,9 +215,18 @@ void JoinHiddenWiFiPage::onBtnJoinClicked()
} else if (eapType == PEAP) {
m_secuWidget->updatePeapChange(m_info.peapInfo);
m_wirelessConnOpration->addAndActiveWirelessEnterPrisePeapConnect(m_info.peapInfo, connSettingInfo, m_devName, true);
} else if (eapType = TTLS) {
} else if (eapType == TTLS) {
m_secuWidget->updateTtlsChange(m_info.ttlsInfo);
m_wirelessConnOpration->addAndActiveWirelessEnterPriseTtlsConnect(m_info.ttlsInfo, connSettingInfo, m_devName, true);
} else if (eapType == LEAP) {
m_secuWidget->updateLeapChange(m_info.leapInfo);
m_wirelessConnOpration->addAndActiveWirelessEnterPriseLeapConnect(m_info.leapInfo, connSettingInfo, m_devName, true);
} else if (eapType == PWD) {
m_secuWidget->updatePwdChange(m_info.pwdInfo);
m_wirelessConnOpration->addAndActiveWirelessEnterPrisePwdConnect(m_info.pwdInfo, connSettingInfo, m_devName, true);
} else if (eapType == FAST) {
m_secuWidget->updateFastChange(m_info.fastInfo);
m_wirelessConnOpration->addAndActiveWirelessEnterPriseFastConnect(m_info.fastInfo, connSettingInfo, m_devName, true);
}
} else {
m_secuWidget->updateSecurityChange(connSettingInfo);
@ -236,18 +245,15 @@ void JoinHiddenWiFiPage::onSecuTypeChanged(const KySecuType &type)
{
if (type != KySecuType::WPA_AND_WPA2_ENTERPRISE) {
this->setFixedHeight(MIN_WINDOW_HEIGHT);
m_centerWidget->setFixedSize(WINDOW_WIDTH, PSK_SCRO_HEIGHT);
}
}
void JoinHiddenWiFiPage::onEapTypeChanged(const KyEapMethodType &type)
{
if (type == KyEapMethodType::TLS) {
if (type == KyEapMethodType::TLS || type == KyEapMethodType::FAST) {
this->setFixedHeight(TLS_WINDOW_HEIGHT);
m_centerWidget->setFixedSize(WINDOW_WIDTH, TLS_SCRO_HEIGHT);
} else if (type == KyEapMethodType::PEAP || type == KyEapMethodType::TTLS) {
this->setFixedHeight(PEAP_WINDOW_HEIGHT);
m_centerWidget->setFixedSize(WINDOW_WIDTH, PEAP_SCRO_HEIGHT);
} else {
this->setFixedHeight(EAPMIN_WINDOW_HEIGHT);
}
}

View File

@ -39,7 +39,6 @@
#define CENTER_LAYOUT_MARGINS 24,0,0,0
#define BOTTOM_LAYOUT_MARGINS 24,0,24,0
#define BOTTOM_LAYOUT_SPACING 16
#define PAGE_LAYOUT_SPACING 1
#define DETAIL_PAGE_NUM 0
#define IPV4_PAGE_NUM 1
#define IPV6_PAGE_NUM 2
@ -47,9 +46,11 @@
#define CONFIG_PAGE_NUM 4
#define CREATE_NET_PAGE_NUM 5
#define PAGE_MIN_HEIGHT 40
#define PAGE_WIDTH 472
#define LAN_TAB_WIDTH 180
#define WLAN_TAB_WIDTH 240
#define SCRO_WIDTH 472
#define SCRO_WIDTH 496
#define SCRO_HEIGHT 600
#define PEAP_SCRO_HEIGHT 300
#define TLS_SCRO_HEIGHT 480
#define MAX_TAB_TEXT_LENGTH 44
@ -167,7 +168,7 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv
getConInfo(m_info);
startObjectThread();
pagePadding(name,isWlan);
setSecuPageHeight();
connect(qApp, &QApplication::paletteChanged, this, &NetDetail::onPaletteChanged);
isCreateOk = !(m_isCreateNet && !isWlan);
@ -283,50 +284,62 @@ void NetDetail::initUI()
mainLayout->setContentsMargins(0,9,0,24);
mainLayout->setSpacing(24);
detailPage = new DetailPage(isWlan, m_name.isEmpty(), this);
this->installEventFilter(this);
pageFrame = new QFrame(this);
centerWidget = new QWidget(this);
bottomWidget = new QWidget(this);
detailPage = new DetailPage(isWlan, m_name.isEmpty(), this);
ipv4Page = new Ipv4Page(this);
ipv6Page = new Ipv6Page(this);
securityPage = new SecurityPage(this);
createNetPage = new CreatNetPage(this);
configPage = new ConfigPage(this);
this->installEventFilter(this);
detailPage->setFixedWidth(PAGE_WIDTH);
ipv4Page->setFixedWidth(PAGE_WIDTH);
ipv6Page->setFixedWidth(PAGE_WIDTH);
securityPage->setFixedWidth(PAGE_WIDTH);
createNetPage->setFixedWidth(PAGE_WIDTH);
configPage->setFixedWidth(PAGE_WIDTH);
centerWidget = new QWidget(this);
bottomWidget = new QWidget(this);
m_secuPageScrollArea = new QScrollArea(this);
// 滚动区域
m_secuPageScrollArea = new QScrollArea(centerWidget);
m_secuPageScrollArea->setFixedWidth(SCRO_WIDTH);
m_secuPageScrollArea->setFrameShape(QFrame::NoFrame);
m_secuPageScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_secuPageScrollArea->setWidget(securityPage);
m_secuPageScrollArea->setWidgetResizable(true);
m_ipv4ScrollArea = new QScrollArea(centerWidget);
m_ipv4ScrollArea->setFixedWidth(SCRO_WIDTH);
m_ipv4ScrollArea->setFrameShape(QFrame::NoFrame);
m_ipv4ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_ipv4ScrollArea->setWidget(ipv4Page);
m_ipv4ScrollArea->setWidgetResizable(true);
m_ipv6ScrollArea = new QScrollArea(centerWidget);
m_ipv6ScrollArea->setFixedWidth(SCRO_WIDTH);
m_ipv6ScrollArea->setFrameShape(QFrame::NoFrame);
m_ipv6ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_ipv6ScrollArea->setWidget(ipv6Page);
m_ipv6ScrollArea->setWidgetResizable(true);
QPalette pal = m_secuPageScrollArea->palette();
pal.setBrush(QPalette::Base, QColor(0,0,0,0));
m_secuPageScrollArea->setPalette(pal);
detailPage->setFixedWidth(SCRO_WIDTH);
ipv4Page->setFixedWidth(SCRO_WIDTH);
ipv6Page->setFixedWidth(SCRO_WIDTH);
createNetPage->setFixedWidth(SCRO_WIDTH);
configPage->setFixedWidth(SCRO_WIDTH);
m_ipv4ScrollArea->setPalette(pal);
m_ipv6ScrollArea->setPalette(pal);
stackWidget = new QStackedWidget(centerWidget);
stackWidget->addWidget(detailPage);
stackWidget->addWidget(ipv4Page);
stackWidget->addWidget(ipv6Page);
stackWidget->addWidget(m_ipv4ScrollArea);
stackWidget->addWidget(m_ipv6ScrollArea);
stackWidget->addWidget(m_secuPageScrollArea);
stackWidget->addWidget(configPage);
stackWidget->addWidget(createNetPage);
mainLayout->addWidget(centerWidget);
mainLayout->addWidget(bottomWidget);
bottomWidget->setMinimumHeight(PAGE_MIN_HEIGHT);
pageFrame = new QFrame(this);
QHBoxLayout *pageLayout = new QHBoxLayout(pageFrame);
// pageLayout->setSpacing(PAGE_LAYOUT_SPACING);
// TabBar
onPaletteChanged();
m_networkMode = NetworkModeType(NetworkModeConfig::getInstance()->getNetworkModeConfig(m_uuid));
@ -351,25 +364,22 @@ void NetDetail::initUI()
}
}
pageLayout->addWidget(m_netTabBar, Qt::AlignCenter);
pageLayout->addSpacing(24);
// TabBar关联选项卡页面
connect(m_netTabBar, SIGNAL(currentChanged(int)), this, SLOT(currentRowChangeSlot(int)));
setNetTabToolTip();
confimBtn = new QPushButton(this);
confimBtn->setText(tr("Confirm"));
cancelBtn = new QPushButton(this);
cancelBtn->setText(tr("Cancel"));
forgetBtn = new QPushButton(this);
QHBoxLayout *pageLayout = new QHBoxLayout(pageFrame);
pageLayout->setContentsMargins(0, 0, 0, 0);
pageLayout->addWidget(m_netTabBar, Qt::AlignCenter);
QVBoxLayout *centerlayout = new QVBoxLayout(centerWidget);
centerlayout->setContentsMargins(CENTER_LAYOUT_MARGINS); // 右边距为0为安全页滚动区域留出空间
centerlayout->addWidget(pageFrame);
centerlayout->addSpacing(4);
centerlayout->addWidget(stackWidget);
QHBoxLayout *bottomLayout = new QHBoxLayout(bottomWidget);
@ -379,9 +389,12 @@ void NetDetail::initUI()
bottomLayout->addStretch();
bottomLayout->addWidget(cancelBtn);
bottomLayout->addWidget(confimBtn);
bottomWidget->setMinimumHeight(PAGE_MIN_HEIGHT);
mainLayout->addWidget(pageFrame);
mainLayout->addWidget(centerWidget);
mainLayout->addWidget(bottomWidget);
// QPalette pal(this->palette());
// pal.setColor(QPalette::Background, qApp->palette().base().color());
this->setAutoFillBackground(true);
// this->setPalette(pal);
}
@ -446,13 +459,6 @@ void NetDetail::initComponent()
setConfirmEnable();
});
connect(securityPage, &SecurityPage::secuTypeChanged, this, [=]() {
setSecuPageHeight();
});
connect(securityPage, &SecurityPage::eapTypeChanged, this, [=]() {
setSecuPageHeight();
});
const QByteArray id(THEME_SCHAME);
if(QGSettings::isSchemaInstalled(id)){
QGSettings * fontSetting = new QGSettings(id, QByteArray(), this);
@ -521,6 +527,14 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
securityPage->setPeapInfo(m_info.peapInfo);
} else if (m_info.enterpriseType == TTLS) {
securityPage->setTtlsInfo(m_info.ttlsInfo);
} else if (m_info.enterpriseType == LEAP) {
securityPage->setLeapInfo(m_info.leapInfo);
} else if (m_info.enterpriseType == PWD) {
securityPage->setPwdInfo(m_info.pwdInfo);
} else if (m_info.enterpriseType == FAST) {
securityPage->setFastInfo(m_info.fastInfo);
} else {
qWarning() << "[NetDetail] unknown enterprise connection type" << m_info.enterpriseType;
}
}
}
@ -714,12 +728,20 @@ void NetDetail::initSecuData()
case WPA_AND_WPA2_ENTERPRISE:
if (!m_wirelessConnOpration->getEnterpiseEapMethod(m_uuid, m_info.enterpriseType)) {
qDebug() << m_name << "not enterprise wifi";
} else if (m_info.enterpriseType == TLS){
} else if (m_info.enterpriseType == TLS) {
initTlsInfo(m_info);
} else if (m_info.enterpriseType == PEAP){
} else if (m_info.enterpriseType == PEAP) {
initPeapInfo(m_info);
} else {
} else if (m_info.enterpriseType == TTLS) {
initTtlsInfo(m_info);
} else if (m_info.enterpriseType == LEAP) {
initLeapInfo(m_info);
} else if (m_info.enterpriseType == PWD) {
initPwdInfo(m_info);
} else if (m_info.enterpriseType == FAST) {
initFastInfo(m_info);
} else {
qWarning() << "[NetDetail] unknown enterprise connection type" << m_info.enterpriseType;
}
break;
default:
@ -727,22 +749,6 @@ void NetDetail::initSecuData()
}
}
void NetDetail::setSecuPageHeight()
{
KySecuType secuType;
KyEapMethodType eapType;
securityPage->getSecuType(secuType, eapType);
if (secuType == WPA_AND_WPA2_ENTERPRISE) {
if (eapType == TLS) {
securityPage->setFixedSize(SCRO_WIDTH, TLS_SCRO_HEIGHT);
} else {
securityPage->setFixedSize(SCRO_WIDTH, PEAP_SCRO_HEIGHT);
}
} else {
securityPage->setFixedSize(SCRO_WIDTH, PEAP_SCRO_HEIGHT);
}
}
void NetDetail::initTlsInfo(ConInfo &conInfo)
{
m_resource->getEnterPriseInfoTls(m_uuid, conInfo.tlsInfo);
@ -758,6 +764,21 @@ void NetDetail::initTtlsInfo(ConInfo &conInfo)
m_resource->getEnterPriseInfoTtls(m_uuid, conInfo.ttlsInfo);
}
void NetDetail::initLeapInfo(ConInfo &conInfo)
{
m_resource->getEnterPriseInfoLeap(m_uuid, conInfo.leapInfo);
}
void NetDetail::initPwdInfo(ConInfo &conInfo)
{
m_resource->getEnterPriseInfoPwd(m_uuid, conInfo.pwdInfo);
}
void NetDetail::initFastInfo(ConInfo &conInfo)
{
m_resource->getEnterPriseInfoFast(m_uuid, conInfo.fastInfo);
}
//点击了保存更改网络设置的按钮
void NetDetail::on_btnConfirm_clicked()
{
@ -873,6 +894,17 @@ void NetDetail::updateWirelessEnterPriseConnect(KyEapMethodType enterpriseType)
} else if (enterpriseType == TTLS) {
securityPage->updateTtlsChange(m_info.ttlsInfo);
m_wirelessConnOpration->updateWirelessEnterPriseTtlsConnect(m_uuid, m_info.ttlsInfo);
} else if (enterpriseType == LEAP) {
securityPage->updateLeapChange(m_info.leapInfo);
m_wirelessConnOpration->updateWirelessEnterPriseLeapConnect(m_uuid, m_info.leapInfo);
} else if (enterpriseType == PWD) {
securityPage->updatePwdChange(m_info.pwdInfo);
m_wirelessConnOpration->updateWirelessEnterPrisePwdConnect(m_uuid, m_info.pwdInfo);
} else if (enterpriseType == FAST) {
securityPage->updateFastChange(m_info.fastInfo);
m_wirelessConnOpration->updateWirelessEnterPriseFastConnect(m_uuid, m_info.fastInfo);
} else {
qWarning() << "[NetDetail] unknown enterprise connection type" << enterpriseType;
}
}
@ -978,6 +1010,35 @@ bool NetDetail::createWirelessConnect()
qDebug() << "addAndConnect TTLS connect";
m_wirelessConnOpration->addAndActiveWirelessEnterPriseTtlsConnect(m_info.ttlsInfo, connetSetting, m_deviceName, true);
}
} else if (enterpriseType == LEAP) {
securityPage->updateLeapChange(m_info.leapInfo);
if (!m_name.isEmpty()) {
qDebug() << "add new LEAP connect";
m_wirelessConnOpration->addLeapConnect(connetSetting, m_info.leapInfo);
} else {
qDebug() << "addAndConnect LEAP connect";
m_wirelessConnOpration->addAndActiveWirelessEnterPriseLeapConnect(m_info.leapInfo, connetSetting, m_deviceName, true);
}
} else if (enterpriseType == PWD) {
securityPage->updatePwdChange(m_info.pwdInfo);
if (!m_name.isEmpty()) {
qDebug() << "add new PWD connect";
m_wirelessConnOpration->addPwdConnect(connetSetting, m_info.pwdInfo);
} else {
qDebug() << "addAndConnect PWD connect";
m_wirelessConnOpration->addAndActiveWirelessEnterPrisePwdConnect(m_info.pwdInfo, connetSetting, m_deviceName, true);
}
} else if (enterpriseType == FAST) {
securityPage->updateFastChange(m_info.fastInfo);
if (!m_name.isEmpty()) {
qDebug() << "add new FAST connect";
m_wirelessConnOpration->addFastConnect(connetSetting, m_info.fastInfo);
} else {
qDebug() << "addAndConnect FAST connect";
m_wirelessConnOpration->addAndActiveWirelessEnterPriseFastConnect(m_info.fastInfo, connetSetting, m_deviceName, true);
}
} else {
qWarning() << "[NetDetail] unknown enterprise connection type" << enterpriseType;
}
} else {
securityPage->updateSecurityChange(connetSetting);
@ -1145,16 +1206,19 @@ NetTabBar::~NetTabBar()
QSize NetTabBar::sizeHint() const
{
return QSize(TAB_WIDTH, TAB_HEIGHT);
QSize size = KTabBar::sizeHint();
size.setWidth(TAB_WIDTH);
return size;
}
QSize NetTabBar::minimumTabSizeHint(int index) const
{
Q_UNUSED(index)
return QSize(TAB_WIDTH, TAB_HEIGHT);
QSize size = KTabBar::minimumTabSizeHint(index);
size.setWidth(TAB_WIDTH);
return size;
}
ThreadObject::ThreadObject(QString deviceName, QObject *parent)
:m_devName(deviceName), QObject(parent)
{

View File

@ -56,6 +56,7 @@ using namespace kdk;
#define TAB_WIDTH 60
#define TAB_HEIGHT 36
#define TAB_HEIGHT_TABLET 48
class NetTabBar : public KTabBar
{
@ -63,9 +64,10 @@ class NetTabBar : public KTabBar
public:
explicit NetTabBar(QWidget *parent = nullptr);
~NetTabBar();
protected:
QSize sizeHint() const;
QSize minimumTabSizeHint(int index) const;
};
class ThreadObject : public QObject
{
@ -107,11 +109,13 @@ private:
void loadPage();
void pagePadding(QString netName, bool isWlan);
void initSecuData();
void setSecuPageHeight();
void initTlsInfo(ConInfo &conInfo);
void initPeapInfo(ConInfo &conInfo);
void initTtlsInfo(ConInfo &conInfo);
void initLeapInfo(ConInfo &conInfo);
void initPwdInfo(ConInfo &conInfo);
void initFastInfo(ConInfo &conInfo);
void updateWirelessPersonalConnect();
void updateWirelessEnterPriseConnect(KyEapMethodType enterpriseType);
@ -159,6 +163,8 @@ private:
QWidget * centerWidget;
QWidget * bottomWidget;
QScrollArea * m_secuPageScrollArea;
QScrollArea * m_ipv4ScrollArea;
QScrollArea * m_ipv6ScrollArea;
QPushButton * cancelBtn;
QPushButton * forgetBtn;

View File

@ -25,7 +25,7 @@
#define DETAIL_MIN_LABEL_WIDTH 80
#define DETAIL_MIN_EDIT_WIDTH 390
#define MIN_LABEL_WIDTH 146
#define MIN_EDIT_WIDTH 278
#define MIN_EDIT_WIDTH 286
SecurityPage::SecurityPage(bool isNetDetailPage, QWidget *parent) : isDetailPage(isNetDetailPage), QFrame(parent)
{
@ -84,6 +84,15 @@ void SecurityPage::initUI()
userPwdEdit->setUseCustomPalette(true);
userPwdFlagBox = new QCheckBox(this);
//FAST
m_pacCheckBox = new QCheckBox(this);
m_pacProvisionComboBox = new QComboBox(this);
m_pacFilePathComboBox = new QComboBox(this);
m_pacProvisionLabel = new FixLabel(this);
m_pacProvisionLabel->setFixedWidth(MIN_LABEL_WIDTH);
m_pacFlagLabel = new FixLabel(this);
m_pacFileLabel = new QLabel(this);
QWidget *queryWidget = new QWidget(this);
QHBoxLayout *queryLayout = new QHBoxLayout(queryWidget);
queryLayout->setContentsMargins(0, 0, 0, 0);
@ -106,6 +115,16 @@ void SecurityPage::initUI()
rememberLayout->addWidget(m_checkLabel);
rememberLayout->addStretch();
//允许自动PAC配置复选框
m_pacCheckWidget = new QWidget(this);
QGridLayout *pacCheckLayout = new QGridLayout(m_pacCheckWidget);
pacCheckLayout->setContentsMargins(0, 0, 0, 0);
pacCheckLayout->setVerticalSpacing(0);
pacCheckLayout->setColumnMinimumWidth(0, 16);
pacCheckLayout->addWidget(m_pacProvisionComboBox, 0, 0, 1, 2);
pacCheckLayout->addWidget(m_pacCheckBox, 1, 0);
pacCheckLayout->addWidget(m_pacFlagLabel, 1, 1);
// mSecuLayout = new QFormLayout(this);
// mSecuLayout->setContentsMargins(0, 0, 0, 0);
// mSecuLayout->addRow(secuTypeLabel, secuTypeCombox);
@ -135,19 +154,24 @@ void SecurityPage::initUI()
// EAP认证 Label和选项框 第2行第0列第1列
topLayout->addWidget(eapTypeLabel, 2, 0);
topLayout->addWidget(eapTypeCombox, 2, 1);
//内部认证 Label和选项框 第3行第0列第1列
topLayout->addWidget(eapMethodLabel, 3, 0);
topLayout->addWidget(eapMethodCombox, 3, 1);
//用户名 Label和输入框 第4行第0列第1列
topLayout->addWidget(userNameLabel, 4, 0);
topLayout->addWidget(userNameEdit, 4, 1);
//密码 Label和密码框 第5行第0列第1列
topLayout->addWidget(userPwdLabel, 5, 0);
topLayout->addWidget(userPwdEdit, 5, 1);
// 匿名身份 Label和输入框 第6行第0列第1列
topLayout->addWidget(identityLable, 6, 0);
topLayout->addWidget(identityEdit, 6, 1);
// 匿名身份 Label和输入框 第3行第0列第1列
topLayout->addWidget(identityLable, 3, 0);
topLayout->addWidget(identityEdit, 3, 1);
//PAC配置 允许自动PAC配置 第4行第0列第4行,第1列占2行1列
topLayout->addWidget(m_pacProvisionLabel, 4, 0, Qt::AlignTop);
topLayout->addWidget(m_pacCheckWidget, 4, 1);
// PAC文件
topLayout->addWidget(m_pacFileLabel, 6, 0);
topLayout->addWidget(m_pacFilePathComboBox, 6, 1);
//内部认证 Label和选项框
topLayout->addWidget(eapMethodLabel, 7, 0);
topLayout->addWidget(eapMethodCombox, 7, 1);
//用户名 Label和输入框
topLayout->addWidget(userNameLabel, 8, 0);
topLayout->addWidget(userNameEdit, 8, 1);
//密码 Label和密码框
topLayout->addWidget(userPwdLabel, 9, 0);
topLayout->addWidget(userPwdEdit, 9, 1);
// CA证书选项框及CheckBox布局
QWidget *caWidget = new QWidget(this);
@ -186,16 +210,18 @@ void SecurityPage::initUI()
if (isDetailPage) {
checkWidget->hide();
topLayout->addWidget(queryWidget, 7, 1);
topLayout->addWidget(queryWidget, 10, 1);
changeColumnWidthWithSecuType();
m_pacFlagLabel->setMinimumWidth(MIN_EDIT_WIDTH);
} else {
queryWidget->hide();
topLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH);
topLayout->setColumnMinimumWidth(1, MIN_EDIT_WIDTH);
bottomLayout->setColumnMinimumWidth(0, MIN_LABEL_WIDTH - 8);
m_pacFlagLabel->setMinimumWidth(MIN_EDIT_WIDTH - 36);
}
topLayout->addWidget(tlsWidget, 7, 0, 6, 2);
topLayout->addWidget(tlsWidget, 10, 0, 6, 2);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
@ -237,6 +263,9 @@ void SecurityPage::initUI()
eapTypeCombox->addItem("TLS", TLS);
eapTypeCombox->addItem("PEAP", PEAP);
eapTypeCombox->addItem("TTLS", TTLS);
eapTypeCombox->addItem("LEAP", LEAP);
eapTypeCombox->addItem("PWD", PWD);
eapTypeCombox->addItem("FAST", FAST);
eapTypeCombox->setCurrentIndex(TLS);
//TLS
caCertPathCombox->addItem(tr("None"), QString(tr("None"))); //无
@ -256,6 +285,18 @@ void SecurityPage::initUI()
pwdOptionCombox->addItem(tr("Ask this password every time"), QString(tr("Ask password every time")));
pwdOptionCombox->setCurrentIndex(1);
//FAST
m_pacCheckBox->setChecked(true);
m_pacProvisionLabel->setLabelText(tr("PAC provisioning")); //PAC配置
m_pacFlagLabel->setLabelText(tr("Allow automatic PAC provisioning")); //允许自动PAC配置
m_pacFileLabel->setText(tr("PAC file")); //PAC文件
m_pacProvisionComboBox->addItem(tr("Anonymous"), ANON); //匿名
m_pacProvisionComboBox->addItem(tr("Authenticated"), AUTHEN); //已认证
m_pacProvisionComboBox->addItem(tr("Both"), BOTH); //两者兼用
m_pacProvisionComboBox->setCurrentIndex(ANON);
m_pacFilePathComboBox->addItem(tr("None"), QString(tr("None"))); //无
m_pacFilePathComboBox->addItem(tr("Choose from file..."), QString(tr("Choose from file..."))); //从文件中选择...
//禁用ClearBtn按钮
pwdEdit->setClearButtonEnabled(false);
clientPrivateKeyPwdEdit->setClearButtonEnabled(false);
@ -308,6 +349,13 @@ void SecurityPage::initConnect()
connect(eapMethodCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
connect(userNameEdit, &LineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(userPwdEdit, &LineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(m_pacCheckBox, &QCheckBox::stateChanged, this, &SecurityPage::setEnableOfSaveBtn);
connect(m_pacProvisionComboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(m_pacFilePathComboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(m_pacCheckBox, &QCheckBox::clicked, this, &SecurityPage::onPacBoxClicked);
connect(m_pacFilePathComboBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &SecurityPage::onPacFilePathComboxIndexChanged);
}
@ -419,6 +467,77 @@ void SecurityPage::setTtlsInfo(KyEapMethodTtlsInfo &info)
}
}
void SecurityPage::setLeapInfo(KyEapMethodLeapInfo &info)
{
showLeapOrPwd();
eapTypeCombox->setCurrentIndex(LEAP);
userNameEdit->setText(info.m_userName);
userPwdEdit->setText(info.m_userPwd);
if (info.m_passwdFlag) {
userPwdFlagBox->setChecked(true);
} else {
userPwdFlagBox->setChecked(false);
}
}
void SecurityPage::setPwdInfo(KyEapMethodPwdInfo &info)
{
showLeapOrPwd();
eapTypeCombox->setCurrentIndex(PWD);
userNameEdit->setText(info.m_userName);
userPwdEdit->setText(info.m_userPwd);
if (info.m_passwdFlag) {
userPwdFlagBox->setChecked(true);
} else {
userPwdFlagBox->setChecked(false);
}
}
void SecurityPage::setFastInfo(KyEapMethodFastInfo &info)
{
showFast();
eapTypeCombox->setCurrentIndex(FAST);
onEapTypeComboxIndexChanged();
identityEdit->setText(info.m_anonIdentity);
m_pacCheckBox->setChecked(false);
m_pacProvisionComboBox->setCurrentIndex(ANON);
if (info.m_pacProvisioning == KyFastProvisioningDisabled) {
m_pacCheckBox->setChecked(false);
m_pacProvisionComboBox->setCurrentIndex(ANON);
m_pacProvisionComboBox->setEnabled(false);
} else if (info.m_pacProvisioning == KyFastProvisioningAllowUnauthenticated) {
m_pacProvisionComboBox->setCurrentIndex(ANON);
} else if (info.m_pacProvisioning == KyFastProvisioningAllowAuthenticated) {
m_pacProvisionComboBox->setCurrentIndex(AUTHEN);
} else if (info.m_pacProvisioning == KyFastProvisioningAllowBoth) {
m_pacProvisionComboBox->setCurrentIndex(BOTH);
} else {
qWarning() << "Unknown fastProvisioning type" << Q_FUNC_INFO << __LINE__;
m_pacCheckBox->setChecked(false);
m_pacProvisionComboBox->setEnabled(false);
}
if (info.m_pacFilePath.isEmpty()) {
m_pacFilePathComboBox->setItemText(0, QString(tr("None")));
} else {
m_pacFilePathComboBox->setItemText(0, info.m_pacFilePath);
}
if (info.m_authMethod == KyAuthMethodGtc) {
eapMethodCombox->setCurrentIndex(GTC_FAST);
} else if (info.m_authMethod == KyAuthMethodMschapv2) {
eapMethodCombox->setCurrentIndex(MSCHAPV2_FAST);
}
userNameEdit->setText(info.m_userName);
userPwdEdit->setText(info.m_userPwd);
if (info.m_passwdFlag) {
userPwdFlagBox->setChecked(true);
} else {
userPwdFlagBox->setChecked(false);
}
}
void SecurityPage::setSecurityVisible(const bool &visible)
{
if (secuTypeLabel) {
@ -461,6 +580,33 @@ void SecurityPage::updateTtlsChange(KyEapMethodTtlsInfo &info)
info = ttlsInfo;
}
void SecurityPage::updateLeapChange(KyEapMethodLeapInfo &info)
{
KyEapMethodLeapInfo leapInfo = assembleLeapInfo();
if (leapInfo.m_userPwd != info.m_userPwd) {
leapInfo.bChanged = true;
}
info = leapInfo;
}
void SecurityPage::updatePwdChange(KyEapMethodPwdInfo &info)
{
KyEapMethodPwdInfo pwdInfo = assemblePwdInfo();
if (pwdInfo.m_userPwd != info.m_userPwd) {
pwdInfo.bChanged = true;
}
info = pwdInfo;
}
void SecurityPage::updateFastChange(KyEapMethodFastInfo &info)
{
KyEapMethodFastInfo pwdInfo = assembleFastInfo();
if (pwdInfo.m_userPwd != info.m_userPwd) {
pwdInfo.bChanged = true;
}
info = pwdInfo;
}
void SecurityPage::getSecuType(KySecuType &secuType, KyEapMethodType &enterpriseType)
{
secuType = (KySecuType)secuTypeCombox->currentData().toInt();
@ -492,6 +638,12 @@ bool SecurityPage::checkIsChanged(const ConInfo info)
return !(info.peapInfo == assemblePeapInfo());
} else if (info.enterpriseType == TTLS) {
return !(info.ttlsInfo == assembleTtlsInfo());
} else if (info.enterpriseType == LEAP) {
return !(info.leapInfo == assembleLeapInfo());
} else if (info.enterpriseType == PWD) {
return !(info.pwdInfo == assemblePwdInfo());
} else if (info.enterpriseType == FAST) {
return !(info.fastInfo == assembleFastInfo());
}
}
}
@ -521,6 +673,12 @@ void SecurityPage::showNone()
userNameEdit->hide();
userPwdEdit->hide();
userPwdFlagLabel->hide();
//FAST
m_pacProvisionLabel->hide();
m_pacCheckWidget->hide();
m_pacFileLabel->hide();
m_pacFilePathComboBox->hide();
}
void SecurityPage::showPsk()
@ -546,6 +704,12 @@ void SecurityPage::showPsk()
userNameEdit->hide();
userPwdEdit->hide();
userPwdFlagLabel->hide();
//FAST
m_pacProvisionLabel->hide();
m_pacCheckWidget->hide();
m_pacFileLabel->hide();
m_pacFilePathComboBox->hide();
}
void SecurityPage::showTls()
@ -570,6 +734,12 @@ void SecurityPage::showTls()
userNameEdit->hide();
userPwdEdit->hide();
userPwdFlagLabel->hide();
//FAST
m_pacProvisionLabel->hide();
m_pacCheckWidget->hide();
m_pacFileLabel->hide();
m_pacFilePathComboBox->hide();
}
void SecurityPage::showPeapOrTtls()
@ -596,6 +766,74 @@ void SecurityPage::showPeapOrTtls()
userNameEdit->show();
userPwdEdit->show();
userPwdFlagLabel->show();
//FAST
m_pacProvisionLabel->hide();
m_pacCheckWidget->hide();
m_pacFileLabel->hide();
m_pacFilePathComboBox->hide();
}
void SecurityPage::showLeapOrPwd()
{
pwdLabel->hide();
pwdEdit->hide();
//企业wifi共有
eapTypeLabel->show();
eapTypeCombox->show();
//TLS
identityLable->hide();
identityEdit->hide();
tlsWidget->hide();
//FAST
m_pacProvisionLabel->hide();
m_pacCheckWidget->hide();
m_pacFileLabel->hide();
m_pacFilePathComboBox->hide();
eapMethodLabel->hide();
eapMethodCombox->hide();
userPwdFlagBox->show();
userPwdFlagLabel->show();
userNameLabel->show();
userNameEdit->show();
userPwdLabel->show();
userPwdEdit->show();
}
void SecurityPage::showFast()
{
pwdLabel->hide();
pwdEdit->hide();
//企业wifi共有
eapTypeLabel->show();
eapTypeCombox->show();
//TLS
identityLable->show();
identityEdit->show();
tlsWidget->hide();
//FAST
m_pacProvisionLabel->show();
m_pacCheckWidget->show();
m_pacFileLabel->show();
m_pacFilePathComboBox->show();
eapMethodLabel->show();
eapMethodCombox->show();
userPwdFlagBox->show();
userPwdFlagLabel->show();
userNameLabel->show();
userNameEdit->show();
userPwdLabel->show();
userPwdEdit->show();
}
KyEapMethodTlsInfo SecurityPage::assembleTlsInfo()
@ -688,6 +926,60 @@ KyEapMethodTtlsInfo SecurityPage::assembleTtlsInfo()
return info;
}
KyEapMethodLeapInfo SecurityPage::assembleLeapInfo()
{
KyEapMethodLeapInfo info;
info.m_userName = userNameEdit->text();
info.m_userPwd = userPwdEdit->text();
info.m_passwdFlag = (userPwdFlagBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None);
return info;
}
KyEapMethodPwdInfo SecurityPage::assemblePwdInfo()
{
KyEapMethodPwdInfo info;
info.m_userName = userNameEdit->text();
info.m_userPwd = userPwdEdit->text();
info.m_passwdFlag = (userPwdFlagBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None);
return info;
}
KyEapMethodFastInfo SecurityPage::assembleFastInfo()
{
KyEapMethodFastInfo info;
info.m_anonIdentity = identityEdit->text();
switch (m_pacProvisionComboBox->currentIndex()) {
case ANON:
info.m_pacProvisioning = KyFastProvisioningAllowUnauthenticated;
break;
case AUTHEN:
info.m_pacProvisioning = KyFastProvisioningAllowAuthenticated;
break;
case BOTH:
info.m_pacProvisioning = KyFastProvisioningAllowBoth;
break;
default:
break;
}
info.m_allowAutoPacFlag = m_pacCheckBox->isChecked();
info.m_pacFilePath = m_pacFilePathComboBox->currentText();
switch (eapMethodCombox->currentIndex()) {
case GTC_FAST:
info.m_authMethod = KyAuthMethodGtc;
break;
case MSCHAPV2_FAST:
info.m_authMethod = KyAuthMethodMschapv2;
break;
default:
break;
}
info.m_userName = userNameEdit->text();
info.m_userPwd = userPwdEdit->text();
info.m_passwdFlag = (userPwdFlagBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None);
return info;
}
void SecurityPage::updateSecurityChange(KyWirelessConnectSetting &setting)
{
qDebug() << "secuTypeCombox->currentData()" << secuTypeCombox->currentData().toInt() << pwdEdit->text();
@ -746,7 +1038,18 @@ bool SecurityPage::checkConnectBtnIsEnabled()
qDebug() << "client Private Key password is empty";
return false;
}
} else if (type == PEAP || type == TTLS) {
} else if (type == PEAP || type == TTLS || type == LEAP || type == PWD) {
if(userNameEdit->text().isEmpty() || userPwdEdit->text().isEmpty()) {
qDebug() << "user name or user password is empty";
return false;
}
} else if (type == FAST) {
if(!m_pacCheckBox->isChecked()) {
if (m_pacFilePathComboBox->currentText() == QString(tr("None"))) {
qDebug() << "Not allow automatic PAC provisioning && pac file is empty";
return false;
}
}
if(userNameEdit->text().isEmpty() || userPwdEdit->text().isEmpty()) {
qDebug() << "user name or user password is empty";
return false;
@ -805,6 +1108,18 @@ void SecurityPage::onEapTypeComboxIndexChanged()
eapMethodCombox->addItem("md5(eap)", MD5_EAP);
eapMethodCombox->addItem("gtc(eap)", GTC_EAP);
Q_EMIT this->eapTypeChanged(TTLS);
} else if (index == LEAP) {
showLeapOrPwd();
Q_EMIT this->eapTypeChanged(LEAP);
} else if (index == PWD) {
showLeapOrPwd();
Q_EMIT this->eapTypeChanged(PWD);
} else if (index == FAST) {
showFast();
eapMethodCombox->clear();
eapMethodCombox->addItem("GTC", GTC_FAST);
eapMethodCombox->addItem("MSCHAPv2", MSCHAPV2_FAST);
Q_EMIT this->eapTypeChanged(FAST);
}
}
@ -818,6 +1133,16 @@ void SecurityPage::onCaNeedBoxClicked()
}
}
void SecurityPage::onPacBoxClicked()
{
if (!m_pacCheckBox->isChecked()) {
m_pacProvisionComboBox->setCurrentIndex(ANON);
m_pacProvisionComboBox->setEnabled(false);
} else {
m_pacProvisionComboBox->setEnabled(true);
}
}
void SecurityPage::onCaCertPathComboxIndexChanged(QString str)
{
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
@ -918,3 +1243,26 @@ void SecurityPage::changeColumnWidthWithSecuType()
}
}
void SecurityPage::onPacFilePathComboxIndexChanged(QString str)
{
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a PAC file"), "recent:///",
tr("PAC Files (*.pac)"));
if (!fileName.isNull()) {
QStringList nameList = fileName.split("/");
m_pacFilePathComboBox->blockSignals(true);
m_pacFilePathComboBox->setItemText(0, fileName);
m_pacFilePathComboBox->setCurrentIndex(0);
m_pacFilePathComboBox->blockSignals(false);
} else {
m_pacFilePathComboBox->blockSignals(true);
m_pacFilePathComboBox->setItemText(0, tr("None"));
m_pacFilePathComboBox->setCurrentIndex(0);
m_pacFilePathComboBox->blockSignals(false);
}
} else {
qWarning() << "Choose file is null or unvalible";
}
}

View File

@ -45,6 +45,9 @@ public:
void setTlsInfo(KyEapMethodTlsInfo &info);
void setPeapInfo(KyEapMethodPeapInfo &info);
void setTtlsInfo(KyEapMethodTtlsInfo &info);
void setLeapInfo(KyEapMethodLeapInfo &info);
void setPwdInfo(KyEapMethodPwdInfo &info);
void setFastInfo(KyEapMethodFastInfo &info);
void setSecurityVisible(const bool &visible);
bool checkIsChanged(const ConInfo info);
@ -52,6 +55,9 @@ public:
void updateTlsChange(KyEapMethodTlsInfo &info);
void updatePeapChange(KyEapMethodPeapInfo &info);
void updateTtlsChange(KyEapMethodTtlsInfo &info);
void updateLeapChange(KyEapMethodLeapInfo &info);
void updatePwdChange(KyEapMethodPwdInfo &info);
void updateFastChange(KyEapMethodFastInfo &info);
void getSecuType(KySecuType &secuType, KyEapMethodType &enterpriseType);
bool getAutoConnectState();
@ -103,6 +109,15 @@ private:
KPasswordEdit *userPwdEdit = nullptr;
QCheckBox *userPwdFlagBox;
//FAST
QCheckBox *m_pacCheckBox;
QComboBox *m_pacProvisionComboBox;
QComboBox *m_pacFilePathComboBox;
FixLabel *m_pacProvisionLabel;
FixLabel *m_pacFlagLabel;
QLabel *m_pacFileLabel;
QWidget *m_pacCheckWidget;
QLabel *m_emptyLabel = nullptr;
QLabel *m_checkLabel = nullptr;
QCheckBox *m_rememberCheckBox = nullptr;
@ -115,12 +130,17 @@ private:
void showPsk();
void showTls();
void showPeapOrTtls();
void showLeapOrPwd();
void showFast();
void initUI();
void initConnect();
KyEapMethodTlsInfo assembleTlsInfo();
KyEapMethodPeapInfo assemblePeapInfo();
KyEapMethodTtlsInfo assembleTtlsInfo();
KyEapMethodLeapInfo assembleLeapInfo();
KyEapMethodPwdInfo assemblePwdInfo();
KyEapMethodFastInfo assembleFastInfo();
bool checkConnectBtnIsEnabled();
@ -131,12 +151,14 @@ private Q_SLOTS:
void setEnableOfSaveBtn();
void onCaNeedBoxClicked();
void onPacBoxClicked();
void onCaCertPathComboxIndexChanged(QString str);
void onClientCertPathComboxIndexChanged(QString str);
void onClientPrivateKeyComboxIndexChanged(QString str);
void onPwdOptionComboxIndexChanged(QString str);
void changeColumnWidthWithSecuType();
void onPacFilePathComboxIndexChanged(QString str);
Q_SIGNALS:
void setSecuPageState(bool);

View File

@ -717,11 +717,11 @@
<source>Connect</source>
<translation></translation>
</message>
<message>
<message>
<source>Property</source>
<translation></translation>
</message>
<message>
<message>
<source>Delete</source>
<translation></translation>
</message>
@ -1074,7 +1074,7 @@
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="212"/>
<source>CA certficate</source>
<translation>CA certficate</translation>
<translation>CAལག</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="213"/>
@ -1124,15 +1124,7 @@
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="229"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="239"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="242"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="245"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="328"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="805"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="826"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="848"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="871"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="252"/>
<source>None</source>
<translation></translation>
</message>
@ -1152,9 +1144,7 @@
<translation>WPA3མི</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="240"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="243"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="246"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="253"/>
<source>Choose from file...</source>
<translation>...</translation>
</message>
@ -1189,19 +1179,63 @@
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="816"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="839"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="861"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="1150"/>
<source>Choose a CA certificate</source>
<translation>CAཡི</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="817"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="840"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="862"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="1151"/>
<source>CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)</source>
<translation>CA (*.pem *.der *.p12 *.crt *.cer *.pfx)</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="290"/>
<source>PAC provisioning</source>
<translatorcomment>PAC </translatorcomment>
<translation>PAC </translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="291"/>
<source>Allow automatic PAC provisioning</source>
<translatorcomment>PAC配置</translatorcomment>
<translation>PACམཚོ</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="292"/>
<source>PAC file</source>
<translatorcomment>PAC </translatorcomment>
<translation>PACཡིག</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="293"/>
<source>Anonymous</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="294"/>
<source>Authenticated</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="295"/>
<source>Both</source>
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="1250"/>
<source>Choose a PAC file</source>
<translatorcomment>PAC文件</translatorcomment>
<translation>PACཡིག</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="1251"/>
<source>PAC Files (*.pac)</source>
<translatorcomment>PAC文件(*.pac)</translatorcomment>
<translation>PACཡིག(*.pac)</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.h" line="110"/>
<source> </source>
@ -1323,7 +1357,7 @@
<source>Forget</source>
<translation></translation>
</message>
<message>
<message>
<source>Property</source>
<translation></translation>
</message>

View File

@ -1124,15 +1124,7 @@
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="229"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="239"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="242"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="245"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="328"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="805"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="826"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="848"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="871"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="252"/>
<source>None</source>
<translation></translation>
</message>
@ -1152,9 +1144,7 @@
<translation>WPA3 </translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="240"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="243"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="246"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="253"/>
<source>Choose from file...</source>
<translation>...</translation>
</message>
@ -1189,19 +1179,55 @@
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="816"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="839"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="861"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="1150"/>
<source>Choose a CA certificate</source>
<translation>CA证书</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="817"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="840"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="862"/>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="1151"/>
<source>CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)</source>
<translation>CA (*.pem *.der *.p12 *.crt *.cer *.pfx)</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="290"/>
<source>PAC provisioning</source>
<translation>PAC </translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="291"/>
<source>Allow automatic PAC provisioning</source>
<translation>PAC配置</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="292"/>
<source>PAC file</source>
<translation>PAC </translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="293"/>
<source>Anonymous</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="294"/>
<source>Authenticated</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="295"/>
<source>Both</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="1250"/>
<source>Choose a PAC file</source>
<translation>PAC文件</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.cpp" line="1251"/>
<source>PAC Files (*.pac)</source>
<translation>PAC文件(*.pac)</translation>
</message>
<message>
<location filename="../src/frontend/netdetails/securitypage.h" line="110"/>
<source> </source>