Merge branch 'ukui-dbus-interface' into kylin-nm-wlan

This commit is contained in:
renpeijia 2021-10-18 16:21:16 +08:00
commit ef51c826f5
42 changed files with 1449 additions and 4758 deletions

2
debian/control vendored
View File

@ -16,7 +16,7 @@ Build-Depends: debhelper (>=9),
libx11-dev, libx11-dev,
libqt5svg5-dev, libqt5svg5-dev,
libkf5networkmanagerqt-dev (>= 5.36.0), libkf5networkmanagerqt-dev (>= 5.36.0),
libnm-dev, libnm-dev,
libcap-dev, libcap-dev,
Standards-Version: 4.5.0 Standards-Version: 4.5.0
Rules-Requires-Root: no Rules-Requires-Root: no

4
debian/rules vendored
View File

@ -28,3 +28,7 @@ override_dh_auto_clean:
override_dh_auto_build: override_dh_auto_build:
dh_auto_build -- $(MAKE_OPTS) dh_auto_build -- $(MAKE_OPTS)
override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

View File

@ -560,3 +560,23 @@ bool KyActiveConnectResourse::isActiveConnection(QString uuid, QStringList &devN
} }
} }
} }
QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid)
{
QString deviceName = "";
NetworkManager::ActiveConnection::Ptr activeConnectPtr =
m_networkResourceInstance->getActiveConnect(conUuid);
if (nullptr == activeConnectPtr) {
qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< conUuid;
return deviceName;
}
QStringList interfaces = activeConnectPtr->devices();
QString ifaceUni = interfaces.at(0);
NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni);
deviceName = devicePtr->interfaceName();
return deviceName;
}

View File

@ -37,6 +37,8 @@ public:
bool isActiveConnection(QString uuid, QStringList &devName); bool isActiveConnection(QString uuid, QStringList &devName);
QString getDeviceOfActivateConnect(QString conUuid);
private: private:
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr, void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
QString &ipv4Address, QString &ipv4Address,

View File

@ -81,6 +81,32 @@ free_wifi_info (SecretsRequest *req)
} }
} }
void
applet_secrets_request_free (SecretsRequest *req)
{
g_return_if_fail (req != NULL);
if (req->free_func)
req->free_func (req);
secrets_reqs = g_slist_remove (secrets_reqs, req);
g_object_unref (req->connection);
g_free (req->setting_name);
g_strfreev (req->hints);
memset (req, 0, req->totsize);
g_free (req);
}
void
applet_secrets_request_complete (SecretsRequest *req,
GVariant *settings,
GError *error)
{
req->callback (req->agent, error ? NULL : settings, error, req->callback_data);
}
static void static void
get_secrets_dialog_response_cb (GtkDialog *foo, get_secrets_dialog_response_cb (GtkDialog *foo,
gint response, gint response,
@ -230,24 +256,6 @@ l_out:
//return 0; //return 0;
} }
void
applet_secrets_request_free (SecretsRequest *req)
{
g_return_if_fail (req != NULL);
if (req->free_func)
req->free_func (req);
secrets_reqs = g_slist_remove (secrets_reqs, req);
g_object_unref (req->connection);
g_free (req->setting_name);
g_strfreev (req->hints);
memset (req, 0, req->totsize);
g_free (req);
}
static SecretsRequest * static SecretsRequest *
applet_secrets_request_new (size_t totsize, applet_secrets_request_new (size_t totsize,
NMConnection *connection, NMConnection *connection,
@ -277,15 +285,6 @@ applet_secrets_request_new (size_t totsize,
return req; return req;
} }
void
applet_secrets_request_complete (SecretsRequest *req,
GVariant *settings,
GError *error)
{
req->callback (req->agent, error ? NULL : settings, error, req->callback_data);
}
static void static void
get_existing_secrets_cb (NMSecretAgentOld *agent, get_existing_secrets_cb (NMSecretAgentOld *agent,
NMConnection *connection, NMConnection *connection,

View File

@ -7,6 +7,7 @@ KyApConnectItem::KyApConnectItem(QObject *parent) : QObject(parent)
m_connectUuid = ""; m_connectUuid = "";
m_ifaceName = ""; m_ifaceName = "";
m_password = ""; m_password = "";
m_band = "";
m_isActivated = false; m_isActivated = false;
} }

View File

@ -16,7 +16,9 @@ public:
QString m_connectUuid; QString m_connectUuid;
QString m_ifaceName; QString m_ifaceName;
QString m_password; QString m_password;
QString m_band;
bool m_isActivated; bool m_isActivated;
}; };
#endif // KYLINAPCONNECTITEM_H #endif // KYLINAPCONNECTITEM_H

View File

@ -211,6 +211,7 @@ void KyConnectOperation::deactivateConnection(const QString activeConnectName, c
NetworkManager::ActiveConnection::Ptr activateConnectPtr = nullptr; NetworkManager::ActiveConnection::Ptr activateConnectPtr = nullptr;
qDebug()<<"deactivetate connect name"<<activeConnectName<<"uuid"<<activeConnectUuid; qDebug()<<"deactivetate connect name"<<activeConnectName<<"uuid"<<activeConnectUuid;
activateConnectPtr = m_networkResourceInstance->getActiveConnect(activeConnectUuid); activateConnectPtr = m_networkResourceInstance->getActiveConnect(activeConnectUuid);
if (nullptr == activateConnectPtr) { if (nullptr == activateConnectPtr) {
QString errorMessage = tr("it can not find the activate connect") QString errorMessage = tr("it can not find the activate connect")

View File

@ -8,6 +8,25 @@
#include <NetworkManagerQt/VpnPlugin> #include <NetworkManagerQt/VpnPlugin>
#include <NetworkManagerQt/VpnSetting> #include <NetworkManagerQt/VpnSetting>
const QString str2GBand = "2.4Ghz";
const QString str5GBand = "5Ghz";
static bool subLanListSort(const KyConnectItem* info1, const KyConnectItem* info2)
{
QString name1 = info1->m_connectName;
QString name2 = info2->m_connectName;
bool result = true;
if (QString::compare(name1, name2, Qt::CaseInsensitive) > 0) {
result = false;
}
return result;
}
static void lanListSort(QList<KyConnectItem *> &list)
{
qSort(list.begin(), list.end(), subLanListSort);
}
KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent) KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent)
{ {
m_networkResourceInstance = KyNetworkResourceManager::getInstance(); m_networkResourceInstance = KyNetworkResourceManager::getInstance();
@ -152,6 +171,9 @@ void KyConnectResourse::getConnectionList(QString deviceName,
connectPtr = nullptr; connectPtr = nullptr;
} }
if (connectItemList.size() > 1) {
lanListSort(connectItemList);
}
return; return;
} }
@ -331,7 +353,7 @@ void KyConnectResourse::getConnectionSetting(QString connectUuid, KyConnectSetti
return; return;
} }
bool KyConnectResourse::getInterfaceByUuid(QString &deviceName, NetworkManager::ConnectionSettings::ConnectionType &type, const QString connUuid) bool KyConnectResourse::getInterfaceByUuid(QString &deviceName, const QString connUuid)
{ {
deviceName.clear(); deviceName.clear();
NetworkManager::Connection::Ptr connectPtr = NetworkManager::Connection::Ptr connectPtr =
@ -347,7 +369,7 @@ bool KyConnectResourse::getInterfaceByUuid(QString &deviceName, NetworkManager::
qWarning()<<"getInterfaceByUuid failed, connect uuid"<<connUuid; qWarning()<<"getInterfaceByUuid failed, connect uuid"<<connUuid;
return false; return false;
} }
type = connectPtr->settings()->connectionType();
deviceName = connectPtr->settings()->interfaceName(); deviceName = connectPtr->settings()->interfaceName();
qDebug() << "getInterfaceByUuid success " << deviceName; qDebug() << "getInterfaceByUuid success " << deviceName;
return true; return true;
@ -530,6 +552,11 @@ KyApConnectItem *KyConnectResourse::getApConnectItem(NetworkManager::Connection:
KyApConnectItem *apConnectItem = new KyApConnectItem(); KyApConnectItem *apConnectItem = new KyApConnectItem();
apConnectItem->m_connectName = connectPtr->name(); apConnectItem->m_connectName = connectPtr->name();
apConnectItem->m_connectUuid = connectPtr->uuid(); apConnectItem->m_connectUuid = connectPtr->uuid();
if (wirelessSetting->band() == NetworkManager::WirelessSetting::FrequencyBand::A) {
apConnectItem->m_band = str2GBand;
} else if (wirelessSetting->band() == NetworkManager::WirelessSetting::FrequencyBand::Bg) {
apConnectItem->m_band = str5GBand;
}
apConnectItem->m_ifaceName = settingPtr->interfaceName(); apConnectItem->m_ifaceName = settingPtr->interfaceName();
apConnectItem->m_isActivated = m_networkResourceInstance->isActiveConnection(connectPtr->uuid()); apConnectItem->m_isActivated = m_networkResourceInstance->isActiveConnection(connectPtr->uuid());
@ -606,7 +633,7 @@ bool KyConnectResourse::isWiredConnection(QString uuid)
return false; return false;
} }
if (connectPtr->isValid()) { if (!connectPtr.isNull()) {
NetworkManager::ConnectionSettings::Ptr connectSettingPtr = connectPtr->settings(); NetworkManager::ConnectionSettings::Ptr connectSettingPtr = connectPtr->settings();
if (connectSettingPtr.isNull()) { if (connectSettingPtr.isNull()) {

View File

@ -30,7 +30,7 @@ public:
KyApConnectItem *getApConnectionByUuid(QString connectUuid); KyApConnectItem *getApConnectionByUuid(QString connectUuid);
void getConnectionSetting(QString connectUuid, KyConnectSetting &connectSetting); void getConnectionSetting(QString connectUuid, KyConnectSetting &connectSetting);
bool getInterfaceByUuid(QString &deviceName, NetworkManager::ConnectionSettings::ConnectionType &type, const QString connUuid); bool getInterfaceByUuid(QString &deviceName, const QString connUuid);
void getConnectivity(NetworkManager::Connectivity &connectivity); void getConnectivity(NetworkManager::Connectivity &connectivity);
bool isWiredConnection(QString uuid); bool isWiredConnection(QString uuid);

View File

@ -202,6 +202,33 @@ void KyNetworkDeviceResourse::getDeviceActiveAPInfo(const QString devName, QStri
} }
} }
int KyNetworkDeviceResourse::getWirelessDeviceCapability(const QString deviceName)
{
NetworkManager::Device::Ptr connectDevice =
m_networkResourceInstance->findDeviceInterface(deviceName);
if (connectDevice->isValid()
&& NetworkManager::Device::Type::Wifi == connectDevice->type()) {
NetworkManager::WirelessDevice *wirelessDevicePtr =
qobject_cast<NetworkManager::WirelessDevice *>(connectDevice.data());
int cap = 0;
if (wirelessDevicePtr->wirelessCapabilities() & NetworkManager::WirelessDevice::ApCap) {
cap = cap | 0x01;
}
if (wirelessDevicePtr->wirelessCapabilities() & NetworkManager::WirelessDevice::Freq2Ghz) {
cap = cap | 0x02;
}
if (wirelessDevicePtr->wirelessCapabilities() & NetworkManager::WirelessDevice::Freq5Ghz) {
cap = cap | 0x04;
}
return cap;
} else {
qWarning()<<"[KyNetworkDeviceResourse]"<<deviceName<<" is not valid or not wireless.";
}
return 0;
}
#if 0 #if 0
void KyNetworkDeviceResourse::DeviceSpeed(QString deviceName, KyConnectItem *wiredItem) void KyNetworkDeviceResourse::DeviceSpeed(QString deviceName, KyConnectItem *wiredItem)
{ {

View File

@ -37,6 +37,7 @@ public:
// void disconnectDevice(); // void disconnectDevice();
//void setDeviceAutoConnect(); //void setDeviceAutoConnect();
void getDeviceActiveAPInfo(const QString devName, QString &strMac, uint &iHz, uint &iChan, QString &secuType); void getDeviceActiveAPInfo(const QString devName, QString &strMac, uint &iHz, uint &iChan, QString &secuType);
int getWirelessDeviceCapability(const QString deviceName);
private: private:
KyWiredConnectOperation wiredOperation; KyWiredConnectOperation wiredOperation;

View File

@ -17,6 +17,8 @@
*/ */
#include "kylinnetworkresourcemanager.h" #include "kylinnetworkresourcemanager.h"
#define SIGNAL_DELAY 80000
#define EMIT_DELAY 10000
KyNetworkResourceManager* KyNetworkResourceManager::m_pInstance = nullptr; KyNetworkResourceManager* KyNetworkResourceManager::m_pInstance = nullptr;
@ -559,11 +561,12 @@ void KyNetworkResourceManager::onActiveConnectionChanged(
NetworkManager::ActiveConnection * activeConnect = NetworkManager::ActiveConnection * activeConnect =
qobject_cast<NetworkManager::ActiveConnection *>(sender()); qobject_cast<NetworkManager::ActiveConnection *>(sender());
if (activeConnect->isValid()) { if (activeConnect->isValid()) {
qDebug()<<"!New state change activate connect"<<activeConnect->uuid(); qDebug()<< "[KyNetworkResourceManager]" <<"!New state change activate connect"<<activeConnect->uuid();
qDebug()<<"!New the active connect state"<<state; qDebug()<< "[KyNetworkResourceManager]" <<"!New the active connect state"<<state;
::usleep(SIGNAL_DELAY);
while(activeConnect->state() != state) { while(activeConnect->state() != state) {
qDebug()<<"connect real state"<<activeConnect->state() <<"change state"<<state; qDebug()<<"connect real state"<<activeConnect->state() <<"change state"<<state;
::usleep(10000); ::usleep(EMIT_DELAY);
} }
emit activeConnectStateChangeReason(activeConnect->uuid(), state, emit activeConnectStateChangeReason(activeConnect->uuid(), state,
NetworkManager::ActiveConnection::Reason::UknownReason); NetworkManager::ActiveConnection::Reason::UknownReason);

View File

@ -654,16 +654,6 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
void KyWirelessConnectOperation::setWirelessEnabled(bool enabled) void KyWirelessConnectOperation::setWirelessEnabled(bool enabled)
{ {
NetworkManager::setWirelessEnabled(enabled); NetworkManager::setWirelessEnabled(enabled);
#if 0
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA);
if (gsetting->get(WIRELESS_SWITCH).toBool() != enabled) {
gsetting->set(WIRELESS_SWITCH, enabled);
}
} else {
qDebug()<<"isSchemaInstalled false";
}
#endif
} }
bool KyWirelessConnectOperation::getWirelessEnabled() bool KyWirelessConnectOperation::getWirelessEnabled()
@ -687,7 +677,10 @@ bool KyWirelessConnectOperation::getConnSecretFlags(QString &connUuid, NetworkMa
} }
NetworkManager::ConnectionSettings::Ptr NetworkManager::ConnectionSettings::Ptr
KyWirelessConnectOperation::createWirelessApSetting(const QString apSsid, const QString apPassword, const QString apDevice) KyWirelessConnectOperation::createWirelessApSetting(const QString apSsid,
const QString apPassword,
const QString apDevice,
const QString wirelessBand)
{ {
NetworkManager::ConnectionSettings::Ptr connectionSettings = NetworkManager::ConnectionSettings::Ptr connectionSettings =
NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless)); NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless));
@ -713,6 +706,15 @@ NetworkManager::ConnectionSettings::Ptr
wirelessSetting->setSsid(apSsid.toUtf8()); wirelessSetting->setSsid(apSsid.toUtf8());
wirelessSetting->setMode(NetworkManager::WirelessSetting::NetworkMode::Ap); wirelessSetting->setMode(NetworkManager::WirelessSetting::NetworkMode::Ap);
wirelessSetting->setSecurity("802-11-wireless-security"); wirelessSetting->setSecurity("802-11-wireless-security");
if (wirelessBand == WIFI_BAND_2_4GHZ) {
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Bg);
} else if (wirelessBand == WIFI_BAND_5GHZ) {
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::A);
} else {
qWarning()<<"[KyWirelessConnectOperation] the band type undefined"<<wirelessBand;
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Automatic);
}
NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
= connectionSettings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>(); = connectionSettings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
@ -729,7 +731,9 @@ NetworkManager::ConnectionSettings::Ptr
void KyWirelessConnectOperation::updateWirelessApSetting( void KyWirelessConnectOperation::updateWirelessApSetting(
NetworkManager::Connection::Ptr apConnectPtr, NetworkManager::Connection::Ptr apConnectPtr,
const QString apName, const QString apPassword, const QString apDevice) const QString apName, const QString apPassword,
const QString apDevice, const QString wirelessBand)
{ {
NetworkManager::ConnectionSettings::Ptr apConnectSettingPtr = apConnectPtr->settings(); NetworkManager::ConnectionSettings::Ptr apConnectSettingPtr = apConnectPtr->settings();
apConnectSettingPtr->setId(apName); apConnectSettingPtr->setId(apName);
@ -740,6 +744,15 @@ void KyWirelessConnectOperation::updateWirelessApSetting(
= apConnectSettingPtr->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>(); = apConnectSettingPtr->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
wirelessSetting->setInitialized(true); wirelessSetting->setInitialized(true);
wirelessSetting->setSsid(apName.toUtf8()); wirelessSetting->setSsid(apName.toUtf8());
if (wirelessBand == WIFI_BAND_2_4GHZ) {
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Bg);
} else if (wirelessBand == WIFI_BAND_5GHZ) {
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::A);
} else {
qWarning()<<"[KyWirelessConnectOperation] the band type undefined"<<wirelessBand;
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Automatic);
}
NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
= apConnectSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>(); = apConnectSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
@ -755,8 +768,11 @@ void KyWirelessConnectOperation::updateWirelessApSetting(
} }
void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QString apName, void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QString apName,
const QString apPassword, const QString apDevice) const QString apPassword, const QString apDevice,
const QString wirelessBand)
{ {
qDebug() << "activeWirelessAp]" << apUuid << apName << apPassword << apDevice << wirelessBand;
//1、检查连接是否存在 //1、检查连接是否存在
NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(apUuid); NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(apUuid);
if (nullptr == connectPtr) { if (nullptr == connectPtr) {
@ -771,7 +787,7 @@ void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QS
QString deviceIdentifier = devicePtr->uni(); QString deviceIdentifier = devicePtr->uni();
NetworkManager::ConnectionSettings::Ptr apConnectSettingPtr = NetworkManager::ConnectionSettings::Ptr apConnectSettingPtr =
createWirelessApSetting(apName, apPassword, apDevice); createWirelessApSetting(apName, apPassword, apDevice, wirelessBand);
QString specificObject = ""; QString specificObject = "";
QDBusPendingCallWatcher * watcher; QDBusPendingCallWatcher * watcher;
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(apConnectSettingPtr->toMap(), deviceIdentifier, specificObject), this}; watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(apConnectSettingPtr->toMap(), deviceIdentifier, specificObject), this};
@ -784,7 +800,7 @@ void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QS
watcher->deleteLater(); watcher->deleteLater();
}); });
} else { } else {
updateWirelessApSetting(connectPtr, apName, apPassword, apDevice); updateWirelessApSetting(connectPtr, apName, apPassword, apDevice, wirelessBand);
QTimer::singleShot(500, this, [=](){ QTimer::singleShot(500, this, [=](){
activateApConnectionByUuid(apUuid, apDevice); activateApConnectionByUuid(apUuid, apDevice);
}); });

View File

@ -9,7 +9,10 @@
#include "kyenterpricesettinginfo.h" #include "kyenterpricesettinginfo.h"
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch"; const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
const QString WIRELESS_SWITCH = "wirelessswitch"; const QString WIRELESS_SWITCH = "wirelessswitch";
const QString WIFI_BAND_2_4GHZ = "2.4Ghz";
const QString WIFI_BAND_5GHZ = "5Ghz";
enum KySecuType { enum KySecuType {
NONE = 0, NONE = 0,
@ -105,13 +108,22 @@ public:
//申请扫描 //申请扫描
void requestWirelessScan(); void requestWirelessScan();
void activeWirelessAp(const QString apUuid, const QString apName, const QString apPassword, const QString apDevice); void activeWirelessAp(const QString apUuid, const QString apName,
const QString apPassword, const QString apDevice,
const QString wirelessBand);
void deactiveWirelessAp(const QString apName, const QString apUuid); void deactiveWirelessAp(const QString apName, const QString apUuid);
private: private:
NetworkManager::ConnectionSettings::Ptr createWirelessApSetting(const QString apSsid, const QString apPassword, const QString apDevice); NetworkManager::ConnectionSettings::Ptr createWirelessApSetting(const QString apSsid,
const QString apPassword,
const QString apDevice,
const QString wirelessBand);
void updateWirelessApSetting(NetworkManager::Connection::Ptr apConnectPtr, void updateWirelessApSetting(NetworkManager::Connection::Ptr apConnectPtr,
const QString apName, const QString apPassword, const QString apDevice); const QString apName,
const QString apPassword,
const QString apDevice,
const QString wirelessBand);

View File

@ -33,6 +33,10 @@ KyWirelessNetResource::KyWirelessNetResource(QObject *parent)
connect(m_connectResource, &KyConnectResourse::connectionRemove, this, &KyWirelessNetResource::onConnectionRemove); connect(m_connectResource, &KyConnectResourse::connectionRemove, this, &KyWirelessNetResource::onConnectionRemove);
connect(m_connectResource, &KyConnectResourse::connectionUpdate, this, &KyWirelessNetResource::onConnectionUpdate); connect(m_connectResource, &KyConnectResourse::connectionUpdate, this, &KyWirelessNetResource::onConnectionUpdate);
connect(m_device, &KyNetworkDeviceResourse::deviceAdd, this, &KyWirelessNetResource::onDeviceAdd);
connect(m_device, &KyNetworkDeviceResourse::deviceRemove, this, &KyWirelessNetResource::onDeviceRemove);
connect(m_device, &KyNetworkDeviceResourse::deviceNameUpdate, this, &KyWirelessNetResource::onDeviceNameUpdate);
} }
KyWirelessNetResource::~KyWirelessNetResource() KyWirelessNetResource::~KyWirelessNetResource()
@ -616,3 +620,34 @@ void KyWirelessNetResource::onConnectionUpdate(QString uuid)
kyWirelessNetItemListInit(); kyWirelessNetItemListInit();
emit wifiNetworkUpdate(); emit wifiNetworkUpdate();
} }
void KyWirelessNetResource::onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType)
{
if(deviceType == NetworkManager::Device::Type::Wifi) {
if (!m_WifiNetworkList.contains(deviceName)) {
m_WifiNetworkList.insert(deviceName,QList<KyWirelessNetItem>());
}
}
}
void KyWirelessNetResource::onDeviceRemove(QString deviceName)
{
if (m_WifiNetworkList.contains(deviceName)) {
m_WifiNetworkList.remove(deviceName);
}
}
void KyWirelessNetResource::onDeviceNameUpdate(QString oldName, QString newName)
{
if (!m_WifiNetworkList.contains(oldName)) {
return;
}
QMap<QString, QList<KyWirelessNetItem> > newWifiNetworkList(m_WifiNetworkList);
QList<KyWirelessNetItem> list = m_WifiNetworkList[oldName];
newWifiNetworkList.remove(oldName);
newWifiNetworkList.insert(newName,list);
m_WifiNetworkList = newWifiNetworkList;
}

View File

@ -7,6 +7,7 @@
#include "kyenterpricesettinginfo.h" #include "kyenterpricesettinginfo.h"
#include "kylinconnectresource.h" #include "kylinconnectresource.h"
#include "kywirelessconnectoperation.h" #include "kywirelessconnectoperation.h"
#include "kylinnetworkdeviceresource.h"
//class KyWirelessNetItem; //class KyWirelessNetItem;
@ -50,6 +51,10 @@ public slots:
void onConnectionUpdate(QString uuid); void onConnectionUpdate(QString uuid);
void onConnectionRemove(QString); void onConnectionRemove(QString);
void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType);
void onDeviceRemove(QString deviceName);
void onDeviceNameUpdate(QString oldName, QString newName);
signals: signals:
void signalStrengthChange(QString, QString, int); void signalStrengthChange(QString, QString, int);
void bssidChange(QString, QString, QString); void bssidChange(QString, QString, QString);
@ -64,6 +69,7 @@ private:
KyNetworkResourceManager *m_networkResourceInstance = nullptr; KyNetworkResourceManager *m_networkResourceInstance = nullptr;
KyConnectResourse *m_connectResource = nullptr; KyConnectResourse *m_connectResource = nullptr;
KyWirelessConnectOperation *m_operation = nullptr; KyWirelessConnectOperation *m_operation = nullptr;
KyNetworkDeviceResourse *m_device = nullptr;
QMap<QString, QList<KyWirelessNetItem> > m_WifiNetworkList; QMap<QString, QList<KyWirelessNetItem> > m_WifiNetworkList;
}; };

View File

@ -30,6 +30,7 @@ DbusAdaptor::DbusAdaptor(MainWindow *parent)
{ {
// constructor // constructor
qDBusRegisterMetaType<QMap<QString, bool> >(); qDBusRegisterMetaType<QMap<QString, bool> >();
qDBusRegisterMetaType<QMap<QString, int> >();
qDBusRegisterMetaType<QVector<QStringList> >(); qDBusRegisterMetaType<QVector<QStringList> >();
qDBusRegisterMetaType<QMap<QString, QVector<QStringList> >>(); qDBusRegisterMetaType<QMap<QString, QVector<QStringList> >>();
//setAutoRelaySignals(true)后会自动转发mainwindow发出的同名信号因此不必再额外写一个转发 //setAutoRelaySignals(true)后会自动转发mainwindow发出的同名信号因此不必再额外写一个转发
@ -77,16 +78,17 @@ void DbusAdaptor::setWiredSwitchEnable(bool enable)
void DbusAdaptor::setWirelessSwitchEnable(bool enable) void DbusAdaptor::setWirelessSwitchEnable(bool enable)
{ {
//todo mainwindow调用backend 对开关 打开/关闭 //todo mainwindow调用backend 对开关 打开/关闭
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) { // if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA_KYLIN_NM)) {
QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM); // QGSettings *gsetting = new QGSettings(GSETTINGS_SCHEMA_KYLIN_NM);
if (gsetting->get(KEY_WIRELESS_SWITCH).toBool() != enable) { // if (gsetting->get(KEY_WIRELESS_SWITCH).toBool() != enable) {
gsetting->set(KEY_WIRELESS_SWITCH, enable); // gsetting->set(KEY_WIRELESS_SWITCH, enable);
} // }
delete gsetting; // delete gsetting;
gsetting = nullptr; // gsetting = nullptr;
} else { // } else {
qDebug()<<"isSchemaInstalled false"; // qDebug()<<"isSchemaInstalled false";
} // }
parent()->setWirelessSwitchEnable(enable);
} }
//启用/禁用网卡 //启用/禁用网卡
@ -175,28 +177,38 @@ QMap<QString, bool> DbusAdaptor::getDeviceListAndEnabled(int devType)
return map; return map;
} }
//获取无线设备能力
QMap<QString, int> DbusAdaptor::getWirelessDeviceCap()
{
QMap<QString, int> map;
parent()->getWirelessDeviceCap(map);
return map;
}
//唤起属性页 根据网卡类型 参数2 为ssid/uuid //唤起属性页 根据网卡类型 参数2 为ssid/uuid
void DbusAdaptor::showPropertyWidget(QString devName, QString ssid) void DbusAdaptor::showPropertyWidget(QString devName, QString ssid)
{ {
qDebug() << "showPropertyWidget";
parent()->showPropertyWidget(devName,ssid); parent()->showPropertyWidget(devName,ssid);
} }
//唤起新建有线连接界面 //唤起新建有线连接界面
void DbusAdaptor::showCreateWiredConnectWidget(QString devName) void DbusAdaptor::showCreateWiredConnectWidget(QString devName)
{ {
qDebug() << "showCreateWiredConnectWidget";
parent()->showCreateWiredConnectWidget(devName); parent()->showCreateWiredConnectWidget(devName);
} }
//开启热点 //开启热点
void DbusAdaptor::activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice) void DbusAdaptor::activeWirelessAp(const QString apName, const QString apPassword, const QString band, const QString apDevice)
{ {
parent()->activeWirelessAp(apName, apPassword, apDevice); parent()->activeWirelessAp(apName, apPassword, band, apDevice);
} }
//断开热点 //断开热点
void DbusAdaptor::deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice) void DbusAdaptor::deactiveWirelessAp(const QString apName, const QString uuid)
{ {
parent()->deactiveWirelessAp(apName, apPassword, apDevice); parent()->deactiveWirelessAp(apName, uuid);
} }
//获取热点 //获取热点
@ -207,3 +219,18 @@ QStringList DbusAdaptor::getStoredApInfo()
parent()->getStoredApInfo(list); parent()->getStoredApInfo(list);
return list; return list;
} }
QStringList DbusAdaptor::getApInfoBySsid(QString devName, QString ssid)
{
QStringList list;
list.clear();
parent()->getApInfoBySsid(devName, ssid, list);
return list;
}
//扫描
void DbusAdaptor::reScan()
{
parent()->rescan();
}

View File

@ -68,16 +68,21 @@ public Q_SLOTS: // METHODS
Q_NOREPLY void deActivateConnect(int type, QString devName, QString ssid); Q_NOREPLY void deActivateConnect(int type, QString devName, QString ssid);
//获取设备列表和启用/禁用状态 //获取设备列表和启用/禁用状态
QMap<QString, bool> getDeviceListAndEnabled(int devType); QMap<QString, bool> getDeviceListAndEnabled(int devType);
//获取无线设备能力
QMap<QString, int> getWirelessDeviceCap();
//唤起属性页 根据网卡类型 参数2 为ssid/uuid //唤起属性页 根据网卡类型 参数2 为ssid/uuid
Q_NOREPLY void showPropertyWidget(QString devName, QString ssid); Q_NOREPLY void showPropertyWidget(QString devName, QString ssid);
//唤起新建有线连接界面 //唤起新建有线连接界面
Q_NOREPLY void showCreateWiredConnectWidget(QString devName); Q_NOREPLY void showCreateWiredConnectWidget(QString devName);
//开启热点 //开启热点
void activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice); void activeWirelessAp(const QString apName, const QString apPassword, const QString band, const QString apDevice);
//断开热点 //断开热点
void deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice); void deactiveWirelessAp(const QString apName, const QString uuid);
//获取热点 //获取热点
QStringList getStoredApInfo(); QStringList getStoredApInfo();
QStringList getApInfoBySsid(QString devName, QString ssid);
//wifi扫描
void reScan();
Q_SIGNALS: // SIGNALS Q_SIGNALS: // SIGNALS
// void wirelessActivating(QString devName, QString ssid); // void wirelessActivating(QString devName, QString ssid);
// void wiredActivating(QString devName, QString ssid); // void wiredActivating(QString devName, QString ssid);
@ -86,7 +91,7 @@ Q_SIGNALS: // SIGNALS
void lanUpdate(QString devName, QStringList info); void lanUpdate(QString devName, QStringList info);
void wlanAdd(QString devName, QStringList info); void wlanAdd(QString devName, QStringList info);
void wlanRemove(QString devName,QString ssid); void wlanRemove(QString devName,QString ssid);
void wlanactiveConnectionStateChanged(QString devName, QString ssid, int status); void wlanactiveConnectionStateChanged(QString devName, QString ssid, QString uuid, int status);
void lanActiveConnectionStateChanged(QString devName, QString uuid, int status); void lanActiveConnectionStateChanged(QString devName, QString uuid, int status);
//仅失败若成功直接发listUpdate //仅失败若成功直接发listUpdate
void activateFailed(QString errorMessage); void activateFailed(QString errorMessage);
@ -97,7 +102,7 @@ Q_SIGNALS: // SIGNALS
//热点断开 //热点断开
void hotspotDeactivated(QString devName, QString ssid); void hotspotDeactivated(QString devName, QString ssid);
//热点连接 //热点连接
void hotspotActivated(QString devName, QString ssid); void hotspotActivated(QString devName, QString ssid, QString uuid);
//信号强度变化 //信号强度变化
void signalStrengthChange(QString devName, QString ssid, int strength); void signalStrengthChange(QString devName, QString ssid, int strength);

View File

