From c45ddd0ecb076e3c8a14e9f88991bcf7c7526931 Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Fri, 22 Jul 2022 16:32:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../networkmode/networkmodeconfig.cpp | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/frontend/networkmode/networkmodeconfig.cpp b/src/frontend/networkmode/networkmodeconfig.cpp index 94e46ed7..fa19cc6c 100644 --- a/src/frontend/networkmode/networkmodeconfig.cpp +++ b/src/frontend/networkmode/networkmodeconfig.cpp @@ -37,9 +37,6 @@ NetworkModeConfig::NetworkModeConfig(QObject *parent) : QObject(parent) "/firewall", "com.ksc.defender.firewall", QDBusConnection::systemBus()); - if(!m_dbusInterface->isValid()) { - qWarning ()<< "init com.ksc.defender dbus error"; - } } int NetworkModeConfig::getNetworkModeConfig(QString uuid) @@ -49,27 +46,39 @@ int NetworkModeConfig::getNetworkModeConfig(QString uuid) return -1; } - QDBusReply reply = m_dbusInterface->call("get_networkModeConfig", uuid); - if (reply.isValid()) { - return reply.value(); - } else { - qWarning() << "call get_networkModeConfig failed" << reply.error().message(); - } - return -1; + if(!m_dbusInterface->isValid()) { + qWarning ()<< "init com.ksc.defender dbus error"; + } + + QDBusReply reply = m_dbusInterface->call("get_networkModeConfig", uuid); + if (reply.isValid()) { + return reply.value(); + } else { + qWarning() << "call get_networkModeConfig failed" << reply.error().message(); + } + return -1; } void NetworkModeConfig::setNetworkModeConfig(QString uuid, QString cardName, QString ssid, int mode) { - QDBusReply reply = m_dbusInterface->call("set_networkModeConfig", uuid, cardName, ssid, mode); - if (reply.isValid()) { - qDebug() << "set_networkModeConfig" << ssid << uuid << cardName << mode << ",result" << reply.value(); - } else { - qWarning() << "call set_networkModeConfig" << reply.error().message(); - } + if(!m_dbusInterface->isValid()) { + qWarning ()<< "init com.ksc.defender dbus error"; + } + + QDBusReply reply = m_dbusInterface->call("set_networkModeConfig", uuid, cardName, ssid, mode); + if (reply.isValid()) { + qDebug() << "set_networkModeConfig" << ssid << uuid << cardName << mode << ",result" << reply.value(); + } else { + qWarning() << "call set_networkModeConfig" << reply.error().message(); + } } int NetworkModeConfig::breakNetworkConnect(QString uuid, QString cardName, QString ssid) { + if(!m_dbusInterface->isValid()) { + qWarning ()<< "init com.ksc.defender dbus error"; + } + QDBusReply reply = m_dbusInterface->call("break_networkConnect", uuid, cardName, ssid); if (reply.isValid()) { qDebug() << "break_networkConnect" << ssid << uuid << cardName << ",result" << reply.value();