补充接口获取无线网络信息 激活断开移动热点
This commit is contained in:
parent
864bcd06a3
commit
b8b6b8660b
|
@ -14,6 +14,7 @@ public:
|
|||
bool m_isApConnection = false;
|
||||
QString m_secuType = "";
|
||||
int m_signalStrength = 0;
|
||||
int m_category = 0;
|
||||
};
|
||||
|
||||
#endif // KYWIRELESSNETITEM_H
|
||||
|
|
|
@ -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<NetworkManager::WirelessDevice *>(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<QVariant> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -104,8 +104,16 @@ public:
|
|||
void getWiredList(QMap<QString,QList<KyWiredItem>> &map);
|
||||
//wireless
|
||||
void getWifiNetworkList(QString devName, QList<KyWirelessNetItem> &list);
|
||||
void getWirelessConnectInfo(QString deviceName, QString &secuType, int &cateGory);
|
||||
|
||||
//移动热点
|
||||
void getApConnections(QList<KyApConnectItem> &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);
|
||||
|
|
|
@ -150,10 +150,40 @@ void KyNetworkManager::getWifiNetworkList(QString devName, QList<KyWirelessNetIt
|
|||
m_wirelessNetResource->getWifiNetworkList(devName, list);
|
||||
}
|
||||
|
||||
void KyNetworkManager::getWirelessConnectInfo(QString deviceName, QString &secuType, int &cateGory)
|
||||
{
|
||||
m_wirelessNetResource->getWirelessConnectInfo(deviceName, secuType, cateGory);
|
||||
}
|
||||
|
||||
void KyNetworkManager::getApConnections(QList<KyApConnectItem> &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)
|
||||
|
|
Loading…
Reference in New Issue