From 3a560324f8abddc9257026df9f844cc94ac2d4f4 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Wed, 20 Oct 2021 19:22:52 +0200 Subject: [PATCH] - Add an option to enable standard and secure chats feature ('app' section) - Fix history buttons that should not appear if chat room mode is not activated - Allow to use a secure chat room to be used when calling (set by context : encrypted call/secure chat enabled) - Replace a warning log by info while creating a chat room. - Fix missing qml variables. - Change Contact Edit and SIP Addresses selections to start a standard chat or a secure one. - Simplify encryption activation on call parameters with enableEncryption() --- linphone-app/assets/languages/da.ts | 5 +++ linphone-app/assets/languages/de.ts | 5 +++ linphone-app/assets/languages/en.ts | 5 +++ linphone-app/assets/languages/es.ts | 5 +++ linphone-app/assets/languages/fr_FR.ts | 5 +++ linphone-app/assets/languages/hu.ts | 5 +++ linphone-app/assets/languages/it.ts | 5 +++ linphone-app/assets/languages/ja.ts | 5 +++ linphone-app/assets/languages/lt.ts | 5 +++ linphone-app/assets/languages/pt_BR.ts | 5 +++ linphone-app/assets/languages/ru.ts | 5 +++ linphone-app/assets/languages/sv.ts | 5 +++ linphone-app/assets/languages/tr.ts | 5 +++ linphone-app/assets/languages/uk.ts | 5 +++ linphone-app/assets/languages/zh_CN.ts | 5 +++ .../src/components/call/CallModel.cpp | 36 +++++++++++++++++- .../src/components/calls/CallsListModel.cpp | 11 ++---- .../src/components/core/CoreHandlers.cpp | 3 +- .../AbstractEventCountNotifier.cpp | 6 ++- .../src/components/settings/SettingsModel.cpp | 14 ++++++- .../src/components/settings/SettingsModel.hpp | 6 +++ .../components/timeline/TimelineListModel.cpp | 18 ++++++++- .../ui/modules/Linphone/Chat/Chat.qml | 6 +-- .../Linphone/Menus/SipAddressesMenu.qml | 11 +++--- .../SmartSearchBar/SmartSearchBar.qml | 25 ++++++------ .../ui/modules/Linphone/Timeline/Timeline.qml | 2 +- .../ui/views/App/Calls/CallsWindow.qml | 6 ++- linphone-app/ui/views/App/Calls/Incall.qml | 2 +- .../ui/views/App/Main/ContactEdit.qml | 38 +++++++++++++++---- linphone-app/ui/views/App/Main/Contacts.qml | 7 ++-- .../ui/views/App/Main/Conversation.qml | 7 ++-- .../ui/views/App/Main/Dialogs/NewChatRoom.qml | 19 ++++++---- linphone-app/ui/views/App/Main/MainWindow.qml | 1 + .../views/App/Settings/SettingsCallsChat.qml | 13 ++++++- .../ui/views/App/Settings/SettingsUi.qml | 3 +- 35 files changed, 247 insertions(+), 62 deletions(-) diff --git a/linphone-app/assets/languages/da.ts b/linphone-app/assets/languages/da.ts index bedd54139..d06897198 100644 --- a/linphone-app/assets/languages/da.ts +++ b/linphone-app/assets/languages/da.ts @@ -753,6 +753,11 @@ Server url ikke konfigureret. tooltipShowConversation Vis samtale + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + + Contacts diff --git a/linphone-app/assets/languages/de.ts b/linphone-app/assets/languages/de.ts index 94cd51909..372d12d71 100644 --- a/linphone-app/assets/languages/de.ts +++ b/linphone-app/assets/languages/de.ts @@ -753,6 +753,11 @@ Server URL ist nicht konfiguriert. tooltipShowConversation Konversation anzeigen + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + + Contacts diff --git a/linphone-app/assets/languages/en.ts b/linphone-app/assets/languages/en.ts index ecd8c9f63..5c868c459 100644 --- a/linphone-app/assets/languages/en.ts +++ b/linphone-app/assets/languages/en.ts @@ -753,6 +753,11 @@ Server URL not configured. tooltipShowConversation Show conversation + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + You need to set the conference URI in your account settings to create a conference based chat room. + Contacts diff --git a/linphone-app/assets/languages/es.ts b/linphone-app/assets/languages/es.ts index 87414c66c..0ae44e77e 100644 --- a/linphone-app/assets/languages/es.ts +++ b/linphone-app/assets/languages/es.ts @@ -753,6 +753,11 @@ URL del servidor no configurada. tooltipShowConversation Mostrar conversación + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + + Contacts diff --git a/linphone-app/assets/languages/fr_FR.ts b/linphone-app/assets/languages/fr_FR.ts index c14624305..eddb53a3c 100644 --- a/linphone-app/assets/languages/fr_FR.ts +++ b/linphone-app/assets/languages/fr_FR.ts @@ -753,6 +753,11 @@ URL du serveur non configurée. tooltipShowConversation Aller à la conversation + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + Vous devez définir l'URI de la conférence dans les paramètres de votre compte pour créer une conférence. + Contacts diff --git a/linphone-app/assets/languages/hu.ts b/linphone-app/assets/languages/hu.ts index a3cce2150..b9b0086a0 100644 --- a/linphone-app/assets/languages/hu.ts +++ b/linphone-app/assets/languages/hu.ts @@ -748,6 +748,11 @@ A kiszolgáló URL-je nincs konfigurálva. tooltipShowConversation Beszélgetés megjelenítése + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + Konferenciaalapú csevegőszoba létrehozásához be kell állítania a konferencia URI-címét a fiókbeállításokban. + Contacts diff --git a/linphone-app/assets/languages/it.ts b/linphone-app/assets/languages/it.ts index af41cdfa4..934052e0d 100644 --- a/linphone-app/assets/languages/it.ts +++ b/linphone-app/assets/languages/it.ts @@ -753,6 +753,11 @@ URL del server non configurato. tooltipShowConversation Mostra conversazione + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + + Contacts diff --git a/linphone-app/assets/languages/ja.ts b/linphone-app/assets/languages/ja.ts index cb1ad1d45..e3b388192 100644 --- a/linphone-app/assets/languages/ja.ts +++ b/linphone-app/assets/languages/ja.ts @@ -748,6 +748,11 @@ tooltipShowConversation 会話を表示 + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + + Contacts diff --git a/linphone-app/assets/languages/lt.ts b/linphone-app/assets/languages/lt.ts index ac4be82d1..688943e96 100644 --- a/linphone-app/assets/languages/lt.ts +++ b/linphone-app/assets/languages/lt.ts @@ -758,6 +758,11 @@ Nesukonfigūruotas serverio url. tooltipShowConversation Rodyti pokalbį + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + + Contacts diff --git a/linphone-app/assets/languages/pt_BR.ts b/linphone-app/assets/languages/pt_BR.ts index 1beba78cb..9b8b96115 100644 --- a/linphone-app/assets/languages/pt_BR.ts +++ b/linphone-app/assets/languages/pt_BR.ts @@ -753,6 +753,11 @@ URL do servidor não configurado. tooltipShowConversation Mostrar conversa + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + + Contacts diff --git a/linphone-app/assets/languages/ru.ts b/linphone-app/assets/languages/ru.ts index d39c82cec..8db5f7756 100644 --- a/linphone-app/assets/languages/ru.ts +++ b/linphone-app/assets/languages/ru.ts @@ -758,6 +758,11 @@ tooltipShowConversation Показать разговор + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + + Contacts diff --git a/linphone-app/assets/languages/sv.ts b/linphone-app/assets/languages/sv.ts index e1cf41823..8ae2292a3 100644 --- a/linphone-app/assets/languages/sv.ts +++ b/linphone-app/assets/languages/sv.ts @@ -753,6 +753,11 @@ Serverwebbadressen är inte konfigurerad. tooltipShowConversation Visa konversation + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + + Contacts diff --git a/linphone-app/assets/languages/tr.ts b/linphone-app/assets/languages/tr.ts index 9481151d8..f66b10e0e 100644 --- a/linphone-app/assets/languages/tr.ts +++ b/linphone-app/assets/languages/tr.ts @@ -748,6 +748,11 @@ Sunucu url'si yapılandırılmadı. tooltipShowConversation Sohbeti göster + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + + Contacts diff --git a/linphone-app/assets/languages/uk.ts b/linphone-app/assets/languages/uk.ts index d821a30f0..da7f38501 100644 --- a/linphone-app/assets/languages/uk.ts +++ b/linphone-app/assets/languages/uk.ts @@ -758,6 +758,11 @@ tooltipShowConversation Показати розмову + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + + Contacts diff --git a/linphone-app/assets/languages/zh_CN.ts b/linphone-app/assets/languages/zh_CN.ts index dd948d30f..81fe0ab9d 100644 --- a/linphone-app/assets/languages/zh_CN.ts +++ b/linphone-app/assets/languages/zh_CN.ts @@ -748,6 +748,11 @@ tooltipShowConversation 显示对话 + + missingConferenceURI + 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + 您需要在帐户设置中设置会议 URI 以创建基于会议的聊天室。 + Contacts diff --git a/linphone-app/src/components/call/CallModel.cpp b/linphone-app/src/components/call/CallModel.cpp index 397a2cd0b..6357096ad 100644 --- a/linphone-app/src/components/call/CallModel.cpp +++ b/linphone-app/src/components/call/CallModel.cpp @@ -116,9 +116,41 @@ ContactModel *CallModel::getContactModel() const{ } ChatRoomModel * CallModel::getChatRoomModel() const{ - if(mCall->getCallLog()->getCallId() != "") + if(mCall->getCallLog()->getCallId() != "") { + auto currentParams = mCall->getCurrentParams(); + bool isEncrypted = currentParams->getMediaEncryption() != linphone::MediaEncryption::None; + SettingsModel * settingsModel = CoreManager::getInstance()->getSettingsModel(); + + if( mCall->getChatRoom() && (settingsModel->getSecureChatEnabled() && + (!settingsModel->getChatEnabled() || (settingsModel->getChatEnabled() && isEncrypted)) + )){ + std::shared_ptr core = CoreManager::getInstance()->getCore(); + std::shared_ptr dbParams = mCall->getChatRoom()->getCurrentParams(); + std::shared_ptr params = core->createDefaultChatRoomParams(); + auto callLog = mCall->getCallLog(); + auto callLocalAddress = callLog->getLocalAddress(); + std::list> participants; + std::shared_ptr chatRoom; +// Copy parameters + params->setBackend(dbParams->getBackend()); + params->setEncryptionBackend(dbParams->getEncryptionBackend()); + params->enableEncryption(dbParams->encryptionEnabled()); + params->enableGroup(dbParams->groupEnabled()); + params->enableRtt(dbParams->rttEnabled()); + params->setSubject(dbParams->getSubject()); + params->enableEncryption(true); + std::list> chatRoomParticipants = mCall->getChatRoom()->getParticipants(); + for(auto p : chatRoomParticipants){ + participants.push_back(p->getAddress()->clone()); + } + chatRoom = core->searchChatRoom(params, callLocalAddress + , nullptr + , participants); + if(chatRoom) + return CoreManager::getInstance()->getTimelineListModel()->getChatRoomModel(chatRoom, true).get(); + } return CoreManager::getInstance()->getTimelineListModel()->getChatRoomModel(mCall->getChatRoom(), true).get(); - else + }else return nullptr; } diff --git a/linphone-app/src/components/calls/CallsListModel.cpp b/linphone-app/src/components/calls/CallsListModel.cpp index a735cc8fa..6e6282788 100644 --- a/linphone-app/src/components/calls/CallsListModel.cpp +++ b/linphone-app/src/components/calls/CallsListModel.cpp @@ -223,8 +223,7 @@ ChatRoomModel* CallsListModel::launchSecureChat (const QString &sipAddress) cons params->enableEncryption(true); params->setSubject("Dummy Subject"); - params->setBackend(linphone::ChatRoomBackend::FlexisipChat); - params->setEncryptionBackend(linphone::ChatRoomEncryptionBackend::Lime); + params->enableEncryption(true); std::shared_ptr chatRoom = core->createChatRoom(params, localAddress, participants); if( chatRoom != nullptr){ @@ -293,8 +292,7 @@ bool CallsListModel::createSecureChat (const QString& subject, const QString &pa params->enableEncryption(true); params->setSubject(Utils::appStringToCoreString(subject)); - params->setBackend(linphone::ChatRoomBackend::FlexisipChat); - params->setEncryptionBackend(linphone::ChatRoomEncryptionBackend::Lime); + params->enableEncryption(true); params->enableGroup(true); std::shared_ptr chatRoom = core->createChatRoom(params, localAddress, participants); @@ -309,7 +307,7 @@ QVariantMap CallsListModel::createChatRoom(const QString& subject, const int& se QList< std::shared_ptr> admins; std::shared_ptr timeline; auto timelineList = CoreManager::getInstance()->getTimelineListModel(); - qWarning() << "ChatRoom creation of " << subject << " at " << securityLevel << " security and with " << participants; + qInfo() << "ChatRoom creation of " << subject << " at " << securityLevel << " security and with " << participants; std::shared_ptr params = core->createDefaultChatRoomParams(); std::list > chatRoomParticipants; @@ -333,8 +331,7 @@ QVariantMap CallsListModel::createChatRoom(const QString& subject, const int& se params->enableEncryption(securityLevel>0); if( securityLevel>0){ - params->setBackend(linphone::ChatRoomBackend::FlexisipChat); - params->setEncryptionBackend(linphone::ChatRoomEncryptionBackend::Lime); + params->enableEncryption(true); }else params->setBackend(linphone::ChatRoomBackend::Basic); params->enableGroup( subject!="" ); diff --git a/linphone-app/src/components/core/CoreHandlers.cpp b/linphone-app/src/components/core/CoreHandlers.cpp index d7997a20f..b2c2eda6f 100644 --- a/linphone-app/src/components/core/CoreHandlers.cpp +++ b/linphone-app/src/components/core/CoreHandlers.cpp @@ -197,7 +197,8 @@ void CoreHandlers::onMessageReceived ( // 1. Do not notify if chat is not activated. CoreManager *coreManager = CoreManager::getInstance(); SettingsModel *settingsModel = coreManager->getSettingsModel(); - if (!settingsModel->getChatEnabled()) + if (chatRoom->getCurrentParams()->getEncryptionBackend() == linphone::ChatRoomEncryptionBackend::None && !settingsModel->getChatEnabled() + || chatRoom->getCurrentParams()->getEncryptionBackend() != linphone::ChatRoomEncryptionBackend::None && !settingsModel->getSecureChatEnabled()) return; // 2. Notify with Notification popup. diff --git a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp index 693493a5c..d1617bf86 100644 --- a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp +++ b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp @@ -53,6 +53,10 @@ AbstractEventCountNotifier::AbstractEventCountNotifier (QObject *parent) : QObje coreManager->getSettingsModel(), &SettingsModel::chatEnabledChanged, this, &AbstractEventCountNotifier::internalnotifyEventCount ); + QObject::connect( + coreManager->getSettingsModel(), &SettingsModel::secureChatEnabledChanged, + this, &AbstractEventCountNotifier::internalnotifyEventCount + ); /* QObject::connect( coreManager->getCallsListModel(), &CallsListModel::callMissed, @@ -72,7 +76,7 @@ void AbstractEventCountNotifier::internalnotifyEventCount () { qInfo() << QStringLiteral("Notify event count: %1.").arg(n); n = n > 99 ? 99 : n; - notifyEventCount(CoreManager::getInstance()->getSettingsModel()->getChatEnabled() ? n : 0); + notifyEventCount(CoreManager::getInstance()->getSettingsModel()->getChatEnabled() || CoreManager::getInstance()->getSettingsModel()->getSecureChatEnabled()? n : 0); emit eventCountChanged(); } diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index ec6d98276..539cc261c 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -41,6 +41,7 @@ using namespace std; const string SettingsModel::UiSection("ui"); +const string SettingsModel::AppSection("app"); const string SettingsModel::ContactsSection("contacts_import"); SettingsModel::SettingsModel (QObject *parent) : QObject(parent) { @@ -601,14 +602,23 @@ void SettingsModel::setMuteMicrophoneEnabled (bool status) { // ----------------------------------------------------------------------------- bool SettingsModel::getChatEnabled () const { - return !!mConfig->getInt(UiSection, "chat_enabled", 1); + return !!mConfig->getInt(AppSection, "chat_enabled", 1); } void SettingsModel::setChatEnabled (bool status) { - mConfig->setInt(UiSection, "chat_enabled", status); + mConfig->setInt(AppSection, "chat_enabled", status); emit chatEnabledChanged(status); } +bool SettingsModel::getSecureChatEnabled () const { + return !!mConfig->getInt(AppSection, "secure_chat_enabled", 1); +} + +void SettingsModel::setSecureChatEnabled (bool status) { + mConfig->setInt(AppSection, "secure_chat_enabled", status); + emit secureChatEnabledChanged(status); +} + // ----------------------------------------------------------------------------- bool SettingsModel::getHideEmptyChatRooms() const{ diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index 43fa5b192..f9bb5de42 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -104,6 +104,7 @@ class SettingsModel : public QObject { Q_PROPERTY(bool muteMicrophoneEnabled READ getMuteMicrophoneEnabled WRITE setMuteMicrophoneEnabled NOTIFY muteMicrophoneEnabledChanged) Q_PROPERTY(bool chatEnabled READ getChatEnabled WRITE setChatEnabled NOTIFY chatEnabledChanged) + Q_PROPERTY(bool secureChatEnabled READ getSecureChatEnabled WRITE setSecureChatEnabled NOTIFY secureChatEnabledChanged) Q_PROPERTY(bool hideEmptyChatRooms READ getHideEmptyChatRooms WRITE setHideEmptyChatRooms NOTIFY hideEmptyChatRoomsChanged) Q_PROPERTY(bool waitRegistrationForCall READ getWaitRegistrationForCall WRITE setWaitRegistrationForCall NOTIFY waitRegistrationForCallChanged)// Allow call only if the current proxy has been registered @@ -328,6 +329,9 @@ public: bool getChatEnabled () const; void setChatEnabled (bool status); + bool getSecureChatEnabled () const; + void setSecureChatEnabled (bool status); + bool getHideEmptyChatRooms() const; void setHideEmptyChatRooms(const bool& data); @@ -487,6 +491,7 @@ public: bool getIsInCall() const; static const std::string UiSection; + static const std::string AppSection; static const std::string ContactsSection; // =========================================================================== @@ -555,6 +560,7 @@ signals: void muteMicrophoneEnabledChanged (bool status); void chatEnabledChanged (bool status); + void secureChatEnabledChanged (bool status); void hideEmptyChatRoomsChanged (bool status); void waitRegistrationForCallChanged (bool status); diff --git a/linphone-app/src/components/timeline/TimelineListModel.cpp b/linphone-app/src/components/timeline/TimelineListModel.cpp index 84e36ae91..e8e6d140c 100644 --- a/linphone-app/src/components/timeline/TimelineListModel.cpp +++ b/linphone-app/src/components/timeline/TimelineListModel.cpp @@ -352,8 +352,22 @@ void TimelineListModel::onCallCreated(const std::shared_ptr &cal bool found = false; auto callLog = call->getCallLog(); auto callLocalAddress = callLog->getLocalAddress(); + auto currentParams = call->getCurrentParams(); + bool isEncrypted = currentParams->getMediaEncryption() != linphone::MediaEncryption::None; + bool createSecureChatRoom = false; + SettingsModel * settingsModel = CoreManager::getInstance()->getSettingsModel(); + + + + if( settingsModel->getSecureChatEnabled() && + (!settingsModel->getChatEnabled() || (settingsModel->getChatEnabled() && isEncrypted)) + ){ + params->enableEncryption(true); + createSecureChatRoom = true; + } + participants.push_back(callLog->getRemoteAddress()->clone()); auto chatRoom = core->searchChatRoom(params, callLocalAddress - , callLog->getRemoteAddress() + , nullptr//callLog->getRemoteAddress() , participants); if(chatRoom){ for(auto timeline : mTimelines){ @@ -370,7 +384,7 @@ void TimelineListModel::onCallCreated(const std::shared_ptr &cal auto remoteAddress = callLog->getRemoteAddress()->clone(); remoteAddress->clean(); participants << Utils::coreStringToAppString(remoteAddress->asStringUriOnly()); - CoreManager::getInstance()->getCallsListModel()->createChatRoom("", 0, participants, isOutgoing); + CoreManager::getInstance()->getCallsListModel()->createChatRoom("", (createSecureChatRoom?1:0), participants, isOutgoing); } } diff --git a/linphone-app/ui/modules/Linphone/Chat/Chat.qml b/linphone-app/ui/modules/Linphone/Chat/Chat.qml index 20bc6774d..726acd42f 100644 --- a/linphone-app/ui/modules/Linphone/Chat/Chat.qml +++ b/linphone-app/ui/modules/Linphone/Chat/Chat.qml @@ -270,7 +270,6 @@ Rectangle { } } } - footer: Item{ Text { property var composers : container.proxyModel.composers @@ -278,7 +277,7 @@ Rectangle { font.pointSize: ChatStyle.composingText.pointSize height: visible ? undefined : 0 leftPadding: ChatStyle.composingText.leftPadding - visible: composers.length > 0 && SettingsModel.chatEnabled + visible: composers.length > 0 && (!proxyModel.chatRoomModel.haveEncryption && SettingsModel.chatEnabled || proxyModel.chatRoomModel.haveEncryption && SettingsModel.secureChatEnabled) wrapMode: Text.Wrap //: '%1 is typing...' indicate that someone is composing in chat text:(composers.length==0?'': qsTr('chatTyping','',composers.length).arg(container.proxyModel.getDisplayNameComposers())) @@ -359,7 +358,8 @@ Rectangle { borderColor: ChatStyle.sendArea.border.color topWidth: ChatStyle.sendArea.border.width - visible: SettingsModel.chatEnabled && proxyModel.chatRoomModel && !proxyModel.chatRoomModel.hasBeenLeft + visible: proxyModel.chatRoomModel && !proxyModel.chatRoomModel.hasBeenLeft && (!proxyModel.chatRoomModel.haveEncryption && SettingsModel.chatEnabled || proxyModel.chatRoomModel.haveEncryption && SettingsModel.secureChatEnabled) + DroppableTextArea { id: textArea diff --git a/linphone-app/ui/modules/Linphone/Menus/SipAddressesMenu.qml b/linphone-app/ui/modules/Linphone/Menus/SipAddressesMenu.qml index f194974e3..53b45c104 100644 --- a/linphone-app/ui/modules/Linphone/Menus/SipAddressesMenu.qml +++ b/linphone-app/ui/modules/Linphone/Menus/SipAddressesMenu.qml @@ -18,16 +18,16 @@ Item { // --------------------------------------------------------------------------- - function open () { + function open (isSecure) { var length = sipAddresses.length if (!length) { return } if (length === 1) { - return sipAddressesMenu.sipAddressClicked(sipAddresses[0]) + return sipAddressesMenu.sipAddressClicked(sipAddresses[0], isSecure) } - + menu.isSecure = isSecure menu.open() } @@ -41,7 +41,7 @@ Item { // --------------------------------------------------------------------------- - signal sipAddressClicked (string sipAddress) + signal sipAddressClicked (string sipAddress, bool isSecure) // --------------------------------------------------------------------------- @@ -51,6 +51,7 @@ Item { DropDownDynamicMenu { id: menu + property bool isSecure : false parent: sipAddressesMenu.parent @@ -104,7 +105,7 @@ Item { onClicked: { menu.close() - sipAddressesMenu.sipAddressClicked($sipAddress) + sipAddressesMenu.sipAddressClicked($sipAddress, menu.isSecure) } } } diff --git a/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml b/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml index 860f0dedc..fa2c11fef 100644 --- a/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml +++ b/linphone-app/ui/modules/Linphone/SmartSearchBar/SmartSearchBar.qml @@ -60,8 +60,8 @@ SearchBox { actions: [{ icon: 'video_call', - secure:0, - visible:true, + secure: 0, + visible: true, handler: function (entry) { searchBox.closeMenu() searchBox.launchVideoCall(entry.sipAddress) @@ -69,27 +69,30 @@ SearchBox { visible: SettingsModel.videoSupported && SettingsModel.outgoingCallsEnabled && SettingsModel.showStartVideoCallButton }, { icon: 'call', - secure:0, - visible:true, + secure: 0, + visible: true, handler: function (entry) { searchBox.closeMenu() searchBox.launchCall(entry.sipAddress) }, visible: SettingsModel.outgoingCallsEnabled }, { - icon: SettingsModel.chatEnabled && SettingsModel.getShowStartChatButton() ? 'chat' : 'history', - secure:0, - visible:true, + icon: SettingsModel.getShowStartChatButton() ? 'chat' : 'history', + secure: 0, + visible: SettingsModel.chatEnabled , handler: function (entry) { searchBox.closeMenu() searchBox.launchChat(entry.sipAddress) } }, { - icon: SettingsModel.chatEnabled && SettingsModel.getShowStartChatButton() ? 'chat' : 'history', - secure:1, - visible:SettingsModel.chatEnabled && SettingsModel.getShowStartChatButton() && AccountSettingsModel.conferenceURI != '', + icon: SettingsModel.getShowStartChatButton() ? 'chat' : 'history', + secure: 1, + visible: SettingsModel.secureChatEnabled && AccountSettingsModel.conferenceURI != '', visibleHandler : function(entry) { - return UtilsCpp.hasCapability(entry.sipAddress, LinphoneEnums.FriendCapabilityLimeX3Dh); + if(entry) + return UtilsCpp.hasCapability(entry.sipAddress ? entry.sipAddress : entry, LinphoneEnums.FriendCapabilityLimeX3Dh); + else + return false; }, handler: function (entry) { searchBox.closeMenu() diff --git a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml index ac143407f..a888b19d6 100644 --- a/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml +++ b/linphone-app/ui/modules/Linphone/Timeline/Timeline.qml @@ -243,7 +243,7 @@ Rectangle { ? TimelineStyle.contact.backgroundColor.a : TimelineStyle.contact.backgroundColor.b ) - displayUnreadMessageCount: SettingsModel.chatEnabled + displayUnreadMessageCount: SettingsModel.chatEnabled || SettingsModel.secureChatEnabled entry: modelData.chatRoomModel sipAddressColor: isSelected ? TimelineStyle.contact.sipAddress.color.selected diff --git a/linphone-app/ui/views/App/Calls/CallsWindow.qml b/linphone-app/ui/views/App/Calls/CallsWindow.qml index be7de2bc4..e451dcd92 100644 --- a/linphone-app/ui/views/App/Calls/CallsWindow.qml +++ b/linphone-app/ui/views/App/Calls/CallsWindow.qml @@ -202,7 +202,8 @@ Window { Chat { proxyModel: ChatRoomProxyModel { Component.onCompleted: { - if (!SettingsModel.chatEnabled) { + if (chatRoomModel + && (!chatRoomModel.haveEncryption && !SettingsModel.chatEnabled || chatRoomModel.haveEncryption && !SettingsModel.secureChatEnabled)) { setEntryTypeFilter(ChatRoomModel.CallEntry | ChatRoomModel.NoticeEntry) } } @@ -217,7 +218,8 @@ Window { Connections { target: SettingsModel - onChatEnabledChanged: proxyModel.setEntryTypeFilter(status ? ChatRoomModel.GenericEntry : ChatRoomModel.CallEntry | ChatRoomModel.NoticeEntry) + onChatEnabledChanged: if(!chatRoomModel.haveEncryption) proxyModel.setEntryTypeFilter(status ? ChatRoomModel.GenericEntry : ChatRoomModel.CallEntry | ChatRoomModel.NoticeEntry) + onSecureChatEnabledChanged: if(chatRoomModel.haveEncryption) proxyModel.setEntryTypeFilter(status ? ChatRoomModel.GenericEntry : ChatRoomModel.CallEntry | ChatRoomModel.NoticeEntry) } } } diff --git a/linphone-app/ui/views/App/Calls/Incall.qml b/linphone-app/ui/views/App/Calls/Incall.qml index c0b468270..541ee6c4e 100644 --- a/linphone-app/ui/views/App/Calls/Incall.qml +++ b/linphone-app/ui/views/App/Calls/Incall.qml @@ -421,7 +421,7 @@ Rectangle { } ActionButton { - icon: SettingsModel.chatEnabled && SettingsModel.showStartChatButton ? 'chat' : 'history' + icon: (SettingsModel.chatEnabled || SettingsModel.secureChatEnabled) && SettingsModel.showStartChatButton ? 'chat' : 'history' onClicked: { if (window.chatIsOpened) { diff --git a/linphone-app/ui/views/App/Main/ContactEdit.qml b/linphone-app/ui/views/App/Main/ContactEdit.qml index 931093b46..6ce088d41 100644 --- a/linphone-app/ui/views/App/Main/ContactEdit.qml +++ b/linphone-app/ui/views/App/Main/ContactEdit.qml @@ -8,6 +8,7 @@ import Linphone 1.0 import Linphone.Styles 1.0 import UtilsCpp 1.0 +import LinphoneEnums 1.0 import App.Styles 1.0 @@ -147,17 +148,38 @@ ColumnLayout { visible: _contact != null ActionBar { + id: actionBar anchors.verticalCenter: parent.verticalCenter iconSize: ContactEditStyle.bar.actions.history.iconSize ActionButton { - icon: 'history' - - onClicked: sipAddressesMenu.open() - - TooltipArea { - isClickable: false - text: qsTr('tooltipShowConversation') + icon: SettingsModel.getShowStartChatButton() ? 'chat' : 'history' + visible: SettingsModel.chatEnabled + onClicked: sipAddressesMenu.open(false) + TooltipArea { + isClickable: false + text: qsTr('tooltipShowConversation') + } + } + + ActionButton { + icon: SettingsModel.getShowStartChatButton() ? 'chat' : 'history' + visible: SettingsModel.secureChatEnabled && _contact && _contact.hasCapability(LinphoneEnums.FriendCapabilityLimeX3Dh) + enabled: AccountSettingsModel.conferenceURI != '' + Icon{ + icon:'secure_level_1' + iconSize:15 + anchors.right:parent.right + anchors.top:parent.top + anchors.topMargin: -3 + } + onClicked: {sipAddressesMenu.open(true)} + TooltipArea{ + maxWidth: actionBar.width + visible: AccountSettingsModel.conferenceURI == '' + //: 'You need to set the conference URI in your account settings to create a conference based chat room.' : Tooltip to warn the user that a setting is missing in its configuration. + text: '- ' + qsTr('missingConferenceURI') + '\n' + } } } @@ -196,7 +218,7 @@ ColumnLayout { sipAddresses: _contact ? _contact.vcard.sipAddresses : [ contactEdit.sipAddress ] onSipAddressClicked: { - var entry = CallsListModel.createChatRoom( "", false, [sipAddress], false ) + var entry = CallsListModel.createChatRoom( "", isSecure, [sipAddress], false ) if(entry){ window.setView('Conversation', { chatRoomModel:entry.chatRoomModel diff --git a/linphone-app/ui/views/App/Main/Contacts.qml b/linphone-app/ui/views/App/Main/Contacts.qml index fa8a1af0c..5d7836090 100644 --- a/linphone-app/ui/views/App/Main/Contacts.qml +++ b/linphone-app/ui/views/App/Main/Contacts.qml @@ -148,13 +148,14 @@ ColumnLayout { } ActionButton { - icon: SettingsModel.chatEnabled && SettingsModel.getShowStartChatButton() ? 'chat' : 'history' + icon: SettingsModel.getShowStartChatButton() ? 'chat' : 'history' + visible: SettingsModel.chatEnabled onClicked: actions.itemAt(2).open() } ActionButton { - icon: 'chat' - visible: SettingsModel.chatEnabled && SettingsModel.getShowStartChatButton() && $contact.hasCapability(LinphoneEnums.FriendCapabilityLimeX3Dh) + icon: SettingsModel.getShowStartChatButton() ? 'chat' : 'history' + visible: SettingsModel.secureChatEnabled && $contact.hasCapability(LinphoneEnums.FriendCapabilityLimeX3Dh) enabled: AccountSettingsModel.conferenceURI != '' Icon{ icon:'secure_level_1' diff --git a/linphone-app/ui/views/App/Main/Conversation.qml b/linphone-app/ui/views/App/Main/Conversation.qml index d2525d8ce..8c10fd84c 100644 --- a/linphone-app/ui/views/App/Main/Conversation.qml +++ b/linphone-app/ui/views/App/Main/Conversation.qml @@ -264,7 +264,7 @@ ColumnLayout { } ActionButton { icon: 'chat' - visible: SettingsModel.chatEnabled && SettingsModel.getShowStartChatButton() && !conversation.haveMoreThanOneParticipants && conversation.securityLevel == 1 && UtilsCpp.hasCapability(conversation.peerAddress, LinphoneEnums.FriendCapabilityLimeX3Dh) + visible: SettingsModel.secureChatEnabled && SettingsModel.getShowStartChatButton() && !conversation.haveMoreThanOneParticipants && conversation.securityLevel == 1 && UtilsCpp.hasCapability(conversation.peerAddress, LinphoneEnums.FriendCapabilityLimeX3Dh) onClicked: CallsListModel.launchChat(chatRoomModel.participants.addressesToString, 1) Icon{ @@ -415,7 +415,7 @@ ColumnLayout { bottomWidth: ConversationStyle.filters.border.bottomWidth color: ConversationStyle.filters.backgroundColor topWidth: ConversationStyle.filters.border.topWidth - visible: SettingsModel.chatEnabled + visible: !chatRoomModel.haveEncryption && SettingsModel.chatEnabled || chatRoomModel.haveEncryption && SettingsModel.secureChatEnabled ExclusiveButtons { id: filterButtons @@ -515,7 +515,8 @@ ColumnLayout { id: chatRoomProxyModel Component.onCompleted: { - if (!SettingsModel.chatEnabled) { + if ( (!chatRoomModel.haveEncryption && !SettingsModel.chatEnabled) + || (chatRoomModel.haveEncryption && !SettingsModel.secureChatEnabled) ) { setEntryTypeFilter(ChatRoomModel.CallEntry) } } diff --git a/linphone-app/ui/views/App/Main/Dialogs/NewChatRoom.qml b/linphone-app/ui/views/App/Main/Dialogs/NewChatRoom.qml index c83b09c53..21e465ac8 100644 --- a/linphone-app/ui/views/App/Main/Dialogs/NewChatRoom.qml +++ b/linphone-app/ui/views/App/Main/Dialogs/NewChatRoom.qml @@ -119,15 +119,20 @@ DialogPlus { anchors.verticalCenter: parent.verticalCenter width:50 enabled:true + checked: !SettingsModel.chatEnabled && SettingsModel.secureChatEnabled + onClicked: { - if(!checked){ // Remove all participants that have not the capabilities - var participants = selectedParticipants.getParticipants() - for(var index in participants){ - if(!smartSearchBar.isUsable(participants[index].sipAddress)) - participantView.removeParticipant(participants[index]) + var newCheck = checked + if(! ( SettingsModel.chatEnabled && !checked || SettingsModel.secureChatEnabled && checked)) + newCheck = !checked; + if(newCheck){ // Remove all participants that have not the capabilities + var participants = selectedParticipants.getParticipants() + for(var index in participants){ + if(!smartSearchBar.isUsable(participants[index].sipAddress)) + participantView.removeParticipant(participants[index]) + } } - } - checked = !checked + checked = newCheck; } indicatorStyle: SwitchStyle.aux } diff --git a/linphone-app/ui/views/App/Main/MainWindow.qml b/linphone-app/ui/views/App/Main/MainWindow.qml index d395f1527..638fda64a 100644 --- a/linphone-app/ui/views/App/Main/MainWindow.qml +++ b/linphone-app/ui/views/App/Main/MainWindow.qml @@ -201,6 +201,7 @@ ApplicationWindow { //: 'Open Conference' : Tooltip to illustrate a button tooltipText : qsTr('newChatRoom') iconSize: MainWindowStyle.newConferenceSize + visible: SettingsModel.chatEnabled || SettingsModel.secureChatEnabled //autoIcon: true onClicked: { window.detachVirtualWindow() diff --git a/linphone-app/ui/views/App/Settings/SettingsCallsChat.qml b/linphone-app/ui/views/App/Settings/SettingsCallsChat.qml index 754ec9f31..123cc3904 100644 --- a/linphone-app/ui/views/App/Settings/SettingsCallsChat.qml +++ b/linphone-app/ui/views/App/Settings/SettingsCallsChat.qml @@ -216,7 +216,7 @@ TabContainer { Form { title: qsTr('chatTitle') - visible: SettingsModel.chatEnabled || SettingsModel.developerSettingsEnabled + visible: SettingsModel.chatEnabled || SettingsModel.secureChatEnabled || SettingsModel.developerSettingsEnabled width: parent.width FormLine { @@ -231,7 +231,16 @@ TabContainer { onClicked: SettingsModel.chatEnabled = !checked } } - + FormGroup { + label: 'Activate secure chats' + + Switch { + checked: SettingsModel.secureChatEnabled + + onClicked: SettingsModel.secureChatEnabled = !checked + } + } + FormGroup { label: qsTr('conferenceEnabledLabel') diff --git a/linphone-app/ui/views/App/Settings/SettingsUi.qml b/linphone-app/ui/views/App/Settings/SettingsUi.qml index ee5e54def..e7ad37dcc 100644 --- a/linphone-app/ui/views/App/Settings/SettingsUi.qml +++ b/linphone-app/ui/views/App/Settings/SettingsUi.qml @@ -107,6 +107,7 @@ TabContainer { visible: SettingsModel.videoSupported || SettingsModel.callRecorderEnabled || SettingsModel.chatEnabled || + SettingsModel.secureChatEnabled || SettingsModel.developerSettingsEnabled width: parent.width @@ -141,7 +142,7 @@ TabContainer { } FormLine { - visible: SettingsModel.chatEnabled || SettingsModel.developerSettingsEnabled + visible: SettingsModel.chatEnabled || SettingsModel.secureChatEnabled || SettingsModel.developerSettingsEnabled FormGroup { label: qsTr('downloadLabel')