Commit 4c5c1003 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos Committed by Bhushan Shah

Add cell network module

New kcm added to manage the cellular network. SIM, Modem, Registration and
Context information pages have been included in the module, displaying
information retrieved from ofono.
parent 258dd773
Pipeline #23947 failed with stage
in 10 minutes and 2 seconds
......@@ -11,3 +11,6 @@ endif()
# Info
add_subdirectory(info)
# Cellular Network
add_subdirectory(cellularnetwork)
set(cellularnetwork_SRCS # Specify source files for the library
cellularnetwork.cpp
)
add_library(kcm_mobile_cellularnetwork MODULE ${cellularnetwork_SRCS})
target_link_libraries(kcm_mobile_cellularnetwork
Qt5::Core
KF5::CoreAddons
KF5::I18n
KF5::QuickAddons
KF5::ConfigCore
)
kcoreaddons_desktop_to_json(kcm_mobile_cellularnetwork "cellularnetwork.desktop") # Convert our desktop file to json
install(TARGETS kcm_mobile_cellularnetwork DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms) # Install the library to the kcm location
install(FILES cellularnetwork.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) # Install the desktop file
kpackage_install_package(package kcm_mobile_cellularnetwork kcms) # Finally install our QML kpackage.
$XGETTEXT $(find . -name \*.cpp -o -name \*.h -o -name \*.qml) -o $podir/kcm_mobile_cellularnetwork.pot
/*
* Copyright 2020 Dimitris Kardarakos <dimkard@posteo.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 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 14 of version 3 of the license.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "cellularnetwork.h"
#include <KAboutData>
#include <KLocalizedString>
#include <KPluginFactory>
K_PLUGIN_CLASS_WITH_JSON(CellularNetwork, "cellularnetwork.json")
CellularNetwork::CellularNetwork(QObject *parent, const QVariantList &args) : KQuickAddons::ConfigModule(parent, args)
{
KAboutData* about = new KAboutData("kcm_mobile_cellularnetwork", i18n("Cellular Networks"),
"1.0", QString(), KAboutLicense::GPL);
about->addAuthor(i18n("Dimitris Kardarakos"), QString(), "dimkard@posteo.net");
setAboutData(about);
qDebug() << "Cellular Networks module loaded";
}
#include "cellularnetwork.moc"
[Desktop Entry]
Name=Cellular Networks
Name[x-test]=xxCellular Networksxx
Comment=Management of cellular networks
Comment[x-test]=xxManagement of cellular networksxx
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kcm_mobile_cellularnetwork
X-KDE-FormFactors=handset,tablet,mediacenter
Categories=Qt;KDE;X-KDE-settings-system;
X-KDE-Keywords=info,cell,mobile
X-KDE-Keywords[x-test]=xxinfoxx,xx cellxx,xx mobilemxx
X-KDE-ParentApp=kcontrol
Exec=plasma-settings -m kcm_mobile_cellularnetwork
/*
* Copyright 2020 Dimitris Kardarakos <dimkard@posteo.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 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 14 of version 3 of the license.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <KQuickAddons/ConfigModule>
#ifndef CELLULALNETWORK_H
#define CELLULALNETWORK_H
class CellularNetwork : public KQuickAddons::ConfigModule
{
Q_OBJECT
public:
CellularNetwork(QObject* parent, const QVariantList& args);
};
#endif
/*
* Copyright 2020 Dimitris Kardarakos <dimkard@posteo.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import org.kde.kcm 1.2 as KCM
import QtQuick.Layouts 1.2
import QtQuick 2.7
import QtQuick.Controls 2.2 as Controls
import org.kde.kirigami 2.10 as Kirigami
import MeeGo.QOfono 0.2
KCM.SimpleKCM {
title: i18n("Access Points")
OfonoManager {
id: ofonoManager
}
ListView {
width: parent.width
model: ofonoManager.modems.length
delegate: ColumnLayout {
property int modemId: model.index
width: parent.width
Repeater {
Layout.fillWidth: true
model: ofonoConnManager.contexts.length
delegate: Kirigami.AbstractCard {
property int contextId: model.index
Layout.fillWidth: true
visible: context.accessPointName != ""
header: Kirigami.Heading {
text: context.name
level: 2
horizontalAlignment: Text.AlignHCenter
}
contentItem: Kirigami.FormLayout {
Layout.fillWidth: true
RowLayout {
Layout.fillWidth: true
Kirigami.FormData.label: i18n("Active:")
Controls.CheckBox {
enabled: false
checked: context.active
}
}
Controls.Label {
visible: context.protocol != ""
wrapMode: Text.WordWrap
text: context.protocol
Kirigami.FormData.label: i18n("Protocol:")
Layout.fillWidth: true
}
Controls.Label {
visible: context.type != ""
wrapMode: Text.WordWrap
text: context.type
Kirigami.FormData.label: i18n("Type:")
Layout.fillWidth: true
}
Controls.Label {
visible: context.accessPointName != ""
wrapMode: Text.WordWrap
text: context.accessPointName
Kirigami.FormData.label: i18n("APN:")
Layout.fillWidth: true
}
}
OfonoContextConnection {
id: context
contextPath: ofonoConnManager.contexts[contextId]
}
}
}
OfonoConnMan {
id: ofonoConnManager
modemPath: ofonoManager.modems[modemId]
}
}
}
}
/*
* Copyright 2020 Dimitris Kardarakos <dimkard@posteo.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import org.kde.kcm 1.2 as KCM
import QtQuick.Layouts 1.2
import QtQuick 2.7
import QtQuick.Controls 2.2 as Controls
import org.kde.kirigami 2.10 as Kirigami
import MeeGo.QOfono 0.2
KCM.SimpleKCM {
title: i18n("Modems")
OfonoManager {
id: ofonoManager
}
Kirigami.CardsListView {
width: parent.width
model: ofonoManager.modems.length
delegate: Kirigami.AbstractCard {
property int modemId: model.index
width: parent.width
header: Kirigami.Heading {
text: ofonoManager.modems.length == 1 ? i18n("Modem") : i18np("Modem 1", "Modem %1", modemId+1)
level: 2
horizontalAlignment: Text.AlignHCenter
}
contentItem: Kirigami.FormLayout {
width: parent.width
Controls.Label {
visible: ofonoModem.name != ""
wrapMode: Text.WordWrap
text: ofonoModem.name
Kirigami.FormData.label: i18n("Name:")
Layout.fillWidth: true
}
Controls.Label {
visible: ofonoModem.serial != ""
wrapMode: Text.WordWrap
text: ofonoModem.serial
Kirigami.FormData.label: i18n("IMEI:")
Layout.fillWidth: true
}
Controls.Label {
visible: ofonoModem.manufacturer != ""
wrapMode: Text.WordWrap
text: ofonoModem.manufacturer
Kirigami.FormData.label: i18n("Manufacturer:")
Layout.fillWidth: true
}
Controls.Label {
visible: ofonoModem.model != ""
wrapMode: Text.WordWrap
text: ofonoModem.model
Kirigami.FormData.label: i18n("Model:")
Layout.fillWidth: true
}
Controls.Label {
visible: ofonoModem.revision != ""
wrapMode: Text.WordWrap
text: ofonoModem.revision
Kirigami.FormData.label: i18n("Revision:")
Layout.fillWidth: true
}
Controls.Label {
visible: ofonoModem.type != ""
wrapMode: Text.WordWrap
text: ofonoModem.type
Kirigami.FormData.label: i18n("Type:")
Layout.fillWidth: true
}
}
OfonoModem {
id: ofonoModem
modemPath: ofonoManager.modems[modemId]
}
}
}
}
/*
* Copyright 2020 Dimitris Kardarakos <dimkard@posteo.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import org.kde.kcm 1.2 as KCM
import QtQuick.Layouts 1.2
import QtQuick 2.7
import QtQuick.Controls 2.2 as Controls
import org.kde.kirigami 2.10 as Kirigami
import MeeGo.QOfono 0.2
KCM.SimpleKCM {
title: i18n("Networks")
OfonoManager {
id: ofonoManager
}
Kirigami.CardsListView {
width: parent.width
model: ofonoManager.modems.length
delegate: Kirigami.AbstractCard {
property int modemId: model.index
width: parent.width
header: Kirigami.Heading {
text: ofonoManager.modems.length == 1 ? i18n("Network") : i18n("Network %1", modemId+1)
level: 2
horizontalAlignment: Text.AlignHCenter
}
contentItem: Kirigami.FormLayout {
width: parent.width
Controls.Label {
visible: netreg.name != ""
wrapMode: Text.WordWrap
text: netreg.name
Kirigami.FormData.label: i18n("Operator:")
Layout.fillWidth: true
}
Controls.Label {
visible: netreg.mode != ""
wrapMode: Text.WordWrap
text: netreg.mode
Kirigami.FormData.label: i18n("Mode:")
Layout.fillWidth: true
}
Controls.Label {
visible: netreg.cellId != ""
wrapMode: Text.WordWrap
text: netreg.cellId
Kirigami.FormData.label: i18n("Cell Id:")
Layout.fillWidth: true
}
Controls.Label {
visible: netreg.mcc != ""
wrapMode: Text.WordWrap
text: netreg.mcc
Kirigami.FormData.label: i18n("MCC:")
Layout.fillWidth: true
}
Controls.Label {
visible: netreg.mnc != ""
wrapMode: Text.WordWrap
text: netreg.mnc
Kirigami.FormData.label: i18n("MNC:")
Layout.fillWidth: true
}
Controls.Label {
visible: netreg.technology != ""
wrapMode: Text.WordWrap
text: netreg.technology
Kirigami.FormData.label: i18n("Technology:")
Layout.fillWidth: true
}
Controls.Label {
visible: netreg.strength != ""
wrapMode: Text.WordWrap
text: "%1 %2".arg(netreg.strength).arg("%")
Kirigami.FormData.label: i18n("Strength:")
Layout.fillWidth: true
}
Controls.Label {
visible: netreg.baseStation != ""
wrapMode: Text.WordWrap
text: netreg.baseStation
Kirigami.FormData.label: i18n("Base Station:")
Layout.fillWidth: true
}
}
OfonoNetworkRegistration {
id: netreg
modemPath: ofonoManager.modems[modemId]
}
}
}
}
/*
* Copyright 2020 Dimitris Kardarakos <dimkard@posteo.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import org.kde.kcm 1.2 as KCM
import QtQuick.Layouts 1.2
import QtQuick 2.7
import QtQuick.Controls 2.2 as Controls
import org.kde.kirigami 2.10 as Kirigami
import MeeGo.QOfono 0.2
KCM.SimpleKCM {
title: i18n("SIM Cards")
OfonoManager {
id: ofonoManager
}
Kirigami.CardsListView {
width: parent.width
model: ofonoManager.modems.length
delegate: Kirigami.AbstractCard {
property int modemId: model.index
width: parent.width
header: Kirigami.Heading {
text: ofonoManager.modems.length == 1 ? i18n("SIM Card") : i18np("SIM Card 1", "SIM Card %1", modemId+1)
level: 2
horizontalAlignment: Text.AlignHCenter
}
contentItem: Kirigami.FormLayout {
width: parent.width
Controls.Label {
visible: ofonoSimManager.subscriberIdentity != ""
wrapMode: Text.WordWrap
text: ofonoSimManager.subscriberIdentity
Kirigami.FormData.label: i18n("IMSI:")
Layout.fillWidth: true
}
Controls.Label {
visible: ofonoSimManager.mobileCountryCode != ""
wrapMode: Text.WordWrap
text: ofonoSimManager.mobileCountryCode
Kirigami.FormData.label: i18n("MCC:")
Layout.fillWidth: true
}
Controls.Label {
visible: ofonoSimManager.mobileNetworkCode != ""
wrapMode: Text.WordWrap
text: ofonoSimManager.mobileNetworkCode
Kirigami.FormData.label: i18n("MNC:")
Layout.fillWidth: true
}
Controls.Label {
visible: ofonoSimManager.cardIdentifier != ""
wrapMode: Text.WordWrap
text: ofonoSimManager.cardIdentifier
Kirigami.FormData.label: i18n("ICCID:")
Layout.fillWidth: true
}
Controls.Label {
visible: ofonoSimManager.serviceProviderName != ""
wrapMode: Text.WordWrap
text: ofonoSimManager.serviceProviderName
Kirigami.FormData.label: i18n("Service Provider:")
Layout.fillWidth: true
}
Controls.Label {
visible: ofonoSimManager.subscriberNumbers.length > 0
wrapMode: Text.WordWrap
text: ofonoSimManager.subscriberNumbers.join(",")
Kirigami.FormData.label: i18np("Subscriber Number:", "Subscriber Numbers:", ofonoSimManager.subscriberNumbers.length)
Layout.fillWidth: true
}
Controls.Label {
visible: ofonoSimManager.preferredLanguages.length > 0
text: ofonoSimManager.preferredLanguages.join(", ")
wrapMode: Text.WordWrap
Kirigami.FormData.label: i18np("Preferred Language:", "Preferred Languages:", ofonoSimManager.preferredLanguages.length)
Layout.fillWidth: true
}
}
OfonoSimManager {
id: ofonoSimManager
modemPath: ofonoManager.modems[modemId]
}
}
}
}
/*
* Copyright 2020 Dimitris Kardarakos <dimkard@posteo.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import org.kde.kcm 1.2 as KCM
import QtQuick 2.7
import org.kde.kirigami 2.10 as Kirigami
import MeeGo.QOfono 0.2
KCM.SimpleKCM {
property string modems: i18n("Modems")
property string sims: i18n("SIM Cards")
property string registrations: i18n("Networks")
property string contexts: i18n("Access Points")
property var entries: [ { name: modems, page: "Modems.qml", icon: "network-modem" } , { name: sims, page: "SimCards.qml", icon: "auth-sim-symbolic" }, { name: registrations, page: "Registrations.qml", icon: "" }, { name: contexts, page: "Contexts.qml", icon: "network-wireless-hotspot" } ]
title: i18n("Cellular Networks")
ListView {
model: entries
delegate: Kirigami.BasicListItem {
label: modelData.name
icon: modelData.icon
onClicked: kcm.push(modelData.page)