Merge lp:~unity-api-team/indicator-network/mobile_data_switch into lp:indicator-network

Proposed by Antti Kaijanmäki
Status: Rejected
Rejected by: Antti Kaijanmäki
Proposed branch: lp:~unity-api-team/indicator-network/mobile_data_switch
Merge into: lp:indicator-network
Diff against target: 8959 lines (+7904/-17)
62 files modified
CMakeLists.txt (+2/-0)
data/com.ubuntu.connectivity1.Modem.xml (+9/-0)
data/com.ubuntu.connectivity1.Private.xml (+8/-0)
data/com.ubuntu.connectivity1.Sim.xml (+16/-0)
scripts/CMakeLists.txt (+5/-0)
scripts/disable-mobile-data.sh (+8/-0)
scripts/enable-mobile-data.sh (+8/-0)
scripts/get-mobile-data-enabled.sh (+6/-0)
scripts/get-modems.sh (+6/-0)
scripts/get-sim-for-mobile-data.sh (+6/-0)
scripts/get-sims.sh (+6/-0)
scripts/monitor-private-properties.sh (+7/-0)
scripts/set-sim-for-mobile-data.sh (+8/-0)
src/connectivity-api/connectivity-qml/CMakeLists.txt (+1/-1)
src/connectivity-api/connectivity-qml/plugin.cpp (+14/-1)
src/connectivity-api/connectivity-qml/proxy-model.h (+80/-0)
src/connectivity-api/connectivity-qt/CMakeLists.txt (+21/-2)
src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp (+92/-0)
src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h (+24/-0)
src/connectivity-api/connectivity-qt/connectivityqt/modem.cpp (+112/-0)
src/connectivity-api/connectivity-qt/connectivityqt/modem.h (+68/-0)
src/connectivity-api/connectivity-qt/connectivityqt/modems-list-model.cpp (+172/-0)
src/connectivity-api/connectivity-qt/connectivityqt/modems-list-model.h (+78/-0)
src/connectivity-api/connectivity-qt/connectivityqt/path.cpp (+103/-0)
src/connectivity-api/connectivity-qt/connectivityqt/path.h (+59/-0)
src/connectivity-api/connectivity-qt/connectivityqt/sim.cpp (+153/-0)
src/connectivity-api/connectivity-qt/connectivityqt/sim.h (+90/-0)
src/connectivity-api/connectivity-qt/connectivityqt/sims-list-model.cpp (+214/-0)
src/connectivity-api/connectivity-qt/connectivityqt/sims-list-model.h (+93/-0)
src/indicator/CMakeLists.txt (+21/-0)
src/indicator/connectivity-service/connectivity-service.cpp (+185/-0)
src/indicator/connectivity-service/connectivity-service.h (+17/-0)
src/indicator/connectivity-service/dbus-modem.cpp (+98/-0)
src/indicator/connectivity-service/dbus-modem.h (+83/-0)
src/indicator/connectivity-service/dbus-sim.cpp (+149/-0)
src/indicator/connectivity-service/dbus-sim.h (+103/-0)
src/indicator/factory.cpp (+12/-2)
src/indicator/factory.h (+3/-1)
src/indicator/menu-builder.cpp (+3/-1)
src/indicator/nmofono/manager-impl.cpp (+210/-0)
src/indicator/nmofono/manager-impl.h (+12/-0)
src/indicator/nmofono/manager.h (+26/-0)
src/indicator/nmofono/wwan/modem.cpp (+63/-2)
src/indicator/nmofono/wwan/modem.h (+10/-0)
src/indicator/nmofono/wwan/qofono-sim-wrapper.cpp (+251/-0)
src/indicator/nmofono/wwan/qofono-sim-wrapper.h (+77/-0)
src/indicator/nmofono/wwan/sim-manager.cpp (+271/-0)
src/indicator/nmofono/wwan/sim-manager.h (+56/-0)
src/indicator/nmofono/wwan/sim.cpp (+582/-0)
src/indicator/nmofono/wwan/sim.h (+182/-0)
src/indicator/sections/wwan-section.cpp (+9/-5)
src/indicator/sections/wwan-section.h (+1/-1)
src/qdbus-stubs/dbus-types.h (+13/-0)
tests/data/phonesim/sim_general.xml (+3677/-0)
tests/integration/CMakeLists.txt (+2/-0)
tests/integration/indicator-network-test-base.cpp (+8/-0)
tests/integration/indicator-network-test-base.h (+1/-0)
tests/integration/qml/test.qml (+119/-0)
tests/integration/test-connectivity-api-modem.cpp (+53/-0)
tests/integration/test-connectivity-api-sim.cpp (+68/-0)
tests/integration/test-connectivity-api.cpp (+21/-0)
tests/integration/test-indicator.cpp (+49/-1)
To merge this branch: bzr merge lp:~unity-api-team/indicator-network/mobile_data_switch
Reviewer Review Type Date Requested Status
Indicator Applet Developers Pending
Review via email: mp+289028@code.launchpad.net

Commit message

New Connectivity Service Private API for managing mobile data and SIM cards.

To post a comment you must log in.
576. By Antti Kaijanmäki

add stuff to .Private

577. By Antti Kaijanmäki

add switch to the menu

578. By Antti Kaijanmäki

.

579. By Antti Kaijanmäki

add sim and modem ADAPTORS

580. By Antti Kaijanmäki

modem and sim Interfaces.

581. By Antti Kaijanmäki

some test skeletons

582. By Antti Kaijanmäki

Sim: add Primmary phone number

583. By Antti Kaijanmäki

some more test skeletons

584. By Antti Kaijanmäki

introduce wwan::Sim

585. By Antti Kaijanmäki

factory: introduce mobileDataSwitch

586. By Antti Kaijanmäki

Augment nmofono::Manager interface.

587. By Antti Kaijanmäki

commit for a while..

588. By Antti Kaijanmäki

added scripts/

589. By Antti Kaijanmäki

Get the ConnectionManager interface for actually managing the data connection.

590. By Antti Kaijanmäki

add phonesim/general_sim.xml

591. By Antti Kaijanmäki

QML API start

592. By Antti Kaijanmäki

merge upstream

593. By Antti Kaijanmäki

finish qml bindings.

594. By Antti Kaijanmäki

add simple qml program

595. By Antti Kaijanmäki

cleanups

Unmerged revisions

595. By Antti Kaijanmäki

cleanups

594. By Antti Kaijanmäki

add simple qml program

593. By Antti Kaijanmäki

finish qml bindings.

592. By Antti Kaijanmäki

merge upstream

591. By Antti Kaijanmäki

QML API start

590. By Antti Kaijanmäki

add phonesim/general_sim.xml

589. By Antti Kaijanmäki

Get the ConnectionManager interface for actually managing the data connection.

588. By Antti Kaijanmäki

added scripts/

587. By Antti Kaijanmäki

commit for a while..

586. By Antti Kaijanmäki

Augment nmofono::Manager interface.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-02-15 09:31:38 +0000
+++ CMakeLists.txt 2016-04-26 11:24:03 +0000
@@ -139,3 +139,5 @@
139)139)
140140
141endif()141endif()
142
143add_subdirectory(scripts)
142144
=== added file 'data/com.ubuntu.connectivity1.Modem.xml'
--- data/com.ubuntu.connectivity1.Modem.xml 1970-01-01 00:00:00 +0000
+++ data/com.ubuntu.connectivity1.Modem.xml 2016-04-26 11:24:03 +0000
@@ -0,0 +1,9 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2
3<node>
4 <interface name="com.ubuntu.connectivity1.Modem">
5 <property name="Index" type="i" access="read" />
6 <property name="Serial" type="s" access="read" />
7 <property name="Sim" type="o" access="read" />
8 </interface>
9</node>
010
=== modified file 'data/com.ubuntu.connectivity1.Private.xml'
--- data/com.ubuntu.connectivity1.Private.xml 2015-12-04 13:18:04 +0000
+++ data/com.ubuntu.connectivity1.Private.xml 2016-04-26 11:24:03 +0000
@@ -52,6 +52,14 @@
52 52
53 <property name="VpnConnections" type="ao" access="read"/>53 <property name="VpnConnections" type="ao" access="read"/>
5454
55 <property name="MobileDataEnabled" type="b" access="readwrite"/>
56
57 <property name="SimForMobileData" type="o" access="readwrite"/>
58
59 <property name="Modems" type="ao" access="read"/>
60
61 <property name="Sims" type="ao" access="read"/>
62
55 <signal name="ReportError">63 <signal name="ReportError">
56 <arg type="i" direction="out" name="reason"/>64 <arg type="i" direction="out" name="reason"/>
57 </signal>65 </signal>
5866
=== added file 'data/com.ubuntu.connectivity1.Sim.xml'
--- data/com.ubuntu.connectivity1.Sim.xml 1970-01-01 00:00:00 +0000
+++ data/com.ubuntu.connectivity1.Sim.xml 2016-04-26 11:24:03 +0000
@@ -0,0 +1,16 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2
3<node>
4 <interface name="com.ubuntu.connectivity1.Sim">
5 <property name="Imsi" type="s" access="read" />
6 <property name="PrimaryPhoneNumber" type="s" access="read" />
7 <property name="Locked" type="b" access="read" />
8 <property name="Present" type="b" access="read" />
9 <property name="Mcc" type="s" access="read" />
10 <property name="Mnc" type="s" access="read" />
11 <property name="PreferredLanguages" type="as" access="read" />
12 <property name="DataRoamingEnabled" type="b" access="readwrite" />
13
14 <method name="Unlock" />
15 </interface>
16</node>
017
=== added directory 'scripts'
=== added file 'scripts/CMakeLists.txt'
--- scripts/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ scripts/CMakeLists.txt 2016-04-26 11:24:03 +0000
@@ -0,0 +1,5 @@
1
2file(GLOB_RECURSE SCRIPT_FILES
3 ${CMAKE_CURRENT_SOURCE_DIR}/*.sh
4)
5add_custom_target(scriptfiles SOURCES ${SCRIPT_FILES})
06
=== added file 'scripts/disable-mobile-data.sh'
--- scripts/disable-mobile-data.sh 1970-01-01 00:00:00 +0000
+++ scripts/disable-mobile-data.sh 2016-04-26 11:24:03 +0000
@@ -0,0 +1,8 @@
1dbus-send --session --print-reply \
2 --dest=com.ubuntu.connectivity1 \
3 /com/ubuntu/connectivity1/Private \
4 org.freedesktop.DBus.Properties.Set \
5 string:com.ubuntu.connectivity1.Private \
6 string:MobileDataEnabled \
7 variant:boolean:false
8sh get-mobile-data-enabled.sh
09
=== added file 'scripts/enable-mobile-data.sh'
--- scripts/enable-mobile-data.sh 1970-01-01 00:00:00 +0000
+++ scripts/enable-mobile-data.sh 2016-04-26 11:24:03 +0000
@@ -0,0 +1,8 @@
1dbus-send --session --print-reply \
2 --dest=com.ubuntu.connectivity1 \
3 /com/ubuntu/connectivity1/Private \
4 org.freedesktop.DBus.Properties.Set \
5 string:com.ubuntu.connectivity1.Private \
6 string:MobileDataEnabled \
7 variant:boolean:true
8sh get-mobile-data-enabled.sh
09
=== added file 'scripts/get-mobile-data-enabled.sh'
--- scripts/get-mobile-data-enabled.sh 1970-01-01 00:00:00 +0000
+++ scripts/get-mobile-data-enabled.sh 2016-04-26 11:24:03 +0000
@@ -0,0 +1,6 @@
1dbus-send --session --print-reply \
2 --dest=com.ubuntu.connectivity1 \
3 /com/ubuntu/connectivity1/Private \
4 org.freedesktop.DBus.Properties.Get \
5 string:com.ubuntu.connectivity1.Private \
6 string:MobileDataEnabled
07
=== added file 'scripts/get-modems.sh'
--- scripts/get-modems.sh 1970-01-01 00:00:00 +0000
+++ scripts/get-modems.sh 2016-04-26 11:24:03 +0000
@@ -0,0 +1,6 @@
1dbus-send --session --print-reply \
2 --dest=com.ubuntu.connectivity1 \
3 /com/ubuntu/connectivity1/Private \
4 org.freedesktop.DBus.Properties.Get \
5 string:com.ubuntu.connectivity1.Private \
6 string:Modems
07
=== added file 'scripts/get-sim-for-mobile-data.sh'
--- scripts/get-sim-for-mobile-data.sh 1970-01-01 00:00:00 +0000
+++ scripts/get-sim-for-mobile-data.sh 2016-04-26 11:24:03 +0000
@@ -0,0 +1,6 @@
1dbus-send --session --print-reply \
2 --dest=com.ubuntu.connectivity1 \
3 /com/ubuntu/connectivity1/Private \
4 org.freedesktop.DBus.Properties.Get \
5 string:com.ubuntu.connectivity1.Private \
6 string:SimForMobileData
07
=== added file 'scripts/get-sims.sh'
--- scripts/get-sims.sh 1970-01-01 00:00:00 +0000
+++ scripts/get-sims.sh 2016-04-26 11:24:03 +0000
@@ -0,0 +1,6 @@
1dbus-send --session --print-reply \
2 --dest=com.ubuntu.connectivity1 \
3 /com/ubuntu/connectivity1/Private \
4 org.freedesktop.DBus.Properties.Get \
5 string:com.ubuntu.connectivity1.Private \
6 string:Sims
07
=== added file 'scripts/monitor-private-properties.sh'
--- scripts/monitor-private-properties.sh 1970-01-01 00:00:00 +0000
+++ scripts/monitor-private-properties.sh 2016-04-26 11:24:03 +0000
@@ -0,0 +1,7 @@
1dbus-monitor --session \
2 "type=signal,
3 sender='com.ubuntu.connectivity1',
4 path=/com/ubuntu/connectivity1/Private,
5 interface=org.freedesktop.DBus.Properties,
6 member=PropertiesChanged"
7
08
=== added file 'scripts/set-sim-for-mobile-data.sh'
--- scripts/set-sim-for-mobile-data.sh 1970-01-01 00:00:00 +0000
+++ scripts/set-sim-for-mobile-data.sh 2016-04-26 11:24:03 +0000
@@ -0,0 +1,8 @@
1dbus-send --session --print-reply \
2 --dest=com.ubuntu.connectivity1 \
3 /com/ubuntu/connectivity1/Private \
4 org.freedesktop.DBus.Properties.Set \
5 string:com.ubuntu.connectivity1.Private \
6 string:SimForMobileData \
7 variant:objpath:$1
8sh get-sim-for-mobile-data.sh
09
=== modified file 'src/connectivity-api/connectivity-qml/CMakeLists.txt'
--- src/connectivity-api/connectivity-qml/CMakeLists.txt 2015-05-19 13:49:21 +0000
+++ src/connectivity-api/connectivity-qml/CMakeLists.txt 2016-04-26 11:24:03 +0000
@@ -8,7 +8,7 @@
8)8)
99
10set(CONNECTIVITY_QML_SRC10set(CONNECTIVITY_QML_SRC
11 plugin.cpp11 plugin.cpp
12)12)
1313
14add_library(connectivity-qml SHARED14add_library(connectivity-qml SHARED
1515
=== modified file 'src/connectivity-api/connectivity-qml/plugin.cpp'
--- src/connectivity-api/connectivity-qml/plugin.cpp 2015-12-04 13:18:04 +0000
+++ src/connectivity-api/connectivity-qml/plugin.cpp 2016-04-26 11:24:03 +0000
@@ -21,6 +21,13 @@
21#include <connectivityqt/connectivity.h>21#include <connectivityqt/connectivity.h>
22#include <connectivityqt/openvpn-connection.h>22#include <connectivityqt/openvpn-connection.h>
2323
24#include <connectivityqt/path.h>
25#include <connectivityqt/sim.h>
26
27#include <connectivityqt/modems-list-model.h>
28#include <connectivityqt/sims-list-model.h>
29
30
24#include <QtQml>31#include <QtQml>
2532
26namespace33namespace
@@ -44,10 +51,16 @@
44{51{
45 connectivityqt::Connectivity::registerMetaTypes();52 connectivityqt::Connectivity::registerMetaTypes();
46 qmlRegisterSingletonType<connectivityqt::Connectivity>(uri, 1, 0, "NetworkingStatus", connectivitySingletonProvider);53 qmlRegisterSingletonType<connectivityqt::Connectivity>(uri, 1, 0, "NetworkingStatus", connectivitySingletonProvider);
47 qmlRegisterSingletonType<connectivityqt::Connectivity>(uri, 1, 0, "Connectivity", connectivitySingletonProvider);54 qmlRegisterSingletonType<connectivityqt::Connectivity>(uri, 1, 1, "Connectivity", connectivitySingletonProvider);
48 qmlRegisterUncreatableType<connectivityqt::VpnConnectionsListModel>(uri, 1, 0, "VpnConnectionsListModel", "Access VpnConnectionsListModel via Connectivity object");55 qmlRegisterUncreatableType<connectivityqt::VpnConnectionsListModel>(uri, 1, 0, "VpnConnectionsListModel", "Access VpnConnectionsListModel via Connectivity object");
49 qmlRegisterUncreatableType<connectivityqt::VpnConnection>(uri, 1, 0, "VpnConnection", "Access VpnConnection via VpnConnectionsListModel object");56 qmlRegisterUncreatableType<connectivityqt::VpnConnection>(uri, 1, 0, "VpnConnection", "Access VpnConnection via VpnConnectionsListModel object");
50 qmlRegisterUncreatableType<connectivityqt::OpenvpnConnection>(uri, 1, 0, "OpenvpnConnection", "Access OpenvpnConnection via VpnConnectionsListModel object");57 qmlRegisterUncreatableType<connectivityqt::OpenvpnConnection>(uri, 1, 0, "OpenvpnConnection", "Access OpenvpnConnection via VpnConnectionsListModel object");
58
59 qmlRegisterUncreatableType<connectivityqt::Path>(uri, 1, 1, "Path", "");
60 qmlRegisterUncreatableType<connectivityqt::Sim>(uri, 1, 1, "Sim", "");
61
62 qmlRegisterUncreatableType<connectivityqt::ModemsListModel>(uri, 1, 1, "ModemsListModel", "");
63 qmlRegisterUncreatableType<connectivityqt::ModemsListModel>(uri, 1, 1, "SimsListModel", "");
51}64}
5265
53void66void
5467
=== added file 'src/connectivity-api/connectivity-qml/proxy-model.cpp'
=== added file 'src/connectivity-api/connectivity-qml/proxy-model.h'
--- src/connectivity-api/connectivity-qml/proxy-model.h 1970-01-01 00:00:00 +0000
+++ src/connectivity-api/connectivity-qml/proxy-model.h 2016-04-26 11:24:03 +0000
@@ -0,0 +1,80 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#pragma once
21
22#include <QAbstractItemModel>
23#include <QDBusConnection>
24#include <QDBusObjectPath>
25
26#include <memory>
27
28namespace connectivityqt
29{
30
31class Q_DECL_EXPORT ModemsListModel : public QAbstractListModel
32{
33 Q_OBJECT
34
35 Q_ENUMS(Roles)
36
37public:
38
39 enum Roles
40 {
41 RoleIndex = Qt::UserRole + 1,
42 RoleSerial,
43 RoleSimPath
44 };
45
46 ModemsListModel(const QDBusConnection &connection, QObject *parent);
47
48 ~ModemsListModel();
49
50 int columnCount(const QModelIndex &parent) const override;
51
52 int rowCount(const QModelIndex &parent) const override;
53
54 QVariant data(const QModelIndex &index, int role) const override;
55
56 bool setData(const QModelIndex &index, const QVariant &value, int role) override;
57
58 Qt::ItemFlags flags(const QModelIndex & index) const override;
59
60 QHash<int, QByteArray> roleNames() const override
61 {
62 QHash<int, QByteArray> roles;
63 roles[RoleIndex] = "Index";
64 roles[RoleSerial] = "Serial";
65 roles[RoleSimPath] = "SimPath";
66 return roles;
67 }
68
69 void updateModemDBusPaths(QList<QDBusObjectPath> values);
70
71public Q_SLOTS:
72
73Q_SIGNALS:
74
75protected:
76 class Priv;
77 std::shared_ptr<Priv> d;
78};
79
80}
081
=== modified file 'src/connectivity-api/connectivity-qt/CMakeLists.txt'
--- src/connectivity-api/connectivity-qt/CMakeLists.txt 2016-02-17 10:58:27 +0000
+++ src/connectivity-api/connectivity-qt/CMakeLists.txt 2016-04-26 11:24:03 +0000
@@ -22,6 +22,11 @@
22 CONNECTIVITY_QT_SRC22 CONNECTIVITY_QT_SRC
23 connectivityqt/internal/dbus-property-cache.cpp23 connectivityqt/internal/dbus-property-cache.cpp
24 connectivityqt/connectivity.cpp24 connectivityqt/connectivity.cpp
25 connectivityqt/modem.cpp
26 connectivityqt/modems-list-model.cpp
27 connectivityqt/sim.cpp
28 connectivityqt/sims-list-model.cpp
29 connectivityqt/path.cpp
25 connectivityqt/openvpn-connection.cpp30 connectivityqt/openvpn-connection.cpp
26 connectivityqt/pptp-connection.cpp31 connectivityqt/pptp-connection.cpp
27 connectivityqt/vpn-connection.cpp32 connectivityqt/vpn-connection.cpp
@@ -33,6 +38,8 @@
33 "${DATA_DIR}/org.freedesktop.DBus.Properties.xml"38 "${DATA_DIR}/org.freedesktop.DBus.Properties.xml"
34 "${DATA_DIR}/com.ubuntu.connectivity1.NetworkingStatus.xml"39 "${DATA_DIR}/com.ubuntu.connectivity1.NetworkingStatus.xml"
35 "${DATA_DIR}/com.ubuntu.connectivity1.Private.xml"40 "${DATA_DIR}/com.ubuntu.connectivity1.Private.xml"
41 "${DATA_DIR}/com.ubuntu.connectivity1.Modem.xml"
42 "${DATA_DIR}/com.ubuntu.connectivity1.Sim.xml"
36 "${DATA_DIR}/com.ubuntu.connectivity1.vpn.VpnConnection.xml"43 "${DATA_DIR}/com.ubuntu.connectivity1.vpn.VpnConnection.xml"
37 "${DATA_DIR}/com.ubuntu.connectivity1.vpn.VpnConnection.OpenVpn.xml"44 "${DATA_DIR}/com.ubuntu.connectivity1.vpn.VpnConnection.OpenVpn.xml"
38 "${DATA_DIR}/com.ubuntu.connectivity1.vpn.VpnConnection.Pptp.xml"45 "${DATA_DIR}/com.ubuntu.connectivity1.vpn.VpnConnection.Pptp.xml"
@@ -54,6 +61,18 @@
5461
55qt5_add_dbus_interface(62qt5_add_dbus_interface(
56 CONNECTIVITY_QT_SRC63 CONNECTIVITY_QT_SRC
64 "${DATA_DIR}/com.ubuntu.connectivity1.Modem.xml"
65 ModemInterface
66)
67
68qt5_add_dbus_interface(
69 CONNECTIVITY_QT_SRC
70 "${DATA_DIR}/com.ubuntu.connectivity1.Sim.xml"
71 SimInterface
72)
73
74qt5_add_dbus_interface(
75 CONNECTIVITY_QT_SRC
57 "${DATA_DIR}/com.ubuntu.connectivity1.vpn.VpnConnection.xml"76 "${DATA_DIR}/com.ubuntu.connectivity1.vpn.VpnConnection.xml"
58 VpnConnectionInterface77 VpnConnectionInterface
59)78)
@@ -99,8 +118,8 @@
99 ${CONNECTIVITY_QT_LIB_TARGET}118 ${CONNECTIVITY_QT_LIB_TARGET}
100 PROPERTIES119 PROPERTIES
101 SOVERSION ${SO_VERSION}120 SOVERSION ${SO_VERSION}
102 LINK_FLAGS "-Wl,--version-script,${SYMBOL_MAP}"121# LINK_FLAGS "-Wl,--version-script,${SYMBOL_MAP}"
103 LINK_DEPENDS "${SYMBOL_MAP}"122# LINK_DEPENDS "${SYMBOL_MAP}"
104)123)
105124
106install(125install(
107126
=== modified file 'src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp'
--- src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp 2015-12-04 13:18:04 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp 2016-04-26 11:24:03 +0000
@@ -20,6 +20,8 @@
20#include <connectivityqt/connectivity.h>20#include <connectivityqt/connectivity.h>
21#include <connectivityqt/internal/vpn-connection-list-model-parameters.h>21#include <connectivityqt/internal/vpn-connection-list-model-parameters.h>
22#include <connectivityqt/vpn-connections-list-model.h>22#include <connectivityqt/vpn-connections-list-model.h>
23#include <connectivityqt/modems-list-model.h>
24#include <connectivityqt/sims-list-model.h>
23#include <dbus-types.h>25#include <dbus-types.h>
24#include <NetworkingStatusInterface.h>26#include <NetworkingStatusInterface.h>
25#include <NetworkingStatusPrivateInterface.h>27#include <NetworkingStatusPrivateInterface.h>
@@ -57,6 +59,11 @@
5759
58 VpnConnectionsListModel::SPtr m_vpnConnectionsModel;60 VpnConnectionsListModel::SPtr m_vpnConnectionsModel;
5961
62 SimsListModel *m_simsModel;
63 ModemsListModel *m_modemsModel;
64
65 Sim *m_simForMobileData = nullptr;
66
60 static QVector<Limitations> toLimitations(const QVariant& value)67 static QVector<Limitations> toLimitations(const QVariant& value)
61 {68 {
62 auto l = value.toStringList();69 auto l = value.toStringList();
@@ -100,6 +107,8 @@
100 {107 {
101 Q_EMIT p.initialized();108 Q_EMIT p.initialized();
102 }109 }
110 QList<QDBusObjectPath> tmp;
111 qvariant_cast<QDBusArgument>(m_writePropertyCache->get("Modems")) >> tmp;
103 }112 }
104113
105 void propertyChanged(const QString& name, const QVariant& value)114 void propertyChanged(const QString& name, const QVariant& value)
@@ -164,6 +173,29 @@
164 {173 {
165 Q_EMIT p.hotspotStoredUpdated(value.toBool());174 Q_EMIT p.hotspotStoredUpdated(value.toBool());
166 }175 }
176 else if (name == "MobileDataEnabled")
177 {
178 Q_EMIT p.mobileDataEnabledUpdated(value.toBool());
179 }
180 else if (name == "SimForMobileData")
181 {
182 auto path = value.value<QDBusObjectPath>();
183 auto sim = m_simsModel->getSimByPath(path);
184 p.setSimForMobileData(sim);
185 }
186 else if (name == "Modems")
187 {
188 QList<QDBusObjectPath> tmp;
189 qvariant_cast<QDBusArgument>(m_writePropertyCache->get("Modems")) >> tmp;
190 m_modemsModel->updateModemDBusPaths(tmp);
191 }
192 else if (name == "Sims")
193 {
194 QList<QDBusObjectPath> tmp;
195 qvariant_cast<QDBusArgument>(m_writePropertyCache->get("Sims")) >> tmp;
196 m_simsModel->updateSimDBusPaths(tmp);
197 }
198
167 }199 }
168200
169};201};
@@ -178,6 +210,8 @@
178210
179 qRegisterMetaType<connectivityqt::VpnConnection*>("VpnConnection*");211 qRegisterMetaType<connectivityqt::VpnConnection*>("VpnConnection*");
180 qRegisterMetaType<connectivityqt::VpnConnection::Type>("VpnConnection::Type");212 qRegisterMetaType<connectivityqt::VpnConnection::Type>("VpnConnection::Type");
213
214 qRegisterMetaType<connectivityqt::Sim*>("Sim*");
181}215}
182216
183Connectivity::Connectivity(const QDBusConnection& sessionConnection, QObject* parent) :217Connectivity::Connectivity(const QDBusConnection& sessionConnection, QObject* parent) :
@@ -196,6 +230,9 @@
196{230{
197 d->m_objectOwner = objectOwner;231 d->m_objectOwner = objectOwner;
198232
233 d->m_simsModel = new SimsListModel(sessionConnection, this);
234 d->m_modemsModel = new ModemsListModel(sessionConnection, d->m_simsModel, this);
235
199 d->m_readInterface = make_shared<236 d->m_readInterface = make_shared<
200 ComUbuntuConnectivity1NetworkingStatusInterface>(237 ComUbuntuConnectivity1NetworkingStatusInterface>(
201 DBusTypes::DBUS_NAME, DBusTypes::SERVICE_PATH,238 DBusTypes::DBUS_NAME, DBusTypes::SERVICE_PATH,
@@ -225,6 +262,17 @@
225 &internal::DBusPropertyCache::initialized, d.get(),262 &internal::DBusPropertyCache::initialized, d.get(),
226 &Connectivity::Priv::interfaceInitialized);263 &Connectivity::Priv::interfaceInitialized);
227264
265 if (d->m_writePropertyCache->isInitialized()) {
266 QList<QDBusObjectPath> tmp;
267 qvariant_cast<QDBusArgument>(d->m_writePropertyCache->get("Sims")) >> tmp;
268 d->m_simsModel->updateSimDBusPaths(tmp);
269 tmp.clear();
270 qvariant_cast<QDBusArgument>(d->m_writePropertyCache->get("Modems")) >> tmp;
271 d->m_modemsModel->updateModemDBusPaths(tmp);
272
273 d->m_simForMobileData = d->m_simsModel->getSimByPath(d->m_writePropertyCache->get("SimForMobileData").value<QDBusObjectPath>());
274 }
275
228 connect(d->m_writeInterface.get(),276 connect(d->m_writeInterface.get(),
229 &ComUbuntuConnectivity1PrivateInterface::ReportError, this,277 &ComUbuntuConnectivity1PrivateInterface::ReportError, this,
230 &Connectivity::reportError);278 &Connectivity::reportError);
@@ -384,6 +432,50 @@
384 return d->m_vpnConnectionsModel.get();432 return d->m_vpnConnectionsModel.get();
385}433}
386434
435bool Connectivity::mobileDataEnabled() const
436{
437 return d->m_writePropertyCache->get("MobileDataEnabled").toBool();
438}
439
440void Connectivity::setMobileDataEnabled(bool enabled)
441{
442 d->m_writeInterface->setMobileDataEnabled(enabled);
443}
444
445Sim *Connectivity::simForMobileData() const
446{
447 return d->m_simForMobileData;
448}
449
450void Connectivity::setSimForMobileData(Sim *sim)
451{
452 if (d->m_simForMobileData == sim)
453 {
454 return;
455 }
456 d->m_simForMobileData = sim;
457 if (sim)
458 {
459 d->m_writeInterface->setSimForMobileData(sim->path());
460 }
461 else
462 {
463 d->m_writeInterface->setSimForMobileData(QDBusObjectPath("/"));
464 }
465 Q_EMIT simForMobileDataUpdated(sim);
466}
467
468QAbstractItemModel* Connectivity::modems() const
469{
470 return d->m_modemsModel;
471}
472
473QAbstractItemModel *Connectivity::sims() const
474{
475 return d->m_simsModel;
476}
477
478
387}479}
388480
389#include "connectivity.moc"481#include "connectivity.moc"
390482
=== modified file 'src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h'
--- src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 2016-01-14 13:38:38 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 2016-04-26 11:24:03 +0000
@@ -30,9 +30,13 @@
3030
31#include <connectivityqt/vpn-connections-list-model.h>31#include <connectivityqt/vpn-connections-list-model.h>
3232
33#include <QDBusObjectPath>
34
33namespace connectivityqt35namespace connectivityqt
34{36{
3537
38class Sim;
39
36class Q_DECL_EXPORT Connectivity: public QObject40class Q_DECL_EXPORT Connectivity: public QObject
37{41{
38 Q_OBJECT42 Q_OBJECT
@@ -138,6 +142,18 @@
138 Q_PROPERTY(QAbstractItemModel* vpnConnections READ vpnConnections NOTIFY vpnConnectionsUpdated)142 Q_PROPERTY(QAbstractItemModel* vpnConnections READ vpnConnections NOTIFY vpnConnectionsUpdated)
139 QAbstractItemModel* vpnConnections() const;143 QAbstractItemModel* vpnConnections() const;
140144
145 Q_PROPERTY(bool mobileDataEnabled READ mobileDataEnabled WRITE setMobileDataEnabled NOTIFY mobileDataEnabledUpdated)
146 bool mobileDataEnabled() const;
147
148 Q_PROPERTY(Sim* simForMobileData READ simForMobileData WRITE setSimForMobileData NOTIFY simForMobileDataUpdated)
149 Sim* simForMobileData() const;
150
151 Q_PROPERTY(QAbstractItemModel* modems READ modems CONSTANT)
152 QAbstractItemModel* modems() const;
153
154 Q_PROPERTY(QAbstractItemModel* sims READ sims CONSTANT)
155 QAbstractItemModel* sims() const;
156
141public Q_SLOTS:157public Q_SLOTS:
142 void setFlightMode(bool enabled);158 void setFlightMode(bool enabled);
143159
@@ -153,6 +169,10 @@
153169
154 void setHotspotAuth(const QString& auth);170 void setHotspotAuth(const QString& auth);
155171
172 void setMobileDataEnabled(bool enabled);
173
174 void setSimForMobileData(Sim *sim);
175
156Q_SIGNALS:176Q_SIGNALS:
157 void flightModeUpdated(bool);177 void flightModeUpdated(bool);
158178
@@ -194,6 +214,10 @@
194214
195 void vpnConnectionsUpdated(QAbstractItemModel*);215 void vpnConnectionsUpdated(QAbstractItemModel*);
196216
217 void mobileDataEnabledUpdated(bool);
218
219 void simForMobileDataUpdated(Sim* sim);
220
197protected:221protected:
198 class Priv;222 class Priv;
199 std::shared_ptr<Priv> d;223 std::shared_ptr<Priv> d;
200224
=== added file 'src/connectivity-api/connectivity-qt/connectivityqt/modem.cpp'
--- src/connectivity-api/connectivity-qt/connectivityqt/modem.cpp 1970-01-01 00:00:00 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/modem.cpp 2016-04-26 11:24:03 +0000
@@ -0,0 +1,112 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include <connectivityqt/internal/dbus-property-cache.h>
21#include <connectivityqt/modem.h>
22#include <dbus-types.h>
23
24#include <ModemInterface.h>
25
26using namespace std;
27
28namespace connectivityqt
29{
30
31class Modem::Priv: public QObject
32{
33 Q_OBJECT
34
35public:
36 Priv(Modem& parent) :
37 p(parent)
38 {
39 }
40
41public Q_SLOTS:
42 void propertyChanged(const QString& name, const QVariant& value)
43 {
44 if (name == "Sim")
45 {
46 m_sim = m_sims->getSimByPath(value.value<QDBusObjectPath>());
47 Q_EMIT p.simChanged(m_sim);
48 }
49 }
50
51public:
52 Modem& p;
53
54 Sim *m_sim;
55 SimsListModel *m_sims;
56
57 unique_ptr<ComUbuntuConnectivity1ModemInterface> m_modemInterface;
58
59 internal::DBusPropertyCache::UPtr m_propertyCache;
60};
61
62Modem::Modem(const QDBusObjectPath& path,
63 const QDBusConnection& connection,
64 SimsListModel *sims,
65 QObject* parent) :
66 QObject(parent), d(new Priv(*this))
67{
68 d->m_sims = sims;
69 d->m_modemInterface = make_unique<
70 ComUbuntuConnectivity1ModemInterface>(
71 DBusTypes::DBUS_NAME, path.path(), connection);
72
73 d->m_propertyCache =
74 make_unique<internal::DBusPropertyCache>(
75 DBusTypes::DBUS_NAME,
76 ComUbuntuConnectivity1ModemInterface::staticInterfaceName(),
77 path.path(), connection);
78
79 connect(d->m_propertyCache.get(),
80 &internal::DBusPropertyCache::propertyChanged, d.get(),
81 &Priv::propertyChanged);
82
83 d->m_sim = d->m_sims->getSimByPath(d->m_propertyCache->get("Sim").value<QDBusObjectPath>());
84}
85
86Modem::~Modem()
87{
88}
89
90QDBusObjectPath Modem::path() const
91{
92 return QDBusObjectPath(d->m_modemInterface->path());
93}
94
95int Modem::index() const
96{
97 return d->m_propertyCache->get("Index").toInt();
98}
99
100Sim *Modem::sim() const
101{
102 return d->m_sim;
103}
104
105QString Modem::serial() const
106{
107 return d->m_propertyCache->get("Serial").toString();
108}
109
110}
111
112#include "modem.moc"
0113
=== added file 'src/connectivity-api/connectivity-qt/connectivityqt/modem.h'
--- src/connectivity-api/connectivity-qt/connectivityqt/modem.h 1970-01-01 00:00:00 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/modem.h 2016-04-26 11:24:03 +0000
@@ -0,0 +1,68 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#pragma once
21
22#include <QDBusConnection>
23#include <QDBusObjectPath>
24#include <QObject>
25
26#include <unity/util/DefinesPtrs.h>
27#include <connectivityqt/sims-list-model.h>
28
29namespace connectivityqt
30{
31
32class Q_DECL_EXPORT Modem : public QObject
33{
34 Q_OBJECT
35
36public:
37 UNITY_DEFINES_PTRS(Modem);
38
39 Modem(const QDBusObjectPath& path,
40 const QDBusConnection& connection,
41 SimsListModel *sims,
42 QObject* parent = 0);
43
44 virtual ~Modem();
45
46 Q_PROPERTY(QDBusObjectPath path READ path)
47 QDBusObjectPath path() const;
48
49 Q_PROPERTY(QString serial READ serial)
50 QString serial() const;
51
52 Q_PROPERTY(int index READ index CONSTANT)
53 int index() const;
54
55 Q_PROPERTY(connectivityqt::Sim* sim READ sim NOTIFY simChanged)
56 Sim* sim() const;
57
58public Q_SLOTS:
59
60Q_SIGNALS:
61 void simChanged(Sim *sim);
62
63protected:
64 class Priv;
65 std::shared_ptr<Priv> d;
66};
67
68}
069
=== added file 'src/connectivity-api/connectivity-qt/connectivityqt/modems-list-model.cpp'
--- src/connectivity-api/connectivity-qt/connectivityqt/modems-list-model.cpp 1970-01-01 00:00:00 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/modems-list-model.cpp 2016-04-26 11:24:03 +0000
@@ -0,0 +1,172 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include <connectivityqt/modems-list-model.h>
21#include <connectivityqt/modem.h>
22#include <connectivityqt/path.h>
23
24#include <QDebug>
25
26using namespace std;
27
28namespace connectivityqt
29{
30
31class ModemsListModel::Priv: public QObject
32{
33 Q_OBJECT
34
35public:
36 Priv(ModemsListModel& parent, const QDBusConnection &connection) :
37 p(parent),
38 m_connection(connection)
39 {
40 }
41
42 void updateModemDBusPaths(QList<QDBusObjectPath> values)
43 {
44 auto paths = values.toSet();
45
46 QSet<QDBusObjectPath> current;
47 for (const auto& m: m_modems)
48 {
49 current << m->path();
50 }
51
52 auto toRemove(current);
53 toRemove.subtract(paths);
54
55 auto toAdd(paths);
56 toAdd.subtract(current);
57
58 QMutableListIterator<Modem::SPtr> i(m_modems);
59 int idx = 0;
60 while (i.hasNext())
61 {
62 auto modem(i.next());
63 if (toRemove.contains(modem->path()))
64 {
65 p.beginRemoveRows(QModelIndex(), idx, idx);
66 i.remove();
67 p.endRemoveRows();
68 }
69 else
70 {
71 ++idx;
72 }
73 }
74
75 if (!toAdd.isEmpty())
76 {
77 p.beginInsertRows(QModelIndex(), m_modems.size(), m_modems.size() + toAdd.size() - 1);
78 for (const auto& path: toAdd)
79 {
80 auto modem = std::make_shared<Modem>(path, m_connection, m_sims, this);
81 m_modems << modem;
82 connect(modem.get(), &Modem::simChanged, this, &Priv::simChanged);
83 }
84 p.endInsertRows();
85 }
86 }
87
88 QModelIndex findModem(QObject* o)
89 {
90 auto modem = qobject_cast<Modem*>(o);
91 for (auto i = m_modems.constBegin(); i != m_modems.constEnd(); ++i)
92 {
93 if (i->get() == modem)
94 {
95 return p.index(std::distance(m_modems.constBegin(), i));
96 }
97 }
98 return QModelIndex();
99 }
100
101public Q_SLOTS:
102 void simChanged(Sim *sim)
103 {
104 auto idx = findModem(sender());
105 p.dataChanged(idx, idx, {ModemsListModel::Roles::RoleSim});
106 }
107
108public:
109 ModemsListModel& p;
110 SimsListModel *m_sims;
111 QList<QDBusObjectPath> m_dbus_paths;
112 QList<Modem::SPtr> m_modems;
113
114 const QDBusConnection &m_connection;
115};
116
117ModemsListModel::ModemsListModel(const QDBusConnection& connection, SimsListModel *sims, QObject *parent) :
118 QAbstractListModel(parent),
119 d(new Priv(*this, connection))
120{
121 d->m_sims = sims;
122}
123
124ModemsListModel::~ModemsListModel()
125{
126}
127
128int ModemsListModel::columnCount(const QModelIndex &) const
129{
130 return 1;
131}
132
133int ModemsListModel::rowCount(const QModelIndex &) const
134{
135 return d->m_modems.size();
136}
137
138QVariant ModemsListModel::data(const QModelIndex &index, int role) const
139{
140 int row(index.row());
141 if (row < 0 || row >= d->m_modems.size())
142 {
143 return QVariant();
144 }
145
146 auto modem = d->m_modems.value(row);
147
148 switch (role)
149 {
150 case Roles::RoleIndex:
151 return modem->index();
152 break;
153 case Roles::RoleSerial:
154 return modem->serial();
155 break;
156 case Roles::RoleSim:
157 return QVariant::fromValue<Sim*>(modem->sim());
158 break;
159 }
160
161 return QVariant();
162}
163
164void ModemsListModel::updateModemDBusPaths(QList<QDBusObjectPath> values)
165{
166 d->updateModemDBusPaths(values);
167}
168
169
170}
171
172#include "modems-list-model.moc"
0173
=== added file 'src/connectivity-api/connectivity-qt/connectivityqt/modems-list-model.h'
--- src/connectivity-api/connectivity-qt/connectivityqt/modems-list-model.h 1970-01-01 00:00:00 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/modems-list-model.h 2016-04-26 11:24:03 +0000
@@ -0,0 +1,78 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#pragma once
21
22#include <QAbstractItemModel>
23#include <QDBusConnection>
24#include <QDBusObjectPath>
25
26#include <memory>
27
28namespace connectivityqt
29{
30
31class SimsListModel;
32
33class Q_DECL_EXPORT ModemsListModel : public QAbstractListModel
34{
35 Q_OBJECT
36
37 Q_ENUMS(Roles)
38
39public:
40
41 enum Roles
42 {
43 RoleIndex = Qt::UserRole + 1,
44 RoleSerial,
45 RoleSim
46 };
47
48 ModemsListModel(const QDBusConnection &connection, SimsListModel *sims, QObject *parent);
49
50 ~ModemsListModel();
51
52 int columnCount(const QModelIndex &parent) const override;
53
54 int rowCount(const QModelIndex &parent) const override;
55
56 QVariant data(const QModelIndex &index, int role) const override;
57
58 QHash<int, QByteArray> roleNames() const override
59 {
60 QHash<int, QByteArray> roles;
61 roles[RoleIndex] = "Index";
62 roles[RoleSerial] = "Serial";
63 roles[RoleSim] = "Sim";
64 return roles;
65 }
66
67 void updateModemDBusPaths(QList<QDBusObjectPath> values);
68
69public Q_SLOTS:
70
71Q_SIGNALS:
72
73protected:
74 class Priv;
75 std::shared_ptr<Priv> d;
76};
77
78}
079
=== added file 'src/connectivity-api/connectivity-qt/connectivityqt/path.cpp'
--- src/connectivity-api/connectivity-qt/connectivityqt/path.cpp 1970-01-01 00:00:00 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/path.cpp 2016-04-26 11:24:03 +0000
@@ -0,0 +1,103 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include <connectivityqt/path.h>
21#include <QDBusObjectPath>
22
23#include <QDebug>
24
25namespace connectivityqt
26{
27
28class Path::Priv: public QObject
29{
30 Q_OBJECT
31
32public:
33 Priv(Path& parent) :
34 p(parent)
35 {
36 }
37
38public Q_SLOTS:
39
40public:
41 Path& p;
42
43 QDBusObjectPath m_path;
44};
45
46Path::Path(QObject* parent)
47 : Path("", parent)
48{}
49
50Path::Path(const QString& path, QObject* parent) :
51 QObject(parent), d(new Priv(*this))
52{
53 setPath(path);
54}
55
56Path::Path(const Path& path, QObject* parent) :
57 QObject(parent), d(new Priv(*this))
58{
59 setPath(path.path());
60}
61
62
63Path::~Path()
64{
65}
66
67QString Path::path() const
68{
69 if (d->m_path == QDBusObjectPath("/"))
70 return "";
71 return d->m_path.path();
72}
73
74void Path::setPath(const QString &value)
75{
76 QString tmp = value;
77 if (tmp == "")
78 {
79 tmp = "/";
80 }
81 if (d->m_path == QDBusObjectPath(tmp))
82 {
83 return;
84 }
85 d->m_path = QDBusObjectPath(tmp);
86 Q_EMIT pathChanged(value);
87
88 /// @todo emit emptyChanged..
89}
90
91void Path::clear()
92{
93 setPath("");
94}
95
96bool Path::empty() const
97{
98 return d->m_path == QDBusObjectPath("/");
99}
100
101}
102
103#include "path.moc"
0104
=== added file 'src/connectivity-api/connectivity-qt/connectivityqt/path.h'
--- src/connectivity-api/connectivity-qt/connectivityqt/path.h 1970-01-01 00:00:00 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/path.h 2016-04-26 11:24:03 +0000
@@ -0,0 +1,59 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#pragma once
21
22#include <QObject>
23#include <memory>
24
25namespace connectivityqt
26{
27
28class Q_DECL_EXPORT Path : public QObject
29{
30 Q_OBJECT
31
32public:
33 Path(QObject* parent = 0);
34 Path(const QString& path, QObject* parent = 0);
35 Path(const Path& path, QObject* parent = 0);
36 ~Path();
37
38 Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
39 QString path() const;
40 void setPath(const QString &value);
41
42 Q_PROPERTY(bool empty READ empty NOTIFY emptyChanged)
43 bool empty() const;
44
45public Q_SLOTS:
46 void clear();
47
48Q_SIGNALS:
49 void pathChanged(const QString &value);
50 void emptyChanged(bool value);
51
52protected:
53 class Priv;
54 std::shared_ptr<Priv> d;
55};
56
57}
58
59Q_DECLARE_METATYPE(connectivityqt::Path*)
060
=== added file 'src/connectivity-api/connectivity-qt/connectivityqt/sim.cpp'
--- src/connectivity-api/connectivity-qt/connectivityqt/sim.cpp 1970-01-01 00:00:00 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/sim.cpp 2016-04-26 11:24:03 +0000
@@ -0,0 +1,153 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include <connectivityqt/internal/dbus-property-cache.h>
21#include <connectivityqt/sim.h>
22#include <dbus-types.h>
23
24#include <SimInterface.h>
25
26using namespace std;
27
28namespace connectivityqt
29{
30
31class Sim::Priv: public QObject
32{
33 Q_OBJECT
34
35public:
36 Priv(Sim& parent) :
37 p(parent)
38 {
39 }
40
41public Q_SLOTS:
42 void propertyChanged(const QString& name, const QVariant& value)
43 {
44 if (name == "Locked")
45 {
46 Q_EMIT p.lockedChanged(value.toBool());
47 } else if (name == "Present")
48 {
49 Q_EMIT p.presentChanged(value.toBool());
50 } else if (name == "DataRoamingEnabled")
51 {
52 Q_EMIT p.dataRoamingEnabledChanged(value.toBool());
53 } else {
54 qWarning() << "connectivityqt::Sim::Priv::propertyChanged(): "
55 << "Unexpected property: " << name;
56 }
57
58 }
59
60public:
61 Sim& p;
62
63 unique_ptr<ComUbuntuConnectivity1SimInterface> m_simInterface;
64
65 internal::DBusPropertyCache::UPtr m_propertyCache;
66};
67
68Sim::Sim(const QDBusObjectPath& path, const QDBusConnection& connection, QObject* parent) :
69 QObject(parent), d(new Priv(*this))
70{
71 d->m_simInterface = make_unique<
72 ComUbuntuConnectivity1SimInterface>(
73 DBusTypes::DBUS_NAME, path.path(), connection);
74
75 d->m_propertyCache =
76 make_unique<internal::DBusPropertyCache>(
77 DBusTypes::DBUS_NAME,
78 ComUbuntuConnectivity1SimInterface::staticInterfaceName(),
79 path.path(), connection);
80
81 connect(d->m_propertyCache.get(),
82 &internal::DBusPropertyCache::propertyChanged, d.get(),
83 &Priv::propertyChanged);
84}
85
86Sim::~Sim()
87{
88}
89
90QDBusObjectPath Sim::path() const
91{
92 return QDBusObjectPath(d->m_simInterface->path());
93}
94
95QString Sim::imsi() const
96{
97 return d->m_propertyCache->get("Imsi").toString();
98}
99
100QString Sim::primaryPhoneNumber() const
101{
102 return d->m_propertyCache->get("PrimaryPhoneNumber").toString();
103}
104
105QList<QString> Sim::phoneNumbers() const
106{
107 return d->m_propertyCache->get("PhoneNumbers").toStringList();
108}
109
110bool Sim::locked() const
111{
112 return d->m_propertyCache->get("Locked").toBool();
113}
114
115bool Sim::present() const
116{
117 return d->m_propertyCache->get("Present").toBool();
118}
119
120QString Sim::mcc() const
121{
122 return d->m_propertyCache->get("Mcc").toString();
123}
124
125QString Sim::mnc() const
126{
127 return d->m_propertyCache->get("Mnc").toString();
128}
129
130QList<QString> Sim::preferredLanguages() const
131{
132 return d->m_propertyCache->get("PreferredLanguages").toStringList();
133}
134
135bool Sim::dataRoamingEnabled() const
136{
137 return d->m_propertyCache->get("DataRoamingEnabled").toBool();
138}
139
140void Sim::setDataRoamingEnabled(bool value)
141{
142 d->m_propertyCache->set("DataRoamingEnabled", QVariant(value));
143}
144
145void Sim::unlock()
146{
147 d->m_simInterface->Unlock();
148}
149
150}
151
152#include "sim.moc"
153
0154
=== added file 'src/connectivity-api/connectivity-qt/connectivityqt/sim.h'
--- src/connectivity-api/connectivity-qt/connectivityqt/sim.h 1970-01-01 00:00:00 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/sim.h 2016-04-26 11:24:03 +0000
@@ -0,0 +1,90 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#pragma once
21
22#include <QDBusConnection>
23#include <QDBusObjectPath>
24#include <QObject>
25
26#include <unity/util/DefinesPtrs.h>
27
28namespace connectivityqt
29{
30
31class Q_DECL_EXPORT Sim : public QObject
32{
33 Q_OBJECT
34
35public:
36 UNITY_DEFINES_PTRS(Sim);
37
38 Sim(const QDBusObjectPath& path, const QDBusConnection& connection, QObject* parent = 0);
39
40 virtual ~Sim();
41
42 Q_PROPERTY(QDBusObjectPath path READ path)
43 QDBusObjectPath path() const;
44
45 Q_PROPERTY(QString Imsi READ imsi CONSTANT)
46 QString imsi() const;
47
48 Q_PROPERTY(QString PrimaryPhoneNumber READ primaryPhoneNumber CONSTANT)
49 QString primaryPhoneNumber() const;
50
51 Q_PROPERTY(QList<QString> PhoneNumbers READ phoneNumbers CONSTANT)
52 QList<QString> phoneNumbers() const;
53
54 Q_PROPERTY(bool Locked READ locked NOTIFY lockedChanged)
55 bool locked() const;
56
57 Q_PROPERTY(bool Present READ present NOTIFY presentChanged)
58 bool present() const;
59
60 Q_PROPERTY(QString Mcc READ mcc CONSTANT)
61 QString mcc() const;
62
63 Q_PROPERTY(QString Mnc READ mnc CONSTANT)
64 QString mnc() const;
65
66 Q_PROPERTY(QList<QString> PreferredLanguages READ preferredLanguages CONSTANT)
67 QList<QString> preferredLanguages() const;
68
69 Q_PROPERTY(bool DataRoamingEnabled READ dataRoamingEnabled WRITE setDataRoamingEnabled NOTIFY dataRoamingEnabledChanged)
70 bool dataRoamingEnabled() const;
71 void setDataRoamingEnabled(bool value);
72
73public Q_SLOTS:
74
75 void unlock();
76
77Q_SIGNALS:
78 void lockedChanged(bool value);
79 void presentChanged(bool value);
80 void dataRoamingEnabledChanged(bool value);
81
82
83protected:
84 class Priv;
85 std::shared_ptr<Priv> d;
86};
87
88}
89
90Q_DECLARE_METATYPE(connectivityqt::Sim*)
091
=== added file 'src/connectivity-api/connectivity-qt/connectivityqt/sims-list-model.cpp'
--- src/connectivity-api/connectivity-qt/connectivityqt/sims-list-model.cpp 1970-01-01 00:00:00 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/sims-list-model.cpp 2016-04-26 11:24:03 +0000
@@ -0,0 +1,214 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include <connectivityqt/sims-list-model.h>
21#include <connectivityqt/path.h>
22
23#include <QDebug>
24
25using namespace std;
26
27namespace connectivityqt
28{
29
30class SimsListModel::Priv: public QObject
31{
32 Q_OBJECT
33
34public:
35 Priv(SimsListModel& parent, const QDBusConnection &connection) :
36 p(parent),
37 m_connection(connection)
38 {
39 }
40
41 void updateSimDBusPaths(QList<QDBusObjectPath> values)
42 {
43 auto paths = values.toSet();
44
45 QSet<QDBusObjectPath> current;
46 for (const auto& m: m_sims)
47 {
48 current << m->path();
49 }
50
51 auto toRemove(current);
52 toRemove.subtract(paths);
53
54 auto toAdd(paths);
55 toAdd.subtract(current);
56
57 QMutableListIterator<Sim::SPtr> i(m_sims);
58 int idx = 0;
59 while (i.hasNext())
60 {
61 auto sim(i.next());
62 if (toRemove.contains(sim->path()))
63 {
64 p.beginRemoveRows(QModelIndex(), idx, idx);
65 i.remove();
66 p.endRemoveRows();
67 }
68 else
69 {
70 ++idx;
71 }
72 }
73
74 if (!toAdd.isEmpty())
75 {
76 p.beginInsertRows(QModelIndex(), m_sims.size(), m_sims.size() + toAdd.size() - 1);
77 for (const auto& path: toAdd)
78 {
79 auto sim = std::make_shared<Sim>(path, m_connection, this);
80 m_sims << sim;
81 connect(sim.get(), &Sim::lockedChanged, this, &Priv::lockedChanged);
82 connect(sim.get(), &Sim::presentChanged, this, &Priv::presentChanged);
83 connect(sim.get(), &Sim::dataRoamingEnabledChanged, this, &Priv::dataRoamingEnabledChanged);
84 }
85 p.endInsertRows();
86 }
87 }
88
89 QModelIndex findSim(QObject* o)
90 {
91 auto sim = qobject_cast<Sim*>(o);
92 for (auto i = m_sims.constBegin(); i != m_sims.constEnd(); ++i)
93 {
94 if (i->get() == sim)
95 {
96 return p.index(std::distance(m_sims.constBegin(), i));
97 }
98 }
99 return QModelIndex();
100 }
101
102public Q_SLOTS:
103 void lockedChanged()
104 {
105 auto idx = findSim(sender());
106 p.dataChanged(idx, idx, {SimsListModel::Roles::RoleLocked});
107 }
108
109 void presentChanged()
110 {
111 auto idx = findSim(sender());
112 p.dataChanged(idx, idx, {SimsListModel::Roles::RolePresent});
113 }
114 void dataRoamingEnabledChanged()
115 {
116 auto idx = findSim(sender());
117 p.dataChanged(idx, idx, {SimsListModel::Roles::RoleDataRoamingEnabled});
118 }
119
120public:
121 SimsListModel& p;
122 QList<QDBusObjectPath> m_dbus_paths;
123 QList<Sim::SPtr> m_sims;
124
125 const QDBusConnection &m_connection;
126};
127
128SimsListModel::SimsListModel(const QDBusConnection& connection, QObject *parent) :
129 QAbstractListModel(parent),
130 d(new Priv(*this, connection))
131{
132}
133
134SimsListModel::~SimsListModel()
135{
136}
137
138int SimsListModel::columnCount(const QModelIndex &) const
139{
140 return 1;
141}
142
143int SimsListModel::rowCount(const QModelIndex &) const
144{
145 return d->m_sims.size();
146}
147
148QVariant SimsListModel::data(const QModelIndex &index, int role) const
149{
150 int row(index.row());
151 if (row < 0 || row >= d->m_sims.size())
152 {
153 return QVariant();
154 }
155
156 auto sim = d->m_sims.value(row);
157
158 switch (role)
159 {
160 case Roles::RoleImsi:
161 return sim->imsi();
162 break;
163 case Roles::RolePrimaryPhoneNumber:
164 return sim->primaryPhoneNumber();
165 break;
166 case Roles::RolePhoneNumbers:
167 return QVariant::fromValue<QStringList>(sim->phoneNumbers());
168 break;
169 case RoleLocked:
170 return sim->locked();
171 break;
172 case RolePresent:
173 return sim->present();
174 break;
175 case Roles::RoleMcc:
176 return sim->mcc();
177 break;
178 case Roles::RoleMnc:
179 return sim->mnc();
180 case Roles::RolePreferredLanguages:
181 return QVariant::fromValue<QStringList>(sim->preferredLanguages());
182 break;
183 case Roles::RoleDataRoamingEnabled:
184 return sim->dataRoamingEnabled();
185 break;
186 case Roles::RoleSimObject:
187 return QVariant::fromValue<Sim*>(sim.get());
188 break;
189 }
190
191
192 return QVariant();
193}
194
195void SimsListModel::updateSimDBusPaths(QList<QDBusObjectPath> values)
196{
197 d->updateSimDBusPaths(values);
198}
199
200Sim *SimsListModel::getSimByPath(const QDBusObjectPath &path) const
201{
202 for (auto sim : d->m_sims)
203 {
204 if (sim->path() == path) {
205 return sim.get();
206 }
207 }
208 return nullptr;
209}
210
211
212}
213
214#include "sims-list-model.moc"
0215
=== added file 'src/connectivity-api/connectivity-qt/connectivityqt/sims-list-model.h'
--- src/connectivity-api/connectivity-qt/connectivityqt/sims-list-model.h 1970-01-01 00:00:00 +0000
+++ src/connectivity-api/connectivity-qt/connectivityqt/sims-list-model.h 2016-04-26 11:24:03 +0000
@@ -0,0 +1,93 @@
1/*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#pragma once
21
22#include <QAbstractItemModel>
23#include <QDBusConnection>
24#include <QDBusObjectPath>
25#include <connectivityqt/sim.h>
26
27#include <memory>
28
29namespace connectivityqt
30{
31
32class Q_DECL_EXPORT SimsListModel : public QAbstractListModel
33{
34 Q_OBJECT
35
36 Q_ENUMS(Roles)
37
38public:
39
40 enum Roles
41 {
42 RoleImsi = Qt::UserRole + 1,
43 RolePrimaryPhoneNumber,
44 RolePhoneNumbers,
45 RoleLocked,
46 RolePresent,
47 RoleMcc,
48 RoleMnc,
49 RolePreferredLanguages,
50 RoleDataRoamingEnabled,
51 RoleSimObject
52 };
53
54 SimsListModel(const QDBusConnection &connection, QObject *parent);
55
56 ~SimsListModel();
57
58 int columnCount(const QModelIndex &parent) const override;
59
60 int rowCount(const QModelIndex &parent) const override;
61
62 QVariant data(const QModelIndex &index, int role) const override;
63
64 QHash<int, QByteArray> roleNames() const override
65 {
66 QHash<int, QByteArray> roles;
67 roles[RoleImsi] = "Imsi";
68 roles[RolePrimaryPhoneNumber] = "PrimaryPhoneNumber";
69 roles[RolePhoneNumbers] = "PhoneNumbers";
70 roles[RoleLocked] = "Locked";
71 roles[RolePresent] = "Present";
72 roles[RoleMcc] = "Mcc";
73 roles[RoleMnc] = "Mnc";
74 roles[RolePreferredLanguages] = "PreferredLanguages";
75 roles[RoleDataRoamingEnabled] = "DataRoamingEnabled";
76 roles[RoleSimObject] = "SimObject";
77 return roles;
78 }
79
80 void updateSimDBusPaths(QList<QDBusObjectPath> values);
81
82 Sim *getSimByPath(const QDBusObjectPath &path) const;
83
84public Q_SLOTS:
85
86Q_SIGNALS:
87
88protected:
89 class Priv;
90 std::shared_ptr<Priv> d;
91};
92
93}
094
=== modified file 'src/indicator/CMakeLists.txt'
--- src/indicator/CMakeLists.txt 2016-02-15 09:31:38 +0000
+++ src/indicator/CMakeLists.txt 2016-04-26 11:24:03 +0000
@@ -32,6 +32,9 @@
32 nmofono/wifi/grouped-access-point.cpp32 nmofono/wifi/grouped-access-point.cpp
33 nmofono/wifi/wifi-link-impl.cpp33 nmofono/wifi/wifi-link-impl.cpp
34 nmofono/wwan/modem.cpp34 nmofono/wwan/modem.cpp
35 nmofono/wwan/sim.cpp
36 nmofono/wwan/sim-manager.cpp
37 nmofono/wwan/qofono-sim-wrapper.cpp
35 nmofono/vpn/openvpn-connection.cpp38 nmofono/vpn/openvpn-connection.cpp
36 nmofono/vpn/pptp-connection.cpp39 nmofono/vpn/pptp-connection.cpp
37 nmofono/vpn/vpn-connection.cpp40 nmofono/vpn/vpn-connection.cpp
@@ -53,6 +56,8 @@
53 connectivity-service/dbus-openvpn-connection.cpp56 connectivity-service/dbus-openvpn-connection.cpp
54 connectivity-service/dbus-pptp-connection.cpp57 connectivity-service/dbus-pptp-connection.cpp
55 connectivity-service/dbus-vpn-connection.cpp58 connectivity-service/dbus-vpn-connection.cpp
59 connectivity-service/dbus-modem.cpp
60 connectivity-service/dbus-sim.cpp
5661
57 menuitems/access-point-item.cpp62 menuitems/access-point-item.cpp
58 menuitems/switch-item.cpp63 menuitems/switch-item.cpp
@@ -73,6 +78,22 @@
7378
74qt5_add_dbus_adaptor(79qt5_add_dbus_adaptor(
75 NETWORK_SERVICE_SOURCES80 NETWORK_SERVICE_SOURCES
81 "${DATA_DIR}/com.ubuntu.connectivity1.Modem.xml"
82 connectivity-service/dbus-modem.h
83 connectivity_service::DBusModem
84 ModemAdaptor
85)
86
87qt5_add_dbus_adaptor(
88 NETWORK_SERVICE_SOURCES
89 "${DATA_DIR}/com.ubuntu.connectivity1.Sim.xml"
90 connectivity-service/dbus-sim.h
91 connectivity_service::DBusSim
92 SimAdaptor
93)
94
95qt5_add_dbus_adaptor(
96 NETWORK_SERVICE_SOURCES
76 "${DATA_DIR}/com.ubuntu.connectivity1.Private.xml"97 "${DATA_DIR}/com.ubuntu.connectivity1.Private.xml"
77 connectivity-service/connectivity-service.h98 connectivity-service/connectivity-service.h
78 connectivity_service::PrivateService99 connectivity_service::PrivateService
79100
=== modified file 'src/indicator/connectivity-service/connectivity-service.cpp'
--- src/indicator/connectivity-service/connectivity-service.cpp 2016-01-14 11:40:59 +0000
+++ src/indicator/connectivity-service/connectivity-service.cpp 2016-04-26 11:24:03 +0000
@@ -19,6 +19,8 @@
19 */19 */
2020
21#include <connectivity-service/connectivity-service.h>21#include <connectivity-service/connectivity-service.h>
22#include <connectivity-service/dbus-modem.h>
23#include <connectivity-service/dbus-sim.h>
22#include <connectivity-service/dbus-vpn-connection.h>24#include <connectivity-service/dbus-vpn-connection.h>
23#include <connectivity-service/dbus-openvpn-connection.h>25#include <connectivity-service/dbus-openvpn-connection.h>
24#include <connectivity-service/dbus-pptp-connection.h>26#include <connectivity-service/dbus-pptp-connection.h>
@@ -48,6 +50,9 @@
4850
49 QMap<QDBusObjectPath, DBusVpnConnection::SPtr> m_vpnConnections;51 QMap<QDBusObjectPath, DBusVpnConnection::SPtr> m_vpnConnections;
5052
53 QMap<QString, DBusModem::SPtr> m_modems;
54 QMap<QString, DBusSim::SPtr> m_sims;
55
51 shared_ptr<PrivateService> m_privateService;56 shared_ptr<PrivateService> m_privateService;
5257
53 QStringList m_limitations;58 QStringList m_limitations;
@@ -166,6 +171,111 @@
166 });171 });
167 }172 }
168173
174 void mobileDataEnabledUpdated(bool value)
175 {
176 Q_UNUSED(value)
177 notifyPrivateProperties({
178 "MobileDataEnabled"
179 });
180 }
181
182 void simForMobileDataUpdated()
183 {
184 notifyPrivateProperties({
185 "SimForMobileData"
186 });
187 }
188
189 void updateSims()
190 {
191 qDebug() << "updateSims()";
192 auto current_imsis = m_sims.keys().toSet();
193 QMap<QString, nmofono::wwan::Sim::Ptr> sims;
194 for (auto i : m_manager->sims())
195 {
196 sims[i->imsi()] = i;
197 }
198 auto toAdd(sims.keys().toSet());
199 toAdd.subtract(current_imsis);
200
201 auto toRemove(current_imsis);
202 toRemove.subtract(sims.keys().toSet());
203
204 for (auto imsi : toRemove)
205 {
206 qDebug() << "Removing " << imsi;
207 m_sims.remove(imsi);
208 }
209
210 for (auto imsi : toAdd)
211 {
212 qDebug() << "Adding " << imsi;
213
214 DBusSim::SPtr dbussim = make_shared<DBusSim>(sims[imsi], m_connection);
215 m_sims[imsi] = dbussim;
216 }
217
218 notifyPrivateProperties({
219 "Sims"
220 });
221 }
222
223 void updateModems()
224 {
225 qDebug() << "updateModems() " << m_manager->modems().length();
226 auto current_serials = m_modems.keys().toSet();
227 QMap<QString, nmofono::wwan::Modem::Ptr> modems;
228 for (auto i : m_manager->modems())
229 {
230 modems[i->serial()] = i;
231 }
232 auto toAdd(modems.keys().toSet());
233 toAdd.subtract(current_serials);
234
235 auto toRemove(current_serials);
236 toRemove.subtract(modems.keys().toSet());
237
238 for (auto serial : toRemove)
239 {
240 qDebug() << "Removing " << serial;
241 m_modems.remove(serial);
242 }
243
244 for (auto serial : toAdd)
245 {
246 qDebug() << "Adding " << serial;
247
248 wwan::Modem::Ptr m = modems[serial];
249
250 DBusModem::SPtr dbusmodem = make_shared<DBusModem>(m, m_connection);
251 m_modems[serial] = dbusmodem;
252 qDebug() << "asdfghjklm,nghff: " << m_modems.size();
253 updateModemSimPath(dbusmodem, m->sim());
254 connect(m.get(), &wwan::Modem::simUpdated, this, &Private::modemSimUpdated);
255 }
256 notifyPrivateProperties({
257 "Modems"
258 });
259 }
260
261 void modemSimUpdated()
262 {
263 auto modem_raw = qobject_cast<wwan::Modem*>(sender());
264 updateModemSimPath(m_modems[modem_raw->serial()], modem_raw->sim());
265 }
266
267 void updateModemSimPath(DBusModem::SPtr modem, wwan::Sim::Ptr sim)
268 {
269 if (!sim)
270 {
271 modem->setSim(QDBusObjectPath("/"));
272 }
273 else
274 {
275 modem->setSim(m_sims[sim->imsi()]->path());
276 }
277 }
278
169 void updateNetworkingStatus()279 void updateNetworkingStatus()
170 {280 {
171 QStringList changed;281 QStringList changed;
@@ -293,10 +403,17 @@
293 connect(d->m_manager.get(), &Manager::hotspotAuthChanged, d.get(), &Private::hotspotAuthUpdated);403 connect(d->m_manager.get(), &Manager::hotspotAuthChanged, d.get(), &Private::hotspotAuthUpdated);
294 connect(d->m_manager.get(), &Manager::hotspotStoredChanged, d.get(), &Private::hotspotStoredUpdated);404 connect(d->m_manager.get(), &Manager::hotspotStoredChanged, d.get(), &Private::hotspotStoredUpdated);
295405
406 connect(d->m_manager.get(), &Manager::mobileDataEnabledChanged, d.get(), &Private::mobileDataEnabledUpdated);
407 connect(d->m_manager.get(), &Manager::simsChanged, d.get(), &Private::updateSims);
408 connect(d->m_manager.get(), &Manager::modemsChanged, d.get(), &Private::updateModems);
409 connect(d->m_manager.get(), &Manager::simForMobileDataChanged, d.get(), &Private::simForMobileDataUpdated);
410
296 connect(d->m_manager.get(), &Manager::reportError, d->m_privateService.get(), &PrivateService::ReportError);411 connect(d->m_manager.get(), &Manager::reportError, d->m_privateService.get(), &PrivateService::ReportError);
297412
298 connect(d->m_vpnManager.get(), &vpn::VpnManager::connectionsChanged, d.get(), &Private::updateVpnList);413 connect(d->m_vpnManager.get(), &vpn::VpnManager::connectionsChanged, d.get(), &Private::updateVpnList);
299414
415 d->updateSims();
416 d->updateModems();
300 d->updateNetworkingStatus();417 d->updateNetworkingStatus();
301 d->updateVpnList();418 d->updateVpnList();
302419
@@ -508,6 +625,74 @@
508 return paths;625 return paths;
509}626}
510627
628bool PrivateService::mobileDataEnabled() const
629{
630 return p.d->m_manager->mobileDataEnabled();
631}
632
633void PrivateService::setMobileDataEnabled(bool enabled)
634{
635 p.d->m_manager->setMobileDataEnabled(enabled);
636}
637
638QDBusObjectPath PrivateService::simForMobileData() const
639{
640 wwan::Sim::Ptr sim = p.d->m_manager->simForMobileData();
641 if (!sim)
642 {
643 return QDBusObjectPath("/");
644 }
645
646 Q_ASSERT(p.d->m_sims.contains(sim->imsi()));
647 return p.d->m_sims[sim->imsi()]->path();
648}
649
650void PrivateService::setSimForMobileData(const QDBusObjectPath &path)
651{
652 if (path.path() == "/")
653 {
654 p.d->m_manager->setSimForMobileData(wwan::Sim::Ptr());
655 return;
656 }
657
658 bool found = false;
659 for (DBusSim::SPtr dbussim: p.d->m_sims)
660 {
661 if (dbussim->path() == path)
662 {
663 found = true;
664 p.d->m_manager->setSimForMobileData(dbussim->sim());
665 }
666 }
667
668 if (!found)
669 {
670 sendErrorReply(QDBusError::UnknownObject);
671 }
672}
673
674QList<QDBusObjectPath> PrivateService::modems() const
675{
676 auto list = QList<QDBusObjectPath>();
677 for (DBusModem::SPtr modem : p.d->m_modems)
678 {
679 list << modem->path();
680 }
681 qDebug() << "FGHJKLKJHG " << list.length();
682 return list;
683}
684
685QList<QDBusObjectPath> PrivateService::sims() const
686{
687 QList<QDBusObjectPath> paths;
688
689 for (auto dbussim : p.d->m_sims)
690 {
691 paths.append(dbussim->path());
692 }
693 return paths;
694}
695
511}696}
512697
513#include "connectivity-service.moc"698#include "connectivity-service.moc"
514699
=== modified file 'src/indicator/connectivity-service/connectivity-service.h'
--- src/indicator/connectivity-service/connectivity-service.h 2015-12-04 13:18:04 +0000
+++ src/indicator/connectivity-service/connectivity-service.h 2016-04-26 11:24:03 +0000
@@ -109,6 +109,18 @@
109 Q_PROPERTY(QList<QDBusObjectPath> VpnConnections READ vpnConnections)109 Q_PROPERTY(QList<QDBusObjectPath> VpnConnections READ vpnConnections)
110 QList<QDBusObjectPath> vpnConnections() const;110 QList<QDBusObjectPath> vpnConnections() const;
111111
112 Q_PROPERTY(bool MobileDataEnabled READ mobileDataEnabled WRITE setMobileDataEnabled)
113 bool mobileDataEnabled() const;
114
115 Q_PROPERTY(QDBusObjectPath SimForMobileData READ simForMobileData WRITE setSimForMobileData)
116 QDBusObjectPath simForMobileData() const;
117
118 Q_PROPERTY(QList<QDBusObjectPath> Modems READ modems)
119 QList<QDBusObjectPath> modems() const;
120
121 Q_PROPERTY(QList<QDBusObjectPath> Sims READ sims)
122 QList<QDBusObjectPath> sims() const;
123
112protected Q_SLOTS:124protected Q_SLOTS:
113 void UnlockAllModems();125 void UnlockAllModems();
114126
@@ -132,6 +144,11 @@
132144
133 void RemoveVpnConnection(const QDBusObjectPath &path);145 void RemoveVpnConnection(const QDBusObjectPath &path);
134146
147 void setMobileDataEnabled(bool enabled);
148
149 void setSimForMobileData(const QDBusObjectPath &path);
150
151
135Q_SIGNALS:152Q_SIGNALS:
136 void ReportError(int reason);153 void ReportError(int reason);
137154
138155
=== added file 'src/indicator/connectivity-service/dbus-modem.cpp'
--- src/indicator/connectivity-service/dbus-modem.cpp 1970-01-01 00:00:00 +0000
+++ src/indicator/connectivity-service/dbus-modem.cpp 2016-04-26 11:24:03 +0000
@@ -0,0 +1,98 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include <connectivity-service/dbus-modem.h>
21#include <ModemAdaptor.h>
22#include <dbus-types.h>
23#include <util/dbus-utils.h>
24
25using namespace std;
26using namespace nmofono::wwan;
27
28namespace connectivity_service
29{
30
31DBusModem::DBusModem(Modem::Ptr modem,
32 const QDBusConnection& connection) :
33 m_modem(modem),
34 m_connection(connection)
35{
36 m_path.setPath(DBusTypes::modemPath(m_modem->serial()));
37
38 new ModemAdaptor(this);
39
40 registerDBusObject();
41}
42
43DBusModem::~DBusModem()
44{
45}
46
47void DBusModem::registerDBusObject()
48{
49 if (!m_connection.registerObject(m_path.path(), this))
50 {
51 qWarning() << "Unable to register Modem object" << m_path.path();
52 }
53}
54
55void DBusModem::notifyProperties(const QStringList& propertyNames)
56{
57 DBusUtils::notifyPropertyChanged(
58 m_connection,
59 *this,
60 m_path.path(),
61 ModemAdaptor::staticMetaObject.classInfo(ModemAdaptor::staticMetaObject.indexOfClassInfo("D-Bus Interface")).value(),
62 propertyNames
63 );
64}
65
66QDBusObjectPath DBusModem::sim() const
67{
68 return m_simpath;
69}
70
71void DBusModem::setSim(QDBusObjectPath path)
72{
73 if (m_simpath == path)
74 {
75 return;
76 }
77 m_simpath = path;
78 notifyProperties({"Sim"});
79}
80
81int DBusModem::index() const
82{
83 return m_modem->index();
84}
85
86
87QString DBusModem::serial() const
88{
89 return m_modem->serial();
90}
91
92QDBusObjectPath
93DBusModem::path() const
94{
95 return m_path;
96}
97
98}
099
=== added file 'src/indicator/connectivity-service/dbus-modem.h'
--- src/indicator/connectivity-service/dbus-modem.h 1970-01-01 00:00:00 +0000
+++ src/indicator/connectivity-service/dbus-modem.h 2016-04-26 11:24:03 +0000
@@ -0,0 +1,83 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#pragma once
21
22#include <nmofono/wwan/modem.h>
23
24#include <QDBusConnection>
25#include <QDBusContext>
26#include <QDBusObjectPath>
27#include <QObject>
28#include <QString>
29
30#include <unity/util/DefinesPtrs.h>
31
32class ModemAdaptor;
33
34namespace connectivity_service
35{
36
37class DBusModem: public QObject, protected QDBusContext
38{
39 Q_OBJECT
40 Q_DISABLE_COPY(DBusModem)
41
42 friend ModemAdaptor;
43
44public:
45 UNITY_DEFINES_PTRS(DBusModem);
46
47 DBusModem(nmofono::wwan::Modem::Ptr modem, const QDBusConnection& connection);
48
49 virtual ~DBusModem();
50
51 Q_PROPERTY(int Index READ index)
52 int index() const;
53
54 Q_PROPERTY(QString Serial READ serial)
55 QString serial() const;
56
57 Q_PROPERTY(QDBusObjectPath Sim READ sim)
58 QDBusObjectPath sim() const;
59
60 void setSim(QDBusObjectPath path);
61
62 QDBusObjectPath path() const;
63
64Q_SIGNALS:
65
66protected Q_SLOTS:
67
68private:
69 void notifyProperties(const QStringList& propertyNames);
70
71protected:
72 void registerDBusObject();
73
74 nmofono::wwan::Modem::Ptr m_modem;
75
76 QDBusConnection m_connection;
77
78 QDBusObjectPath m_path;
79 QDBusObjectPath m_simpath;
80
81};
82
83}
084
=== added file 'src/indicator/connectivity-service/dbus-sim.cpp'
--- src/indicator/connectivity-service/dbus-sim.cpp 1970-01-01 00:00:00 +0000
+++ src/indicator/connectivity-service/dbus-sim.cpp 2016-04-26 11:24:03 +0000
@@ -0,0 +1,149 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Pete Woods <pete.woods@canonical.com>
18 */
19
20#include <connectivity-service/dbus-sim.h>
21#include <SimAdaptor.h>
22#include <dbus-types.h>
23#include <util/dbus-utils.h>
24
25#include <QDebug>
26
27using namespace std;
28using namespace nmofono::wwan;
29
30namespace connectivity_service
31{
32
33DBusSim::DBusSim(Sim::Ptr sim,
34 const QDBusConnection& connection) :
35 m_sim(sim),
36 m_connection(connection)
37{
38 m_path.setPath(DBusTypes::simPath(m_sim->imsi()));
39
40 new SimAdaptor(this);
41
42 registerDBusObject();
43
44 connect(sim.get(), &Sim::lockedChanged, this, &DBusSim::lockedChanged);
45 connect(sim.get(), &Sim::presentChanged, this, &DBusSim::presentChanged);
46 connect(sim.get(), &Sim::dataRoamingEnabledChanged, this, &DBusSim::dataRoamingEnabledChanged);
47}
48
49DBusSim::~DBusSim()
50{
51}
52
53QDBusObjectPath DBusSim::path() const
54{
55 return m_path;
56}
57
58void DBusSim::registerDBusObject()
59{
60 if (!m_connection.registerObject(m_path.path(), this))
61 {
62 qWarning() << "Unable to register SIM object" << m_path.path();
63 }
64}
65
66void DBusSim::notifyProperties(const QStringList& propertyNames)
67{
68 DBusUtils::notifyPropertyChanged(
69 m_connection,
70 *this,
71 m_path.path(),
72 SimAdaptor::staticMetaObject.classInfo(SimAdaptor::staticMetaObject.indexOfClassInfo("D-Bus Interface")).value(),
73 propertyNames
74 );
75}
76
77QString DBusSim::imsi() const
78{
79 return m_sim->imsi();
80}
81
82QString DBusSim::primaryPhoneNumber() const
83{
84 return m_sim->primaryPhoneNumber();
85}
86
87bool DBusSim::locked() const
88{
89 return false;
90}
91
92bool DBusSim::present() const
93{
94 return m_sim->present();
95}
96
97QString DBusSim::mcc() const
98{
99 return m_sim->mcc();
100}
101
102QString DBusSim::mnc() const
103{
104 return m_sim->mnc();
105}
106
107QStringList DBusSim::preferredLanguages() const
108{
109 return m_sim->preferredLanguages();
110}
111
112bool DBusSim::dataRoamingEnabled() const
113{
114 return m_sim->dataRoamingEnabled();
115}
116
117void DBusSim::setDataRoamingEnabled(bool value) const
118{
119 m_sim->setDataRoamingEnabled(value);
120}
121
122void DBusSim::Unlock()
123{
124 m_sim->unlock();
125}
126
127void DBusSim::lockedChanged()
128{
129 notifyProperties({"Locked"});
130}
131
132void DBusSim::presentChanged()
133{
134 notifyProperties({"Present"});
135}
136
137void DBusSim::dataRoamingEnabledChanged()
138{
139 qDebug() << "DATAROAMINGENABLEDCHANGED";
140 notifyProperties({"DataRoamingEnabled"});
141}
142
143nmofono::wwan::Sim::Ptr DBusSim::sim() const
144{
145 return m_sim;
146}
147
148
149}
0150
=== added file 'src/indicator/connectivity-service/dbus-sim.h'
--- src/indicator/connectivity-service/dbus-sim.h 1970-01-01 00:00:00 +0000
+++ src/indicator/connectivity-service/dbus-sim.h 2016-04-26 11:24:03 +0000
@@ -0,0 +1,103 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#pragma once
21
22#include <nmofono/wwan/sim.h>
23
24#include <QDBusConnection>
25#include <QDBusContext>
26#include <QDBusObjectPath>
27#include <QObject>
28#include <QString>
29
30#include <unity/util/DefinesPtrs.h>
31
32class SimAdaptor;
33
34namespace connectivity_service
35{
36
37class DBusSim: public QObject, protected QDBusContext
38{
39 Q_OBJECT
40 Q_DISABLE_COPY(DBusSim)
41
42 friend SimAdaptor;
43
44public:
45 UNITY_DEFINES_PTRS(DBusSim);
46
47 DBusSim(nmofono::wwan::Sim::Ptr sim, const QDBusConnection& connection);
48
49 virtual ~DBusSim();
50
51 Q_PROPERTY(QString Imsi READ imsi)
52 QString imsi() const;
53
54 Q_PROPERTY(QString PrimaryPhoneNumber READ primaryPhoneNumber)
55 QString primaryPhoneNumber() const;
56
57 Q_PROPERTY(bool Locked READ locked)
58 bool locked() const;
59
60 Q_PROPERTY(bool Present READ present)
61 bool present() const;
62
63 Q_PROPERTY(QString Mcc READ mcc)
64 QString mcc() const;
65
66 Q_PROPERTY(QString Mnc READ mnc)
67 QString mnc() const;
68
69 Q_PROPERTY(QStringList PreferredLanguages READ preferredLanguages)
70 QStringList preferredLanguages() const;
71
72 Q_PROPERTY(bool DataRoamingEnabled READ dataRoamingEnabled WRITE setDataRoamingEnabled)
73 bool dataRoamingEnabled() const;
74 void setDataRoamingEnabled(bool value) const;
75
76 QDBusObjectPath path() const;
77
78 nmofono::wwan::Sim::Ptr sim() const;
79
80Q_SIGNALS:
81
82protected Q_SLOTS:
83
84 void Unlock();
85
86 void lockedChanged();
87 void presentChanged();
88 void dataRoamingEnabledChanged();
89
90private:
91 void notifyProperties(const QStringList& propertyNames);
92
93protected:
94 void registerDBusObject();
95
96 nmofono::wwan::Sim::Ptr m_sim;
97
98 QDBusConnection m_connection;
99
100 QDBusObjectPath m_path;
101};
102
103}
0104
=== modified file 'src/indicator/factory.cpp'
--- src/indicator/factory.cpp 2016-02-15 09:31:38 +0000
+++ src/indicator/factory.cpp 2016-04-26 11:24:03 +0000
@@ -155,9 +155,9 @@
155 return make_unique<QuickAccessSection>(d->singletonNmofono(), flightModeSwitch);155 return make_unique<QuickAccessSection>(d->singletonNmofono(), flightModeSwitch);
156}156}
157157
158unique_ptr<WwanSection> Factory::newWwanSection(SwitchItem::Ptr hotspotSwitch)158unique_ptr<WwanSection> Factory::newWwanSection(SwitchItem::Ptr mobileDataSwitch, SwitchItem::Ptr hotspotSwitch)
159{159{
160 return make_unique<WwanSection>(d->singletonNmofono(), hotspotSwitch);160 return make_unique<WwanSection>(d->singletonNmofono(), mobileDataSwitch, hotspotSwitch);
161}161}
162162
163unique_ptr<VpnSection> Factory::newVpnSection()163unique_ptr<VpnSection> Factory::newVpnSection()
@@ -203,6 +203,16 @@
203 return flightModeSwitch;203 return flightModeSwitch;
204}204}
205205
206SwitchItem::UPtr Factory::newMobileDataSwitch()
207{
208 auto s = make_unique<SwitchItem>(_("Cellular data"), "mobiledata", "enabled");
209 auto manager = d->singletonNmofono();
210 //s->setState(manager->flightMode());
211 //QObject::connect(manager.get(), &nmofono::Manager::flightModeUpdated, flightModeSwitch.get(), &SwitchItem::setState);
212 //QObject::connect(flightModeSwitch.get(), &SwitchItem::stateUpdated, manager.get(), &nmofono::Manager::setFlightMode);
213 return s;
214}
215
206SwitchItem::UPtr Factory::newHotspotSwitch()216SwitchItem::UPtr Factory::newHotspotSwitch()
207{217{
208 // TODO Move this into a new class218 // TODO Move this into a new class
209219
=== modified file 'src/indicator/factory.h'
--- src/indicator/factory.h 2016-02-15 09:31:38 +0000
+++ src/indicator/factory.h 2016-04-26 11:24:03 +0000
@@ -56,7 +56,7 @@
5656
57 virtual std::unique_ptr<QuickAccessSection> newQuickAccessSection(SwitchItem::Ptr flightModeSwitch);57 virtual std::unique_ptr<QuickAccessSection> newQuickAccessSection(SwitchItem::Ptr flightModeSwitch);
5858
59 virtual std::unique_ptr<WwanSection> newWwanSection(SwitchItem::Ptr hotspotSwitch);59 virtual std::unique_ptr<WwanSection> newWwanSection(SwitchItem::Ptr mobileDataSwitch, SwitchItem::Ptr hotspotSwitch);
6060
61 virtual std::unique_ptr<WifiSection> newWiFiSection(SwitchItem::Ptr wifiSwitch);61 virtual std::unique_ptr<WifiSection> newWiFiSection(SwitchItem::Ptr wifiSwitch);
6262
@@ -68,6 +68,8 @@
6868
69 virtual SwitchItem::UPtr newWifiSwitch();69 virtual SwitchItem::UPtr newWifiSwitch();
7070
71 virtual SwitchItem::UPtr newMobileDataSwitch();
72
71 virtual SwitchItem::UPtr newFlightModeSwitch();73 virtual SwitchItem::UPtr newFlightModeSwitch();
7274
73 virtual SwitchItem::UPtr newHotspotSwitch();75 virtual SwitchItem::UPtr newHotspotSwitch();
7476
=== modified file 'src/indicator/menu-builder.cpp'
--- src/indicator/menu-builder.cpp 2015-10-06 10:14:57 +0000
+++ src/indicator/menu-builder.cpp 2016-04-26 11:24:03 +0000
@@ -43,6 +43,7 @@
43 RootState::Ptr m_rootState;43 RootState::Ptr m_rootState;
4444
45 SwitchItem::Ptr m_flightModeSwitch;45 SwitchItem::Ptr m_flightModeSwitch;
46 SwitchItem::Ptr m_mobileDataSwitch;
46 SwitchItem::Ptr m_hotspotSwitch;47 SwitchItem::Ptr m_hotspotSwitch;
47 SwitchItem::Ptr m_wifiSwitch;48 SwitchItem::Ptr m_wifiSwitch;
4849
@@ -111,6 +112,7 @@
111 d->m_ubiquityMenu = factory.newIndicatorMenu(d->m_rootState, "ubiquity");112 d->m_ubiquityMenu = factory.newIndicatorMenu(d->m_rootState, "ubiquity");
112113
113 d->m_flightModeSwitch = factory.newFlightModeSwitch();114 d->m_flightModeSwitch = factory.newFlightModeSwitch();
115 d->m_mobileDataSwitch = factory.newMobileDataSwitch();
114 d->m_hotspotSwitch = factory.newHotspotSwitch();116 d->m_hotspotSwitch = factory.newHotspotSwitch();
115 d->m_wifiSwitch = factory.newWifiSwitch();117 d->m_wifiSwitch = factory.newWifiSwitch();
116118
@@ -125,7 +127,7 @@
125 d.get(), &Priv::updateHotspotSwitch);127 d.get(), &Priv::updateHotspotSwitch);
126128
127 d->m_quickAccessSection = factory.newQuickAccessSection(d->m_flightModeSwitch);129 d->m_quickAccessSection = factory.newQuickAccessSection(d->m_flightModeSwitch);
128 d->m_wwanSection = factory.newWwanSection(d->m_hotspotSwitch);130 d->m_wwanSection = factory.newWwanSection(d->m_mobileDataSwitch, d->m_hotspotSwitch);
129 d->m_wifiSection = factory.newWiFiSection(d->m_wifiSwitch);131 d->m_wifiSection = factory.newWiFiSection(d->m_wifiSwitch);
130 d->m_vpnSection = factory.newVpnSection();132 d->m_vpnSection = factory.newVpnSection();
131133
132134
=== modified file 'src/indicator/nmofono/manager-impl.cpp'
--- src/indicator/nmofono/manager-impl.cpp 2016-04-06 09:30:45 +0000
+++ src/indicator/nmofono/manager-impl.cpp 2016-04-26 11:24:03 +0000
@@ -20,6 +20,7 @@
2020
21#include <nmofono/manager-impl.h>21#include <nmofono/manager-impl.h>
22#include <nmofono/wifi/wifi-link-impl.h>22#include <nmofono/wifi/wifi-link-impl.h>
23#include <nmofono/wwan/sim-manager.h>
23#include <NetworkManagerActiveConnectionInterface.h>24#include <NetworkManagerActiveConnectionInterface.h>
24#include <NetworkManagerDeviceInterface.h>25#include <NetworkManagerDeviceInterface.h>
25#include <NetworkManagerInterface.h>26#include <NetworkManagerInterface.h>
@@ -30,6 +31,7 @@
30#include <qofono-qt5/qofonomanager.h>31#include <qofono-qt5/qofonomanager.h>
31#include <qofono-qt5/qofonomodem.h>32#include <qofono-qt5/qofonomodem.h>
32#undef slots33#undef slots
34#include <ofono/dbus.h>
3335
34#include <notify-cpp/notification-manager.h>36#include <notify-cpp/notification-manager.h>
35#include <notify-cpp/snapdecision/sim-unlock.h>37#include <notify-cpp/snapdecision/sim-unlock.h>
@@ -39,6 +41,7 @@
39#include <QMap>41#include <QMap>
40#include <QList>42#include <QList>
41#include <QRegularExpression>43#include <QRegularExpression>
44#include <QSettings>
42#include <NetworkManager.h>45#include <NetworkManager.h>
43#include <QDebug>46#include <QDebug>
44#include <algorithm>47#include <algorithm>
@@ -76,9 +79,113 @@
7679
77 HotspotManager::SPtr m_hotspotManager;80 HotspotManager::SPtr m_hotspotManager;
7881
82 bool m_mobileDataEnabled = false;
83 bool m_mobileDataEnabledPending = false;
84
85 wwan::Sim::Ptr m_simForMobileData;
86 bool m_simForMobileDataPending = false;
87
88 QList<wwan::Modem::Ptr> m_modems;
89 QList<wwan::Sim::Ptr> m_sims;
90
91 wwan::SimManager::Ptr m_simManager;
92
93 QSettings *m_settings;
94
79 Private(Manager& parent) :95 Private(Manager& parent) :
80 p(parent)96 p(parent)
81 {97 {
98 m_simManager = make_shared<wwan::SimManager>();
99 m_sims = m_simManager->knownSims();
100 connect(m_simManager.get(), &wwan::SimManager::simAdded, this, &Private::simAdded);
101
102 m_settings = new QSettings(QSettings::IniFormat,
103 QSettings::UserScope,
104 "Ubuntu",
105 "connectivityservice",
106 this);
107 QVariant ret = m_settings->value("MobileDataEnabled");
108 if (ret.isNull())
109 {
110 /* This is the first time we are running on a system.
111 *
112 * We need to figure out the status of mobile data from looking
113 * at the individual modems.
114 */
115 m_mobileDataEnabledPending = true;
116 m_settings->setValue("MobileDataEnabled", true);
117 }
118 else
119 {
120 m_mobileDataEnabled = ret.toBool();
121 }
122
123 ret = m_settings->value("SimForMobileData");
124 if (ret.isNull())
125 {
126 /* This is the first time we are running on a system.
127 *
128 * We need to figure out the SIM used for mobile data
129 * from the individual modems.
130 */
131 m_simForMobileDataPending = true;
132 m_settings->setValue("SimForMobileData", QString());
133 }
134 else
135 {
136 QString imsi = ret.toString();
137 wwan::Sim::Ptr sim;
138 for(auto i = m_sims.begin(); i != m_sims.end(); i++)
139 {
140 if ((*i)->imsi() == imsi) {
141 sim = *i;
142 break;
143 }
144 }
145 m_simForMobileData = sim;
146 }
147
148 }
149
150 void matchModemsAndSims()
151 {
152 for (wwan::Modem::Ptr modem: m_modems)
153 {
154 bool match = false;
155 for(wwan::Sim::Ptr sim : m_sims)
156 {
157 if (sim->ofonoPath() == modem->ofonoPath())
158 {
159 match = true;
160 modem->setSim(sim);
161 break;
162 }
163 }
164 if (!match)
165 {
166 modem->setSim(wwan::Sim::Ptr());
167 }
168 }
169 }
170
171 void simAdded(wwan::Sim::Ptr sim)
172 {
173 m_sims.append(sim);
174 matchModemsAndSims();
175 Q_EMIT p.simsChanged();
176 }
177
178 void modemReady()
179 {
180 wwan::Modem *modem_raw = qobject_cast<wwan::Modem*>(sender());
181 if (!modem_raw)
182 {
183 qWarning() << "modem cast failed.";
184 return;
185 }
186 m_modems.append(m_ofonoLinks[modem_raw->name()]);
187 matchModemsAndSims();
188 Q_EMIT p.modemsChanged();
82 }189 }
83190
84 void setUnstoppableOperationHappening(bool happening)191 void setUnstoppableOperationHappening(bool happening)
@@ -192,6 +299,8 @@
192 m_pendingUnlocks.removeOne(modem);299 m_pendingUnlocks.removeOne(modem);
193 disconnect(modem.get(), &wwan::Modem::readyToUnlock, this, &Private::modemReadyToUnlock);300 disconnect(modem.get(), &wwan::Modem::readyToUnlock, this, &Private::modemReadyToUnlock);
194 }301 }
302 m_modems.removeAll(modem);
303 Q_EMIT p.modemsChanged();
195 }304 }
196305
197 for (const auto& path : toAdd)306 for (const auto& path : toAdd)
@@ -202,6 +311,7 @@
202 auto modem = make_shared<wwan::Modem>(modemInterface);311 auto modem = make_shared<wwan::Modem>(modemInterface);
203 m_ofonoLinks[path] = modem;312 m_ofonoLinks[path] = modem;
204 connect(modem.get(), &wwan::Modem::readyToUnlock, this, &Private::modemReadyToUnlock);313 connect(modem.get(), &wwan::Modem::readyToUnlock, this, &Private::modemReadyToUnlock);
314 connect(modem.get(), &wwan::Modem::ready, this, &Private::modemReady);
205 }315 }
206316
207 Q_EMIT p.linksUpdated();317 Q_EMIT p.linksUpdated();
@@ -209,6 +319,69 @@
209319
210 updateModemAvailable();320 updateModemAvailable();
211 }321 }
322
323 void setMobileDataEnabled(bool value) {
324 if (m_mobileDataEnabled == value)
325 {
326 return;
327 }
328
329 m_settings->setValue("MobileDataEnabled", value);
330 m_settings->sync();
331
332 m_mobileDataEnabled = value;
333 Q_EMIT p.mobileDataEnabledChanged(value);
334
335 if (m_mobileDataEnabled)
336 {
337 for (wwan::Modem::Ptr modem : m_modems)
338 {
339 if (modem->sim() && modem->sim() == m_simForMobileData)
340 {
341 modem->sim()->setMobileDataEnabled(true);
342 }
343 }
344 }
345 else
346 {
347 for (wwan::Modem::Ptr modem : m_modems)
348 {
349 if (modem->sim()) {
350 modem->sim()->setMobileDataEnabled(false);
351 }
352 }
353 }
354 }
355
356 void setSimForMobileData(wwan::Sim::Ptr sim) {
357 if (m_simForMobileData == sim)
358 {
359 return;
360 }
361
362 if (m_simForMobileData)
363 {
364 m_simForMobileData->setMobileDataEnabled(false);
365 }
366
367 if (!sim)
368 {
369 m_settings->setValue("SimForMobileData", "");
370 }
371 else
372 {
373 m_settings->setValue("SimForMobileData", sim->imsi());
374 }
375 m_settings->sync();
376
377 m_simForMobileData = sim;
378 if (m_simForMobileData)
379 {
380 m_simForMobileData->setMobileDataEnabled(true);
381 }
382
383 Q_EMIT p.simForMobileDataChanged();
384 }
212};385};
213386
214void387void
@@ -652,6 +825,43 @@
652 d->m_hotspotManager->setAuth(auth);825 d->m_hotspotManager->setAuth(auth);
653}826}
654827
828bool
829ManagerImpl::mobileDataEnabled() const
830{
831 return d->m_mobileDataEnabled;
832}
833
834void
835ManagerImpl::setMobileDataEnabled(bool value)
836{
837 d->setMobileDataEnabled(value);
838}
839
840wwan::Sim::Ptr
841ManagerImpl::simForMobileData() const
842{
843 return d->m_simForMobileData;
844}
845
846void
847ManagerImpl::setSimForMobileData(wwan::Sim::Ptr sim)
848{
849 d->setSimForMobileData(sim);
850}
851
852QList<wwan::Modem::Ptr>
853ManagerImpl::modems() const
854{
855 return d->m_modems;
856}
857
858QList<wwan::Sim::Ptr>
859ManagerImpl::sims() const
860{
861 return d->m_sims;
862}
863
864
655}865}
656866
657#include "manager-impl.moc"867#include "manager-impl.moc"
658868
=== modified file 'src/indicator/nmofono/manager-impl.h'
--- src/indicator/nmofono/manager-impl.h 2015-10-06 10:19:30 +0000
+++ src/indicator/nmofono/manager-impl.h 2016-04-26 11:24:03 +0000
@@ -91,6 +91,14 @@
9191
92 QString hotspotAuth() const override;92 QString hotspotAuth() const override;
9393
94 bool mobileDataEnabled() const override;
95
96 wwan::Sim::Ptr simForMobileData() const override;
97
98 QList<wwan::Modem::Ptr> modems() const override;
99
100 QList<wwan::Sim::Ptr> sims() const override;
101
94 void setHotspotEnabled(bool) override;102 void setHotspotEnabled(bool) override;
95103
96 void setHotspotSsid(const QByteArray&) override;104 void setHotspotSsid(const QByteArray&) override;
@@ -101,6 +109,10 @@
101109
102 void setHotspotAuth(const QString&) override;110 void setHotspotAuth(const QString&) override;
103111
112 void setMobileDataEnabled(bool) override;
113
114 void setSimForMobileData(wwan::Sim::Ptr) override;
115
104private Q_SLOTS:116private Q_SLOTS:
105 void device_added(const QDBusObjectPath &path);117 void device_added(const QDBusObjectPath &path);
106 void device_removed(const QDBusObjectPath &path);118 void device_removed(const QDBusObjectPath &path);
107119
=== modified file 'src/indicator/nmofono/manager.h'
--- src/indicator/nmofono/manager.h 2015-09-15 12:35:22 +0000
+++ src/indicator/nmofono/manager.h 2016-04-26 11:24:03 +0000
@@ -23,6 +23,7 @@
23#include <nmofono/link.h>23#include <nmofono/link.h>
24#include <nmofono/wifi/wifi-link.h>24#include <nmofono/wifi/wifi-link.h>
25#include <nmofono/wwan/modem.h>25#include <nmofono/wwan/modem.h>
26#include <nmofono/wwan/sim.h>
2627
27#include <memory>28#include <memory>
28#include <QSet>29#include <QSet>
@@ -143,6 +144,19 @@
143 Q_PROPERTY(QString hotspotAuth READ hotspotAuth WRITE setHotspotAuth NOTIFY hotspotAuthChanged)144 Q_PROPERTY(QString hotspotAuth READ hotspotAuth WRITE setHotspotAuth NOTIFY hotspotAuthChanged)
144 virtual QString hotspotAuth() const = 0;145 virtual QString hotspotAuth() const = 0;
145146
147 Q_PROPERTY(bool mobileDataEnabled READ mobileDataEnabled WRITE setMobileDataEnabled NOTIFY mobileDataEnabledChanged)
148 virtual bool mobileDataEnabled() const = 0;
149
150 Q_PROPERTY(wwan::Sim::Ptr simForMobileData READ simForMobileData WRITE setSimForMobileData NOTIFY simForMobileDataChanged)
151 virtual wwan::Sim::Ptr simForMobileData() const = 0;
152
153 Q_PROPERTY(QList<wwan::Modem::Ptr> modems READ modems NOTIFY modemsChanged)
154 virtual QList<wwan::Modem::Ptr> modems() const = 0;
155
156 Q_PROPERTY(QList<wwan::Sim::Ptr> sims READ sims NOTIFY simsChanged)
157 virtual QList<wwan::Sim::Ptr> sims() const = 0;
158
159
146Q_SIGNALS:160Q_SIGNALS:
147 void flightModeUpdated(bool);161 void flightModeUpdated(bool);
148162
@@ -174,6 +188,14 @@
174188
175 void unstoppableOperationHappeningUpdated(bool);189 void unstoppableOperationHappeningUpdated(bool);
176190
191 void mobileDataEnabledChanged(bool);
192
193 void simForMobileDataChanged();
194
195 void modemsChanged();
196
197 void simsChanged();
198
177public Q_SLOTS:199public Q_SLOTS:
178 virtual void setWifiEnabled(bool) = 0;200 virtual void setWifiEnabled(bool) = 0;
179201
@@ -189,6 +211,10 @@
189211
190 virtual void setHotspotAuth(const QString&) = 0;212 virtual void setHotspotAuth(const QString&) = 0;
191213
214 virtual void setMobileDataEnabled(bool) = 0;
215
216 virtual void setSimForMobileData(wwan::Sim::Ptr) = 0;
217
192protected:218protected:
193 /**219 /**
194 * @brief The default constructor is protected.220 * @brief The default constructor is protected.
195221
=== modified file 'src/indicator/nmofono/wwan/modem.cpp'
--- src/indicator/nmofono/wwan/modem.cpp 2015-08-05 15:14:28 +0000
+++ src/indicator/nmofono/wwan/modem.cpp 2016-04-26 11:24:03 +0000
@@ -96,6 +96,10 @@
96 bool m_requiredPinSet = false;96 bool m_requiredPinSet = false;
97 bool m_retriesSet = false;97 bool m_retriesSet = false;
9898
99 QString m_serial;
100 bool m_serialSet = false;
101 bool m_readyFired = false;
102
99 QString m_operatorName;103 QString m_operatorName;
100 Modem::ModemStatus m_status;104 Modem::ModemStatus m_status;
101 int8_t m_strength;105 int8_t m_strength;
@@ -108,6 +112,8 @@
108112
109 QSet<QString> m_interfaces;113 QSet<QString> m_interfaces;
110114
115 Sim::Ptr m_sim;
116
111 shared_ptr<QOfonoConnectionManager> m_connectionManager;117 shared_ptr<QOfonoConnectionManager> m_connectionManager;
112 shared_ptr<QOfonoNetworkRegistration> m_networkRegistration;118 shared_ptr<QOfonoNetworkRegistration> m_networkRegistration;
113 shared_ptr<QOfonoSimManager> m_simManager;119 shared_ptr<QOfonoSimManager> m_simManager;
@@ -125,6 +131,9 @@
125 connect(m_ofonoModem.get(), &QOfonoModem::interfacesChanged, this, &Private::interfacesChanged);131 connect(m_ofonoModem.get(), &QOfonoModem::interfacesChanged, this, &Private::interfacesChanged);
126 interfacesChanged(m_ofonoModem->interfaces());132 interfacesChanged(m_ofonoModem->interfaces());
127133
134 connect(m_ofonoModem.get(), &QOfonoModem::serialChanged, this, &Private::serialChanged);
135 serialChanged(m_ofonoModem->serial());
136
128 /// @todo hook up with system-settings to allow changing the identifier.137 /// @todo hook up with system-settings to allow changing the identifier.
129 /// for now just provide the defaults138 /// for now just provide the defaults
130 auto path = m_ofonoModem->modemPath();139 auto path = m_ofonoModem->modemPath();
@@ -154,6 +163,28 @@
154 m_shouldTriggerUnlock = false;163 m_shouldTriggerUnlock = false;
155 Q_EMIT p.readyToUnlock(p.name());164 Q_EMIT p.readyToUnlock(p.name());
156 }165 }
166
167 if (m_serialSet && !m_readyFired)
168 {
169 m_readyFired = true;
170 Q_EMIT p.ready();
171 }
172 }
173
174 void serialChanged(const QString &value) {
175 if (m_serial == value)
176 {
177 return;
178 }
179 if (m_serialSet)
180 {
181 qWarning() << "Unexpected update on SERIAL: " << m_serial << ", " << value;
182 }
183
184 m_serial = value;
185 m_serialSet = true;
186
187 update();
157 }188 }
158189
159 void connectionManagerChanged(shared_ptr<QOfonoConnectionManager> conmgr)190 void connectionManagerChanged(shared_ptr<QOfonoConnectionManager> conmgr)
@@ -662,6 +693,12 @@
662QString693QString
663Modem::name() const694Modem::name() const
664{695{
696 return ofonoPath();
697}
698
699QString
700Modem::ofonoPath() const
701{
665 return d->m_ofonoModem->modemPath();702 return d->m_ofonoModem->modemPath();
666}703}
667704
@@ -725,8 +762,32 @@
725{762{
726 d->m_shouldTriggerUnlock = true;763 d->m_shouldTriggerUnlock = true;
727}764}
728}765
729766Sim::Ptr Modem::sim() const
767{
768 return d->m_sim;
769}
770
771void
772Modem::setSim(Sim::Ptr sim)
773{
774 if (d->m_sim == sim)
775 {
776 return;
777 }
778 d->m_sim = sim;
779 Q_EMIT simUpdated();
780}
781
782QString
783Modem::serial() const
784{
785 return d->m_serial;
786}
787
788
789
790}
730}791}
731792
732#include "modem.moc"793#include "modem.moc"
733794
=== modified file 'src/indicator/nmofono/wwan/modem.h'
--- src/indicator/nmofono/wwan/modem.h 2015-08-05 15:14:28 +0000
+++ src/indicator/nmofono/wwan/modem.h 2016-04-26 11:24:03 +0000
@@ -21,6 +21,8 @@
2121
22#include <nmofono/wwan/wwan-link.h>22#include <nmofono/wwan/wwan-link.h>
2323
24#include <nmofono/wwan/sim.h>
25
24#include <map>26#include <map>
25#include <memory>27#include <memory>
2628
@@ -127,8 +129,12 @@
127 const QString &simIdentifier() const;129 const QString &simIdentifier() const;
128130
129 int index() const;131 int index() const;
132 Sim::Ptr sim() const;
133 void setSim(Sim::Ptr sim);
134 QString serial() const;
130135
131 QString name() const override;136 QString name() const override;
137 QString ofonoPath() const;
132138
133 WwanType wwanType() const override;139 WwanType wwanType() const override;
134140
@@ -176,6 +182,10 @@
176 void resetPinFailed(const QString& error);182 void resetPinFailed(const QString& error);
177183
178 bool readyToUnlock(const QString& name);184 bool readyToUnlock(const QString& name);
185
186 void simUpdated();
187
188 void ready();
179};189};
180190
181}191}
182192
=== added file 'src/indicator/nmofono/wwan/qofono-sim-wrapper.cpp'
--- src/indicator/nmofono/wwan/qofono-sim-wrapper.cpp 1970-01-01 00:00:00 +0000
+++ src/indicator/nmofono/wwan/qofono-sim-wrapper.cpp 2016-04-26 11:24:03 +0000
@@ -0,0 +1,251 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include <nmofono/wwan/qofono-sim-wrapper.h>
21
22#include <ofono/dbus.h>
23
24using namespace std;
25
26namespace nmofono
27{
28namespace wwan
29{
30namespace
31{
32
33}
34
35class QOfonoSimWrapper::Private : public QObject, public std::enable_shared_from_this<Private>
36{
37 Q_OBJECT
38
39public:
40
41 QOfonoSimWrapper& p;
42 shared_ptr<QOfonoSimManager> m_simManager;
43
44 QString m_imsi;
45 QStringList m_phoneNumbers;
46 QString m_mcc;
47 QString m_mnc;
48 QStringList m_preferredLanguages;
49
50 bool m_present = false;
51
52 bool m_imsiSet = false;
53 bool m_phoneNumbersSet = false;
54 bool m_mccSet = false;
55 bool m_mncSet = false;
56 bool m_preferredLanguagesSet = false;
57
58
59 Private(QOfonoSimWrapper& parent, shared_ptr<QOfonoSimManager> simmgr)
60 : p(parent), m_simManager{simmgr}
61 {
62 connect(simmgr.get(), &QOfonoSimManager::presenceChanged, this, &Private::presentChanged);
63 connect(simmgr.get(), &QOfonoSimManager::subscriberIdentityChanged, this, &Private::imsiChanged);
64 connect(simmgr.get(), &QOfonoSimManager::mobileCountryCodeChanged, this, &Private::mccChanged);
65 connect(simmgr.get(), &QOfonoSimManager::mobileNetworkCodeChanged, this, &Private::mncChanged);
66 connect(simmgr.get(), &QOfonoSimManager::subscriberNumbersChanged, this, &Private::phoneNumbersChanged);
67 connect(simmgr.get(), &QOfonoSimManager::preferredLanguagesChanged, this, &Private::preferredLanguagesChanged);
68 }
69
70public Q_SLOTS:
71
72 void presentChanged(bool value)
73 {
74 if (m_present == value)
75 {
76 return;
77 }
78 m_present = value;
79 if (!m_present) {
80 m_imsiSet = false;
81 m_phoneNumbersSet = false;
82 m_mccSet = false;
83 m_mncSet = false;
84 m_preferredLanguagesSet = false;
85 Q_EMIT p.readyChanged(false);
86 }
87 Q_EMIT p.presentChanged(value);
88 }
89
90 void imsiChanged(const QString &value)
91 {
92 if (value.isEmpty())
93 {
94 return;
95 }
96
97 if (m_imsiSet)
98 {
99 qWarning() << "Unexpected update on IMSI: " << m_imsi << ", " << value;
100 }
101
102 m_imsi = value;
103 m_imsiSet = true;
104 if (p.ready())
105 {
106 Q_EMIT p.readyChanged(true);
107 }
108 }
109
110 void mccChanged(const QString &value)
111 {
112 if (value.isEmpty())
113 {
114 return;
115 }
116
117 if (m_mccSet)
118 {
119 qWarning() << "Unexpected update on MCC: " << m_mcc << ", " << value;
120 }
121
122
123 m_mcc = value;
124 m_mccSet = true;
125 if (p.ready())
126 {
127 Q_EMIT p.readyChanged(true);
128 }
129 }
130
131 void mncChanged(const QString &value)
132 {
133 if (value.isEmpty())
134 {
135 return;
136 }
137
138 if (m_mncSet)
139 {
140 qWarning() << "Unexpected update on MNC: " << m_mnc << ", " << value;
141 }
142
143 m_mnc = value;
144 m_mncSet = true;
145 if (p.ready())
146 {
147 Q_EMIT p.readyChanged(true);
148 }
149 }
150
151 void phoneNumbersChanged(const QStringList &value)
152 {
153 if (value.isEmpty())
154 {
155 return;
156 }
157
158 if (m_phoneNumbersSet)
159 {
160 qWarning() << "Unexpected update on Phone Numbers: " << m_phoneNumbers << ", " << value;
161 }
162
163
164 m_phoneNumbers = value;
165 m_phoneNumbersSet = true;
166 if (p.ready())
167 {
168 Q_EMIT p.readyChanged(true);
169 }
170 }
171
172 void preferredLanguagesChanged(const QStringList &value)
173 {
174 if (value.isEmpty())
175 {
176 return;
177 }
178
179 if (m_preferredLanguagesSet)
180 {
181 qWarning() << "Unexpected update on Preferred Languages: " << m_preferredLanguages << ", " << value;
182 }
183
184
185 m_preferredLanguages = value;
186 m_preferredLanguagesSet = true;
187 if (p.ready())
188 {
189 Q_EMIT p.readyChanged(true);
190 }
191 }
192};
193
194
195
196QOfonoSimWrapper::QOfonoSimWrapper(std::shared_ptr<QOfonoSimManager> simmgr)
197 : d{new Private(*this, simmgr)}
198{
199}
200
201QOfonoSimWrapper::~QOfonoSimWrapper()
202{}
203
204QString QOfonoSimWrapper::imsi() const
205{
206 return d->m_imsi;
207}
208
209bool QOfonoSimWrapper::present() const
210{
211 return d->m_present;
212}
213
214QString QOfonoSimWrapper::mcc() const
215{
216 return d->m_mcc;
217}
218
219QString QOfonoSimWrapper::mnc() const
220{
221 return d->m_mnc;
222}
223
224QStringList QOfonoSimWrapper::phoneNumbers() const
225{
226 return d->m_phoneNumbers;
227}
228
229QStringList QOfonoSimWrapper::preferredLanguages() const
230{
231 return d->m_preferredLanguages;
232}
233
234bool QOfonoSimWrapper::ready() const {
235 return d->m_imsiSet &&
236 d->m_phoneNumbersSet &&
237 d->m_mccSet &&
238 d->m_mncSet &&
239 d->m_preferredLanguagesSet;
240}
241
242std::shared_ptr<QOfonoSimManager> QOfonoSimWrapper::ofonoSimManager() const
243{
244 return d->m_simManager;
245}
246
247
248}
249}
250
251#include "qofono-sim-wrapper.moc"
0252
=== added file 'src/indicator/nmofono/wwan/qofono-sim-wrapper.h'
--- src/indicator/nmofono/wwan/qofono-sim-wrapper.h 1970-01-01 00:00:00 +0000
+++ src/indicator/nmofono/wwan/qofono-sim-wrapper.h 2016-04-26 11:24:03 +0000
@@ -0,0 +1,77 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#pragma once
21
22#include <QObject>
23#include <QSettings>
24
25#include <memory>
26
27#define slots
28#include <qofono-qt5/qofonomodem.h>
29#include <qofono-qt5/qofonosimmanager.h>
30#undef slots
31
32class QOfonoModem;
33
34namespace nmofono
35{
36class ManagerImpl;
37
38namespace wwan
39{
40
41class QOfonoSimWrapper : public QObject
42{
43 Q_OBJECT
44
45 class Private;
46 std::shared_ptr<Private> d;
47
48public:
49
50 typedef std::shared_ptr<QOfonoSimWrapper> Ptr;
51 typedef std::weak_ptr<QOfonoSimWrapper> WeakPtr;
52
53 QOfonoSimWrapper() = delete;
54
55
56 QOfonoSimWrapper(std::shared_ptr<QOfonoSimManager> simmgr);
57 ~QOfonoSimWrapper();
58
59 QString imsi() const;
60 bool present() const;
61 QString mcc() const;
62 QString mnc() const;
63 QStringList phoneNumbers() const;
64 QStringList preferredLanguages() const;
65 bool ready() const;
66
67 std::shared_ptr<QOfonoSimManager> ofonoSimManager() const;
68
69
70Q_SIGNALS:
71
72 void presentChanged(bool value);
73 void readyChanged(bool value);
74};
75
76}
77}
078
=== added file 'src/indicator/nmofono/wwan/sim-manager.cpp'
--- src/indicator/nmofono/wwan/sim-manager.cpp 1970-01-01 00:00:00 +0000
+++ src/indicator/nmofono/wwan/sim-manager.cpp 2016-04-26 11:24:03 +0000
@@ -0,0 +1,271 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include <nmofono/wwan/sim-manager.h>
21
22#include <nmofono/wwan/qofono-sim-wrapper.h>
23
24#define slots
25#include <qofono-qt5/qofonomanager.h>
26#include <qofono-qt5/qofonomodem.h>
27#include <qofono-qt5/qofonosimmanager.h>
28#undef slots
29#include <ofono/dbus.h>
30
31using namespace std;
32
33namespace nmofono
34{
35namespace wwan
36{
37namespace
38{
39
40}
41
42class SimManager::Private : public QObject, public std::enable_shared_from_this<Private>
43{
44 Q_OBJECT
45
46public:
47
48 SimManager& p;
49
50 QMap<QString, Sim::Ptr> m_knownSims;
51
52 shared_ptr<QOfonoManager> m_ofono;
53 QMap<QString, shared_ptr<QOfonoModem>> m_ofonoModems;
54 QMap<QString, QOfonoSimWrapper::Ptr> m_wrappers;
55
56 QSettings *m_settings;
57
58 Private(SimManager& parent)
59 : p(parent)
60 {
61 m_settings = new QSettings(QSettings::IniFormat,
62 QSettings::UserScope,
63 "Ubuntu",
64 "connectivityservice",
65 this);
66
67 QVariant ret;
68 ret = m_settings->value("KnownSims");
69 if (ret.isNull())
70 {
71 /* This is the first time we are running on a system.
72 */
73 m_settings->setValue("KnownSims", QVariant(QVariant::StringList));
74 }
75 else
76 {
77 QStringList imsis = ret.toStringList();
78 for(auto imsi : imsis) {
79 auto sim = wwan::Sim::createFromSettings(m_settings, imsi);
80 connect(sim.get(), &Sim::dataRoamingEnabledChanged, this, &Private::simDataRoamingEnabledChanged);
81 if (!sim)
82 {
83 continue;
84 }
85 m_knownSims[sim->imsi()] = sim;
86 }
87 }
88
89 m_ofono = make_shared<QOfonoManager>();
90 connect(m_ofono.get(), &QOfonoManager::modemsChanged, this, &Private::modemsChanged);
91 modemsChanged(m_ofono->modems());
92 }
93
94public Q_SLOTS:
95
96 void modemsChanged(const QStringList& value)
97 {
98 QSet<QString> modemPaths(value.toSet());
99 QSet<QString> currentModemPaths(m_ofonoModems.keys().toSet());
100
101 auto toRemove = currentModemPaths;
102 toRemove.subtract(modemPaths);
103
104 auto toAdd = modemPaths;
105 toAdd.subtract(currentModemPaths);
106
107 for (const auto& path : toRemove)
108 {
109 if (!m_ofonoModems.contains(path))
110 {
111 qWarning("Something went horribly wrong.");
112 continue;
113 }
114 auto modem = m_ofonoModems.take(path);
115 if (m_wrappers.contains(path))
116 {
117 auto wrapper = m_wrappers[path];
118 if (m_knownSims.contains(wrapper->imsi()))
119 {
120 auto sim = m_knownSims[wrapper->imsi()];
121 sim->setOfonoSimManager(std::shared_ptr<QOfonoSimManager>());
122 }
123 m_wrappers.remove(path);
124 }
125 }
126
127 for (const auto& path : toAdd)
128 {
129 auto modem = make_shared<QOfonoModem>();
130 modem->setModemPath(path);
131
132 if (m_ofonoModems.contains(path))
133 {
134 qWarning("Something went horribly wrong.");
135 }
136 m_ofonoModems[path] = modem;
137
138 connect(modem.get(), &QOfonoModem::interfacesChanged, this, &Private::modemInterfacesChanged);
139 // use Q_EMIT to get the sender() set.
140 Q_EMIT modem->interfacesChanged(modem->interfaces());
141 }
142 }
143
144 void modemInterfacesChanged() {
145 QOfonoModem *modem = qobject_cast<QOfonoModem*>(sender());
146 if (!modem)
147 {
148 qWarning() << "Unable to cast sender().";
149 return;
150 }
151
152 QSet<QString> interfaces(modem->interfaces().toSet());
153 if (interfaces.contains(OFONO_SIM_MANAGER_INTERFACE))
154 {
155 if (!m_wrappers.contains(modem->modemPath()))
156 {
157 auto simmgr = make_shared<QOfonoSimManager>();
158 simmgr->setModemPath(modem->modemPath());
159
160 auto wrapper = make_shared<wwan::QOfonoSimWrapper>(simmgr);
161
162 connect(wrapper.get(), &wwan::QOfonoSimWrapper::presentChanged, this, &Private::ofonoSimPresentChanged);
163 connect(wrapper.get(), &wwan::QOfonoSimWrapper::readyChanged, this, &Private::ofonoSimReady);
164
165 m_wrappers[modem->modemPath()] = wrapper;
166 }
167
168 } else {
169 if (m_wrappers.contains(modem->modemPath()))
170 {
171 auto wrapper = m_wrappers[modem->modemPath()];
172 if (m_knownSims.contains(wrapper->imsi()))
173 {
174 auto sim = m_knownSims[wrapper->imsi()];
175 sim->setOfonoSimManager(std::shared_ptr<QOfonoSimManager>());
176 }
177 m_wrappers.remove(modem->modemPath());
178 }
179 }
180 }
181
182 void ofonoSimPresentChanged(bool present)
183 {
184 auto wrapper = qobject_cast<QOfonoSimWrapper*>(sender());
185 if (!wrapper) {
186 qWarning("casting failed.");
187 }
188
189 if (!present) {
190 if (m_knownSims.contains(wrapper->imsi()))
191 {
192 auto sim = m_knownSims[wrapper->imsi()];
193 sim->setOfonoSimManager(std::shared_ptr<QOfonoSimManager>());
194 }
195 }
196 }
197
198 void ofonoSimReady(bool value)
199 {
200 if (!value)
201 {
202 // handled in present changed
203 return;
204 }
205
206 auto wrapper = qobject_cast<wwan::QOfonoSimWrapper*>(sender());
207 if (!wrapper)
208 {
209 qWarning("casting failed.");
210 return;
211 }
212
213 auto wrappers = m_wrappers;
214
215 bool found = false;
216 for (auto i : m_knownSims.values())
217 {
218 if (wrapper->imsi() == i->imsi())
219 {
220 found = true;
221 i->setOfonoSimManager(wrapper->ofonoSimManager());
222 break;
223 }
224 }
225 if (!found)
226 {
227 auto sim = Sim::fromQOfonoSimWrapper(wrapper);
228 connect(sim.get(), &Sim::dataRoamingEnabledChanged, this, &Private::simDataRoamingEnabledChanged);
229 wwan::Sim::saveToSettings(m_settings, sim);
230 m_knownSims[sim->imsi()] = sim;
231 m_settings->setValue("KnownSims", QVariant(m_knownSims.keys()));
232 Q_EMIT p.simAdded(sim);
233 }
234 }
235
236 void simDataRoamingEnabledChanged(bool value)
237 {
238 Q_UNUSED(value)
239
240 auto sim_raw = qobject_cast<Sim*>(sender());
241 auto sim = m_knownSims[sim_raw->imsi()];
242 if (!sim)
243 {
244 qWarning("foobar");
245 return;
246 }
247 Sim::saveToSettings(m_settings, sim);
248 }
249
250};
251
252
253
254SimManager::SimManager()
255 : d{new Private(*this)}
256{
257}
258
259SimManager::~SimManager()
260{}
261
262QList<Sim::Ptr>
263SimManager::knownSims() const
264{
265 return d->m_knownSims.values();
266}
267
268}
269}
270
271#include "sim-manager.moc"
0272
=== added file 'src/indicator/nmofono/wwan/sim-manager.h'
--- src/indicator/nmofono/wwan/sim-manager.h 1970-01-01 00:00:00 +0000
+++ src/indicator/nmofono/wwan/sim-manager.h 2016-04-26 11:24:03 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#pragma once
21
22#include <QObject>
23#include <QSettings>
24
25#include <memory>
26
27#include "sim.h"
28
29namespace nmofono
30{
31namespace wwan
32{
33
34class SimManager : public QObject
35{
36 Q_OBJECT
37
38 class Private;
39 std::shared_ptr<Private> d;
40
41public:
42
43 typedef std::shared_ptr<SimManager> Ptr;
44 typedef std::weak_ptr<SimManager> WeakPtr;
45
46 SimManager();
47 ~SimManager();
48
49 QList<Sim::Ptr> knownSims() const;
50
51Q_SIGNALS:
52 void simAdded(Sim::Ptr sim);
53};
54
55}
56}
057
=== added file 'src/indicator/nmofono/wwan/sim.cpp'
--- src/indicator/nmofono/wwan/sim.cpp 1970-01-01 00:00:00 +0000
+++ src/indicator/nmofono/wwan/sim.cpp 2016-04-26 11:24:03 +0000
@@ -0,0 +1,582 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#include <nmofono/wwan/sim.h>
21
22#include <ofono/dbus.h>
23
24#define slots
25#include <qofono-qt5/qofonoconnectionmanager.h>
26#undef slots
27
28using namespace std;
29
30namespace nmofono
31{
32namespace wwan
33{
34namespace
35{
36
37}
38
39Sim::Ptr
40Sim::createFromSettings(QSettings *settings, const QString &imsi)
41{
42 settings->beginGroup(QString("Sims/%1/").arg(imsi));
43 QVariant primaryPhoneNumber_var = settings->value("PrimaryPhoneNumber");
44 QVariant mcc_var = settings->value("Mcc");
45 QVariant mnc_var = settings->value("Mnc");
46 QVariant preferredLanguages_var = settings->value("PreferredLanguages");
47 QVariant dataRoamingEnabled_var = settings->value("DataRoamingEnabled");
48 settings->endGroup();
49
50 if (imsi.isNull() ||
51 primaryPhoneNumber_var.isNull() ||
52 mcc_var.isNull() ||
53 mnc_var.isNull() ||
54 preferredLanguages_var.isNull() ||
55 dataRoamingEnabled_var.isNull())
56 {
57 qWarning() << "Corrupt settings for SIM: " << imsi;
58 settings->remove(QString("Sims/%1/").arg(imsi));
59 return Sim::Ptr();
60 }
61
62 return Sim::Ptr(new Sim(imsi,
63 primaryPhoneNumber_var.toString(),
64 mcc_var.toString(),
65 mnc_var.toString(),
66 preferredLanguages_var.toStringList(),
67 dataRoamingEnabled_var.toBool()));
68}
69
70void
71Sim::saveToSettings(QSettings *settings, Sim::Ptr sim)
72{
73 settings->beginGroup(QString("Sims/%1/").arg(sim->imsi()));
74 settings->setValue("PrimaryPhoneNumber", QVariant(sim->primaryPhoneNumber()));
75 settings->setValue("Mcc", sim->mcc());
76 settings->setValue("Mnc", sim->mnc());
77 settings->setValue("PreferredLanguages", QVariant(sim->preferredLanguages()));
78 settings->setValue("DataRoamingEnabled", sim->dataRoamingEnabled());
79 settings->endGroup();
80 settings->sync();
81}
82
83Sim::Ptr Sim::fromQOfonoSimWrapper(const QOfonoSimWrapper *wrapper)
84{
85 auto sim = Sim::Ptr(new Sim(wrapper->imsi(),
86 wrapper->phoneNumbers().first(), // default to the first number
87 wrapper->mcc(),
88 wrapper->mnc(),
89 wrapper->preferredLanguages(),
90 false));
91 sim->setOfonoSimManager(wrapper->ofonoSimManager());
92 return sim;
93}
94
95class Sim::Private : public QObject, public std::enable_shared_from_this<Private>
96{
97 Q_OBJECT
98
99public:
100
101 Sim& p;
102
103 Sim::PinType m_requiredPin;
104 RetriesType m_retries;
105 Sim::Status m_status = Sim::Status::missing;
106
107 bool m_requiredPinSet = false;
108 bool m_retriesSet = false;
109 bool m_statusSet = false;
110
111 int m_index = -1;
112
113 QString m_simIdentifier;
114
115 shared_ptr<QOfonoSimManager> m_simManager;
116 shared_ptr<QOfonoConnectionManager> m_connManager;
117
118 bool m_shouldTriggerUnlock = false;
119
120 QSet<QString> m_interfaces;
121
122 QTimer m_updatedTimer;
123
124 QString m_imsi;
125 QString m_primaryPhoneNumber;
126 QString m_mcc;
127 QString m_mnc;
128 QStringList m_preferredLanguages;
129 bool m_dataRoamingEnabled;
130 bool m_mobileDataEnabled = false;
131
132 bool m_locked = false;
133
134 Private(Sim &parent)
135 : p(parent)
136 {
137 }
138
139 Private(Sim& parent, shared_ptr<QOfonoSimManager> simmgr)
140 : p(parent)
141 {
142 simManagerChanged(simmgr);
143
144
145 /// @todo hook up with system-settings to allow changing the identifier.
146 if (m_simIdentifier.isEmpty())
147 {
148 setSimIdentifier(m_primaryPhoneNumber);
149 }
150
151 // Throttle the updates using a timer
152 m_updatedTimer.setInterval(0);
153 m_updatedTimer.setSingleShot(true);
154 connect(&m_updatedTimer, &QTimer::timeout, this, &Private::fireUpdate);
155 }
156
157public Q_SLOTS:
158
159 void fireUpdate()
160 {
161 Q_EMIT p.updated(p);
162
163 if (p.isReadyToUnlock() && m_shouldTriggerUnlock)
164 {
165 m_shouldTriggerUnlock = false;
166 Q_EMIT p.readyToUnlock(p.ofonoPath());
167 }
168 }
169
170 void simManagerChanged(shared_ptr<QOfonoSimManager> simmgr)
171 {
172 if (m_simManager == simmgr)
173 {
174 return;
175 }
176
177 m_simManager = simmgr;
178 if (m_simManager)
179 {
180 connect(m_simManager.get(),
181 &QOfonoSimManager::pinRequiredChanged, this,
182 &Private::update);
183
184 connect(m_simManager.get(),
185 &QOfonoSimManager::pinRetriesChanged, this,
186 &Private::update);
187
188 connect(m_simManager.get(),
189 &QOfonoSimManager::enterPinComplete, this,
190 &Private::enterPinComplete);
191
192 connect(m_simManager.get(),
193 &QOfonoSimManager::resetPinComplete, this,
194 &Private::resetPinComplete);
195 }
196
197 update();
198
199 Q_EMIT p.presentChanged(m_simManager.get() != nullptr);
200 }
201
202 void connManagerChanged(shared_ptr<QOfonoConnectionManager> connmgr)
203 {
204 if (m_connManager == connmgr)
205 {
206 return;
207 }
208
209 m_connManager = connmgr;
210 if (m_connManager)
211 {
212 connect(m_connManager.get(),
213 &QOfonoConnectionManager::poweredChanged, this,
214 &Private::update);
215 connect(m_connManager.get(),
216 &QOfonoConnectionManager::roamingAllowedChanged, this,
217 &Private::update);
218
219 m_connManager->setPowered(m_mobileDataEnabled);
220 m_connManager->setRoamingAllowed(m_dataRoamingEnabled);
221 }
222
223 update();
224 }
225
226 void update()
227 {
228 if (m_simManager) {
229 // update requiredPin
230 switch(m_simManager->pinRequired())
231 {
232 case QOfonoSimManager::PinType::NoPin:
233 setRequiredPin(PinType::none);
234 break;
235 case QOfonoSimManager::PinType::SimPin:
236 setRequiredPin(PinType::pin);
237 break;
238 case QOfonoSimManager::PinType::SimPuk:
239 setRequiredPin(PinType::puk);
240 break;
241 default:
242 throw std::runtime_error("Ofono requires a PIN we have not been prepared to handle (" +
243 to_string(m_simManager->pinRequired()) +
244 "). Bailing out.");
245 }
246
247 m_requiredPinSet = true;
248
249 bool retriesWasSet = true;
250 // update retries
251 RetriesType tmp;
252 QVariantMap retries = m_simManager->pinRetries();
253 QMapIterator<QString, QVariant> i(retries);
254 while (i.hasNext()) {
255 i.next();
256 QOfonoSimManager::PinType type = (QOfonoSimManager::PinType) i.key().toInt();
257 int count = i.value().toInt();
258 if (count < 0)
259 {
260 retriesWasSet = false;
261 }
262 switch(type)
263 {
264 case QOfonoSimManager::PinType::SimPin:
265 tmp[Sim::PinType::pin] = count;
266 break;
267 case QOfonoSimManager::PinType::SimPuk:
268 tmp[Sim::PinType::puk] = count;
269 break;
270 default:
271 break;
272 }
273 }
274 setRetries(tmp);
275
276 m_retriesSet = retriesWasSet;
277
278 } else {
279 setRequiredPin(PinType::none);
280 setRetries({});
281
282 m_requiredPinSet = false;
283 m_retriesSet = false;
284 }
285
286 if (m_connManager)
287 {
288 bool powered = m_connManager->powered();
289 bool roamingAllowed = m_connManager->roamingAllowed();
290
291 /*
292 * Connectivity Service is the policy manager for the system.
293 * If ofono has different settings force them back to stored values.
294 */
295 if (m_mobileDataEnabled != powered)
296 {
297 m_connManager->setPowered(m_mobileDataEnabled);
298 }
299 if (m_dataRoamingEnabled != roamingAllowed)
300 {
301 m_connManager->setRoamingAllowed(m_dataRoamingEnabled);
302 }
303 }
304 else
305 {
306 /* empty */
307 }
308 }
309
310 void enterPinComplete(QOfonoSimManager::Error error, const QString &errorString)
311 {
312 if (error == QOfonoSimManager::Error::NoError)
313 {
314 Q_EMIT p.enterPinSuceeded();
315 }
316 else
317 {
318 Q_EMIT p.enterPinFailed(errorString);
319 }
320 }
321
322 void resetPinComplete(QOfonoSimManager::Error error, const QString &errorString)
323 {
324 if (error == QOfonoSimManager::Error::NoError)
325 {
326 Q_EMIT p.resetPinSuceeded();
327 }
328 else
329 {
330 Q_EMIT p.resetPinFailed(errorString);
331 }
332 }
333
334 void setSimIdentifier(const QString& simIdentifier)
335 {
336 if (m_simIdentifier == simIdentifier)
337 {
338 return;
339 }
340
341 m_simIdentifier = simIdentifier;
342 Q_EMIT p.simIdentifierUpdated(m_simIdentifier);
343 }
344
345 void setRequiredPin(Sim::PinType requiredPin)
346 {
347 if (m_requiredPin == requiredPin)
348 {
349 return;
350 }
351
352 m_requiredPin = requiredPin;
353 Q_EMIT p.requiredPinUpdated(m_requiredPin);
354 }
355
356 void setRetries(const RetriesType& retries)
357 {
358 if (m_retries == retries)
359 {
360 return;
361 }
362
363 m_retries = retries;
364 Q_EMIT p.retriesUpdated();
365 }
366
367 void setStatus(Sim::Status value)
368 {
369 if (m_status == value)
370 {
371 return;
372 }
373
374 m_status = value;
375 Q_EMIT p.statusUpdated();
376 }
377
378 void setOfono(std::shared_ptr<QOfonoSimManager> simmgr)
379 {
380 simManagerChanged(simmgr);
381 if (simmgr)
382 {
383 m_connManager = std::make_shared<QOfonoConnectionManager>(this);
384 connManagerChanged(m_connManager);
385 }
386 else
387 {
388 m_connManager = std::shared_ptr<QOfonoConnectionManager>();
389 connManagerChanged(m_connManager);
390 }
391 }
392
393
394};
395
396Sim::Sim(const QString &imsi,
397 const QString &primaryPhoneNumber,
398 const QString &mcc,
399 const QString &mnc,
400 const QStringList &preferredLanguages,
401 bool dataRoamingEnabled)
402 : d{new Private(*this)}
403{
404 d->m_imsi = imsi;
405 d->m_primaryPhoneNumber = primaryPhoneNumber;
406 d->m_mcc = mcc;
407 d->m_mnc = mnc;
408 d->m_preferredLanguages = preferredLanguages;
409 d->m_dataRoamingEnabled = dataRoamingEnabled;
410}
411
412Sim::~Sim()
413{}
414
415void
416Sim::enterPin(PinType type, const QString &pin)
417{
418 if (!d->m_simManager)
419 {
420 throw std::runtime_error(std::string(__PRETTY_FUNCTION__) + ": no simManager.");
421 }
422
423 switch(type) {
424 case PinType::none:
425 break;
426 case PinType::pin:
427 d->m_simManager->enterPin(QOfonoSimManager::PinType::SimPin,
428 pin);
429 break;
430 case PinType::puk:
431 d->m_simManager->enterPin(QOfonoSimManager::PinType::SimPuk,
432 pin);
433 break;
434 }
435}
436
437
438void
439Sim::resetPin(PinType type, const QString &puk, const QString &pin)
440{
441 if (!d->m_simManager) {
442 throw std::runtime_error(std::string(__PRETTY_FUNCTION__) + ": no simManager.");
443 }
444
445 switch(type) {
446 case PinType::none:
447 break;
448 case PinType::puk:
449 d->m_simManager->resetPin(QOfonoSimManager::PinType::SimPuk,
450 puk,
451 pin);
452 break;
453 default:
454 throw std::runtime_error(std::string(__PRETTY_FUNCTION__) + ": Not Supported.");
455 }
456}
457
458Sim::PinType
459Sim::requiredPin() const
460{
461 return d->m_requiredPin;
462}
463
464const Sim::RetriesType&
465Sim::retries() const
466{
467 return d->m_retries;
468}
469
470const QString&
471Sim::simIdentifier() const
472{
473 return d->m_simIdentifier;
474}
475
476bool
477Sim::isReadyToUnlock() const
478{
479 return d->m_statusSet && d->m_requiredPinSet && d->m_retriesSet
480 && (d->m_requiredPin != PinType::none);
481}
482
483void
484Sim::notifyWhenReadyToUnlock()
485{
486 d->m_shouldTriggerUnlock = true;
487}
488
489
490Sim::Status Sim::status() const
491{
492 return d->m_status;
493}
494
495QString Sim::imsi() const
496{
497 return d->m_imsi;
498}
499
500QString Sim::primaryPhoneNumber() const
501{
502 return d->m_primaryPhoneNumber;
503}
504
505bool Sim::locked() const
506{
507 return d->m_locked;
508}
509
510bool Sim::present() const
511{
512 return d->m_simManager.get() != nullptr;
513}
514
515QString Sim::mcc() const
516{
517 return d->m_mcc;
518}
519
520QString Sim::mnc() const
521{
522 return d->m_mnc;
523}
524
525QList<QString> Sim::preferredLanguages() const
526{
527 return d->m_preferredLanguages;
528}
529
530bool Sim::dataRoamingEnabled() const
531{
532 return d->m_dataRoamingEnabled;
533}
534
535void Sim::setDataRoamingEnabled(bool value)
536{
537 if (d->m_dataRoamingEnabled == value)
538 return;
539 d->m_dataRoamingEnabled = value;
540 Q_EMIT dataRoamingEnabledChanged(value);
541}
542
543bool Sim::mobileDataEnabled() const
544{
545 return d->m_mobileDataEnabled;
546}
547
548void Sim::setMobileDataEnabled(bool value)
549{
550 if (d->m_mobileDataEnabled == value)
551 return;
552 d->m_mobileDataEnabled = value;
553 if (d->m_connManager)
554 {
555 d->m_connManager->setPowered(d->m_mobileDataEnabled);
556 }
557 Q_EMIT mobileDataEnabledChanged(value);
558}
559
560void Sim::unlock()
561{
562
563}
564
565QString Sim::ofonoPath() const
566{
567 if (d->m_simManager) {
568 return d->m_simManager->objectPath();
569 }
570 return QString();
571}
572
573void Sim::setOfonoSimManager(std::shared_ptr<QOfonoSimManager> simmgr)
574{
575 d->setOfono(simmgr);
576}
577
578
579}
580}
581
582#include "sim.moc"
0583
=== added file 'src/indicator/nmofono/wwan/sim.h'
--- src/indicator/nmofono/wwan/sim.h 1970-01-01 00:00:00 +0000
+++ src/indicator/nmofono/wwan/sim.h 2016-04-26 11:24:03 +0000
@@ -0,0 +1,182 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18 */
19
20#pragma once
21
22#include <QObject>
23#include <QSettings>
24
25#include <memory>
26
27#define slots
28#include <qofono-qt5/qofonomodem.h>
29#include <qofono-qt5/qofonosimmanager.h>
30#undef slots
31
32#include <nmofono/wwan/qofono-sim-wrapper.h>
33
34class QOfonoModem;
35
36namespace nmofono
37{
38class ManagerImpl;
39
40namespace wwan
41{
42
43class Sim : public QObject
44{
45 Q_OBJECT
46
47 class Private;
48 std::shared_ptr<Private> d;
49
50public:
51
52 typedef std::shared_ptr<Sim> Ptr;
53 typedef std::weak_ptr<Sim> WeakPtr;
54
55 enum class PinType
56 {
57 none,
58 pin,
59 puk
60 };
61
62 enum class Status
63 {
64 missing,
65 error,
66 locked,
67 permanentlyLocked,
68 ready,
69 not_available
70 };
71
72 Sim() = delete;
73
74 static Sim::Ptr createFromSettings(QSettings*, const QString &imsi);
75 static void saveToSettings(QSettings *, Sim::Ptr);
76
77 static Sim::Ptr fromQOfonoSimWrapper(const QOfonoSimWrapper *wrapper);
78
79private:
80 Sim(const QString &imsi,
81 const QString &primaryPhoneNumber,
82 const QString &mcc,
83 const QString &mnc,
84 const QStringList &preferredLanguages,
85 bool dataRoamingEnabled);
86
87public:
88 ~Sim();
89 void setOfonoSimManager(std::shared_ptr<QOfonoSimManager> simmgr);
90
91
92 Q_PROPERTY(Sim::PinType requiredPin READ requiredPin NOTIFY requiredPinUpdated)
93 PinType requiredPin() const;
94
95 typedef std::map<Sim::PinType, int> RetriesType;
96 Q_PROPERTY(RetriesType retries READ retries NOTIFY retriesUpdated)
97 const RetriesType &retries() const;
98
99 Q_PROPERTY(QString simIdentifier READ simIdentifier NOTIFY simIdentifierUpdated)
100 const QString &simIdentifier() const;
101
102 Q_PROPERTY(Sim::Status status READ status NOTIFY statusUpdated)
103 Status status() const;
104
105 Q_PROPERTY(QString imsi READ imsi CONSTANT)
106 QString imsi() const;
107
108 Q_PROPERTY(QString primaryPhoneNumber READ primaryPhoneNumber CONSTANT)
109 QString primaryPhoneNumber() const;
110
111 Q_PROPERTY(bool locked READ locked NOTIFY lockedChanged)
112 bool locked() const;
113
114 Q_PROPERTY(bool present READ present NOTIFY presentChanged)
115 bool present() const;
116
117 Q_PROPERTY(QString mcc READ mcc CONSTANT)
118 QString mcc() const;
119
120 Q_PROPERTY(QString mnc READ mnc CONSTANT)
121 QString mnc() const;
122
123 Q_PROPERTY(QList<QString> preferredLanguages READ preferredLanguages CONSTANT)
124 QList<QString> preferredLanguages() const;
125
126 Q_PROPERTY(bool dataRoamingEnabled READ dataRoamingEnabled WRITE setDataRoamingEnabled NOTIFY dataRoamingEnabledChanged)
127 bool dataRoamingEnabled() const;
128 void setDataRoamingEnabled(bool value);
129
130 Q_PROPERTY(bool mobileDataEnabled READ mobileDataEnabled WRITE setMobileDataEnabled NOTIFY mobileDataEnabledChanged)
131 bool mobileDataEnabled() const;
132 void setMobileDataEnabled(bool value);
133
134 bool isReadyToUnlock() const;
135
136 void notifyWhenReadyToUnlock();
137
138 void enterPin(PinType type,
139 const QString &pin);
140
141 void resetPin(PinType type,
142 const QString &puk,
143 const QString &pin);
144
145 QString ofonoPath() const;
146
147public Q_SLOTS:
148 void unlock();
149
150Q_SIGNALS:
151
152 void requiredPinUpdated(PinType);
153
154 void retriesUpdated();
155
156 void simIdentifierUpdated(const QString &);
157
158 void updated(const Sim& sim);
159
160 void enterPinSuceeded();
161
162 void enterPinFailed(const QString& error);
163
164 void resetPinSuceeded();
165
166 void resetPinFailed(const QString& error);
167
168 bool readyToUnlock(const QString& name);
169
170 void statusUpdated();
171
172 void lockedChanged(bool value);
173
174 void presentChanged(bool value);
175
176 void dataRoamingEnabledChanged(bool value);
177
178 void mobileDataEnabledChanged(bool value);
179};
180
181}
182}
0183
=== modified file 'src/indicator/sections/wwan-section.cpp'
--- src/indicator/sections/wwan-section.cpp 2016-02-12 14:25:16 +0000
+++ src/indicator/sections/wwan-section.cpp 2016-04-26 11:24:03 +0000
@@ -54,13 +54,14 @@
5454
55 Manager::Ptr m_manager;55 Manager::Ptr m_manager;
5656
57 SwitchItem::Ptr m_mobileDataSwitch;
57 SwitchItem::Ptr m_hotspotSwitch;58 SwitchItem::Ptr m_hotspotSwitch;
58 TextItem::Ptr m_openCellularSettings;59 TextItem::Ptr m_openCellularSettings;
5960
60 QMap<wwan::Modem::Ptr, WwanLinkItem::Ptr> m_items;61 QMap<wwan::Modem::Ptr, WwanLinkItem::Ptr> m_items;
6162
62 Private() = delete;63 Private() = delete;
63 Private(Manager::Ptr modemManager, SwitchItem::Ptr hotspotSwitch);64 Private(Manager::Ptr modemManager, SwitchItem::Ptr mobileDataSwitch ,SwitchItem::Ptr hotspotSwitch);
6465
65public Q_SLOTS:66public Q_SLOTS:
66 void modemsChanged();67 void modemsChanged();
@@ -77,8 +78,8 @@
77 }78 }
78};79};
7980
80WwanSection::Private::Private(Manager::Ptr modemManager, SwitchItem::Ptr hotspotSwitch)81WwanSection::Private::Private(Manager::Ptr modemManager, SwitchItem::Ptr mobileDataSwitch,SwitchItem::Ptr hotspotSwitch)
81 : QObject(nullptr), m_manager{modemManager}, m_hotspotSwitch{hotspotSwitch}82 : QObject(nullptr), m_manager{modemManager}, m_mobileDataSwitch{mobileDataSwitch}, m_hotspotSwitch{hotspotSwitch}
82{83{
83 m_actionGroupMerger = make_shared<ActionGroupMerger>();84 m_actionGroupMerger = make_shared<ActionGroupMerger>();
84 m_menuMerger = make_shared<MenuMerger>();85 m_menuMerger = make_shared<MenuMerger>();
@@ -91,6 +92,9 @@
91 m_menuMerger->append(m_linkMenuMerger);92 m_menuMerger->append(m_linkMenuMerger);
92 m_menuMerger->append(m_bottomMenu);93 m_menuMerger->append(m_bottomMenu);
9394
95 m_upperMenu->append(m_mobileDataSwitch->menuItem());
96 m_actionGroupMerger->add(m_mobileDataSwitch->actionGroup());
97
94 // have the modem list in their own section.98 // have the modem list in their own section.
95 m_topItem = MenuItem::newSection(m_menuMerger);99 m_topItem = MenuItem::newSection(m_menuMerger);
96 m_topMenu = make_shared<Menu>();100 m_topMenu = make_shared<Menu>();
@@ -186,8 +190,8 @@
186 }190 }
187}191}
188192
189WwanSection::WwanSection(nmofono::Manager::Ptr manager, SwitchItem::Ptr hotspotSwitch)193WwanSection::WwanSection(nmofono::Manager::Ptr manager, SwitchItem::Ptr mobileDataSwitch, SwitchItem::Ptr hotspotSwitch)
190 : d{new Private(manager, hotspotSwitch)}194 : d{new Private(manager, mobileDataSwitch, hotspotSwitch)}
191{195{
192}196}
193197
194198
=== modified file 'src/indicator/sections/wwan-section.h'
--- src/indicator/sections/wwan-section.h 2015-08-14 15:52:39 +0000
+++ src/indicator/sections/wwan-section.h 2016-04-26 11:24:03 +0000
@@ -30,7 +30,7 @@
3030
31public:31public:
32 typedef std::shared_ptr<WwanSection> Ptr;32 typedef std::shared_ptr<WwanSection> Ptr;
33 explicit WwanSection(nmofono::Manager::Ptr modemManager, SwitchItem::Ptr hotspotSwitch);33 explicit WwanSection(nmofono::Manager::Ptr modemManager, SwitchItem::Ptr mobileDataSwitch, SwitchItem::Ptr hotspotSwitch);
34 virtual ~WwanSection();34 virtual ~WwanSection();
3535
36 virtual ActionGroup::Ptr actionGroup();36 virtual ActionGroup::Ptr actionGroup();
3737
=== modified file 'src/qdbus-stubs/dbus-types.h'
--- src/qdbus-stubs/dbus-types.h 2015-11-20 13:14:50 +0000
+++ src/qdbus-stubs/dbus-types.h 2016-04-26 11:24:03 +0000
@@ -47,6 +47,19 @@
47 return path.arg(counter++);47 return path.arg(counter++);
48 }48 }
4949
50 inline QString modemPath(const QString &serial)
51 {
52 static QString path{"/com/ubuntu/connectivity1/modem/%1"};
53 return path.arg(serial);
54 }
55
56 inline QString simPath(const QString &imsi)
57 {
58 static QString path{"/com/ubuntu/connectivity1/sim/%1"};
59 return path.arg(imsi);
60 }
61
62
50 static constexpr char const* WPASUPPLICANT_DBUS_NAME = "fi.w1.wpa_supplicant1";63 static constexpr char const* WPASUPPLICANT_DBUS_NAME = "fi.w1.wpa_supplicant1";
5164
52 static constexpr char const* WPASUPPLICANT_DBUS_INTERFACE = "fi.w1.wpa_supplicant1";65 static constexpr char const* WPASUPPLICANT_DBUS_INTERFACE = "fi.w1.wpa_supplicant1";
5366
=== added file 'tests/data/phonesim/sim_general.xml'
--- tests/data/phonesim/sim_general.xml 1970-01-01 00:00:00 +0000
+++ tests/data/phonesim/sim_general.xml 2016-04-26 11:24:03 +0000
@@ -0,0 +1,3677 @@
1<?xml version="1.0"?>
2<simulator>
3
4<!-- Phone simulator definition file for the "Qt Extended Pseudo Phone" -->
5
6<!-- Note: dialing 199 will cause a dialback to simulate an incoming call -->
7<!-- Note: dialing 177 will cause a dialback to simulate an incoming call, and hangup after 5 seconds -->
8<!-- Note: dialing 166 will accept the incoming call and hangup up after 5 seconds-->
9<!-- Note: dialing 155 will elicit a 'BUSY' response from the recipient-->
10<!-- Note: dialing 05123xx cause an MT disconnect of the connected call after xx seconds-->
11<!-- Note: dialing 06123xx cause an automatic accept after xx seconds-->
12
13<!-- Initialize state variables -->
14
15 <!-- Advice of charge -->
16 <!-- Call Meter -->
17 <set name="AOC" value="000000"/>
18
19 <!-- Call Meter reporting -->
20 <set name="AOCMODE" value="1"/>
21
22 <!-- Accumulated Call Meter -->
23 <set name="ACM" value="000480"/>
24
25 <!-- Accumulated Call Meter Maximum -->
26 <set name="ACMMAX" value="000500"/>
27
28 <!-- Price per Unit and Currency -->
29 <set name="PPU" value='GBP","2.66'/>
30
31 <!-- Battery Capacity
32 first value
33 0-powered by battery
34 1-battery connected, powered by charger
35 2-no battery.
36
37 second value is percentage battery remaining.
38 0-exhausted
39 1-99-partial charge
40 100-fully charged.
41 -->
42 <set name="BC" value="0,100"/>
43
44 <!-- Signal Quality -->
45 <set name="SQ" value="31,99"/>
46
47 <!-- Manufacturer -->
48 <set name="GMI" value="Ubuntu"/>
49
50 <!-- Model -->
51 <set name="GMM" value="Synthetic Device"/>
52
53 <!-- Revision -->
54 <set name="GMR" value="REV1"/>
55
56 <!-- Serial number -->
57 <set name="GSN" value="5647382910"/>
58
59 <!-- SIM card id -->
60 <set name="IMSI" value="123123123"/>
61
62 <!-- Identifier for ATI command -->
63 <set name="ID" value="Ubuntu Phone Simulator"/>
64
65 <!-- Character set -->
66 <set name="SCS" value="IRA"/>
67
68 <!-- Type of address (local = 129, international = 145) -->
69 <set name="STA" value="129"/>
70
71 <!-- Service reporting control flag -->
72 <set name="CR" value="0"/>
73
74 <!-- Cellular result code control flag -->
75 <set name="CRC" value="0"/>
76
77 <!-- Extended error message string -->
78 <set name="ERR" value="EXTENDED ERROR STRING"/>
79
80 <!-- Network registration presentation flag -->
81 <set name="REG" value="1,0"/>
82
83 <!-- GPRS network registration presentation flag -->
84 <set name="GREG" value="0"/>
85
86 <!-- Mobile phone operator selection mode (0=auto, 1=manual, 2=deregister, 3=set only <format>, 4=manual / automatic) -->
87 <set name="OPMODE" value="0"/>
88
89 <!-- Mobile phone operator selection format (0=long alphanumeric, 1=short alphanumeric, 2=numeric -->
90 <set name="OPFORMAT" value="0"/>
91
92 <!-- GCF Operator List, format <status(1:available,2:current,3:forbidden)>,"<alphanum.operator name>","<short operator name>","<MCC/MNC num>"-->
93 <set name="OP1" value="T-Ubuntu"/>
94 <set name="OP1PLMN" value="23401"/>
95 <set name="OP1STATE" value="2"/>
96
97 <set name="OP2" value="Maybe Forbidden Net"/>
98 <set name="OP2PLMN" value="23402"/>
99 <set name="OP2STATE" value="3"/>
100
101 <set name="OP3" value="Competitor Net"/>
102 <set name="OP3PLMN" value="23403"/>
103 <set name="OP3STATE" value="3"/>
104
105 <set name="OP4" value="Blocked Net"/>
106 <set name="OP4PLMN" value="23404"/>
107 <set name="OP4STATE" value="3"/>
108
109 <set name="OP5" value="Inaccessible Net"/>
110 <set name="OP5PLMN" value="23405"/>
111 <set name="OP5STATE" value="3"/>
112
113 <set name="OP6" value="Phone Net"/>
114 <set name="OP6PLMN" value="23406"/>
115 <set name="OP6STATE" value="1"/>
116
117 <set name="OP7" value="Teleco Net"/>
118 <set name="OP7PLMN" value="24681"/>
119 <set name="OP7STATE" value="1"/>
120
121 <set name="OP8" value="Mobile Net"/>
122 <set name="OP8PLMN" value="24682"/>
123 <set name="OP8STATE" value="1"/>
124
125 <set name="OP9" value="IMSI Unknown"/>
126 <set name="OP9PLMN" value="24683"/>
127 <set name="OP9STATE" value="1"/>
128
129 <set name="OP10" value="NotAllowed"/>
130 <set name="OP10PLMN" value="24684"/>
131 <set name="OP10STATE" value="1"/>
132
133 <set name="OP11" value="NoService"/>
134 <set name="OP11PLMN" value="24685"/>
135 <set name="OP11STATE" value="1"/>
136
137 <!-- Preferred Operators -->
138 <set name="PO1" value="1,2,23401"/>
139 <set name="PO2" value="2,2,23402"/>
140
141 <!-- Name of current mobile phone operator -->
142 <set name="OP" value="${OP1}"/>
143 <set name="OPPLMN" value="${OP1PLMN}"/>
144
145 <!-- Calling line identification presentation flag -->
146 <set name="LIP" value="0"/>
147
148 <!-- Calling line identification restriction flag -->
149 <set name="LIR" value="0"/>
150 <set name="LIR_STATUS" value="3"/>
151
152 <!-- Originating line identification presentation flag -->
153 <set name="OLP" value="0"/>
154
155 <!-- Call waiting presentation mode -->
156 <set name="CWA_V" value="1"/>
157 <set name="CWA_D" value="0"/>
158 <set name="CWA_F" value="0"/>
159
160 <!-- Call forwarding -->
161 <set name="CF0C1" value="0"/>
162 <set name="CF0C2" value="0"/>
163 <set name="CF0C4" value="0"/>
164 <set name="CF0C8" value="0"/>
165 <set name="CF1C1" value="0"/>
166 <set name="CF1C2" value="0"/>
167 <set name="CF1C4" value="0"/>
168 <set name="CF1C8" value="0"/>
169 <set name="CF2C1" value="0"/>
170 <set name="CF2C2" value="0"/>
171 <set name="CF2C4" value="0"/>
172 <set name="CF2C8" value="0"/>
173 <set name="CF3C1" value="0"/>
174 <set name="CF3C2" value="0"/>
175 <set name="CF3C4" value="0"/>
176 <set name="CF3C8" value="0"/>
177 <set name="CF0C1T" value="129"/>
178 <set name="CF1C1T" value="129"/>
179 <set name="CF2C1T" value="129"/>
180 <set name="CF3C1T" value="129"/>
181 <set name="CF2C1O" value="20"/>
182
183 <!-- Service Center Address -->
184 <set name="SCA" value="+15551234567"/>
185 <set name="SCAT" value="145"/>
186
187 <!-- Fixed Dialling presentation mode -->
188 <set name="FD" value="0"/>
189
190 <!-- Unstructured service presentation mode -->
191 <set name="USD" value="0"/>
192
193 <!-- Supplementary service notification flags -->
194 <set name="SSN" value="0,0"/>
195
196 <!-- Phone activity status (ready = 0, ringing = 3, call active = 4) -->
197 <set name="PAS" value="0"/>
198
199 <!-- Phone functionality power consumption level (minimal = 0, full = 1) -->
200 <set name="FUN" value="4"/>
201
202 <!-- Mobile equipment control modes -->
203 <set name="MEC" value="0,0,0"/>
204
205 <!-- Mobile equipment event reporting modes -->
206 <set name="MER" value="0,0,0,0,0"/>
207
208 <!-- Ericsson-style call monitoring status values -->
209 <set name="ECAM" value="0"/>
210
211 <!-- SMS text vs PDU message format (1 = text, 0 = PDU) -->
212 <set name="CMGF" value="0"/>
213
214 <!-- Error reporting mode -->
215 <set name="MEE" value="0"/>
216
217 <!-- SMS message list -->
218 <set name="MSGLIST" value=""/>
219 <set name="MSGLISTCOPY" value=""/>
220 <set name="MSGMEM" value="SM"/>
221
222 <!-- Number of messages in the SMS message list -->
223 <set name="MSGCOUNT" value="0"/>
224
225 <!-- Identifier for the current call -->
226 <set name="CALLID" value="1"/>
227
228 <!-- Name of the PIN that is required (eg. "PIN") -->
229 <!-- READY: PIN/PUK not required; SIM PIN: PIN required; SIM PUK: PUK REQUIRED -->
230 <set name="PINNAME" value="READY"/>
231
232 <!-- Value of the PIN that is required -->
233 <set name="PINVALUE" value="1234"/>
234
235 <!-- How many times can PIN unlocking be attempted -->
236 <set name="PINRETRYCOUNT" value="3"/>
237
238 <!-- pin protection status -->
239 <set name="SC" value="0"/>
240
241 <!-- Value of the PIN2 that is required -->
242 <set name="PIN2VALUE" value="5678"/>
243
244 <!-- Value of the PUK that is required -->
245 <set name="PUKVALUE" value="1234567890"/>
246
247 <!-- Value of the PUK2 that is required -->
248 <set name="PUK2VALUE" value="01010101"/>
249
250 <!-- Value of the PSPIN that is required -->
251 <set name="PSPINVALUE" value="5550"/>
252
253 <!-- phone to sim pin protection status -->
254 <set name="PS" value="0"/>
255
256 <!-- Value of the SIM PIN2 that is required -->
257 <set name="SIMPIN2VALUE" value="666777"/>
258
259 <!-- Call Barring -->
260 <set name="BARVAO" value="0"/>
261 <set name="BARVOI" value="0"/>
262 <set name="BARVOX" value="0"/>
263 <set name="BARVAI" value="0"/>
264 <set name="BARVIR" value="0"/>
265 <set name="BARVNT" value="0"/>
266 <set name="BARVNM" value="0"/>
267 <set name="BARVNS" value="0"/>
268 <set name="BARVNA" value="0"/>
269 <set name="BARVAB" value="0"/>
270 <set name="BARVAG" value="0"/>
271 <set name="BARVAC" value="0"/>
272
273 <!-- accessories, handsfree and car. 0 means not connected, 1 for connected -->
274 <set name="HANDSFREE" value="0"/>
275
276 <set name="CARHANDSFREE" value="0"/>
277
278 <!-- list of available bands -->
279 <set name="BAND0" value="GSM &amp; EGSM"/>
280 <set name="BAND1" value="GSM 1800"/>
281 <set name="BAND2" value="Dualband 900/1800"/>
282 <set name="BAND3" value="PCS 1900"/>
283 <set name="BAND4" value="GSM 850"/>
284 <set name="BAND5" value="Dualband 1900/850"/>
285 <set name="BAND6" value=""/>
286 <set name="BAND7" value=""/>
287 <set name="BAND8" value=""/>
288 <set name="BAND9" value=""/>
289 <set name="BANDA" value=""/>
290 <set name="BANDB" value=""/>
291 <set name="BANDC" value=""/>
292 <set name="BANDD" value=""/>
293 <set name="BANDE" value=""/>
294 <set name="BANDF" value=""/>
295
296 <!-- current band. 0 means automatic and 1,"name" means manually select "name" -->
297 <set name="BAND" value="0"/>
298
299 <!-- Loudspeaker Volume Level -->
300 <set name="LVL" value="125"/>
301
302 <!-- Muting control -->
303 <set name="MUT" value="0"/>
304
305 <!-- CGSMS Bearer control -->
306 <set name="CGSMS" value="3"/>
307
308 <!-- TTY (hearing impared) state -->
309 <set name="PTTY" value="1"/>
310
311 <!-- Positioning reporting state -->
312 <set name="CPOSR" value="0"/>
313
314 <!-- SIM insertion state -->
315 <set name="SIMSTATE" value="1"/>
316
317<!-- Time -->
318<!-- Enable for testing
319<unsolicited delay="3000" once="true">*TTZ: 2, "11/25/2007, 12:12:12+40", 0</unsolicited>
320<unsolicited delay="3000" once="true">*TTZ: 2, "Cingluar", 0</unsolicited>
321-->
322
323<!-- GSM 07.07: General commands -->
324
325<chat>
326 <!-- Get manufacturer identifier -->
327 <command>AT+CGMI</command>
328 <response>${GMI}\n\nOK</response>
329</chat>
330
331<chat>
332 <!-- Get manufacturer identifier support check -->
333 <command>AT+CGMI=?</command>
334 <response>OK</response>
335</chat>
336
337<chat>
338 <!-- Get manufacturer identifier, V.25ter version -->
339 <command>AT+GMI</command>
340 <response>${GMI}\n\nOK</response>
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches