From e620af3f3ece67ba355c58a9968a52271e095005 Mon Sep 17 00:00:00 2001
From: gaelle <gaelle.braud@belledonne-communications.com>
Date: Mon, 3 Mar 2025 10:37:18 +0100
Subject: [PATCH] fix #LINQT-1672 connection when another softphone is using
 the same sip address (try to let the OS choose the port to listen to)

fix empty root ca path : try to create file if doesn't exist

fix #LINQT-1671 loading indicator call history

remove clang from nightly

fix #LINQT-1667 add time before closing window when call ends
---
 .../linux-desktop-ubuntu-2004.yml             |  4 ++--
 Linphone/core/path/Paths.cpp                  |  4 ++++
 Linphone/model/core/CoreModel.cpp             | 11 +++++++++
 Linphone/model/setting/SettingsModel.cpp      |  2 +-
 Linphone/view/Control/Button/Button.qml       |  1 +
 .../Display/Call/CallHistoryListView.qml      | 18 ++++++++++++---
 Linphone/view/Page/Main/Call/CallPage.qml     | 23 -------------------
 .../view/Page/Window/Call/CallsWindow.qml     |  2 +-
 8 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/.gitlab-ci-files/linux-desktop-ubuntu-2004.yml b/.gitlab-ci-files/linux-desktop-ubuntu-2004.yml
index bc7a2c02c..eb1507214 100644
--- a/.gitlab-ci-files/linux-desktop-ubuntu-2004.yml
+++ b/.gitlab-ci-files/linux-desktop-ubuntu-2004.yml
@@ -34,7 +34,7 @@ ubuntu2004-makefile-gcc:
 ubuntu2004-ninja-clang:
   rules:
     - !reference [.rules-merge-request-manual, rules]
-    - if: $NIGHTLY_MASTER && $LINUX_NINJA
+    - if: $NIGHTLY_MASTER  == null
   variables:
     CMAKE_OPTIONS: -DENABLE_DOC=ON -DENABLE_G729=ON -DENABLE_PQCRYPTO=ON -DENABLE_GPL_THIRD_PARTIES=ON
     CMAKE_GENERATOR: Ninja
@@ -46,7 +46,7 @@ ubuntu2004-ninja-clang:
 ubuntu2004-ninja-clang-small:
   rules:
     - !reference [.rules-merge-request-manual, rules]
-    - if: $NIGHTLY_MASTER && $LINUX_NINJA
+    - if: $NIGHTLY_MASTER == null
   variables:
     CMAKE_OPTIONS: -DENABLE_VIDEO=NO -DENABLE_ADVANCED_IM=NO -DENABLE_DB_STORAGE=NO -DENABLE_PQCRYPTO=OFF
   extends: ubuntu2004-ninja-clang
diff --git a/Linphone/core/path/Paths.cpp b/Linphone/core/path/Paths.cpp
index a7bb2c568..3f344895e 100644
--- a/Linphone/core/path/Paths.cpp
+++ b/Linphone/core/path/Paths.cpp
@@ -162,6 +162,10 @@ static inline QString getAppRootCaFilePath() {
 	QString rootca = getAppPackageDataDirPath() + Constants::PathRootCa;
 	if (Paths::filePathExists(rootca)) { // Packaged
 		return rootca;
+	} else {
+		QFile rootCaFile(rootca);
+		if (rootCaFile.open(QIODevice::ReadWrite))
+			return rootca;
 	}
 	return "";
 }
diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp
index 73c916d0a..3a75e1be0 100644
--- a/Linphone/model/core/CoreModel.cpp
+++ b/Linphone/model/core/CoreModel.cpp
@@ -90,6 +90,17 @@ void CoreModel::start() {
 		config->setInt("video", "capture", 1);
 		config->setInt("video", "display", 1);
 	}
+
+	// TODO : set the real transport type when sdk will be updated
+	// for now, we need to let the OS choose the port to listen on
+	// so that the user can be connected to linphone and another softphone
+	// at the same time (otherwise it tries to listen on the same port as
+	// the other software)
+	auto transports = mCore->getTransports();
+	transports->setTcpPort(-2);
+	transports->setUdpPort(-2);
+	transports->setTlsPort(-2);
+	mCore->setTransports(transports);
 	mCore->enableVideoPreview(false);         // SDK doesn't write the state in configuration if not ready.
 	config->setInt("video", "show_local", 0); // So : write ourself to turn off camera before starting the core.
 	QString userAgent = ToolModel::computeUserAgent(config);
