context-preferred.patch 3.74 KB
Newer Older
Jonah Brüchert's avatar
Jonah Brüchert committed
1 2
--- a/src/qofonoconnectioncontext.cpp
+++ b/src/qofonoconnectioncontext.cpp
JBBgameich's avatar
JBBgameich committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
@@ -117,6 +117,8 @@ void QOfonoConnectionContext::propertyCh
     SUPER::propertyChanged(property, value);
     if (property == QLatin1String("Active")) {
         Q_EMIT activeChanged(value.value<bool>());
+    } else if (property == QLatin1String("Preferred")) {
+        Q_EMIT preferredChanged(value.value<bool>());
     } else if (property == QLatin1String("Name")) {
         Q_EMIT nameChanged(value.value<QString>());
     } else if (property == QLatin1String("AccessPointName")) {
@@ -147,6 +149,11 @@ bool QOfonoConnectionContext::active() c
     return getBool("Active");
 }
 
+bool QOfonoConnectionContext::preferred() const
+{
+    return getBool("Preferred");
+}
+
 QString QOfonoConnectionContext::accessPointName() const
 {
     return getString("AccessPointName");
@@ -211,6 +218,11 @@ void QOfonoConnectionContext::setActive(
     setProperty("Active", value);
 }
 
+void QOfonoConnectionContext::setPreferred(const bool value)
+{
+    setProperty("Preferred", value);
+}
+
 void QOfonoConnectionContext::setAccessPointName(const QString &value)
 {
     setProperty("AccessPointName", value);
Jonah Brüchert's avatar
Jonah Brüchert committed
36 37
--- a/src/qofonoconnectioncontext.h
+++ b/src/qofonoconnectioncontext.h
JBBgameich's avatar
JBBgameich committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
@@ -28,6 +28,7 @@ class QOFONOSHARED_EXPORT QOfonoConnecti
 {
     Q_OBJECT
     Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
+    Q_PROPERTY(bool preferred READ preferred WRITE setPreferred NOTIFY preferredChanged)
     Q_PROPERTY(bool provisioning READ provisioning NOTIFY provisioningChanged)
     Q_PROPERTY(QString accessPointName READ accessPointName WRITE setAccessPointName NOTIFY accessPointNameChanged)
     Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
@@ -56,6 +57,9 @@ public:
 
     bool provisioning() const;
 
+    bool preferred() const;
+    void setPreferred(bool);
+
     QString accessPointName() const;
     void setAccessPointName(const QString &);
 
@@ -104,6 +108,7 @@ public:
 Q_SIGNALS:
     void disconnectRequested();
     void activeChanged(bool active);
+    void preferredChanged(bool preferred);
     void provisioningChanged(bool provisioning);
     void accessPointNameChanged(const QString &apn);
     void nameChanged(const QString &name);
Jonah Brüchert's avatar
Jonah Brüchert committed
64 65
--- a/test/auto/tests/tst_qofonoconnmancontext.cpp
+++ b/test/auto/tests/tst_qofonoconnmancontext.cpp
JBBgameich's avatar
JBBgameich committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
@@ -61,6 +61,7 @@ private slots:
         QTRY_COMPARE(context->isValid(), true);
 
         QSignalSpy active(context, SIGNAL(activeChanged(bool)));
+        QSignalSpy preferred(context, SIGNAL(preferredChanged(bool)));
         QSignalSpy apn(context,SIGNAL(accessPointNameChanged(QString)));
         QSignalSpy name(context, SIGNAL(nameChanged(QString)));
         QSignalSpy type (context, SIGNAL(typeChanged(QString)));
@@ -93,6 +94,10 @@ private slots:
         QTRY_COMPARE(active.count(), 1);
         QCOMPARE(active.takeFirst().at(0).toBool(), true);
 
+        context->setPreferred(true);
+        QTRY_COMPARE(preferred.count(), 1);
+        QCOMPARE(preferred.takeFirst().at(0).toBool(), true);
+
         QTRY_COMPARE(sett6.count(), 1);
         QCOMPARE(sett6.takeFirst().at(0).toMap()["Interface"].value<QString>().left(5),
             QString("dummy")); // "dummy" plus number
@@ -109,11 +114,16 @@ private slots:
         QCOMPARE(sett.count(), 0);
         QCOMPARE(proto.count(), 0);
         QCOMPARE(active.count(), 0);
+        QCOMPARE(preferred.count(), 0);
 
         context->setActive(false);
         QTRY_COMPARE(active.count(), 1);
         QCOMPARE(active.takeFirst().at(0).toBool(), false);
 
+        context->setPreferred(false);
+        QTRY_COMPARE(preferred.count(), 1);
+        QCOMPARE(preferred.takeFirst().at(0).toBool(), false);
+
         delete context;
 
         m->removeContext(contextid);