接口调用判断

This commit is contained in:
zhangyuanyuan1 2022-07-22 16:32:24 +08:00
parent 1dffddcd3b
commit c45ddd0ecb
1 changed files with 25 additions and 16 deletions

View File

@ -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<int> 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<int> 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<int> 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<int> 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<int> reply = m_dbusInterface->call("break_networkConnect", uuid, cardName, ssid);
if (reply.isValid()) {
qDebug() << "break_networkConnect" << ssid << uuid << cardName << ",result" << reply.value();