@ -32,8 +32,8 @@ LanListItem::LanListItem(KyConnectItem *data, QString deviceName, QWidget *paren
LanListItem::LanListItem(QWidget *parent) : ListItem(parent) LanListItem::LanListItem(QWidget *parent) : ListItem(parent)
{ {
m_isActive = false; m_isActive = false;
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-none-symbolic")); m_netButton->setButtonIcon(QIcon::fromTheme("network-offline-symbolic"));
const QString str="Not connected"; const QString str=tr("Not connected");
m_nameLabel->setText(str); m_nameLabel->setText(str);
this->m_infoButton->hide(); this->m_infoButton->hide();
} }
@ -82,11 +82,17 @@ void LanListItem::onRightButtonClicked()
void LanListItem::onInfoButtonClicked() void LanListItem::onInfoButtonClicked()
{ {
if(isDetailShow){
qDebug() << "has show the detail page,and do not show again" << Q_FUNC_INFO << __LINE__;
return;
}
if(m_data){ if(m_data){
qDebug()<<"Net active or not:"<<m_isActive; 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__; qDebug() << "On lan info button clicked! uuid = " << m_data->m_connectUuid << "; name = " << m_data->m_connectName << "." <<Q_FUNC_INFO << __LINE__;
NetDetail *netDetail = new NetDetail(deviceName, m_data->m_connectName, m_data->m_connectUuid, m_isActive,false, false, this); NetDetail *netDetail = new NetDetail(deviceName, m_data->m_connectName, m_data->m_connectUuid, m_isActive,false, false, this);
connect(netDetail, &NetDetail::detailPageClose, this, &LanListItem::onDetailShow);
netDetail->show(); netDetail->show();
emit this->detailShow(true);
} }
else{ else{
qDebug() << "On lan info button clicked! But there is no wlan connect " ; qDebug() << "On lan info button clicked! But there is no wlan connect " ;

View File

@ -14,9 +14,12 @@
ListItem::ListItem(QWidget *parent) : QFrame(parent) ListItem::ListItem(QWidget *parent) : QFrame(parent)
{ {
m_connectState = UnknownState; m_connectState = UnknownState;
isDetailShow = false;
initUI(); initUI();
initConnection(); initConnection();
connect(qApp, &QApplication::paletteChanged, this, &ListItem::onPaletteChanged); connect(qApp, &QApplication::paletteChanged, this, &ListItem::onPaletteChanged);
connect(this, &ListItem::detailShow, this, &ListItem::onDetailShow);
// m_itemFrame->installEventFilter(this);
} }
ListItem::~ListItem() ListItem::~ListItem()
@ -166,3 +169,8 @@ void ListItem::onPaletteChanged()
pal.setColor(QPalette::Window, qApp->palette().base().color()); pal.setColor(QPalette::Window, qApp->palette().base().color());
this->setPalette(pal); this->setPalette(pal);
} }
void ListItem::onDetailShow(bool isShow)
{
isDetailShow = isShow;
}

View File

@ -49,6 +49,7 @@ protected:
public: public:
QVBoxLayout * m_mainLayout = nullptr; QVBoxLayout * m_mainLayout = nullptr;
QHBoxLayout * m_hItemLayout = nullptr; QHBoxLayout * m_hItemLayout = nullptr;
bool isDetailShow;
private: private:
void initUI(); void initUI();
void initConnection(); void initConnection();
@ -56,6 +57,10 @@ private:
public slots: public slots:
virtual void onNetButtonClicked() = 0; virtual void onNetButtonClicked() = 0;
void onPaletteChanged(); void onPaletteChanged();
void onDetailShow(bool isShow);
signals:
void detailShow(bool isShow);
}; };
#endif // LISTITEM_H #endif // LISTITEM_H

View File

@ -4,12 +4,13 @@
#define EMPTY_SSID "EMPTY_SSID" #define EMPTY_SSID "EMPTY_SSID"
#define LOG_FLAG "[WlanListItem]" #define LOG_FLAG "[WlanListItem]"
#define WAIT_US 70*1000 #define WAIT_US 10*1000
WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, QWidget *parent) : ListItem(parent) WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, QWidget *parent) : ListItem(parent)
{ {
m_wlanDevice = device; m_wlanDevice = device;
m_wirelessNetItem = wirelessNetItem; m_wirelessNetItem = wirelessNetItem;
m_forgetConnection = false;
qDebug()<<"[WlanPage] wlan list item is created." << m_wirelessNetItem.m_NetSsid; qDebug()<<"[WlanPage] wlan list item is created." << m_wirelessNetItem.m_NetSsid;
@ -27,7 +28,9 @@ WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, Q
WlanListItem::WlanListItem(QWidget *parent) : ListItem(parent) WlanListItem::WlanListItem(QWidget *parent) : ListItem(parent)
{ {
m_wirelessNetItem.m_NetSsid = EMPTY_SSID; m_wirelessNetItem.m_NetSsid = EMPTY_SSID;
qDebug()<<"[WlanPage] wlan list item is created." << m_wirelessNetItem.m_NetSsid; qDebug()<<"[WlanPage] wlan list item is created." << m_wirelessNetItem.m_NetSsid;
m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-none-symbolic")); m_netButton->setButtonIcon(QIcon::fromTheme("network-wireless-signal-none-symbolic"));
const QString name = tr("Not connected"); const QString name = tr("Not connected");
setExpanded(false); setExpanded(false);
@ -304,6 +307,12 @@ void WlanListItem::refreshIcon()
void WlanListItem::onInfoButtonClicked() void WlanListItem::onInfoButtonClicked()
{ {
//ZJP_TODO 呼出无线详情页
if(isDetailShow){
qDebug() << "has show the detail page,and do not show again" << Q_FUNC_INFO << __LINE__;
return;
}
qDebug() << LOG_FLAG << "Net active or not:"<< m_connectState; qDebug() << LOG_FLAG << "Net active or not:"<< m_connectState;
qDebug() << LOG_FLAG << "On wlan info button clicked! ssid = " qDebug() << LOG_FLAG << "On wlan info button clicked! ssid = "
<< m_wirelessNetItem.m_NetSsid << "; name = " << m_wirelessNetItem.m_NetSsid << "; name = "
@ -314,11 +323,13 @@ void WlanListItem::onInfoButtonClicked()
if (Activated == m_connectState) { if (Activated == m_connectState) {
isActive = true; isActive = true;
} }
NetDetail *netDetail = new NetDetail(m_wlanDevice, m_wirelessNetItem.m_NetSsid, NetDetail *netDetail = new NetDetail(m_wlanDevice, m_wirelessNetItem.m_NetSsid,
m_wirelessNetItem.m_connectUuid, isActive, true, m_wirelessNetItem.m_connectUuid, isActive, true,
!m_wirelessNetItem.m_isConfigured, this); !m_wirelessNetItem.m_isConfigured, this);
connect(netDetail, &NetDetail::detailPageClose, this, &WlanListItem::onDetailShow);
netDetail->show(); netDetail->show();
emit this->detailShow(true);
} }
void WlanListItem::onNetButtonClicked() void WlanListItem::onNetButtonClicked()
@ -457,23 +468,25 @@ void WlanListItem::onConnectButtonClicked()
return; return;
} }
void WlanListItem::connectStateIsChanging() ConnectState WlanListItem::getConnectionState()
{ {
m_netButton->startLoading(); return m_connectState;
return;
}
void WlanListItem::connectStateChanged()
{
m_netButton->stopLoading();
return;
} }
void WlanListItem::updateConnectState(ConnectState state) void WlanListItem::updateConnectState(ConnectState state)
{ {
m_connectState = state; m_connectState = state;
if (m_forgetConnection) {
/*
*
*/
if (state == Deactivated) {
m_wirelessConnectOperation->deleteWirelessConnect(m_wirelessNetItem.m_connectUuid);
m_forgetConnection = false;
}
}
if (Deactivated == state || Activated == state) { if (Deactivated == state || Activated == state) {
m_netButton->stopLoading(); m_netButton->stopLoading();
} else { } else {
@ -488,12 +501,15 @@ void WlanListItem::onMenuTriggered(QAction *action)
if (action->text() == tr("Disconnect") || action->text() == tr("Connect")) { if (action->text() == tr("Disconnect") || action->text() == tr("Connect")) {
this->onNetButtonClicked(); this->onNetButtonClicked();
} else if (action->text() == tr("Forget")) { } else if (action->text() == tr("Forget")) {
/*
*
*/
if (Activated == m_connectState) { if (Activated == m_connectState) {
m_forgetConnection = true;
m_wirelessConnectOperation->deActivateWirelessConnection(m_wlanDevice, m_wirelessNetItem.m_connectUuid); m_wirelessConnectOperation->deActivateWirelessConnection(m_wlanDevice, m_wirelessNetItem.m_connectUuid);
::usleep(WAIT_US); } else {
m_wirelessConnectOperation->deleteWirelessConnect(m_wirelessNetItem.m_connectUuid);
} }
m_wirelessConnectOperation->deleteWirelessConnect(m_wirelessNetItem.m_connectUuid);
} }
return; return;

View File

@ -33,10 +33,9 @@ public:
void setWlanState(const int &state); void setWlanState(const int &state);
void setExpanded(const bool &expanded); void setExpanded(const bool &expanded);
void connectStateIsChanging(); ConnectState getConnectionState();
void connectStateChanged();
void updateConnectState(ConnectState state); void updateConnectState(ConnectState state);
void updateWirelessNetSecurity(QString ssid, QString securityType); void updateWirelessNetSecurity(QString ssid, QString securityType);
void updateWirelessNetItem(KyWirelessNetItem &wirelessNetItem); void updateWirelessNetItem(KyWirelessNetItem &wirelessNetItem);
@ -81,6 +80,8 @@ private:
bool m_focusIsOut = true; bool m_focusIsOut = true;
bool m_mouseIsOut = true; bool m_mouseIsOut = true;
bool m_forgetConnection = false;
protected slots: protected slots:
void onInfoButtonClicked(); void onInfoButtonClicked();

View File

@ -147,13 +147,14 @@ void MainWindow::initTrayIcon()
m_trayIcon->setToolTip(QString(tr("kylin-nm"))); m_trayIcon->setToolTip(QString(tr("kylin-nm")));
m_showSettingsAction->setIcon(QIcon::fromTheme("document-page-setup-symbolic", QIcon(":/res/x/setup.png")) ); m_showSettingsAction->setIcon(QIcon::fromTheme("document-page-setup-symbolic", QIcon(":/res/x/setup.png")) );
m_trayIconMenu->addAction(m_showMainwindowAction); // m_trayIconMenu->addAction(m_showMainwindowAction);
m_trayIconMenu->addAction(m_showSettingsAction); m_trayIconMenu->addAction(m_showSettingsAction);
m_trayIcon->setContextMenu(m_trayIconMenu); m_trayIcon->setContextMenu(m_trayIconMenu);
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic")); m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
onRefreshTrayIcon();
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::onTrayIconActivated); connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::onTrayIconActivated);
connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled); // connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled);
connect(m_showSettingsAction, &QAction::triggered, this, &MainWindow::onShowSettingsActionTriggled); connect(m_showSettingsAction, &QAction::triggered, this, &MainWindow::onShowSettingsActionTriggled);
m_trayIcon->show(); m_trayIcon->show();
} }
@ -419,29 +420,39 @@ void MainWindow::getWiredList(QMap<QString, QVector<QStringList>> &map)
* @param apPassword * @param apPassword
* @param apDevice * @param apDevice
*/ */
void MainWindow::activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice) void MainWindow::activeWirelessAp(const QString apName, const QString apPassword, const QString band, const QString apDevice)
{ {
m_wlanWidget->activeWirelessAp(apName, apPassword, apDevice); m_wlanWidget->activeWirelessAp(apName, apPassword, band, apDevice);
} }
/** /**
* @brief MainWindow::activeWirelessAp dbus调用 * @brief MainWindow::activeWirelessAp dbus调用
* @param apName * @param apName
*/ */
void MainWindow::deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice) void MainWindow::deactiveWirelessAp(const QString apName, const QString uuid)
{ {
m_wlanWidget->deactiveWirelessAp(apName, apPassword, apDevice); m_wlanWidget->deactiveWirelessAp(apName, uuid);
} }
/** /**
* @brief MainWindow::activeWirelessAp dbus调用 * @brief MainWindow::activeWirelessAp dbus调用
* @param list * @param list
*/ */
void MainWindow::getApInfoBySsid(QString devName, QString ssid, QStringList &list)
{
m_wlanWidget->getApInfoBySsid(devName, ssid, list);
}
void MainWindow::getStoredApInfo(QStringList &list) void MainWindow::getStoredApInfo(QStringList &list)
{ {
m_wlanWidget->getStoredApInfo(list); m_wlanWidget->getStoredApInfo(list);
} }
//无线开关
void MainWindow::setWirelessSwitchEnable(bool enable)
{
m_wlanWidget->setWirelessSwitchEnable(enable);
}
void MainWindow::setWiredDeviceEnable(const QString& devName, bool enable) void MainWindow::setWiredDeviceEnable(const QString& devName, bool enable)
{ {
@ -484,6 +495,11 @@ void MainWindow::showCreateWiredConnectWidget(const QString devName)
netDetail->show(); netDetail->show();
} }
void MainWindow::getWirelessDeviceCap(QMap<QString, int> &map)
{
m_wlanWidget->getWirelessDeviceCap(map);
}
//有线连接断开 //有线连接断开
void MainWindow::activateWired(const QString& devName, const QString& connUuid) void MainWindow::activateWired(const QString& devName, const QString& connUuid)
{ {
@ -504,3 +520,8 @@ void MainWindow::deactivateWireless(const QString& devName, const QString& ssid)
{ {
m_wlanWidget->deactivateWirelessConnection(devName, ssid); m_wlanWidget->deactivateWirelessConnection(devName, ssid);
} }
void MainWindow::rescan()
{
m_wlanWidget->requestScan();
}

View File

@ -30,17 +30,20 @@ public:
void getWirelessList(QMap<QString, QVector<QStringList> > &map); void getWirelessList(QMap<QString, QVector<QStringList> > &map);
void getWiredList(QMap<QString, QVector<QStringList>> &map); void getWiredList(QMap<QString, QVector<QStringList>> &map);
//开启热点 //开启热点
void activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice); void activeWirelessAp(const QString apName, const QString apPassword, const QString wirelessBand, const QString apDevice);
//断开热点 //断开热点
void deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice); void deactiveWirelessAp(const QString apName, const QString uuid);
//获取热点 //获取热点
void getStoredApInfo(QStringList &list); void getStoredApInfo(QStringList &list);
void getApInfoBySsid(QString devName, QString ssid, QStringList &list);
//有线连接断开 //有线连接断开
void activateWired(const QString& devName, const QString& connUuid); void activateWired(const QString& devName, const QString& connUuid);
void deactivateWired(const QString& devName, const QString& connUuid); void deactivateWired(const QString& devName, const QString& connUuid);
//无线连接断开 //无线连接断开
void activateWireless(const QString& devName, const QString& ssid); void activateWireless(const QString& devName, const QString& ssid);
void deactivateWireless(const QString& devName, const QString& ssid); void deactivateWireless(const QString& devName, const QString& ssid);
//无线总开关
void setWirelessSwitchEnable(bool enable);
void setWiredDeviceEnable(const QString& devName, bool enable); void setWiredDeviceEnable(const QString& devName, bool enable);
@ -49,6 +52,10 @@ public:
//唤起新建有线连接界面 //唤起新建有线连接界面
void showCreateWiredConnectWidget(const QString devName); void showCreateWiredConnectWidget(const QString devName);
void getWirelessDeviceCap(QMap<QString, int> &map);
void rescan();
signals: signals:
//设备插拔 //设备插拔
void deviceStatusChanged(); void deviceStatusChanged();
@ -60,13 +67,13 @@ signals:
void lanUpdate(QString devName, QStringList info); void lanUpdate(QString devName, QStringList info);
void wlanAdd(QString devName, QStringList info); void wlanAdd(QString devName, QStringList info);
void wlanRemove(QString devName,QString ssid); void wlanRemove(QString devName,QString ssid);
void wlanactiveConnectionStateChanged(QString devName, QString ssid, int status); void wlanactiveConnectionStateChanged(QString devName, QString ssid, QString uuid, int status);
void lanActiveConnectionStateChanged(QString devName, QString uuid, int status); void lanActiveConnectionStateChanged(QString devName, QString uuid, int status);
void activateFailed(QString errorMessage); void activateFailed(QString errorMessage);
void deactivateFailed(QString errorMessage); void deactivateFailed(QString errorMessage);
//热点断开 //热点断开
void hotspotDeactivated(QString devName, QString ssid); void hotspotDeactivated(QString devName, QString ssid);
void hotspotActivated(QString devName, QString ssid); void hotspotActivated(QString devName, QString ssid, QString uuid);
//信号强度变化 //信号强度变化
void signalStrengthChange(QString devName, QString ssid, int strength); void signalStrengthChange(QString devName, QString ssid, int strength);
//安全性变化 //安全性变化

View File

@ -1,4 +1,6 @@
#include "detailpage.h" #include "detailpage.h"
#include <QPainter>
#include <QListWidget>
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
@ -72,65 +74,78 @@ bool DetailPage::checkIsChanged(const ConInfo info)
} }
} }
void DetailPage::addDetailItem(QListWidget *listWidget, DetailWidget *detailWidget)
{
QListWidgetItem *listWidgetItem = new QListWidgetItem(listWidget);
listWidgetItem->setSizeHint(QSize(listWidget->width(),36));
listWidgetItem->setFlags(Qt::NoItemFlags);
listWidget->addItem(listWidgetItem);
listWidget->setItemWidget(listWidgetItem, detailWidget);
}
void DetailPage::initUI() { void DetailPage::initUI() {
forgetNetBox = new QCheckBox(this); forgetNetBox = new QCheckBox(this);
layout = new QVBoxLayout(this); layout = new QVBoxLayout(this);
layout->setContentsMargins(0,0,0,0);
mDetailLayout = new QFormLayout(this); QWidget *mDetailFrame = new QFrame(this);
mDetailLayout = new QVBoxLayout(mDetailFrame);
mDetailLayout->setContentsMargins(0,0,0,0);
m_listWidget = new QListWidget(mDetailFrame);
m_listWidget->setFrameShape(QFrame::Shape::NoFrame);
m_listWidget->setBackgroundRole(QPalette::Base);
m_listWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
mDetailLayout->addWidget(m_listWidget);
mSSID = new QLineEdit(this); mSSID = new QLineEdit(this);
mSSID->setAlignment(Qt::AlignRight); mSSID->setAlignment(Qt::AlignRight);
if (!isCreate) { if (!isCreate) {
mSSID->setStyleSheet("background:transparent;border-width:0;border-style:outset"); mSSID->setStyleSheet("background:transparent;border-width:0px;border-style:none");
mSSID->setFocusPolicy(Qt::NoFocus); mSSID->setFocusPolicy(Qt::NoFocus);
} else { } else {
mSSID->setStyleSheet("border-width:0;border-style:outset"); // mSSID->setStyleSheet("border-width:1px;;border-style:solid;border-color:black;border-radius:2px");
mSSID->setStyleSheet("border-top:0px solid;border-bottom:1px solid;border-left:0px solid;border-right: 0px solid;");
mSSID->setPlaceholderText(tr("Please input SSID:"));
} }
m_ssidWidget = new DetailWidget(qobject_cast<QWidget *>(mSSID), m_listWidget);
m_ssidWidget->setKey(tr("SSID:"));
mProtocol = new QLabel(this); mProtocol = new QLabel(this);
QHBoxLayout *mProtocolLayout = new QHBoxLayout(this); m_protocolWidget = new DetailWidget(qobject_cast<QWidget *>(mProtocol), m_listWidget);
mProtocolLayout->addStretch(); m_protocolWidget->setKey(tr("Protocol:"));
mProtocolLayout->addWidget(mProtocol);
mSecType = new QLabel(this); mSecType = new QLabel(this);
QHBoxLayout *mSecTypeLayout = new QHBoxLayout(this); m_secTypeWidget = new DetailWidget(qobject_cast<QWidget *>(mSecType));
mSecTypeLayout->addStretch(); m_secTypeWidget->setKey(tr("Security Type:"));
mSecTypeLayout->addWidget(mSecType);
mHz = new QLabel(this); mHz = new QLabel(this);
QHBoxLayout *mHzLayout = new QHBoxLayout(this); m_hzWidget = new DetailWidget(qobject_cast<QWidget *>(mHz));
mHzLayout->addStretch(); m_hzWidget->setKey(tr("Hz:"));
mHzLayout->addWidget(mHz);
mChan = new QLabel(this); mChan = new QLabel(this);
QHBoxLayout *mChanLayout = new QHBoxLayout(this); m_chanelWidget = new DetailWidget(qobject_cast<QWidget *>(mChan));
mChanLayout->addStretch(); m_chanelWidget->setKey(tr("Chan:"));
mChanLayout->addWidget(mChan);
mBandWidth = new QLabel(this); mBandWidth = new QLabel(this);
QHBoxLayout *mBandWidthLayout = new QHBoxLayout(this); m_bandwidthWidget = new DetailWidget(qobject_cast<QWidget *>(mBandWidth), m_listWidget);
mBandWidthLayout->addStretch(); m_bandwidthWidget->setKey(tr("BandWidth:"));
mBandWidthLayout->addWidget(mBandWidth);
mIPV4 = new QLabel(this); mIPV4 = new QLabel(this);
QHBoxLayout *mIPV4Layout = new QHBoxLayout(this); m_ipv4Widget = new DetailWidget(qobject_cast<QWidget *>(mIPV4), m_listWidget);
mIPV4Layout->addStretch(); m_ipv4Widget->setKey(tr("IPV4:"));
mIPV4Layout->addWidget(mIPV4);
mIPV4Dns = new QLabel(this); mIPV4Dns = new QLabel(this);
QHBoxLayout *mIPV4DnsLayout = new QHBoxLayout(this); m_ipv4DnsWidget = new DetailWidget(qobject_cast<QWidget *>(mIPV4Dns), m_listWidget);
mIPV4DnsLayout->addStretch(); m_ipv4DnsWidget->setKey(tr("IPV4 Dns:"));
mIPV4DnsLayout->addWidget(mIPV4Dns);
mIPV6 = new QLabel(this); mIPV6 = new QLabel(this);
QHBoxLayout *mIPV6Layout = new QHBoxLayout(this); m_ipv6Widget = new DetailWidget(qobject_cast<QWidget *>(mIPV6), m_listWidget);
mIPV6Layout->addStretch(); m_ipv6Widget->setKey(tr("IPV6:"));
mIPV6Layout->addWidget(mIPV6);
mMac = new QLabel(this); mMac = new QLabel(this);
QHBoxLayout *mMacLayout = new QHBoxLayout(this); m_macWidget = new DetailWidget(qobject_cast<QWidget *>(mMac), m_listWidget);
mMacLayout->addStretch(); m_macWidget->setKey(tr("Mac:"));
mMacLayout->addWidget(mMac);
autoConnect = new QLabel(this); autoConnect = new QLabel(this);
@ -143,23 +158,28 @@ void DetailPage::initUI() {
mAutoLayout->addWidget(autoConnect); mAutoLayout->addWidget(autoConnect);
mAutoLayout->addSpacerItem(horizontalSpacer); mAutoLayout->addSpacerItem(horizontalSpacer);
mDetailLayout->addRow(tr("SSID:"), mSSID); this->addDetailItem(m_listWidget, m_ssidWidget);
mDetailLayout->addRow(tr("Protocol:"), mProtocolLayout); this->addDetailItem(m_listWidget, m_protocolWidget);
if (mIsWlan) { if (mIsWlan) {
mDetailLayout->addRow(tr("Security Type:"), mSecTypeLayout); this->addDetailItem(m_listWidget, m_secTypeWidget);
mDetailLayout->addRow(tr("Hz:"), mHzLayout); this->addDetailItem(m_listWidget, m_hzWidget);
mDetailLayout->addRow(tr("Chan:"), mChanLayout); this->addDetailItem(m_listWidget, m_chanelWidget);
} }
mDetailLayout->addRow(tr("BandWidth:"), mBandWidthLayout); this->addDetailItem(m_listWidget, m_bandwidthWidget);
mDetailLayout->addRow(tr("IPV6:"), mIPV6Layout); this->addDetailItem(m_listWidget, m_ipv6Widget);
mDetailLayout->addRow(tr("IPV4:"), mIPV4Layout); this->addDetailItem(m_listWidget, m_ipv4Widget);
mDetailLayout->addRow(tr("IPV4 Dns:"), mIPV4DnsLayout); this->addDetailItem(m_listWidget, m_ipv4DnsWidget);
mDetailLayout->addRow(tr("Mac:"), mMacLayout); this->addDetailItem(m_listWidget, m_macWidget);
layout->addLayout(mDetailLayout); QPalette mpal(m_listWidget->palette());
layout->addStretch(); mpal.setColor(QPalette::Base, qApp->palette().base().color());
mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
m_listWidget->setAlternatingRowColors(true);
// m_listWidget->setAutoFillBackground(true);
m_listWidget->setPalette(mpal);
layout->addWidget(mDetailFrame);
layout->addLayout(mAutoLayout); layout->addLayout(mAutoLayout);
} }
void DetailPage::setEnableOfSaveBtn() { void DetailPage::setEnableOfSaveBtn() {

View File

@ -7,7 +7,10 @@
#include <QCheckBox> #include <QCheckBox>
#include <QSpacerItem> #include <QSpacerItem>
#include <QDebug> #include <QDebug>
#include <QListWidget>
#include <QApplication>
#include "detailwidget.h"
#include "coninfo.h" #include "coninfo.h"
class DetailPage : public QFrame class DetailPage : public QFrame
@ -34,8 +37,21 @@ public:
private: private:
void initUI(); void initUI();
void addDetailItem(QListWidget *listWidget, DetailWidget *detailWidget);
public: public:
QListWidget * m_listWidget = nullptr;
DetailWidget * m_ssidWidget = nullptr;
DetailWidget * m_protocolWidget = nullptr;
DetailWidget * m_secTypeWidget = nullptr;
DetailWidget * m_hzWidget = nullptr;
DetailWidget * m_chanelWidget = nullptr;
DetailWidget * m_bandwidthWidget = nullptr;
DetailWidget * m_ipv4Widget = nullptr;
DetailWidget * m_ipv4DnsWidget = nullptr;
DetailWidget * m_ipv6Widget = nullptr;
DetailWidget * m_macWidget = nullptr;
QLineEdit *mSSID; QLineEdit *mSSID;
QLabel *mProtocol; QLabel *mProtocol;
QLabel *mSecType; QLabel *mSecType;
@ -51,7 +67,7 @@ public:
// QWidget *autoFrame; // QWidget *autoFrame;
private: private:
QVBoxLayout *layout; QVBoxLayout *layout;
QFormLayout *mDetailLayout; QVBoxLayout *mDetailLayout;
QHBoxLayout *mAutoLayout; QHBoxLayout *mAutoLayout;
QCheckBox *forgetNetBox; QCheckBox *forgetNetBox;
bool mIsWlan; bool mIsWlan;

View File

@ -0,0 +1,32 @@
#include "detailwidget.h"
#define ITEM_HEIGHT 36
#define ITEM_MARGINS 18,0,16,0
DetailWidget::DetailWidget(QWidget *valueWidget, QWidget *parent)
: m_valueWidget(valueWidget) , QWidget(parent)
{
// m_valueWidget = valueWidget;
initUI();
}
DetailWidget::~DetailWidget()
{
}
void DetailWidget::initUI()
{
this->setFixedHeight(ITEM_HEIGHT);
m_mainLayout = new QHBoxLayout(this);
m_mainLayout->setContentsMargins(ITEM_MARGINS);
m_keyLabel = new QLabel(this);
m_mainLayout->addWidget(m_keyLabel);
m_mainLayout->addStretch();
m_mainLayout->addWidget(m_valueWidget);
}
void DetailWidget::setKey(const QString &keyLabel)
{
m_keyLabel->setText(keyLabel);
}

View File

@ -0,0 +1,27 @@
#ifndef DetailWidget_H
#define DetailWidget_H
#include <QWidget>
#include <QLabel>
#include <QHBoxLayout>
class DetailWidget : public QWidget
{
Q_OBJECT
public:
explicit DetailWidget(QWidget *valueWidget = nullptr, QWidget *parent = nullptr);
~DetailWidget();
void setKey(const QString &keyLabel);
private:
QHBoxLayout * m_mainLayout = nullptr;
QLabel * m_keyLabel = nullptr;
QWidget * m_valueWidget = nullptr;
void initUI();
signals:
};
#endif // DetailWidget_H

View File

@ -3,8 +3,8 @@
#include "backend/kylinipv6arping.h" #include "backend/kylinipv6arping.h"
#include "xatom/xatom-helper.h" #include "xatom/xatom-helper.h"
#define WINDOW_WIDTH 540 #define WINDOW_WIDTH 520
#define WINDOW_HEIGHT 574 #define WINDOW_HEIGHT 590
#define BUTTON_SIZE 30 #define BUTTON_SIZE 30
#define ICON_SIZE 22,22 #define ICON_SIZE 22,22
#define TITLE_LAYOUT_MARGINS 9,9,0,0 #define TITLE_LAYOUT_MARGINS 9,9,0,0
@ -44,7 +44,7 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv
m_uuid(uuid), m_uuid(uuid),
isActive(isActive), isActive(isActive),
isWlan(isWlan), isWlan(isWlan),
isCreateNet(isCreateNet), m_isCreateNet(isCreateNet),
QDialog(parent) QDialog(parent)
{ {
//设置窗口无边框,阴影 //设置窗口无边框,阴影
@ -64,9 +64,11 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv
setFixedSize(WINDOW_WIDTH,WINDOW_HEIGHT); setFixedSize(WINDOW_WIDTH,WINDOW_HEIGHT);
centerToScreen(); centerToScreen();
if (isCreateNet && !uuid.isEmpty()) { qDebug() << m_isCreateNet << name;
isCreateNet = false; if (m_isCreateNet && !name.isEmpty()) {
m_isCreateNet = false;
} }
qDebug() << m_isCreateNet;
m_netDeviceResource = new KyNetworkDeviceResourse(this); m_netDeviceResource = new KyNetworkDeviceResourse(this);
m_wirelessConnOpration = new KyWirelessConnectOperation(this); m_wirelessConnOpration = new KyWirelessConnectOperation(this);
m_resource = new KyWirelessNetResource(this); m_resource = new KyWirelessNetResource(this);
@ -78,14 +80,15 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv
getConInfo(m_info); getConInfo(m_info);
pagePadding(name,isWlan); pagePadding(name,isWlan);
connect(qApp, &QApplication::paletteChanged, this, &NetDetail::onPaletteChanged);
isCreateOk = !(isCreateNet && !isWlan); isCreateOk = !(m_isCreateNet && !isWlan);
isDetailOk = !(m_name.isEmpty()); isDetailOk = !(m_name.isEmpty());
isIpv4Ok = true; isIpv4Ok = true;
isIpv6Ok = true; isIpv6Ok = true;
isSecuOk = true; isSecuOk = true;
qDebug() << interface << name << uuid << "isWlan" << isWlan << "isCreateNet" <<isCreateNet; qDebug() << interface << name << uuid << "isWlan" << isWlan << "isCreateNet" <<m_isCreateNet;
setConfirmEnable(); setConfirmEnable();
} }
@ -95,11 +98,31 @@ NetDetail::~NetDetail()
} }
void NetDetail::onPaletteChanged()
{
QPalette pal = qApp->palette();
pal.setColor(QPalette::Window, qApp->palette().base().color());
this->setPalette(pal);
QPalette listwidget_pal(detailPage->m_listWidget->palette());
listwidget_pal.setColor(QPalette::Base, qApp->palette().base().color());
listwidget_pal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
detailPage->m_listWidget->setAlternatingRowColors(true);
detailPage->m_listWidget->setPalette(listwidget_pal);
}
void NetDetail::paintEvent(QPaintEvent *event) void NetDetail::paintEvent(QPaintEvent *event)
{ {
return QDialog::paintEvent(event); return QDialog::paintEvent(event);
} }
void NetDetail::closeEvent(QCloseEvent *event)
{
emit this->detailPageClose(false);
return QDialog::closeEvent(event);
}
void NetDetail::centerToScreen() void NetDetail::centerToScreen()
{ {
QDesktopWidget* m = QApplication::desktop(); QDesktopWidget* m = QApplication::desktop();
@ -116,7 +139,7 @@ void NetDetail::initUI()
QVBoxLayout *mainLayout = new QVBoxLayout(this); QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(9,9,14,24); mainLayout->setContentsMargins(9,9,14,24);
detailPage = new DetailPage(isWlan, isCreateNet, this); detailPage = new DetailPage(isWlan, m_isCreateNet, this);
ipv4Page = new Ipv4Page(this); ipv4Page = new Ipv4Page(this);
ipv6Page = new Ipv6Page(this); ipv6Page = new Ipv6Page(this);
securityPage = new SecurityPage(this); securityPage = new SecurityPage(this);
@ -225,12 +248,16 @@ void NetDetail::initUI()
bottomLayout->addWidget(cancelBtn); bottomLayout->addWidget(cancelBtn);
bottomLayout->addWidget(confimBtn); bottomLayout->addWidget(confimBtn);
QPalette pal(this->palette());
pal.setColor(QPalette::Background, qApp->palette().base().color());
this->setAutoFillBackground(true);
this->setPalette(pal);
} }
void NetDetail::loadPage() void NetDetail::loadPage()
{ {
//判断是否创建网络页面 //判断是否创建网络页面
if (isCreateNet && !isWlan) { if (m_isCreateNet && !isWlan) {
pageFrame->hide(); pageFrame->hide();
stackWidget->setCurrentIndex(CREATE_NET_PAGE_NUM); stackWidget->setCurrentIndex(CREATE_NET_PAGE_NUM);
titleLabel->setText(tr("Add Lan Connect")); titleLabel->setText(tr("Add Lan Connect"));
@ -305,7 +332,7 @@ void NetDetail::initComponent()
void NetDetail::pagePadding(QString netName, bool isWlan) void NetDetail::pagePadding(QString netName, bool isWlan)
{ {
//网络详情页填充 //网络详情页填充
if(isCreateNet && !isWlan) { if(m_isCreateNet && !isWlan) {
return; return;
} }
@ -363,7 +390,7 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
//获取网路详情信息 //获取网路详情信息
void NetDetail::getConInfo(ConInfo &conInfo) void NetDetail::getConInfo(ConInfo &conInfo)
{ {
if (isCreateNet && !isWlan) { if (m_isCreateNet && !isWlan) {
return; return;
} }
getBaseInfo(conInfo); getBaseInfo(conInfo);
@ -555,7 +582,7 @@ void NetDetail::initTtlsInfo(ConInfo &conInfo)
//点击了保存更改网络设置的按钮 //点击了保存更改网络设置的按钮
void NetDetail::on_btnConfirm_clicked() void NetDetail::on_btnConfirm_clicked()
{ {
if (isCreateNet) { if (m_isCreateNet) {
if (!isWlan) { if (!isWlan) {
//新建有线连接 //新建有线连接
qDebug() << "Confirm create wired connect"; qDebug() << "Confirm create wired connect";
@ -589,7 +616,7 @@ void NetDetail::on_btnForget_clicked()
void NetDetail::setConfirmEnable() void NetDetail::setConfirmEnable()
{ {
if (isCreateNet && !isWlan) { if (m_isCreateNet && !isWlan) {
isConfirmBtnEnable = isCreateOk; isConfirmBtnEnable = isCreateOk;
} else { } else {
if (isDetailOk && isIpv4Ok && isIpv6Ok) { if (isDetailOk && isIpv4Ok && isIpv6Ok) {
@ -804,14 +831,25 @@ bool NetDetail::updateConnect()
m_wiredConnOperation->updateWiredConnect(m_uuid, connetSetting); m_wiredConnOperation->updateWiredConnect(m_uuid, connetSetting);
} }
if (isWlan && securityPage->checkIsChanged(m_info)) { bool securityChange = false;
KySecuType secuType; if (isWlan) {
KyEapMethodType enterpriseType; securityChange = securityPage->checkIsChanged(m_info);
securityPage->getSecuType(secuType, enterpriseType); if (securityChange) {
if (secuType == WPA_AND_WPA2_ENTERPRISE) { KySecuType secuType;
updateWirelessEnterPriseConnect(enterpriseType); KyEapMethodType enterpriseType;
} else { securityPage->getSecuType(secuType, enterpriseType);
updateWirelessPersonalConnect(); if (secuType == WPA_AND_WPA2_ENTERPRISE) {
updateWirelessEnterPriseConnect(enterpriseType);
} else {
updateWirelessPersonalConnect();
}
}
}
if (ipv4Change || ipv6Change || securityChange) {
if (isActive) {
//信息变化 断开-重连
m_wirelessConnOpration->activateConnection(m_uuid, m_deviceName);
} }
} }
return true; return true;

View File

@ -19,6 +19,7 @@
#include <QDBusObjectPath> #include <QDBusObjectPath>
#include <QDBusInterface> #include <QDBusInterface>
#include <QDBusReply> #include <QDBusReply>
#include <QCloseEvent>
#include "detailpage.h" #include "detailpage.h"
#include "ipv4page.h" #include "ipv4page.h"
@ -37,6 +38,7 @@ public:
~NetDetail(); ~NetDetail();
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
void closeEvent(QCloseEvent *event);
private: private:
void initUI(); void initUI();
@ -109,7 +111,7 @@ private:
QString m_deviceName; QString m_deviceName;
bool isWlan; bool isWlan;
bool isCreateNet; bool m_isCreateNet;
bool isActive; bool isActive;
bool isHideWlan; bool isHideWlan;
@ -127,5 +129,9 @@ private:
private slots: private slots:
void on_btnConfirm_clicked(); void on_btnConfirm_clicked();
void on_btnForget_clicked(); void on_btnForget_clicked();
void onPaletteChanged();
signals:
void detailPageClose(bool on);
}; };
#endif // NETDETAIL_H #endif // NETDETAIL_H

View File

@ -5,6 +5,7 @@ HEADERS += \
$$PWD/creatnetpage.h \ $$PWD/creatnetpage.h \
$$PWD/customtabstyle.h \ $$PWD/customtabstyle.h \
$$PWD/detailpage.h \ $$PWD/detailpage.h \
$$PWD/detailwidget.h \
$$PWD/ipv4page.h \ $$PWD/ipv4page.h \
$$PWD/ipv6page.h \ $$PWD/ipv6page.h \
$$PWD/netdetail.h \ $$PWD/netdetail.h \
@ -14,6 +15,7 @@ SOURCES += \
$$PWD/creatnetpage.cpp \ $$PWD/creatnetpage.cpp \
$$PWD/customtabstyle.cpp \ $$PWD/customtabstyle.cpp \
$$PWD/detailpage.cpp \ $$PWD/detailpage.cpp \
$$PWD/detailwidget.cpp \
$$PWD/ipv4page.cpp \ $$PWD/ipv4page.cpp \
$$PWD/ipv6page.cpp \ $$PWD/ipv6page.cpp \
$$PWD/netdetail.cpp \ $$PWD/netdetail.cpp \

View File

@ -22,6 +22,7 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent)
m_activeResourse = new KyActiveConnectResourse(this); m_activeResourse = new KyActiveConnectResourse(this);
m_connectResourse = new KyConnectResourse(this); m_connectResourse = new KyConnectResourse(this);
m_deviceResource = new KyNetworkDeviceResourse(this); m_deviceResource = new KyNetworkDeviceResourse(this);
m_wiredConnectOperation = new KyWiredConnectOperation(this);
initUI(); initUI();
initNetSwitch(); initNetSwitch();
@ -679,14 +680,13 @@ void LanPage::initUI()
inactiveLanListLayout->addWidget(m_inactivatedLanListWidget); inactiveLanListLayout->addWidget(m_inactivatedLanListWidget);
m_settingsLabel->installEventFilter(this); m_settingsLabel->installEventFilter(this);
// emit this->lanConnectChanged();
} }
QListWidgetItem *LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget) QListWidgetItem *LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget)
{ {
QListWidgetItem *p_listWidgetItem = new QListWidgetItem(listWidget); QListWidgetItem *p_listWidgetItem = new QListWidgetItem();
p_listWidgetItem->setSizeHint(QSize(listWidget->width(),ITEM_HEIGHT)); p_listWidgetItem->setSizeHint(QSize(listWidget->width(),ITEM_HEIGHT));
listWidget->addItem(p_listWidgetItem); listWidget->insertItem(0, p_listWidgetItem);
LanListItem *p_lanItem = nullptr; LanListItem *p_lanItem = nullptr;
if (itemData != nullptr) { if (itemData != nullptr) {
@ -766,8 +766,6 @@ void LanPage::updateConnectionArea(QString uuid)
qDebug()<<"[LanPage] update connection item"<<p_newItem->m_connectName; qDebug()<<"[LanPage] update connection item"<<p_newItem->m_connectName;
QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_inactivatedLanListWidget); QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_inactivatedLanListWidget);
m_deactiveMap.insert(p_newItem, p_listWidgetItem); m_deactiveMap.insert(p_newItem, p_listWidgetItem);
emit this->lanConnectChanged();
} else { } else {
delete p_newItem; delete p_newItem;
p_newItem = nullptr; p_newItem = nullptr;
@ -792,11 +790,20 @@ void LanPage::onUpdateLanlist(QString uuid,
updateActivatedConnectionArea(uuid); updateActivatedConnectionArea(uuid);
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) { } else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
updateConnectionArea(uuid); updateConnectionArea(uuid);
} else if (state == NetworkManager::ActiveConnection::State::Activating
|| state == NetworkManager::ActiveConnection::State::Deactivating) {
QString devName = m_activeResourse->getDeviceOfActivateConnect(uuid);
if (devName.isEmpty()) {
m_connectResourse->getInterfaceByUuid(devName, uuid);
}
emit lanActiveConnectionStateChanged(devName, uuid, state);
} }
emit this->lanConnectChanged();
return; return;
} }
void LanPage::getWiredList(QMap<QString, QVector<QStringList> > &map) void LanPage::getWiredList(QMap<QString, QVector<QStringList> > &map)
{ {
QStringList devlist; QStringList devlist;
@ -1040,7 +1047,6 @@ void LanPage::activateWired(const QString& devName, const QString& connUuid)
{ {
qDebug() << "[LanPage] activateWired" << devName << connUuid; qDebug() << "[LanPage] activateWired" << devName << connUuid;
m_wiredConnectOperation->activateConnection(connUuid, devName); m_wiredConnectOperation->activateConnection(connUuid, devName);
emit this->lanConnectChanged();
} }
void LanPage::deactivateWired(const QString& devName, const QString& connUuid) void LanPage::deactivateWired(const QString& devName, const QString& connUuid)

View File

@ -146,7 +146,7 @@ void WlanPage::onWlanSwitchClicked()
if (m_wlanSwitchEnable != switchEnable) { if (m_wlanSwitchEnable != switchEnable) {
qDebug()<< LOG_FLAG << "wlan switch state " << switchEnable; qDebug()<< LOG_FLAG << "wlan switch state " << switchEnable;
m_wirelessConnectOpreation->setWirelessEnabled(switchEnable); m_wirelessConnectOpreation->setWirelessEnabled(switchEnable);
m_switchGsettings->set(WIRELESS_SWITCH, switchEnable); //m_switchGsettings->set(WIRELESS_SWITCH, switchEnable);
} }
} }
@ -236,8 +236,8 @@ void WlanPage::initDeviceCombox()
} }
} else { } else {
m_deviceFrame->hide(); m_deviceFrame->hide();
m_currentDevice = ""; //m_currentDevice = "";
setDefaultDevice(WIRELESS, m_currentDevice); //setDefaultDevice(WIRELESS, m_currentDevice);
} }
connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
@ -292,15 +292,15 @@ void WlanPage::clearWirelessNetItemMap(QMap<QString, QListWidgetItem*> &wireless
iter = wirelessNetItem.begin(); iter = wirelessNetItem.begin();
while (iter != wirelessNetItem.end()) { while (iter != wirelessNetItem.end()) {
QListWidgetItem *p_widgetItem = iter.value(); QListWidgetItem *p_listWidgetItem = iter.value();
WlanListItem *p_wlanItem = (WlanListItem *)wirelessListWidget->itemWidget(p_widgetItem); WlanListItem *p_wlanItem = (WlanListItem *)wirelessListWidget->itemWidget(p_listWidgetItem);
wirelessListWidget->removeItemWidget(p_widgetItem); wirelessListWidget->removeItemWidget(p_listWidgetItem);
delete p_wlanItem; delete p_wlanItem;
p_wlanItem = nullptr; p_wlanItem = nullptr;
delete p_widgetItem; delete p_listWidgetItem;
p_widgetItem = nullptr; p_listWidgetItem = nullptr;
iter = wirelessNetItem.erase(iter); iter = wirelessNetItem.erase(iter);
} }
@ -358,8 +358,8 @@ void WlanPage::constructActivateConnectionArea()
bool ret = m_wirelessNetResource->getActiveWirelessNetItem(m_currentDevice, wirelessNetItem); bool ret = m_wirelessNetResource->getActiveWirelessNetItem(m_currentDevice, wirelessNetItem);
if (ret == true) { if (ret == true) {
QListWidgetItem *p_listWidgetItem = addNewItem(wirelessNetItem, m_activatedNetListWidget); QListWidgetItem *p_listWidgetItem = addNewItem(wirelessNetItem, m_activatedNetListWidget);
updateWlanItemState(m_activatedNetListWidget, p_listWidgetItem, Activated);
m_activateConnectionItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem); m_activateConnectionItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem);
updateWlanItemState(m_activatedNetListWidget, p_listWidgetItem, Activated);
height += p_listWidgetItem->sizeHint().height(); height += p_listWidgetItem->sizeHint().height();
} }
@ -369,8 +369,7 @@ void WlanPage::constructActivateConnectionArea()
QListWidgetItem *p_listWidgetItem = addEmptyItem(m_activatedNetListWidget); QListWidgetItem *p_listWidgetItem = addEmptyItem(m_activatedNetListWidget);
m_activateConnectionItemMap.insert(EMPTY_SSID, p_listWidgetItem); m_activateConnectionItemMap.insert(EMPTY_SSID, p_listWidgetItem);
WlanListItem *p_wlanItem = (WlanListItem *)m_activatedNetListWidget->itemWidget(p_listWidgetItem); height += p_listWidgetItem->sizeHint().height();
height += p_wlanItem->height();
} }
m_activatedNetListWidget->setFixedHeight(height); m_activatedNetListWidget->setFixedHeight(height);
@ -401,8 +400,8 @@ void WlanPage::constructWirelessNetArea()
} }
QListWidgetItem *p_listWidgetItem = addNewItem(wirelessNetItem, m_inactivatedNetListWidget); QListWidgetItem *p_listWidgetItem = addNewItem(wirelessNetItem, m_inactivatedNetListWidget);
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
m_wirelessNetItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem); m_wirelessNetItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem);
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
if (height == 0) { if (height == 0) {
@ -462,8 +461,8 @@ void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item)
<< interface << "; ssid = " << item.m_NetSsid << Q_FUNC_INFO <<__LINE__; << interface << "; ssid = " << item.m_NetSsid << Q_FUNC_INFO <<__LINE__;
QListWidgetItem *p_listWidgetItem = addNewItem(item, m_inactivatedNetListWidget); QListWidgetItem *p_listWidgetItem = addNewItem(item, m_inactivatedNetListWidget);
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
m_wirelessNetItemMap.insert(item.m_NetSsid, p_listWidgetItem); m_wirelessNetItemMap.insert(item.m_NetSsid, p_listWidgetItem);
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height()
+ p_listWidgetItem->sizeHint().height() + NET_LIST_SPACING); + p_listWidgetItem->sizeHint().height() + NET_LIST_SPACING);
@ -526,6 +525,8 @@ void WlanPage::updateWlanListItem(QString ssid)
void WlanPage::onConnectionAdd(QString deviceName, QString ssid) void WlanPage::onConnectionAdd(QString deviceName, QString ssid)
{ {
qDebug() << LOG_FLAG << "one connection is added, it's ssid " << ssid << "device name"<< deviceName;
if (deviceName == m_currentDevice) { if (deviceName == m_currentDevice) {
updateWlanListItem(ssid); updateWlanListItem(ssid);
} }
@ -534,6 +535,7 @@ void WlanPage::onConnectionAdd(QString deviceName, QString ssid)
} }
void WlanPage::onConnectionRemove(QString deviceName, QString ssid) void WlanPage::onConnectionRemove(QString deviceName, QString ssid)
{ {
qDebug() << LOG_FLAG << "one connection is removed, it's ssid " << ssid << "device name"<< deviceName;
if (deviceName == m_currentDevice) { if (deviceName == m_currentDevice) {
updateWlanListItem(ssid); updateWlanListItem(ssid);
} }
@ -728,7 +730,7 @@ void WlanPage::sendApStateChangeSignal(QString uuid,
emit hotspotDeactivated(deviceName, ssid); emit hotspotDeactivated(deviceName, ssid);
} else if (state == NetworkManager::ActiveConnection::State::Activated) { } else if (state == NetworkManager::ActiveConnection::State::Activated) {
qDebug() << "[WlanPage] hotspot activated"; qDebug() << "[WlanPage] hotspot activated";
emit hotspotActivated(deviceName, ssid); emit hotspotActivated(deviceName, ssid, uuid);
} }
return; return;
@ -772,11 +774,10 @@ void WlanPage::updateActivatedArea(QString uuid, QString ssid, QString devName)
deleteWirelessItemFormMap(m_activateConnectionItemMap, m_activatedNetListWidget, EMPTY_SSID); deleteWirelessItemFormMap(m_activateConnectionItemMap, m_activatedNetListWidget, EMPTY_SSID);
QListWidgetItem *p_listWidgetItem = addNewItem(wirelessNetItem, m_activatedNetListWidget); QListWidgetItem *p_listWidgetItem = addNewItem(wirelessNetItem, m_activatedNetListWidget);
updateWlanItemState(m_activatedNetListWidget, p_listWidgetItem, Activated);
m_activateConnectionItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem); m_activateConnectionItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem);
updateWlanItemState(m_activatedNetListWidget, p_listWidgetItem, Activated);
m_activatedNetListWidget->setFixedHeight(m_activatedNetListWidget->height() m_activatedNetListWidget->setFixedHeight(p_listWidgetItem->sizeHint().height());
+ p_listWidgetItem->sizeHint().height() + NET_LIST_SPACING);
return; return;
} }
@ -794,15 +795,22 @@ void WlanPage::updateWirelessNetArea(QString uuid, QString ssid, QString devName
return; return;
} }
/*
*
*/
QListWidgetItem *p_activelistItem = m_activateConnectionItemMap.value(ssid);
if (nullptr != p_activelistItem) {
updateWlanItemState(m_activatedNetListWidget, p_activelistItem, Deactivated);
}
deleteWirelessItemFormMap(m_activateConnectionItemMap, m_activatedNetListWidget, ssid); deleteWirelessItemFormMap(m_activateConnectionItemMap, m_activatedNetListWidget, ssid);
QListWidgetItem *p_activeListWidgetItem = addEmptyItem(m_activatedNetListWidget); QListWidgetItem *p_activeListWidgetItem = addEmptyItem(m_activatedNetListWidget);
m_activateConnectionItemMap.insert(EMPTY_SSID, p_activeListWidgetItem); m_activateConnectionItemMap.insert(EMPTY_SSID, p_activeListWidgetItem);
m_activatedNetListWidget->setFixedHeight(m_activatedNetListWidget->height() m_activatedNetListWidget->setFixedHeight(p_activeListWidgetItem->sizeHint().height());
+ p_activeListWidgetItem->sizeHint().height() + NET_LIST_SPACING);
QListWidgetItem *p_listWidgetItem = addNewItem(wirelessNetItem, m_inactivatedNetListWidget); QListWidgetItem *p_listWidgetItem = addNewItem(wirelessNetItem, m_inactivatedNetListWidget);
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
m_wirelessNetItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem); m_wirelessNetItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem);
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height()
+ p_listWidgetItem->sizeHint().height() + NET_LIST_SPACING); + p_listWidgetItem->sizeHint().height() + NET_LIST_SPACING);
@ -817,6 +825,7 @@ void WlanPage::onConnectionStateChanged(QString uuid,
NetworkManager::ActiveConnection::Reason reason) NetworkManager::ActiveConnection::Reason reason)
{ {
if (!m_connectResource->isWirelessConnection(uuid)) { if (!m_connectResource->isWirelessConnection(uuid)) {
qDebug()<< LOG_FLAG << "it is not wireless connection" << uuid;
return; return;
} }
@ -824,11 +833,13 @@ void WlanPage::onConnectionStateChanged(QString uuid,
m_wirelessNetResource->getSsidByUuid(uuid, ssid); m_wirelessNetResource->getSsidByUuid(uuid, ssid);
m_wirelessNetResource->getDeviceByUuid(uuid, devName); m_wirelessNetResource->getDeviceByUuid(uuid, devName);
if (ssid.isEmpty() || devName.isEmpty()) { if (ssid.isEmpty() || devName.isEmpty()) {
qDebug()<< LOG_FLAG << "ssid or devicename is empty"
<< "devicename"<< devName <<"ssid"<<ssid;
return; return;
} }
qDebug() << "emit wlanActiveConnectionStateChanged" << devName << ssid << state; qDebug()<< LOG_FLAG << "emit wlanActiveConnectionStateChanged" << devName << ssid << state;
emit wlanActiveConnectionStateChanged(devName, ssid, state); emit wlanActiveConnectionStateChanged(devName, ssid,uuid, state);
sendApStateChangeSignal(uuid, ssid, devName, state); sendApStateChangeSignal(uuid, ssid, devName, state);
wlanShowNotify(state, reason); wlanShowNotify(state, reason);
@ -943,6 +954,8 @@ void WlanPage::showControlCenter()
void WlanPage::onWifiEnabledChanged(bool isWifiOn) void WlanPage::onWifiEnabledChanged(bool isWifiOn)
{ {
//监听外部命令导致wifi状态变化更新界面 //监听外部命令导致wifi状态变化更新界面
qDebug() << "[WlanPage] onWifiEnabledChanged wifi state" << isWifiOn;
//应该先检测是否有无线网卡可用,才改变开关状态 //应该先检测是否有无线网卡可用,才改变开关状态
if (m_devList.isEmpty()) { if (m_devList.isEmpty()) {
qDebug() << "[WLanPage] have no device to use " << Q_FUNC_INFO << __LINE__; qDebug() << "[WLanPage] have no device to use " << Q_FUNC_INFO << __LINE__;
@ -968,7 +981,7 @@ void WlanPage::onRefreshIconTimer()
return; return;
} }
qDebug()<< LOG_FLAG << "Will update Wlan list by strength." << Q_FUNC_INFO << __LINE__; //qDebug()<< LOG_FLAG << "Will update Wlan list by strength." << Q_FUNC_INFO << __LINE__;
QList<KyWirelessNetItem> wlanList; QList<KyWirelessNetItem> wlanList;
if (!m_wirelessNetResource->getDeviceWifiNetwork(m_currentDevice, wlanList)) { if (!m_wirelessNetResource->getDeviceWifiNetwork(m_currentDevice, wlanList)) {
@ -998,6 +1011,10 @@ void WlanPage::onRefreshIconTimer()
QListWidgetItem *p_sortListWidgetItem = m_wirelessNetItemMap.value(sortSsid); QListWidgetItem *p_sortListWidgetItem = m_wirelessNetItemMap.value(sortSsid);
if (p_sortListWidgetItem) { if (p_sortListWidgetItem) {
WlanListItem *p_wlanItem = (WlanListItem *)m_inactivatedNetListWidget->itemWidget(p_listWidgetItem);
if (Deactivated != p_wlanItem->getConnectionState()) {
continue;
}
qDebug()<< LOG_FLAG << "sort wlan update position." << sortSsid << Q_FUNC_INFO << __LINE__; qDebug()<< LOG_FLAG << "sort wlan update position." << sortSsid << Q_FUNC_INFO << __LINE__;
int takeRow = m_inactivatedNetListWidget->row(p_sortListWidgetItem); int takeRow = m_inactivatedNetListWidget->row(p_sortListWidgetItem);
m_inactivatedNetListWidget->takeItem(takeRow); m_inactivatedNetListWidget->takeItem(takeRow);
@ -1014,8 +1031,8 @@ void WlanPage::onRefreshIconTimer()
qDebug()<< LOG_FLAG << "sort wlan add new item." << Q_FUNC_INFO << __LINE__; qDebug()<< LOG_FLAG << "sort wlan add new item." << Q_FUNC_INFO << __LINE__;
QListWidgetItem *p_newListWidgetItem = insertNewItem(sortItem, m_inactivatedNetListWidget, sortRow); QListWidgetItem *p_newListWidgetItem = insertNewItem(sortItem, m_inactivatedNetListWidget, sortRow);
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
m_wirelessNetItemMap.insert(sortItem.m_NetSsid, p_newListWidgetItem); m_wirelessNetItemMap.insert(sortItem.m_NetSsid, p_newListWidgetItem);
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
int height = m_inactivatedNetListWidget->height() + int height = m_inactivatedNetListWidget->height() +
p_newListWidgetItem->sizeHint().height() + NET_LIST_SPACING; p_newListWidgetItem->sizeHint().height() + NET_LIST_SPACING;
@ -1047,12 +1064,12 @@ void WlanPage::getWirelessList(QMap<QString, QVector<QStringList> > &map)
QString activeSsid ; QString activeSsid ;
//先是已连接 //先是已连接
if (actMap.contains(iter.key())) { if (actMap.contains(iter.key())) {
qDebug() << "find " <<iter.key();
KyWirelessNetItem data; KyWirelessNetItem data;
if (m_wirelessNetResource->getWifiNetwork(iter.key(), actMap[iter.key()].at(0), data)) { if (m_wirelessNetResource->getWifiNetwork(iter.key(), actMap[iter.key()].at(0), data)) {
vector.append(QStringList()<<data.m_NetSsid<<QString::number(data.m_signalStrength)<<data.m_secuType); vector.append(QStringList()<<data.m_NetSsid<<QString::number(data.m_signalStrength)<<data.m_secuType);
activeSsid = data.m_NetSsid; activeSsid = data.m_NetSsid;
} }
} else { } else {
vector.append(QStringList("--")); vector.append(QStringList("--"));
} }
@ -1072,7 +1089,7 @@ void WlanPage::getWirelessList(QMap<QString, QVector<QStringList> > &map)
} }
//开启热点 //开启热点
void WlanPage::activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice) void WlanPage::activeWirelessAp(const QString apName, const QString apPassword, const QString wirelessBand, const QString apDevice)
{ {
QString uuid(""); QString uuid("");
QList<KyApConnectItem *> apConnectItemList; QList<KyApConnectItem *> apConnectItemList;
@ -1081,30 +1098,14 @@ void WlanPage::activeWirelessAp(const QString apName, const QString apPassword,
uuid = apConnectItemList.at(0)->m_connectUuid; uuid = apConnectItemList.at(0)->m_connectUuid;
} }
m_wirelessConnectOpreation->activeWirelessAp(uuid, apName, apPassword, apDevice); m_wirelessConnectOpreation->activeWirelessAp(uuid, apName, apPassword, apDevice, wirelessBand);
} }
//断开热点 //断开热点
void WlanPage::deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice) void WlanPage::deactiveWirelessAp(const QString apName, const QString uuid)
{ {
QString uuid("");
QList<KyApConnectItem *> apConnectItemList;
m_connectResource->getApConnections(apConnectItemList);
if (!apConnectItemList.isEmpty()) {
foreach (auto item, apConnectItemList) {
if (apName == item->m_connectName && apPassword == item->m_password && apDevice == item->m_ifaceName) {
uuid = item->m_connectUuid;
qDebug() << "[WlanPage] deactiveWirelessAp uuid = " << uuid;
break;
}
}
}
if (!uuid.isEmpty()) { if (!uuid.isEmpty()) {
m_wirelessConnectOpreation->deactiveWirelessAp(apName, uuid); m_wirelessConnectOpreation->deactiveWirelessAp(apName, uuid);
} else {
qDebug() << "[WlanPage] deactiveWirelessAp can not find apName " << apName;
emit deactivateFailed("Deactivate hotspot failed.Don't exist " + apName);
} }
} }
@ -1118,6 +1119,22 @@ void WlanPage::getStoredApInfo(QStringList &list)
list << apConnectItemList.at(0)->m_password; list << apConnectItemList.at(0)->m_password;
list << apConnectItemList.at(0)->m_ifaceName; list << apConnectItemList.at(0)->m_ifaceName;
list << (apConnectItemList.at(0)->m_isActivated? "true":"false"); list << (apConnectItemList.at(0)->m_isActivated? "true":"false");
list << apConnectItemList.at(0)->m_connectUuid;
list << apConnectItemList.at(0)->m_band;
}
}
void WlanPage::getApInfoBySsid(QString devName, QString ssid, QStringList &list)
{
list.clear();
QList<KyApConnectItem *> apConnectItemList;
m_connectResource->getApConnections(apConnectItemList);
for (int i = 0; i < apConnectItemList.size(); i++) {
if (apConnectItemList.at(i)->m_connectName == ssid
&& apConnectItemList.at(i)->m_ifaceName == devName) {
list << apConnectItemList.at(i)->m_password;
list << apConnectItemList.at(i)->m_band;
}
} }
return; return;
@ -1203,3 +1220,25 @@ bool WlanPage::wlanIsConnected()
return true; return true;
} }
void WlanPage::setWirelessSwitchEnable(bool enable)
{
qDebug() << "dbus setWirelessSwitchEnable = " << enable << __LINE__;
//应该先检测是否有无线网卡可用,才改变开关状态
if (m_devList.isEmpty()) {
qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__;
//检测不到无线网卡不再触发click信号
m_netSwitch->setSwitchStatus(false);
//m_netSwitch->setEnabled(false);
}else{
m_wirelessConnectOpreation->setWirelessEnabled(enable);
}
}
void WlanPage::getWirelessDeviceCap(QMap<QString, int> &map)
{
for (int i = 0; i < m_devList.size(); ++i) {
QString devName = m_devList.at(i);
map.insert(devName, m_netDeviceResource->getWirelessDeviceCapability(devName));
}
}

