Update conference detection on call.

Display group chat icone when calling/receiving a conference.
This commit is contained in:
Julien Wadel 2022-10-25 11:24:38 +02:00
parent 1def97ee08
commit 5a44f1f3bb
5 changed files with 109 additions and 113 deletions

View file

@ -240,7 +240,22 @@ QSharedPointer<ConferenceModel> 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();
}
// -----------------------------------------------------------------------------

View file

@ -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<linphone::CallParams> &callParams);
static void setRecordFile (const std::shared_ptr<linphone::CallParams> &callParams, const QString &to);

View file

@ -548,12 +548,9 @@ static inline QVariantMap createMapFromVideoDefinition (const shared_ptr<const l
QVariantMap map;
if (!definition) {
Q_ASSERT(!CoreManager::getInstance()->getCore()->videoSupported());
map["name"] = QStringLiteral("Bad EGG");
map["width"] = QStringLiteral("?????");
map["height"] = QStringLiteral("?????");
return map;
}

View file

@ -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
}
}

View file

@ -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