1
Index: libqofono-0.79/src/dbus/ofono_connection_manager.xml
2
===================================================================
3
--- libqofono-0.79.orig/src/dbus/ofono_connection_manager.xml
4
+++ libqofono-0.79/src/dbus/ofono_connection_manager.xml
6
<arg type="o" direction="in"/>
8
<method name="DeactivateAll"/>
9
+ <method name="ResetContexts"/>
10
<method name="GetContexts">
11
<arg type="a(oa{sv})" direction="out"/>
12
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="ObjectPathPropertiesList"/>
13
Index: libqofono-0.79/src/qofonoconnectionmanager.cpp
14
===================================================================
15
--- libqofono-0.79.orig/src/qofonoconnectionmanager.cpp
16
+++ libqofono-0.79/src/qofonoconnectionmanager.cpp
17
@@ -143,6 +143,21 @@ void QOfonoConnectionManager::removeCont
21
+void QOfonoConnectionManager::resetContexts()
23
+ OfonoConnectionManager *iface = (OfonoConnectionManager*)dbusInterface();
25
+ QDBusPendingReply<> deactivate = iface->DeactivateAll();
26
+ deactivate.waitForFinished();
27
+ QDBusPendingReply<> reset = iface->ResetContexts();
28
+ reset.waitForFinished();
29
+ if (reset.isError()) {
30
+ qDebug() << reset.error();
31
+ Q_EMIT reportError(reset.error().message());
36
bool QOfonoConnectionManager::attached() const
38
return getBool("Attached");
39
Index: libqofono-0.79/src/qofonoconnectionmanager.h
40
===================================================================
41
--- libqofono-0.79.orig/src/qofonoconnectionmanager.h
42
+++ libqofono-0.79/src/qofonoconnectionmanager.h
43
@@ -79,6 +79,7 @@ public slots:
45
void addContext(const QString &type);
46
void removeContext(const QString &path);
47
+ void resetContexts();
50
void onAddContextFinished(QDBusPendingCallWatcher *watch);
51
Index: libqofono-0.79/test/auto/tests/tst_qofonoconnman.cpp
52
===================================================================
53
--- libqofono-0.79.orig/test/auto/tests/tst_qofonoconnman.cpp
54
+++ libqofono-0.79/test/auto/tests/tst_qofonoconnman.cpp
55
@@ -107,8 +107,45 @@ private slots:
56
QCOMPARE(rem.count(), 0);
59
+ void testResetContexts()
61
+ Q_FOREACH (QString context, m->contexts()) {
62
+ m->removeContext(context);
64
+ QTRY_VERIFY(m->contexts().isEmpty());
66
+ QSignalSpy pow(m, SIGNAL(poweredChanged(bool)));
67
+ QSignalSpy add(m, SIGNAL(contextAdded(QString)));
68
+ QSignalSpy rem(m, SIGNAL(contextRemoved(QString)));
71
+ m->addContext(QString("internet"));
72
+ QTRY_COMPARE(add.count(), 1);
73
+ QString path = add.takeFirst().at(0).toString();
74
+ QOfonoConnectionContext* contextInternet = new QOfonoConnectionContext(this);
75
+ contextInternet->setContextPath(path);
77
+ // We activate context to make sure connman is deactivating on reset.
78
+ contextInternet->setActive(true);
79
+ QTRY_VERIFY(contextInternet->active());
81
+ // Connman needs to be powered down before calling reset.
82
+ m->setPowered(false);
83
+ QTRY_COMPARE(pow.count(), 1);
84
+ QCOMPARE(pow.takeFirst().at(0).toBool(), false);
85
+ QCOMPARE(m->powered(), false);
88
+ QTRY_COMPARE(rem.count(), 1);
91
void cleanupTestCase()
93
+ QSignalSpy pow(m, SIGNAL(poweredChanged(bool)));
94
+ m->setPowered(true);
95
+ QTRY_COMPARE(pow.count(), 1);
96
+ QCOMPARE(pow.takeFirst().at(0).toBool(), true);
97
+ QCOMPARE(m->powered(), true);