Commit 8bf34d85 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(Call): display correctly `forced display name` and only sip uri in description

parent d7be2afb
......@@ -71,7 +71,7 @@ CallModel::~CallModel () {
// -----------------------------------------------------------------------------
QString CallModel::getSipAddress () const {
return ::Utils::coreStringToAppString(mCall->getRemoteAddress()->asStringUriOnly());
return ::Utils::coreStringToAppString(mCall->getRemoteAddress()->asString());
}
// -----------------------------------------------------------------------------
......
......@@ -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<ContactModel *>());
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) {
......
......@@ -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:
......
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
......
......@@ -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('>'))
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment