File 0001-Add-option-to-disable-unlocking-modem-on-detection.patch of Package plasma-nm5
From dbdf7004e6f5164566e9ae3319896129c1e5a47e Mon Sep 17 00:00:00 2001
From: Jan Grulich <jgrulich@redhat.com>
Date: Thu, 25 May 2017 14:00:04 +0200
Subject: [PATCH 1/2] Add option to disable unlocking modem on detection
BUG:380150
---
applet/contents/config/config.qml | 33 +++++++++++++++++++++++
applet/contents/config/main.xml | 15 +++++++++++
applet/contents/ui/main.qml | 5 +++-
kded/modemmonitor.cpp | 20 +++++++++++---
libs/declarative/CMakeLists.txt | 1 +
libs/declarative/configuration.cpp | 55 ++++++++++++++++++++++++++++++++++++++
libs/declarative/configuration.h | 41 ++++++++++++++++++++++++++++
libs/declarative/qmlplugins.cpp | 3 +++
8 files changed, 169 insertions(+), 4 deletions(-)
create mode 100644 applet/contents/config/config.qml
create mode 100644 applet/contents/config/main.xml
create mode 100644 libs/declarative/configuration.cpp
create mode 100644 libs/declarative/configuration.h
diff --git a/applet/contents/config/config.qml b/applet/contents/config/config.qml
new file mode 100644
index 00000000..036b5b6c
--- /dev/null
+++ b/applet/contents/config/config.qml
@@ -0,0 +1,33 @@
+/*
+ Copyright 2017 Jan Grulich <jgrulich@redhat.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+import QtQuick 2.0
+
+import org.kde.plasma.configuration 2.0
+
+ConfigModel {
+ id: configModel
+
+ ConfigCategory {
+ name: i18n("General")
+ icon: "plasma"
+ source: "configGeneral.qml"
+ }
+}
diff --git a/applet/contents/config/main.xml b/applet/contents/config/main.xml
new file mode 100644
index 00000000..3746a5d5
--- /dev/null
+++ b/applet/contents/config/main.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ <kcfgfile name=""/>
+
+ <group name="General">
+ <entry name="unlockModemOnDetection" type="Bool">
+ <label>If true request PIN code as soon as modem is detected.</label>
+ <default>true</default>
+ </entry>
+ </group>
+
+</kcfg>
diff --git a/applet/contents/ui/main.qml b/applet/contents/ui/main.qml
index 6c88d6de..6140ac8b 100644
--- a/applet/contents/ui/main.qml
+++ b/applet/contents/ui/main.qml
@@ -47,7 +47,6 @@ Item {
}
Component.onCompleted: {
- plasmoid.removeAction("configure");
plasmoid.setAction("openEditor", i18n("&Configure Network Connections..."), "preferences-system-network");
}
@@ -62,4 +61,8 @@ Item {
PlasmaNM.Handler {
id: handler
}
+
+ PlasmaNM.Configuration {
+ unlockModemOnDetection: plasmoid.configuration.unlockModemOnDetection
+ }
}
diff --git a/kded/modemmonitor.cpp b/kded/modemmonitor.cpp
index 91e884d7..1075f168 100644
--- a/kded/modemmonitor.cpp
+++ b/kded/modemmonitor.cpp
@@ -25,8 +25,15 @@
#include <QDBusPendingReply>
+#include <KConfigGroup>
#include <KLocalizedString>
#include <KMessageBox>
+#include <KSharedConfig>
+
+#include <NetworkManagerQt/Device>
+#include <NetworkManagerQt/Connection>
+#include <NetworkManagerQt/GsmSetting>
+#include <NetworkManagerQt/Manager>
#include <ModemManager/ModemManager.h>
#include <ModemManagerQt/Manager>
@@ -47,9 +54,16 @@ ModemMonitor::ModemMonitor(QObject * parent)
Q_D(ModemMonitor);
d->dialog.clear();
- connect(ModemManager::notifier(), &ModemManager::Notifier::modemAdded, this, &ModemMonitor::unlockModem);
- Q_FOREACH (const ModemManager::ModemDevice::Ptr &iface, ModemManager::modemDevices()) {
- unlockModem(iface->uni());
+ KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String("plasma-nm"));
+ KConfigGroup grp(config, QLatin1String("General"));
+
+ if (grp.isValid()) {
+ if (grp.readEntry(QLatin1String("UnlockModemOnDetection"), true)) {
+ connect(ModemManager::notifier(), &ModemManager::Notifier::modemAdded, this, &ModemMonitor::unlockModem);
+ Q_FOREACH (const ModemManager::ModemDevice::Ptr &iface, ModemManager::modemDevices()) {
+ unlockModem(iface->uni());
+ }
+ }
}
}
diff --git a/libs/declarative/CMakeLists.txt b/libs/declarative/CMakeLists.txt
index 4bd177c7..e66219ed 100644
--- a/libs/declarative/CMakeLists.txt
+++ b/libs/declarative/CMakeLists.txt
@@ -3,6 +3,7 @@ include_directories(${CMAKE_SOURCE_DIR}/libs/models)
set(plasmanm_qml_plugins_SRCS
availabledevices.cpp
connectionicon.cpp
+ configuration.cpp
enabledconnections.cpp
enums.cpp
networkstatus.cpp
diff --git a/libs/declarative/configuration.cpp b/libs/declarative/configuration.cpp
new file mode 100644
index 00000000..1ec903a5
--- /dev/null
+++ b/libs/declarative/configuration.cpp
@@ -0,0 +1,55 @@
+/*
+ Copyright 2017 Jan Grulich <jgrulich@redhat.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "configuration.h"
+
+#include <KConfigGroup>
+#include <KSharedConfig>
+
+Configuration::Configuration(QObject *parent)
+ : QObject(parent)
+{
+}
+
+Configuration::~Configuration()
+{
+}
+
+bool Configuration::unlockModemOnDetection() const
+{
+ KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String("plasma-nm"));
+ KConfigGroup grp(config, QLatin1String("General"));
+
+ if (grp.isValid()) {
+ return grp.readEntry(QLatin1String("UnlockModemOnDetection"), true);
+ }
+
+ return true;
+}
+
+void Configuration::setUnlockModemOnDetection(bool unlock)
+{
+ KSharedConfigPtr config = KSharedConfig::openConfig(QLatin1String("plasma-nm"));
+ KConfigGroup grp(config, QLatin1String("General"));
+
+ if (grp.isValid()) {
+ grp.writeEntry(QLatin1String("UnlockModemOnDetection"), unlock);
+ }
+}
diff --git a/libs/declarative/configuration.h b/libs/declarative/configuration.h
new file mode 100644
index 00000000..4aaa981a
--- /dev/null
+++ b/libs/declarative/configuration.h
@@ -0,0 +1,41 @@
+/*
+ Copyright 2017 Jan Grulich <jgrulich@redhat.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef PLASMA_NM_CONFIGURATION_H
+#define PLASMA_NM_CONFIGURATION_H
+
+#include <QObject>
+
+#include <NetworkManagerQt/Manager>
+
+class Configuration : public QObject
+{
+ Q_PROPERTY(bool unlockModemOnDetection READ unlockModemOnDetection WRITE setUnlockModemOnDetection)
+ Q_OBJECT
+public:
+ explicit Configuration(QObject *parent = 0);
+ virtual ~Configuration();
+
+ bool unlockModemOnDetection() const;
+ void setUnlockModemOnDetection(bool unlock);
+};
+
+#endif // PLAMA_NM_CONFIGURATION_H
+
diff --git a/libs/declarative/qmlplugins.cpp b/libs/declarative/qmlplugins.cpp
index cec2c773..1993b039 100644
--- a/libs/declarative/qmlplugins.cpp
+++ b/libs/declarative/qmlplugins.cpp
@@ -28,6 +28,7 @@
#include "networkstatus.h"
#include "appletproxymodel.h"
+#include "configuration.h"
#include "networkmodel.h"
#include "handler.h"
@@ -39,6 +40,8 @@ void QmlPlugins::registerTypes(const char* uri)
qmlRegisterType<AvailableDevices>(uri, 0, 2, "AvailableDevices");
// @uri org.kde.plasma.networkmanagement.ConnectionIcon
qmlRegisterType<ConnectionIcon>(uri, 0, 2, "ConnectionIcon");
+ // @uri org.kde.plasma.networkmanagement.Configuration
+ qmlRegisterType<Configuration>(uri, 0, 2, "Configuration");
// @uri org.kde.plasma.networkmanagement.EnabledConnections
qmlRegisterType<EnabledConnections>(uri, 0, 2, "EnabledConnections");
// @uri org.kde.plasma.networkmanagement.Enums
--
2.13.2