diff --git a/libnm-kylin/libnm-base-kylin/depend/kywirelessnetitem.h b/libnm-kylin/libnm-base-kylin/depend/kywirelessnetitem.h index cf4191b2..8e57202c 100644 --- a/libnm-kylin/libnm-base-kylin/depend/kywirelessnetitem.h +++ b/libnm-kylin/libnm-base-kylin/depend/kywirelessnetitem.h @@ -14,6 +14,7 @@ public: bool m_isApConnection = false; QString m_secuType = ""; int m_signalStrength = 0; + int m_category = 0; }; #endif // KYWIRELESSNETITEM_H diff --git a/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.cpp b/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.cpp index 440f1144..37f55df8 100644 --- a/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.cpp +++ b/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.cpp @@ -129,6 +129,9 @@ void KyWirelessNetResource::wirelessNetItemInit(KyWirelessNetItem &wirelessItem, KyWirelessConnectOperation operation; wirelessItem.m_connectSecuType = operation.getConnectSecuType(wirelessItem.m_connectUuid); wirelessItem.m_isApConnection = operation.isApConnection(wirelessItem.m_connectUuid); + + //category + wirelessItem.m_category = getCategory(accessPointPtr->uni()); } void KyWirelessNetResource::getUuidBySsid(const QString &ssid, QString &deviceName, QString &uuid, QString &dbusPath) @@ -451,6 +454,40 @@ void KyWirelessNetResource::getWirelessConnectDetail(QString interface, QString } } +bool KyWirelessNetResource::isApConnection(QString uuid) +{ + bool state = false; + KyWirelessConnectOperation operation; + state = operation.isApConnection(uuid); + return state; +} + +void KyWirelessNetResource::getWirelessConnectInfo(QString devName, QString &secuType, int &cateGory) +{ + NetworkManager::Device::Ptr connectDevice = + m_networkResourceInstance->findDeviceByName(devName); + if (nullptr == connectDevice || !connectDevice->isValid()) { + qWarning()<< LOG_FLAG <<"getWirelessConnectInfo failed, the device" << devName << "is not existed"; + return; + } + if (connectDevice->type() == NetworkManager::Device::Wifi) { + NetworkManager::WirelessDevice *wirelessDevicePtr = + qobject_cast(connectDevice.data()); + NetworkManager::AccessPoint::Ptr apPtr = wirelessDevicePtr->activeAccessPoint(); + if (apPtr.isNull()) { + return; + } + NetworkManager::AccessPoint::Capabilities cap = apPtr->capabilities(); + NetworkManager::AccessPoint::WpaFlags wpaFlag = apPtr->wpaFlags(); + NetworkManager::AccessPoint::WpaFlags rsnFlag = apPtr->rsnFlags(); + secuType = enumToQstring(cap, wpaFlag, rsnFlag); + + QString uni = ""; + uni = apPtr->uni(); + cateGory = getCategory(uni); + } +} + void KyWirelessNetResource::onConnectionAdd(QString connectUuid, QString connectName, QString connectPath) { Q_UNUSED(connectName); @@ -582,3 +619,22 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::WirelessNetwork::P return dev->interfaceName(); } + +int KyWirelessNetResource::getCategory(QString uni) +{ + + QDBusInterface interface( "org.freedesktop.NetworkManager", uni, "org.freedesktop.DBus.Properties", QDBusConnection::systemBus() ); + if (!interface.isValid()) { + qDebug() << Q_FUNC_INFO << "dbus is invalid"; + return -1; + } + + QDBusReply reply = interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "Category"); + if (!reply.isValid()) { + //qDebug()<<"can not get the attribute 'Category' in func getCategory()"; + return 0; + } else { + return reply.value().toInt(); + } + +} diff --git a/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.h b/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.h index 8329b6d3..087f04e9 100644 --- a/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.h +++ b/libnm-kylin/libnm-base-kylin/depend/kywirelessnetresource.h @@ -36,12 +36,16 @@ public: void getWirelessConnectDetail(QString interface, QString ssid, QString uuid, KyDetailInfo &connectSetting); + bool isApConnection(QString uuid); + + void getWirelessConnectInfo(QString devName, QString &secuType, int &cateGory); + private: void kyWirelessNetItemListInit(); void wirelessNetItemInit(KyWirelessNetItem &wirelessItem, NetworkManager::WirelessNetwork::Ptr wirelessNetPtr); void getUuidBySsid(const QString &ssid, QString &deviceName, QString &uuid, QString &dbusPath); - + int getCategory(QString uni); public Q_SLOTS: void onWifiNetworkAdded(QString devIfaceName, QString ssid); void onWifiNetworkRemoved(QString devIfaceName, QString ssid); diff --git a/libnm-kylin/libnm-base-kylin/kylinnetworkmanager.h b/libnm-kylin/libnm-base-kylin/kylinnetworkmanager.h index 1542e49e..bcf6d10a 100644 --- a/libnm-kylin/libnm-base-kylin/kylinnetworkmanager.h +++ b/libnm-kylin/libnm-base-kylin/kylinnetworkmanager.h @@ -104,8 +104,16 @@ public: void getWiredList(QMap> &map); //wireless void getWifiNetworkList(QString devName, QList &list); + void getWirelessConnectInfo(QString deviceName, QString &secuType, int &cateGory); + //移动热点 void getApConnections(QList &apConnectItemList); + bool isApConnection(QString uuid); + int getWirelessDeviceCapability(const QString deviceName); + 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); //详情页-->ipv4 + ipv6 + autoconnect void getConnectIpInfo(QString uuid, KyConnectSetting &connectSetting); diff --git a/libnm-kylin/libnm-base-kylin/kylinnetworkmanger.cpp b/libnm-kylin/libnm-base-kylin/kylinnetworkmanger.cpp index f9724ae0..83342849 100644 --- a/libnm-kylin/libnm-base-kylin/kylinnetworkmanger.cpp +++ b/libnm-kylin/libnm-base-kylin/kylinnetworkmanger.cpp @@ -150,10 +150,40 @@ void KyNetworkManager::getWifiNetworkList(QString devName, QListgetWifiNetworkList(devName, list); } +void KyNetworkManager::getWirelessConnectInfo(QString deviceName, QString &secuType, int &cateGory) +{ + m_wirelessNetResource->getWirelessConnectInfo(deviceName, secuType, cateGory); +} + void KyNetworkManager::getApConnections(QList &apConnectItemList) { m_apNetResource->getApConnections(apConnectItemList); } + +bool KyNetworkManager::isApConnection(QString uuid) +{ + return m_wirelessNetResource->isApConnection(uuid); +} + +int KyNetworkManager::getWirelessDeviceCapability(const QString deviceName) +{ + return m_deviceResource->getWirelessDeviceCapability(deviceName); +} + +void KyNetworkManager::activeWirelessAp(const QString apUuid, const QString apName, + const QString apPassword, const QString apDevice, + const QString wirelessBand) +{ + KyWirelessConnectOperation operate; + operate.activeWirelessAp(apUuid, apName, apPassword, apDevice, wirelessBand); +} + +void KyNetworkManager::deactiveWirelessAp(const QString apName, const QString apUuid) +{ + KyWirelessConnectOperation operate; + operate.deactiveWirelessAp(apName, apUuid); +} + //详情页 //共有ipv4 ipv6 包括autoconnect void KyNetworkManager::getConnectIpInfo(QString uuid, KyConnectSetting &connectSetting)