View File

@ -30,11 +30,12 @@ public:
//for dbus //for dbus
void getWirelessList(QMap<QString, QVector<QStringList> > &map); void getWirelessList(QMap<QString, QVector<QStringList> > &map);
//开启热点 //开启热点
void activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice); void activeWirelessAp(const QString apName, const QString apPassword, const QString wirelessBand, const QString apDevice);
//断开热点 //断开热点
void deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice); void deactiveWirelessAp(const QString apName, const QString uuid);
//获取热点 //获取热点
void getStoredApInfo(QStringList &list); void getStoredApInfo(QStringList &list);
void activateWirelessConnection(const QString& devName, const QString& ssid); void activateWirelessConnection(const QString& devName, const QString& ssid);
void deactivateWirelessConnection(const QString& devName, const QString& ssid); void deactivateWirelessConnection(const QString& devName, const QString& ssid);
@ -42,13 +43,18 @@ public:
bool wlanIsConnected(); bool wlanIsConnected();
void getApInfoBySsid(QString devName, QString ssid, QStringList &list);
//无线总开关
void setWirelessSwitchEnable(bool enable);
void getWirelessDeviceCap(QMap<QString, int> &map);
signals: signals:
void oneItemExpanded(const QString &ssid); void oneItemExpanded(const QString &ssid);
void wlanAdd(QString devName, QStringList info); void wlanAdd(QString devName, QStringList info);
void wlanRemove(QString devName,QString ssid); void wlanRemove(QString devName,QString ssid);
void wlanActiveConnectionStateChanged(QString interface, QString ssid, int status); void wlanActiveConnectionStateChanged(QString interface, QString ssid, QString uuid, int status);
void hotspotDeactivated(QString devName, QString ssid); void hotspotDeactivated(QString devName, QString ssid);
void hotspotActivated(QString devName, QString ssid); void hotspotActivated(QString devName, QString ssid, QString uuid);
void signalStrengthChange(QString devName, QString ssid, int strength); void signalStrengthChange(QString devName, QString ssid, int strength);
void secuTypeChange(QString devName, QString ssid, QString secuType); void secuTypeChange(QString devName, QString ssid, QString secuType);
void hiddenWlanClicked(); void hiddenWlanClicked();
@ -57,6 +63,7 @@ signals:
public slots: public slots:
void onMainWindowVisibleChanged(const bool &visible); void onMainWindowVisibleChanged(const bool &visible);
void onSecurityTypeChange(QString devName, QString ssid, QString secuType); void onSecurityTypeChange(QString devName, QString ssid, QString secuType);
void requestScan();
private slots: private slots:
void onWlanAdded(QString interface, KyWirelessNetItem &item); void onWlanAdded(QString interface, KyWirelessNetItem &item);
@ -78,7 +85,6 @@ private slots:
void onWlanSwithGsettingsChanged(const QString &key); void onWlanSwithGsettingsChanged(const QString &key);
void onDeviceComboxIndexChanged(int currentIndex); void onDeviceComboxIndexChanged(int currentIndex);
void requestScan();
void onHiddenWlanClicked(); void onHiddenWlanClicked();
void showControlCenter(); void showControlCenter();
void onWifiEnabledChanged(bool isWifiOn); void onWifiEnabledChanged(bool isWifiOn);

