~ken-vandine/libqofono/0.82

« back to all changes in this revision

Viewing changes to debian/patches/connman-resetcontexts.patch

  • Committer: Ken VanDine
  • Date: 2015-09-11 12:09:56 UTC
  • Revision ID: ken.vandine@canonical.com-20150911120956-vtls3uz6e82lhny3
added packaging

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
5
@@ -18,6 +18,7 @@
 
6
                        <arg type="o" direction="in"/>
 
7
                </method>
 
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
 
18
     }
 
19
 }
 
20
 
 
21
+void QOfonoConnectionManager::resetContexts()
 
22
+{
 
23
+    OfonoConnectionManager *iface = (OfonoConnectionManager*)dbusInterface();
 
24
+    if (iface) {
 
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());
 
32
+        }
 
33
+    }
 
34
+}
 
35
+
 
36
 bool QOfonoConnectionManager::attached() const
 
37
 {
 
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:
 
44
     void deactivateAll();
 
45
     void addContext(const QString &type);
 
46
     void removeContext(const QString &path);
 
47
+    void resetContexts();
 
48
 
 
49
 private slots:
 
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);
 
57
     }
 
58
 
 
59
+    void testResetContexts()
 
60
+    {
 
61
+        Q_FOREACH (QString context, m->contexts()) {
 
62
+            m->removeContext(context);
 
63
+        }
 
64
+        QTRY_VERIFY(m->contexts().isEmpty());
 
65
+
 
66
+        QSignalSpy pow(m, SIGNAL(poweredChanged(bool)));
 
67
+        QSignalSpy add(m, SIGNAL(contextAdded(QString)));
 
68
+        QSignalSpy rem(m, SIGNAL(contextRemoved(QString)));
 
69
+
 
70
+        // Add new context.
 
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);
 
76
+
 
77
+        // We activate context to make sure connman is deactivating on reset.
 
78
+        contextInternet->setActive(true);
 
79
+        QTRY_VERIFY(contextInternet->active());
 
80
+
 
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);
 
86
+
 
87
+        m->resetContexts();
 
88
+        QTRY_COMPARE(rem.count(), 1);
 
89
+    }
 
90
+
 
91
     void cleanupTestCase()
 
92
     {
 
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);
 
98
     }
 
99
 
 
100
 private: