Commit 1f9732e3 authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

Add a message and disable the firewall on forced failure

If the firewall is disconnected by another system, when we have
the firewall as active, we can't do anything. ask the user
to restart the firewall.
parent c963f227
......@@ -110,6 +110,11 @@ KJob *FirewallClient::addRule(Rule *rule)
if (!m_currentBackend) {
return nullptr;
}
if (!m_currentBackend->isCurrentlyLoaded()) {
return nullptr;
}
return m_currentBackend->addRule(rule);
}
......@@ -118,6 +123,9 @@ KJob *FirewallClient::removeRule(int index)
if (!m_currentBackend) {
return nullptr;
}
if (!m_currentBackend->isCurrentlyLoaded()) {
return nullptr;
}
return m_currentBackend->removeRule(index);
}
......@@ -126,6 +134,9 @@ KJob *FirewallClient::updateRule(Rule *rule)
if (!m_currentBackend) {
return nullptr;
}
if (!m_currentBackend->isCurrentlyLoaded()) {
return nullptr;
}
return m_currentBackend->updateRule(rule);
}
......@@ -249,6 +260,9 @@ KJob *FirewallClient::setDefaultIncomingPolicy(const QString &defaultIncomingPol
if (!m_currentBackend) {
return nullptr;
}
if (!m_currentBackend->isCurrentlyLoaded()) {
return nullptr;
}
return m_currentBackend->setDefaultIncomingPolicy(defaultIncomingPolicy);
}
......@@ -257,7 +271,9 @@ KJob *FirewallClient::setDefaultOutgoingPolicy(const QString &defaultOutgoingPol
if (!m_currentBackend) {
return nullptr;
}
if (!m_currentBackend->isCurrentlyLoaded()) {
return nullptr;
}
return m_currentBackend->setDefaultOutgoingPolicy(defaultOutgoingPolicy);
}
......
......@@ -74,6 +74,12 @@ KCM.ScrollViewKCM {
onAccepted: {
var job = kcm.client[newRule ? "addRule" : "updateRule"](rule);
if (!job) {
ruleEditMessage.text = i18n("Please restart plasma firewall, the backend disconnected.");
ruleEditMessage.visible = true;
return;
}
busy = true;
kcm.needsSave = true;
job.result.connect(function() {
......@@ -229,6 +235,11 @@ KCM.ScrollViewKCM {
onActivated: {
const job = kcm.client["setDefault" + modelData.key + "Policy"](currentPolicy)
if (!job) {
firewallInlineErrorMessage.text = i18n("Please restart plasma firewall, the backend disconnected.");
firewallInlineErrorMessage.visible = true;
return;
}
policyCombo.activeJob = job;
job.result.connect(function () {
policyCombo.activeJob = null;
......@@ -356,6 +367,12 @@ KCM.ScrollViewKCM {
icon.name: "edit-delete"
onClicked: {
const job = kcm.client.removeRule(styleData.row);
if (!job) {
firewallInlineErrorMessage.text = i18n("Please restart plasma firewall, the backend disconnected.");
firewallInlineErrorMessage.visible = true;
return;
}
ruleActionsRow.activeJob = job;
kcm.needsSave = true;
job.result.connect(function () {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment