From 552f7acb461c09894cc43817693cf2b0a8a0386f Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Mon, 6 May 2024 17:15:04 +0200 Subject: [PATCH] fix conferences info in call history --- .../core/call-history/CallHistoryCore.cpp | 11 +++++++++- .../core/call-history/CallHistoryCore.hpp | 4 ++++ Linphone/tool/Utils.cpp | 17 ++++++++++++++++ Linphone/tool/Utils.hpp | 1 + .../view/Layout/Contact/ContactLayout.qml | 19 +++++++++--------- Linphone/view/Page/Main/CallPage.qml | 20 +++++++++++-------- Linphone/view/Page/Main/ContactPage.qml | 1 - 7 files changed, 53 insertions(+), 20 deletions(-) diff --git a/Linphone/core/call-history/CallHistoryCore.cpp b/Linphone/core/call-history/CallHistoryCore.cpp index 094a49290..612716a4a 100644 --- a/Linphone/core/call-history/CallHistoryCore.cpp +++ b/Linphone/core/call-history/CallHistoryCore.cpp @@ -46,12 +46,21 @@ CallHistoryCore::CallHistoryCore(const std::shared_ptr &callL auto addr = callLog->getRemoteAddress()->clone(); addr->clean(); - mRemoteAddress = Utils::coreStringToAppString(addr->asStringUriOnly()); // mRemoteAddress->clean(); mStatus = LinphoneEnums::fromLinphone(callLog->getStatus()); mDate = QDateTime::fromMSecsSinceEpoch(callLog->getStartDate() * 1000); mIsOutgoing = callLog->getDir() == linphone::Call::Dir::Outgoing; mDuration = QString::number(callLog->getDuration()); + mIsConference = callLog->wasConference(); + if (mIsConference) { + auto confinfo = callLog->getConferenceInfo(); + confinfo->getSubject(); + mRemoteAddress = Utils::coreStringToAppString(confinfo->getUri()->asStringUriOnly()); + mDisplayName = Utils::coreStringToAppString(confinfo->getSubject()); + } else { + mRemoteAddress = Utils::coreStringToAppString(addr->asStringUriOnly()); + mDisplayName = ToolModel::getDisplayName(Utils::coreStringToAppString(addr->asStringUriOnly())); + } } CallHistoryCore::~CallHistoryCore() { diff --git a/Linphone/core/call-history/CallHistoryCore.hpp b/Linphone/core/call-history/CallHistoryCore.hpp index 4ee2debf6..8f24ded80 100644 --- a/Linphone/core/call-history/CallHistoryCore.hpp +++ b/Linphone/core/call-history/CallHistoryCore.hpp @@ -33,8 +33,10 @@ class CallHistoryModel; class CallHistoryCore : public QObject, public AbstractObject { Q_OBJECT + Q_PROPERTY(QString displayName MEMBER mDisplayName CONSTANT) Q_PROPERTY(QString remoteAddress MEMBER mRemoteAddress CONSTANT) Q_PROPERTY(bool isOutgoing MEMBER mIsOutgoing CONSTANT) + Q_PROPERTY(bool isConference MEMBER mIsConference CONSTANT) Q_PROPERTY(QDateTime date MEMBER mDate CONSTANT) Q_PROPERTY(LinphoneEnums::CallStatus status MEMBER mStatus CONSTANT) Q_PROPERTY(QString duration READ getDuration WRITE setDuration NOTIFY durationChanged) @@ -52,8 +54,10 @@ public: Q_INVOKABLE void remove(); QString mRemoteAddress; + QString mDisplayName; QDateTime mDate; bool mIsOutgoing; + bool mIsConference; LinphoneEnums::CallStatus mStatus; signals: diff --git a/Linphone/tool/Utils.cpp b/Linphone/tool/Utils.cpp index ff1e59e49..7cf6e6535 100644 --- a/Linphone/tool/Utils.cpp +++ b/Linphone/tool/Utils.cpp @@ -24,6 +24,7 @@ #include "core/call/CallGui.hpp" #include "core/conference/ConferenceInfoCore.hpp" #include "core/conference/ConferenceInfoGui.hpp" +#include "core/friend/FriendGui.hpp" #include "core/path/Paths.hpp" #include "model/object/VariantObject.hpp" #include "model/tool/ToolModel.hpp" @@ -298,6 +299,22 @@ QString Utils::findAvatarByAddress(const QString &address) { return avatar; } +VariantObject *Utils::findFriendByAddress(const QString &address) { + VariantObject *data = new VariantObject(); + if (!data) return nullptr; + data->makeRequest([address]() { + auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList(); + if (!defaultFriendList) return QVariant(); + auto linphoneAddr = ToolModel::interpretUrl(address); + auto linFriend = CoreModel::getInstance()->getCore()->findFriend(linphoneAddr); + if (!linFriend) return QVariant(); + auto friendCore = FriendCore::create(linFriend); + return QVariant::fromValue(new FriendGui(friendCore)); + }); + data->requestValue(); + return data; +} + QString Utils::generateSavedFilename(const QString &from, const QString &to) { auto escape = [](const QString &str) { constexpr char ReservedCharacters[] = "[<|>|:|\"|/|\\\\|\\?|\\*|\\+|\\||_|-]+"; diff --git a/Linphone/tool/Utils.hpp b/Linphone/tool/Utils.hpp index 2f4a7bf75..b35b01e48 100644 --- a/Linphone/tool/Utils.hpp +++ b/Linphone/tool/Utils.hpp @@ -103,6 +103,7 @@ public: Q_INVOKABLE static QDateTime addYears(QDateTime date, int years); Q_INVOKABLE static QString generateLinphoneSipAddress(const QString &uri); Q_INVOKABLE static QString findAvatarByAddress(const QString &address); + Q_INVOKABLE static VariantObject *findFriendByAddress(const QString &address); static QString generateSavedFilename(const QString &from, const QString &to); Q_INVOKABLE static bool isMe(const QString &address); Q_INVOKABLE static bool isLocal(const QString &address); diff --git a/Linphone/view/Layout/Contact/ContactLayout.qml b/Linphone/view/Layout/Contact/ContactLayout.qml index b93b6d38c..9014e4ef5 100644 --- a/Linphone/view/Layout/Contact/ContactLayout.qml +++ b/Linphone/view/Layout/Contact/ContactLayout.qml @@ -13,8 +13,6 @@ ColumnLayout { property string contactAddress: contact && contact.core.defaultAddress || "" property string contactName: contact && contact.core.displayName || "" - property bool addressVisible: true - property alias buttonContent: rightButton.data property alias detailContent: detailControl.data @@ -50,7 +48,7 @@ ColumnLayout { } Item { - Layout.preferredWidth: mainItem.implicitWidth + Layout.preferredWidth: 360 * DefaultStyle.dp Layout.preferredHeight: detailAvatar.height // Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter @@ -73,11 +71,15 @@ ColumnLayout { } ColumnLayout { Layout.alignment: Qt.AlignHCenter - // Layout.fillWidth: true + Layout.preferredWidth: 360 * DefaultStyle.dp Text { Layout.alignment: Qt.AlignHCenter + Layout.fillWidth: true horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WrapAnywhere + elide: Text.ElideRight text: mainItem.contactName + maximumLineCount: 1 font { pixelSize: 14 * DefaultStyle.dp weight: 400 * DefaultStyle.dp @@ -85,11 +87,10 @@ ColumnLayout { } } Text { - id: contactAddress property var mode : contact ? contact.core.consolidatedPresence : -1 Layout.alignment: Qt.AlignHCenter horizontalAlignment: Text.AlignHCenter - visible: mainItem.addressVisible + visible: mainItem.contact text: mode === LinphoneEnums.ConsolidatedPresence.Online ? qsTr("En ligne") : mode === LinphoneEnums.ConsolidatedPresence.Busy @@ -126,8 +127,7 @@ ColumnLayout { button.icon.source: AppIcons.phone label: qsTr("Appel") button.onClicked: { - var addr = UtilsCpp.generateLinphoneSipAddress(mainItem.contactAddress) - UtilsCpp.createCall(addr) + UtilsCpp.createCall(mainItem.contactAddress) } } LabelButton { @@ -150,8 +150,7 @@ ColumnLayout { button.icon.source: AppIcons.videoCamera label: qsTr("Appel Video") button.onClicked: { - var addr = UtilsCpp.generateLinphoneSipAddress(mainItem.contactAddress) - UtilsCpp.createCall(addr, {'localVideoEnabled':true}) + UtilsCpp.createCall(mainItem.contactAddress, {'localVideoEnabled':true}) } } } diff --git a/Linphone/view/Page/Main/CallPage.qml b/Linphone/view/Page/Main/CallPage.qml index 97a34bb9b..e7f6e4aa3 100644 --- a/Linphone/view/Page/Main/CallPage.qml +++ b/Linphone/view/Page/Main/CallPage.qml @@ -39,6 +39,7 @@ AbstractMainPage { else rightPanelStackView.replace(emptySelection, Control.StackView.Immediate) } rightPanelStackView.initialItem: emptySelection + rightPanelStackView.width: 360 * DefaultStyle.dp onNoItemButtonPressed: goToNewCall() @@ -48,6 +49,10 @@ AbstractMainPage { listStackView.push(newCallItem) } + function createCall(addr) { + UtilsCpp.createCall(addr) + } + Dialog { id: deleteHistoryPopup width: 278 * DefaultStyle.dp @@ -92,7 +97,7 @@ AbstractMainPage { width: parent.width height: parent.height onLaunchCall: { - UtilsCpp.createCall(searchBar.text + "@sip.linphone.org") + mainItem.createCall(UtilsCpp.generateLinphoneSipAddress(searchBar.text)) // TODO : auto completion instead of sip linphone } } @@ -248,8 +253,7 @@ AbstractMainPage { id: friendAddress Layout.fillWidth: true maximumLineCount: 1 - property var remoteAddress: modelData ? UtilsCpp.getDisplayName(modelData.core.remoteAddress) : null - text: remoteAddress ? remoteAddress.value : "" + text: modelData.core.displayName font { pixelSize: 14 * DefaultStyle.dp weight: 400 * DefaultStyle.dp @@ -311,8 +315,7 @@ AbstractMainPage { icon.width: 24 * DefaultStyle.dp icon.height: 24 * DefaultStyle.dp onClicked: { - var addr = UtilsCpp.generateLinphoneSipAddress(modelData.core.remoteAddress) - UtilsCpp.createCall(addr) + mainItem.createCall(modelData.core.remoteAddress) } } } @@ -405,7 +408,7 @@ AbstractMainPage { searchBarColor: DefaultStyle.grey_100 onCallButtonPressed: (address) => { - UtilsCpp.createCall(UtilsCpp.generateLinphoneSipAddress(address)) + mainItem.createCall(address) // var window = UtilsCpp.getCallsWindow() } onGroupCallCreationRequested: { @@ -508,9 +511,10 @@ AbstractMainPage { ContactLayout { id: contactDetail visible: mainItem.selectedRowHistoryGui != undefined - property var remoteName: mainItem.selectedRowHistoryGui ? UtilsCpp.getDisplayName(mainItem.selectedRowHistoryGui.core.remoteAddress) : null + property var contactObj: UtilsCpp.findFriendByAddress(contactAddress) + contact: contactObj ? contactObj.value : null contactAddress: mainItem.selectedRowHistoryGui && mainItem.selectedRowHistoryGui.core.remoteAddress || "" - contactName: remoteName ? remoteName.value : "" + contactName: mainItem.selectedRowHistoryGui ? mainItem.selectedRowHistoryGui.core.displayName : "" anchors.top: rightPanelStackView.top anchors.bottom: rightPanelStackView.bottom anchors.topMargin: 45 * DefaultStyle.dp diff --git a/Linphone/view/Page/Main/ContactPage.qml b/Linphone/view/Page/Main/ContactPage.qml index 8766e2864..9c6b2086f 100644 --- a/Linphone/view/Page/Main/ContactPage.qml +++ b/Linphone/view/Page/Main/ContactPage.qml @@ -122,7 +122,6 @@ AbstractMainPage { Control.ScrollView { id: listLayout anchors.fill: parent - anchors.topMargin: 25 * DefaultStyle.dp contentWidth: width contentHeight: content.height clip: true