diff --git a/src/components/call/CallModel.cpp b/src/components/call/CallModel.cpp index 8974b1da9..e0788dce6 100644 --- a/src/components/call/CallModel.cpp +++ b/src/components/call/CallModel.cpp @@ -71,7 +71,7 @@ CallModel::~CallModel () { // ----------------------------------------------------------------------------- QString CallModel::getSipAddress () const { - return ::Utils::coreStringToAppString(mCall->getRemoteAddress()->asStringUriOnly()); + return ::Utils::coreStringToAppString(mCall->getRemoteAddress()->asString()); } // ----------------------------------------------------------------------------- diff --git a/src/components/sip-addresses/SipAddressesModel.cpp b/src/components/sip-addresses/SipAddressesModel.cpp index 033f5eeed..cc1a1eaed 100644 --- a/src/components/sip-addresses/SipAddressesModel.cpp +++ b/src/components/sip-addresses/SipAddressesModel.cpp @@ -99,9 +99,10 @@ ContactModel *SipAddressesModel::mapSipAddressToContact (const QString &sipAddre SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sipAddress) { SipAddressObserver *model = new SipAddressObserver(sipAddress); + const QString cleanedSipAddress = cleanSipAddress(sipAddress); { - auto it = mSipAddresses.find(sipAddress); + auto it = mSipAddresses.find(cleanedSipAddress); if (it != mSipAddresses.end()) { model->setContact(it->value("contact").value()); model->setPresenceStatus( @@ -113,10 +114,10 @@ SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sip } } - mObservers.insert(sipAddress, model); + mObservers.insert(cleanedSipAddress, model); QObject::connect( model, &SipAddressObserver::destroyed, this, [this, model]() { - const QString sipAddress = model->getSipAddress(); + const QString sipAddress = cleanSipAddress(model->getSipAddress()); if (mObservers.remove(sipAddress, model) == 0) qWarning() << QStringLiteral("Unable to remove sip address `%1` from observers.").arg(sipAddress); }); @@ -190,6 +191,13 @@ bool SipAddressesModel::sipAddressIsValid (const QString &sipAddress) { return address && !address->getUsername().empty(); } +QString SipAddressesModel::cleanSipAddress (const QString &sipAddress) { + const int index = sipAddress.lastIndexOf('<'); + if (index == -1) + return sipAddress; + return sipAddress.mid(index + 1, sipAddress.lastIndexOf('>') - index - 1); +} + // ----------------------------------------------------------------------------- bool SipAddressesModel::removeRow (int row, const QModelIndex &parent) { diff --git a/src/components/sip-addresses/SipAddressesModel.hpp b/src/components/sip-addresses/SipAddressesModel.hpp index 9b3dccf8b..ef4e00f8c 100644 --- a/src/components/sip-addresses/SipAddressesModel.hpp +++ b/src/components/sip-addresses/SipAddressesModel.hpp @@ -62,6 +62,8 @@ public: Q_INVOKABLE static bool addressIsValid (const QString &address); Q_INVOKABLE static bool sipAddressIsValid (const QString &sipAddress); + Q_INVOKABLE static QString cleanSipAddress (const QString &sipAddress); + // --------------------------------------------------------------------------- private: diff --git a/ui/modules/Linphone/Contact/ContactDescription.qml b/ui/modules/Linphone/Contact/ContactDescription.qml index 2cfe983a2..4351a8ba8 100644 --- a/ui/modules/Linphone/Contact/ContactDescription.qml +++ b/ui/modules/Linphone/Contact/ContactDescription.qml @@ -1,7 +1,7 @@ import QtQuick 2.7 +import Linphone 1.0 import Linphone.Styles 1.0 -import LinphoneUtils 1.0 // ============================================================================= @@ -29,7 +29,7 @@ Column { } Text { - text: LinphoneUtils.cleanSipAddress(sipAddress) + text: SipAddressesModel.cleanSipAddress(sipAddress) color: sipAddressColor elide: Text.ElideRight diff --git a/ui/scripts/LinphoneUtils/linphone-utils.js b/ui/scripts/LinphoneUtils/linphone-utils.js index 30874ca59..7d39c4247 100644 --- a/ui/scripts/LinphoneUtils/linphone-utils.js +++ b/ui/scripts/LinphoneUtils/linphone-utils.js @@ -84,10 +84,3 @@ function getContactUsername (contact) { name = _getUsername(object) return name == null ? 'Bad EGG' : name } - -function cleanSipAddress (sipAddress) { - var index = sipAddress.indexOf('<') - return index === -1 - ? sipAddress - : sipAddress.substring(index + 1, sipAddress.lastIndexOf('>')) -}