Merge lp:~tiagosh/telepathy-ofono/sim-presence into lp:telepathy-ofono

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 101
Merged at revision: 100
Proposed branch: lp:~tiagosh/telepathy-ofono/sim-presence
Merge into: lp:telepathy-ofono
Diff against target: 1056 lines (+660/-71)
14 files modified
connection.cpp (+62/-58)
connection.h (+5/-3)
tests/CallTest.cpp (+1/-0)
tests/ConnectionTest.cpp (+14/-6)
tests/MessagesTest.cpp (+1/-0)
tests/mock/CMakeLists.txt (+3/-0)
tests/mock/SimManagerPrivate.xml (+17/-0)
tests/mock/mock_common.h (+1/-0)
tests/mock/ofonosimmanager.cpp (+313/-0)
tests/mock/ofonosimmanager.h (+134/-0)
tests/mock/simmanagerprivate.cpp (+46/-0)
tests/mock/simmanagerprivate.h (+42/-0)
tests/ofonomockcontroller.cpp (+16/-3)
tests/ofonomockcontroller.h (+5/-1)
To merge this branch: bzr merge lp:~tiagosh/telepathy-ofono/sim-presence
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+231046@code.launchpad.net

Commit message

- Report "away" status if there is no network and "offline" if the sim card is not present.
- Remove legacy code
- Expose operator name to apps via presence message.

Description of the change

- Report "away" status if there is no network and "offline" if the sim card is not present.
- Remove legacy code
- Expose operator name to apps via presence message.

--Checklist--
Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~tiagosh/telephony-service/sim-presence/+merge/231045

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/telepathy-ofono) on device or emulator?
Yes

If you changed the UI, was the change specified/approved by design?
N/A

If you changed UI labels, did you update the pot file?
N/A

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
N/A

To post a comment you must log in.
98. By Tiago Salem Herrmann

merge trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
99. By Tiago Salem Herrmann

report new status: nomodem, nosim, flightmode, and all ofono network status

100. By Tiago Salem Herrmann

- refresh properties when interfaces become available
- export the actual status to upper layers

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
101. By Tiago Salem Herrmann

add SimManager interface to ofono-qt mock

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes

Did CI run pass? If not, please explain why.
No, but not related to the MR.

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes

