Merge branch 'up-dbus' into 'dbus-interface'
Up dbus See merge request kylin-desktop/kylin-nm!251
This commit is contained in:
commit
636ec6af4c
|
@ -13,11 +13,16 @@ void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSe
|
|||
if (!info.domain.isEmpty()){
|
||||
wifi_8021x_sett->setDomainSuffixMatch(info.domain);
|
||||
}
|
||||
QByteArray caCerEndWithNull(info.caCertPath.toUtf8() + '\0');
|
||||
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
|
||||
QByteArray cliCertEndWithNull(info.clientCertPath.toUtf8() + '\0');
|
||||
if (info.bNeedCa) {
|
||||
QByteArray caCerEndWithNull("file://" + info.caCertPath.toUtf8() + '\0');
|
||||
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
|
||||
} else {
|
||||
QByteArray caCerEndWithNull("");
|
||||
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
|
||||
}
|
||||
QByteArray cliCertEndWithNull("file://" + info.clientCertPath.toUtf8() + '\0');
|
||||
wifi_8021x_sett->setClientCertificate(cliCertEndWithNull);
|
||||
QByteArray cliPriKeyEndWithNull(info.clientPrivateKey.toUtf8() + '\0');
|
||||
QByteArray cliPriKeyEndWithNull("file://" + info.clientPrivateKey.toUtf8() + '\0');
|
||||
wifi_8021x_sett->setPrivateKey(cliPriKeyEndWithNull);
|
||||
wifi_8021x_sett->setPrivateKeyPassword(info.clientPrivateKeyPWD);
|
||||
wifi_8021x_sett->setPrivateKeyPasswordFlags(info.m_privateKeyPWDFlag);
|
||||
|
@ -98,13 +103,16 @@ void modifyEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSett
|
|||
}
|
||||
if (tlsInfo.bNeedCa)
|
||||
{
|
||||
QByteArray caCerEndWithNull(tlsInfo.caCertPath.toUtf8() + '\0');
|
||||
QByteArray caCerEndWithNull("file://" + tlsInfo.caCertPath.toUtf8() + '\0');
|
||||
setting->setCaCertificate(caCerEndWithNull);
|
||||
} else {
|
||||
QByteArray caCerEndWithNull("");
|
||||
setting->setCaCertificate(caCerEndWithNull);
|
||||
}
|
||||
|
||||
QByteArray cliCertEndWithNull(tlsInfo.clientCertPath.toUtf8() + '\0');
|
||||
QByteArray cliCertEndWithNull("file://" + tlsInfo.clientCertPath.toUtf8() + '\0');
|
||||
setting->setClientCertificate(cliCertEndWithNull);
|
||||
QByteArray cliPriKeyEndWithNull(tlsInfo.clientPrivateKey.toUtf8() + '\0');
|
||||
QByteArray cliPriKeyEndWithNull("file://" + tlsInfo.clientPrivateKey.toUtf8() + '\0');
|
||||
setting->setPrivateKey(cliPriKeyEndWithNull);
|
||||
setting->setPrivateKeyPasswordFlags(tlsInfo.m_privateKeyPWDFlag);
|
||||
if(tlsInfo.bChanged)
|
||||
|
@ -133,6 +141,9 @@ void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSet
|
|||
}
|
||||
wifi_8021x_sett->setPasswordFlags(peapInfo.m_passwdFlag);
|
||||
|
||||
QByteArray caCerEndWithNull("");
|
||||
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -158,5 +169,8 @@ void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSet
|
|||
wifi_8021x_sett->setPassword(ttlsInfo.userPWD);
|
||||
}
|
||||
wifi_8021x_sett->setPasswordFlags(ttlsInfo.m_passwdFlag);
|
||||
|
||||
QByteArray caCerEndWithNull("");
|
||||
wifi_8021x_sett->setCaCertificate(caCerEndWithNull);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,12 @@
|
|||
#include "kylinnetworkresourcemanager.h"
|
||||
#include <QObject>
|
||||
|
||||
enum KyEapMethodType {
|
||||
TLS = 0,
|
||||
PEAP,
|
||||
TTLS,
|
||||
};
|
||||
|
||||
class KyEapMethodTlsInfo
|
||||
{
|
||||
public:
|
||||
|
@ -21,6 +27,23 @@ public:
|
|||
NetworkManager::Setting::SecretFlags m_privateKeyPWDFlag;
|
||||
// only valid when update
|
||||
bool bChanged;
|
||||
|
||||
inline bool operator == (const KyEapMethodTlsInfo& info) const
|
||||
{
|
||||
if (this->identity == info.identity
|
||||
&& this->domain == info.domain
|
||||
// && this->devIfaceName == info.devIfaceName
|
||||
&& this->caCertPath == info.caCertPath
|
||||
&& this->bNeedCa == info.bNeedCa
|
||||
&& this->clientCertPath == info.clientCertPath
|
||||
&& this->clientPrivateKey == info.clientPrivateKey
|
||||
&& this->clientPrivateKeyPWD == info.clientPrivateKeyPWD
|
||||
/*&& this->m_privateKeyPWDFlag == info.m_privateKeyPWDFlag*/) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
@ -54,6 +77,18 @@ public:
|
|||
NetworkManager::Setting::SecretFlags m_passwdFlag;
|
||||
// only valid when update
|
||||
bool bChanged;
|
||||
|
||||
inline bool operator == (const KyEapMethodPeapInfo& info) const
|
||||
{
|
||||
if (this->phase2AuthMethod == info.phase2AuthMethod
|
||||
&& this->userName == info.userName
|
||||
&& this->userPWD == info.userPWD
|
||||
/*&& this->m_passwdFlag == info.m_passwdFlag*/) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
enum KyTtlsAuthMethod
|
||||
|
@ -73,6 +108,31 @@ public:
|
|||
NetworkManager::Setting::SecretFlags m_passwdFlag;
|
||||
// only valid when update
|
||||
bool bChanged;
|
||||
|
||||
inline bool operator == (const KyEapMethodTtlsInfo& info) const
|
||||
{
|
||||
if (this->authType == info.authType) {
|
||||
if (authType == AUTH_EAP) {
|
||||
if (this->authEapMethod == info.authEapMethod
|
||||
&& this ->userName == info.userName
|
||||
&& this->userPWD == info.userPWD
|
||||
/*&& this->m_passwdFlag == info.m_passwdFlag*/) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (authType == AUTH_EAP) {
|
||||
if (this->authNoEapMethod == info.authNoEapMethod
|
||||
&& this ->userName == info.userName
|
||||
&& this->userPWD == info.userPWD
|
||||
/*&& this->m_passwdFlag == info.m_passwdFlag*/) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo);
|
||||
|
|
|
@ -75,6 +75,9 @@ KyConnectItem *KyActiveConnectResourse::getActiveConnectionByUuid(QString connec
|
|||
if (devicePtr->interfaceName() == deviceName) {
|
||||
KyConnectItem *activeConnectItem =
|
||||
getActiveConnectionItem(activeConnectPtr);
|
||||
if (nullptr == activeConnectItem) {
|
||||
return nullptr;
|
||||
}
|
||||
activeConnectItem->m_ifaceName = deviceName;
|
||||
activeConnectItem->m_itemType = activeConnectPtr->type();
|
||||
return activeConnectItem;
|
||||
|
@ -511,3 +514,24 @@ void KyActiveConnectResourse::getApActivateConnect(QList<KyApConnectItem *> &apC
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
bool KyActiveConnectResourse::isActiveConnection(QString uuid, QStringList &devName)
|
||||
{
|
||||
if (!m_networkResourceInstance->isActiveConnection(uuid)) {
|
||||
return false;
|
||||
} else {
|
||||
NetworkManager::ActiveConnection::Ptr actPtr = m_networkResourceInstance->getActiveConnect(uuid);
|
||||
if (actPtr.isNull()) {
|
||||
return false;
|
||||
} else {
|
||||
QStringList interfaces = actPtr->devices();
|
||||
for (int index = 0; index < interfaces.size(); ++index) {
|
||||
QString ifaceUni = interfaces.at(index);
|
||||
NetworkManager::Device:: Ptr devicePtr =
|
||||
m_networkResourceInstance->findDeviceUni(ifaceUni);
|
||||
devName <<devicePtr->interfaceName();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ public:
|
|||
|
||||
void getApActivateConnect(QList<KyApConnectItem *> &apConnectItemList);
|
||||
|
||||
bool isActiveConnection(QString uuid, QStringList &devName);
|
||||
|
||||
private:
|
||||
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||
QString &ipv4Address,
|
||||
|
|
|
@ -15,6 +15,7 @@ KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent)
|
|||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionAdd, this, &KyConnectResourse::connectionAdd);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionRemove, this, &KyConnectResourse::connectionRemove);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionUpdate, this, &KyConnectResourse::connectionUpdate);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectivityChanged, this, &KyConnectResourse::connectivityChanged);
|
||||
}
|
||||
|
||||
KyConnectResourse::~KyConnectResourse()
|
||||
|
@ -273,6 +274,11 @@ void KyConnectResourse::getIpv6ConnectSetting(
|
|||
return;
|
||||
}
|
||||
|
||||
void KyConnectResourse::getConnectivity(NetworkManager::Connectivity &connectivity)
|
||||
{
|
||||
m_networkResourceInstance->getConnectivity(connectivity);
|
||||
}
|
||||
|
||||
void KyConnectResourse::getConnectionSetting(QString connectUuid, KyConnectSetting &connectSetting)
|
||||
{
|
||||
qDebug() <<"[KyConnectResourse]" << connectUuid <<"get connect setting info, connect uuid";
|
||||
|
@ -290,6 +296,7 @@ void KyConnectResourse::getConnectionSetting(QString connectUuid, KyConnectSetti
|
|||
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
connectSetting.m_ifaceName = connectionSettings->interfaceName();
|
||||
connectSetting.m_isAutoConnect = connectionSettings->autoconnect();
|
||||
|
||||
NetworkManager::Ipv4Setting::Ptr ipv4Setting = connectionSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
|
||||
getIpv4ConnectSetting(ipv4Setting, connectSetting);
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
void getApConnections(QList<KyApConnectItem *> &apConnectItemList);
|
||||
void getConnectionSetting(QString connectUuid, KyConnectSetting &connectSetting);
|
||||
bool getInterfaceByUuid(QString &deviceName, NetworkManager::ConnectionSettings::ConnectionType &type, const QString connUuid);
|
||||
void getConnectivity(NetworkManager::Connectivity &connectivity);
|
||||
|
||||
private:
|
||||
KyConnectItem *getConnectionItem(NetworkManager::Connection::Ptr connectPtr);
|
||||
|
@ -51,6 +52,7 @@ signals:
|
|||
void connectionAdd(QString uuid);
|
||||
void connectionUpdate(QString uuid);
|
||||
void connectionRemove(QString path);
|
||||
void connectivityChanged(NetworkManager::Connectivity connectivity);
|
||||
|
||||
private:
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
|
|
|
@ -30,6 +30,8 @@ KyConnectSetting::KyConnectSetting(/*QObject *parent) : QObject(parent*/)
|
|||
m_ipv6ConfigIpType = CONFIG_IP_DHCP;
|
||||
m_ipv6Address.clear();
|
||||
m_ipv6Dns.clear();
|
||||
|
||||
m_isAutoConnect = true;
|
||||
}
|
||||
|
||||
KyConnectSetting::~KyConnectSetting()
|
||||
|
@ -74,8 +76,10 @@ void KyConnectSetting::ipv4AddressConstruct(QString &ipv4Address, QString &ipv4N
|
|||
nmIpv4Address.setIp(QHostAddress(ipv4Address));
|
||||
nmIpv4Address.setGateway(QHostAddress(ipv4GateWay));
|
||||
nmIpv4Address.setNetmask(QHostAddress(ipv4NetMask));
|
||||
m_ipv4Address.clear();
|
||||
m_ipv4Address << nmIpv4Address;
|
||||
|
||||
m_ipv4Dns.clear();
|
||||
for (int index = 0; index < ipv4Dns.size(); ++index) {
|
||||
qDebug()<<"dns"<<ipv4Dns[index];
|
||||
m_ipv4Dns << QHostAddress(ipv4Dns[index]);
|
||||
|
@ -89,8 +93,10 @@ void KyConnectSetting::ipv6AddressConstruct(QString &ipv6Address, QString &ipv6N
|
|||
nmIpv6Address.setIp(QHostAddress(ipv6Address));
|
||||
nmIpv6Address.setGateway(QHostAddress(ipv6GateWay));
|
||||
nmIpv6Address.setPrefixLength(ipv6NetMask.toInt());
|
||||
m_ipv6Address.clear();
|
||||
m_ipv6Address << nmIpv6Address;
|
||||
|
||||
m_ipv6Dns.clear();
|
||||
for (int index = 0; index < ipv6Dns.size(); index++) {
|
||||
m_ipv6Dns << QHostAddress(ipv6Dns[index]);
|
||||
}
|
||||
|
@ -104,7 +110,7 @@ void KyConnectSetting::dumpInfo()
|
|||
qDebug()<<"connect name"<< m_connectName;
|
||||
qDebug()<<"iface name" << m_ifaceName;
|
||||
|
||||
for (int index = 0 ; index << m_ipv4Address.size(); index++) {
|
||||
for (int index = 0 ; index < m_ipv4Address.size(); index++) {
|
||||
qDebug()<<"ipv4 address" << m_ipv4Address.at(index).ip().toString();
|
||||
qDebug()<<"ipv4 gate way" << m_ipv4Address.at(index).gateway().toString();
|
||||
qDebug()<<"ipv4 net mask" << m_ipv4Address.at(index).netmask().toString();
|
||||
|
|
|
@ -65,6 +65,8 @@ public:
|
|||
KyIpConfigType m_ipv6ConfigIpType;
|
||||
QList<NetworkManager::IpAddress> m_ipv6Address;
|
||||
QList<QHostAddress> m_ipv6Dns;
|
||||
|
||||
bool m_isAutoConnect;
|
||||
};
|
||||
|
||||
#endif // KYLINCONNECTSETTING_H
|
||||
|
|
|
@ -51,6 +51,7 @@ KyNetworkResourceManager::KyNetworkResourceManager(QObject *parent) : QObject(pa
|
|||
connect(NetworkManager::settingsNotifier(), &NetworkManager::SettingsNotifier::connectionAdded, this, &KyNetworkResourceManager::onConnectionAdded);
|
||||
connect(NetworkManager::settingsNotifier(), &NetworkManager::SettingsNotifier::connectionRemoved, this, static_cast<void (KyNetworkResourceManager::*)(QString const &)>(&KyNetworkResourceManager::onConnectionRemoved));
|
||||
|
||||
connect(NetworkManager::notifier(), &NetworkManager::Notifier::connectivityChanged, this, &KyNetworkResourceManager::connectivityChanged);
|
||||
//todo wifi开关信号
|
||||
connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessEnabledChanged, this, &KyNetworkResourceManager::wifinEnabledChanged);
|
||||
connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessHardwareEnabledChanged, [=](){
|
||||
|
@ -483,6 +484,11 @@ bool KyNetworkResourceManager::isActivatingConnection(QString uuid)
|
|||
return false;
|
||||
}
|
||||
|
||||
void KyNetworkResourceManager::getConnectivity(NetworkManager::Connectivity &connectivity)
|
||||
{
|
||||
connectivity = NetworkManager::connectivity();
|
||||
}
|
||||
|
||||
void KyNetworkResourceManager::requestScan(NetworkManager::WirelessDevice * dev)
|
||||
{
|
||||
qDebug() <<"[KyNetworkResourceManager]"<< dev->interfaceName()<<"start scan wifi ap";
|
||||
|
|
|
@ -101,6 +101,8 @@ public:
|
|||
bool isActiveConnection(QString uuid);
|
||||
bool isActivatingConnection(QString uuid);
|
||||
|
||||
void getConnectivity(NetworkManager::Connectivity &connectivity);
|
||||
|
||||
signals:
|
||||
void connectionAdd(QString uuid);
|
||||
void connectionUpdate(QString uuid);
|
||||
|
@ -136,6 +138,8 @@ signals:
|
|||
NetworkManager::VpnConnection::State state,
|
||||
NetworkManager::VpnConnection::StateChangeReason reason);
|
||||
|
||||
void connectivityChanged(NetworkManager::Connectivity connectivity);
|
||||
|
||||
private slots:
|
||||
//connection
|
||||
void onConnectionUpdated();
|
||||
|
|
|
@ -43,6 +43,7 @@ NetworkManager::ConnectionSettings::Ptr assembleWirelessSettings(const KyWireles
|
|||
settings->setAutoconnect(connSettingInfo.isAutoConnect);
|
||||
//Note: workaround for wrongly (randomly) initialized gateway-ping-timeout
|
||||
settings->setGatewayPingTimeout(0);
|
||||
settings->setInterfaceName(connSettingInfo.m_ifaceName);
|
||||
|
||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
|
@ -235,6 +236,7 @@ void KyWirelessConnectOperation::deleteWirelessConnect(const QString &connectUui
|
|||
|
||||
QString KyWirelessConnectOperation::getPsk(const QString &connectUuid)
|
||||
{
|
||||
qDebug() << "getPsk" << connectUuid;
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(connectUuid);
|
||||
if (connectPtr.isNull()) {
|
||||
|
@ -243,13 +245,50 @@ QString KyWirelessConnectOperation::getPsk(const QString &connectUuid)
|
|||
return "";
|
||||
}
|
||||
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PSK_SETTING_NAME);
|
||||
if(!reply.isValid()) {
|
||||
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 "";
|
||||
}
|
||||
|
||||
QString KyWirelessConnectOperation::getPrivateKeyPassword(const QString &connectUuid)
|
||||
{
|
||||
qDebug() << "getPsk" << 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"))
|
||||
if (map.contains("802-1x")
|
||||
&& map.value("802-1x").contains("private-key-password")) {
|
||||
QString psk = map.value("802-1x").value("private-key-password").toString();
|
||||
return psk;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
QString KyWirelessConnectOperation::get8021xPassword(const QString &connectUuid)
|
||||
{
|
||||
qDebug() << "getPsk" << 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-1x") && map.value("802-1x").contains("password"))
|
||||
{
|
||||
QString psk = map.value("802-11-wireless-security").value("psk").toString();
|
||||
QString psk = map.value("802-1x").value("password").toString();
|
||||
return psk;
|
||||
}
|
||||
return "";
|
||||
|
@ -616,7 +655,9 @@ void KyWirelessConnectOperation::setWirelessEnabled(bool enabled)
|
|||
NetworkManager::setWirelessEnabled(enabled);
|
||||
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||
QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA);
|
||||
gsetting->set(WIRELESS_SWITCH, enabled);
|
||||
if (gsetting->get(WIRELESS_SWITCH).toBool() != enabled) {
|
||||
gsetting->set(WIRELESS_SWITCH, enabled);
|
||||
}
|
||||
} else {
|
||||
qDebug()<<"isSchemaInstalled false";
|
||||
}
|
||||
|
@ -776,14 +817,16 @@ KyKeyMgmt KyWirelessConnectOperation::getConnectKeyMgmt(const QString &uuid)
|
|||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (connectPtr.isNull()) {
|
||||
return KyKeyMgmt::Unknown;
|
||||
}
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= connectPtr->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
|
||||
// if(security_sett.isNull())
|
||||
// {
|
||||
// return KyKeyMgmt::Unknown;
|
||||
// }
|
||||
if(security_sett.isNull()) {
|
||||
return KyKeyMgmt::Unknown;
|
||||
}
|
||||
return (KyKeyMgmt)security_sett->keyMgmt();
|
||||
}
|
||||
|
||||
|
@ -803,7 +846,6 @@ void KyWirelessConnectOperation::updateWirelessSecu(NetworkManager::ConnectionSe
|
|||
}
|
||||
security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)type);
|
||||
if (bPwdChange) {
|
||||
qDebug() << "get psk " << security_sett->psk();
|
||||
security_sett->setPsk(connSettingInfo.m_psk);
|
||||
}
|
||||
return;
|
||||
|
@ -876,3 +918,36 @@ void KyWirelessConnectOperation::activateApConnectionByUuid(const QString apUuid
|
|||
|
||||
return ;
|
||||
}
|
||||
|
||||
bool KyWirelessConnectOperation::getEnterpiseEapMethod(const QString &uuid, KyEapMethodType &type)
|
||||
{
|
||||
NetworkManager::Connection::Ptr connectPtr =
|
||||
NetworkManager::findConnectionByUuid(uuid);
|
||||
if (connectPtr.isNull()) {
|
||||
qWarning() << "getEnterpiseEapMethod faild.Can't find uuid = " << uuid;
|
||||
return false;
|
||||
}
|
||||
|
||||
KyKeyMgmt keyMgmt = getConnectKeyMgmt(uuid);
|
||||
if (keyMgmt != WpaEap) {
|
||||
qWarning() << "getEnterpiseEapMethod but not WpaEap.it's " << keyMgmt;
|
||||
return false;
|
||||
}
|
||||
|
||||
NetworkManager::ConnectionSettings::Ptr connectionSettings = connectPtr->settings();
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= connectionSettings->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list = wifi_8021x_sett->eapMethods();
|
||||
|
||||
if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTls)) {
|
||||
type = TLS;
|
||||
} else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap)) {
|
||||
type = PEAP;
|
||||
} else if (list.contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls)) {
|
||||
type = TTLS;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ enum KySecuType {
|
|||
NONE = 0,
|
||||
WPA_AND_WPA2_PERSONAL,
|
||||
WPA_AND_WPA2_ENTERPRISE,
|
||||
WPA2_AND_WPA3_PERSONAL
|
||||
WPA3_PERSONAL,
|
||||
};
|
||||
|
||||
enum KyKeyMgmt {
|
||||
|
@ -27,12 +27,6 @@ enum KyKeyMgmt {
|
|||
SAE
|
||||
};
|
||||
|
||||
enum KyEapMethodType {
|
||||
TLS,
|
||||
PEAP,
|
||||
TTLS,
|
||||
};
|
||||
|
||||
class KyWirelessConnectSetting : public KyConnectSetting
|
||||
{
|
||||
// Q_OBJECT
|
||||
|
@ -65,6 +59,9 @@ public:
|
|||
//获取KeyMgmt
|
||||
KyKeyMgmt getConnectKeyMgmt(const QString &uuid);
|
||||
|
||||
//获取企业网类型
|
||||
bool getEnterpiseEapMethod(const QString &uuid, KyEapMethodType &type);
|
||||
|
||||
//激活连接
|
||||
void activeWirelessConnect(QString , QString);
|
||||
//断开连接
|
||||
|
@ -102,6 +99,8 @@ public:
|
|||
void deleteWirelessConnect(const QString &connectUuid);
|
||||
//获取密码
|
||||
QString getPsk(const QString &connectUuid);
|
||||
QString getPrivateKeyPassword(const QString &connectUuid);
|
||||
QString get8021xPassword(const QString &connectUuid);
|
||||
|
||||
//申请扫描
|
||||
void requestWirelessScan();
|
||||
|
|
|
@ -19,6 +19,7 @@ KyWirelessNetResource::KyWirelessNetResource(QObject *parent)
|
|||
qDebug()<<"KyWirelessNetResource";
|
||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
m_connectResource = new KyConnectResourse(this);
|
||||
m_operation = new KyWirelessConnectOperation(this);
|
||||
|
||||
kyWirelessNetItemListInit();
|
||||
|
||||
|
@ -74,16 +75,18 @@ bool KyWirelessNetResource::getWifiNetwork(const QString &devIfaceName, const QS
|
|||
// onWifiNetworkDeviceDisappear();
|
||||
|
||||
if (!m_WifiNetworkList.contains(devIfaceName)) {
|
||||
qDebug() << "getWifiNetwork fail,not contain " << devIfaceName;
|
||||
return false;
|
||||
} else {
|
||||
for (int index = 0; index < m_WifiNetworkList[devIfaceName].size(); index ++){
|
||||
if (m_WifiNetworkList[devIfaceName].at(index).m_NetSsid == ssid) {
|
||||
wirelessNetResource = m_WifiNetworkList[devIfaceName].at(index);
|
||||
qDebug() << "getWifiNetwork success";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "getWifiNetwork fail,not contain " << ssid;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -346,13 +349,13 @@ bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsIn
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
info.identity = setting->identity();
|
||||
info.domain = setting->domainSuffixMatch();
|
||||
|
||||
info.caCertPath = setting->caPath();
|
||||
info.clientCertPath = setting->clientCertificate();
|
||||
info.clientPrivateKey = QString(setting->privateKey());
|
||||
info.clientPrivateKeyPWD = setting->privateKeyPassword();
|
||||
info.clientPrivateKeyPWD = m_operation->getPrivateKeyPassword(conn->uuid());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -382,7 +385,7 @@ bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeap
|
|||
|
||||
info.phase2AuthMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod();
|
||||
info.userName = setting->identity();
|
||||
info.userPWD = setting->password();
|
||||
info.userPWD = m_operation->get8021xPassword(conn->uuid());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -422,7 +425,8 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls
|
|||
info.authType = KyTtlsAuthMethod::AUTH_NO_EAP;
|
||||
}
|
||||
info.userName = setting->identity();
|
||||
info.userPWD = setting->password();
|
||||
info.userPWD = m_operation->get8021xPassword(conn->uuid());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "kylinnetworkresourcemanager.h"
|
||||
#include "kyenterpricesettinginfo.h"
|
||||
#include "kylinconnectresource.h"
|
||||
#include "kywirelessconnectoperation.h"
|
||||
|
||||
|
||||
//class KyWirelessNetItem;
|
||||
|
@ -59,6 +60,7 @@ signals:
|
|||
private:
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
KyConnectResourse *m_connectResource = nullptr;
|
||||
KyWirelessConnectOperation *m_operation = nullptr;
|
||||
QMap<QString, QList<KyWirelessNetItem> > m_WifiNetworkList;
|
||||
|
||||
};
|
||||
|
|
|
@ -21,63 +21,6 @@ const QByteArray GSETTINGS_SCHEMA_KYLIN_NM = "org.ukui.kylin-nm.switch";
|
|||
const QString KEY_WIRELESS_SWITCH = "wirelessswitch";
|
||||
const QString KEY_WIRED_SWITCH = "wiredswitch";
|
||||
|
||||
void saveDeviceEnableState(QString deviceName, bool enable)
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("CARDEABLE");
|
||||
m_settings->setValue(deviceName, enable);
|
||||
m_settings->endGroup();
|
||||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
void getDeviceEnableState(int type, QMap<QString, bool> &map)
|
||||
{
|
||||
map.clear();
|
||||
if (!QFile::exists(CONFIG_FILE_PATH)) {
|
||||
return;
|
||||
}
|
||||
if (type != WIRED && type != WIRELESS) {
|
||||
qDebug() << "getDeviceEnableState but wrong type";
|
||||
return;
|
||||
}
|
||||
|
||||
KyNetworkDeviceResourse * kdr = new KyNetworkDeviceResourse();
|
||||
QStringList wiredDevList,wirelessDevList;
|
||||
wiredDevList.clear();
|
||||
wirelessDevList.clear();
|
||||
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("CARDEABLE");
|
||||
|
||||
if (type == WIRED) {
|
||||
kdr->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDevList);
|
||||
if (!wiredDevList.isEmpty()) {
|
||||
for (int i = 0; i < wiredDevList.size(); ++i) {
|
||||
bool enable = m_settings->value(wiredDevList.at(i), true).toBool();
|
||||
map.insert(wiredDevList.at(i), enable);
|
||||
}
|
||||
}
|
||||
} else if (type == WIRELESS) {
|
||||
kdr->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDevList);
|
||||
if (!wirelessDevList.isEmpty()) {
|
||||
for (int i = 0; i < wirelessDevList.size(); ++i) {
|
||||
bool enable = m_settings->value(wirelessDevList.at(i), true).toBool();
|
||||
map.insert(wirelessDevList.at(i), enable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_settings->endGroup();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
delete kdr;
|
||||
kdr = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of adaptor class DbusAdaptor
|
||||
*/
|
||||
|
@ -143,6 +86,7 @@ void DbusAdaptor::setWirelessSwitchEnable(bool enable)
|
|||
//启用/禁用网卡
|
||||
void DbusAdaptor::setDeviceEnable(QString devName, bool enable)
|
||||
{
|
||||
parent()->setWiredDeviceEnable(devName, enable);
|
||||
saveDeviceEnableState(devName, enable);
|
||||
}
|
||||
|
||||
|
@ -227,15 +171,13 @@ QMap<QString, bool> DbusAdaptor::getDeviceListAndEnabled(int devType)
|
|||
//唤起属性页 根据网卡类型 参数2 为ssid/uuid
|
||||
void DbusAdaptor::showPropertyWidget(QString devName, QString ssid)
|
||||
{
|
||||
//todo
|
||||
//parent()->showPropertyWidget(devName,ssid);
|
||||
parent()->showPropertyWidget(devName,ssid);
|
||||
}
|
||||
|
||||
//唤起新建有线连接界面
|
||||
void DbusAdaptor::showCreateWiredConnectWidget(QString devName, QString connectionName)
|
||||
void DbusAdaptor::showCreateWiredConnectWidget(QString devName)
|
||||
{
|
||||
//todo
|
||||
//parent()->showCreateWiredConnectWidget(devName,connectionName);
|
||||
parent()->showCreateWiredConnectWidget(devName);
|
||||
}
|
||||
|
||||
//开启热点
|
||||
|
|
|
@ -51,11 +51,11 @@ public Q_SLOTS: // METHODS
|
|||
QMap<QString, QVector<QStringList> > getWirelessList();
|
||||
//有线列表
|
||||
QMap<QString, QVector<QStringList>> getWiredList();
|
||||
//有线开关
|
||||
//有线总开关
|
||||
Q_NOREPLY void setWiredSwitchEnable(bool enable);
|
||||
//无线开关
|
||||
//无线总开关
|
||||
Q_NOREPLY void setWirelessSwitchEnable(bool enable);
|
||||
//启用/禁用网卡
|
||||
//有线网卡开关
|
||||
Q_NOREPLY void setDeviceEnable(QString devName, bool enable);
|
||||
//设置默认网卡
|
||||
Q_NOREPLY void setDefaultWiredDevice(QString deviceName);
|
||||
|
@ -71,7 +71,7 @@ public Q_SLOTS: // METHODS
|
|||
//唤起属性页 根据网卡类型 参数2 为ssid/uuid
|
||||
Q_NOREPLY void showPropertyWidget(QString devName, QString ssid);
|
||||
//唤起新建有线连接界面
|
||||
Q_NOREPLY void showCreateWiredConnectWidget(QString devName, QString connectionName);
|
||||
Q_NOREPLY void showCreateWiredConnectWidget(QString devName);
|
||||
//开启热点
|
||||
void activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
|
||||
//断开热点
|
||||
|
@ -79,9 +79,15 @@ public Q_SLOTS: // METHODS
|
|||
//获取热点
|
||||
QStringList getStoredApInfo();
|
||||
Q_SIGNALS: // SIGNALS
|
||||
void wirelessActivating(QString devName, QString ssid);
|
||||
void wiredActivating(QString devName, QString ssid);
|
||||
void listUpdate(QString devName);
|
||||
// void wirelessActivating(QString devName, QString ssid);
|
||||
// void wiredActivating(QString devName, QString ssid);
|
||||
void lanAdd(QString devName, QStringList info);
|
||||
void lanRemove(QString dbusPath);
|
||||
void lanUpdate(QString devName, QStringList info);
|
||||
void wlanAdd(QString devName, QStringList info);
|
||||
void wlanRemove(QString devName,QString ssid);
|
||||
void wlanactiveConnectionStateChanged(QString devName, QString ssid, int status);
|
||||
void lanActiveConnectionStateChanged(QString devName, QString uuid, int status);
|
||||
//仅失败,若成功直接发listUpdate
|
||||
void activateFailed(QString errorMessage);
|
||||
void deactivateFailed(QString errorMessage);
|
||||
|
@ -92,6 +98,11 @@ Q_SIGNALS: // SIGNALS
|
|||
void hotspotDeactivated(QString devName, QString ssid);
|
||||
//热点连接
|
||||
void hotspotActivated(QString devName, QString ssid);
|
||||
|
||||
//信号强度变化
|
||||
void signalStrengthChange(QString devName, QString ssid, int strength);
|
||||
//安全性变化
|
||||
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -107,7 +107,7 @@ void LanListItem::onInfoButtonClicked()
|
|||
if(m_data){
|
||||
qDebug()<<"Net active or not:"<<m_isActive;
|
||||
qDebug() << "On lan info button clicked! uuid = " << m_data->m_connectUuid << "; name = " << m_data->m_connectName << "." <<Q_FUNC_INFO << __LINE__;
|
||||
NetDetail *netDetail = new NetDetail(m_data->m_connectName, m_data->m_connectUuid, m_isActive,false, false);
|
||||
NetDetail *netDetail = new NetDetail(deviceName, m_data->m_connectName, m_data->m_connectUuid, m_isActive,false, false, this);
|
||||
netDetail->show();
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
KyConnectItem *m_data = nullptr;
|
||||
KyWiredConnectOperation *m_connectOperation = nullptr;
|
||||
|
||||
QString deviceName = nullptr;
|
||||
QString deviceName = "";
|
||||
void refreshIcon();
|
||||
|
||||
protected:
|
||||
|
@ -29,7 +29,6 @@ protected:
|
|||
|
||||
private:
|
||||
|
||||
|
||||
private slots:
|
||||
void onInfoButtonClicked();
|
||||
void onNetButtonClicked();
|
||||
|
|
|
@ -241,7 +241,7 @@ void WlanListItem::onInfoButtonClicked()
|
|||
if(m_data){
|
||||
qDebug()<<"Net active or not:"<<m_isActive;
|
||||
qDebug() << "On wlan info button clicked! ssid = " << m_data->m_NetSsid << "; name = " << m_data->m_connName << "." <<Q_FUNC_INFO << __LINE__;
|
||||
NetDetail *netDetail = new NetDetail(m_data->m_NetSsid, m_data->m_connectUuid,m_isActive, true, false);
|
||||
NetDetail *netDetail = new NetDetail(m_wlanDevice, m_data->m_NetSsid, m_data->m_connectUuid, m_isActive, true, !m_data->m_isConfigured, this);
|
||||
netDetail->show();
|
||||
}
|
||||
else{
|
||||
|
@ -365,8 +365,8 @@ void WlanListItem::onConnectionAdd(QString deviceName, QString ssid)
|
|||
if (!m_data) {
|
||||
return;
|
||||
}
|
||||
if (ssid == m_data->m_NetSsid) {
|
||||
m_data->m_isConfigured = true;
|
||||
if (ssid == m_data->m_NetSsid && deviceName == m_wlanDevice) {
|
||||
m_resource->getWifiNetwork(deviceName, ssid, *m_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,8 +375,8 @@ void WlanListItem::onConnectionRemove(QString deviceName, QString ssid)
|
|||
if (!m_data) {
|
||||
return;
|
||||
}
|
||||
if (ssid == m_data->m_NetSsid) {
|
||||
m_data->m_isConfigured = false;
|
||||
if (ssid == m_data->m_NetSsid && deviceName == m_wlanDevice) {
|
||||
m_resource->getWifiNetwork(deviceName, ssid, *m_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
HEADERS += \
|
||||
$$PWD/netdetails/coninfo.h \
|
||||
$$PWD/netdetails/creatnetpage.h \
|
||||
$$PWD/netdetails/customtabstyle.h \
|
||||
$$PWD/netdetails/detailpage.h \
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
#ifndef CONINFO_H
|
||||
#define CONINFO_H
|
||||
|
||||
#include <QString>
|
||||
#include "kywirelessnetitem.h"
|
||||
#include "kylinconnectresource.h"
|
||||
#include "kylinactiveconnectresource.h"
|
||||
#include "kywirelessconnectoperation.h"
|
||||
#include "kywirelessnetresource.h"
|
||||
#include "kyenterpricesettinginfo.h"
|
||||
|
||||
#define AUTO_CONFIG 0
|
||||
#define MANUAL_CONFIG 1
|
||||
|
||||
enum TtlsInnerType
|
||||
{
|
||||
PAP = 0,
|
||||
MSCHAP,
|
||||
MSCHAPV2_EAP,
|
||||
MSCHAPV2,
|
||||
CHAP,
|
||||
MD5_EAP,
|
||||
GTC_EAP
|
||||
};
|
||||
|
||||
class ConInfo {
|
||||
public:
|
||||
QString strConName;
|
||||
QString strConType;
|
||||
QString strSecType;
|
||||
KySecuType secType = WPA_AND_WPA2_PERSONAL;
|
||||
QString strPassword;
|
||||
QString strChan;
|
||||
QString strMac;
|
||||
QString strHz;
|
||||
QString strBandWidth;
|
||||
QString strDynamicIpv4;
|
||||
QString strDynamicIpv6;
|
||||
QString strDynamicIpv4Dns;
|
||||
bool isAutoConnect = false;
|
||||
|
||||
KyIpConfigType ipv4ConfigType = CONFIG_IP_DHCP;
|
||||
QString strIPV4Address;
|
||||
QString strIPV4NetMask;
|
||||
QString strIPV4FirDns;
|
||||
QString strIPV4SecDns;
|
||||
QString strIPV4GateWay;
|
||||
|
||||
KyIpConfigType ipv6ConfigType = CONFIG_IP_DHCP;
|
||||
QString strIPV6Address;
|
||||
QString strIPV6Prefix;
|
||||
QString strIPV6FirDns;
|
||||
QString strIPV6SecDns;
|
||||
QString strIPV6GateWay;
|
||||
|
||||
KyEapMethodType enterpriseType;
|
||||
KyEapMethodTlsInfo tlsInfo;
|
||||
KyEapMethodPeapInfo peapInfo;
|
||||
KyEapMethodTtlsInfo ttlsInfo;
|
||||
};
|
||||
#endif // CONINFO_H
|
|
@ -1,6 +1,187 @@
|
|||
#include "creatnetpage.h"
|
||||
|
||||
CreatNetPage::CreatNetPage(QWidget *parent) : QFrame(parent)
|
||||
|
||||
|
||||
CreatNetPage::CreatNetPage(QWidget *parent):QFrame(parent)
|
||||
{
|
||||
initUI();
|
||||
initComponent();
|
||||
}
|
||||
|
||||
void CreatNetPage::initUI()
|
||||
{
|
||||
connNameEdit = new QLineEdit(this);
|
||||
ipv4ConfigCombox = new QComboBox(this);
|
||||
ipv4addressEdit = new QLineEdit(this);
|
||||
netMaskEdit = new QLineEdit(this);
|
||||
gateWayEdit = new QLineEdit(this);
|
||||
firstDnsEdit = new QLineEdit(this);
|
||||
secondDnsEdit = new QLineEdit(this);
|
||||
|
||||
m_connNameLabel = new QLabel(this);
|
||||
m_configLabel = new QLabel(this);
|
||||
m_addressLabel = new QLabel(this);
|
||||
m_maskLabel = new QLabel(this);
|
||||
m_gateWayLabel = new QLabel(this);
|
||||
m_dnsLabel = new QLabel(this);
|
||||
m_secDnsLabel = new QLabel(this);
|
||||
|
||||
m_connNameLabel->setText(tr("Connection Name"));
|
||||
m_configLabel->setText(tr("Ipv4Config"));
|
||||
m_addressLabel->setText(tr("Address"));
|
||||
m_maskLabel->setText(tr("Netmask"));
|
||||
m_gateWayLabel->setText(tr("Default Gateway"));
|
||||
m_dnsLabel->setText(tr("Prefs DNS"));
|
||||
m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||
|
||||
m_detailLayout = new QFormLayout(this);
|
||||
m_detailLayout->addRow(m_connNameLabel,connNameEdit);
|
||||
m_detailLayout->addRow(m_configLabel,ipv4ConfigCombox);
|
||||
m_detailLayout->addRow(m_addressLabel,ipv4addressEdit);
|
||||
m_detailLayout->addRow(m_maskLabel,netMaskEdit);
|
||||
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
|
||||
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
|
||||
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
|
||||
|
||||
ipv4ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
|
||||
ipv4ConfigCombox->addItem(tr("Manual")); //"手动"
|
||||
|
||||
|
||||
// IP的正则格式限制
|
||||
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
|
||||
|
||||
ipv4addressEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
gateWayEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
netMaskEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
}
|
||||
|
||||
void CreatNetPage::initComponent() {
|
||||
if (ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
setLineEnabled(false);
|
||||
} else if (ipv4ConfigCombox->currentIndex() == MANUAL_CONFIG) {
|
||||
setLineEnabled(true);
|
||||
}
|
||||
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int)));
|
||||
|
||||
connect(connNameEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
}
|
||||
|
||||
bool CreatNetPage::checkConnectBtnIsEnabled()
|
||||
{
|
||||
if (connNameEdit->text().isEmpty()) {
|
||||
qDebug() << "create connName empty or invalid";
|
||||
return false;
|
||||
}
|
||||
qDebug() << "checkConnectBtnIsEnabled currentIndex" << ipv4ConfigCombox->currentIndex();
|
||||
if (ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
return true;
|
||||
} else {
|
||||
if (ipv4addressEdit->text().isEmpty() || !getTextEditState(ipv4addressEdit->text())) {
|
||||
qDebug() << "create ipv4address empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (netMaskEdit->text().isEmpty() || !getTextEditState(netMaskEdit->text())) {
|
||||
qDebug() << "create ipv4 netMask empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gateWayEdit->text().isEmpty() || !getTextEditState(gateWayEdit->text())) {
|
||||
qDebug() << "create ipv4 gateway empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
|
||||
qDebug() << "create ipv4 dns sort invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getTextEditState(firstDnsEdit->text())) {
|
||||
qDebug() << "create ipv4 first dns invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getTextEditState(secondDnsEdit->text())) {
|
||||
qDebug() << "create ipv4 second dns invalid";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CreatNetPage::configChanged(int index) {
|
||||
if (index == AUTO_CONFIG) {
|
||||
setLineEnabled(false);
|
||||
}
|
||||
if (index == MANUAL_CONFIG) {
|
||||
setLineEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CreatNetPage::setLineEnabled(bool check) {
|
||||
|
||||
ipv4addressEdit->setEnabled(check);
|
||||
netMaskEdit->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
firstDnsEdit->setEnabled(check);
|
||||
secondDnsEdit->setEnabled(check);
|
||||
|
||||
if (!check) {
|
||||
ipv4addressEdit->clear();
|
||||
netMaskEdit->clear();
|
||||
gateWayEdit->clear();
|
||||
firstDnsEdit->clear();
|
||||
secondDnsEdit->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void CreatNetPage::setEnableOfSaveBtn() {
|
||||
emit setCreatePageState(checkConnectBtnIsEnabled());
|
||||
}
|
||||
|
||||
bool CreatNetPage::getTextEditState(QString text)
|
||||
{
|
||||
if (text.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
|
||||
|
||||
bool match = false;
|
||||
match = rx.exactMatch(text);
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
void CreatNetPage::constructIpv4Info(KyConnectSetting &setting)
|
||||
{
|
||||
setting.m_connectName = connNameEdit->text();
|
||||
QString ipv4address =ipv4addressEdit->text();
|
||||
QString netMask = netMaskEdit->text();
|
||||
QString gateWay = gateWayEdit->text();
|
||||
qDebug() << "constructIpv4Info: " << "ipv4address " << ipv4address
|
||||
<< " netMask " << netMask
|
||||
<< " gateWay " << gateWay;
|
||||
|
||||
QStringList dnsList;
|
||||
dnsList.empty();
|
||||
if (!firstDnsEdit->text().isEmpty()) {
|
||||
dnsList << firstDnsEdit->text();
|
||||
if (!secondDnsEdit->text().isEmpty()) {
|
||||
dnsList << secondDnsEdit->text();
|
||||
}
|
||||
}
|
||||
if (ipv4ConfigCombox->currentData() == AUTO_CONFIG) {
|
||||
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP);
|
||||
} else {
|
||||
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL);
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,13 +2,58 @@
|
|||
#define CREATNETPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
#include <QLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QPainter>
|
||||
#include <QScrollArea>
|
||||
#include <QSpacerItem>
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QDebug>
|
||||
|
||||
#include "coninfo.h"
|
||||
|
||||
class CreatNetPage : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CreatNetPage(QWidget *parent = nullptr);
|
||||
|
||||
void constructIpv4Info(KyConnectSetting &setting);
|
||||
private:
|
||||
QLineEdit *connNameEdit;
|
||||
QComboBox *ipv4ConfigCombox;
|
||||
QLineEdit *ipv4addressEdit;
|
||||
QLineEdit *netMaskEdit;
|
||||
QLineEdit *gateWayEdit;
|
||||
QLineEdit *firstDnsEdit;
|
||||
QLineEdit *secondDnsEdit;
|
||||
|
||||
private:
|
||||
QFormLayout *m_detailLayout;
|
||||
QVBoxLayout *mvBoxLayout;
|
||||
QLabel *m_connNameLabel;
|
||||
QLabel *m_configLabel;
|
||||
QLabel *m_addressLabel;
|
||||
QLabel *m_maskLabel;
|
||||
QLabel *m_gateWayLabel;
|
||||
QLabel *m_dnsLabel;
|
||||
QLabel *m_secDnsLabel;
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
void setLineEnabled(bool check);
|
||||
void configSave();
|
||||
bool getTextEditState(QString text);
|
||||
bool checkConnectBtnIsEnabled();
|
||||
|
||||
private slots:
|
||||
void setEnableOfSaveBtn();
|
||||
void configChanged(int index);
|
||||
Q_SIGNALS:
|
||||
void setCreatePageState(bool);
|
||||
|
||||
};
|
||||
|
||||
#endif // CREATNETPAGE_H
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
|
||||
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
||||
|
||||
DetailPage::DetailPage(bool isWlan, QWidget *parent)
|
||||
: mIsWlan(isWlan), QFrame(parent)
|
||||
DetailPage::DetailPage(bool isWlan, bool isCreate, QWidget *parent)
|
||||
: mIsWlan(isWlan), isCreate(isCreate), QFrame(parent)
|
||||
{
|
||||
this->setFrameShape(QFrame::Shape::StyledPanel);
|
||||
this->setMaximumWidth(960);
|
||||
initUI();
|
||||
initComponent();
|
||||
if (isCreate) {
|
||||
connect(mSSID, &QLineEdit::textEdited, this, &DetailPage::setEnableOfSaveBtn);
|
||||
}
|
||||
}
|
||||
|
||||
void DetailPage::setSSID(const QString &ssid) {
|
||||
|
@ -51,16 +53,39 @@ void DetailPage::setMac(const QString &mac) {
|
|||
this->mMac->setText(mac);
|
||||
}
|
||||
|
||||
void DetailPage::setAutoConnect(bool flag)
|
||||
{
|
||||
this->forgetNetBox->setChecked(flag);
|
||||
}
|
||||
|
||||
void DetailPage::getSsid(QString &ssid)
|
||||
{
|
||||
ssid = mSSID->text();
|
||||
}
|
||||
|
||||
bool DetailPage::checkIsChanged(const ConInfo info)
|
||||
{
|
||||
if (info.isAutoConnect != forgetNetBox->isChecked()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void DetailPage::initUI() {
|
||||
forgetNetBox = new QCheckBox(this);
|
||||
layout = new QVBoxLayout(this);
|
||||
|
||||
mDetailLayout = new QFormLayout(this);
|
||||
|
||||
mSSID = new QLabel(this);
|
||||
QHBoxLayout *mSSIDLayout = new QHBoxLayout(this);
|
||||
mSSIDLayout->addStretch();
|
||||
mSSIDLayout->addWidget(mSSID);
|
||||
mSSID = new QLineEdit(this);
|
||||
mSSID->setAlignment(Qt::AlignRight);
|
||||
if (!isCreate) {
|
||||
mSSID->setStyleSheet("background:transparent;border-width:0;border-style:outset");
|
||||
mSSID->setFocusPolicy(Qt::NoFocus);
|
||||
} else {
|
||||
mSSID->setStyleSheet("border-width:0;border-style:outset");
|
||||
}
|
||||
|
||||
mProtocol = new QLabel(this);
|
||||
QHBoxLayout *mProtocolLayout = new QHBoxLayout(this);
|
||||
|
@ -118,7 +143,7 @@ void DetailPage::initUI() {
|
|||
mAutoLayout->addWidget(autoConnect);
|
||||
mAutoLayout->addSpacerItem(horizontalSpacer);
|
||||
|
||||
mDetailLayout->addRow(tr("SSID:"), mSSIDLayout);
|
||||
mDetailLayout->addRow(tr("SSID:"), mSSID);
|
||||
mDetailLayout->addRow(tr("Protocol:"), mProtocolLayout);
|
||||
if (mIsWlan) {
|
||||
mDetailLayout->addRow(tr("Security Type:"), mSecTypeLayout);
|
||||
|
@ -136,10 +161,7 @@ void DetailPage::initUI() {
|
|||
layout->addLayout(mAutoLayout);
|
||||
|
||||
}
|
||||
void DetailPage::initComponent() {
|
||||
connect(forgetNetBox, SIGNAL(toggled(bool)), this, SLOT(setNetStatus(bool)));
|
||||
}
|
||||
|
||||
void DetailPage::setNetStatus(bool checked) {
|
||||
|
||||
void DetailPage::setEnableOfSaveBtn() {
|
||||
emit setDetailPageState(!mSSID->text().isEmpty());
|
||||
}
|
||||
|
|
|
@ -7,11 +7,14 @@
|
|||
#include <QCheckBox>
|
||||
#include <QSpacerItem>
|
||||
#include <QDebug>
|
||||
|
||||
#include "coninfo.h"
|
||||
|
||||
class DetailPage : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DetailPage(bool isWlan, QWidget *parent = nullptr);
|
||||
DetailPage(bool isWlan, bool isCreate = false, QWidget *parent = nullptr);
|
||||
|
||||
void setSSID(const QString &ssid);
|
||||
void setProtocol(const QString &protocol);
|
||||
|
@ -23,13 +26,17 @@ public:
|
|||
void setIpv4Dns(const QString &ipv4Dns);
|
||||
void setIpv6(const QString &ipv6);
|
||||
void setMac(const QString &mac);
|
||||
void setAutoConnect(bool flag);
|
||||
|
||||
bool checkIsChanged(const ConInfo info);
|
||||
|
||||
void getSsid(QString &ssid);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
|
||||
public:
|
||||
QLabel *mSSID;
|
||||
QLineEdit *mSSID;
|
||||
QLabel *mProtocol;
|
||||
QLabel *mSecType;
|
||||
QLabel *mHz;
|
||||
|
@ -48,8 +55,12 @@ private:
|
|||
QHBoxLayout *mAutoLayout;
|
||||
QCheckBox *forgetNetBox;
|
||||
bool mIsWlan;
|
||||
bool isCreate;
|
||||
private slots:
|
||||
void setNetStatus(bool checked);
|
||||
void setEnableOfSaveBtn();
|
||||
|
||||
signals:
|
||||
void setDetailPageState(bool);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "ipv4page.h"
|
||||
#include "netdetail.h"
|
||||
Ipv4Page::Ipv4Page(bool isWlan, QWidget *parent)
|
||||
: isWlan(isWlan), QFrame(parent)
|
||||
|
||||
Ipv4Page::Ipv4Page(QWidget *parent):QFrame(parent)
|
||||
{
|
||||
initUI();
|
||||
initComponent();
|
||||
|
@ -10,10 +10,10 @@ Ipv4Page::Ipv4Page(bool isWlan, QWidget *parent)
|
|||
void Ipv4Page::initUI() {
|
||||
ipv4ConfigCombox = new QComboBox(this);
|
||||
ipv4addressEdit = new QLineEdit(this);
|
||||
netMaskCombox = new QComboBox(this);
|
||||
netMaskEdit = new QLineEdit(this);
|
||||
gateWayEdit = new QLineEdit(this);
|
||||
firstDnsEidt = new QLineEdit(this);
|
||||
secondDnsEidt = new QLineEdit(this);
|
||||
firstDnsEdit = new QLineEdit(this);
|
||||
secondDnsEdit = new QLineEdit(this);
|
||||
|
||||
m_configLabel = new QLabel(this);
|
||||
m_addressLabel = new QLabel(this);
|
||||
|
@ -32,27 +32,30 @@ void Ipv4Page::initUI() {
|
|||
m_detailLayout = new QFormLayout(this);
|
||||
m_detailLayout->addRow(m_configLabel,ipv4ConfigCombox);
|
||||
m_detailLayout->addRow(m_addressLabel,ipv4addressEdit);
|
||||
m_detailLayout->addRow(m_maskLabel,netMaskCombox);
|
||||
m_detailLayout->addRow(m_maskLabel,netMaskEdit);
|
||||
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
|
||||
m_detailLayout->addRow(m_dnsLabel,firstDnsEidt);
|
||||
m_detailLayout->addRow(m_secDnsLabel,secondDnsEidt);
|
||||
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
|
||||
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
|
||||
|
||||
ipv4ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
|
||||
ipv4ConfigCombox->addItem(tr("Manual")); //"手动"
|
||||
|
||||
netMaskCombox->addItem("255.255.255.0"); //24
|
||||
netMaskCombox->addItem("255.255.254.0"); //23
|
||||
netMaskCombox->addItem("255.255.252.0"); //22
|
||||
netMaskCombox->addItem("255.255.0.0"); //16
|
||||
netMaskCombox->addItem("255.0.0.0"); //8
|
||||
// netMaskCombox->addItem("");
|
||||
// netMaskCombox->addItem("255.255.255.0"); //24
|
||||
// netMaskCombox->addItem("255.255.254.0"); //23
|
||||
// netMaskCombox->addItem("255.255.252.0"); //22
|
||||
// netMaskCombox->addItem("255.255.0.0"); //16
|
||||
// netMaskCombox->addItem("255.0.0.0"); //8
|
||||
|
||||
|
||||
// IP的正则格式限制
|
||||
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
|
||||
|
||||
ipv4addressEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
gateWayEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
firstDnsEidt->setValidator(new QRegExpValidator(rx, this));
|
||||
secondDnsEidt->setValidator(new QRegExpValidator(rx, this));
|
||||
setEnableOfSaveBtn();
|
||||
netMaskEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
}
|
||||
|
||||
void Ipv4Page::initComponent() {
|
||||
|
@ -62,12 +65,17 @@ void Ipv4Page::initComponent() {
|
|||
setLineEnabled(true);
|
||||
}
|
||||
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int)));
|
||||
// connect(mNetMask, SIGNAL(currentIndexChanged(int)), this, SLOT(cbMaskChanged(int)));
|
||||
|
||||
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
}
|
||||
|
||||
void Ipv4Page::setIpv4Config(const QString &ipv4Config)
|
||||
void Ipv4Page::setIpv4Config(KyIpConfigType ipv4Config)
|
||||
{
|
||||
if (ipv4Config.toInt() == AUTO_CONFIG) {
|
||||
if (ipv4Config == CONFIG_IP_MANUAL) {
|
||||
ipv4ConfigCombox->setCurrentIndex(MANUAL_CONFIG);
|
||||
} else {
|
||||
ipv4ConfigCombox->setCurrentIndex(AUTO_CONFIG);
|
||||
|
@ -79,14 +87,19 @@ void Ipv4Page::setIpv4(const QString &ipv4)
|
|||
ipv4addressEdit->setText(ipv4);
|
||||
}
|
||||
|
||||
void Ipv4Page::setNetMask(const QString &netMask)
|
||||
{
|
||||
netMaskEdit->setText(netMask);
|
||||
}
|
||||
|
||||
void Ipv4Page::setIpv4FirDns(const QString &ipv4FirDns)
|
||||
{
|
||||
firstDnsEidt->setText(ipv4FirDns);
|
||||
firstDnsEdit->setText(ipv4FirDns);
|
||||
}
|
||||
|
||||
void Ipv4Page::setIpv4SecDns(const QString &ipv4SecDns)
|
||||
{
|
||||
secondDnsEidt->setText(ipv4SecDns);
|
||||
secondDnsEdit->setText(ipv4SecDns);
|
||||
}
|
||||
|
||||
void Ipv4Page::setGateWay(const QString &gateWay)
|
||||
|
@ -94,6 +107,88 @@ void Ipv4Page::setGateWay(const QString &gateWay)
|
|||
gateWayEdit->setText(gateWay);
|
||||
}
|
||||
|
||||
bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
||||
{
|
||||
bool isChanged = false;
|
||||
if (ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
if (info.ipv4ConfigType != CONFIG_IP_DHCP) {
|
||||
qDebug() << "ipv4ConfigType change to Auto";
|
||||
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP);
|
||||
isChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (info.ipv4ConfigType != CONFIG_IP_MANUAL) {
|
||||
qDebug() << "ipv4ConfigType change to Manual";
|
||||
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL);
|
||||
isChanged = true;
|
||||
}
|
||||
if(info.strIPV4Address != ipv4addressEdit->text()
|
||||
|| info.strIPV4NetMask != netMaskEdit->text()
|
||||
|| info.strIPV4GateWay != gateWayEdit->text()
|
||||
|| info.strIPV4FirDns != firstDnsEdit->text()
|
||||
|| info.strIPV4SecDns != secondDnsEdit->text()) {
|
||||
|
||||
qDebug() << "ipv4 info changed";
|
||||
QStringList dnsList;
|
||||
dnsList.empty();
|
||||
if (!firstDnsEdit->text().isEmpty()) {
|
||||
dnsList << firstDnsEdit->text();
|
||||
if (!secondDnsEdit->text().isEmpty()) {
|
||||
dnsList << secondDnsEdit->text();
|
||||
}
|
||||
}
|
||||
|
||||
QString ipv4address =ipv4addressEdit->text();
|
||||
QString netMask = netMaskEdit->text();
|
||||
QString gateWay = gateWayEdit->text();
|
||||
qDebug() << ipv4address << netMask << gateWay;
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList);
|
||||
setting.dumpInfo();
|
||||
isChanged = true;
|
||||
}
|
||||
}
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
bool Ipv4Page::checkConnectBtnIsEnabled()
|
||||
{
|
||||
qDebug() << "checkConnectBtnIsEnabled currentIndex" << ipv4ConfigCombox->currentIndex();
|
||||
if (ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
return true;
|
||||
} else {
|
||||
if (ipv4addressEdit->text().isEmpty() || !getTextEditState(ipv4addressEdit->text())) {
|
||||
qDebug() << "ipv4address empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (netMaskEdit->text().isEmpty() || !getTextEditState(netMaskEdit->text())) {
|
||||
qDebug() << "ipv4 netMask empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gateWayEdit->text().isEmpty() || !getTextEditState(gateWayEdit->text())) {
|
||||
qDebug() << "ipv4 gateway empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
|
||||
qDebug() << "ipv4 dns sort invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getTextEditState(firstDnsEdit->text())) {
|
||||
qDebug() << "ipv4 first dns invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getTextEditState(secondDnsEdit->text())) {
|
||||
qDebug() << "ipv4 second dns invalid";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Ipv4Page::configChanged(int index) {
|
||||
if (index == AUTO_CONFIG) {
|
||||
setLineEnabled(false);
|
||||
|
@ -104,54 +199,36 @@ void Ipv4Page::configChanged(int index) {
|
|||
}
|
||||
|
||||
void Ipv4Page::setLineEnabled(bool check) {
|
||||
m_addressLabel->setEnabled(check);
|
||||
m_maskLabel->setEnabled(check);
|
||||
m_gateWayLabel->setEnabled(check);
|
||||
m_dnsLabel->setEnabled(check);
|
||||
m_secDnsLabel->setEnabled(check);
|
||||
|
||||
ipv4addressEdit->setEnabled(check);
|
||||
netMaskCombox->setEnabled(check);
|
||||
netMaskEdit->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
firstDnsEidt->setEnabled(check);
|
||||
secondDnsEidt->setEnabled(check);
|
||||
}
|
||||
firstDnsEdit->setEnabled(check);
|
||||
secondDnsEdit->setEnabled(check);
|
||||
|
||||
void Ipv4Page::setEnableOfSaveBtn() {
|
||||
if (ipv4ConfigCombox->currentIndex() == 1) {
|
||||
// if (mIpv4address->text().isEmpty()) {
|
||||
// //当ipv4和ipv6地址均未设置时,禁止保存
|
||||
// emit setBtnEnableFalse();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!ui->leAddr->text().isEmpty() && !this->getTextEditState(ui->leAddr->text()) ) {
|
||||
// emit setBtnEnableFalse();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!ui->leGateway->text().isEmpty() && !this->getTextEditState(ui->leGateway->text()) ) {
|
||||
// emit setBtnEnableFalse();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!ui->leDns->text().isEmpty() && !this->getTextEditState(ui->leDns->text()) ) {
|
||||
// emit setBtnEnableFalse();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!ui->leAddr_ipv6->text().isEmpty() && ! this->getIpv6EditState(ui->leAddr_ipv6->text())) {
|
||||
// emit setBtnEnableFalse();
|
||||
// return;
|
||||
// }
|
||||
// if(ui->leDns2->text().isEmpty()){
|
||||
|
||||
// }else{
|
||||
// if(!this->getTextEditState(ui->leDns2->text())){
|
||||
// emit setBtnEnableFalse();
|
||||
// return ;
|
||||
// }
|
||||
// }
|
||||
if (!check) {
|
||||
ipv4addressEdit->clear();
|
||||
netMaskEdit->clear();
|
||||
gateWayEdit->clear();
|
||||
firstDnsEdit->clear();
|
||||
secondDnsEdit->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Ipv4Page::setEnableOfSaveBtn() {
|
||||
emit setIpv4PageState(checkConnectBtnIsEnabled());
|
||||
}
|
||||
|
||||
bool Ipv4Page::getTextEditState(QString text)
|
||||
{
|
||||
if (text.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
|
||||
|
||||
bool match = false;
|
||||
match = rx.exactMatch(text);
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,35 +12,29 @@
|
|||
#include <QLineEdit>
|
||||
#include <QDebug>
|
||||
|
||||
struct ConnProperties
|
||||
{
|
||||
QString uuidName; //uuid
|
||||
QString v4method; //
|
||||
QString v4addr; //ipv4地址
|
||||
QString mask; //
|
||||
QString gateway; //网关
|
||||
QString dns; //DNS
|
||||
bool isActConf; //
|
||||
QString type; //网络类型
|
||||
};
|
||||
//#include "kylinconnectsetting.h"
|
||||
#include "coninfo.h"
|
||||
|
||||
class Ipv4Page : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Ipv4Page(bool isWlan, QWidget *parent = nullptr);
|
||||
void setIpv4Config(const QString &ipv4Config);
|
||||
Ipv4Page(QWidget *parent = nullptr);
|
||||
void setIpv4Config(KyIpConfigType ipv4Config);
|
||||
void setIpv4(const QString &ipv4);
|
||||
void setNetMask(const QString &netMask);
|
||||
void setIpv4FirDns(const QString &ipv4FirDns);
|
||||
void setIpv4SecDns(const QString &ipv4SecDns);
|
||||
void setGateWay(const QString &gateWay);
|
||||
public:
|
||||
|
||||
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
|
||||
private:
|
||||
QComboBox *ipv4ConfigCombox;
|
||||
QLineEdit *ipv4addressEdit;
|
||||
QComboBox *netMaskCombox;
|
||||
QLineEdit *netMaskEdit;
|
||||
QLineEdit *gateWayEdit;
|
||||
QLineEdit *firstDnsEidt;
|
||||
QLineEdit *secondDnsEidt;
|
||||
QLineEdit *firstDnsEdit;
|
||||
QLineEdit *secondDnsEdit;
|
||||
|
||||
private:
|
||||
QFormLayout *m_detailLayout;
|
||||
|
@ -51,19 +45,19 @@ private:
|
|||
QLabel *m_gateWayLabel;
|
||||
QLabel *m_dnsLabel;
|
||||
QLabel *m_secDnsLabel;
|
||||
bool isWlan;
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
void setEnableOfSaveBtn();
|
||||
void setLineEnabled(bool check);
|
||||
void configSave();
|
||||
bool getTextEditState(QString text);
|
||||
bool checkConnectBtnIsEnabled();
|
||||
|
||||
|
||||
public slots:
|
||||
private slots:
|
||||
void setEnableOfSaveBtn();
|
||||
void configChanged(int index);
|
||||
Q_SIGNALS:
|
||||
// void setBtnEnableFalse();
|
||||
void setIpv4PageState(bool);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#include "ipv6page.h"
|
||||
#include "netdetail.h"
|
||||
Ipv6Page::Ipv6Page(bool isWlan, QWidget *parent)
|
||||
:isWlan(isWlan), QFrame(parent)
|
||||
|
||||
Ipv6Page::Ipv6Page(QWidget *parent):QFrame(parent)
|
||||
{
|
||||
initUI();
|
||||
initComponent();
|
||||
}
|
||||
|
||||
void Ipv6Page::setIpv6Config(const QString &ipv6Config)
|
||||
void Ipv6Page::setIpv6Config(KyIpConfigType ipv6Config)
|
||||
{
|
||||
if (ipv6Config.toInt() == AUTO_CONFIG) {
|
||||
if (ipv6Config == CONFIG_IP_MANUAL) {
|
||||
ipv6ConfigCombox->setCurrentIndex(MANUAL_CONFIG);
|
||||
} else {
|
||||
ipv6ConfigCombox->setCurrentIndex(AUTO_CONFIG);
|
||||
|
@ -36,6 +36,48 @@ void Ipv6Page::setGateWay(const QString &gateWay)
|
|||
gateWayEdit->setText(gateWay);
|
||||
}
|
||||
|
||||
bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
||||
{
|
||||
bool isChanged = false;
|
||||
if (ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
if (info.ipv6ConfigType != CONFIG_IP_DHCP) {
|
||||
qDebug() << "ipv6ConfigType change to Auto";
|
||||
setting.setIpConfigType(IPADDRESS_V6, CONFIG_IP_DHCP);
|
||||
isChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (info.ipv6ConfigType != CONFIG_IP_MANUAL) {
|
||||
qDebug() << "ipv6ConfigType change to Manual";
|
||||
setting.setIpConfigType(IPADDRESS_V6, CONFIG_IP_MANUAL);
|
||||
isChanged = true;
|
||||
}
|
||||
if(info.strIPV6Address != ipv6AddressEdit->text()
|
||||
|| info.strIPV6Prefix != lengthEdit->text()
|
||||
|| info.strIPV6GateWay != gateWayEdit->text()
|
||||
|| info.strIPV6FirDns != firstDnsEdit->text()
|
||||
|| info.strIPV6SecDns != secondDnsEdit->text()) {
|
||||
|
||||
qDebug() << "ipv6 info changed";
|
||||
QStringList dnsList;
|
||||
dnsList.empty();
|
||||
if (!firstDnsEdit->text().isEmpty()) {
|
||||
dnsList << firstDnsEdit->text();
|
||||
if (!secondDnsEdit->text().isEmpty()) {
|
||||
dnsList << secondDnsEdit->text();
|
||||
}
|
||||
}
|
||||
|
||||
QString ipv6address =ipv6AddressEdit->text();
|
||||
QString prefix = lengthEdit->text();
|
||||
QString gateWay = gateWayEdit->text();
|
||||
setting.ipv6AddressConstruct(ipv6address, prefix, gateWay, dnsList);
|
||||
setting.dumpInfo();
|
||||
isChanged = true;
|
||||
}
|
||||
}
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
void Ipv6Page::initUI() {
|
||||
ipv6ConfigCombox = new QComboBox(this);
|
||||
ipv6AddressEdit = new QLineEdit(this);
|
||||
|
@ -73,15 +115,27 @@ void Ipv6Page::initUI() {
|
|||
|
||||
QRegExp ipv6_rx("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$");
|
||||
ipv6AddressEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
|
||||
gateWayEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
|
||||
firstDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
|
||||
secondDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
|
||||
|
||||
QRegExp prefix_rx("\\b(?:(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\.){3}(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\b");
|
||||
lengthEdit->setValidator(new QRegExpValidator(prefix_rx,this));
|
||||
}
|
||||
|
||||
void Ipv6Page::initComponent() {
|
||||
if (ipv6ConfigCombox->currentIndex() == MANUAL_CONFIG) {
|
||||
if (ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
setControlEnabled(false);
|
||||
} else if (ipv6ConfigCombox->currentIndex() == MANUAL_CONFIG) {
|
||||
setControlEnabled(true);
|
||||
}
|
||||
connect(ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int)));
|
||||
|
||||
connect(ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(lengthEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
}
|
||||
|
||||
void Ipv6Page::configChanged(int index) {
|
||||
|
@ -93,17 +147,76 @@ void Ipv6Page::configChanged(int index) {
|
|||
}
|
||||
}
|
||||
|
||||
void Ipv6Page::setControlEnabled(bool check) {
|
||||
m_addressLabel->setEnabled(check);
|
||||
m_subnetLabel->setEnabled(check);
|
||||
lengthEdit->setEnabled(check);
|
||||
m_gateWayLabel->setEnabled(check);
|
||||
m_dnsLabel->setEnabled(check);
|
||||
m_secDnsLabel->setEnabled(check);
|
||||
|
||||
void Ipv6Page::setControlEnabled(bool check)
|
||||
{
|
||||
ipv6AddressEdit->setEnabled(check);
|
||||
m_subnetLabel->setEnabled(check);
|
||||
lengthEdit->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
firstDnsEdit->setEnabled(check);
|
||||
secondDnsEdit->setEnabled(check);
|
||||
|
||||
if (!check) {
|
||||
ipv6AddressEdit->clear();
|
||||
lengthEdit->clear();
|
||||
gateWayEdit->clear();
|
||||
firstDnsEdit->clear();
|
||||
secondDnsEdit->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void Ipv6Page::setEnableOfSaveBtn()
|
||||
{
|
||||
emit setIpv6PageState(checkConnectBtnIsEnabled());
|
||||
}
|
||||
|
||||
bool Ipv6Page::checkConnectBtnIsEnabled()
|
||||
{
|
||||
if (ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
return true;
|
||||
} else {
|
||||
if (ipv6AddressEdit->text().isEmpty() || !getIpv6EditState(ipv6AddressEdit->text())) {
|
||||
qDebug() << "ipv6address empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lengthEdit->text().isEmpty()) {
|
||||
qDebug() << "ipv6 prefix length empty";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gateWayEdit->text().isEmpty() || !getIpv6EditState(gateWayEdit->text())) {
|
||||
qDebug() << "ipv6 gateway empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
|
||||
qDebug() << "ipv6 dns sort invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getIpv6EditState(firstDnsEdit->text())) {
|
||||
qDebug() << "ipv6 first dns invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getIpv6EditState(secondDnsEdit->text())) {
|
||||
qDebug() << "ipv6 second dns invalid";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ipv6Page::getIpv6EditState(QString text)
|
||||
{
|
||||
if (text.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
QRegExp rx("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$");
|
||||
|
||||
bool match = false;
|
||||
match = rx.exactMatch(text);
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,17 +12,22 @@
|
|||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
|
||||
//#include "kylinconnectsetting.h"
|
||||
#include "coninfo.h"
|
||||
|
||||
class Ipv6Page : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Ipv6Page(bool isWlan, QWidget *parent = nullptr);
|
||||
void setIpv6Config(const QString &ipv6Config);
|
||||
Ipv6Page(QWidget *parent = nullptr);
|
||||
void setIpv6Config(KyIpConfigType ipv6Config);
|
||||
void setIpv6(const QString &ipv4);
|
||||
void setIpv6FirDns(const QString &ipv6FirDns);
|
||||
void setIpv6SecDns(const QString &ipv6SecDns);
|
||||
void setGateWay(const QString &gateWay);
|
||||
|
||||
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
|
||||
|
||||
public:
|
||||
QComboBox *ipv6ConfigCombox;
|
||||
QLineEdit *ipv6AddressEdit;
|
||||
|
@ -38,15 +43,22 @@ private:
|
|||
QLabel *m_gateWayLabel;
|
||||
QLabel *m_dnsLabel;
|
||||
QLabel *m_secDnsLabel;
|
||||
private:
|
||||
bool isWlan;
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
void setControlEnabled(bool check);
|
||||
|
||||
public slots:
|
||||
bool getIpv6EditState(QString text);
|
||||
|
||||
bool checkConnectBtnIsEnabled();
|
||||
|
||||
|
||||
private slots:
|
||||
void configChanged(int index);
|
||||
void setEnableOfSaveBtn();
|
||||
|
||||
signals:
|
||||
void setIpv6PageState(bool);
|
||||
};
|
||||
|
||||
#endif // IPV6PAGE_H
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include "netdetail.h"
|
||||
#include "backend/kylinipv4arping.h"
|
||||
#include "backend/kylinipv6arping.h"
|
||||
|
||||
#define WINDOW_WIDTH 540
|
||||
#define WINDOW_HEIGHT 574
|
||||
|
@ -17,29 +19,49 @@
|
|||
|
||||
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
||||
|
||||
NetDetail::NetDetail(QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent)
|
||||
:m_name(name), m_uuid(uuid), isActive(isActive), isWlan(isWlan), isCreateNet(isCreateNet), QDialog(parent)
|
||||
NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent)
|
||||
:m_deviceName(interface),
|
||||
m_name(name),
|
||||
m_uuid(uuid),
|
||||
isActive(isActive),
|
||||
isWlan(isWlan),
|
||||
isCreateNet(isCreateNet),
|
||||
QDialog(parent)
|
||||
{
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
|
||||
setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint );
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setFixedSize(WINDOW_WIDTH,WINDOW_HEIGHT);
|
||||
centerToScreen();
|
||||
|
||||
m_netDeviceResource = new KyNetworkDeviceResourse(this);
|
||||
initWifiDevice();
|
||||
initLanDevice();
|
||||
m_wirelessConnOpration = new KyWirelessConnectOperation(this);
|
||||
m_resource = new KyWirelessNetResource(this);
|
||||
m_connectOperation = new KyConnectOperation(this);
|
||||
m_wiredConnOperation = new KyWiredConnectOperation(this);
|
||||
initUI();
|
||||
loadPage();
|
||||
initComponent();
|
||||
getConInfo(mInfo);
|
||||
getConInfo(m_info);
|
||||
pagePadding(name,isWlan);
|
||||
|
||||
|
||||
isCreateOk = !(isCreateNet && !isWlan);
|
||||
isDetailOk = !(m_name.isEmpty());
|
||||
isIpv4Ok = true;
|
||||
isIpv6Ok = true;
|
||||
isSecuOk = true;
|
||||
|
||||
qDebug() << interface << name << uuid << "isWlan" << isWlan << "isCreateNet" <<isCreateNet;
|
||||
|
||||
setConfirmEnable();
|
||||
}
|
||||
|
||||
NetDetail::~NetDetail()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NetDetail::centerToScreen()
|
||||
{
|
||||
QDesktopWidget* m = QApplication::desktop();
|
||||
|
@ -56,12 +78,11 @@ void NetDetail::initUI()
|
|||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(9,9,14,24);
|
||||
|
||||
detailPage = new DetailPage(isWlan,this);
|
||||
ipv4Page = new Ipv4Page(isWlan,this);
|
||||
ipv6Page = new Ipv6Page(isWlan,this);
|
||||
securityWidget = new SecurityPage(this);
|
||||
detailPage = new DetailPage(isWlan, isCreateNet, this);
|
||||
ipv4Page = new Ipv4Page(this);
|
||||
ipv6Page = new Ipv6Page(this);
|
||||
securityPage = new SecurityPage(this);
|
||||
createNetPage = new CreatNetPage(this);
|
||||
// addLanWidget = new AddLanWidget;
|
||||
|
||||
titleWidget = new QWidget(this);
|
||||
centerWidget = new QWidget(this);
|
||||
|
@ -71,7 +92,7 @@ void NetDetail::initUI()
|
|||
stackWidget->addWidget(detailPage);
|
||||
stackWidget->addWidget(ipv4Page);
|
||||
stackWidget->addWidget(ipv6Page);
|
||||
stackWidget->addWidget(securityWidget);
|
||||
stackWidget->addWidget(securityPage);
|
||||
stackWidget->addWidget(createNetPage);
|
||||
|
||||
mainLayout->addWidget(titleWidget);
|
||||
|
@ -150,19 +171,22 @@ void NetDetail::initUI()
|
|||
|
||||
void NetDetail::loadPage()
|
||||
{
|
||||
//判断是否创建网络
|
||||
if (isCreateNet) {
|
||||
//判断是否创建网络页面
|
||||
if (isCreateNet && !isWlan) {
|
||||
pageFrame->hide();
|
||||
stackWidget->setCurrentIndex(CREATE_NET_PAGE_NUM);
|
||||
titleLabel->setText(tr("Add Connect"));
|
||||
titleLabel->setText(tr("Add Lan Connect"));
|
||||
} else {
|
||||
stackWidget->setCurrentIndex(DETAIL_PAGE_NUM);
|
||||
titleLabel->setText(m_name);
|
||||
}
|
||||
if (!isWlan) {
|
||||
securityBtn->hide();
|
||||
} else {
|
||||
securityBtn->show();
|
||||
if (!isWlan) {
|
||||
securityBtn->hide();
|
||||
} else {
|
||||
securityBtn->show();
|
||||
if (m_name.isEmpty()) {
|
||||
titleLabel->setText(tr("connect hiddin wlan"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,243 +211,392 @@ void NetDetail::initComponent()
|
|||
stackWidget->setCurrentIndex(SECURITY_PAGE_NUM);
|
||||
});
|
||||
connect(confimBtn, SIGNAL(clicked()), this, SLOT(on_btnConfirm_clicked()));
|
||||
if (!m_uuid.isEmpty()) {
|
||||
forgetBtn->show();
|
||||
connect(forgetBtn, SIGNAL(clicked()), this, SLOT(on_btnForget_clicked()));
|
||||
} else {
|
||||
forgetBtn->hide();
|
||||
}
|
||||
|
||||
connect(createNetPage, &CreatNetPage::setCreatePageState, this, [=](bool status) {
|
||||
isCreateOk = status;
|
||||
setConfirmEnable();
|
||||
});
|
||||
|
||||
connect(detailPage, &DetailPage::setDetailPageState, this, [=](bool status) {
|
||||
isDetailOk = status;
|
||||
setConfirmEnable();
|
||||
});
|
||||
|
||||
connect(ipv4Page, &Ipv4Page::setIpv4PageState, this, [=](bool status) {
|
||||
isIpv4Ok = status;
|
||||
setConfirmEnable();
|
||||
});
|
||||
|
||||
connect(ipv6Page, &Ipv6Page::setIpv6PageState, this, [=](bool status) {
|
||||
isIpv6Ok = status;
|
||||
setConfirmEnable();
|
||||
});
|
||||
|
||||
connect(securityPage, &SecurityPage::setSecuPageState, this, [=](bool status) {
|
||||
isSecuOk = status;
|
||||
setConfirmEnable();
|
||||
});
|
||||
}
|
||||
|
||||
void NetDetail::pagePadding(QString netName, bool isWlan)
|
||||
{
|
||||
foreach (ConInfo netInfo, mInfo) {
|
||||
//网络详情页填充
|
||||
if (isWlan) {
|
||||
if (!netInfo.strConName.compare(netName, Qt::CaseInsensitive)) {
|
||||
detailPage->setSSID(netName);
|
||||
detailPage->setProtocol(netInfo.strConType);
|
||||
detailPage->setSecType(netInfo.strSecType);
|
||||
detailPage->setHz(netInfo.strHz);
|
||||
detailPage->setChan(netInfo.strChan);
|
||||
detailPage->setIpv4(netInfo.strIPV4Address);
|
||||
detailPage->setIpv4Dns(netInfo.strIPV4FirDns);
|
||||
detailPage->setIpv6(netInfo.strIPV6Address);
|
||||
detailPage->setMac(netInfo.strMac);
|
||||
detailPage->setBandWidth(netInfo.strBandWidth);
|
||||
}
|
||||
} else {
|
||||
if (!netInfo.strConName.compare(netName, Qt::CaseInsensitive)) {
|
||||
detailPage->setSSID(netName);
|
||||
detailPage->setProtocol(netInfo.strConType);
|
||||
detailPage->setIpv4(netInfo.strIPV4Address);
|
||||
detailPage->setIpv4Dns(netInfo.strIPV4FirDns);
|
||||
detailPage->setIpv6(netInfo.strIPV6Address);
|
||||
detailPage->setMac(netInfo.strMac);
|
||||
detailPage->setBandWidth(netInfo.strBandWidth);
|
||||
}
|
||||
}
|
||||
//ipv4页面填充
|
||||
if (!netInfo.strConName.compare(netName, Qt::CaseInsensitive)) {
|
||||
if (netInfo.strIPV4ConfigType.toInt() == AUTO_CONFIG) {
|
||||
ipv4Page->setIpv4Config(netInfo.strIPV4ConfigType);
|
||||
ipv4Page->setIpv4(netInfo.strIPV4Address);
|
||||
ipv4Page->setIpv4FirDns(netInfo.strIPV4FirDns);
|
||||
ipv4Page->setIpv4SecDns(netInfo.strIPV4SecDns);
|
||||
ipv4Page->setGateWay(netInfo.strIPV4GateWay);
|
||||
} else {
|
||||
ipv4Page->setIpv4Config(netInfo.strIPV4ConfigType);
|
||||
}
|
||||
}
|
||||
//ipv6页面填充
|
||||
if (!netInfo.strConName.compare(netName, Qt::CaseInsensitive)) {
|
||||
if (netInfo.strIPV4ConfigType.toInt() == AUTO_CONFIG) {
|
||||
ipv6Page->setIpv6Config(netInfo.strIPV6ConfigType);
|
||||
ipv6Page->setIpv6(netInfo.strIPV4Address);
|
||||
ipv6Page->setIpv6FirDns(netInfo.strIPV6FirDns);
|
||||
ipv6Page->setIpv6SecDns(netInfo.strIPV4SecDns);
|
||||
ipv6Page->setGateWay(netInfo.strIPV4GateWay);
|
||||
} else {
|
||||
ipv6Page->setIpv6Config(netInfo.strIPV6ConfigType);
|
||||
}
|
||||
}
|
||||
//网络详情页填充
|
||||
if(isCreateNet && !isWlan) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void NetDetail::initLanDevice()
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wired");
|
||||
m_deviceName = m_settings->value(key, "").toString();
|
||||
if (m_deviceName.isEmpty()) {
|
||||
qDebug() << "initDevice but defalut wired card is null";
|
||||
QStringList list;
|
||||
list.empty();
|
||||
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, list);
|
||||
if (!list.isEmpty()) {
|
||||
m_deviceName = list.at(0);
|
||||
m_settings->setValue(key, m_deviceName);
|
||||
}
|
||||
}
|
||||
qDebug() << "[LanPage] initDevice defaultDevice = " << m_deviceName;
|
||||
m_settings->endGroup();
|
||||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
}
|
||||
detailPage->setSSID(netName);
|
||||
detailPage->setProtocol(m_info.strConType);
|
||||
detailPage->setSecType(m_info.strSecType);
|
||||
detailPage->setHz(m_info.strHz);
|
||||
detailPage->setChan(m_info.strChan);
|
||||
detailPage->setIpv4(m_info.strDynamicIpv4);
|
||||
detailPage->setIpv4Dns(m_info.strDynamicIpv4Dns);
|
||||
detailPage->setIpv6(m_info.strDynamicIpv6);
|
||||
detailPage->setMac(m_info.strMac);
|
||||
detailPage->setBandWidth(m_info.strBandWidth);
|
||||
detailPage->setAutoConnect(m_info.isAutoConnect);
|
||||
|
||||
void NetDetail::initWifiDevice()
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wireless");
|
||||
QString deviceName = m_settings->value(key, "").toString();
|
||||
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList);
|
||||
if (deviceName.isEmpty()) {
|
||||
qDebug() << "initDevice but defalut wireless card is null";
|
||||
if (!m_devList.isEmpty()) {
|
||||
deviceName = m_devList.at(0);
|
||||
m_settings->setValue(key, deviceName);
|
||||
//ipv4页面填充
|
||||
if (m_info.ipv4ConfigType == CONFIG_IP_MANUAL) {
|
||||
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
|
||||
ipv4Page->setIpv4(m_info.strIPV4Address);
|
||||
ipv4Page->setNetMask(m_info.strIPV4NetMask);
|
||||
ipv4Page->setIpv4FirDns(m_info.strIPV4FirDns);
|
||||
ipv4Page->setIpv4SecDns(m_info.strIPV4SecDns);
|
||||
ipv4Page->setGateWay(m_info.strIPV4GateWay);
|
||||
} else {
|
||||
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
|
||||
}
|
||||
//ipv6页面填充
|
||||
if (m_info.ipv6ConfigType == CONFIG_IP_MANUAL) {
|
||||
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
|
||||
ipv6Page->setIpv6(m_info.strIPV4Address);
|
||||
ipv6Page->setIpv6FirDns(m_info.strIPV6FirDns);
|
||||
ipv6Page->setIpv6SecDns(m_info.strIPV4SecDns);
|
||||
ipv6Page->setGateWay(m_info.strIPV4GateWay);
|
||||
} else {
|
||||
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
|
||||
}
|
||||
|
||||
//安全页面
|
||||
if (isWlan) {
|
||||
securityPage->setSecurity(m_info.secType);
|
||||
qDebug() << "setSecurity" << m_info.secType;
|
||||
if (m_info.secType == WPA_AND_WPA2_ENTERPRISE) {
|
||||
if (m_info.enterpriseType == TLS) {
|
||||
securityPage->setTlsInfo(m_info.tlsInfo);
|
||||
} else if (m_info.enterpriseType == PEAP) {
|
||||
securityPage->setPeapInfo(m_info.peapInfo);
|
||||
} else if (m_info.enterpriseType == TTLS) {
|
||||
securityPage->setTtlsInfo(m_info.ttlsInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
qDebug() << "[WlanPage] initDevice defaultDevice = " << deviceName;
|
||||
m_settings->endGroup();
|
||||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
|
||||
}
|
||||
|
||||
//获取网路详情信息
|
||||
void NetDetail::getConInfo(QList<ConInfo>& qlConInfo)
|
||||
void NetDetail::getConInfo(ConInfo &conInfo)
|
||||
{
|
||||
ConInfo conInfo;
|
||||
KyConnectSetting connetSetting;
|
||||
KyWirelessNetItem kyWirelessNetItem;
|
||||
KyWirelessNetResource *m_resource = new KyWirelessNetResource(this);
|
||||
KyConnectResourse *kyConnectResourse = new KyConnectResourse(this);
|
||||
if (isCreateNet && !isWlan) {
|
||||
return;
|
||||
}
|
||||
getBaseInfo(conInfo);
|
||||
getDynamicIpInfo(conInfo, isActive);
|
||||
getStaticIpInfo(conInfo,isActive);
|
||||
}
|
||||
|
||||
|
||||
//详情ssid 带宽 物理地址 无线额外(安全性 频带 通道)
|
||||
void NetDetail::getBaseInfo(ConInfo &conInfo)
|
||||
{
|
||||
//有线无线公有
|
||||
conInfo.strConName = m_name;
|
||||
|
||||
QString deviceName;
|
||||
QString hardAddress;
|
||||
int bandWith;
|
||||
m_netDeviceResource->getHardwareInfo(m_deviceName, hardAddress, bandWith);
|
||||
|
||||
if (!m_devList.isEmpty()) {
|
||||
deviceName = m_devList.at(0);
|
||||
if (!hardAddress.isEmpty()) {
|
||||
conInfo.strBandWidth = QString("%1").arg(bandWith/1000) + "Mbps";
|
||||
}
|
||||
if(isWlan) {
|
||||
if (!m_resource->getWifiNetwork(deviceName, m_name, kyWirelessNetItem)) {
|
||||
return;
|
||||
|
||||
if (!isWlan) {
|
||||
conInfo.strConType = "802-3-ethernet";
|
||||
if (!hardAddress.isEmpty()) {
|
||||
conInfo.strMac = hardAddress;
|
||||
}
|
||||
} else {
|
||||
conInfo.strConType = "802-11-wireless";
|
||||
KyWirelessNetItem item;
|
||||
if (!m_resource->getWifiNetwork(m_deviceName, m_name, item)) {
|
||||
qDebug() << "getWifiNetWork failed device:" << m_deviceName << " name:" << m_name;
|
||||
return;
|
||||
} else {
|
||||
conInfo.strMac = item.m_bssid;
|
||||
}
|
||||
|
||||
//无线特有
|
||||
conInfo.strSecType = item.m_secuType;
|
||||
qDebug() << conInfo.strSecType;
|
||||
|
||||
KyKeyMgmt type = m_wirelessConnOpration->getConnectKeyMgmt(m_uuid);
|
||||
if (type == WpaNone || type == Unknown) {
|
||||
conInfo.secType = NONE;
|
||||
} else if (type == WpaPsk) {
|
||||
conInfo.secType = WPA_AND_WPA2_PERSONAL;
|
||||
} else if (type == SAE) {
|
||||
conInfo.secType = WPA3_PERSONAL;
|
||||
} else if (type == WpaEap) {
|
||||
conInfo.secType = WPA_AND_WPA2_ENTERPRISE;
|
||||
} else {
|
||||
qDebug() << "KeyMgmt not support now " << type;
|
||||
}
|
||||
conInfo.strHz = QString::number(item.m_frequency);
|
||||
if (item.m_isConfigured) {
|
||||
conInfo.strChan = QString::number(item.m_channel);
|
||||
}
|
||||
|
||||
initSecuData();
|
||||
}
|
||||
}
|
||||
|
||||
//详情ipv4 ipv6 ipv4Dns
|
||||
void NetDetail::getDynamicIpInfo(ConInfo &conInfo, bool bActived)
|
||||
{
|
||||
if (!bActived) {
|
||||
return;
|
||||
}
|
||||
//已激活的网络 详情页显示动态ipv4 ipv6 dns
|
||||
QString ipv4,ipv6;
|
||||
QList<QHostAddress> ipv4Dns,ipv6Dns;
|
||||
KyActiveConnectResourse *activeResourse = new KyActiveConnectResourse(this);
|
||||
activeResourse->getActiveConnectIpInfo(m_uuid,ipv4,ipv6);
|
||||
activeResourse->getActiveConnectDnsInfo(m_uuid,ipv4Dns,ipv6Dns);
|
||||
|
||||
//Ipv6
|
||||
if (!ipv6.isEmpty()) {
|
||||
conInfo.strDynamicIpv6 = ipv6;
|
||||
}
|
||||
|
||||
//IPv4
|
||||
if (!ipv4.isEmpty()) {
|
||||
conInfo.strDynamicIpv4 = ipv4;
|
||||
}
|
||||
|
||||
if (!ipv4Dns.isEmpty()) {
|
||||
conInfo.strDynamicIpv4Dns = ipv4Dns.at(0).toString();
|
||||
}
|
||||
}
|
||||
|
||||
//ipv4+ipv6页面
|
||||
void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
|
||||
{
|
||||
KyConnectResourse *kyConnectResourse = new KyConnectResourse(this);
|
||||
KyConnectSetting connetSetting;
|
||||
kyConnectResourse->getConnectionSetting(m_uuid,connetSetting);
|
||||
|
||||
conInfo.strConUUID = m_uuid;
|
||||
conInfo.strIPV4ConfigType = QString("%1").arg(connetSetting.m_ipv4ConfigIpType);
|
||||
conInfo.strIPV6ConfigType = QString("%1").arg(connetSetting.m_ipv6ConfigIpType);
|
||||
qDebug()<<"conInfo.strConUUID:"<<conInfo.strConUUID<<"conInfo.strSecType"<<conInfo.strSecType;
|
||||
if (connetSetting.m_ipv4Address.length() > 0) {
|
||||
conInfo.strIPV4Address = connetSetting.m_ipv4Address.at(0).ip().toString();
|
||||
conInfo.strIPV4GateWay = connetSetting.m_ipv4Address.at(0).gateway().toString();
|
||||
} else {
|
||||
conInfo.strIPV4Address = "--";
|
||||
conInfo.strIPV4GateWay = "--";
|
||||
qDebug()<<"m_ipv4Address length is 0";
|
||||
}
|
||||
if (connetSetting.m_ipv6Address.length() > 0) {
|
||||
conInfo.strIPV6Address = connetSetting.m_ipv6Address.at(0).ip().toString();
|
||||
conInfo.strIPV6GateWay = connetSetting.m_ipv6Address.at(0).gateway().toString();
|
||||
} else {
|
||||
conInfo.strIPV6Address = "--";
|
||||
conInfo.strIPV6GateWay = "--";
|
||||
qDebug()<<"m_ipv4Address length is 0";
|
||||
}
|
||||
conInfo.ipv4ConfigType = connetSetting.m_ipv4ConfigIpType;
|
||||
conInfo.ipv6ConfigType = connetSetting.m_ipv6ConfigIpType;
|
||||
conInfo.isAutoConnect = connetSetting.m_isAutoConnect;
|
||||
|
||||
if (isWlan && isActive) {
|
||||
conInfo.strConType = "802-11-wireless";
|
||||
KyActiveConnectResourse *activeResourse = new KyActiveConnectResourse(this);
|
||||
QString ipv4,ipv6;
|
||||
QList<QHostAddress> ipv4Dns,ipv6Dns;
|
||||
activeResourse->getActiveConnectIpInfo(m_uuid,ipv4,ipv6);
|
||||
activeResourse->getActiveConnectDnsInfo(m_uuid,ipv4Dns,ipv6Dns);
|
||||
m_netDeviceResource->getHardwareInfo(deviceName, hardAddress, bandWith);
|
||||
|
||||
qDebug()<<"802-11-wireless : "<<"deviceName:"<<deviceName<<",ssid:"<<m_ssid<<",uuid:"<<m_uuid;
|
||||
|
||||
if (ipv4Dns.length() == 1) {
|
||||
conInfo.strIPV4FirDns = ipv4Dns.at(0).toString();
|
||||
conInfo.strIPV4SecDns = "--";
|
||||
} else if (ipv4Dns.length() == 2){
|
||||
conInfo.strIPV4FirDns = ipv4Dns.at(0).toString();
|
||||
conInfo.strIPV4SecDns = ipv4Dns.at(1).toString();
|
||||
} else {
|
||||
conInfo.strIPV4FirDns = "--";
|
||||
conInfo.strIPV4SecDns = "--";
|
||||
qDebug()<<"ipv4Dns length is 0";
|
||||
if (connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
if (connetSetting.m_ipv4Address.size() > 0) {
|
||||
conInfo.strIPV4Address = connetSetting.m_ipv4Address.at(0).ip().toString();
|
||||
conInfo.strIPV4NetMask = connetSetting.m_ipv4Address.at(0).netmask().toString();
|
||||
conInfo.strIPV4GateWay = connetSetting.m_ipv4Address.at(0).gateway().toString();
|
||||
}
|
||||
if (ipv6Dns.length() == 1) {
|
||||
conInfo.strIPV6FirDns = ipv6Dns.at(0).toString();
|
||||
conInfo.strIPV6SecDns = "--";
|
||||
} else if (ipv4Dns.length() == 2){
|
||||
conInfo.strIPV6FirDns = ipv6Dns.at(0).toString();
|
||||
conInfo.strIPV6SecDns = ipv6Dns.at(1).toString();
|
||||
} else {
|
||||
conInfo.strIPV6FirDns = "--";
|
||||
conInfo.strIPV6SecDns = "--";
|
||||
qDebug()<<"ipv6Dns length is 0";
|
||||
}
|
||||
|
||||
conInfo.strSecType = kyWirelessNetItem.m_secuType;
|
||||
conInfo.strMac = kyWirelessNetItem.m_bssid;
|
||||
conInfo.strHz = QString("%1").arg(kyWirelessNetItem.m_frequency) +" MHz";
|
||||
conInfo.strConName = kyWirelessNetItem.m_NetSsid;
|
||||
conInfo.strIPV4Address = ipv4;
|
||||
conInfo.strIPV6Address = ipv6;
|
||||
conInfo.strBandWidth = QString("%1").arg(bandWith/1000) + "Mbps";
|
||||
} else if (isWlan && !isActive) {
|
||||
conInfo.strConType = "802-11-wireless";
|
||||
} else {
|
||||
conInfo.strConType = "802-3-ethernet";
|
||||
qDebug()<<"802-11-ethernet : "<<"deviceName:"<<m_deviceName<<",ssid:"<<m_ssid<<",uuid:"<<m_uuid;
|
||||
conInfo.strConName = m_name;
|
||||
qDebug()<<"conInfo.strConName :aaaaaa"<<conInfo.strConName;
|
||||
m_netDeviceResource->getHardwareInfo(m_deviceName, hardAddress, bandWith);
|
||||
if (connetSetting.m_ipv4Dns.length() == 1) {
|
||||
if (connetSetting.m_ipv4Dns.size() == 1) {
|
||||
conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
|
||||
conInfo.strIPV4SecDns = "--";
|
||||
} else if (connetSetting.m_ipv4Dns.length() == 2) {
|
||||
} else if (connetSetting.m_ipv4Dns.size() > 1) {
|
||||
conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
|
||||
conInfo.strIPV4SecDns = connetSetting.m_ipv4Dns.at(1).toString();
|
||||
} else {
|
||||
conInfo.strIPV4FirDns = "--";
|
||||
conInfo.strIPV4SecDns = "--";
|
||||
qDebug()<<"m_ipv4DNS length is 0";
|
||||
}
|
||||
if (connetSetting.m_ipv6Dns.length() == 1) {
|
||||
}
|
||||
|
||||
if (connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
if (connetSetting.m_ipv6Address.size() > 0) {
|
||||
conInfo.strIPV6Address = connetSetting.m_ipv6Address.at(0).ip().toString();
|
||||
conInfo.strIPV6Prefix = connetSetting.m_ipv6Address.at(0).netmask().toString();
|
||||
conInfo.strIPV6GateWay = connetSetting.m_ipv6Address.at(0).gateway().toString();
|
||||
}
|
||||
|
||||
if (connetSetting.m_ipv6Dns.size() == 1) {
|
||||
conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString();
|
||||
conInfo.strIPV6SecDns = "--";
|
||||
} else if (connetSetting.m_ipv6Dns.length() == 2) {
|
||||
} else if (connetSetting.m_ipv4Dns.size() > 1) {
|
||||
conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString();
|
||||
conInfo.strIPV6SecDns = connetSetting.m_ipv6Dns.at(1).toString();
|
||||
} else {
|
||||
conInfo.strIPV6FirDns = "--";
|
||||
conInfo.strIPV6SecDns = "--";
|
||||
qDebug()<<"m_ipv6DNS length is 0";
|
||||
}
|
||||
conInfo.strBandWidth = QString("%1").arg(bandWith/1000) + "Mbps";
|
||||
conInfo.strMac = hardAddress;
|
||||
}
|
||||
qlConInfo.append(conInfo);
|
||||
|
||||
if (!bActived) {
|
||||
conInfo.strDynamicIpv4 = conInfo.strIPV4Address.isEmpty() ? tr("Auto") : conInfo.strIPV4Address;
|
||||
conInfo.strDynamicIpv6 = conInfo.strIPV6Address.isEmpty() ? tr("Auto") : conInfo.strIPV6Address;
|
||||
conInfo.strDynamicIpv4Dns = conInfo.strIPV4FirDns.isEmpty() ? tr("Auto") : conInfo.strIPV4FirDns;
|
||||
}
|
||||
}
|
||||
|
||||
void NetDetail::initSecuData()
|
||||
{
|
||||
QString password;
|
||||
int type = m_info.secType;
|
||||
switch (type) {
|
||||
case NONE:
|
||||
break;
|
||||
case WPA_AND_WPA2_PERSONAL:
|
||||
case WPA3_PERSONAL:
|
||||
password = m_wirelessConnOpration->getPsk(m_uuid);
|
||||
m_info.strPassword = password;
|
||||
securityPage->setPsk(password);
|
||||
break;
|
||||
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){
|
||||
initTlsInfo(m_info);
|
||||
} else if (m_info.enterpriseType == PEAP){
|
||||
initPeapInfo(m_info);
|
||||
} else {
|
||||
initTtlsInfo(m_info);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NetDetail::initTlsInfo(ConInfo &conInfo)
|
||||
{
|
||||
m_resource->getEnterPriseInfoTls(m_uuid, conInfo.tlsInfo);
|
||||
}
|
||||
|
||||
void NetDetail::initPeapInfo(ConInfo &conInfo)
|
||||
{
|
||||
m_resource->getEnterPriseInfoPeap(m_uuid, conInfo.peapInfo);
|
||||
}
|
||||
|
||||
void NetDetail::initTtlsInfo(ConInfo &conInfo)
|
||||
{
|
||||
m_resource->getEnterPriseInfoTtls(m_uuid, conInfo.ttlsInfo);
|
||||
}
|
||||
|
||||
//点击了保存更改网络设置的按钮
|
||||
void NetDetail::on_btnConfirm_clicked()
|
||||
{
|
||||
if (checkConfig()) {
|
||||
|
||||
if (isCreateNet) {
|
||||
if (!isWlan) {
|
||||
//新建有线连接
|
||||
qDebug() << "Confirm create wired connect";
|
||||
if (!createWiredConnect()) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
//新建无线连接
|
||||
qDebug() << "Confirm create wireless connect";
|
||||
if (!createWirelessConnect()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//更新连接
|
||||
qDebug() << "Confirm update connect";
|
||||
if (!updateConnect()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
//点击忘记网络
|
||||
void NetDetail::on_btnForget_clicked()
|
||||
{
|
||||
qDebug() << "user choose forget connection uuid = " << m_uuid;
|
||||
m_connectOperation->deleteConnect(m_uuid);
|
||||
close();
|
||||
}
|
||||
|
||||
void NetDetail::setConfirmEnable()
|
||||
{
|
||||
if (isCreateNet && !isWlan) {
|
||||
isConfirmBtnEnable = isCreateOk;
|
||||
} else {
|
||||
if (isDetailOk && isIpv4Ok && isIpv6Ok) {
|
||||
if (isWlan && !isSecuOk) {
|
||||
isConfirmBtnEnable = false;
|
||||
} else {
|
||||
isConfirmBtnEnable = true;
|
||||
}
|
||||
} else {
|
||||
isConfirmBtnEnable = false;
|
||||
}
|
||||
}
|
||||
qDebug() << "setConfirmEnable "<< isConfirmBtnEnable;
|
||||
confimBtn->setEnabled(isConfirmBtnEnable);
|
||||
}
|
||||
|
||||
bool NetDetail::checkIpv4Conflict(QString ipv4Address)
|
||||
{
|
||||
bool isConflict = false;
|
||||
KyIpv4Arping* ipv4Arping = new KyIpv4Arping(m_deviceName, ipv4Address);
|
||||
|
||||
if (ipv4Arping->ipv4ConflictCheck() >= 0) {
|
||||
isConflict = ipv4Arping->ipv4IsConflict();
|
||||
} else {
|
||||
qWarning() << "checkIpv4Conflict internal error";
|
||||
}
|
||||
|
||||
delete ipv4Arping;
|
||||
ipv4Arping = nullptr;
|
||||
return isConflict;
|
||||
}
|
||||
|
||||
bool NetDetail::checkIpv6Conflict(QString ipv6address)
|
||||
{
|
||||
bool isConflict = false;
|
||||
KyIpv6Arping* ipv46rping = new KyIpv6Arping(m_deviceName, ipv6address);
|
||||
|
||||
if (ipv46rping->ipv6ConflictCheck() >= 0) {
|
||||
isConflict = ipv46rping->ipv6IsConflict();
|
||||
} else {
|
||||
qWarning() << "checkIpv6Conflict internal error";
|
||||
}
|
||||
|
||||
delete ipv46rping;
|
||||
ipv46rping = nullptr;
|
||||
return isConflict;
|
||||
}
|
||||
|
||||
void NetDetail::updateWirelessPersonalConnect()
|
||||
{
|
||||
KyWirelessConnectSetting setting;
|
||||
securityPage->updateSecurityChange(setting);
|
||||
bool isPwdChanged = !(m_info.strPassword == setting.m_psk);
|
||||
m_wirelessConnOpration->updateWirelessPersonalConnect(m_uuid, setting, isPwdChanged);
|
||||
}
|
||||
|
||||
void NetDetail::updateWirelessEnterPriseConnect(KyEapMethodType enterpriseType)
|
||||
{
|
||||
if (enterpriseType == TLS) {
|
||||
m_info.tlsInfo.devIfaceName = m_deviceName;
|
||||
securityPage->updateTlsChange(m_info.tlsInfo);
|
||||
m_wirelessConnOpration->updateWirelessEnterPriseTlsConnect(m_uuid, m_info.tlsInfo);
|
||||
} else if (enterpriseType == PEAP) {
|
||||
securityPage->updatePeapChange(m_info.peapInfo);
|
||||
m_wirelessConnOpration->updateWirelessEnterPrisePeapConnect(m_uuid, m_info.peapInfo);
|
||||
} else if (enterpriseType == TTLS) {
|
||||
securityPage->updateTtlsChange(m_info.ttlsInfo);
|
||||
m_wirelessConnOpration->updateWirelessEnterPriseTtlsConnect(m_uuid, m_info.ttlsInfo);
|
||||
}
|
||||
}
|
||||
|
||||
//检测网络配置信息是否改变
|
||||
bool NetDetail::checkConfig() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void NetDetail::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
|
@ -466,3 +639,153 @@ void NetDetail::paintEvent(QPaintEvent *event)
|
|||
p.fillPath(rectPath, palette().color(QPalette::Base));
|
||||
p.restore();
|
||||
}
|
||||
|
||||
bool NetDetail::createWiredConnect()
|
||||
{
|
||||
KyWirelessConnectSetting connetSetting;
|
||||
connetSetting.setIfaceName(m_deviceName);
|
||||
createNetPage->constructIpv4Info(connetSetting);
|
||||
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
||||
qDebug() << "ipv4 conflict";
|
||||
//todo desktop notify
|
||||
return false;
|
||||
}
|
||||
m_wiredConnOperation->createWiredConnect(connetSetting);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NetDetail::createWirelessConnect()
|
||||
{
|
||||
KyWirelessConnectSetting connetSetting;
|
||||
//基本信息
|
||||
QString ssid;
|
||||
detailPage->getSsid(ssid);
|
||||
connetSetting.setConnectName(ssid);
|
||||
connetSetting.setIfaceName(m_deviceName);
|
||||
if (detailPage->checkIsChanged(m_info)) {
|
||||
connetSetting.isAutoConnect = !m_info.isAutoConnect;
|
||||
} else {
|
||||
connetSetting.isAutoConnect = m_info.isAutoConnect;
|
||||
}
|
||||
qDebug() << "isAutoConnect" << connetSetting.isAutoConnect;
|
||||
connetSetting.m_ssid = ssid;
|
||||
connetSetting.m_secretFlag = NetworkManager::Setting::None;
|
||||
|
||||
//ipv4 & ipv6
|
||||
bool ipv4Change = ipv4Page->checkIsChanged(m_info, connetSetting);
|
||||
bool ipv6Change = ipv6Page->checkIsChanged(m_info, connetSetting);
|
||||
|
||||
connetSetting.dumpInfo();
|
||||
|
||||
qDebug() << "ipv4Changed" << ipv4Change << "ipv6Change" << ipv6Change;
|
||||
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
||||
qDebug() << "ipv4 conflict";
|
||||
//todo desktop notify
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
|
||||
qDebug() << "ipv6 conflict";
|
||||
//todo desktop notify
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//wifi安全性
|
||||
KySecuType secuType;
|
||||
KyEapMethodType enterpriseType;
|
||||
securityPage->getSecuType(secuType, enterpriseType);
|
||||
if (secuType == WPA_AND_WPA2_ENTERPRISE) {
|
||||
connetSetting.m_type = SAE;
|
||||
if (enterpriseType == TLS) {
|
||||
m_info.tlsInfo.devIfaceName = m_deviceName;
|
||||
securityPage->updateTlsChange(m_info.tlsInfo);
|
||||
if (!m_name.isEmpty()) {
|
||||
qDebug() << "add new TLS connect";
|
||||
m_wirelessConnOpration->addTlsConnect(connetSetting, m_info.tlsInfo);
|
||||
} else {
|
||||
qDebug() << "addAndConnect TLS connect";
|
||||
m_wirelessConnOpration->addAndActiveWirelessEnterPriseTlsConnect(m_info.tlsInfo, connetSetting, m_deviceName, true);
|
||||
}
|
||||
} else if (enterpriseType == PEAP) {
|
||||
securityPage->updatePeapChange(m_info.peapInfo);
|
||||
if (!m_name.isEmpty()) {
|
||||
qDebug() << "add new PEAP connect";
|
||||
m_wirelessConnOpration->addPeapConnect(connetSetting, m_info.peapInfo);
|
||||
} else {
|
||||
qDebug() << "addAndConnect PEAP connect";
|
||||
m_wirelessConnOpration->addAndActiveWirelessEnterPrisePeapConnect(m_info.peapInfo, connetSetting, m_deviceName, true);
|
||||
}
|
||||
} else if (enterpriseType == TTLS) {
|
||||
securityPage->updateTtlsChange(m_info.ttlsInfo);
|
||||
if (!m_name.isEmpty()) {
|
||||
qDebug() << "add new TTLS connect";
|
||||
m_wirelessConnOpration->addTtlsConnect(connetSetting, m_info.ttlsInfo);
|
||||
} else {
|
||||
qDebug() << "addAndConnect TTLS connect";
|
||||
m_wirelessConnOpration->addAndActiveWirelessEnterPriseTtlsConnect(m_info.ttlsInfo, connetSetting, m_deviceName, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
securityPage->updateSecurityChange(connetSetting);
|
||||
if (!m_name.isEmpty()) {
|
||||
qDebug() << "add new personal connect";
|
||||
m_wirelessConnOpration->addConnect(connetSetting);
|
||||
} else {
|
||||
qDebug() << "addAndConnect personal connect";
|
||||
m_wirelessConnOpration->addAndActiveWirelessConnect(m_deviceName, connetSetting, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NetDetail::updateConnect()
|
||||
{
|
||||
KyConnectResourse *kyConnectResourse = new KyConnectResourse(this);
|
||||
KyConnectSetting connetSetting;
|
||||
kyConnectResourse->getConnectionSetting(m_uuid,connetSetting);
|
||||
|
||||
if(!m_uuid.isEmpty() && detailPage->checkIsChanged(m_info)) {
|
||||
m_wirelessConnOpration->setWirelessAutoConnect(m_uuid, !m_info.isAutoConnect);
|
||||
}
|
||||
|
||||
bool ipv4Change = ipv4Page->checkIsChanged(m_info, connetSetting);
|
||||
bool ipv6Change = ipv6Page->checkIsChanged(m_info, connetSetting);
|
||||
|
||||
qDebug() << "ipv4Changed" << ipv4Change << "ipv6Change" << ipv6Change;
|
||||
|
||||
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
||||
qDebug() << "ipv4 conflict";
|
||||
//todo desktop notify
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
|
||||
qDebug() << "ipv6 conflict";
|
||||
//todo desktop notify
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ipv4Change || ipv6Change) {
|
||||
connetSetting.dumpInfo();
|
||||
m_wiredConnOperation->updateWiredConnect(m_uuid, connetSetting);
|
||||
}
|
||||
|
||||
if (isWlan && securityPage->checkIsChanged(m_info)) {
|
||||
KySecuType secuType;
|
||||
KyEapMethodType enterpriseType;
|
||||
securityPage->getSecuType(secuType, enterpriseType);
|
||||
if (secuType == WPA_AND_WPA2_ENTERPRISE) {
|
||||
updateWirelessEnterPriseConnect(enterpriseType);
|
||||
} else {
|
||||
updateWirelessPersonalConnect();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -24,73 +24,64 @@
|
|||
#include "ipv6page.h"
|
||||
#include "securitypage.h"
|
||||
#include "creatnetpage.h"
|
||||
#include "kywirelessnetitem.h"
|
||||
#include "kylinconnectresource.h"
|
||||
#include "kylinactiveconnectresource.h"
|
||||
#include "kywirelessnetresource.h"
|
||||
#include "coninfo.h"
|
||||
#include "tab-pages/tabpage.h"
|
||||
|
||||
static int AUTO_CONFIG = 0;
|
||||
static int MANUAL_CONFIG = 1;
|
||||
|
||||
typedef struct ConInfo_s {
|
||||
QString strConName;
|
||||
QString strConUUID;
|
||||
QString strConType;
|
||||
QString strSecType;
|
||||
QString strChan;
|
||||
QString strMac;
|
||||
QString strHz;
|
||||
QString strBandWidth;
|
||||
|
||||
QString strIPV4ConfigType;
|
||||
QString strIPV4Address;
|
||||
QString strIPV4Prefix;
|
||||
QString strIPV4FirDns;
|
||||
QString strIPV4SecDns;
|
||||
QString strIPV4GateWay;
|
||||
|
||||
QString strIPV6ConfigType;
|
||||
QString strIPV6Address;
|
||||
QString strIPV6FirDns;
|
||||
QString strIPV6SecDns;
|
||||
QString strIPV6GateWay;
|
||||
QString strIPV6Prefix;
|
||||
}ConInfo;
|
||||
|
||||
|
||||
class NetDetail : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NetDetail(QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent = nullptr);
|
||||
NetDetail(QString interface, QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent = nullptr);
|
||||
~NetDetail();
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initWifiDevice();//初始化无线默认设备
|
||||
void initLanDevice();//初始化有线默认设备
|
||||
void centerToScreen();
|
||||
void initComponent();
|
||||
void getConInfo(QList<ConInfo>& qlConInfo);
|
||||
bool checkConfig();
|
||||
void getConInfo(ConInfo &conInfo);
|
||||
void loadPage();
|
||||
void pagePadding(QString netName, bool isWlan);
|
||||
void initSecuData();
|
||||
|
||||
void initTlsInfo(ConInfo &conInfo);
|
||||
void initPeapInfo(ConInfo &conInfo);
|
||||
void initTtlsInfo(ConInfo &conInfo);
|
||||
|
||||
void updateWirelessPersonalConnect();
|
||||
void updateWirelessEnterPriseConnect(KyEapMethodType enterpriseType);
|
||||
|
||||
//详情ssid 带宽 物理地址 无线额外(安全性 频带 通道)
|
||||
void getBaseInfo(ConInfo &conInfo);
|
||||
//详情ipv4 ipv6 ipv4Dns
|
||||
void getDynamicIpInfo(ConInfo &conInfo, bool bActived);
|
||||
//ipv4+ipv6页面
|
||||
void getStaticIpInfo(ConInfo &conInfo, bool bActived);
|
||||
|
||||
void setConfirmEnable();
|
||||
|
||||
bool checkIpv4Conflict(QString ipv4Address);
|
||||
bool checkIpv6Conflict(QString ipv6Address);
|
||||
|
||||
bool createWiredConnect();
|
||||
bool createWirelessConnect();
|
||||
bool updateConnect();
|
||||
private:
|
||||
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
|
||||
KyConnectOperation* m_connectOperation = nullptr;
|
||||
KyWirelessConnectOperation *m_wirelessConnOpration = nullptr;
|
||||
KyWiredConnectOperation *m_wiredConnOperation = nullptr;
|
||||
KyWirelessNetResource *m_resource = nullptr;
|
||||
|
||||
QStackedWidget * stackWidget;
|
||||
|
||||
DetailPage * detailPage;
|
||||
Ipv4Page * ipv4Page;
|
||||
Ipv6Page * ipv6Page;
|
||||
SecurityPage * securityWidget;
|
||||
SecurityPage * securityPage;
|
||||
CreatNetPage * createNetPage;
|
||||
// AddLanWidget * addLanWidget;
|
||||
|
||||
QWidget * titleWidget;
|
||||
QWidget * centerWidget;
|
||||
|
@ -112,18 +103,24 @@ private:
|
|||
|
||||
QString m_name;
|
||||
QString m_uuid;
|
||||
QString m_ssid;
|
||||
QStringList m_devList;
|
||||
QString m_deviceName;
|
||||
|
||||
bool isWlan;
|
||||
bool isCreateNet;
|
||||
bool isActive;
|
||||
bool isHideWlan;
|
||||
|
||||
QList<ConInfo> mInfo;
|
||||
bool isCreateOk;
|
||||
bool isDetailOk;
|
||||
bool isIpv4Ok;
|
||||
bool isIpv6Ok;
|
||||
bool isSecuOk;
|
||||
bool isConfirmBtnEnable;
|
||||
|
||||
ConInfo m_info;
|
||||
|
||||
private slots:
|
||||
void on_btnConfirm_clicked();
|
||||
|
||||
void on_btnForget_clicked();
|
||||
};
|
||||
#endif // NETDETAIL_H
|
||||
|
|
|
@ -1,11 +1,761 @@
|
|||
#include "securitypage.h"
|
||||
#include "netdetail.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
SecurityPage::SecurityPage(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
initUI();
|
||||
initConnect();
|
||||
}
|
||||
|
||||
void SecurityPage::initUI()
|
||||
{
|
||||
secuTypeLabel = new QLabel(this);
|
||||
pwdLabel = new QLabel(this);
|
||||
secuTypeLabel = new QLabel(this);
|
||||
pwdLabel = new QLabel(this);
|
||||
//企业wifi共有
|
||||
eapTypeLabel = new QLabel(this);
|
||||
//TLS
|
||||
identityLable = new QLabel(this);
|
||||
domainLable = new QLabel(this);
|
||||
caCertPathLabel = new QLabel(this);
|
||||
caNeedFlagLabel = new QLabel(this);
|
||||
clientCertPathLabel = new QLabel(this);
|
||||
clientPrivateKeyLabel = new QLabel(this);
|
||||
clientPrivateKeyPwdLabel = new QLabel(this);
|
||||
|
||||
//PEAP TTLS共有
|
||||
eapMethodLabel = new QLabel(this);
|
||||
userNameLabel = new QLabel(this);
|
||||
userPwdLabel = new QLabel(this);
|
||||
userPwdFlagLabel = new QLabel(this);
|
||||
|
||||
secuTypeCombox = new QComboBox(this);
|
||||
pwdEdit = new QLineEdit(this);
|
||||
eapTypeCombox = new QComboBox(this);
|
||||
//TLS
|
||||
identityEdit = new QLineEdit(this);
|
||||
domainEdit = new QLineEdit(this);
|
||||
caCertPathCombox = new QComboBox(this);
|
||||
caNeedBox = new QCheckBox(this);
|
||||
clientCertPathCombox = new QComboBox(this);
|
||||
clientPrivateKeyCombox = new QComboBox(this);
|
||||
clientPrivateKeyPwdEdit = new QLineEdit(this);
|
||||
|
||||
//PEAP && TTLS
|
||||
eapMethodCombox = new QComboBox(this);
|
||||
userNameEdit = new QLineEdit(this);
|
||||
userPwdEdit = new QLineEdit(this);
|
||||
userPwdFlagBox = new QCheckBox(this);
|
||||
|
||||
|
||||
mSecuLayout = new QFormLayout(this);
|
||||
mSecuLayout->addRow(secuTypeLabel, secuTypeCombox);
|
||||
mSecuLayout->addRow(pwdLabel, pwdEdit);
|
||||
mSecuLayout->addRow(eapTypeLabel, eapTypeCombox);
|
||||
mSecuLayout->addRow(identityLable, identityEdit);
|
||||
mSecuLayout->addRow(domainLable, domainEdit);
|
||||
mSecuLayout->addRow(caCertPathLabel, caCertPathCombox);
|
||||
mSecuLayout->addRow(caNeedBox, caNeedFlagLabel);
|
||||
mSecuLayout->addRow(clientCertPathLabel, clientCertPathCombox);
|
||||
mSecuLayout->addRow(clientPrivateKeyLabel, clientPrivateKeyCombox);
|
||||
mSecuLayout->addRow(clientPrivateKeyPwdLabel,clientPrivateKeyPwdEdit);
|
||||
mSecuLayout->addRow(eapMethodLabel, eapMethodCombox);
|
||||
mSecuLayout->addRow(userNameLabel, userNameEdit);
|
||||
mSecuLayout->addRow(userPwdLabel, userPwdEdit);
|
||||
mSecuLayout->addRow(userPwdFlagBox, userPwdFlagLabel);
|
||||
|
||||
|
||||
secuTypeLabel->setText(tr("Security"));
|
||||
pwdLabel->setText(tr("Password"));
|
||||
//企业wifi共有
|
||||
eapTypeLabel->setText(tr("EAP type"));
|
||||
//TLS
|
||||
identityLable->setText(tr("Identity"));
|
||||
domainLable->setText(tr("Domain"));
|
||||
caCertPathLabel->setText(tr("CA certficate"));
|
||||
caNeedFlagLabel->setText(tr("no need for CA certificate"));
|
||||
clientCertPathLabel->setText(tr("User certificate"));
|
||||
clientPrivateKeyLabel->setText(tr("User private key"));
|
||||
clientPrivateKeyPwdLabel->setText(tr("User key password"));
|
||||
|
||||
//PEAP TTLS共有
|
||||
eapMethodLabel->setText(tr("Ineer authentication"));
|
||||
userNameLabel->setText(tr("Usename"));
|
||||
userPwdLabel->setText(tr("Password"));
|
||||
userPwdFlagLabel->setText(tr("Ask pwd each query"));
|
||||
|
||||
secuTypeCombox->addItem(tr("None"),NONE);
|
||||
secuTypeCombox->addItem(tr("WPA&WPA2 Personal"),WPA_AND_WPA2_PERSONAL);
|
||||
secuTypeCombox->addItem(tr("WPA&WPA2 Enterprise"), WPA_AND_WPA2_ENTERPRISE);
|
||||
secuTypeCombox->addItem(tr("WPA3 Personal"), WPA3_PERSONAL);
|
||||
|
||||
eapTypeCombox->addItem("TLS", TLS);
|
||||
eapTypeCombox->addItem("PEAP", PEAP);
|
||||
eapTypeCombox->addItem("TTLS", TTLS);
|
||||
eapTypeCombox->setCurrentIndex(TLS);
|
||||
//TLS
|
||||
caCertPathCombox->addItem(tr("None"), QString(tr("None"))); //无
|
||||
caCertPathCombox->addItem(tr("Choose from file..."), QString(tr("Choose from file..."))); //从文件中选择...
|
||||
|
||||
clientCertPathCombox->addItem(tr("None"), QString(tr("None"))); //无
|
||||
clientCertPathCombox->addItem(tr("Choose from file..."), QString(tr("Choose from file..."))); //从文件中选择...
|
||||
|
||||
clientPrivateKeyCombox->addItem(tr("None"), QString(tr("None"))); //无
|
||||
clientPrivateKeyCombox->addItem(tr("Choose from file..."), QString(tr("Choose from file..."))); //从文件中选择...
|
||||
|
||||
pwdBox = new QCheckBox(this);
|
||||
pwdBox->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}"
|
||||
"QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}"
|
||||
"QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}");
|
||||
pwdBox->setCursor(Qt::PointingHandCursor);
|
||||
pwdBox->setFixedSize(30, pwdEdit->height());
|
||||
//防止文本框输入内容位于按钮之下
|
||||
QMargins margins = pwdEdit->textMargins();
|
||||
pwdEdit->setTextMargins(margins.left(), margins.top(), pwdBox->width(), margins.bottom());
|
||||
QHBoxLayout *pPwdLayout = new QHBoxLayout();
|
||||
pPwdLayout->addStretch();
|
||||
pPwdLayout->addWidget(pwdBox);
|
||||
pPwdLayout->setSpacing(0);
|
||||
pPwdLayout->setContentsMargins(0, 0, 0, 0);
|
||||
pwdEdit->setLayout(pPwdLayout);
|
||||
pwdEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
userPwdBox = new QCheckBox(this);
|
||||
userPwdBox->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}"
|
||||
"QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}"
|
||||
"QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}");
|
||||
userPwdBox->setCursor(Qt::PointingHandCursor);
|
||||
userPwdBox->setFixedSize(30, userPwdEdit->height());
|
||||
//防止文本框输入内容位于按钮之下
|
||||
userPwdEdit->setTextMargins(margins.left(), margins.top(), userPwdBox->width(), margins.bottom());
|
||||
QHBoxLayout *puserPwdLayout = new QHBoxLayout();
|
||||
puserPwdLayout->addStretch();
|
||||
puserPwdLayout->addWidget(userPwdBox);
|
||||
puserPwdLayout->setSpacing(0);
|
||||
puserPwdLayout->setContentsMargins(0, 0, 0, 0);
|
||||
userPwdEdit->setLayout(puserPwdLayout);
|
||||
userPwdEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
privateKeyBox = new QCheckBox(this);
|
||||
privateKeyBox->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}"
|
||||
"QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}"
|
||||
"QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}");
|
||||
privateKeyBox->setCursor(Qt::PointingHandCursor);
|
||||
privateKeyBox->setFixedSize(30, clientPrivateKeyPwdEdit->height());
|
||||
//防止文本框输入内容位于按钮之下
|
||||
clientPrivateKeyPwdEdit->setTextMargins(margins.left(), margins.top(), privateKeyBox->width(), margins.bottom());
|
||||
QHBoxLayout *pPrivateKeyPwdLayout = new QHBoxLayout();
|
||||
pPrivateKeyPwdLayout->addStretch();
|
||||
pPrivateKeyPwdLayout->addWidget(privateKeyBox);
|
||||
pPrivateKeyPwdLayout->setSpacing(0);
|
||||
pPrivateKeyPwdLayout->setContentsMargins(0, 0, 0, 0);
|
||||
clientPrivateKeyPwdEdit->setLayout(pPrivateKeyPwdLayout);
|
||||
clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
showNone();
|
||||
}
|
||||
|
||||
void SecurityPage::initConnect()
|
||||
{
|
||||
//安全类型变化
|
||||
connect(secuTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onSecuTypeComboxIndexChanged);
|
||||
//EAP方式变化
|
||||
connect(eapTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onEapTypeComboxIndexChanged);
|
||||
|
||||
connect(caNeedBox, &QCheckBox::clicked, this, &SecurityPage::onCaNeedBoxClicked);
|
||||
|
||||
connect(pwdBox, &QCheckBox::clicked, this, &SecurityPage::onPwdBoxClicked);
|
||||
connect(userPwdBox, &QCheckBox::clicked, this, &SecurityPage::onUserPwdBox);
|
||||
connect(privateKeyBox, &QCheckBox::clicked, this, &SecurityPage::onPrivateKeyBoxClicked);
|
||||
|
||||
connect(caCertPathCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &SecurityPage::onCaCertPathComboxIndexChanged);
|
||||
|
||||
connect(clientCertPathCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &SecurityPage::onClientCertPathComboxIndexChanged);
|
||||
|
||||
connect(clientPrivateKeyCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||
this, &SecurityPage::onClientPrivateKeyComboxIndexChanged);
|
||||
|
||||
connect(secuTypeCombox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(pwdEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
|
||||
connect(eapTypeCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(identityEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
|
||||
connect(caCertPathCombox, SIGNAL(currentTextChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(caNeedBox, &QCheckBox::stateChanged, this, &SecurityPage::setEnableOfSaveBtn);
|
||||
connect(clientCertPathCombox, SIGNAL(currentTextChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(clientPrivateKeyCombox, SIGNAL(currentTextChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(clientPrivateKeyPwdEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
|
||||
connect(eapMethodCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(userNameEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
|
||||
connect(userPwdEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn);
|
||||
|
||||
}
|
||||
|
||||
void SecurityPage::setSecurity(KySecuType index)
|
||||
{
|
||||
secuTypeCombox->setCurrentIndex(index);
|
||||
onSecuTypeComboxIndexChanged();
|
||||
}
|
||||
|
||||
void SecurityPage::setPsk(const QString &psk)
|
||||
{
|
||||
pwdEdit->setText(psk);
|
||||
}
|
||||
|
||||
void SecurityPage::setTlsInfo(KyEapMethodTlsInfo &info)
|
||||
{
|
||||
showTls();
|
||||
identityEdit->setText(info.identity);
|
||||
domainEdit->setText(info.domain);
|
||||
if (info.caCertPath.isEmpty()) {
|
||||
caCertPathCombox->setItemText(0, "");
|
||||
caNeedBox->setChecked(true);
|
||||
} else {
|
||||
caCertPathCombox->setItemText(0, info.caCertPath);
|
||||
caNeedBox->setChecked(false);
|
||||
}
|
||||
|
||||
if (info.clientCertPath.isEmpty()) {
|
||||
clientCertPathCombox->setItemText(0, "");
|
||||
} else {
|
||||
clientCertPathCombox->setItemText(0, info.clientCertPath);
|
||||
}
|
||||
|
||||
if (info.clientPrivateKey.isEmpty()) {
|
||||
clientPrivateKeyCombox->setItemText(0, "");
|
||||
} else {
|
||||
clientPrivateKeyCombox->setItemText(0, info.clientPrivateKey);
|
||||
}
|
||||
|
||||
clientPrivateKeyPwdEdit->setText(info.clientPrivateKeyPWD);
|
||||
|
||||
}
|
||||
|
||||
void SecurityPage::setPeapInfo(KyEapMethodPeapInfo &info)
|
||||
{
|
||||
showPeapOrTtls();
|
||||
eapTypeCombox->setCurrentIndex(PEAP);
|
||||
onEapTypeComboxIndexChanged();
|
||||
eapMethodCombox->setCurrentIndex(info.phase2AuthMethod);
|
||||
userNameEdit->setText(info.userName);
|
||||
userPwdEdit->setText(info.userPWD);
|
||||
if (info.m_passwdFlag & NetworkManager::Setting::NotSaved) {
|
||||
userPwdFlagBox->setChecked(true);
|
||||
} else {
|
||||
userPwdFlagBox->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityPage::setTtlsInfo(KyEapMethodTtlsInfo &info)
|
||||
{
|
||||
showPeapOrTtls();
|
||||
eapTypeCombox->setCurrentIndex(TTLS);
|
||||
onEapTypeComboxIndexChanged();
|
||||
|
||||
if (info.authType == AUTH_EAP) {
|
||||
if (info.authEapMethod = KyAuthEapMethodMschapv2) {
|
||||
eapMethodCombox->setCurrentIndex(MSCHAPV2_EAP);
|
||||
} else if (info.authEapMethod = KyAuthEapMethodMd5) {
|
||||
eapMethodCombox->setCurrentIndex(MD5_EAP);
|
||||
} else if (info.authEapMethod = KyAuthEapMethodMd5) {
|
||||
eapMethodCombox->setCurrentIndex(MD5_EAP);
|
||||
} else {
|
||||
qDebug() << "not support yet. AUTH_EAP method" << info.authEapMethod;
|
||||
}
|
||||
} else {
|
||||
if (info.authNoEapMethod == KyAuthMethodPap) {
|
||||
eapMethodCombox->setCurrentIndex(PAP);
|
||||
} else if (info.authNoEapMethod == KyAuthMethodMschap) {
|
||||
eapMethodCombox->setCurrentIndex(MSCHAP);
|
||||
} else if (info.authNoEapMethod == KyAuthMethodMschapv2) {
|
||||
eapMethodCombox->setCurrentIndex(MSCHAPV2);
|
||||
} else if (info.authNoEapMethod == KyAuthMethodChap) {
|
||||
eapMethodCombox->setCurrentIndex(CHAP);
|
||||
} else {
|
||||
qDebug() << "not support yet. AUTH_NO_EAP method" << info.authNoEapMethod;
|
||||
}
|
||||
}
|
||||
userNameEdit->setText(info.userName);
|
||||
userPwdEdit->setText(info.userPWD);
|
||||
if (info.m_passwdFlag & NetworkManager::Setting::NotSaved) {
|
||||
userPwdFlagBox->setChecked(true);
|
||||
} else {
|
||||
userPwdFlagBox->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityPage::updateTlsChange(KyEapMethodTlsInfo &info)
|
||||
{
|
||||
KyEapMethodTlsInfo tlsInfo = assembleTlsInfo();
|
||||
// if (tlsInfo.clientPrivateKeyPWD != info.clientPrivateKeyPWD) {
|
||||
tlsInfo.bChanged = true;
|
||||
// }
|
||||
tlsInfo.devIfaceName = info.devIfaceName;
|
||||
info = tlsInfo;
|
||||
}
|
||||
|
||||
void SecurityPage::updatePeapChange(KyEapMethodPeapInfo &info)
|
||||
{
|
||||
KyEapMethodPeapInfo peapInfo = assemblePeapInfo();
|
||||
// if (peapInfo.userPWD != info.userPWD) {
|
||||
peapInfo.bChanged = true;
|
||||
// }
|
||||
info = peapInfo;
|
||||
}
|
||||
|
||||
void SecurityPage::updateTtlsChange(KyEapMethodTtlsInfo &info)
|
||||
{
|
||||
KyEapMethodTtlsInfo ttlsInfo = assembleTtlsInfo();
|
||||
// if (ttlsInfo.userPWD != info.userPWD) {
|
||||
ttlsInfo.bChanged = true;
|
||||
// }
|
||||
info = ttlsInfo;
|
||||
}
|
||||
|
||||
void SecurityPage::getSecuType(KySecuType &secuType, KyEapMethodType &enterpriseType)
|
||||
{
|
||||
secuType = (KySecuType)secuTypeCombox->currentData().toInt();
|
||||
enterpriseType = (KyEapMethodType)eapTypeCombox->currentData().toInt();
|
||||
}
|
||||
|
||||
bool SecurityPage::checkIsChanged(const ConInfo info)
|
||||
{
|
||||
qDebug() << "SecurityPage checkIsChanged";
|
||||
if (info.secType != secuTypeCombox->currentData().toInt()) {
|
||||
return true;
|
||||
} else {
|
||||
if (info.secType == NONE) {
|
||||
return false;
|
||||
} else if (info.secType == WPA_AND_WPA2_PERSONAL || info.secType == WPA3_PERSONAL) {
|
||||
return !(info.strPassword == pwdEdit->text());
|
||||
} else {
|
||||
if (info.enterpriseType != eapTypeCombox->currentData().toInt()) {
|
||||
return true;
|
||||
} else {
|
||||
if (info.enterpriseType == TLS) {
|
||||
return !(info.tlsInfo == assembleTlsInfo());
|
||||
} else if (info.enterpriseType == PEAP) {
|
||||
return !(info.peapInfo == assemblePeapInfo());
|
||||
} else if (info.enterpriseType == TTLS) {
|
||||
return !(info.ttlsInfo == assembleTtlsInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityPage::showNone()
|
||||
{
|
||||
pwdEdit->hide();
|
||||
eapTypeCombox->hide();
|
||||
|
||||
identityEdit->hide();
|
||||
domainEdit->hide();
|
||||
caCertPathCombox->hide();
|
||||
caNeedBox->hide();
|
||||
clientCertPathCombox->hide();
|
||||
clientPrivateKeyCombox->hide();
|
||||
clientPrivateKeyPwdEdit->hide();
|
||||
|
||||
eapMethodCombox->hide();
|
||||
userNameEdit->hide();
|
||||
userPwdEdit->hide();
|
||||
userPwdFlagBox->hide();
|
||||
|
||||
pwdLabel->hide();
|
||||
//企业wifi共有
|
||||
eapTypeLabel->hide();
|
||||
//TLS
|
||||
identityLable->hide();
|
||||
domainLable->hide();
|
||||
caCertPathLabel->hide();
|
||||
caNeedFlagLabel->hide();
|
||||
clientCertPathLabel->hide();
|
||||
clientPrivateKeyLabel->hide();
|
||||
clientPrivateKeyPwdLabel->hide();
|
||||
|
||||
//PEAP TTLS共有
|
||||
eapMethodLabel->hide();
|
||||
userNameLabel->hide();
|
||||
userPwdLabel->hide();
|
||||
userPwdFlagLabel->hide();
|
||||
}
|
||||
|
||||
void SecurityPage::showPsk()
|
||||
{
|
||||
pwdEdit->show();
|
||||
eapTypeCombox->hide();
|
||||
|
||||
identityEdit->hide();
|
||||
domainEdit->hide();
|
||||
caCertPathCombox->hide();
|
||||
caNeedBox->hide();
|
||||
clientCertPathCombox->hide();
|
||||
clientPrivateKeyCombox->hide();
|
||||
clientPrivateKeyPwdEdit->hide();
|
||||
|
||||
eapMethodCombox->hide();
|
||||
userNameEdit->hide();
|
||||
userPwdEdit->hide();
|
||||
userPwdFlagBox->hide();
|
||||
|
||||
pwdLabel->show();
|
||||
//企业wifi共有
|
||||
eapTypeLabel->hide();
|
||||
//TLS
|
||||
identityLable->hide();
|
||||
domainLable->hide();
|
||||
caCertPathLabel->hide();
|
||||
caNeedFlagLabel->hide();
|
||||
clientCertPathLabel->hide();
|
||||
clientPrivateKeyLabel->hide();
|
||||
clientPrivateKeyPwdLabel->hide();
|
||||
|
||||
//PEAP TTLS共有
|
||||
eapMethodLabel->hide();
|
||||
userNameLabel->hide();
|
||||
userPwdLabel->hide();
|
||||
userPwdFlagLabel->hide();
|
||||
}
|
||||
|
||||
void SecurityPage::showTls()
|
||||
{
|
||||
pwdEdit->hide();
|
||||
eapTypeCombox->show();
|
||||
|
||||
identityEdit->show();
|
||||
domainEdit->show();
|
||||
caCertPathCombox->show();
|
||||
caNeedBox->show();
|
||||
clientCertPathCombox->show();
|
||||
clientPrivateKeyCombox->show();
|
||||
clientPrivateKeyPwdEdit->show();
|
||||
|
||||
eapMethodCombox->hide();
|
||||
userNameEdit->hide();
|
||||
userPwdEdit->hide();
|
||||
userPwdFlagBox->hide();
|
||||
|
||||
pwdLabel->hide();
|
||||
//企业wifi共有
|
||||
eapTypeLabel->show();
|
||||
//TLS
|
||||
identityLable->show();
|
||||
domainLable->show();
|
||||
caCertPathLabel->show();
|
||||
caNeedFlagLabel->show();
|
||||
clientCertPathLabel->show();
|
||||
clientPrivateKeyLabel->show();
|
||||
clientPrivateKeyPwdLabel->show();
|
||||
|
||||
//PEAP TTLS共有
|
||||
eapMethodLabel->hide();
|
||||
userNameLabel->hide();
|
||||
userPwdLabel->hide();
|
||||
userPwdFlagLabel->hide();
|
||||
}
|
||||
|
||||
void SecurityPage::showPeapOrTtls()
|
||||
{
|
||||
pwdEdit->hide();
|
||||
eapTypeCombox->show();
|
||||
|
||||
identityEdit->hide();
|
||||
domainEdit->hide();
|
||||
caCertPathCombox->hide();
|
||||
caNeedBox->hide();
|
||||
clientCertPathCombox->hide();
|
||||
clientPrivateKeyCombox->hide();
|
||||
clientPrivateKeyPwdEdit->hide();
|
||||
|
||||
eapMethodCombox->show();
|
||||
userNameEdit->show();
|
||||
userPwdEdit->show();
|
||||
userPwdFlagBox->show();
|
||||
|
||||
pwdLabel->hide();
|
||||
//企业wifi共有
|
||||
eapTypeLabel->show();
|
||||
//TLS
|
||||
identityLable->hide();
|
||||
domainLable->hide();
|
||||
caCertPathLabel->hide();
|
||||
caNeedFlagLabel->hide();
|
||||
clientCertPathLabel->hide();
|
||||
clientPrivateKeyLabel->hide();
|
||||
clientPrivateKeyPwdLabel->hide();
|
||||
|
||||
//PEAP TTLS共有
|
||||
eapMethodLabel->show();
|
||||
userNameLabel->show();
|
||||
userPwdLabel->show();
|
||||
userPwdFlagLabel->show();
|
||||
}
|
||||
|
||||
KyEapMethodTlsInfo SecurityPage::assembleTlsInfo()
|
||||
{
|
||||
KyEapMethodTlsInfo info;
|
||||
info.identity = identityEdit->text();
|
||||
info.domain = domainEdit->text();
|
||||
info.caCertPath = caCertPathCombox->currentText();
|
||||
info.bNeedCa = !caNeedBox->isChecked();
|
||||
info.clientCertPath = clientCertPathCombox->currentText();
|
||||
info.clientPrivateKey = clientPrivateKeyCombox->currentText();
|
||||
info.clientPrivateKeyPWD = clientPrivateKeyPwdEdit->text();
|
||||
info.m_privateKeyPWDFlag = (privateKeyBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
KyEapMethodPeapInfo SecurityPage::assemblePeapInfo()
|
||||
{
|
||||
KyEapMethodPeapInfo info;
|
||||
info.phase2AuthMethod = (KyNoEapMethodAuth)eapMethodCombox->currentData().toInt();
|
||||
info.userName = userNameEdit->text();
|
||||
info.userPWD = userPwdEdit->text();
|
||||
info.m_passwdFlag = (userPwdBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None);
|
||||
|
||||
return info;
|
||||
}
|
||||
KyEapMethodTtlsInfo SecurityPage::assembleTtlsInfo()
|
||||
{
|
||||
KyEapMethodTtlsInfo info;
|
||||
if (eapMethodCombox->currentData().toInt() == PAP
|
||||
|| eapMethodCombox->currentData().toInt() == MSCHAP
|
||||
|| eapMethodCombox->currentData().toInt() == MSCHAPV2
|
||||
|| eapMethodCombox->currentData().toInt() == CHAP) {
|
||||
info.authType = AUTH_NO_EAP;
|
||||
info.authEapMethod = (KyEapMethodAuth)eapMethodCombox->currentData().toInt();
|
||||
} else {
|
||||
info.authType = AUTH_EAP;
|
||||
info.authNoEapMethod = (KyNoEapMethodAuth)eapMethodCombox->currentData().toInt();
|
||||
}
|
||||
info.userName = userNameEdit->text();
|
||||
info.userPWD = userPwdEdit->text();
|
||||
info.m_passwdFlag = (userPwdBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None);
|
||||
return info;
|
||||
}
|
||||
|
||||
void SecurityPage::updateSecurityChange(KyWirelessConnectSetting &setting)
|
||||
{
|
||||
qDebug() << "secuTypeCombox->currentData()" << secuTypeCombox->currentData().toInt() << pwdEdit->text();
|
||||
if (secuTypeCombox->currentData().toInt() == NONE) {
|
||||
setting.m_psk = "";
|
||||
} else {
|
||||
setting.m_psk = pwdEdit->text();
|
||||
}
|
||||
|
||||
if (secuTypeCombox->currentData().toInt() == NONE) {
|
||||
setting.m_type = WpaNone;
|
||||
} else if (secuTypeCombox->currentData().toInt() == WPA_AND_WPA2_PERSONAL) {
|
||||
setting.m_type = WpaPsk;
|
||||
} else if (secuTypeCombox->currentData().toInt() == WPA3_PERSONAL) {
|
||||
setting.m_type = SAE;
|
||||
}
|
||||
}
|
||||
|
||||
bool SecurityPage::checkConnectBtnIsEnabled()
|
||||
{
|
||||
int index = secuTypeCombox->currentData().toInt();
|
||||
if (index == NONE) {
|
||||
|
||||
} else if (index == WPA_AND_WPA2_PERSONAL || index == WPA3_PERSONAL) {
|
||||
if (pwdEdit->text().isEmpty() || pwdEdit->text().length() < 8 ) {
|
||||
qDebug() << "password is empty or length < 8";
|
||||
return false;
|
||||
}
|
||||
} else if (index == WPA_AND_WPA2_ENTERPRISE) {
|
||||
int type = eapTypeCombox->currentData().toInt();
|
||||
if (type == TLS) {
|
||||
if (identityEdit->text().isEmpty()) {
|
||||
qDebug() << "tls identity is empty";
|
||||
return false;
|
||||
}
|
||||
QFile cafile(caCertPathCombox->currentText());
|
||||
if(!caNeedBox->isChecked() && !cafile.exists()) {
|
||||
qDebug() << "ca cert filepath " << caCertPathCombox->currentText() << " is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile cliCafile(clientCertPathCombox->currentText());
|
||||
if(!cliCafile.exists()) {
|
||||
qDebug() << "client cert filepath " << clientCertPathCombox->currentText() << " is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile cliKeyfile(clientPrivateKeyCombox->currentText());
|
||||
if(!cliKeyfile.exists()) {
|
||||
qDebug() << "client private key filepath " << clientPrivateKeyCombox->currentText() << " is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(clientPrivateKeyPwdEdit->text().isEmpty()) {
|
||||
qDebug() << "client Private Key password is empty";
|
||||
return false;
|
||||
}
|
||||
} else if (type == PEAP || type == TTLS) {
|
||||
if(userNameEdit->text().isEmpty() || userPwdEdit->text().isEmpty()) {
|
||||
qDebug() << "user name or user password is empty";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SecurityPage::setEnableOfSaveBtn()
|
||||
{
|
||||
emit setSecuPageState(checkConnectBtnIsEnabled());
|
||||
}
|
||||
|
||||
void SecurityPage::onSecuTypeComboxIndexChanged()
|
||||
{
|
||||
int index = secuTypeCombox->currentData().toInt();
|
||||
qDebug() << "onSecuTypeComboxIndexChanged" << index;
|
||||
if (index == WPA_AND_WPA2_PERSONAL || index == WPA3_PERSONAL) {
|
||||
showPsk();
|
||||
} else if (index == WPA_AND_WPA2_ENTERPRISE) {
|
||||
onEapTypeComboxIndexChanged();
|
||||
} else if (index == NONE) {
|
||||
showNone();
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityPage::onEapTypeComboxIndexChanged()
|
||||
{
|
||||
int index = eapTypeCombox->currentData().toInt();
|
||||
if (index == TLS) {
|
||||
showTls();
|
||||
} else if (index == PEAP) {
|
||||
showPeapOrTtls();
|
||||
eapMethodCombox->clear();
|
||||
eapMethodCombox->addItem("MSCHAPv2", KyAuthMethodMschapv2);
|
||||
eapMethodCombox->addItem("MD5", KyAuthMethodMd5);
|
||||
eapMethodCombox->addItem("GTC", KyAuthMethodGtc);
|
||||
} else if (index == TTLS) {
|
||||
showPeapOrTtls();
|
||||
eapMethodCombox->clear();
|
||||
eapMethodCombox->addItem("pap", PAP);
|
||||
eapMethodCombox->addItem("mschap", MSCHAP);
|
||||
eapMethodCombox->addItem("mschapv2(eap)", MSCHAPV2_EAP);
|
||||
eapMethodCombox->addItem("mschapv2", MSCHAPV2);
|
||||
eapMethodCombox->addItem("chap", CHAP);
|
||||
eapMethodCombox->addItem("md5(eap)", MD5_EAP);
|
||||
eapMethodCombox->addItem("gtc(eap)", GTC_EAP);
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityPage::onCaNeedBoxClicked()
|
||||
{
|
||||
if (caNeedBox->isChecked()) {
|
||||
caCertPathCombox->setEnabled(false);
|
||||
} else {
|
||||
caCertPathCombox->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityPage::onPwdBoxClicked()
|
||||
{
|
||||
if (pwdEdit->echoMode() == QLineEdit::Password) {
|
||||
pwdBox->setChecked(true);
|
||||
pwdEdit->setEchoMode(QLineEdit::Normal);
|
||||
} else {
|
||||
pwdBox->setChecked(false);
|
||||
pwdEdit->setEchoMode(QLineEdit::Password);
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityPage::onUserPwdBox()
|
||||
{
|
||||
if (userPwdEdit->echoMode() == QLineEdit::Password) {
|
||||
userPwdBox->setChecked(true);
|
||||
userPwdEdit->setEchoMode(QLineEdit::Normal);
|
||||
} else {
|
||||
userPwdBox->setChecked(false);
|
||||
userPwdEdit->setEchoMode(QLineEdit::Password);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SecurityPage::onPrivateKeyBoxClicked()
|
||||
{
|
||||
if (clientPrivateKeyPwdEdit->echoMode() == QLineEdit::Password) {
|
||||
privateKeyBox->setChecked(true);
|
||||
clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Normal);
|
||||
} else {
|
||||
privateKeyBox->setChecked(false);
|
||||
clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Password);
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityPage::onCaCertPathComboxIndexChanged(QString str)
|
||||
{
|
||||
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///",
|
||||
tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)"));
|
||||
if (!fileName.isNull()) {
|
||||
QStringList nameList = fileName.split("/");
|
||||
caCertPathCombox->blockSignals(true);
|
||||
caCertPathCombox->setItemText(0, fileName);
|
||||
caCertPathCombox->setCurrentIndex(0);
|
||||
caCertPathCombox->blockSignals(false);
|
||||
} else {
|
||||
caCertPathCombox->blockSignals(true);
|
||||
caCertPathCombox->setItemText(0, tr("None"));
|
||||
caCertPathCombox->setCurrentIndex(0);
|
||||
caCertPathCombox->blockSignals(false);
|
||||
}
|
||||
} else {
|
||||
qWarning() << "Choose file is null or unvalible";
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityPage::onClientCertPathComboxIndexChanged(QString str)
|
||||
{
|
||||
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///",
|
||||
tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)"));
|
||||
if (!fileName.isNull()) {
|
||||
clientCertPathCombox->blockSignals(true);
|
||||
clientCertPathCombox->setItemText(0, fileName);
|
||||
clientCertPathCombox->setCurrentIndex(0);
|
||||
clientCertPathCombox->blockSignals(false);
|
||||
} else {
|
||||
clientCertPathCombox->blockSignals(true);
|
||||
clientCertPathCombox->setItemText(0, tr("None"));
|
||||
clientCertPathCombox->setCurrentIndex(0);
|
||||
clientCertPathCombox->blockSignals(false);
|
||||
}
|
||||
} else {
|
||||
qWarning() << "Choose file is null or unvalible";
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityPage::onClientPrivateKeyComboxIndexChanged(QString str)
|
||||
{
|
||||
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///",
|
||||
tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)"));
|
||||
if (!fileName.isNull()) {
|
||||
QStringList nameList = fileName.split("/");
|
||||
clientPrivateKeyCombox->blockSignals(true);
|
||||
clientPrivateKeyCombox->setItemText(0, fileName);
|
||||
clientPrivateKeyCombox->setCurrentIndex(0);
|
||||
clientPrivateKeyCombox->blockSignals(false);
|
||||
} else {
|
||||
clientPrivateKeyCombox->blockSignals(true);
|
||||
clientPrivateKeyCombox->setItemText(0, tr("None"));
|
||||
clientPrivateKeyCombox->setCurrentIndex(0);
|
||||
clientPrivateKeyCombox->blockSignals(false);
|
||||
}
|
||||
} else {
|
||||
qWarning() << "Choose file is null or unvalible";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,17 +6,107 @@
|
|||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
|
||||
#include "coninfo.h"
|
||||
|
||||
|
||||
class SecurityPage : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SecurityPage(QWidget *parent = nullptr);
|
||||
private:
|
||||
QFormLayout *mDetailLayout;
|
||||
|
||||
void setSecurity(KySecuType index);
|
||||
void setPsk(const QString &psk);
|
||||
void setTlsInfo(KyEapMethodTlsInfo &info);
|
||||
void setPeapInfo(KyEapMethodPeapInfo &info);
|
||||
void setTtlsInfo(KyEapMethodTtlsInfo &info);
|
||||
|
||||
bool checkIsChanged(const ConInfo info);
|
||||
void updateSecurityChange(KyWirelessConnectSetting &setting);
|
||||
void updateTlsChange(KyEapMethodTlsInfo &info);
|
||||
void updatePeapChange(KyEapMethodPeapInfo &info);
|
||||
void updateTtlsChange(KyEapMethodTtlsInfo &info);
|
||||
|
||||
void getSecuType(KySecuType &secuType, KyEapMethodType &enterpriseType);
|
||||
|
||||
private:
|
||||
QFormLayout *mSecuLayout;
|
||||
|
||||
private:
|
||||
|
||||
QLabel *secuTypeLabel;
|
||||
QLabel *pwdLabel;
|
||||
//企业wifi共有
|
||||
QLabel *eapTypeLabel;
|
||||
//TLS
|
||||
QLabel *identityLable;
|
||||
QLabel *domainLable;
|
||||
QLabel *caCertPathLabel;
|
||||
QLabel *caNeedFlagLabel;
|
||||
QLabel *clientCertPathLabel;
|
||||
QLabel *clientPrivateKeyLabel;
|
||||
QLabel *clientPrivateKeyPwdLabel;
|
||||
|
||||
//PEAP TTLS共有
|
||||
QLabel *eapMethodLabel;
|
||||
QLabel *userNameLabel;
|
||||
QLabel *userPwdLabel;
|
||||
QLabel *userPwdFlagLabel;
|
||||
|
||||
QComboBox *secuTypeCombox;
|
||||
QLineEdit *pwdEdit;
|
||||
QComboBox *eapTypeCombox;
|
||||
//TLS
|
||||
QLineEdit *identityEdit;
|
||||
QLineEdit *domainEdit;
|
||||
QComboBox *caCertPathCombox;
|
||||
QCheckBox *caNeedBox;
|
||||
QComboBox *clientCertPathCombox;
|
||||
QComboBox *clientPrivateKeyCombox;
|
||||
QLineEdit *clientPrivateKeyPwdEdit;
|
||||
|
||||
//PEAP && TTLS
|
||||
QComboBox *eapMethodCombox;
|
||||
QLineEdit *userNameEdit;
|
||||
QLineEdit *userPwdEdit;
|
||||
QCheckBox *userPwdFlagBox;
|
||||
|
||||
QCheckBox *pwdBox;
|
||||
QCheckBox *userPwdBox;
|
||||
QCheckBox *privateKeyBox;
|
||||
|
||||
void showNone();
|
||||
void showPsk();
|
||||
void showTls();
|
||||
void showPeapOrTtls();
|
||||
void initUI();
|
||||
void initConnect();
|
||||
|
||||
KyEapMethodTlsInfo assembleTlsInfo();
|
||||
KyEapMethodPeapInfo assemblePeapInfo();
|
||||
KyEapMethodTtlsInfo assembleTtlsInfo();
|
||||
|
||||
bool checkConnectBtnIsEnabled();
|
||||
|
||||
|
||||
private slots:
|
||||
void onSecuTypeComboxIndexChanged();
|
||||
void onEapTypeComboxIndexChanged();
|
||||
void setEnableOfSaveBtn();
|
||||
|
||||
void onCaNeedBoxClicked();
|
||||
void onPwdBoxClicked();
|
||||
void onUserPwdBox();
|
||||
void onPrivateKeyBoxClicked();
|
||||
|
||||
void onCaCertPathComboxIndexChanged(QString str);
|
||||
void onClientCertPathComboxIndexChanged(QString str);
|
||||
void onClientPrivateKeyComboxIndexChanged(QString str);
|
||||
|
||||
signals:
|
||||
void setSecuPageState(bool);
|
||||
};
|
||||
|
||||
#endif // SECURITYWIDGET_H
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <QKeyEvent>
|
||||
#include <QProcess>
|
||||
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
|
||||
#define MAINWINDOW_WIDTH 420
|
||||
#define MAINWINDOW_HEIGHT 456
|
||||
#define THEME_SCHAME "org.ukui.style"
|
||||
|
@ -151,14 +153,19 @@ void MainWindow::initDbusConnnect()
|
|||
connect(m_wlanWidget, &WlanPage::activateFailed, this, &MainWindow::activateFailed);
|
||||
connect(m_wlanWidget, &WlanPage::deactivateFailed, this, &MainWindow::deactivateFailed);
|
||||
|
||||
connect(m_lanWidget, &LanPage::listUpdate, this, &MainWindow::listUpdate);
|
||||
connect(m_wlanWidget, &WlanPage::listUpdate, this, &MainWindow::listUpdate);
|
||||
connect(m_lanWidget, &LanPage::lanAdd, this, &MainWindow::lanAdd);
|
||||
connect(m_lanWidget, &LanPage::lanRemove, this, &MainWindow::lanRemove);
|
||||
connect(m_lanWidget, &LanPage::lanUpdate, this, &MainWindow::lanUpdate);
|
||||
connect(m_lanWidget, &LanPage::lanActiveConnectionStateChanged, this, &MainWindow::lanActiveConnectionStateChanged);
|
||||
|
||||
connect(m_lanWidget, &LanPage::wiredActivating, this, &MainWindow::wiredActivating);
|
||||
connect(m_wlanWidget, &WlanPage::wirelessActivating, this, &MainWindow::wirelessActivating);
|
||||
|
||||
connect(m_wlanWidget, &WlanPage::wlanAdd, this, &MainWindow::wlanAdd);
|
||||
connect(m_wlanWidget, &WlanPage::wlanRemove, this, &MainWindow::wlanRemove);
|
||||
connect(m_wlanWidget, &WlanPage::wlanActiveConnectionStateChanged, this, &MainWindow::wlanactiveConnectionStateChanged);
|
||||
connect(m_wlanWidget, &WlanPage::hotspotDeactivated, this, &MainWindow::hotspotDeactivated);
|
||||
connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated);
|
||||
connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange);
|
||||
connect(m_wlanWidget, &WlanPage::signalStrengthChange, this, &MainWindow::signalStrengthChange);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -399,24 +406,66 @@ void MainWindow::getStoredApInfo(QStringList &list)
|
|||
m_wlanWidget->getStoredApInfo(list);
|
||||
}
|
||||
|
||||
//有线连接断开
|
||||
void MainWindow::activateWired(const QString& devName, const QString& connName)
|
||||
{
|
||||
|
||||
void MainWindow::setWiredDeviceEnable(const QString& devName, bool enable)
|
||||
{
|
||||
m_lanWidget->setWiredDeviceEnable(devName, enable);
|
||||
}
|
||||
void MainWindow::showPropertyWidget(QString devName, QString ssid)
|
||||
{
|
||||
KyNetworkDeviceResourse *devResourse = new KyNetworkDeviceResourse();
|
||||
QStringList wiredDeviceList;
|
||||
wiredDeviceList.clear();
|
||||
devResourse->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDeviceList);
|
||||
if (wiredDeviceList.contains(devName)) {
|
||||
qDebug() << "showPropertyWidget device type wired device name " << devName << " uuid " << ssid;
|
||||
m_lanWidget->showDetailPage(devName, ssid);
|
||||
delete devResourse;
|
||||
devResourse = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList wirelessDeviceList;
|
||||
wirelessDeviceList.clear();
|
||||
devResourse->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDeviceList);
|
||||
if (wirelessDeviceList.contains(devName)) {
|
||||
qDebug() << "showPropertyWidget device type wireless device name " << devName << " ssid " << ssid;
|
||||
m_wlanWidget->showDetailPage(devName, ssid);
|
||||
delete devResourse;
|
||||
devResourse = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
qWarning() << "showPropertyWidget no such device " << devName;
|
||||
delete devResourse;
|
||||
devResourse = nullptr;
|
||||
}
|
||||
|
||||
void MainWindow::deactivateWired(const QString& devName, const QString& connName)
|
||||
void MainWindow::showCreateWiredConnectWidget(const QString devName)
|
||||
{
|
||||
qDebug() << "showCreateWiredConnectWidget! devName = " << devName;
|
||||
NetDetail *netDetail = new NetDetail(devName, "", "", false, false, true, this);
|
||||
netDetail->show();
|
||||
}
|
||||
|
||||
//有线连接断开
|
||||
void MainWindow::activateWired(const QString& devName, const QString& connUuid)
|
||||
{
|
||||
m_lanWidget->activateWired(devName, connUuid);
|
||||
}
|
||||
|
||||
void MainWindow::deactivateWired(const QString& devName, const QString& connUuid)
|
||||
{
|
||||
m_lanWidget->deactivateWired(devName, connUuid);
|
||||
}
|
||||
|
||||
//无线连接断开
|
||||
void MainWindow::activateWireless(const QString& devName, const QString& ssid)
|
||||
{
|
||||
|
||||
m_wlanWidget->activateWireless(devName, ssid);
|
||||
}
|
||||
|
||||
void MainWindow::deactivateWireless(const QString& devName, const QString& ssid)
|
||||
{
|
||||
|
||||
m_wlanWidget->deactivateWireless(devName, ssid);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <QDBusInterface>
|
||||
#include "lanpage.h"
|
||||
#include "wlanpage.h"
|
||||
#include "netdetails/netdetail.h"
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
|
@ -33,27 +34,41 @@ public:
|
|||
//获取热点
|
||||
void getStoredApInfo(QStringList &list);
|
||||
//有线连接断开
|
||||
void activateWired(const QString& devName, const QString& connName);
|
||||
void deactivateWired(const QString& devName, const QString& connName);
|
||||
void activateWired(const QString& devName, const QString& connUuid);
|
||||
void deactivateWired(const QString& devName, const QString& connUuid);
|
||||
//无线连接断开
|
||||
void activateWireless(const QString& devName, const QString& ssid);
|
||||
void deactivateWireless(const QString& devName, const QString& ssid);
|
||||
|
||||
void setWiredDeviceEnable(const QString& devName, bool enable);
|
||||
|
||||
//唤起属性页 根据网卡类型 参数2 为ssid/uuid
|
||||
void showPropertyWidget(QString devName, QString ssid);
|
||||
//唤起新建有线连接界面
|
||||
void showCreateWiredConnectWidget(const QString devName);
|
||||
|
||||
signals:
|
||||
//设备插拔
|
||||
void deviceStatusChanged();
|
||||
//设备名称变化
|
||||
void deviceNameChanged(QString oldName, QString newName);
|
||||
//设备有线无线列表更新(有线增删、无线增加减少)
|
||||
void listUpdate(QString devName);
|
||||
//控制面板连接中
|
||||
void wiredActivating(QString devName, QString ssid);
|
||||
void wirelessActivating(QString devName, QString ssid);
|
||||
//有线无线列表更新(有线增删、无线增加减少)
|
||||
void lanAdd(QString devName, QStringList info);
|
||||
void lanRemove(QString dbusPath);
|
||||
void lanUpdate(QString devName, QStringList info);
|
||||
void wlanAdd(QString devName, QStringList info);
|
||||
void wlanRemove(QString devName,QString ssid);
|
||||
void wlanactiveConnectionStateChanged(QString devName, QString ssid, int status);
|
||||
void lanActiveConnectionStateChanged(QString devName, QString uuid, int status);
|
||||
void activateFailed(QString errorMessage);
|
||||
void deactivateFailed(QString errorMessage);
|
||||
//热点断开
|
||||
void hotspotDeactivated(QString devName, QString ssid);
|
||||
void hotspotActivated(QString devName, QString ssid);
|
||||
//信号强度变化
|
||||
void signalStrengthChange(QString devName, QString ssid, int strength);
|
||||
//安全性变化
|
||||
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
||||
void mainWindowVisibleChanged(const bool &visible);
|
||||
public slots:
|
||||
|
||||
|
|
|
@ -15,32 +15,34 @@
|
|||
#define ITEM_HEIGHT 48
|
||||
|
||||
const QString WIRED_SWITCH = "wiredswitch";
|
||||
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
|
||||
//const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
|
||||
|
||||
LanPage::LanPage(QWidget *parent) : TabPage(parent)
|
||||
{
|
||||
//释放问题
|
||||
m_activeResourse = new KyActiveConnectResourse;
|
||||
m_connectResourse = new KyConnectResourse;
|
||||
m_device = new KyNetworkDeviceResourse;
|
||||
devList.empty();
|
||||
m_nullLanItem = new LanListItem();
|
||||
|
||||
initDevice();
|
||||
initUI();
|
||||
initDeviceCombox();
|
||||
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
|
||||
initNetSwitch();
|
||||
} else {
|
||||
} else {
|
||||
qDebug()<<"[LanPage] org.ukui.kylin-nm.switch is not installed!";
|
||||
}
|
||||
}
|
||||
initDevice();
|
||||
initDeviceCombox();
|
||||
initList(m_deviceName);
|
||||
connect(m_activeResourse, &KyActiveConnectResourse::stateChangeReason, this, &LanPage::updateLanlist);
|
||||
connect(m_connectResourse, &KyConnectResourse::connectionAdd, this, &LanPage::addConnectionSlot);
|
||||
connect(m_connectResourse, &KyConnectResourse::connectionRemove, this, &LanPage::removeConnectionSlot);
|
||||
connect(m_connectResourse, &KyConnectResourse::connectionUpdate, this, &LanPage::connectionUpdateSlot);
|
||||
connect(m_device, &KyNetworkDeviceResourse::deviceAdd, this, &LanPage::onDeviceAdd);
|
||||
connect(m_device, &KyNetworkDeviceResourse::deviceRemove, this, &LanPage::onDeviceRemove);
|
||||
connect(m_device, &KyNetworkDeviceResourse::deviceNameUpdate, this, &LanPage::onDeviceNameUpdate);
|
||||
//为什么同一个类中要用信号槽
|
||||
connect(this, &LanPage::deviceStatusChanged, this, &LanPage::onDeviceChanged);
|
||||
}
|
||||
|
||||
|
@ -120,7 +122,12 @@ void LanPage::onLanSwitchClicked()
|
|||
|
||||
void LanPage::removeConnectionSlot(QString path) //删除时后端会自动断开激活,将其从未激活列表中删除
|
||||
{
|
||||
//for dbus
|
||||
qDebug() << "[LanPage] emit lanRemove because removeConnectionSlot " << path;
|
||||
emit lanRemove(path);
|
||||
|
||||
qDebug()<<"[LanPage] Removing a connection, path:"<<path;
|
||||
bool isLan = false;
|
||||
QEventLoop loop;
|
||||
QTimer::singleShot(200, &loop, SLOT(quit()));
|
||||
loop.exec();
|
||||
|
@ -132,10 +139,7 @@ void LanPage::removeConnectionSlot(QString path) //删除时后端会
|
|||
m_inactivatedLanListWidget->removeItemWidget(iters.value());
|
||||
delete(iters.value());
|
||||
m_deactiveMap.erase(iters);
|
||||
|
||||
//for dbus
|
||||
qDebug() << "[LanPage] because removeConnectionSlot " << item->m_ifaceName;
|
||||
emit listUpdate(item->m_ifaceName);
|
||||
isLan = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -144,6 +148,27 @@ void LanPage::removeConnectionSlot(QString path) //删除时后端会
|
|||
|
||||
void LanPage::addConnectionSlot(QString uuid) //新增一个有线连接,将其加入到激活列表
|
||||
{
|
||||
QString devName;
|
||||
NetworkManager::ConnectionSettings::ConnectionType type;
|
||||
if(m_connectResourse->getInterfaceByUuid(devName, type, uuid)) {
|
||||
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
||||
qDebug() << "[LanPage] addConnectionSlot but type is not Wired";
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "[LanPage] addConnectionSlot but uuid is invalid";
|
||||
}
|
||||
|
||||
//for dbus
|
||||
KyConnectItem *item = nullptr;
|
||||
item = m_connectResourse->getConnectionItemByUuid(uuid, devName);
|
||||
if (nullptr != item) {
|
||||
QStringList info;
|
||||
info << item->m_connectName << uuid << item->m_connectPath;
|
||||
qDebug() << "[LanPage] emit lanAdd because addConnection " << devName;
|
||||
emit lanAdd(devName, info);
|
||||
}
|
||||
|
||||
KyConnectItem * newItem = m_connectResourse->getConnectionItemByUuid(uuid, m_deviceName);
|
||||
if (newItem != nullptr) {
|
||||
if (newItem->m_itemType == NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
||||
|
@ -151,13 +176,46 @@ void LanPage::addConnectionSlot(QString uuid) //新增一个有线
|
|||
addNewItem(newItem, m_inactivatedLanListWidget);
|
||||
m_deactiveMap.insert(newItem, m_listWidgetItem);
|
||||
}
|
||||
//for dbus
|
||||
qDebug() << "[LanPage] because addConnectionSlot " << newItem->m_ifaceName;
|
||||
emit listUpdate(newItem->m_ifaceName);
|
||||
|
||||
} else {
|
||||
qDebug()<<"[LanPage] GetConnectionItemByUuid is empty when add a new!";
|
||||
}
|
||||
}
|
||||
void LanPage::connectionUpdateSlot(QString uuid)
|
||||
{
|
||||
//for dbus
|
||||
QStringList devNameList;
|
||||
if (m_activeResourse->isActiveConnection(uuid, devNameList)) {
|
||||
for (int i = 0; i < devNameList.size(); ++i) {
|
||||
KyConnectItem *item = nullptr;
|
||||
item = m_activeResourse->getActiveConnectionByUuid(uuid, devNameList.at(i));
|
||||
if (nullptr != item) {
|
||||
if (item->m_itemType != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
||||
return;
|
||||
}
|
||||
QStringList info;
|
||||
info << item->m_connectName << uuid << item->m_connectPath;
|
||||
emit lanUpdate(devNameList.at(i), info);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QString devName;
|
||||
NetworkManager::ConnectionSettings::ConnectionType type;
|
||||
if (!m_connectResourse->getInterfaceByUuid(devName, type, uuid)) {
|
||||
return;
|
||||
}
|
||||
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
||||
return;
|
||||
}
|
||||
KyConnectItem *item = nullptr;
|
||||
item = m_connectResourse->getConnectionItemByUuid(uuid, devName);
|
||||
if (nullptr != item) {
|
||||
QStringList info;
|
||||
info << item->m_connectName << uuid << item->m_connectPath;
|
||||
emit lanUpdate(devName, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LanPage::initDevice()
|
||||
{
|
||||
|
@ -187,18 +245,32 @@ void LanPage::initDevice()
|
|||
void LanPage::initDeviceCombox()
|
||||
{
|
||||
//TODO 获取设备列表,单设备时隐藏下拉框,多设备时添加到下拉框
|
||||
QMap<QString, bool> enableMap;
|
||||
getDeviceEnableState(0,enableMap);
|
||||
m_deviceComboBox->clear();
|
||||
m_deviceMap.clear();
|
||||
getWiredList(m_deviceMap);
|
||||
// if (m_deactiveMap.count() <= 1) {
|
||||
// m_deviceFrame->hide();
|
||||
// } else{
|
||||
m_deviceFrame->show();
|
||||
QMap<QString, QVector<QStringList> >::iterator iter;
|
||||
for (iter = m_deviceMap.begin(); iter != m_deviceMap.constEnd(); ++iter) {
|
||||
m_deviceFrame->show();
|
||||
QMap<QString, QVector<QStringList> >::iterator iter;
|
||||
for (iter = m_deviceMap.begin(); iter != m_deviceMap.constEnd(); ++iter) {
|
||||
if (enableMap.contains(iter.key())) {
|
||||
if (enableMap[iter.key()]) {
|
||||
m_deviceComboBox->addItem(iter.key());
|
||||
}
|
||||
} else {
|
||||
m_deviceComboBox->addItem(iter.key());
|
||||
saveDeviceEnableState(iter.key(), true);
|
||||
}
|
||||
// }
|
||||
}
|
||||
if (m_deviceComboBox->currentText().isEmpty()) {
|
||||
if (m_switchGsettings->get(WIRED_SWITCH).toBool()) {
|
||||
m_switchGsettings->set(WIRED_SWITCH,false);
|
||||
}
|
||||
} else {
|
||||
if (!m_switchGsettings->get(WIRED_SWITCH).toBool()) {
|
||||
m_switchGsettings->set(WIRED_SWITCH,true);
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "[LanPage]current:" << m_deviceComboBox->currentText();
|
||||
}
|
||||
|
@ -266,7 +338,7 @@ void LanPage::onDeviceNameUpdate(QString oldName, QString newName)
|
|||
if (devList.contains(oldName)) {
|
||||
devList.removeOne(oldName);
|
||||
devList.append(newName);
|
||||
qDebug() << "LanPage emit deviceNameUpdate " << oldName << newName;
|
||||
qDebug() << "[LanPage] emit deviceNameUpdate " << oldName << newName;
|
||||
emit deviceNameChanged(oldName, newName);
|
||||
}
|
||||
}
|
||||
|
@ -363,19 +435,36 @@ void LanPage::initList(QString m_deviceName) //程序拉起,初始化显
|
|||
void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason)
|
||||
{
|
||||
qDebug()<<"[LanPage] State change slot:"<<state;
|
||||
|
||||
QString devName;
|
||||
if (state == NetworkManager::ActiveConnection::State::Activating) {
|
||||
qDebug() << "[LanPage] wiredActivating " << devName;
|
||||
emit wiredActivating(devName,uuid);
|
||||
NetworkManager::ConnectionSettings::ConnectionType type;
|
||||
|
||||
if(m_connectResourse->getInterfaceByUuid(devName, type, uuid)) {
|
||||
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
||||
qDebug() << "[LanPage] updateLanlist but type is not Wired";
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "[LanPage] updateLanlist but uuid is invalid";
|
||||
}
|
||||
|
||||
if (state == NetworkManager::ActiveConnection::State::Activated || state == NetworkManager::ActiveConnection::State::Deactivated)
|
||||
{
|
||||
qDebug() << "[LanPage] because updateLanlist " <<devName;
|
||||
emit listUpdate(devName);
|
||||
QStringList devNameList;
|
||||
if (m_activeResourse->isActiveConnection(uuid, devNameList)) {
|
||||
for (int i = 0; i < devNameList.size(); ++i) {
|
||||
KyConnectItem *item = nullptr;
|
||||
item = m_activeResourse->getActiveConnectionByUuid(uuid, devNameList.at(i));
|
||||
if (nullptr != item) {
|
||||
QStringList info;
|
||||
info << item->m_connectName << uuid << item->m_connectPath;
|
||||
emit lanActiveConnectionStateChanged(devNameList.at(i), uuid, state);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qDebug() << "emit lanActiveConnectionStateChanged" << devName << uuid << state;
|
||||
emit lanActiveConnectionStateChanged(devName, uuid, state);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
||||
qDebug()<<"Get a deactivate, begin to remove it from activeList";
|
||||
QMap<KyConnectItem *, QListWidgetItem *>::iterator i;
|
||||
|
@ -461,7 +550,7 @@ void LanPage::getWiredList(QMap<QString, QVector<QStringList> > &map)
|
|||
QVector<QStringList> vector;
|
||||
m_activeResourse->getActiveConnectionList(deviceName,NetworkManager::ConnectionSettings::Wired,activedList);
|
||||
if (!activedList.isEmpty()) {
|
||||
vector.append(QStringList()<<activedList.at(0)->m_connectName<<activedList.at(0)->m_connectUuid);
|
||||
vector.append(QStringList() << activedList.at(0)->m_connectName << activedList.at(0)->m_connectUuid << activedList.at(0)->m_connectPath);
|
||||
} else {
|
||||
vector.append(QStringList()<<("--"));
|
||||
}
|
||||
|
@ -477,12 +566,50 @@ void LanPage::getWiredList(QMap<QString, QVector<QStringList> > &map)
|
|||
return;
|
||||
}
|
||||
|
||||
void LanPage::setWiredDeviceEnable(const QString& devName, bool enable)
|
||||
{
|
||||
saveDeviceEnableState(devName, enable);
|
||||
initDeviceCombox();
|
||||
}
|
||||
|
||||
void LanPage::activateWired(const QString& devName, const QString& connUuid)
|
||||
{
|
||||
//todo:
|
||||
qDebug() << "activateWired" << devName << connUuid;
|
||||
KyWiredConnectOperation a;
|
||||
a.activateConnection(connUuid, devName);
|
||||
}
|
||||
|
||||
void LanPage::deactivateWired(const QString& devName, const QString& connUuid)
|
||||
{
|
||||
//todo:
|
||||
qDebug() << "deactivateWired" << devName << connUuid;
|
||||
KyConnectItem *item = nullptr;
|
||||
item = m_activeResourse->getActiveConnectionByUuid(connUuid, devName);
|
||||
if (nullptr == item) {
|
||||
//todo: 通知桌面
|
||||
qDebug() << "not ActiveConnection";
|
||||
return;
|
||||
}
|
||||
|
||||
KyWiredConnectOperation a;
|
||||
a.deactivateWiredConnection(item->m_connectName, connUuid);
|
||||
}
|
||||
|
||||
void LanPage::showDetailPage(QString devName, QString uuid)
|
||||
{
|
||||
KyConnectItem *item = nullptr;
|
||||
bool isActive = true;
|
||||
item = m_activeResourse->getActiveConnectionByUuid(uuid, devName);
|
||||
if (nullptr == item) {
|
||||
item = m_connectResourse->getConnectionItemByUuid(uuid, devName);
|
||||
if (nullptr == item) {
|
||||
qWarning()<<"[LanPage] GetConnectionItemByUuid is empty when showDetailPage";
|
||||
return;
|
||||
}
|
||||
isActive= false;
|
||||
}
|
||||
|
||||
NetDetail *netDetail = new NetDetail(devName, item->m_connectName, uuid, isActive, false, false, this);
|
||||
netDetail->show();
|
||||
delete item;
|
||||
item = nullptr;
|
||||
}
|
||||
|
|
|
@ -26,10 +26,13 @@ public:
|
|||
void getWiredList(QMap<QString, QVector<QStringList> > &map);
|
||||
void activateWired(const QString& devName, const QString& connUuid);
|
||||
void deactivateWired(const QString& devName, const QString& connUuid);
|
||||
|
||||
void showDetailPage(QString devName, QString uuid);
|
||||
void setWiredDeviceEnable(const QString& devName, bool enable);
|
||||
signals:
|
||||
void wiredActivating(QString devName, QString ssid);
|
||||
|
||||
void lanAdd(QString devName, QStringList info);
|
||||
void lanRemove(QString dbusPath);
|
||||
void lanUpdate(QString devName, QStringList info);
|
||||
void lanActiveConnectionStateChanged(QString interface, QString uuid, int status);
|
||||
private:
|
||||
void initDevice();//初始化默认设备
|
||||
void initDeviceCombox();
|
||||
|
@ -71,6 +74,7 @@ private slots:
|
|||
void updateLanlist(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason);
|
||||
void addConnectionSlot(QString uuid);
|
||||
void removeConnectionSlot(QString path);
|
||||
void connectionUpdateSlot(QString uuid);
|
||||
void onSwithGsettingsChanged(const QString &key);
|
||||
void onLanSwitchClicked();
|
||||
void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType);
|
||||
|
|
|
@ -149,3 +149,60 @@ bool checkDeviceExist(KyDeviceType deviceType, QString deviceName)
|
|||
delete kdr;
|
||||
return devList.contains(deviceName);
|
||||
}
|
||||
|
||||
void saveDeviceEnableState(QString deviceName, bool enable)
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("CARDEABLE");
|
||||
m_settings->setValue(deviceName, enable);
|
||||
m_settings->endGroup();
|
||||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
void getDeviceEnableState(int type, QMap<QString, bool> &map)
|
||||
{
|
||||
map.clear();
|
||||
if (!QFile::exists(CONFIG_FILE_PATH)) {
|
||||
return;
|
||||
}
|
||||
if (type != WIRED && type != WIRELESS) {
|
||||
qDebug() << "getDeviceEnableState but wrong type";
|
||||
return;
|
||||
}
|
||||
|
||||
KyNetworkDeviceResourse * kdr = new KyNetworkDeviceResourse();
|
||||
QStringList wiredDevList,wirelessDevList;
|
||||
wiredDevList.clear();
|
||||
wirelessDevList.clear();
|
||||
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("CARDEABLE");
|
||||
|
||||
if (type == WIRED) {
|
||||
kdr->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDevList);
|
||||
if (!wiredDevList.isEmpty()) {
|
||||
for (int i = 0; i < wiredDevList.size(); ++i) {
|
||||
bool enable = m_settings->value(wiredDevList.at(i), true).toBool();
|
||||
map.insert(wiredDevList.at(i), enable);
|
||||
}
|
||||
}
|
||||
} else if (type == WIRELESS) {
|
||||
kdr->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDevList);
|
||||
if (!wirelessDevList.isEmpty()) {
|
||||
for (int i = 0; i < wirelessDevList.size(); ++i) {
|
||||
bool enable = m_settings->value(wirelessDevList.at(i), true).toBool();
|
||||
map.insert(wirelessDevList.at(i), enable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_settings->endGroup();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
delete kdr;
|
||||
kdr = nullptr;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ enum KyDeviceType
|
|||
const QString CONFIG_FILE_PATH = QDir::homePath() + "/.config/ukui/kylin-nm.conf";
|
||||
bool checkDeviceExist(KyDeviceType deviceType, QString deviceName);
|
||||
void setDefaultDevice(KyDeviceType deviceType, QString deviceName);
|
||||
void saveDeviceEnableState(QString deviceName, bool enable);
|
||||
void getDeviceEnableState(int type, QMap<QString, bool> &map);
|
||||
|
||||
class TabPage : public QWidget
|
||||
{
|
||||
|
@ -54,7 +56,6 @@ signals:
|
|||
void deviceNameChanged(QString oldName, QString newName);
|
||||
void activateFailed(QString errorMessage);
|
||||
void deactivateFailed(QString errorMessage);
|
||||
void listUpdate(QString devName);
|
||||
|
||||
protected:
|
||||
void initUI();
|
||||
|
|
|
@ -107,8 +107,9 @@ void WlanPage::initConnections()
|
|||
{
|
||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::onWlanAdded);
|
||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved);
|
||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::listUpdate);
|
||||
connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::listUpdate);
|
||||
connect(m_resource, &KyWirelessNetResource::signalStrengthChange, this, &WlanPage::signalStrengthChange);
|
||||
connect(m_resource, &KyWirelessNetResource::secuTypeChange, this, &WlanPage::secuTypeChange);
|
||||
|
||||
// connect(m_resource, &KyWirelessNetResource::wifiNetworkUpdate, this, &WlanPage::onWlanUpdated);
|
||||
connect(m_connectResource, &KyActiveConnectResourse::stateChangeReason, this, &WlanPage::onActivatedWlanChanged);
|
||||
// connect(m_connectoperation, &KyConnectOperation::activateConnectionError, this, &WlanPage::showDesktopNotify);
|
||||
|
@ -122,6 +123,8 @@ void WlanPage::initConnections()
|
|||
m_netSwitch->setSwitchStatus(m_switchGsettings->get(WIRELESS_SWITCH).toBool());
|
||||
connect(m_switchGsettings, &QGSettings::changed, this, [ = ](const QString &key) {
|
||||
if (key == WIRELESS_SWITCH) {
|
||||
bool status = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
|
||||
m_wirelessConnectOpreation->setWirelessEnabled(status);
|
||||
onWlanSwitchStatusChanged(m_switchGsettings->get(WIRELESS_SWITCH).toBool());
|
||||
}
|
||||
});
|
||||
|
@ -136,7 +139,6 @@ void WlanPage::initTimer()
|
|||
{
|
||||
m_scanTimer = new QTimer(this);
|
||||
connect(m_scanTimer, &QTimer::timeout, this, &WlanPage::requestScan);
|
||||
// m_scanTimer->start(10 * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,14 +171,21 @@ void WlanPage::initDevice()
|
|||
void WlanPage::initDeviceCombox()
|
||||
{
|
||||
//TODO 获取设备列表,单设备时隐藏下拉框,多设备时添加到下拉框
|
||||
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &WlanPage::onDeviceComboxIndexChanged);
|
||||
if (m_devList.length() <= 1) {
|
||||
m_deviceFrame->hide();
|
||||
} else {
|
||||
m_deviceFrame->show();
|
||||
foreach (QString device, m_devList) {
|
||||
//空时addItem 会触发currentIndexChanged
|
||||
m_deviceComboBox->addItem(device, device);
|
||||
}
|
||||
int index = m_deviceComboBox->findData(defaultDevice);
|
||||
qDebug() << index;
|
||||
m_deviceComboBox->setCurrentIndex(index);
|
||||
}
|
||||
connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &WlanPage::onDeviceComboxIndexChanged);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,6 +270,7 @@ void WlanPage::getAllWlan()
|
|||
KyWirelessNetItem *data = new KyWirelessNetItem(itemData);
|
||||
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, defaultDevice);
|
||||
QListWidgetItem *wlanItem = new QListWidgetItem(m_inactivatedNetListWidget);
|
||||
qDebug() << itemData.m_NetSsid << itemData.m_isConfigured;
|
||||
connect(wlanItemWidget, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
|
||||
connect(wlanItemWidget, &WlanListItem::connectButtonClicked, this, &WlanPage::onConnectButtonClicked);
|
||||
m_itemsMap.insert(data->m_NetSsid, wlanItem);
|
||||
|
@ -279,8 +289,16 @@ void WlanPage::getAllWlan()
|
|||
|
||||
void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
|
||||
{
|
||||
qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << Q_FUNC_INFO <<__LINE__;
|
||||
//for dbus
|
||||
QStringList info;
|
||||
info <<item.m_NetSsid<<QString::number(item.m_signalStrength)<<item.m_secuType;
|
||||
emit wlanAdd(interface, info);
|
||||
|
||||
|
||||
qDebug() << "A Wlan Added! interface = " << interface << "; ssid = " << item.m_NetSsid << Q_FUNC_INFO <<__LINE__;
|
||||
if (interface != defaultDevice) {
|
||||
qDebug() << "wlan add interface not equal defaultdevice,ignore";
|
||||
}
|
||||
KyWirelessNetItem *data = new KyWirelessNetItem(item);
|
||||
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, data, defaultDevice);
|
||||
connect(wlanItemWidget, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
|
||||
|
@ -297,9 +315,13 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
|
|||
|
||||
void WlanPage::onWlanRemoved(QString interface, QString ssid)
|
||||
{
|
||||
emit wlanRemove(interface, ssid);
|
||||
if (!m_itemsMap.contains(ssid)) { return; }
|
||||
if (m_expandedItem == m_itemsMap.value(ssid)) { m_expandedItem = nullptr; }
|
||||
qDebug() << "A Wlan Removed! interface = " << interface << "; ssid = " << ssid << Q_FUNC_INFO <<__LINE__;
|
||||
if (interface != defaultDevice) {
|
||||
qDebug() << "wlan remove interface not equal defaultdevice,ignore";
|
||||
}
|
||||
int height = m_inactivatedNetListWidget->itemWidget(m_itemsMap.value(ssid))->height();
|
||||
m_inactivatedNetListWidget->takeItem(m_inactivatedNetListWidget->row(m_itemsMap.value(ssid)));
|
||||
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() - height - NET_LIST_SPACING);
|
||||
|
@ -410,16 +432,8 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
|
|||
|
||||
m_resource->getSsidByUuid(uuid, ssid);
|
||||
|
||||
if (state == NetworkManager::ActiveConnection::State::Activating) {
|
||||
qDebug() << "[WlanPage] wirelessActivating" << devName << ssid;
|
||||
emit wirelessActivating(devName, ssid);
|
||||
}
|
||||
|
||||
if (state == NetworkManager::ActiveConnection::State::Activated || state == NetworkManager::ActiveConnection::State::Deactivated)
|
||||
{
|
||||
qDebug() << "[WlanPage] because ActivatedWlanChanged " << devName;
|
||||
emit listUpdate(devName);
|
||||
}
|
||||
qDebug() << "emit wlanActiveConnectionStateChanged" << devName << ssid << state;
|
||||
emit wlanActiveConnectionStateChanged(devName, ssid, state);
|
||||
|
||||
if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
||||
QList<KyApConnectItem *> apConnectItemList;
|
||||
|
@ -532,7 +546,7 @@ void WlanPage::requestScan()
|
|||
void WlanPage::onHiddenWlanClicked()
|
||||
{
|
||||
qDebug() << "[wlanPage] AddHideWifi Clicked! " << Q_FUNC_INFO << __LINE__ ;
|
||||
NetDetail *netDetail = new NetDetail("", "", false, true, false);
|
||||
NetDetail *netDetail = new NetDetail(defaultDevice, "", "", false, true, true, this);
|
||||
netDetail->show();
|
||||
}
|
||||
|
||||
|
@ -629,12 +643,42 @@ void WlanPage::getStoredApInfo(QStringList &list)
|
|||
|
||||
void WlanPage::activateWireless(const QString& devName, const QString& ssid)
|
||||
{
|
||||
//todo
|
||||
KyWirelessNetItem data;
|
||||
if (!m_resource->getWifiNetwork(devName, ssid, data)) {
|
||||
qDebug() << "no such wifi " << ssid << " in " << devName;
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.m_isConfigured) {
|
||||
m_wirelessConnectOpreation->activeWirelessConnect(devName, data.m_connectUuid);
|
||||
} else {
|
||||
//todo: 显示界面输入密码 (无需密码的wifi?)
|
||||
}
|
||||
}
|
||||
|
||||
void WlanPage::deactivateWireless(const QString& devName, const QString& ssid)
|
||||
{
|
||||
//todo
|
||||
KyWirelessNetItem data;
|
||||
if (!m_resource->getWifiNetwork(devName, ssid, data)) {
|
||||
qDebug() << "no such wifi " << ssid << " in " << devName;
|
||||
return;
|
||||
}
|
||||
|
||||
QMap<QString,QStringList> actMap;
|
||||
m_resource->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap);
|
||||
QMap<QString,QStringList>::iterator iter = actMap.begin();
|
||||
if (!actMap.contains(devName)) {
|
||||
qDebug() << "no such device" << devName;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!actMap[devName].contains(ssid)) {
|
||||
qDebug() << "no such actived wifi" << ssid;
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "deActivateWirelessConnection" << devName << ssid;
|
||||
m_wirelessConnectOpreation->deActivateWirelessConnection(data.m_connName, data.m_connectUuid);
|
||||
}
|
||||
|
||||
void WlanPage::onMainWindowVisibleChanged(const bool &visible)
|
||||
|
@ -651,8 +695,27 @@ void WlanPage::onMainWindowVisibleChanged(const bool &visible)
|
|||
}
|
||||
//若页面打开,开始扫描倒计时,若关闭,停止扫描倒计时
|
||||
if (visible) {
|
||||
m_scanTimer->start(10 * 1000);
|
||||
m_scanTimer->start(20 * 1000);
|
||||
} else {
|
||||
m_scanTimer->stop();
|
||||
}
|
||||
}
|
||||
void WlanPage::showDetailPage(QString devName, QString ssid)
|
||||
{
|
||||
KyWirelessNetItem data;
|
||||
if (!m_resource->getWifiNetwork(devName, ssid, data)) {
|
||||
qDebug()<<"[WlanPage] " << ssid << " is missing when showDetailPage";
|
||||
return;
|
||||
}
|
||||
|
||||
QMap<QString,QStringList> actMap;
|
||||
m_resource->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap);
|
||||
if (!actMap.contains(devName)) {
|
||||
qDebug()<<"[WlanPage] " << devName << " is missing when showDetailPage";
|
||||
return;
|
||||
}
|
||||
|
||||
bool isActive = actMap[devName].contains(ssid);
|
||||
NetDetail *netDetail = new NetDetail(devName, ssid, data.m_connectUuid, isActive, true, false, this);
|
||||
netDetail->show();
|
||||
}
|
||||
|
|
|
@ -33,11 +33,16 @@ public:
|
|||
void activateWireless(const QString& devName, const QString& ssid);
|
||||
void deactivateWireless(const QString& devName, const QString& ssid);
|
||||
|
||||
void showDetailPage(QString devName, QString uuid);
|
||||
signals:
|
||||
void oneItemExpanded(const QString &ssid);
|
||||
void wirelessActivating(QString devName, QString ssid);
|
||||
void wlanAdd(QString devName, QStringList info);
|
||||
void wlanRemove(QString devName,QString ssid);
|
||||
void wlanActiveConnectionStateChanged(QString interface, QString ssid, int status);
|
||||
void hotspotDeactivated(QString devName, QString ssid);
|
||||
void hotspotActivated(QString devName, QString ssid);
|
||||
void signalStrengthChange(QString devName, QString ssid, int strength);
|
||||
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
||||
void hiddenWlanClicked();
|
||||
|
||||
public slots:
|
||||
|
|
Loading…
Reference in New Issue