aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-connectivity/libqofono/libqofono/0001-also-emit-modemRemoved-and-modemAdded.patch
blob: 0122e051f8aef444ceca3a560c7195eb77c59c48 (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
53
54
From 05241dc61e8c43a12f91ee9976a2ecb2337a3eaf 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 deeb946..e94a3c7 100644
--- a/src/qofonomanager.cpp
+++ b/src/qofonomanager.cpp
@@ -40,15 +40,30 @@ void QOfonoManager::Private::handleGetModemsReply(QOfonoManager* obj, ObjectPath
 {
     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();
-- 
2.23.0