Code looks good and works as expected!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'connection.cpp'
2--- connection.cpp 2014-08-12 20:51:37 +0000
3+++ connection.cpp 2014-08-20 19:00:56 +0000
4@@ -23,9 +23,6 @@
5 #include <TelepathyQt/BaseChannel>
6 #include <TelepathyQt/DBusObject>
7
8-// ofono-qt
9-#include <ofonomodem.h>
10-
11 // telepathy-ofono
12 #include "connection.h"
13 #include "phoneutils_p.h"
14@@ -71,9 +68,6 @@
15 #endif
16 }
17
18-// miliseconds
19-#define OFONO_REGISTER_RETRY_TIME 5000
20-
21 oFonoConnection::oFonoConnection(const QDBusConnection &dbusConnection,
22 const QString &cmName,
23 const QString &protocolName,
24@@ -96,6 +90,8 @@
25 mOfonoNetworkRegistration = new OfonoNetworkRegistration(setting, mModemPath);
26 mOfonoMessageWaiting = new OfonoMessageWaiting(setting, mModemPath);
27 mOfonoSupplementaryServices = new OfonoSupplementaryServices(setting, mModemPath);
28+ mOfonoSimManager = new OfonoSimManager(setting, mModemPath);
29+ mOfonoModem = mOfonoSimManager->modem();
30
31 setSelfHandle(newHandle("<SelfHandle>"));
32
33@@ -158,38 +154,43 @@
34 supplementaryServicesIface->setRespondCallback(Tp::memFun(this,&oFonoConnection::USSDRespond));
35 supplementaryServicesIface->setCancelCallback(Tp::memFun(this,&oFonoConnection::USSDCancel));
36 supplementaryServicesIface->StateChanged(mOfonoSupplementaryServices->state());
37- supplementaryServicesIface->setSerial(mOfonoSupplementaryServices->modem()->serial());
38+ supplementaryServicesIface->setSerial(mOfonoModem->serial());
39 plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(supplementaryServicesIface));
40
41 // Set Presence
42 Tp::SimpleStatusSpec presenceOnline;
43 presenceOnline.type = Tp::ConnectionPresenceTypeAvailable;
44- presenceOnline.maySetOnSelf = true;
45- presenceOnline.canHaveMessage = false;
46+ presenceOnline.maySetOnSelf = false;
47+ presenceOnline.canHaveMessage = true;
48
49 Tp::SimpleStatusSpec presenceOffline;
50 presenceOffline.type = Tp::ConnectionPresenceTypeOffline;
51 presenceOffline.maySetOnSelf = false;
52- presenceOffline.canHaveMessage = false;
53+ presenceOffline.canHaveMessage = true;
54+
55+ Tp::SimpleStatusSpec presenceAway;
56+ presenceAway.type = Tp::ConnectionPresenceTypeAway;
57+ presenceAway.maySetOnSelf = false;
58+ presenceAway.canHaveMessage = true;
59
60 Tp::SimpleStatusSpecMap statuses;
61- statuses.insert(QLatin1String("available"), presenceOnline);
62- statuses.insert(QLatin1String("offline"), presenceOffline);
63+ statuses.insert(QLatin1String("registered"), presenceOnline);
64+ statuses.insert(QLatin1String("roaming"), presenceOnline);
65+ statuses.insert(QLatin1String("flightmode"), presenceOffline);
66+ statuses.insert(QLatin1String("nosim"), presenceOffline);
67+ statuses.insert(QLatin1String("nomodem"), presenceOffline);
68+ statuses.insert(QLatin1String("unregistered"), presenceAway);
69+ statuses.insert(QLatin1String("denied"), presenceAway);
70+ statuses.insert(QLatin1String("unknown"), presenceAway);
71+ statuses.insert(QLatin1String("searching"), presenceAway);
72
73 simplePresenceIface->setStatuses(statuses);
74- mSelfPresence.type = Tp::ConnectionPresenceTypeOffline;
75- mRequestedSelfPresence.type = Tp::ConnectionPresenceTypeOffline;
76
77- bool validModem = false;
78- if (mOfonoVoiceCallManager->modem()) {
79- validModem = mOfonoVoiceCallManager->modem()->isValid();
80- if (validModem) {
81- supplementaryServicesIface->setSerial(mOfonoSupplementaryServices->modem()->serial());
82- QObject::connect(mOfonoVoiceCallManager->modem(), SIGNAL(onlineChanged(bool)), SLOT(onValidityChanged(bool)));
83- }
84+ if (mOfonoModem->isValid()) {
85+ supplementaryServicesIface->setSerial(mOfonoModem->serial());
86 }
87 // force update current presence
88- onOfonoNetworkRegistrationChanged(mOfonoNetworkRegistration->status());
89+ updateOnlineStatus();
90
91 contactsIface = Tp::BaseConnectionContactsInterface::create();
92 contactsIface->setGetContactAttributesCallback(Tp::memFun(this,&oFonoConnection::getContactAttributes));
93@@ -198,12 +199,17 @@
94 << TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE);
95 plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(contactsIface));
96
97+ QObject::connect(mOfonoModem, SIGNAL(onlineChanged(bool)), SLOT(updateOnlineStatus()));
98+ QObject::connect(mOfonoModem, SIGNAL(interfacesChanged(QStringList)), SLOT(updateOnlineStatus()));
99 QObject::connect(mOfonoMessageManager, SIGNAL(incomingMessage(QString,QVariantMap)), this, SLOT(onOfonoIncomingMessage(QString,QVariantMap)));
100 QObject::connect(mOfonoMessageManager, SIGNAL(immediateMessage(QString,QVariantMap)), this, SLOT(onOfonoImmediateMessage(QString,QVariantMap)));
101 QObject::connect(mOfonoMessageManager, SIGNAL(statusReport(QString,QVariantMap)), this, SLOT(onDeliveryReportReceived(QString,QVariantMap)));
102 QObject::connect(mOfonoVoiceCallManager, SIGNAL(callAdded(QString,QVariantMap)), SLOT(onOfonoCallAdded(QString, QVariantMap)));
103- QObject::connect(mOfonoVoiceCallManager, SIGNAL(validityChanged(bool)), SLOT(onValidityChanged(bool)));
104- QObject::connect(mOfonoNetworkRegistration, SIGNAL(statusChanged(QString)), SLOT(onOfonoNetworkRegistrationChanged(QString)));
105+ QObject::connect(mOfonoSimManager, SIGNAL(validityChanged(bool)), SLOT(onValidityChanged(bool)));
106+ QObject::connect(mOfonoSimManager, SIGNAL(presenceChanged(bool)), SLOT(updateOnlineStatus()));
107+ QObject::connect(mOfonoNetworkRegistration, SIGNAL(statusChanged(QString)), SLOT(updateOnlineStatus()));
108+ QObject::connect(mOfonoNetworkRegistration, SIGNAL(nameChanged(QString)), SLOT(updateOnlineStatus()));
109+ QObject::connect(mOfonoNetworkRegistration, SIGNAL(validityChanged(bool)), SLOT(updateOnlineStatus()));
110 QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailMessageCountChanged(int)), voicemailIface.data(), SLOT(setVoicemailCount(int)));
111 QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailWaitingChanged(bool)), voicemailIface.data(), SLOT(setVoicemailIndicator(bool)));
112 QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailMailboxNumberChanged(QString)), voicemailIface.data(), SLOT(setVoicemailNumber(QString)));
113@@ -412,8 +418,11 @@
114 bool oFonoConnection::isNetworkRegistered()
115 {
116 QString status = mOfonoNetworkRegistration->status();
117- return !(!mOfonoNetworkRegistration->modem() ||
118- !mOfonoNetworkRegistration->modem()->online() ||
119+ if (!mOfonoNetworkRegistration->isValid()) {
120+ return false;
121+ }
122+ return !(!mOfonoModem->isValid() ||
123+ !mOfonoModem->online() ||
124 status == "unregistered" ||
125 status == "denied" ||
126 status == "unknown" ||
127@@ -432,26 +441,11 @@
128 return false;
129 }
130
131-void oFonoConnection::onOfonoNetworkRegistrationChanged(const QString &status)
132-{
133- qDebug() << "onOfonoNetworkRegistrationChanged" << status << "is network registered: " << isNetworkRegistered();
134- if (!isNetworkRegistered() && mRequestedSelfPresence.type == Tp::ConnectionPresenceTypeAvailable) {
135- setOnline(false);
136- return;
137- }
138- setOnline(isNetworkRegistered());
139-}
140-
141 uint oFonoConnection::setPresence(const QString& status, const QString& statusMessage, Tp::DBusError *error)
142 {
143 qDebug() << "setPresence" << status;
144- if (status == "available") {
145- mRequestedSelfPresence.type = Tp::ConnectionPresenceTypeAvailable;
146- }
147- if(!mOfonoNetworkRegistration->modem() ||!mOfonoNetworkRegistration->modem()->online() || !isNetworkRegistered()) {
148- // this prevents tp-qt to propagate the available status
149- error->set(TP_QT_ERROR_NETWORK_ERROR, "Modem is offline");
150- }
151+ // this prevents tp-qt to propagate the available status
152+ error->set(TP_QT_ERROR_NOT_AVAILABLE, "Can't change online status: Operation not supported");
153 return selfHandle();
154 }
155
156@@ -477,28 +471,38 @@
157
158 void oFonoConnection::onValidityChanged(bool valid)
159 {
160- qDebug() << "validityChanged" << valid << "is network registered: " << isNetworkRegistered() << mRequestedSelfPresence.type;
161- QObject::disconnect(mOfonoVoiceCallManager->modem(), 0,0,0);
162- QObject::connect(mOfonoVoiceCallManager->modem(), SIGNAL(onlineChanged(bool)), SLOT(onValidityChanged(bool)));
163- supplementaryServicesIface->setSerial(mOfonoSupplementaryServices->modem()->serial());
164- if (!isNetworkRegistered() && mRequestedSelfPresence.type == Tp::ConnectionPresenceTypeAvailable) {
165- setOnline(false);
166+ // WORKAROUND: ofono-qt does not refresh the properties once the interface
167+ // becomes available, so it contains old values.
168+ Q_EMIT mOfonoSimManager->modem()->pathChanged(mOfonoModem->path());
169+ Q_EMIT mOfonoNetworkRegistration->modem()->pathChanged(mOfonoModem->path());
170+ QString modemSerial;
171+ if (valid) {
172+ modemSerial = mOfonoModem->serial();
173 }
174- setOnline(isNetworkRegistered());
175+ supplementaryServicesIface->setSerial(modemSerial);
176+ updateOnlineStatus();
177 }
178
179-void oFonoConnection::setOnline(bool online)
180+void oFonoConnection::updateOnlineStatus()
181 {
182- qDebug() << "setOnline" << online;
183 Tp::SimpleContactPresences presences;
184- if (online) {
185- mSelfPresence.status = "available";
186- mSelfPresence.statusMessage = "";
187+ mSelfPresence.statusMessage = "";
188+ mSelfPresence.type = Tp::ConnectionPresenceTypeOffline;
189+
190+ if (!mOfonoModem->isValid()) {
191+ mSelfPresence.status = "nomodem";
192+ } else if (!mOfonoModem->online()) {
193+ mSelfPresence.status = "flightmode";
194+ } else if ((mOfonoSimManager->isValid() && !mOfonoSimManager->present()) ||
195+ !mOfonoSimManager->isValid()) {
196+ mSelfPresence.status = "nosim";
197+ } else if (isNetworkRegistered()) {
198+ mSelfPresence.status = mOfonoNetworkRegistration->status();
199+ mSelfPresence.statusMessage = mOfonoNetworkRegistration->name();
200 mSelfPresence.type = Tp::ConnectionPresenceTypeAvailable;
201 } else {
202- mSelfPresence.status = "offline";
203- mSelfPresence.statusMessage = "";
204- mSelfPresence.type = Tp::ConnectionPresenceTypeOffline;
205+ mSelfPresence.status = mOfonoNetworkRegistration->status();
206+ mSelfPresence.type = Tp::ConnectionPresenceTypeAway;
207 }
208 presences[selfHandle()] = mSelfPresence;
209 simplePresenceIface->setPresences(presences);
210
211=== modified file 'connection.h'
212--- connection.h 2014-08-12 20:51:37 +0000
213+++ connection.h 2014-08-20 19:00:56 +0000
214@@ -27,6 +27,7 @@
215 #include <TelepathyQt/DBusError>
216
217 // ofono-qt
218+#include <ofonomodem.h>
219 #include <ofonomodemmanager.h>
220 #include <ofonomessagemanager.h>
221 #include <ofonovoicecallmanager.h>
222@@ -35,6 +36,7 @@
223 #include <ofononetworkregistration.h>
224 #include <ofonomessagewaiting.h>
225 #include <ofonosupplementaryservices.h>
226+#include <ofonosimmanager.h>
227
228 // telepathy-ofono
229 #include "ofonotextchannel.h"
230@@ -70,7 +72,6 @@
231 Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error);
232 uint setPresence(const QString& status, const QString& statusMessage, Tp::DBusError *error);
233 void connect(Tp::DBusError *error);
234- void setOnline(bool online);
235 void setSpeakerMode(bool active);
236 bool speakerMode();
237 QStringList emergencyNumbers(Tp::DBusError *error);
238@@ -123,7 +124,6 @@
239 void onOfonoIncomingMessage(const QString &message, const QVariantMap &info);
240 void onOfonoImmediateMessage(const QString &message, const QVariantMap &info);
241 void onOfonoCallAdded(const QString &call, const QVariantMap &properties);
242- void onOfonoNetworkRegistrationChanged(const QString &status);
243 void onTextChannelClosed();
244 void onCallChannelClosed();
245 void onCallChannelDestroyed();
246@@ -140,6 +140,7 @@
247 void onCallChannelSplitted();
248 void onMultipartyCallHeld();
249 void onMultipartyCallActive();
250+ void updateOnlineStatus();
251
252 private:
253 bool isNetworkRegistered();
254@@ -159,9 +160,10 @@
255 OfonoNetworkRegistration *mOfonoNetworkRegistration;
256 OfonoMessageWaiting *mOfonoMessageWaiting;
257 OfonoSupplementaryServices *mOfonoSupplementaryServices;
258+ OfonoSimManager *mOfonoSimManager;
259+ OfonoModem *mOfonoModem;
260 uint mHandleCount;
261 Tp::SimplePresence mSelfPresence;
262- Tp::SimplePresence mRequestedSelfPresence;
263 MMSDManager *mMmsdManager;
264 QMap<QString, MMSDService*> mMmsdServices;
265 QMap<QString, QList<MMSDMessage*> > mServiceMMSList;
266
267=== modified file 'tests/CallTest.cpp'
268--- tests/CallTest.cpp 2014-05-08 20:11:46 +0000
269+++ tests/CallTest.cpp 2014-08-20 19:00:56 +0000
270@@ -76,6 +76,7 @@
271 QSignalSpy spy(TelepathyHelper::instance(), SIGNAL(accountReady()));
272 QTRY_COMPARE(spy.count(), 1);
273
274+ OfonoMockController::instance()->SimManagerSetPresence(true);
275 OfonoMockController::instance()->ModemSetOnline();
276 OfonoMockController::instance()->NetworkRegistrationSetStatus("registered");
277 // the account should be connected
278
279=== modified file 'tests/ConnectionTest.cpp'
280--- tests/ConnectionTest.cpp 2014-05-08 20:11:46 +0000
281+++ tests/ConnectionTest.cpp 2014-08-20 19:00:56 +0000
282@@ -40,6 +40,7 @@
283 SIGNAL(accountReady()));
284 QTRY_COMPARE(spy.count(), 1);
285
286+ OfonoMockController::instance()->SimManagerSetPresence(true);
287 OfonoMockController::instance()->ModemSetOnline();
288 OfonoMockController::instance()->NetworkRegistrationSetStatus("registered");
289
290@@ -63,7 +64,7 @@
291 OfonoMockController::instance()->NetworkRegistrationSetStatus("unregistered");
292 QTRY_COMPARE(signalSpy.count(), 1);
293 Tp::Presence presence = signalSpy.first().first().value<Tp::Presence>();
294- QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
295+ QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAway);
296 signalSpy.clear();
297
298 // now set the modem as registered to the network again to see if it works
299@@ -73,21 +74,21 @@
300 QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAvailable);
301 signalSpy.clear();
302
303- // searching should be reported as offline
304+ // searching should be reported as away
305 OfonoMockController::instance()->NetworkRegistrationSetStatus("searching");
306 QTRY_COMPARE(signalSpy.count(), 1);
307 presence = signalSpy.first().first().value<Tp::Presence>();
308- QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
309+ QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAway);
310 signalSpy.clear();
311
312- // denied should be reported as offline (set registered first to force the signal to be emitted)
313+ // denied should be reported as away (set registered first to force the signal to be emitted)
314 OfonoMockController::instance()->NetworkRegistrationSetStatus("registered");
315 QTRY_COMPARE(signalSpy.count(), 1);
316 signalSpy.clear();
317 OfonoMockController::instance()->NetworkRegistrationSetStatus("denied");
318 QTRY_COMPARE(signalSpy.count(), 1);
319 presence = signalSpy.first().first().value<Tp::Presence>();
320- QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
321+ QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAway);
322 signalSpy.clear();
323
324 // unknown should be reported as offline (set registered first to force the signal to be emitted)
325@@ -97,7 +98,7 @@
326 OfonoMockController::instance()->NetworkRegistrationSetStatus("unknown");
327 QTRY_COMPARE(signalSpy.count(), 1);
328 presence = signalSpy.first().first().value<Tp::Presence>();
329- QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
330+ QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAway);
331 signalSpy.clear();
332
333 // roaming should be reported as available
334@@ -105,6 +106,13 @@
335 QTRY_COMPARE(signalSpy.count(), 1);
336 presence = signalSpy.first().first().value<Tp::Presence>();
337 QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAvailable);
338+ signalSpy.clear();
339+
340+ // offline modem should be reported as offline (flightmode)
341+ OfonoMockController::instance()->ModemSetOnline(false);
342+ QTRY_COMPARE(signalSpy.count(), 1);
343+ presence = signalSpy.first().first().value<Tp::Presence>();
344+ QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
345 }
346
347 QTEST_MAIN(ConnectionTest)
348
349=== modified file 'tests/MessagesTest.cpp'
350--- tests/MessagesTest.cpp 2014-05-08 20:11:46 +0000
351+++ tests/MessagesTest.cpp 2014-08-20 19:00:56 +0000
352@@ -65,6 +65,7 @@
353 QSignalSpy spy(TelepathyHelper::instance(), SIGNAL(accountReady()));
354 QTRY_COMPARE(spy.count(), 1);
355
356+ OfonoMockController::instance()->SimManagerSetPresence(true);
357 OfonoMockController::instance()->ModemSetOnline();
358 OfonoMockController::instance()->NetworkRegistrationSetStatus("registered");
359 // the account should be connected
360
361=== modified file 'tests/mock/CMakeLists.txt'
362--- tests/mock/CMakeLists.txt 2013-12-03 14:22:45 +0000
363+++ tests/mock/CMakeLists.txt 2014-08-20 19:00:56 +0000
364@@ -5,6 +5,7 @@
365 modemprivate.cpp
366 voicecallmanagerprivate.cpp
367 voicecallprivate.cpp
368+ simmanagerprivate.cpp
369 networkregistrationprivate.cpp
370 ofonocallvolume.cpp
371 ofonointerface.cpp
372@@ -17,6 +18,7 @@
373 ofononetworkregistration.cpp
374 ofonovoicecall.cpp
375 ofonovoicecallmanager.cpp
376+ ofonosimmanager.cpp
377 )
378
379 include_directories(
380@@ -30,6 +32,7 @@
381 qt5_add_dbus_adaptor(library_SRCS MessagePrivate.xml messageprivate.h MessagePrivate)
382 qt5_add_dbus_adaptor(library_SRCS VoiceCallManagerPrivate.xml voicecallmanagerprivate.h VoiceCallManagerPrivate)
383 qt5_add_dbus_adaptor(library_SRCS VoiceCallPrivate.xml voicecallprivate.h VoiceCallPrivate)
384+qt5_add_dbus_adaptor(library_SRCS SimManagerPrivate.xml simmanagerprivate.h SimManagerPrivate)
385
386 add_library(ofono-qt SHARED ${library_SRCS})
387
388
389=== added file 'tests/mock/SimManagerPrivate.xml'
390--- tests/mock/SimManagerPrivate.xml 1970-01-01 00:00:00 +0000
391+++ tests/mock/SimManagerPrivate.xml 2014-08-20 19:00:56 +0000
392@@ -0,0 +1,17 @@
393+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
394+<node>
395+ <interface name="org.ofono.SimManager">
396+ <signal name="PropertyChanged">
397+ <arg type="s" direction="out"/>
398+ <arg type="v" direction="out"/>
399+ </signal>
400+ <method name="GetProperties">
401+ <arg type="a{sv}" direction="out"/>
402+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
403+ </method>
404+ <method name="SetProperty">
405+ <arg name="name" type="s" direction="in"/>
406+ <arg name="value" type="v" direction="in"/>
407+ </method>
408+ </interface>
409+</node>
410
411=== modified file 'tests/mock/mock_common.h'
412--- tests/mock/mock_common.h 2013-12-03 14:22:45 +0000
413+++ tests/mock/mock_common.h 2014-08-20 19:00:56 +0000
414@@ -3,3 +3,4 @@
415 #define OFONO_MOCK_NETWORK_REGISTRATION_OBJECT "/OfonoNetworkRegistration"
416 #define OFONO_MOCK_VOICECALL_MANAGER_OBJECT "/OfonoVoiceCallManager"
417 #define OFONO_MOCK_CALL_VOLUME_OBJECT "/OfonoCallVolume"
418+#define OFONO_MOCK_SIM_MANAGER_OBJECT "/OfonoSimManager"
419
420=== added file 'tests/mock/ofonosimmanager.cpp'
421--- tests/mock/ofonosimmanager.cpp 1970-01-01 00:00:00 +0000
422+++ tests/mock/ofonosimmanager.cpp 2014-08-20 19:00:56 +0000
423@@ -0,0 +1,313 @@
424+/*
425+ * This file is part of ofono-qt
426+ *
427+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
428+ *
429+ * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
430+ *
431+ * This library is free software; you can redistribute it and/or
432+ * modify it under the terms of the GNU Lesser General Public License
433+ * version 2.1 as published by the Free Software Foundation.
434+ *
435+ * This library is distributed in the hope that it will be useful, but
436+ * WITHOUT ANY WARRANTY; without even the implied warranty of
437+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
438+ * Lesser General Public License for more details.
439+ *
440+ * You should have received a copy of the GNU Lesser General Public
441+ * License along with this library; if not, write to the Free Software
442+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
443+ * 02110-1301 USA
444+ *
445+ */
446+
447+#include <QtDBus/QtDBus>
448+#include <QtCore/QObject>
449+
450+#include "ofonosimmanager.h"
451+#include "ofonointerface.h"
452+#include "simmanagerprivate.h"
453+
454+OfonoSimManager::OfonoSimManager(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
455+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.SimManager", OfonoGetAllOnStartup, parent)
456+{
457+ qRegisterMetaType<OfonoServiceNumbers>("OfonoServiceNumbers");
458+ qRegisterMetaType<OfonoPinRetries>("OfonoPinRetries");
459+
460+ m_if->setPath(OFONO_MOCK_SIM_MANAGER_OBJECT);
461+ if (!simManagerData.keys().contains(modem()->path())) {
462+ simManagerData[modem()->path()] = new SimManagerPrivate();
463+ }
464+
465+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
466+ this, SLOT(propertyChanged(const QString&, const QVariant&)));
467+ connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
468+ this, SLOT(setPropertyFailed(const QString&)));
469+
470+}
471+
472+OfonoSimManager::~OfonoSimManager()
473+{
474+}
475+
476+void OfonoSimManager::changePin(const QString &pintype, const QString &oldpin, const QString &newpin)
477+{
478+ QDBusMessage request;
479+
480+ request = QDBusMessage::createMethodCall("org.ofono",
481+ path(), m_if->ifname(),
482+ "ChangePin");
483+ request << pintype << oldpin << newpin;
484+
485+ QDBusConnection::sessionBus().callWithCallback(request, this,
486+ SLOT(changePinResp()),
487+ SLOT(changePinErr(const QDBusError&)));
488+}
489+
490+void OfonoSimManager::enterPin(const QString &pintype, const QString &pin)
491+{
492+ QDBusMessage request;
493+
494+ request = QDBusMessage::createMethodCall("org.ofono",
495+ path(), m_if->ifname(),
496+ "EnterPin");
497+ request << pintype << pin;
498+
499+ QDBusConnection::sessionBus().callWithCallback(request, this,
500+ SLOT(enterPinResp()),
501+ SLOT(enterPinErr(const QDBusError&)));
502+}
503+
504+void OfonoSimManager::resetPin(const QString &pintype, const QString &puk, const QString &newpin)
505+{
506+ QDBusMessage request;
507+
508+ request = QDBusMessage::createMethodCall("org.ofono",
509+ path(), m_if->ifname(),
510+ "ResetPin");
511+ request << pintype << puk << newpin;
512+
513+ QDBusConnection::sessionBus().callWithCallback(request, this,
514+ SLOT(resetPinResp()),
515+ SLOT(resetPinErr(const QDBusError&)));
516+}
517+
518+void OfonoSimManager::lockPin(const QString &pintype, const QString &pin)
519+{
520+ QDBusMessage request;
521+
522+ request = QDBusMessage::createMethodCall("org.ofono",
523+ path(), m_if->ifname(),
524+ "LockPin");
525+ request << pintype << pin;
526+
527+ QDBusConnection::sessionBus().callWithCallback(request, this,
528+ SLOT(lockPinResp()),
529+ SLOT(lockPinErr(const QDBusError&)));
530+}
531+
532+void OfonoSimManager::unlockPin(const QString &pintype, const QString &pin)
533+{
534+ QDBusMessage request;
535+
536+ request = QDBusMessage::createMethodCall("org.ofono",
537+ path(), m_if->ifname(),
538+ "UnlockPin");
539+ request << pintype << pin;
540+
541+ QDBusConnection::sessionBus().callWithCallback(request, this,
542+ SLOT(unlockPinResp()),
543+ SLOT(unlockPinErr(const QDBusError&)));
544+}
545+
546+void OfonoSimManager::getIcon(quint8 id)
547+{
548+ QDBusMessage request;
549+
550+ request = QDBusMessage::createMethodCall("org.ofono",
551+ path(), m_if->ifname(),
552+ "GetIcon");
553+ request << qVariantFromValue(id);
554+
555+ QDBusConnection::sessionBus().callWithCallback(request, this,
556+ SLOT(getIconResp(QByteArray)),
557+ SLOT(getIconErr(const QDBusError&)));
558+}
559+
560+void OfonoSimManager::setSubscriberNumbers(const QStringList &numbers)
561+{
562+ m_if->setProperty("SubscriberNumbers", qVariantFromValue(numbers));
563+}
564+
565+bool OfonoSimManager::present() const
566+{
567+ return m_if->properties()["Present"].value<bool>();
568+}
569+
570+QString OfonoSimManager::subscriberIdentity() const
571+{
572+ return m_if->properties()["SubscriberIdentity"].value<QString>();
573+}
574+
575+QString OfonoSimManager::mobileCountryCode() const
576+{
577+ return m_if->properties()["MobileCountryCode"].value<QString>();
578+}
579+
580+QString OfonoSimManager::mobileNetworkCode() const
581+{
582+ return m_if->properties()["MobileNetworkCode"].value<QString>();
583+}
584+
585+QStringList OfonoSimManager::subscriberNumbers() const
586+{
587+ return m_if->properties()["SubscriberNumbers"].value<QStringList>();
588+}
589+
590+OfonoServiceNumbers OfonoSimManager::serviceNumbers() const
591+{
592+ OfonoServiceNumbers map;
593+ m_if->properties()["ServiceNumbers"].value<QDBusArgument>() >> map;
594+ return map;
595+}
596+
597+QString OfonoSimManager::pinRequired() const
598+{
599+ return m_if->properties()["PinRequired"].value<QString>();
600+}
601+
602+QStringList OfonoSimManager::lockedPins() const
603+{
604+ return m_if->properties()["LockedPins"].value<QStringList>();
605+}
606+
607+QString OfonoSimManager::cardIdentifier() const
608+{
609+ return m_if->properties()["CardIdentifier"].value<QString>();
610+}
611+
612+QStringList OfonoSimManager::preferredLanguages() const
613+{
614+ return m_if->properties()["PreferredLanguages"].value<QStringList>();
615+}
616+
617+OfonoPinRetries OfonoSimManager::pinRetries() const
618+{
619+ OfonoPinRetries retries;
620+ m_if->properties()["Retries"].value<QDBusArgument>() >> retries;
621+ return retries;
622+}
623+
624+bool OfonoSimManager::fixedDialing() const
625+{
626+ return m_if->properties()["FixedDialing"].value<bool>();
627+}
628+
629+bool OfonoSimManager::barredDialing() const
630+{
631+ return m_if->properties()["BarredDialing"].value<bool>();
632+}
633+
634+void OfonoSimManager::propertyChanged(const QString& property, const QVariant& value)
635+{
636+ if (property == "Present") {
637+ Q_EMIT presenceChanged(value.value<bool>());
638+ } else if (property == "SubscriberIdentity") {
639+ Q_EMIT subscriberIdentityChanged(value.value<QString>());
640+ } else if (property == "MobileCountryCode") {
641+ Q_EMIT mobileCountryCodeChanged(value.value<QString>());
642+ } else if (property == "MobileNetworkCode") {
643+ Q_EMIT mobileNetworkCodeChanged(value.value<QString>());
644+ } else if (property == "SubscriberNumbers") {
645+ Q_EMIT subscriberNumbersChanged(value.value<QStringList>());
646+ } else if (property == "ServiceNumbers") {
647+ OfonoServiceNumbers map;
648+ value.value<QDBusArgument>() >> map;
649+ Q_EMIT serviceNumbersChanged(map);
650+ } else if (property == "PinRequired") {
651+ Q_EMIT pinRequiredChanged(value.value<QString>());
652+ } else if (property == "LockedPins") {
653+ Q_EMIT lockedPinsChanged(value.value<QStringList>());
654+ } else if (property == "CardIdentifier") {
655+ Q_EMIT cardIdentifierChanged(value.value<QString>());
656+ } else if (property == "PreferredLanguages") {
657+ Q_EMIT preferredLanguagesChanged(value.value<QStringList>());
658+ } else if (property == "Retries") {
659+ OfonoPinRetries retries;
660+ value.value<QDBusArgument>() >> retries;
661+ Q_EMIT pinRetriesChanged(retries);
662+ } else if (property == "FixedDialing") {
663+ Q_EMIT fixedDialingChanged(value.value<bool>());
664+ } else if (property == "BarredDialing") {
665+ Q_EMIT barredDialingChanged(value.value<bool>());
666+ }
667+}
668+
669+void OfonoSimManager::setPropertyFailed(const QString& property)
670+{
671+ if (property == "SubscriberNumbers")
672+ Q_EMIT setSubscriberNumbersFailed();
673+}
674+
675+void OfonoSimManager::changePinResp()
676+{
677+ Q_EMIT changePinComplete(true);
678+}
679+
680+void OfonoSimManager::changePinErr(QDBusError error)
681+{
682+ m_if->setError(error.name(), error.message());
683+ Q_EMIT changePinComplete(false);
684+}
685+
686+void OfonoSimManager::enterPinResp()
687+{
688+ Q_EMIT enterPinComplete(true);
689+}
690+
691+void OfonoSimManager::enterPinErr(QDBusError error)
692+{
693+ m_if->setError(error.name(), error.message());
694+ Q_EMIT enterPinComplete(false);
695+}
696+
697+void OfonoSimManager::resetPinResp()
698+{
699+ Q_EMIT resetPinComplete(true);
700+}
701+
702+void OfonoSimManager::resetPinErr(QDBusError error)
703+{
704+ m_if->setError(error.name(), error.message());
705+ Q_EMIT resetPinComplete(false);
706+}
707+
708+void OfonoSimManager::lockPinResp()
709+{
710+ Q_EMIT lockPinComplete(true);
711+}
712+void OfonoSimManager::lockPinErr(QDBusError error)
713+{
714+ m_if->setError(error.name(), error.message());
715+ Q_EMIT lockPinComplete(false);
716+}
717+
718+void OfonoSimManager::unlockPinResp()
719+{
720+ Q_EMIT unlockPinComplete(true);
721+}
722+void OfonoSimManager::unlockPinErr(QDBusError error)
723+{
724+ m_if->setError(error.name(), error.message());
725+ Q_EMIT unlockPinComplete(false);
726+}
727+
728+void OfonoSimManager::getIconResp(QByteArray icon)
729+{
730+ Q_EMIT getIconComplete(true, icon);
731+}
732+void OfonoSimManager::getIconErr(QDBusError error)
733+{
734+ m_if->setError(error.name(), error.message());
735+ Q_EMIT getIconComplete(false, QByteArray());
736+}
737
738=== added file 'tests/mock/ofonosimmanager.h'
739--- tests/mock/ofonosimmanager.h 1970-01-01 00:00:00 +0000
740+++ tests/mock/ofonosimmanager.h 2014-08-20 19:00:56 +0000
741@@ -0,0 +1,134 @@
742+/*
743+ * This file is part of ofono-qt
744+ *
745+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
746+ *
747+ * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
748+ *
749+ * This library is free software; you can redistribute it and/or
750+ * modify it under the terms of the GNU Lesser General Public License
751+ * version 2.1 as published by the Free Software Foundation.
752+ *
753+ * This library is distributed in the hope that it will be useful, but
754+ * WITHOUT ANY WARRANTY; without even the implied warranty of
755+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
756+ * Lesser General Public License for more details.
757+ *
758+ * You should have received a copy of the GNU Lesser General Public
759+ * License along with this library; if not, write to the Free Software
760+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
761+ * 02110-1301 USA
762+ *
763+ */
764+
765+#ifndef OFONOSIMMANAGER_H
766+#define OFONOSIMMANAGER_H
767+
768+#include <QtCore/QObject>
769+#include <QStringList>
770+#include <QDBusError>
771+#include "ofonomodeminterface.h"
772+#include "libofono-qt_global.h"
773+
774+typedef QMap<QString, QString> OfonoServiceNumbers;
775+Q_DECLARE_METATYPE(OfonoServiceNumbers);
776+
777+typedef QMap<QString, quint8> OfonoPinRetries;
778+Q_DECLARE_METATYPE(OfonoPinRetries);
779+
780+//! This class is used to access oFono SIM API
781+/*!
782+ * The API is documented in
783+ * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/sim-api.txt
784+ */
785+class OFONO_QT_EXPORT OfonoSimManager : public OfonoModemInterface
786+{
787+ Q_OBJECT
788+
789+ Q_PROPERTY(bool present READ present NOTIFY presenceChanged)
790+ Q_PROPERTY(QString subscriberIdentity READ subscriberIdentity NOTIFY subscriberIdentityChanged)
791+ Q_PROPERTY(QString mobileCountryCode READ mobileCountryCode NOTIFY mobileCountryCodeChanged)
792+ Q_PROPERTY(QString mobileNetworkCode READ mobileNetworkCode NOTIFY mobileNetworkCodeChanged)
793+ Q_PROPERTY(QStringList subscriberNumbers READ subscriberNumbers WRITE setSubscriberNumbers NOTIFY subscriberNumbersChanged)
794+ Q_PROPERTY(QString pinRequired READ pinRequired NOTIFY pinRequiredChanged)
795+ Q_PROPERTY(QStringList lockedPins READ lockedPins NOTIFY lockedPinsChanged)
796+ Q_PROPERTY(QString cardIdentifier READ cardIdentifier NOTIFY cardIdentifierChanged)
797+ Q_PROPERTY(QStringList preferredLanguages READ preferredLanguages NOTIFY preferredLanguagesChanged)
798+ Q_PROPERTY(OfonoPinRetries pinRetries READ pinRetries NOTIFY pinRetriesChanged)
799+ Q_PROPERTY(bool fixedDialing READ fixedDialing NOTIFY fixedDialingChanged)
800+ Q_PROPERTY(bool barredDialing READ barredDialing NOTIFY barredDialingChanged)
801+
802+public:
803+ OfonoSimManager(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent=0);
804+ ~OfonoSimManager();
805+
806+ /* Properties */
807+ bool present() const;
808+ QString subscriberIdentity() const;
809+ QString mobileCountryCode() const;
810+ QString mobileNetworkCode() const;
811+ QStringList subscriberNumbers() const;
812+ OfonoServiceNumbers serviceNumbers() const;
813+ QString pinRequired() const;
814+ QStringList lockedPins() const;
815+ QString cardIdentifier() const;
816+ QStringList preferredLanguages() const;
817+ OfonoPinRetries pinRetries() const;
818+ bool fixedDialing() const;
819+ bool barredDialing() const;
820+
821+public Q_SLOTS:
822+ void changePin(const QString &pintype, const QString &oldpin, const QString &newpin);
823+ void enterPin(const QString &pintype, const QString &pin);
824+ void resetPin(const QString &pintype, const QString &puk, const QString &newpin);
825+ void lockPin(const QString &pintype, const QString &pin);
826+ void unlockPin(const QString &pintype, const QString &pin);
827+ void getIcon(quint8 id);
828+
829+ void setSubscriberNumbers(const QStringList &numbers);
830+
831+Q_SIGNALS:
832+ void presenceChanged(bool ispresent);
833+ void subscriberIdentityChanged(const QString &imsi);
834+ void mobileCountryCodeChanged(const QString &mcc);
835+ void mobileNetworkCodeChanged(const QString &mnc);
836+ void subscriberNumbersChanged(const QStringList &msisdns);
837+ void setSubscriberNumbersFailed();
838+ void serviceNumbersChanged(const OfonoServiceNumbers &sdns);
839+ void pinRequiredChanged(const QString &pintype);
840+ void lockedPinsChanged(const QStringList &pins);
841+ void cardIdentifierChanged(const QString &iccid);
842+ void preferredLanguagesChanged(const QStringList &languages);
843+ void pinRetriesChanged(const OfonoPinRetries &pinRetries);
844+ void fixedDialingChanged(bool fixedDialing);
845+ void barredDialingChanged(bool barredDialing);
846+
847+ void changePinComplete(bool success);
848+ void enterPinComplete(bool success);
849+ void resetPinComplete(bool success);
850+ void lockPinComplete(bool success);
851+ void unlockPinComplete(bool success);
852+ void getIconComplete(bool success, const QByteArray &icon);
853+
854+private Q_SLOTS:
855+ void propertyChanged(const QString& property, const QVariant& value);
856+ void setPropertyFailed(const QString& property);
857+
858+ void changePinResp();
859+ void changePinErr(QDBusError error);
860+ void enterPinResp();
861+ void enterPinErr(QDBusError error);
862+ void resetPinResp();
863+ void resetPinErr(QDBusError error);
864+ void lockPinResp();
865+ void lockPinErr(QDBusError error);
866+ void unlockPinResp();
867+ void unlockPinErr(QDBusError error);
868+ void getIconResp(QByteArray icon);
869+ void getIconErr(QDBusError error);
870+
871+private:
872+
873+};
874+
875+#endif /* !OFONOSIMMANAGER_H */
876
877=== added file 'tests/mock/simmanagerprivate.cpp'
878--- tests/mock/simmanagerprivate.cpp 1970-01-01 00:00:00 +0000
879+++ tests/mock/simmanagerprivate.cpp 2014-08-20 19:00:56 +0000
880@@ -0,0 +1,46 @@
881+/**
882+ * Copyright (C) 2013 Canonical, Ltd.
883+ *
884+ * This program is free software: you can redistribute it and/or modify it under
885+ * the terms of the GNU Lesser General Public License version 3, as published by
886+ * the Free Software Foundation.
887+ *
888+ * This program is distributed in the hope that it will be useful, but WITHOUT
889+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
890+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
891+ * Lesser General Public License for more details.
892+ *
893+ * You should have received a copy of the GNU Lesser General Public License
894+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
895+ *
896+ * Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
897+ */
898+
899+#include <QDBusConnection>
900+
901+#include "simmanagerprivateadaptor.h"
902+
903+QMap<QString, SimManagerPrivate*> simManagerData;
904+
905+SimManagerPrivate::SimManagerPrivate(QObject *parent) :
906+ QObject(parent)
907+{
908+ QDBusConnection::sessionBus().registerObject(OFONO_MOCK_SIM_MANAGER_OBJECT, this);
909+ QDBusConnection::sessionBus().registerService("org.ofono");
910+ new SimManagerAdaptor(this);
911+}
912+
913+SimManagerPrivate::~SimManagerPrivate()
914+{
915+}
916+
917+QVariantMap SimManagerPrivate::GetProperties()
918+{
919+ return mProperties;
920+}
921+
922+void SimManagerPrivate::SetProperty(const QString &name, const QDBusVariant& value)
923+{
924+ mProperties[name] = value.variant();
925+ Q_EMIT PropertyChanged(name, value);
926+}
927
928=== added file 'tests/mock/simmanagerprivate.h'
929--- tests/mock/simmanagerprivate.h 1970-01-01 00:00:00 +0000
930+++ tests/mock/simmanagerprivate.h 2014-08-20 19:00:56 +0000
931@@ -0,0 +1,42 @@
932+/**
933+ * Copyright (C) 2013 Canonical, Ltd.
934+ *
935+ * This program is free software: you can redistribute it and/or modify it under
936+ * the terms of the GNU Lesser General Public License version 3, as published by
937+ * the Free Software Foundation.
938+ *
939+ * This program is distributed in the hope that it will be useful, but WITHOUT
940+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
941+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
942+ * Lesser General Public License for more details.
943+ *
944+ * You should have received a copy of the GNU Lesser General Public License
945+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
946+ *
947+ * Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
948+ */
949+
950+#ifndef SIMMANAGERPRIVATE_H
951+#define SIMMANAGERPRIVATE_H
952+
953+#include <QDBusContext>
954+#include "mock_common.h"
955+
956+class SimManagerPrivate : public QObject, protected QDBusContext {
957+ Q_OBJECT
958+ Q_CLASSINFO("D-Bus Interface", "org.ofono.SimManager")
959+public:
960+ SimManagerPrivate(QObject *parent = 0);
961+ ~SimManagerPrivate();
962+Q_SIGNALS:
963+ void PropertyChanged(const QString &, const QDBusVariant &);
964+public Q_SLOTS:
965+ QVariantMap GetProperties();
966+ void SetProperty(const QString &name, const QDBusVariant &value);
967+private:
968+ QVariantMap mProperties;
969+};
970+
971+extern QMap<QString, SimManagerPrivate*> simManagerData;
972+
973+#endif
974
975=== modified file 'tests/ofonomockcontroller.cpp'
976--- tests/ofonomockcontroller.cpp 2014-05-08 20:11:46 +0000
977+++ tests/ofonomockcontroller.cpp 2014-08-20 19:00:56 +0000
978@@ -26,12 +26,14 @@
979 mNetworkRegistrationInterface("org.ofono", OFONO_MOCK_NETWORK_REGISTRATION_OBJECT, "org.ofono.NetworkRegistration"),
980 mMessageManagerInterface("org.ofono", OFONO_MOCK_MESSAGE_MANAGER_OBJECT, "org.ofono.MessageManager"),
981 mVoiceCallManagerInterface("org.ofono", OFONO_MOCK_VOICECALL_MANAGER_OBJECT, "org.ofono.VoiceCallManager"),
982- mModemInterface("org.ofono", OFONO_MOCK_MODEM_OBJECT, "org.ofono.Modem")
983+ mModemInterface("org.ofono", OFONO_MOCK_MODEM_OBJECT, "org.ofono.Modem"),
984+ mSimManagerInterface("org.ofono", OFONO_MOCK_SIM_MANAGER_OBJECT, "org.ofono.SimManager")
985 {
986 QDBusConnection::sessionBus().connect("org.ofono", OFONO_MOCK_MESSAGE_MANAGER_OBJECT, "org.ofono.MessageManager", "MessageAdded", this, SIGNAL(MessageAdded(QDBusObjectPath, QVariantMap)));
987 QDBusConnection::sessionBus().connect("org.ofono", OFONO_MOCK_VOICECALL_MANAGER_OBJECT, "org.ofono.VoiceCallManager", "CallAdded", this, SIGNAL(CallAdded(QDBusObjectPath, QVariantMap)));
988 QDBusConnection::sessionBus().connect("org.ofono", OFONO_MOCK_VOICECALL_MANAGER_OBJECT, "org.ofono.VoiceCallManager", "TonesReceived", this, SIGNAL(TonesReceived(QString)));
989 QDBusConnection::sessionBus().connect("org.ofono", OFONO_MOCK_CALL_VOLUME_OBJECT, "org.ofono.CallVolume", "PropertyChanged", this, SLOT(onCallVolumePropertyChanged(QString, QDBusVariant)));
990+ QDBusConnection::sessionBus().connect("org.ofono", OFONO_MOCK_SIM_MANAGER_OBJECT, "org.ofono.SimManager", "PropertyChanged", this, SLOT(onSimManagerPropertyChanged(QString, QDBusVariant)));
991 }
992
993 OfonoMockController *OfonoMockController::instance()
994@@ -40,6 +42,13 @@
995 return self;
996 }
997
998+void OfonoMockController::onSimManagerPropertyChanged(const QString& name, const QDBusVariant& value)
999+{
1000+ if (name == "Present") {
1001+ Q_EMIT SimManagerPresenceChanged(value.variant().value<bool>());
1002+ }
1003+}
1004+
1005 void OfonoMockController::onCallVolumePropertyChanged(const QString& name, const QDBusVariant& value)
1006 {
1007 if (name == "Muted") {
1008@@ -110,8 +119,12 @@
1009 iface.call("Hangup");
1010 }
1011
1012-void OfonoMockController::ModemSetOnline()
1013+void OfonoMockController::ModemSetOnline(bool online)
1014 {
1015- mModemInterface.call("SetProperty", "Online", QVariant::fromValue(QDBusVariant(true)));
1016+ mModemInterface.call("SetProperty", "Online", QVariant::fromValue(QDBusVariant(online)));
1017 }
1018
1019+void OfonoMockController::SimManagerSetPresence(bool present)
1020+{
1021+ mSimManagerInterface.call("SetProperty", "Present", QVariant::fromValue(QDBusVariant(present)));
1022+}
1023
1024=== modified file 'tests/ofonomockcontroller.h'
1025--- tests/ofonomockcontroller.h 2014-05-08 20:11:46 +0000
1026+++ tests/ofonomockcontroller.h 2014-08-20 19:00:56 +0000
1027@@ -35,6 +35,7 @@
1028 void CallAdded(QDBusObjectPath, QVariantMap);
1029 void TonesReceived(QString);
1030 void CallVolumeMuteChanged(bool muted);
1031+ void SimManagerPresenceChanged(bool present);
1032
1033 public Q_SLOTS:
1034 void NetworkRegistrationSetStatus(const QString &status);
1035@@ -48,10 +49,12 @@
1036 void VoiceCallHangup(const QString &objPath);
1037 void VoiceCallAnswer(const QString &objPath);
1038 void VoiceCallSetAlerting(const QString &objPath);
1039- void ModemSetOnline();
1040+ void ModemSetOnline(bool online = true);
1041+ void SimManagerSetPresence(bool present);
1042
1043 private Q_SLOTS:
1044 void onCallVolumePropertyChanged(const QString &name, const QDBusVariant &value);
1045+ void onSimManagerPropertyChanged(const QString &name, const QDBusVariant &value);
1046
1047 private:
1048 explicit OfonoMockController(QObject *parent = 0);
1049@@ -59,6 +62,7 @@
1050 QDBusInterface mMessageManagerInterface;
1051 QDBusInterface mVoiceCallManagerInterface;
1052 QDBusInterface mModemInterface;
1053+ QDBusInterface mSimManagerInterface;
1054 };
1055
1056 #endif // OFONOMOCKCONTROLLER_H

Subscribers

People subscribed via source and target branches