From e053fcf63e393a373f99f4a3c6eee28400a7f4b9 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Thu, 5 Feb 2026 16:24:05 +0100 Subject: [PATCH] do not display non secured message in chatroom if server does not allow encrypted chats --- Linphone/core/App.cpp | 6 +++++ Linphone/core/App.hpp | 8 ++++-- .../Control/Display/Chat/ChatListView.qml | 2 +- .../Display/Chat/ChatMessagesListView.qml | 2 ++ .../view/Page/Form/Chat/SelectedChatView.qml | 25 +++++++++++-------- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index 9c69191e5..74fc5f46b 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -711,6 +711,8 @@ void App::initCore() { mAccountList->setInitialized(false); mAccountList->lUpdate(true); } + connect(mAccountList.get(), &AccountList::defaultAccountChanged, this, + &App::currentAccountChanged); // Update global unread Notifications when an account updates his unread Notifications connect(mAccountList.get(), &AccountList::unreadNotificationsChanged, this, [this]() { lDebug() << "unreadNotificationsChanged of AccountList"; @@ -1724,6 +1726,10 @@ void App::setCurrentChat(ChatGui *chat) { } } +AccountGui *App::getCurrentAccount() const { + return mAccountList ? mAccountList->getDefaultAccount() : nullptr; +} + float App::getScreenRatio() const { return mScreenRatio; } diff --git a/Linphone/core/App.hpp b/Linphone/core/App.hpp index 83b1dea88..1047a1405 100644 --- a/Linphone/core/App.hpp +++ b/Linphone/core/App.hpp @@ -47,6 +47,7 @@ class App : public SingleApplication, public AbstractObject { Q_OBJECT Q_PROPERTY(bool coreStarted READ getCoreStarted WRITE setCoreStarted NOTIFY coreStartedChanged) Q_PROPERTY(AccountList *accounts READ getAccounts NOTIFY accountsChanged) + Q_PROPERTY(AccountGui *currentAccount READ getCurrentAccount NOTIFY currentAccountChanged) Q_PROPERTY(CallList *calls READ getCalls NOTIFY callsChanged) Q_PROPERTY(ChatList *chats READ getChats NOTIFY chatsChanged) Q_PROPERTY(QString shortApplicationVersion READ getShortApplicationVersion CONSTANT) @@ -175,6 +176,10 @@ public: QSharedPointer getChatList() const; ChatList *getChats() const; void setChatList(QSharedPointer data); + ChatGui *getCurrentChat() const; + void setCurrentChat(ChatGui *chat); + + AccountGui *getCurrentAccount() const; QSharedPointer getCallList() const; void setCallList(QSharedPointer data); @@ -192,8 +197,6 @@ public: QString getQtVersion() const; Q_INVOKABLE void checkForUpdate(bool requestedByUser = false); - ChatGui *getCurrentChat() const; - void setCurrentChat(ChatGui *chat); float getScreenRatio() const; Q_INVOKABLE void setScreenRatio(float ratio); @@ -227,6 +230,7 @@ signals: void localeChanged(); void lForceOidcTimeout(); void remainingTimeBeforeOidcTimeoutChanged(); + void currentAccountChanged(); // void executeCommand(QString command); private: diff --git a/Linphone/view/Control/Display/Chat/ChatListView.qml b/Linphone/view/Control/Display/Chat/ChatListView.qml index 60b7bd217..72372008e 100644 --- a/Linphone/view/Control/Display/Chat/ChatListView.qml +++ b/Linphone/view/Control/Display/Chat/ChatListView.qml @@ -297,7 +297,7 @@ ListView { imageSource: AppIcons.clockCountDown } EffectImage { - visible: modelData != undefined && modelData?.core.isBasic + visible: modelData != undefined && !modelData.core.isEncrypted && AppCpp.currentAccount && AppCpp.currentAccount.core.limeServerUrl !== "" && AppCpp.currentAccount.core.conferenceFactoryAddress !== "" Layout.preferredWidth: visible ? Utils.getSizeWithScreenRatio(14) : 0 Layout.preferredHeight: Utils.getSizeWithScreenRatio(14) colorizationColor: DefaultStyle.warning_700 diff --git a/Linphone/view/Control/Display/Chat/ChatMessagesListView.qml b/Linphone/view/Control/Display/Chat/ChatMessagesListView.qml index 22e3e6e0a..7e461f9ae 100644 --- a/Linphone/view/Control/Display/Chat/ChatMessagesListView.qml +++ b/Linphone/view/Control/Display/Chat/ChatMessagesListView.qml @@ -18,6 +18,7 @@ ListView { property real busyIndicatorSize: Utils.getSizeWithScreenRatio(60) property bool loading: false property bool isEncrypted: chat && chat.core.isEncrypted + property bool showEncryptedInfo: AppCpp.currentAccount !== null && AppCpp.currentAccount.core.limeServerUrl !== "" && AppCpp.currentAccount.core.conferenceFactoryAddress !== "" highlightFollowsCurrentItem: true verticalLayoutDirection: ListView.BottomToTop @@ -134,6 +135,7 @@ ListView { anchors.horizontalCenter: parent.horizontalCenter Control.Control { id: headerMessage + visible: mainItem.showEncryptedInfo property int topMargin: Utils.getSizeWithScreenRatio(mainItem.contentHeight > mainItem.height ? 30 : 50) property int bottomMargin: Utils.getSizeWithScreenRatio(30) anchors.topMargin: topMargin diff --git a/Linphone/view/Page/Form/Chat/SelectedChatView.qml b/Linphone/view/Page/Form/Chat/SelectedChatView.qml index 8f8870415..a8ad3fe65 100644 --- a/Linphone/view/Page/Form/Chat/SelectedChatView.qml +++ b/Linphone/view/Page/Form/Chat/SelectedChatView.qml @@ -22,6 +22,8 @@ FocusScope { property alias callHeaderContent: splitPanel.header.contentItem property bool replyingToMessage: false property string lastChar + property AccountGui currentAccount: AppCpp.currentAccount + property bool showEncryptedInfo: currentAccount && currentAccount.core.limeServerUrl !== "" && currentAccount.core.conferenceFactoryAddress !== "" enum PanelType { MessageReactions, SharedFiles, Medias, ImdnStatus, ForwardToList, ManageParticipants, EphemeralSettings, None} signal oneOneCall(bool video) @@ -127,7 +129,7 @@ FocusScope { } } RowLayout { - visible: mainItem.chat != undefined && mainItem.chat.core.isBasic + visible: mainItem.showEncryptedInfo && mainItem.chat != undefined && !mainItem.chat.core.isEncrypted spacing: Utils.getSizeWithScreenRatio(8) EffectImage { Layout.preferredWidth: visible ? Utils.getSizeWithScreenRatio(14) : 0 @@ -135,17 +137,18 @@ FocusScope { colorizationColor: DefaultStyle.warning_700 imageSource: AppIcons.lockSimpleOpen } - Text { - // hiding text if in call cause te view - // has smaller width - visible: !mainItem.call - Layout.fillWidth: true - color: DefaultStyle.warning_700 - //: This conversation is not encrypted ! - text: qsTr("unencrypted_conversation_warning") - font: Typography.p2 - } + // Text { + // // hiding text if in call cause te view + // // has smaller width + // visible: !mainItem.call + // Layout.fillWidth: true + // color: DefaultStyle.warning_700 + // //: This conversation is not encrypted ! + // text: qsTr("unencrypted_conversation_warning") + // font: Typography.p2 + // } } + EffectImage { visible: mainItem.chat?.core.muted || false Layout.preferredWidth: Utils.getSizeWithScreenRatio(20)