delay connect hotspot

This commit is contained in:
jzxc95 2021-09-03 15:48:19 +08:00
parent 52576c13dd
commit d1d8c7781e
3 changed files with 19 additions and 13 deletions

View File

@ -741,7 +741,9 @@ void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QS
}); });
} else { } else {
updateWirelessApSetting(connectPtr, apName, apPassword, apDevice); updateWirelessApSetting(connectPtr, apName, apPassword, apDevice);
activateApConnectionByUuid(apUuid, apDevice, connectPtr); QTimer::singleShot(500, this, [=](){
activateApConnectionByUuid(apUuid, apDevice);
});
} }
return; return;
@ -827,7 +829,7 @@ void KyWirelessConnectOperation::setIpv4AndIpv6Setting(NetworkManager::Connectio
ipv6SettingSet(ipv6Setting, connSettingInfo); ipv6SettingSet(ipv6Setting, connSettingInfo);
} }
void KyWirelessConnectOperation::activateApConnectionByUuid(const QString apUuid, const QString apDevice, NetworkManager::Connection::Ptr connectPtr) void KyWirelessConnectOperation::activateApConnectionByUuid(const QString apUuid, const QString apDevice)
{ {
QString connectPath = ""; QString connectPath = "";
QString deviceIdentifier = ""; QString deviceIdentifier = "";
@ -836,6 +838,14 @@ void KyWirelessConnectOperation::activateApConnectionByUuid(const QString apUuid
qDebug()<<"it will activate hotspot connect"<<apUuid; qDebug()<<"it will activate hotspot connect"<<apUuid;
NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(apUuid);
if (connectPtr.isNull())
{
QString errorMessage = tr("Create hotspot faild.UUID is empty, its name") + apUuid;
qWarning() << errorMessage;
Q_EMIT activateConnectionError(errorMessage);
return;
}
connectPath = connectPtr->path(); connectPath = connectPtr->path();
connectName = connectPtr->name(); connectName = connectPtr->name();

View File

@ -3,6 +3,7 @@
#include <QObject> #include <QObject>
#include <QGSettings> #include <QGSettings>
#include <QTimer>
#include "kyenterpricesettinginfo.h" #include "kyenterpricesettinginfo.h"
#include "kylinconnectoperation.h" #include "kylinconnectoperation.h"
#include "kyenterpricesettinginfo.h" #include "kyenterpricesettinginfo.h"
@ -124,7 +125,7 @@ private:
void updateWirelessSecu(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange = false); void updateWirelessSecu(NetworkManager::ConnectionSettings::Ptr connSettingPtr, const KyWirelessConnectSetting &connSettingInfo, bool bPwdChange = false);
void setIpv4AndIpv6Setting(NetworkManager::ConnectionSettings::Ptr connSetting, const KyConnectSetting &connSettingInfo); void setIpv4AndIpv6Setting(NetworkManager::ConnectionSettings::Ptr connSetting, const KyConnectSetting &connSettingInfo);
void setWirelessSecuWpaXEap(NetworkManager::ConnectionSettings::Ptr connSettingPtr); void setWirelessSecuWpaXEap(NetworkManager::ConnectionSettings::Ptr connSettingPtr);
void activateApConnectionByUuid(const QString apUuid, const QString apDevice, NetworkManager::Connection::Ptr connectPtr); void activateApConnectionByUuid(const QString apUuid, const QString apDevice);
KyNetworkResourceManager *m_networkResourceInstance = nullptr; KyNetworkResourceManager *m_networkResourceInstance = nullptr;

View File

@ -21,11 +21,6 @@ const QByteArray GSETTINGS_SCHEMA_KYLIN_NM = "org.ukui.kylin-nm.switch";
const QString KEY_WIRELESS_SWITCH = "wirelessswitch"; const QString KEY_WIRELESS_SWITCH = "wirelessswitch";
const QString KEY_WIRED_SWITCH = "wiredswitch"; const QString KEY_WIRED_SWITCH = "wiredswitch";
enum KyDeviceType{
WIRED = 0,
WIRELESS,
};
void saveDeviceEnableState(QString deviceName, bool enable) void saveDeviceEnableState(QString deviceName, bool enable)
{ {
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat); QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
@ -44,7 +39,7 @@ void getDeviceEnableState(int type, QMap<QString, bool> &map)
if (!QFile::exists(CONFIG_FILE_PATH)) { if (!QFile::exists(CONFIG_FILE_PATH)) {
return; return;
} }
if (type != 0 && type != 1) { if (type != WIRED && type != WIRELESS) {
qDebug() << "getDeviceEnableState but wrong type"; qDebug() << "getDeviceEnableState but wrong type";
return; return;
} }
@ -57,7 +52,7 @@ void getDeviceEnableState(int type, QMap<QString, bool> &map)
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat); QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
m_settings->beginGroup("CARDEABLE"); m_settings->beginGroup("CARDEABLE");
if (type == 0) { if (type == WIRED) {
kdr->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDevList); kdr->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDevList);
if (!wiredDevList.isEmpty()) { if (!wiredDevList.isEmpty()) {
for (int i = 0; i < wiredDevList.size(); ++i) { for (int i = 0; i < wiredDevList.size(); ++i) {
@ -65,7 +60,7 @@ void getDeviceEnableState(int type, QMap<QString, bool> &map)
map.insert(wiredDevList.at(i), enable); map.insert(wiredDevList.at(i), enable);
} }
} }
} else if (type == 1) { } else if (type == WIRELESS) {
kdr->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDevList); kdr->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDevList);
if (!wirelessDevList.isEmpty()) { if (!wirelessDevList.isEmpty()) {
for (int i = 0; i < wirelessDevList.size(); ++i) { for (int i = 0; i < wirelessDevList.size(); ++i) {
@ -247,9 +242,9 @@ QString DbusAdaptor::getDefaultWirelessDevice()
//连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid //连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
void DbusAdaptor::activateConnect(int type, QString devName, QString ssid) void DbusAdaptor::activateConnect(int type, QString devName, QString ssid)
{ {
if (type == 0) { if (type == WIRED) {
parent()->activateWired(devName,ssid); parent()->activateWired(devName,ssid);
} else if (type == 1) { } else if (type == WIRELESS) {
parent()->activateWireless(devName,ssid); parent()->activateWireless(devName,ssid);
} else { } else {
qDebug() << "[DbusAdaptor] activateConnect type is invalid"; qDebug() << "[DbusAdaptor] activateConnect type is invalid";