diff --git a/Linphone/model/setting/SettingsModel.cpp b/Linphone/model/setting/SettingsModel.cpp
index e0e4a6092..483eea38f 100644
--- a/Linphone/model/setting/SettingsModel.cpp
+++ b/Linphone/model/setting/SettingsModel.cpp
@@ -65,7 +65,7 @@ SettingsModel::SettingsModel() {
 	QObject::connect(CoreModel::getInstance().get(), &CoreModel::defaultAccountChanged, this,
 					 [this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Account> account) {
 						 mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
-						 setDisableMeetingsFeature(!account->getParams()->getAudioVideoConferenceFactoryAddress());
+						 setDisableMeetingsFeature(account && !account->getParams()->getAudioVideoConferenceFactoryAddress());
 					 });
 	auto defaultAccount = core->getDefaultAccount();
 	setDisableMeetingsFeature(defaultAccount && !defaultAccount->getParams()->getAudioVideoConferenceFactoryAddress());
diff --git a/Linphone/view/Control/Button/Button.qml b/Linphone/view/Control/Button/Button.qml
index 9194da0d0..d0589432f 100644
--- a/Linphone/view/Control/Button/Button.qml
+++ b/Linphone/view/Control/Button/Button.qml
@@ -116,6 +116,7 @@ Control.Button {
 	}
 	
 	component ButtonImage: EffectImage {
+        asynchronous: mainItem.asynchronous
 		imageSource: mainItem.icon.source
 		imageWidth: mainItem.icon.width
 		imageHeight: mainItem.icon.height
diff --git a/Linphone/view/Control/Display/Call/CallHistoryListView.qml b/Linphone/view/Control/Display/Call/CallHistoryListView.qml
index 1f06d1405..967a8c89a 100644
--- a/Linphone/view/Control/Display/Call/CallHistoryListView.qml
+++ b/Linphone/view/Control/Display/Call/CallHistoryListView.qml
@@ -23,10 +23,12 @@ ListView {
         loading = false
         // contentY = 0
     }
-    onSearchTextChanged: loading = true
 
     model: CallHistoryProxy {
         id: callHistoryProxy
+        Component.onCompleted: {
+            loading = true
+        }
         filterText: mainItem.searchText
         onFilterTextChanged: maxDisplayItems = initialDisplayItems
         initialDisplayItems: Math.max(
@@ -106,14 +108,22 @@ ListView {
             currentIndex = -1
     }
 
+    BusyIndicator {
+        anchors.horizontalCenter: mainItem.horizontalCenter
+        visible: mainItem.loading
+        height: visible ? mainItem.busyIndicatorSize : 0
+        width: mainItem.busyIndicatorSize
+        indicatorHeight: mainItem.busyIndicatorSize
+        indicatorWidth: mainItem.busyIndicatorSize
+        indicatorColor: DefaultStyle.main1_500_main
+    }
+
     // Qt bug: sometimes, containsMouse may not be send and update on each MouseArea.
     // So we need to use this variable to switch off all hovered items.
     property int lastMouseContainsIndex: -1
     delegate: FocusScope {
         width: mainItem.width
         height: 56 * DefaultStyle.dp
-        visible: !!modelData
-
         RowLayout {
             z: 1
             anchors.fill: parent
@@ -130,6 +140,7 @@ ListView {
                 height: 45 * DefaultStyle.dp
                 isConference: modelData.core.isConference
                 shadowEnabled: false
+                asynchronous: false
             }
             ColumnLayout {
                 Layout.fillHeight: true
@@ -195,6 +206,7 @@ ListView {
                 icon.source: AppIcons.phone
                 focus: true
                 activeFocusOnTab: false
+                asynchronous: false
                 onClicked: {
                     if (modelData.core.isConference) {
                         var callsWindow = UtilsCpp.getCallsWindow()
diff --git a/Linphone/view/Page/Main/Call/CallPage.qml b/Linphone/view/Page/Main/Call/CallPage.qml
index 67467ca8f..b0a951ee9 100644
--- a/Linphone/view/Page/Main/Call/CallPage.qml
+++ b/Linphone/view/Page/Main/Call/CallPage.qml
@@ -236,18 +236,6 @@ AbstractMainPage {
                                 searchBar: searchBar
                                 Control.ScrollBar.vertical: scrollbar
 
-                                BusyIndicator {
-                                    anchors.horizontalCenter: historyListView.horizontalCenter
-                                    visible: historyListView.loading
-                                             && historyListView.count === 0
-                                             && searchBar.text.length === 0
-                                    height: visible ? historyListView.busyIndicatorSize : 0
-                                    width: historyListView.busyIndicatorSize
-                                    indicatorHeight: historyListView.busyIndicatorSize
-                                    indicatorWidth: historyListView.busyIndicatorSize
-                                    indicatorColor: DefaultStyle.main1_500_main
-                                }
-
                                 Connections {
                                     target: mainItem
                                     function onListViewUpdated() {
@@ -630,17 +618,6 @@ ConferenceInfoGui{
                             searchText: mainItem.selectedRowHistoryGui ? mainItem.selectedRowHistoryGui.core.remoteAddress : ""
                             busyIndicatorSize: 40 * DefaultStyle.dp
 
-                            BusyIndicator {
-                                anchors.horizontalCenter: detailListView.horizontalCenter
-                                visible: detailListView.loading
-                                         && detailListView.count === 0
-                                height: visible ? detailListView.busyIndicatorSize : 0
-                                width: detailListView.busyIndicatorSize
-                                indicatorHeight: detailListView.busyIndicatorSize
-                                indicatorWidth: detailListView.busyIndicatorSize
-                                indicatorColor: DefaultStyle.main1_500_main
-                            }
-
                             delegate: Item {
                                 width: detailListView.width
                                 height: 56 * DefaultStyle.dp
diff --git a/Linphone/view/Page/Window/Call/CallsWindow.qml b/Linphone/view/Page/Window/Call/CallsWindow.qml
index ea16c66fc..192b666ab 100644
--- a/Linphone/view/Page/Window/Call/CallsWindow.qml
+++ b/Linphone/view/Page/Window/Call/CallsWindow.qml
@@ -175,7 +175,7 @@ AbstractWindow {
 
     Timer {
         id: autoCloseWindow
-        interval: mainWindow.callTerminatedByUser ? 1000 : 2000
+        interval: mainWindow.callTerminatedByUser ? 1500 : 2500
         onTriggered: {
             UtilsCpp.closeCallsWindow()
         }
-- 
GitLab