From 5a44f1f3bb6d2b74e8adbf07cb6637b123d01aa9 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Tue, 25 Oct 2022 11:24:38 +0200 Subject: [PATCH] Update conference detection on call. Display group chat icone when calling/receiving a conference. --- .../src/components/call/CallModel.cpp | 17 +- .../src/components/call/CallModel.hpp | 3 + .../src/components/settings/SettingsModel.cpp | 3 - .../ui/modules/Linphone/Contact/Avatar.qml | 168 ++++++++++-------- .../ui/modules/Linphone/Contact/Contact.qml | 31 +--- 5 files changed, 109 insertions(+), 113 deletions(-) diff --git a/linphone-app/src/components/call/CallModel.cpp b/linphone-app/src/components/call/CallModel.cpp index f75823394..666502aab 100644 --- a/linphone-app/src/components/call/CallModel.cpp +++ b/linphone-app/src/components/call/CallModel.cpp @@ -240,7 +240,22 @@ QSharedPointer CallModel::getConferenceSharedModel(){ bool CallModel::isConference () const{ // Check status to avoid crash when requesting a conference on an ended call. - return mCall && (Utils::coreStringToAppString(mCall->getRemoteAddress()->asString()).toLower().contains("conf-id") || (getStatus() != CallStatusEnded && mCall->getConference() != nullptr)); + bool isConf = false; + if(mCall){ + isConf = getStatus() != CallStatusEnded && (mCall->getConference() != nullptr || mConferenceInfoModel != nullptr); + if(!isConf){// Check special cases for Linphone. Having conf-id for a conference URI is not standard. + auto remoteAddress = mCall->getRemoteAddress(); + if( remoteAddress->getDomain() == Constants::LinphoneDomain){ + isConf = remoteAddress->hasUriParam("conf-id"); + } + } + } + + return isConf; +} + +bool CallModel::isOneToOne() const{ + return !isConference(); } // ----------------------------------------------------------------------------- diff --git a/linphone-app/src/components/call/CallModel.hpp b/linphone-app/src/components/call/CallModel.hpp index 2659a33a0..1a3792e7b 100644 --- a/linphone-app/src/components/call/CallModel.hpp +++ b/linphone-app/src/components/call/CallModel.hpp @@ -56,6 +56,8 @@ class CallModel : public QObject { Q_PROPERTY(bool isInConference READ isInConference NOTIFY isInConferenceChanged) Q_PROPERTY(bool isConference READ isConference CONSTANT) + Q_PROPERTY(bool isOneToOne READ isOneToOne CONSTANT) + Q_PROPERTY(int duration READ getDuration CONSTANT) // Constants but called with a timer in qml. Q_PROPERTY(float quality READ getQuality CONSTANT) @@ -137,6 +139,7 @@ public: return mIsInConference; } bool isConference () const; + bool isOneToOne() const; void setRecordFile (const std::shared_ptr &callParams); static void setRecordFile (const std::shared_ptr &callParams, const QString &to); diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index ce815e893..d1b4c0018 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -548,12 +548,9 @@ static inline QVariantMap createMapFromVideoDefinition (const shared_ptrgetCore()->videoSupported()); - map["name"] = QStringLiteral("Bad EGG"); map["width"] = QStringLiteral("?????"); map["height"] = QStringLiteral("?????"); - return map; } diff --git a/linphone-app/ui/modules/Linphone/Contact/Avatar.qml b/linphone-app/ui/modules/Linphone/Contact/Avatar.qml index ab2f99fcf..efe711055 100644 --- a/linphone-app/ui/modules/Linphone/Contact/Avatar.qml +++ b/linphone-app/ui/modules/Linphone/Contact/Avatar.qml @@ -10,84 +10,94 @@ import UtilsCpp 1.0 // ============================================================================= Item { - id: avatar - - // --------------------------------------------------------------------------- - - property alias presenceLevel: presenceLevelIcon.level - property color backgroundColor: AvatarStyle.backgroundColor - property color foregroundColor: 'transparent' - property string username - property var image - - property var _initialsRegex: /^\s*([^\s\.]+)(?:[\s\.]+([^\s\.]+))?/ - - property bool isPhoneNumber: UtilsCpp.isPhoneNumber(username) - - // --------------------------------------------------------------------------- - - function isLoaded () { - return roundedImage.status === Image.Ready - } - - function _computeInitials () { - var result = username.match(_initialsRegex) - if (!result) { - return username.length > 0 ? username.charAt(0).toUpperCase() : '' - } - - return result[1].charAt(0).toUpperCase() + ( - result[2] != null - ? result[2].charAt(0).toUpperCase() - : '' - ) - } - - // --------------------------------------------------------------------------- - - RoundedImage { - id: roundedImage - - anchors.fill: parent - backgroundColor: avatar.backgroundColor - foregroundColor: avatar.foregroundColor - source: avatar.image || '' - Icon{ + id: avatar + + // --------------------------------------------------------------------------- + + property alias presenceLevel: presenceLevelIcon.level + property color backgroundColor: AvatarStyle.backgroundColor + property color foregroundColor: 'transparent' + property string username + property var image + property bool isOneToOne: true + + property var _initialsRegex: /^\s*([^\s\.]+)(?:[\s\.]+([^\s\.]+))?/ + + property bool isPhoneNumber: UtilsCpp.isPhoneNumber(username) + + // --------------------------------------------------------------------------- + + function isLoaded () { + return roundedImage.status === Image.Ready + } + + function _computeInitials () { + var result = username.match(_initialsRegex) + if (!result) { + return username.length > 0 ? username.charAt(0).toUpperCase() : '' + } + + return result[1].charAt(0).toUpperCase() + ( + result[2] != null + ? result[2].charAt(0).toUpperCase() + : '' + ) + } + + // --------------------------------------------------------------------------- + + RoundedImage { + id: roundedImage + anchors.fill: parent - icon: AvatarStyle.personImage - visible: parent.source == '' && avatar.isPhoneNumber - overwriteColor: AvatarStyle.initials.color - } - } - - Text { - id: initialsText - anchors.centerIn: parent - color: AvatarStyle.initials.color - font.pointSize: { - var width - - if (parent.width > 0) { - width = parent.width / AvatarStyle.initials.ratio - } - - return AvatarStyle.initials.pointSize * (width || 1) - } - - text: _computeInitials() - visible: roundedImage.status !== Image.Ready && !avatar.isPhoneNumber - } - - PresenceLevel { - id: presenceLevelIcon - visible: level >= 0 - - anchors { - bottom: parent.bottom - right: parent.right - } - - height: parent.height / 4 - width: parent.width / 4 - } + backgroundColor: avatar.backgroundColor + foregroundColor: avatar.foregroundColor + source: avatar.image || '' + Icon{ + anchors.fill: parent + icon: AvatarStyle.personImage + visible: parent.source == '' && avatar.isPhoneNumber + overwriteColor: AvatarStyle.initials.color + } + } + + Text { + id: initialsText + anchors.centerIn: parent + color: AvatarStyle.initials.color + font.pointSize: { + var width + + if (parent.width > 0) { + width = parent.width / AvatarStyle.initials.ratio + } + + return AvatarStyle.initials.pointSize * (width || 1) + } + + text: _computeInitials() + visible: roundedImage.status !== Image.Ready && !avatar.isPhoneNumber && avatar.isOneToOne + } + + Icon { + anchors.fill: parent + icon: ContactStyle.groupChat.icon + overwriteColor: ContactStyle.groupChat.avatarColor + iconSize: avatar.width + //visible: entry!=undefined && entry.isOneToOne!=undefined && !entry.isOneToOne + visible: !avatar.isOneToOne + } + + PresenceLevel { + id: presenceLevelIcon + visible: level >= 0 + + anchors { + bottom: parent.bottom + right: parent.right + } + + height: parent.height / 4 + width: parent.width / 4 + } } diff --git a/linphone-app/ui/modules/Linphone/Contact/Contact.qml b/linphone-app/ui/modules/Linphone/Contact/Contact.qml index 81a7a73f2..ae90b0a1a 100644 --- a/linphone-app/ui/modules/Linphone/Contact/Contact.qml +++ b/linphone-app/ui/modules/Linphone/Contact/Contact.qml @@ -75,16 +75,7 @@ Rectangle { ? '' : item.username : item.username - visible:!groupChat.visible - Icon { - - anchors.fill: parent - - icon: ContactStyle.groupChat.icon - overwriteColor: ContactStyle.groupChat.avatarColor - iconSize: ContactStyle.contentHeight - visible: entry!=undefined && entry.isOneToOne!=undefined && !entry.isOneToOne - } + isOneToOne: entry==undefined || entry.isOneToOne==undefined || entry.isOneToOne Icon{ anchors.top:parent.top @@ -98,26 +89,6 @@ Rectangle { onClicked: item.avatarClicked(mouse) } } - Icon { - id: groupChat - - Layout.preferredHeight: ContactStyle.contentHeight - Layout.preferredWidth: ContactStyle.contentHeight - - icon: ContactStyle.groupChat.icon - overwriteColor: ContactStyle.groupChat.color - iconSize: ContactStyle.contentHeight - visible: false //entry!=undefined && entry.isOneToOne!=undefined && !entry.isOneToOne - - Icon{ - anchors.right: parent.right - anchors.top:parent.top - anchors.topMargin: -5 - visible: entry!=undefined && entry.haveEncryption != undefined && entry.haveEncryption - icon: entry?(entry.securityLevel === 2?'secure_level_1': entry.securityLevel===3? 'secure_level_2' : 'secure_level_unsafe'):'secure_level_unsafe' - iconSize:15 - } - } ContactDescription { id: description