From 2fdddf942fed4c65be1487b7671d49c4de3e0fca Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Thu, 14 Nov 2024 21:11:39 +0100 Subject: [PATCH] Handle CallLog updates --- Linphone/core/call-history/CallHistoryList.cpp | 8 ++------ Linphone/core/proxy/ListProxy.hpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Linphone/core/call-history/CallHistoryList.cpp b/Linphone/core/call-history/CallHistoryList.cpp index ca331dee3..f2195de64 100644 --- a/Linphone/core/call-history/CallHistoryList.cpp +++ b/Linphone/core/call-history/CallHistoryList.cpp @@ -90,12 +90,8 @@ void CallHistoryList::setSelf(QSharedPointer me) { }); if (oldLog == mList.end()) { // New prepend(*callLogs); - } else { // Update - qWarning() << log() - .arg("LinphoneCore::onCallLogUpdated has been call for an existant log which " - "should not be the " - "case. Check with the SDK. CallID=%1") - .arg((*callLogs)->mCallId); + } else { // Update (status, duration, etc ...) + replace(oldLog->objectCast(), *callLogs); } delete[] callLogs; }); diff --git a/Linphone/core/proxy/ListProxy.hpp b/Linphone/core/proxy/ListProxy.hpp index 78fdc51e1..41661bdf3 100644 --- a/Linphone/core/proxy/ListProxy.hpp +++ b/Linphone/core/proxy/ListProxy.hpp @@ -116,6 +116,21 @@ public: virtual bool remove(QSharedPointer itemToRemove) { return remove(itemToRemove.get()); } + + template + void replace(QSharedPointer itemToReplace, QSharedPointer replacementItem) { + lInfo() << QStringLiteral("Replacing ") << itemToReplace->metaObject()->className() << QStringLiteral(" : ") + << itemToReplace << " by " << replacementItem; + int index = mList.indexOf(itemToReplace); + if (index == -1) { + lWarning() << QStringLiteral("Unable to replace ") << itemToReplace->metaObject()->className() + << QStringLiteral(" : ") << itemToReplace << " not found in list"; + return; + } + mList[index] = replacementItem; + QModelIndex modelIndex = createIndex(index, 0); + emit dataChanged(modelIndex, modelIndex, {Qt::DisplayRole}); + } }; #endif