aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-connectivity/libqofono/libqofono/0001-also-emit-modemRemoved-and-modemAdded.patch
blob: f33a391267a4c91a170256fddf5866af89ac8205 (plain)
1
2
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From d2ceb83fe889d7cb40ad1e0d71e75d726a87fb28 Mon Sep 17 00:00:00 2001
From: Christophe Chapuis <chris.chapuis@gmail.com>
Date: Sat, 13 Jul 2019 11:17:08 +0000
Subject: [PATCH] onGetModemsFinished: also emit modemRemoved and modemAdded

VoiceCall only subscribes to these events, so we need to emit these
more "atomic" events too.

Signed-off-by: Christophe Chapuis <chris.chapuis@gmail.com>

---
 src/qofonomanager.cpp | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/qofonomanager.cpp b/src/qofonomanager.cpp
index e1da658..38cf0e4 100644
--- a/src/qofonomanager.cpp
+++ b/src/qofonomanager.cpp
@@ -88,15 +88,30 @@ void QOfonoManager::Private::handleGetModemsReply(QOfonoManager *obj, ObjectPath
 {
     const bool wasAvailable = available;
     QString prevDefault = defaultModem();
-    QStringList newModems;
+    QStringList newModems, oldModems;
     const int n = reply.count();
     for (int i = 0; i < n; i++) {
         newModems.append(reply.at(i).path.path());
     }
     qSort(newModems);
     available = true;
-    if (modems != newModems) {
-        modems = newModems;
+    oldModems = modems;
+    modems = newModems;
+    
+    // emit atomic events for add/remove
+    Q_FOREACH(QString modem, oldModems) {
+        if(!newModems.contains(modem)) {
+            Q_EMIT obj->modemRemoved(modem);
+        }
+    }
+    Q_FOREACH(QString modem, newModems) {
+        if(!oldModems.contains(modem)) {
+            Q_EMIT obj->modemAdded(modem);
+        }
+    }
+    
+    // then update the whole list
+    if (oldModems != newModems) {
         Q_EMIT obj->modemsChanged(modems);
     }
     QString newDefault = defaultModem();