fix:it will report that the lan is closed, when close wifi-p2p.

bug link:https://172.17.50.104/biz/bug-view-91118.html
This commit is contained in:
renpeijia 2021-12-10 10:32:17 +08:00
parent 557a8acc8a
commit a0d4d98df6
4 changed files with 72 additions and 11 deletions

View File

@ -14,6 +14,7 @@ HEADERS += \
$$PWD/kylinconnectsetting.h \ $$PWD/kylinconnectsetting.h \
$$PWD/kylinnetworkdeviceresource.h \ $$PWD/kylinnetworkdeviceresource.h \
$$PWD/kylinnetworkresourcemanager.h \ $$PWD/kylinnetworkresourcemanager.h \
$$PWD/kylinutil.h \
$$PWD/kylinvpnconnectitem.h \ $$PWD/kylinvpnconnectitem.h \
$$PWD/kylinvpnrequest.h \ $$PWD/kylinvpnrequest.h \
$$PWD/kylinwiredconnectoperation.h \ $$PWD/kylinwiredconnectoperation.h \
@ -35,6 +36,7 @@ SOURCES += \
$$PWD/kylinconnectsetting.cpp \ $$PWD/kylinconnectsetting.cpp \
$$PWD/kylinnetworkdeviceresource.cpp \ $$PWD/kylinnetworkdeviceresource.cpp \
$$PWD/kylinnetworkresourcemanager.cpp \ $$PWD/kylinnetworkresourcemanager.cpp \
$$PWD/kylinutil.cpp \
$$PWD/kylinvpnconnectitem.cpp \ $$PWD/kylinvpnconnectitem.cpp \
$$PWD/kylinvpnrequest.c \ $$PWD/kylinvpnrequest.c \
$$PWD/kylinwiredconnectoperation.cpp \ $$PWD/kylinwiredconnectoperation.cpp \

View File

@ -1,6 +1,7 @@
#include "kylinconnectresource.h" #include "kylinconnectresource.h"
#include "kywirelessconnectoperation.h" #include "kywirelessconnectoperation.h"
#include "kylinutil.h"
#include <NetworkManagerQt/Ipv4Setting> #include <NetworkManagerQt/Ipv4Setting>
#include <NetworkManagerQt/Ipv6Setting> #include <NetworkManagerQt/Ipv6Setting>
@ -702,18 +703,16 @@ bool KyConnectResourse::isWiredConnection(QString uuid)
return false; return false;
} }
if (!connectPtr.isNull()) { /*
NetworkManager::ConnectionSettings::Ptr connectSettingPtr = connectPtr->settings(); * NetworkManager库获取的连接类型线
* 线wifi-p2p的投屏
* networkmanager的dbus接口获取
*/
if (connectSettingPtr.isNull()) { QString connectPath = connectPtr->path();
qWarning()<<"[KyConnectResourse]"<<"get connect setting failed, connect uuid"<<uuid; QString connectionType = getConnectTypeByDbus(connectPath);
return false; if (ETHERNET_TYPE == connectionType) {
} return true;
if (NetworkManager::ConnectionSettings::ConnectionType::Wired ==
connectPtr->settings()->connectionType()) {
return true;
}
} }
return false; return false;

View File

@ -0,0 +1,41 @@
#include "kylinutil.h"
#define LOG_FLAG "kylin-util"
QString getConnectTypeByDbus(QString &connectPath)
{
QString connectType = "";
if (connectPath.isEmpty()) {
qWarning()<< LOG_FLAG << "connect path is empty, so can not get connect type";
return connectType;
}
QDBusInterface dbusInterface("org.freedesktop.NetworkManager",
connectPath,
"org.freedesktop.NetworkManager.Settings.Connection",
QDBusConnection::systemBus());
QDBusMessage result = dbusInterface.call("GetSettings");
const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value<QDBusArgument>();
QMap<QString, QMap<QString, QVariant>> map;
dbusArg1st >> map;
if (map.isEmpty()) {
qWarning() << LOG_FLAG <<"get connection settings failed.";
return connectType;
}
QMap<QString,QVariant> connectMap = map.value(KEY_CONNECTION);
if (connectMap.isEmpty()) {
qWarning() << LOG_FLAG <<"threre is not connection settings";
return connectType;
}
connectType = connectMap.value(KEY_CONNECT_TYPE).toString();
qDebug() << LOG_FLAG << "connection type" << connectType;
return connectType;
}

View File

@ -0,0 +1,19 @@
#ifndef KYLINUTIL_H
#define KYLINUTIL_H
#include <QObject>
#include <QDebug>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusObjectPath>
#include <QDBusReply>
#include <QDBusObjectPath>
#define KEY_CONNECTION "connection"
#define KEY_CONNECT_TYPE "type"
#define ETHERNET_TYPE "802-3-ethernet"
QString getConnectTypeByDbus(QString &connectPath);
#endif // KYLINUTIL_H