Commit 743fec5a authored by Jan Grulich's avatar Jan Grulich

Add option to disable unlocking modem on detection

BUG:380150
parent 4b19af74
/*
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"
}
}
<?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>
......@@ -50,7 +50,6 @@ Item {
}
Component.onCompleted: {
plasmoid.removeAction("configure");
if (kcmAuthorized) {
plasmoid.setAction("openKCM", i18n("&Configure Network Connections..."), "preferences-system-network");
}
......@@ -79,4 +78,8 @@ Item {
handler.requestScan()
}
}
PlasmaNM.Configuration {
unlockModemOnDetection: plasmoid.configuration.unlockModemOnDetection
}
}
......@@ -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());
}
}
}
}
......
......@@ -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
......
/*
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);
}
}
/*
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
......@@ -28,6 +28,7 @@
#include "networkstatus.h"
#include "appletproxymodel.h"
#include "configuration.h"
#include "creatableconnectionsmodel.h"
#include "editorproxymodel.h"
#include "kcmidentitymodel.h"
......@@ -42,6 +43,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
......
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