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

This commit is contained in:
Ronan Abhamon 2017-08-09 14:14:38 +02:00
parent d7be2afbb7
commit 8bf34d85ca
5 changed files with 16 additions and 13 deletions

View file

@ -71,7 +71,7 @@ CallModel::~CallModel () {
// -----------------------------------------------------------------------------
QString CallModel::getSipAddress () const {
return ::Utils::coreStringToAppString(mCall->getRemoteAddress()->asStringUriOnly());
return ::Utils::coreStringToAppString(mCall->getRemoteAddress()->asString());
}
// -----------------------------------------------------------------------------

View file

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

View file

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

View file

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

View file

@ -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('>'))
}