Fix Timeline notifications and display name

- Add interfaces to get full sip address
- Use Full Sip addresses when using getSipAddressObserver
- Return -1 instead of null when searching an index in an array in Javascript
This commit is contained in:
Julien Wadel 2020-05-11 12:34:55 +02:00
parent 598be61d91
commit d0b21228a4
25 changed files with 105 additions and 28 deletions

View file

@ -88,10 +88,17 @@ CallModel::~CallModel () {
// -----------------------------------------------------------------------------
QString CallModel::getPeerAddress () const {
return Utils::coreStringToAppString(mCall->getRemoteAddress()->asString());
return Utils::coreStringToAppString(mCall->getRemoteAddress()->asStringUriOnly());
}
QString CallModel::getLocalAddress () const {
return Utils::coreStringToAppString(mCall->getCallLog()->getLocalAddress()->asStringUriOnly());
}
QString CallModel::getFullPeerAddress () const {
return Utils::coreStringToAppString(mCall->getRemoteAddress()->asString());
}
QString CallModel::getFullLocalAddress () const {
return Utils::coreStringToAppString(mCall->getCallLog()->getLocalAddress()->asString());
}
// -----------------------------------------------------------------------------

View file

@ -32,6 +32,8 @@ class CallModel : public QObject {
Q_PROPERTY(QString peerAddress READ getPeerAddress CONSTANT);
Q_PROPERTY(QString localAddress READ getLocalAddress CONSTANT);
Q_PROPERTY(QString fullPeerAddress READ getFullPeerAddress CONSTANT);
Q_PROPERTY(QString fullLocalAddress READ getFullLocalAddress CONSTANT);
Q_PROPERTY(CallStatus status READ getStatus NOTIFY statusChanged);
Q_PROPERTY(QString callError READ getCallError NOTIFY callErrorChanged);
@ -94,6 +96,8 @@ public:
QString getPeerAddress () const;
QString getLocalAddress () const;
QString getFullPeerAddress () const;
QString getFullLocalAddress () const;
bool isInConference () const {
return mIsInConference;

View file

@ -383,16 +383,26 @@ bool ChatModel::removeRows (int row, int count, const QModelIndex &parent) {
QString ChatModel::getPeerAddress () const {
return Utils::coreStringToAppString(
mChatRoom->getPeerAddress()->asString()
mChatRoom->getPeerAddress()->asStringUriOnly()
);
}
QString ChatModel::getLocalAddress () const {
return Utils::coreStringToAppString(
mChatRoom->getLocalAddress()->asString()
mChatRoom->getLocalAddress()->asStringUriOnly()
);
}
QString ChatModel::getFullPeerAddress () const {
return Utils::coreStringToAppString(
mChatRoom->getPeerAddress()->asString()
);
}
QString ChatModel::getFullLocalAddress () const {
return Utils::coreStringToAppString(
mChatRoom->getLocalAddress()->asString()
);
}
void ChatModel::setSipAddresses (const QString &peerAddress, const QString &localAddress) {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::Factory> factory(linphone::Factory::get());

View file

@ -82,6 +82,8 @@ public:
QString getPeerAddress () const;
QString getLocalAddress () const;
QString getFullPeerAddress () const;
QString getFullLocalAddress () const;
bool getIsRemoteComposing () const;

View file

@ -172,6 +172,22 @@ void ChatProxyModel::setLocalAddress (const QString &localAddress) {
reload();
}
QString ChatProxyModel::getFullPeerAddress () const {
return mChatModel ? mChatModel->getFullPeerAddress() : QString("");
}
void ChatProxyModel::setFullPeerAddress (const QString &peerAddress) {
mFullPeerAddress = peerAddress;
}
QString ChatProxyModel::getFullLocalAddress () const {
return mChatModel ? mChatModel->getFullLocalAddress() : QString("");
}
void ChatProxyModel::setFullLocalAddress (const QString &localAddress) {
mFullLocalAddress = localAddress;
}
bool ChatProxyModel::getIsRemoteComposing () const {
return mChatModel ? mChatModel->getIsRemoteComposing() : false;
}

View file

@ -36,6 +36,8 @@ class ChatProxyModel : public QSortFilterProxyModel {
Q_PROPERTY(QString peerAddress READ getPeerAddress WRITE setPeerAddress NOTIFY peerAddressChanged);
Q_PROPERTY(QString localAddress READ getLocalAddress WRITE setLocalAddress NOTIFY localAddressChanged);
Q_PROPERTY(QString fullPeerAddress READ getFullPeerAddress WRITE setFullPeerAddress NOTIFY fullPeerAddressChanged);
Q_PROPERTY(QString fullLocalAddress READ getFullLocalAddress WRITE setFullLocalAddress NOTIFY fullLocalAddressChanged);
Q_PROPERTY(bool isRemoteComposing READ getIsRemoteComposing NOTIFY isRemoteComposingChanged);
public:
@ -61,6 +63,8 @@ public:
signals:
void peerAddressChanged (const QString &peerAddress);
void localAddressChanged (const QString &localAddress);
void fullPeerAddressChanged (const QString &fullPeerAddress);
void fullLocalAddressChanged (const QString &fullLocalAddress);
bool isRemoteComposingChanged (bool status);
void moreEntriesLoaded (int n);
@ -76,6 +80,12 @@ private:
QString getLocalAddress () const;
void setLocalAddress (const QString &localAddress);
QString getFullPeerAddress () const;
void setFullPeerAddress (const QString &peerAddress);
QString getFullLocalAddress () const;
void setFullLocalAddress (const QString &localAddress);
bool getIsRemoteComposing () const;
@ -91,6 +101,8 @@ private:
QString mPeerAddress;
QString mLocalAddress;
QString mFullPeerAddress;
QString mFullLocalAddress;
std::shared_ptr<ChatModel> mChatModel;

View file

@ -255,8 +255,10 @@ void Notifier::notifyReceivedMessage (const shared_ptr<linphone::ChatMessage> &m
: Utils::coreStringToAppString(message->getText());
shared_ptr<linphone::ChatRoom> chatRoom(message->getChatRoom());
map["peerAddress"] = Utils::coreStringToAppString(chatRoom->getPeerAddress()->asString());
map["localAddress"] = Utils::coreStringToAppString(chatRoom->getLocalAddress()->asString());
map["peerAddress"] = Utils::coreStringToAppString(chatRoom->getPeerAddress()->asStringUriOnly());
map["localAddress"] = Utils::coreStringToAppString(chatRoom->getLocalAddress()->asStringUriOnly());
map["fullPeerAddress"] = Utils::coreStringToAppString(chatRoom->getPeerAddress()->asString());
map["fullLocalAddress"] = Utils::coreStringToAppString(chatRoom->getLocalAddress()->asString());
map["window"].setValue(App::getInstance()->getMainWindow());
CREATE_NOTIFICATION(Notifier::ReceivedMessage, map)
}

View file

@ -79,10 +79,13 @@ void AccountSettingsModel::setUsedSipAddress (const shared_ptr<const linphone::A
proxyConfig ? proxyConfig->setIdentityAddress(address) : core->setPrimaryContact(address->asString());
}
QString AccountSettingsModel::getUsedSipAddressAsString () const {
QString AccountSettingsModel::getUsedSipAddressAsStringUriOnly () const {
return Utils::coreStringToAppString(getUsedSipAddress()->asStringUriOnly());
}
QString AccountSettingsModel::getUsedSipAddressAsString () const {
return Utils::coreStringToAppString(getUsedSipAddress()->asString());
}
// -----------------------------------------------------------------------------
bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
@ -397,7 +400,8 @@ QVariantList AccountSettingsModel::getAccounts () const {
{
QVariantMap account;
account["sipAddress"] = Utils::coreStringToAppString(core->createPrimaryContactParsed()->asString());
account["sipAddress"] = Utils::coreStringToAppString(core->createPrimaryContactParsed()->asStringUriOnly());
account["fullSipAddress"] = Utils::coreStringToAppString(core->createPrimaryContactParsed()->asString());
account["unreadMessageCount"] = core->getUnreadChatMessageCountFromLocal(core->createPrimaryContactParsed());
account["proxyConfig"].setValue(nullptr);
accounts << account;
@ -405,7 +409,8 @@ QVariantList AccountSettingsModel::getAccounts () const {
for (const auto &proxyConfig : core->getProxyConfigList()) {
QVariantMap account;
account["sipAddress"] = Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString());
account["sipAddress"] = Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asStringUriOnly());
account["fullSipAddress"] = Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString());
account["proxyConfig"].setValue(proxyConfig);
account["unreadMessageCount"] = proxyConfig->getUnreadChatMessageCount();
accounts << account;

View file

@ -34,7 +34,8 @@ class AccountSettingsModel : public QObject {
// Selected proxy config.
Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY accountSettingsUpdated);
Q_PROPERTY(QString sipAddress READ getUsedSipAddressAsString NOTIFY accountSettingsUpdated);
Q_PROPERTY(QString sipAddress READ getUsedSipAddressAsStringUriOnly NOTIFY accountSettingsUpdated);
Q_PROPERTY(QString fullSipAddress READ getUsedSipAddressAsString);
Q_PROPERTY(RegistrationState registrationState READ getRegistrationState NOTIFY accountSettingsUpdated);
// Default info.
@ -58,6 +59,7 @@ public:
std::shared_ptr<const linphone::Address> getUsedSipAddress () const;
void setUsedSipAddress (const std::shared_ptr<const linphone::Address> &address);
QString getUsedSipAddressAsStringUriOnly () const;
QString getUsedSipAddressAsString () const;
bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);

View file

@ -31,9 +31,9 @@ TimelineModel::TimelineModel (QObject *parent) : QSortFilterProxyModel(parent) {
AccountSettingsModel *accountSettingsModel = coreManager->getAccountSettingsModel();
QObject::connect(accountSettingsModel, &AccountSettingsModel::accountSettingsUpdated, this, [this]() {
handleLocalAddressChanged(CoreManager::getInstance()->getAccountSettingsModel()->getUsedSipAddressAsString());
handleLocalAddressChanged(CoreManager::getInstance()->getAccountSettingsModel()->getUsedSipAddressAsStringUriOnly());
});
mLocalAddress = accountSettingsModel->getUsedSipAddressAsString();
mLocalAddress = accountSettingsModel->getUsedSipAddressAsStringUriOnly();
setSourceModel(coreManager->getSipAddressesModel());
sort(0);

View file

@ -20,6 +20,8 @@ Rectangle {
property string peerAddress
property string localAddress
property string fullPeerAddress
property string fullLocalAddress
// ---------------------------------------------------------------------------
@ -64,7 +66,7 @@ Rectangle {
displayUnreadMessageCount: true
entry: SipAddressesModel.getSipAddressObserver(peerAddress, localAddress)
entry: SipAddressesModel.getSipAddressObserver((fullPeerAddress?fullPeerAddress:peerAddress), (fullLocalAddress?fullLocalAddress:localAddress))
}
Item {

View file

@ -144,6 +144,8 @@ ListView {
peerAddress: $call.peerAddress
localAddress: $call.localAddress
fullPeerAddress: $call.fullPeerAddress
fullLocalAddress: $call.fullLocalAddress
width: parent.width

View file

@ -34,7 +34,7 @@ Rectangle {
property bool bindToEnd: false
property bool tryToLoadMoreEntries: true
property var sipAddressObserver: SipAddressesModel.getSipAddressObserver(proxyModel.peerAddress, proxyModel.localAddress)
property var sipAddressObserver: SipAddressesModel.getSipAddressObserver(proxyModel.fullPeerAddress, proxyModel.fullLocalAddress)
// -----------------------------------------------------------------------

View file

@ -47,7 +47,7 @@ Rectangle {
? Presence.getPresenceLevel(entry.presenceStatus)
: -1
username: LinphoneUtils.getContactUsername(_contact || entry.sipAddress || entry.peerAddress || '')
username: LinphoneUtils.getContactUsername(_contact || entry.sipAddress || entry.fullPeerAddress || entry.peerAddress || '')
}
ContactDescription {
@ -57,7 +57,7 @@ Rectangle {
Layout.fillWidth: true
Layout.leftMargin: ContactStyle.spacing
sipAddress: entry.sipAddress || entry.peerAddress || ''
sipAddress: entry.sipAddress || entry.fullPeerAddress || entry.peerAddress || ''
username: avatar.username
}

View file

@ -36,7 +36,7 @@ Notification {
entry: {
var call = notification.call
return SipAddressesModel.getSipAddressObserver(call ? call.peerAddress : '', call ? call.localAddress : '')
return SipAddressesModel.getSipAddressObserver(call ? call.fullPeerAddress : '', call ? call.fullLocalAddress : '')
}
}

View file

@ -16,6 +16,8 @@ Notification {
readonly property string peerAddress: notificationData && notificationData.peerAddress || ''
readonly property string localAddress: notificationData && notificationData.localAddress || ''
readonly property string fullPeerAddress: notificationData && notificationData.fullPeerAddress || ''
readonly property string fullLocalAddress: notificationData && notificationData.fullLocalAddress || ''
// ---------------------------------------------------------------------------
@ -35,7 +37,7 @@ Notification {
Contact {
Layout.fillWidth: true
entry: SipAddressesModel.getSipAddressObserver(notification.peerAddress, notification.localAddress)
entry: SipAddressesModel.getSipAddressObserver(notification.fullPeerAddress, notification.fullLocalAddress)
}
Rectangle {
@ -76,7 +78,9 @@ Notification {
AccountSettingsModel.setDefaultProxyConfigFromSipAddress(notification.localAddress)
notification.notificationData.window.setView('Conversation', {
peerAddress: notification.peerAddress,
localAddress: notification.localAddress
localAddress: notification.localAddress,
fullPeerAddress: notification.fullPeerAddress,
fullLocalAddress: notification.fullLocalAddress
})
})
}

View file

@ -463,7 +463,7 @@ function findIndex (array, cb, context) {
cb = _computeOptimizedCb(cb, context)
var key = _indexFinder(array, cb, context)
return key != null && key !== -1 ? key : null
return key != null ? key : -1
}
// -----------------------------------------------------------------------------

View file

@ -13,7 +13,7 @@ Rectangle {
property var call
default property alias _actionArea: actionArea.data
property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(call.peerAddress, call.localAddress)
property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(call.fullPeerAddress, call.fullLocalAddress)
// ---------------------------------------------------------------------------

View file

@ -117,6 +117,7 @@ Rectangle {
Column {
readonly property string sipAddress: $call.peerAddress
readonly property string fullSipAddress: $call.fullPeerAddress
anchors {
fill: parent
@ -133,7 +134,7 @@ Rectangle {
horizontalTextAlignment: Text.AlignHCenter
sipAddress: parent.sipAddress
username: LinphoneUtils.getContactUsername(parent.sipAddress)
username: LinphoneUtils.getContactUsername(parent.fullSipAddress)
}
IncallAvatar {

View file

@ -46,7 +46,7 @@ DialogPlus {
Contact {
Layout.fillWidth: true
entry: SipAddressesModel.getSipAddressObserver(call ? call.peerAddress : '', call ? call.localAddress : '')
entry: SipAddressesModel.getSipAddressObserver(call ? call.fullPeerAddress : '', call ? call.fullLocalAddress : '')
}
// -------------------------------------------------------------------------

View file

@ -16,7 +16,7 @@ Rectangle {
property var call
property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(call ? call.peerAddress : '', call ? call.localAddress : '')
property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(call ? call.fullPeerAddress : '', call ? call.fullLocalAddress : '')
// ---------------------------------------------------------------------------

View file

@ -26,7 +26,7 @@ Rectangle {
property var call
property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(call.peerAddress, call.localAddress)
property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(call.fullPeerAddress, call.fullLocalAddress)
property var _fullscreen: null
// ---------------------------------------------------------------------------

View file

@ -10,7 +10,7 @@ import App.Styles 1.0
Avatar {
property var call
readonly property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(call.peerAddress, call.localAddress)
readonly property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(call.fullPeerAddress, call.fullLocalAddress)
readonly property var _username: LinphoneUtils.getContactUsername(_sipAddressObserver)
backgroundColor: CallStyle.container.avatar.backgroundColor

View file

@ -15,8 +15,10 @@ ColumnLayout {
property string peerAddress
property string localAddress
property string fullPeerAddress
property string fullLocalAddress
readonly property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver(peerAddress, localAddress)
readonly property var _sipAddressObserver: SipAddressesModel.getSipAddressObserver((fullPeerAddress?fullPeerAddress:peerAddress), (fullLocalAddress?fullLocalAddress:localAddress))
// ---------------------------------------------------------------------------
@ -170,6 +172,8 @@ ColumnLayout {
peerAddress: conversation.peerAddress
localAddress: conversation.localAddress
fullPeerAddress: conversation.fullPeerAddress
fullLocalAddress: conversation.fullLocalAddress
}
}

View file

@ -159,7 +159,9 @@ ApplicationWindow {
} else {
window.setView('Conversation', {
peerAddress: entry.sipAddress,
localAddress: AccountSettingsModel.sipAddress
localAddress: AccountSettingsModel.sipAddress,
fullPeerAddress: entry.fullSipAddress,
fullLocalAddress: AccountSettingsModel.fullSipAddress
})
}
}
@ -167,7 +169,9 @@ ApplicationWindow {
onLaunchCall: CallsListModel.launchAudioCall(sipAddress)
onLaunchChat: window.setView('Conversation', {
peerAddress: sipAddress,
localAddress: AccountSettingsModel.sipAddress
localAddress: AccountSettingsModel.sipAddress,
fullPeerAddress: sipAddress,
fullLocalAddress: AccountSettingsModel.fullSipAddress
})
onLaunchVideoCall: CallsListModel.launchVideoCall(sipAddress)