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();
|