From 091227e83bb0d41e6370f2180a6e86c0a98d624b Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 9 Aug 2017 12:31:27 +0200 Subject: [PATCH] feat(SipAddressesView): do not display wrong default sip address --- src/app/cli/Cli.cpp | 2 +- src/components/calls/CallsListModel.cpp | 10 +++++----- src/components/calls/CallsListModel.hpp | 4 ++-- src/components/conference/ConferenceAddModel.cpp | 2 +- src/components/contact/VcardModel.cpp | 2 +- src/components/sip-addresses/SipAddressesModel.cpp | 8 +++++--- src/components/sip-addresses/SipAddressesModel.hpp | 4 ++-- src/components/url-handlers/UrlHandlers.cpp | 2 +- ui/modules/Linphone/View/SipAddressesView.qml | 2 +- 9 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/app/cli/Cli.cpp b/src/app/cli/Cli.cpp index deeb73ab8..9b08e61f4 100644 --- a/src/app/cli/Cli.cpp +++ b/src/app/cli/Cli.cpp @@ -52,7 +52,7 @@ static void cliInitiateConference (QHash &args) { // Check identity. { - shared_ptr address = core->interpretUrl(::Utils::appStringToCoreString(args["sip-address"])); + shared_ptr address = core->interpretSipAddress(::Utils::appStringToCoreString(args["sip-address"])); address->clean(); const string sipAddress = address->asString(); diff --git a/src/components/calls/CallsListModel.cpp b/src/components/calls/CallsListModel.cpp index b173d5fdd..24337e5a9 100644 --- a/src/components/calls/CallsListModel.cpp +++ b/src/components/calls/CallsListModel.cpp @@ -91,10 +91,10 @@ void CallsListModel::askForTransfer (CallModel *callModel) { // ----------------------------------------------------------------------------- -void CallsListModel::launchAudioCall (const QString &sipUri, const QHash &headers) const { +void CallsListModel::launchAudioCall (const QString &sipAddress, const QHash &headers) const { shared_ptr core = CoreManager::getInstance()->getCore(); - shared_ptr address = core->interpretUrl(::Utils::appStringToCoreString(sipUri)); + shared_ptr address = core->interpretSipAddress(::Utils::appStringToCoreString(sipAddress)); if (!address) return; @@ -111,15 +111,15 @@ void CallsListModel::launchAudioCall (const QString &sipUri, const QHashinviteAddressWithParams(address, params); } -void CallsListModel::launchVideoCall (const QString &sipUri) const { +void CallsListModel::launchVideoCall (const QString &sipAddress) const { shared_ptr core = CoreManager::getInstance()->getCore(); if (!core->videoSupported()) { qWarning() << QStringLiteral("Unable to launch video call. (Video not supported.) Launching audio call..."); - launchAudioCall(sipUri); + launchAudioCall(sipAddress); return; } - shared_ptr address = core->interpretUrl(::Utils::appStringToCoreString(sipUri)); + shared_ptr address = core->interpretSipAddress(::Utils::appStringToCoreString(sipAddress)); if (!address) return; diff --git a/src/components/calls/CallsListModel.hpp b/src/components/calls/CallsListModel.hpp index 571765133..c64614624 100644 --- a/src/components/calls/CallsListModel.hpp +++ b/src/components/calls/CallsListModel.hpp @@ -45,8 +45,8 @@ public: void askForTransfer (CallModel *callModel); - Q_INVOKABLE void launchAudioCall (const QString &sipUri, const QHash &headers = {}) const; - Q_INVOKABLE void launchVideoCall (const QString &sipUri) const; + Q_INVOKABLE void launchAudioCall (const QString &sipAddress, const QHash &headers = {}) const; + Q_INVOKABLE void launchVideoCall (const QString &sipAddress) const; Q_INVOKABLE int getRunningCallsNumber () const; diff --git a/src/components/conference/ConferenceAddModel.cpp b/src/components/conference/ConferenceAddModel.cpp index b1de6639a..2f6608937 100644 --- a/src/components/conference/ConferenceAddModel.cpp +++ b/src/components/conference/ConferenceAddModel.cpp @@ -95,7 +95,7 @@ bool ConferenceHelperModel::ConferenceAddModel::addToConference (const QString & beginInsertRows(QModelIndex(), row, row); qInfo() << QStringLiteral("Add sip address to conference: `%1`.").arg(sipAddress); - shared_ptr linphoneAddress = CoreManager::getInstance()->getCore()->interpretUrl( + shared_ptr linphoneAddress = CoreManager::getInstance()->getCore()->interpretSipAddress( ::Utils::appStringToCoreString(sipAddress) ); addToConferencePrivate(linphoneAddress); diff --git a/src/components/contact/VcardModel.cpp b/src/components/contact/VcardModel.cpp index c8f5d7dd0..f943a651f 100644 --- a/src/components/contact/VcardModel.cpp +++ b/src/components/contact/VcardModel.cpp @@ -96,7 +96,7 @@ static void removeBelcardPhoto (const shared_ptr &belcard, boo static string interpretSipAddress (const QString &sipAddress) { string out; - shared_ptr linphoneAddress = CoreManager::getInstance()->getCore()->interpretUrl( + shared_ptr linphoneAddress = CoreManager::getInstance()->getCore()->interpretSipAddress( ::Utils::appStringToCoreString(sipAddress) ); diff --git a/src/components/sip-addresses/SipAddressesModel.cpp b/src/components/sip-addresses/SipAddressesModel.cpp index 091afbd28..033f5eeed 100644 --- a/src/components/sip-addresses/SipAddressesModel.cpp +++ b/src/components/sip-addresses/SipAddressesModel.cpp @@ -163,15 +163,17 @@ QString SipAddressesModel::addTransportToSipAddress (const QString &sipAddress, // ----------------------------------------------------------------------------- -QString SipAddressesModel::interpretUrl (const QString &sipAddress) { +QString SipAddressesModel::interpretSipAddress (const QString &sipAddress) { shared_ptr lAddress = CoreManager::getInstance()->getCore()->interpretUrl( ::Utils::appStringToCoreString(sipAddress) ); - return lAddress ? ::Utils::coreStringToAppString(lAddress->asStringUriOnly()) : QString(""); + if (lAddress && !lAddress->getUsername().empty()) + return ::Utils::coreStringToAppString(lAddress->asStringUriOnly()); + return QString(""); } -QString SipAddressesModel::interpretUrl (const QUrl &sipAddress) { +QString SipAddressesModel::interpretSipAddress (const QUrl &sipAddress) { return sipAddress.toString(); } diff --git a/src/components/sip-addresses/SipAddressesModel.hpp b/src/components/sip-addresses/SipAddressesModel.hpp index 90111865e..9b3dccf8b 100644 --- a/src/components/sip-addresses/SipAddressesModel.hpp +++ b/src/components/sip-addresses/SipAddressesModel.hpp @@ -56,8 +56,8 @@ public: Q_INVOKABLE QString getTransportFromSipAddress (const QString &sipAddress) const; Q_INVOKABLE QString addTransportToSipAddress (const QString &sipAddress, const QString &transport) const; - Q_INVOKABLE static QString interpretUrl (const QString &sipAddress); - Q_INVOKABLE static QString interpretUrl (const QUrl &sipAddress); + Q_INVOKABLE static QString interpretSipAddress (const QString &sipAddress); + Q_INVOKABLE static QString interpretSipAddress (const QUrl &sipAddress); Q_INVOKABLE static bool addressIsValid (const QString &address); Q_INVOKABLE static bool sipAddressIsValid (const QString &sipAddress); diff --git a/src/components/url-handlers/UrlHandlers.cpp b/src/components/url-handlers/UrlHandlers.cpp index 4e5de6857..24505e522 100644 --- a/src/components/url-handlers/UrlHandlers.cpp +++ b/src/components/url-handlers/UrlHandlers.cpp @@ -33,5 +33,5 @@ UrlHandlers::UrlHandlers (QObject *parent) : QObject(parent) { } void UrlHandlers::handleSip (const QUrl &url) { - emit sip(SipAddressesModel::interpretUrl(url)); + emit sip(SipAddressesModel::interpretSipAddress(url)); } diff --git a/ui/modules/Linphone/View/SipAddressesView.qml b/ui/modules/Linphone/View/SipAddressesView.qml index 17662409a..6cfeab866 100644 --- a/ui/modules/Linphone/View/SipAddressesView.qml +++ b/ui/modules/Linphone/View/SipAddressesView.qml @@ -25,7 +25,7 @@ ScrollableListView { property string headerButtonIcon property var headerButtonAction - readonly property string interpretableSipAddress: SipAddressesModel.interpretUrl( + readonly property string interpretableSipAddress: SipAddressesModel.interpretSipAddress( genSipAddress )