Merge branch '0821' into 'yhkylin/v101'
fix(kylin-nm):ingore different display command && fix(UI):空白wifi异常问题(#182913) See merge request kylinos-src/kylin-nm!249
This commit is contained in:
commit
67286b44cc
|
@ -59,15 +59,31 @@ void KyWirelessNetItem::init(NetworkManager::WirelessNetwork::Ptr net)
|
||||||
// m_NetSsid = net->ssid();
|
// m_NetSsid = net->ssid();
|
||||||
|
|
||||||
NetworkManager::AccessPoint::Ptr accessPointPtr = net->referenceAccessPoint();
|
NetworkManager::AccessPoint::Ptr accessPointPtr = net->referenceAccessPoint();
|
||||||
|
if (accessPointPtr->ssid().isEmpty()) {
|
||||||
|
qDebug() << accessPointPtr->uni() << "ssid isEmpty";
|
||||||
|
NetworkManager::AccessPoint::List list = net->accessPoints();
|
||||||
|
if (list.size() > 1) {
|
||||||
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
|
if (!list.at(i)->ssid().isEmpty()) {
|
||||||
|
qDebug() << "use" << accessPointPtr->uni();
|
||||||
|
accessPointPtr = list.at(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (accessPointPtr->ssid().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
QByteArray rawSsid = accessPointPtr->rawSsid();
|
QByteArray rawSsid = accessPointPtr->rawSsid();
|
||||||
m_NetSsid = getSsidFromByteArray(rawSsid);
|
m_NetSsid = getSsidFromByteArray(rawSsid);
|
||||||
|
|
||||||
m_signalStrength = net->signalStrength();
|
m_signalStrength = accessPointPtr->signalStrength();
|
||||||
m_frequency = net->referenceAccessPoint()->frequency();
|
m_frequency = accessPointPtr->frequency();
|
||||||
m_channel = NetworkManager::findChannel(m_frequency);
|
m_channel = NetworkManager::findChannel(m_frequency);
|
||||||
NetworkManager::AccessPoint::Capabilities cap = net->referenceAccessPoint()->capabilities();
|
NetworkManager::AccessPoint::Capabilities cap = accessPointPtr->capabilities();
|
||||||
NetworkManager::AccessPoint::WpaFlags wpaFlag = net->referenceAccessPoint()->wpaFlags();
|
NetworkManager::AccessPoint::WpaFlags wpaFlag = accessPointPtr->wpaFlags();
|
||||||
NetworkManager::AccessPoint::WpaFlags rsnFlag = net->referenceAccessPoint()->rsnFlags();
|
NetworkManager::AccessPoint::WpaFlags rsnFlag = accessPointPtr->rsnFlags();
|
||||||
m_secuType = enumToQstring(cap, wpaFlag, rsnFlag);
|
m_secuType = enumToQstring(cap, wpaFlag, rsnFlag);
|
||||||
// if (m_secuType.indexOf(ENTERPRICE_TYPE) >= 0) {
|
// if (m_secuType.indexOf(ENTERPRICE_TYPE) >= 0) {
|
||||||
// m_kySecuType = WPA_AND_WPA2_ENTERPRISE;
|
// m_kySecuType = WPA_AND_WPA2_ENTERPRISE;
|
||||||
|
@ -77,9 +93,9 @@ void KyWirelessNetItem::init(NetworkManager::WirelessNetwork::Ptr net)
|
||||||
// m_kySecuType = WPA_AND_WPA2_PERSONAL;
|
// m_kySecuType = WPA_AND_WPA2_PERSONAL;
|
||||||
// }
|
// }
|
||||||
setKySecuType(m_secuType);
|
setKySecuType(m_secuType);
|
||||||
m_bssid = net->referenceAccessPoint()->hardwareAddress();
|
m_bssid = accessPointPtr->hardwareAddress();
|
||||||
m_device = net->device();
|
m_device = net->device();
|
||||||
m_uni = net->referenceAccessPoint()->uni();
|
m_uni = accessPointPtr->uni();
|
||||||
|
|
||||||
NetworkManager::Device::Ptr devicePtr = nullptr;
|
NetworkManager::Device::Ptr devicePtr = nullptr;
|
||||||
devicePtr = m_networkResourceInstance->findDeviceInterface(m_device);
|
devicePtr = m_networkResourceInstance->findDeviceInterface(m_device);
|
||||||
|
|
|
@ -358,6 +358,9 @@ void KyWirelessNetResource::kyWirelessNetItemListInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
KyWirelessNetItem item(net);
|
KyWirelessNetItem item(net);
|
||||||
|
if (item.m_NetSsid.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!m_WifiNetworkList.contains(devIface)){
|
if (!m_WifiNetworkList.contains(devIface)){
|
||||||
QList<KyWirelessNetItem> list;
|
QList<KyWirelessNetItem> list;
|
||||||
list.append(item);
|
list.append(item);
|
||||||
|
|
42
src/main.cpp
42
src/main.cpp
|
@ -25,6 +25,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <KWindowSystem>
|
||||||
#include <ukui-log4qt.h>
|
#include <ukui-log4qt.h>
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
#include "xatom-helper.h"
|
#include "xatom-helper.h"
|
||||||
|
@ -78,6 +79,27 @@ void messageOutput(QtMsgType type, const QMessageLogContext &context, const QStr
|
||||||
fclose(log_file);
|
fclose(log_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString displayFromPid(uint pid)
|
||||||
|
{
|
||||||
|
QFile environFile(QStringLiteral("/proc/%1/environ").arg(QString::number(pid)));
|
||||||
|
if (environFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
const QByteArray DISPLAY = KWindowSystem::isPlatformWayland() ? QByteArrayLiteral("WAYLAND_DISPLAY") : QByteArrayLiteral("DISPLAY");
|
||||||
|
const auto lines = environFile.readAll().split('\0');
|
||||||
|
for (const QByteArray &line : lines) {
|
||||||
|
const int equalsIdx = line.indexOf('=');
|
||||||
|
if (equalsIdx <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const QByteArray key = line.left(equalsIdx);
|
||||||
|
if (key == DISPLAY) {
|
||||||
|
const QByteArray value = line.mid(equalsIdx + 1);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
initUkuiLog4qt("kylin-nm");
|
initUkuiLog4qt("kylin-nm");
|
||||||
|
@ -104,17 +126,25 @@ int main(int argc, char *argv[])
|
||||||
parser.process(a);
|
parser.process(a);
|
||||||
|
|
||||||
QDBusInterface interface("com.kylin.network",
|
QDBusInterface interface("com.kylin.network",
|
||||||
"/com/kylin/network",
|
"/com/kylin/network",
|
||||||
"com.kylin.network",
|
"com.kylin.network",
|
||||||
QDBusConnection::sessionBus());
|
QDBusConnection::sessionBus());
|
||||||
if(interface.isValid()) {
|
if(interface.isValid()) {
|
||||||
if (parser.isSet(swOption))
|
if (parser.isSet(swOption))
|
||||||
{
|
{
|
||||||
interface.call(QStringLiteral("showKylinNM"),1);
|
interface.call(QStringLiteral("showKylinNM"), 1);
|
||||||
|
} else if (parser.isSet(snOption)){
|
||||||
|
interface.call(QStringLiteral("showKylinNM"), 0);
|
||||||
} else {
|
} else {
|
||||||
interface.call(QStringLiteral("showKylinNM"),0);
|
const QString serviceName = "com.kylin.network";
|
||||||
|
QDBusConnectionInterface *interface1 = QDBusConnection::sessionBus().interface();
|
||||||
|
QDBusReply<uint> pid = interface1->servicePid(serviceName);
|
||||||
|
qDebug() << "current display " << getenv("DISPLAY") << QApplication::applicationPid()
|
||||||
|
<< "exist kylin-nm display" << displayFromPid(pid.value());
|
||||||
|
if (getenv("DISPLAY") != displayFromPid(pid.value())) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QThread thread;
|
QThread thread;
|
||||||
|
|
Loading…
Reference in New Issue