Merge branch 'new-dbus' into 'dbus-interface'
modify connection property See merge request kylin-desktop/kylin-nm!175
This commit is contained in:
commit
1e22ae3a42
|
@ -124,7 +124,6 @@ void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSet
|
|||
|
||||
QList<NetworkManager::Security8021xSetting::EapMethod> list;
|
||||
list.append(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap);
|
||||
wifi_8021x_sett->setInitialized(true);
|
||||
wifi_8021x_sett->setEapMethods(list);
|
||||
wifi_8021x_sett->setPhase2AuthMethod((NetworkManager::Security8021xSetting::AuthMethod)peapInfo.phase2AuthMethod);
|
||||
wifi_8021x_sett->setIdentity(peapInfo.userName);
|
||||
|
|
|
@ -75,12 +75,12 @@ public:
|
|||
bool bChanged;
|
||||
};
|
||||
|
||||
void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &);
|
||||
void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &);
|
||||
void assembleEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &);
|
||||
void assembleEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo);
|
||||
void assembleEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo);
|
||||
void assembleEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo);
|
||||
|
||||
void modifyEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &);
|
||||
void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &);
|
||||
void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &);
|
||||
void modifyEapMethodTlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTlsInfo &tlsInfo);
|
||||
void modifyEapMethodPeapSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodPeapInfo &peapInfo);
|
||||
void modifyEapMethodTtlsSettings(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyEapMethodTtlsInfo &ttlsInfo);
|
||||
|
||||
#endif // KYENTERPRICESETTINGINFO_H
|
||||
|
|
|
@ -52,13 +52,16 @@ NetworkManager::ConnectionSettings::Ptr assembleWirelessSettings(const KyWireles
|
|||
wifi_sett->setSsid(connSettingInfo.m_ssid.toUtf8());
|
||||
wifi_sett->setSecurity("802-11-wireless-security");
|
||||
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)connSettingInfo.m_type);
|
||||
if (KyKeyMgmt::SAE == connSettingInfo.m_type || KyKeyMgmt::WpaPsk == connSettingInfo.m_type)
|
||||
if (connSettingInfo.m_type != KyKeyMgmt::WpaNone && connSettingInfo.m_type != KyKeyMgmt::Unknown)
|
||||
{
|
||||
security_sett->setPsk(connSettingInfo.m_psk);
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)connSettingInfo.m_type);
|
||||
if (KyKeyMgmt::SAE == connSettingInfo.m_type || KyKeyMgmt::WpaPsk == connSettingInfo.m_type)
|
||||
{
|
||||
security_sett->setPsk(connSettingInfo.m_psk);
|
||||
}
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
@ -288,6 +291,10 @@ void KyWirelessConnectOperation::updateWirelessPersonalConnect(const QString &uu
|
|||
return;
|
||||
}
|
||||
|
||||
NetworkManager::Security8021xSetting::Ptr wifi_8021x_sett
|
||||
= connectionSettings->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
|
||||
wifi_8021x_sett->setInitialized(false);
|
||||
|
||||
updateWirelessSecu(connectionSettings, connSettingInfo, bPwdChange);
|
||||
connectPtr->update(connectionSettings->toMap());
|
||||
return;
|
||||
|
@ -357,8 +364,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & devIface,
|
|||
NMVariantMapMap map_settings;
|
||||
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (!isHidden && wifiNet.isNull())
|
||||
{
|
||||
if (!isHidden && wifiNet.isNull()) {
|
||||
qDebug() << "addAndActiveWirelessConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
return;
|
||||
}
|
||||
|
@ -366,8 +372,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & devIface,
|
|||
qDebug() << "addAndActiveWirelessConnect find " << connSettingInfo.m_ssid << " in " << devIface << " or hide";
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||
if (dev.isNull())
|
||||
{
|
||||
if (dev.isNull()) {
|
||||
emit andAndActivateConnectionError("can not find device");
|
||||
return;
|
||||
}
|
||||
|
@ -375,16 +380,11 @@ void KyWirelessConnectOperation::addAndActiveWirelessConnect(QString & devIface,
|
|||
qDebug() << "addAndActiveWirelessConnect device " << devIface << " exist";
|
||||
dev_uni = dev->uni();
|
||||
auto spec_dev = dev->as<NetworkManager::WirelessDevice>();
|
||||
qDebug() << dev_uni;
|
||||
if (!isHidden)
|
||||
{
|
||||
if (!isHidden) {
|
||||
qDebug() << "start assemble";
|
||||
auto access_point = wifiNet->referenceAccessPoint();
|
||||
qDebug() << "1";
|
||||
conn_uni = access_point->uni();
|
||||
qDebug() << "2";
|
||||
conn_name = access_point->ssid();
|
||||
qDebug() << "3";
|
||||
spec_object = conn_uni;
|
||||
qDebug() << "start findBestWirelessSecurity";
|
||||
NetworkManager::WirelessSecurityType sec_type = NetworkManager::findBestWirelessSecurity(spec_dev->wirelessCapabilities()
|
||||
|
@ -402,11 +402,9 @@ qDebug() << dev_uni;
|
|||
break;
|
||||
case NetworkManager::WpaPsk:
|
||||
case NetworkManager::Wpa2Psk:
|
||||
if (NetworkManager::ConnectionSettings::Ptr settings = assembleWpaXPskSettings(access_point, connSettingInfo.m_psk, connSettingInfo.isAutoConnect))
|
||||
{
|
||||
if (NetworkManager::ConnectionSettings::Ptr settings = assembleWpaXPskSettings(access_point, connSettingInfo.m_psk, connSettingInfo.isAutoConnect)) {
|
||||
map_settings = settings->toMap();
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
qWarning() << QStringLiteral("connection settings assembly for '%1' failed, abandoning activation...").arg(conn_name);
|
||||
return;
|
||||
}
|
||||
|
@ -427,8 +425,7 @@ qDebug() << dev_uni;
|
|||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid())
|
||||
{
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = watcher->error().message();
|
||||
qDebug() << "activation of connection failed " << errorMessage;
|
||||
emit andAndActivateConnectionError(errorMessage);
|
||||
|
@ -439,15 +436,12 @@ qDebug() << dev_uni;
|
|||
|
||||
void KyWirelessConnectOperation::requestWirelessScan()
|
||||
{
|
||||
for (auto const & dev : m_networkResourceInstance->m_devices)
|
||||
{
|
||||
for (auto const & dev : m_networkResourceInstance->m_devices) {
|
||||
auto spec_dev = dev->as<NetworkManager::WirelessDevice>();
|
||||
if (nullptr != spec_dev)
|
||||
{
|
||||
if (nullptr != spec_dev) {
|
||||
m_networkResourceInstance->requestScan(spec_dev);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapMethodTlsInfo &info, KyWirelessConnectSetting &connSettingInfo,
|
||||
|
@ -459,11 +453,9 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapM
|
|||
QString spec_object;
|
||||
NMVariantMapMap map_settings;
|
||||
|
||||
if (!isHidden)
|
||||
{
|
||||
if (!isHidden) {
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull())
|
||||
{
|
||||
if (wifiNet.isNull()) {
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTlsConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
return;
|
||||
}
|
||||
|
@ -475,8 +467,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapM
|
|||
}
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||
if (dev.isNull())
|
||||
{
|
||||
if (dev.isNull()) {
|
||||
emit andAndActivateConnectionError("can not find device");
|
||||
return;
|
||||
}
|
||||
|
@ -485,8 +476,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapM
|
|||
NetworkManager::ConnectionSettings::Ptr settings = assembleWirelessSettings(connSettingInfo);
|
||||
assembleEapMethodTlsSettings(settings, info);
|
||||
|
||||
if(settings.isNull())
|
||||
{
|
||||
if(settings.isNull()) {
|
||||
qDebug() << "assembleEapMethodTlsSettings failed";
|
||||
return;
|
||||
}
|
||||
|
@ -496,8 +486,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTlsConnect(KyEapM
|
|||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid())
|
||||
{
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = watcher->error().message();
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTlsConnect failed " << errorMessage;
|
||||
emit andAndActivateConnectionError(errorMessage);
|
||||
|
@ -520,8 +509,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEap
|
|||
if (!isHidden)
|
||||
{
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull())
|
||||
{
|
||||
if (wifiNet.isNull()) {
|
||||
qDebug() << "addAndActiveWirelessEnterPrisePeapConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
return;
|
||||
}
|
||||
|
@ -534,8 +522,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEap
|
|||
}
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||
if (dev.isNull())
|
||||
{
|
||||
if (dev.isNull()) {
|
||||
emit andAndActivateConnectionError("can not find device");
|
||||
return;
|
||||
}
|
||||
|
@ -544,8 +531,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEap
|
|||
NetworkManager::ConnectionSettings::Ptr settings = assembleWirelessSettings(connSettingInfo);
|
||||
assembleEapMethodPeapSettings(settings, info);
|
||||
|
||||
if(settings.isNull())
|
||||
{
|
||||
if(settings.isNull()) {
|
||||
qDebug() << "assembleEapMethodPeapSettings failed";
|
||||
return;
|
||||
}
|
||||
|
@ -554,8 +540,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPrisePeapConnect(KyEap
|
|||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid())
|
||||
{
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = watcher->error().message();
|
||||
qDebug() << "addAndActiveWirelessEnterPrisePeapConnect failed " << errorMessage;
|
||||
emit andAndActivateConnectionError(errorMessage);
|
||||
|
@ -574,11 +559,9 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
|
|||
QString spec_object;
|
||||
NMVariantMapMap map_settings;
|
||||
|
||||
if (!isHidden)
|
||||
{
|
||||
if (!isHidden) {
|
||||
NetworkManager::WirelessNetwork::Ptr wifiNet = checkWifiNetExist(connSettingInfo.m_ssid, devIface);
|
||||
if (wifiNet.isNull())
|
||||
{
|
||||
if (wifiNet.isNull()) {
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect can not find " << connSettingInfo.m_ssid << " in " << devIface;
|
||||
return;
|
||||
}
|
||||
|
@ -590,8 +573,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
|
|||
}
|
||||
|
||||
auto dev = m_networkResourceInstance->findDeviceInterface(devIface);
|
||||
if (dev.isNull())
|
||||
{
|
||||
if (dev.isNull()) {
|
||||
emit andAndActivateConnectionError("can not find device");
|
||||
return;
|
||||
}
|
||||
|
@ -600,8 +582,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
|
|||
NetworkManager::ConnectionSettings::Ptr settings = assembleWirelessSettings(connSettingInfo);
|
||||
assembleEapMethodTtlsSettings(settings, info);
|
||||
|
||||
if(settings.isNull())
|
||||
{
|
||||
if(settings.isNull()) {
|
||||
qDebug() << "assembleEapMethodTtlsSettings failed";
|
||||
return;
|
||||
}
|
||||
|
@ -611,8 +592,7 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
|
|||
QDBusPendingCallWatcher * watcher;
|
||||
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(map_settings, dev_uni, spec_object), this};
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher * watcher) {
|
||||
if (watcher->isError() || !watcher->isValid())
|
||||
{
|
||||
if (watcher->isError() || !watcher->isValid()) {
|
||||
QString errorMessage = watcher->error().message();
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect failed " << errorMessage;
|
||||
emit andAndActivateConnectionError(errorMessage);
|
||||
|
@ -636,8 +616,7 @@ bool KyWirelessConnectOperation::getConnSecretFlags(QString &connUuid, NetworkMa
|
|||
{
|
||||
NetworkManager::Connection::Ptr conn;
|
||||
conn = m_networkResourceInstance->getConnect(connUuid);
|
||||
if (conn.isNull())
|
||||
{
|
||||
if (conn.isNull()) {
|
||||
qDebug() <<"get failed";
|
||||
return false;
|
||||
}
|
||||
|
@ -761,19 +740,15 @@ void KyWirelessConnectOperation::deactiveWirelessAp(const QString apName, const
|
|||
//private
|
||||
NetworkManager::WirelessNetwork::Ptr KyWirelessConnectOperation::checkWifiNetExist(QString ssid, QString devName)
|
||||
{
|
||||
for (auto const & net : m_networkResourceInstance->m_wifiNets)
|
||||
{
|
||||
for (auto const & net : m_networkResourceInstance->m_wifiNets) {
|
||||
auto dev = m_networkResourceInstance->findDeviceUni(net->device());
|
||||
if (dev == nullptr)
|
||||
{
|
||||
if (dev == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (dev->type() != NetworkManager::Device::Wifi || dev->interfaceName() != devName)
|
||||
{
|
||||
if (dev->type() != NetworkManager::Device::Wifi || dev->interfaceName() != devName) {
|
||||
continue;
|
||||
}
|
||||
if (ssid == net->ssid())
|
||||
{
|
||||
if (ssid == net->ssid()) {
|
||||
return net;
|
||||
}
|
||||
}
|
||||
|
@ -803,9 +778,14 @@ void KyWirelessConnectOperation::updateWirelessSecu(NetworkManager::ConnectionSe
|
|||
|
||||
KyKeyMgmt type = connSettingInfo.m_type;
|
||||
qDebug() << "set keyMgmt " << type;
|
||||
// security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)type);
|
||||
if (bPwdChange)
|
||||
{
|
||||
if (type == WpaNone) {
|
||||
security_sett->setInitialized(false);
|
||||
return;
|
||||
} else {
|
||||
security_sett->setInitialized(true);
|
||||
}
|
||||
security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)type);
|
||||
if (bPwdChange) {
|
||||
qDebug() << "get psk " << security_sett->psk();
|
||||
security_sett->setPsk(connSettingInfo.m_psk);
|
||||
}
|
||||
|
@ -817,6 +797,7 @@ void KyWirelessConnectOperation::setWirelessSecuWpaXEap(NetworkManager::Connecti
|
|||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= connSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
|
||||
security_sett->setInitialized(true);
|
||||
security_sett->setKeyMgmt(NetworkManager::WirelessSecuritySetting::KeyMgmt::WpaEap);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ KyWirelessNetItem::KyWirelessNetItem(NetworkManager::WirelessNetwork::Ptr net)
|
|||
m_connName = "";
|
||||
m_connDbusPath = "";
|
||||
m_secuType = "";
|
||||
m_device = "";
|
||||
|
||||
init(net);
|
||||
}
|
||||
|
@ -57,6 +58,7 @@ void KyWirelessNetItem::init(NetworkManager::WirelessNetwork::Ptr net)
|
|||
NetworkManager::AccessPoint::WpaFlags rsnFlag = net->referenceAccessPoint()->rsnFlags();
|
||||
m_secuType = enumToQstring(cap, wpaFlag, rsnFlag);
|
||||
m_bssid = net->referenceAccessPoint()->hardwareAddress();
|
||||
m_device = net->device();
|
||||
initInfoBySsid();
|
||||
}
|
||||
|
||||
|
@ -71,19 +73,13 @@ void KyWirelessNetItem::initInfoBySsid()
|
|||
}
|
||||
NetworkManager::WirelessSetting::Ptr wifi_sett
|
||||
= settings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
if (wifi_sett->ssid() == m_NetSsid)
|
||||
QString devName = m_networkResourceInstance->findDeviceUni(m_device)->interfaceName();
|
||||
if (wifi_sett->ssid() == m_NetSsid && (settings->interfaceName().compare(devName) == 0 || settings->interfaceName().isEmpty()))
|
||||
{
|
||||
m_connectUuid = settings->uuid();
|
||||
m_connName = conn->name();
|
||||
m_connDbusPath = conn->path();
|
||||
m_isConfigured = true;
|
||||
|
||||
if(wifi_sett->ssid() == "NewWifi")
|
||||
{
|
||||
NetworkManager::WirelessSecuritySetting::Ptr security_sett
|
||||
= settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
|
||||
qDebug() << security_sett->keyMgmt();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public:
|
|||
|
||||
private:
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
QString m_device;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ KyWirelessNetResource::KyWirelessNetResource(QObject *parent)
|
|||
{
|
||||
qDebug()<<"KyWirelessNetResource";
|
||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
m_connectResource = new KyConnectResourse(this);
|
||||
|
||||
kyWirelessNetItemListInit();
|
||||
|
||||
|
@ -14,8 +15,9 @@ KyWirelessNetResource::KyWirelessNetResource(QObject *parent)
|
|||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkPropertyChange, this, &KyWirelessNetResource::onWifiNetworkPropertyChange);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkDeviceDisappear, this, &KyWirelessNetResource::onWifiNetworkDeviceDisappear);
|
||||
|
||||
//connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionAdd, this, &KyWirelessNetResource::onConnectionAdd);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionRemove, this, &KyWirelessNetResource::onConnectionRemove);
|
||||
connect(m_connectResource, &KyConnectResourse::connectionAdd, this, &KyWirelessNetResource::onConnectionAdd);
|
||||
connect(m_connectResource, &KyConnectResourse::connectionRemove, this, &KyWirelessNetResource::onConnectionRemove);
|
||||
connect(m_connectResource, &KyConnectResourse::connectionUpdate, this, &KyWirelessNetResource::onConnectionUpdate);
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,7 +28,7 @@ KyWirelessNetResource::~KyWirelessNetResource()
|
|||
|
||||
bool KyWirelessNetResource::getAllDeviceWifiNetwork(QMap<QString,QList<KyWirelessNetItem> > &map)
|
||||
{
|
||||
onWifiNetworkDeviceDisappear();
|
||||
// onWifiNetworkDeviceDisappear();
|
||||
if (m_WifiNetworkList.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -38,7 +40,7 @@ bool KyWirelessNetResource::getAllDeviceWifiNetwork(QMap<QString,QList<KyWireles
|
|||
|
||||
bool KyWirelessNetResource::getDeviceWifiNetwork(QString devIfaceName, QList<KyWirelessNetItem> &wirelessNetResource)
|
||||
{
|
||||
onWifiNetworkDeviceDisappear();
|
||||
// onWifiNetworkDeviceDisappear();
|
||||
|
||||
if (!m_WifiNetworkList.contains(devIfaceName)) {
|
||||
return false;
|
||||
|
@ -50,7 +52,7 @@ bool KyWirelessNetResource::getDeviceWifiNetwork(QString devIfaceName, QList<KyW
|
|||
|
||||
bool KyWirelessNetResource::getWifiNetwork(QString &devIfaceName, QString &ssid, KyWirelessNetItem &wirelessNetResource)
|
||||
{
|
||||
onWifiNetworkDeviceDisappear();
|
||||
// onWifiNetworkDeviceDisappear();
|
||||
|
||||
if (!m_WifiNetworkList.contains(devIfaceName)) {
|
||||
return false;
|
||||
|
@ -66,9 +68,10 @@ bool KyWirelessNetResource::getWifiNetwork(QString &devIfaceName, QString &ssid,
|
|||
return false;
|
||||
}
|
||||
|
||||
bool KyWirelessNetResource::getWirelessActiveConnection(QMap<QString,QStringList> &map)
|
||||
void KyWirelessNetResource::getWirelessActiveConnection(NetworkManager::ActiveConnection::State state, QMap<QString,QStringList> &map)
|
||||
{
|
||||
int index = 0;
|
||||
map.clear();
|
||||
NetworkManager::ActiveConnection::List activeConnectionList;
|
||||
|
||||
map.clear();
|
||||
|
@ -76,8 +79,7 @@ bool KyWirelessNetResource::getWirelessActiveConnection(QMap<QString,QStringList
|
|||
activeConnectionList = m_networkResourceInstance->m_activeConns;
|
||||
if (activeConnectionList.isEmpty())
|
||||
{
|
||||
map.clear();
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectionPtr = nullptr;
|
||||
|
@ -88,7 +90,7 @@ bool KyWirelessNetResource::getWirelessActiveConnection(QMap<QString,QStringList
|
|||
{
|
||||
continue;
|
||||
}
|
||||
if (NetworkManager::ActiveConnection::Activated != activeConnectionPtr->state())
|
||||
if (state != activeConnectionPtr->state())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -102,7 +104,7 @@ bool KyWirelessNetResource::getWirelessActiveConnection(QMap<QString,QStringList
|
|||
map.insert(ifaceName,list);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection::Ptr actConn,
|
||||
|
@ -114,7 +116,8 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection::
|
|||
|
||||
NetworkManager::Connection::Ptr conn = actConn->connection();
|
||||
NetworkManager::ConnectionSettings::Ptr sett = conn->settings();
|
||||
wirelessNetResourcessid = sett->id();
|
||||
NetworkManager::WirelessSetting::Ptr wireless_sett = sett->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
wirelessNetResourcessid = wireless_sett->ssid();
|
||||
|
||||
return sett->interfaceName();
|
||||
}
|
||||
|
@ -410,13 +413,13 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls
|
|||
}
|
||||
|
||||
|
||||
void KyWirelessNetResource::onConnectionAdd(NetworkManager::Connection::Ptr conn)
|
||||
void KyWirelessNetResource::onConnectionAdd(QString uuid)
|
||||
{
|
||||
qDebug() << "onConnectionAdd add " << conn->name();
|
||||
QString devIfaceName;
|
||||
QString ssid;
|
||||
qDebug() << "onConnectionAdd " << uuid;
|
||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
||||
if (conn.isNull())
|
||||
{
|
||||
qDebug() << "onConnectionAdd can not find connection" << uuid;
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr sett= conn->settings();
|
||||
|
@ -425,15 +428,14 @@ void KyWirelessNetResource::onConnectionAdd(NetworkManager::Connection::Ptr conn
|
|||
return;
|
||||
}
|
||||
NetworkManager::WirelessSetting::Ptr wireless_sett = sett->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
|
||||
bool isFind = false;
|
||||
QMap<QString, QString> map;
|
||||
map.clear();
|
||||
QMap<QString, QList<KyWirelessNetItem> >::iterator iter = m_WifiNetworkList.begin();
|
||||
while (iter != m_WifiNetworkList.end())
|
||||
{
|
||||
for(int i = 0; i < iter.value().size(); i++)
|
||||
{
|
||||
if (iter.value().at(i).m_NetSsid == wireless_sett->ssid())
|
||||
{
|
||||
isFind = true;
|
||||
while (iter != m_WifiNetworkList.end()) {
|
||||
for(int i = 0; i < iter.value().size(); i++) {
|
||||
if (iter.value().at(i).m_NetSsid == wireless_sett->ssid() && (sett->interfaceName() == iter.key() || sett->interfaceName().isEmpty())) {
|
||||
QString devIfaceName;
|
||||
QString ssid;
|
||||
m_WifiNetworkList[iter.key()][i].m_isConfigured = true;
|
||||
m_WifiNetworkList[iter.key()][i].m_connName = conn->name();
|
||||
m_WifiNetworkList[iter.key()][i].m_connectUuid = conn->uuid();
|
||||
|
@ -441,22 +443,27 @@ void KyWirelessNetResource::onConnectionAdd(NetworkManager::Connection::Ptr conn
|
|||
|
||||
devIfaceName = sett->interfaceName();
|
||||
ssid = iter.value().at(i).m_NetSsid;
|
||||
map.insert(devIfaceName, ssid);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
if (isFind)
|
||||
{
|
||||
emit connectionAdd(devIfaceName, ssid);
|
||||
if (!map.isEmpty()) {
|
||||
for(auto var = map.cbegin(); var != map.cend(); var++) {
|
||||
QString devIfaceName = var.key();
|
||||
QString ssid = var.value();
|
||||
emit connectionAdd(devIfaceName, ssid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KyWirelessNetResource::onConnectionRemove(QString path)
|
||||
{
|
||||
qDebug() << "onConnectionRemove remove " << path;
|
||||
bool isFind = false;
|
||||
QString devIfaceName;
|
||||
QString ssid;
|
||||
QMap<QString, QString> map;
|
||||
map.clear();
|
||||
|
||||
QMap<QString, QList<KyWirelessNetItem> >::iterator iter = m_WifiNetworkList.begin();
|
||||
while (iter != m_WifiNetworkList.end())
|
||||
|
@ -467,7 +474,8 @@ void KyWirelessNetResource::onConnectionRemove(QString path)
|
|||
qDebug() << iter.value().at(i).m_connDbusPath;
|
||||
if (iter.value().at(i).m_connDbusPath == path)
|
||||
{
|
||||
isFind = true;
|
||||
QString devIfaceName;
|
||||
QString ssid;
|
||||
m_WifiNetworkList[iter.key()][i].m_isConfigured = false;
|
||||
m_WifiNetworkList[iter.key()][i].m_connName = "";
|
||||
m_WifiNetworkList[iter.key()][i].m_connectUuid = "";
|
||||
|
@ -475,14 +483,38 @@ void KyWirelessNetResource::onConnectionRemove(QString path)
|
|||
|
||||
devIfaceName = iter.key();
|
||||
ssid = iter.value().at(i).m_NetSsid;
|
||||
map.insert(devIfaceName, ssid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
|
||||
if (isFind)
|
||||
{
|
||||
emit connectionRemove(devIfaceName, ssid);
|
||||
if (!map.isEmpty()) {
|
||||
for(auto var = map.cbegin(); var != map.cend(); var++) {
|
||||
QString devIfaceName = var.key();
|
||||
QString ssid = var.value();
|
||||
emit connectionRemove(devIfaceName, ssid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void KyWirelessNetResource::onConnectionUpdate(QString uuid)
|
||||
{
|
||||
qDebug() << "onConnectionUpdate " << uuid;
|
||||
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
|
||||
if (conn.isNull())
|
||||
{
|
||||
qDebug() << "onConnectionAdd can not find connection" << uuid;
|
||||
return;
|
||||
}
|
||||
NetworkManager::ConnectionSettings::Ptr sett= conn->settings();
|
||||
if (sett->connectionType() != NetworkManager::ConnectionSettings::ConnectionType::Wireless)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_WifiNetworkList.clear();
|
||||
kyWirelessNetItemListInit();
|
||||
emit wifiNetworkUpadte();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "kywirelessnetitem.h"
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include "kyenterpricesettinginfo.h"
|
||||
#include "kylinconnectresource.h"
|
||||
|
||||
|
||||
//class KyWirelessNetItem;
|
||||
|
@ -25,7 +26,7 @@ public:
|
|||
bool getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info);
|
||||
bool getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtlsInfo &info);
|
||||
|
||||
bool getWirelessActiveConnection(QMap<QString, QStringList> &map);
|
||||
void getWirelessActiveConnection(NetworkManager::ActiveConnection::State state, QMap<QString, QStringList> &map);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -39,7 +40,8 @@ public slots:
|
|||
void onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net);
|
||||
void onWifiNetworkDeviceDisappear();
|
||||
|
||||
void onConnectionAdd(NetworkManager::Connection::Ptr conn);
|
||||
void onConnectionAdd(QString uuid);
|
||||
void onConnectionUpdate(QString uuid);
|
||||
void onConnectionRemove(QString);
|
||||
|
||||
signals:
|
||||
|
@ -48,11 +50,13 @@ signals:
|
|||
void secuTypeChange(QString, QString, QString);
|
||||
void connectionRemove(QString, QString);
|
||||
void connectionAdd(QString, QString);
|
||||
void wifiNetworkUpadte();
|
||||
void wifiNetworkAdd(QString, KyWirelessNetItem&);
|
||||
void wifiNetworkRemove(QString, QString);
|
||||
|
||||
private:
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
KyConnectResourse *m_connectResource = nullptr;
|
||||
QMap<QString, QList<KyWirelessNetItem> > m_WifiNetworkList;
|
||||
|
||||
};
|
||||
|
|
|
@ -127,8 +127,9 @@ void NmDemo::initConnect()
|
|||
|
||||
//ui button
|
||||
connect(refreshButton, &QPushButton::clicked, [=](){
|
||||
appendDebugLog("init refreshButton clicked...");
|
||||
m_wco->requestWirelessScan();
|
||||
// appendDebugLog("init refreshButton clicked...");
|
||||
// m_wco->requestWirelessScan();
|
||||
getWifiList();
|
||||
});
|
||||
|
||||
connect(connectButton, &QPushButton::clicked, this, &NmDemo::onConnectClicked);
|
||||
|
@ -153,8 +154,11 @@ void NmDemo::initConnect()
|
|||
connect(m_wnr, &KyWirelessNetResource::secuTypeChange, this ,&NmDemo::onSecuTypeChange);
|
||||
connect(m_wnr, &KyWirelessNetResource::signalStrengthChange, this ,&NmDemo::onSignalStrengthChange);
|
||||
|
||||
|
||||
|
||||
connect(m_wnr, &KyWirelessNetResource::connectionRemove, this ,&NmDemo::onConnectionRemove);
|
||||
connect(m_wnr, &KyWirelessNetResource::connectionAdd, this ,&NmDemo::onConnectionAdd);
|
||||
connect(m_wnr, &KyWirelessNetResource::wifiNetworkUpadte, this ,&NmDemo::onWifiNetworkUpdate);
|
||||
connect(m_wnr, &KyWirelessNetResource::wifiNetworkAdd, this ,&NmDemo::onWifiNetworkAdd);
|
||||
connect(m_wnr, &KyWirelessNetResource::wifiNetworkRemove, this ,&NmDemo::onWifiNetworkRemove);
|
||||
|
||||
|
@ -221,6 +225,12 @@ void NmDemo::onWifiNetworkRemove(QString devIface, QString ssid)
|
|||
getWifiList();
|
||||
}
|
||||
|
||||
void NmDemo::onWifiNetworkUpdate()
|
||||
{
|
||||
appendDebugLog("onWifiNetworkUpdate...");
|
||||
getWifiList();
|
||||
}
|
||||
|
||||
void NmDemo::onConnectClicked()
|
||||
{
|
||||
appendDebugLog("onConnectClicked...");
|
||||
|
@ -259,8 +269,6 @@ void NmDemo::onConnectClicked()
|
|||
}
|
||||
if (isEnterPirse)
|
||||
{
|
||||
qDebug() <<"EnterPrice";
|
||||
return;
|
||||
if(!isNew)
|
||||
{
|
||||
KyEapMethodPeapInfo a;
|
||||
|
@ -273,14 +281,22 @@ void NmDemo::onConnectClicked()
|
|||
m_wco->activeWirelessConnect(devIface,uuid);
|
||||
return;
|
||||
} else {
|
||||
KyEapMethodTtlsInfo c;
|
||||
c.authType = AUTH_NO_EAP;
|
||||
c.authNoEapMethod = KyAuthMethodMschapv2;
|
||||
KyEapMethodPeapInfo c;
|
||||
c.m_passwdFlag = NetworkManager::Setting::SecretFlagType::None;
|
||||
c.phase2AuthMethod = KyAuthMethodMschapv2;
|
||||
c.userName = "steve";
|
||||
c.userPWD = "testing";
|
||||
|
||||
KyWirelessConnectSetting a;
|
||||
a.m_connectName = ssid;
|
||||
a.m_ssid = ssid;
|
||||
a.isAutoConnect = true;
|
||||
a.m_type = WpaEap;
|
||||
|
||||
appendDebugLog("addAndActiveWirelessEnterPriseTtlsConnect...");
|
||||
qDebug() << "addAndActiveWirelessEnterPriseTtlsConnect";
|
||||
// m_wco->addAndActiveWirelessEnterPriseTtlsConnect(c, devIface, isHidden, true, 0);
|
||||
m_wco->addAndActiveWirelessEnterPrisePeapConnect(c, a, devIface, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +308,7 @@ void NmDemo::onConnectClicked()
|
|||
a.m_ssid = ssid;
|
||||
a.isAutoConnect = true;
|
||||
a.m_psk = pwd;
|
||||
a.m_type = WpaPsk;
|
||||
a.m_type = WpaNone;
|
||||
|
||||
|
||||
m_wco->addAndActiveWirelessConnect(devIface,a, isHidden);
|
||||
|
@ -363,14 +379,19 @@ void NmDemo::onModifyClicked()
|
|||
{
|
||||
return;
|
||||
}
|
||||
QString psk = m_wco->getPsk(uuid);
|
||||
appendDebugLog(ssid +" getPsk is " + psk);
|
||||
return;
|
||||
|
||||
// KyEapMethodTtlsInfo info;
|
||||
// m_wco->updateWirelessEnterPriseTtlsConnect(uuid, info);
|
||||
|
||||
// QString psk = m_wco->getPsk(uuid);
|
||||
// appendDebugLog(ssid +" getPsk is " + psk);
|
||||
// return;
|
||||
|
||||
appendDebugLog("getConnectKeyMgmt" + QString::number(m_wco->getConnectKeyMgmt(uuid)));
|
||||
|
||||
KyWirelessConnectSetting wcs;
|
||||
wcs.m_type = SAE;
|
||||
wcs.m_type = WpaPsk;
|
||||
wcs.m_psk = "123456zsx";
|
||||
m_wco->updateWirelessPersonalConnect(uuid, wcs ,true);
|
||||
appendDebugLog("getConnectKeyMgmt" + QString::number(m_wco->getConnectKeyMgmt(uuid)));
|
||||
return;
|
||||
|
@ -462,17 +483,17 @@ void NmDemo::onAddClick()
|
|||
{
|
||||
appendDebugLog("onAddClick...");
|
||||
KyWirelessConnectSetting sett;
|
||||
sett.m_connectName = "zsx";
|
||||
sett.m_ssid = "zsxsz";
|
||||
sett.m_connectName = "test";
|
||||
sett.m_ssid = "test";
|
||||
sett.isAutoConnect = false;
|
||||
sett.m_psk = "123456zsx";
|
||||
sett.m_type = Wep;
|
||||
//ipv4
|
||||
sett.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL);
|
||||
QString ipv4Address("192.168.1.17"), ipv4NetMask("255.255.255.0"), ipv4GateWay("192.168.1.0");
|
||||
QStringList list;
|
||||
list << "127.17.50.100";
|
||||
sett.ipv4AddressConstruct(ipv4Address, ipv4NetMask, ipv4GateWay, list);
|
||||
sett.m_psk = "";
|
||||
sett.m_type = WpaEap;
|
||||
// //ipv4
|
||||
sett.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP);
|
||||
// QString ipv4Address("192.168.1.17"), ipv4NetMask("255.255.255.0"), ipv4GateWay("192.168.1.0");
|
||||
// QStringList list;
|
||||
// list << "127.17.50.100";
|
||||
// sett.ipv4AddressConstruct(ipv4Address, ipv4NetMask, ipv4GateWay, list);
|
||||
// m_wco->addConnect(sett);
|
||||
KyEapMethodPeapInfo peap;
|
||||
peap.phase2AuthMethod = KyAuthMethodMschapv2;
|
||||
|
@ -530,21 +551,44 @@ void NmDemo::getWifiList()
|
|||
qDebug() << "getWifiList";
|
||||
wifiList->clear();
|
||||
QMap<QString,QStringList> actMap;
|
||||
if (!m_wnr->getWirelessActiveConnection(actMap))
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_wnr->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap);
|
||||
appendDebugLog("getWirelessActiveConnection Activated " +QString::number(actMap.size()));
|
||||
|
||||
QMap<QString,QStringList>::iterator iter1 = actMap.begin();
|
||||
while (iter1 != actMap.end())
|
||||
{
|
||||
wifiList->append(iter1.key());
|
||||
for (int i = 0; i < iter1->size(); i++)
|
||||
{
|
||||
wifiList->append(iter1->at(i));
|
||||
wifiList->append("Activated" + iter1->at(i));
|
||||
}
|
||||
wifiList->append("====================================");
|
||||
iter1++;
|
||||
}
|
||||
|
||||
m_wnr->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activating, actMap);
|
||||
appendDebugLog("getWirelessActiveConnection Activating " +QString::number(actMap.size()));
|
||||
|
||||
QMap<QString,QStringList>::iterator iter2 = actMap.begin();
|
||||
while (iter2 != actMap.end())
|
||||
{
|
||||
wifiList->append(iter2.key());
|
||||
for (int i = 0; i < iter2->size(); i++)
|
||||
{
|
||||
wifiList->append("Activating" + iter2->at(i));
|
||||
}
|
||||
wifiList->append("====================================");
|
||||
iter2++;
|
||||
}
|
||||
|
||||
m_wnr->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Deactivating, actMap);
|
||||
appendDebugLog("getWirelessActiveConnection Deactivating " +QString::number(actMap.size()));
|
||||
|
||||
m_wnr->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Deactivated, actMap);
|
||||
appendDebugLog("getWirelessActiveConnection Deactivated " +QString::number(actMap.size()));
|
||||
|
||||
return;
|
||||
|
||||
QMap<QString, QList<KyWirelessNetItem> > map;
|
||||
if (!m_wnr->getAllDeviceWifiNetwork(map))
|
||||
{
|
||||
|
@ -553,6 +597,7 @@ void NmDemo::getWifiList()
|
|||
QMap<QString, QList<KyWirelessNetItem> >::iterator iter = map.begin();
|
||||
while (iter != map.end())
|
||||
{
|
||||
qDebug() << iter.key() << iter.value().size();
|
||||
for (int i = 0; i < iter.value().size(); i++)
|
||||
{
|
||||
qDebug() << iter.value().at(i).m_NetSsid;
|
||||
|
|
|
@ -70,6 +70,7 @@ public slots:
|
|||
void onConnectionAdd(QString, QString);
|
||||
void onWifiNetworkAdd(QString, KyWirelessNetItem&);
|
||||
void onWifiNetworkRemove(QString, QString);
|
||||
void onWifiNetworkUpdate();
|
||||
|
||||
void onConnectClicked();
|
||||
void onDisConnectClicked();
|
||||
|
|
Loading…
Reference in New Issue