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:
parent
557a8acc8a
commit
a0d4d98df6
|
@ -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 \
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
}
|
|
@ -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
|
Loading…
Reference in New Issue