View File

@ -85,6 +85,7 @@ int main(int argc, char *argv[])
QtSingleApplication a(id, argc, argv); QtSingleApplication a(id, argc, argv);
qInstallMessageHandler(messageOutput); qInstallMessageHandler(messageOutput);
if (a.isRunning()) { if (a.isRunning()) {
qInfo() << "Kylin-Network-Manager Is Already Launched, just show";
auto connection = QDBusConnection::sessionBus(); auto connection = QDBusConnection::sessionBus();
QDBusInterface iface("com.kylin.network", QDBusInterface iface("com.kylin.network",
"/com/kylin/network", "/com/kylin/network",
@ -94,22 +95,19 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
qDebug()<<"Kylin Network Manager Is Already Launched";
QApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);
// Internationalization // Internationalization
QString locale = QLocale::system().name(); QString locale = QLocale::system().name();
QTranslator trans_global; QTranslator trans_global;
if (locale == "zh_CN") { qDebug() << "QLocale " << QLocale();
trans_global.load(":/translations/kylin-nm_zh_CN.qm"); if (trans_global.load(QLocale(), "kylin-nm", "_", ":/translations/"))
{
a.installTranslator(&trans_global); a.installTranslator(&trans_global);
qDebug()<<"Translations load success";
} else {
qWarning() << "Translations load fail";
} }
if (locale == "tr_TR") {
trans_global.load(":/translations/kylin-nm_tr.qm");
a.installTranslator(&trans_global);
}
qDebug()<<"Translations Are Already Loaded";
MainWindow w; MainWindow w;
w.setProperty("useStyleWindowManager", false); //禁用拖动 w.setProperty("useStyleWindowManager", false); //禁用拖动

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff