From 53a8b2f4722003e0cb4b410ad6c2a11f070ef148 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 15 Dec 2016 17:12:39 +0100 Subject: [PATCH] feat(ui/views/App/MainWindow/ContactEdit): name must be given & interpretUrl is used --- submodules/linphone | 2 +- tests/src/components/contact/VcardModel.cpp | 23 ++++++++++++++++--- tests/ui/views/App/MainWindow/ContactEdit.qml | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/submodules/linphone b/submodules/linphone index e816a335c..7650064a1 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit e816a335cd1693cdbbde27a69143e1570058ed5f +Subproject commit 7650064a1cb5b914b157c788e4ff8fa22d971f78 diff --git a/tests/src/components/contact/VcardModel.cpp b/tests/src/components/contact/VcardModel.cpp index a082fdc31..c28c1c7b7 100644 --- a/tests/src/components/contact/VcardModel.cpp +++ b/tests/src/components/contact/VcardModel.cpp @@ -159,18 +159,35 @@ bool VcardModel::setAddress (const QVariantMap &address) { } QVariantList VcardModel::getSipAddresses () const { + shared_ptr core = CoreManager::getInstance()->getCore(); QVariantList list; - for (const auto &address : m_vcard->getBelcard()->getImpp()) - list.append(::Utils::linphoneStringToQString(address->getValue())); + for (const auto &address : m_vcard->getBelcard()->getImpp()) { + string value = address->getValue(); + shared_ptr l_address = core->createAddress(value); + + if (l_address) + list.append(::Utils::linphoneStringToQString(l_address->asStringUriOnly())); + } return list; } bool VcardModel::addSipAddress (const QString &sip_address) { + // Check sip address format. + shared_ptr l_address = CoreManager::getInstance()->getCore()->interpretUrl( + ::Utils::qStringToLinphoneString(sip_address) + ); + + if (!l_address) { + qWarning() << QStringLiteral("Unable to add invalid sip address: `%1`.").arg(sip_address); + return false; + } + + // Add sip address in belcard. shared_ptr belcard = m_vcard->getBelcard(); shared_ptr value = belcard::BelCardGeneric::create(); - value->setValue(::Utils::qStringToLinphoneString(sip_address)); + value->setValue(l_address->asStringUriOnly()); qInfo() << QStringLiteral("Add new sip address: `%1`.").arg(sip_address); diff --git a/tests/ui/views/App/MainWindow/ContactEdit.qml b/tests/ui/views/App/MainWindow/ContactEdit.qml index 87c8e1c8c..8dcc9ac4d 100644 --- a/tests/ui/views/App/MainWindow/ContactEdit.qml +++ b/tests/ui/views/App/MainWindow/ContactEdit.qml @@ -340,7 +340,7 @@ ColumnLayout { visible: _edition TextButtonB { - enabled: _vcard.sipAddresses.length > 0 + enabled: usernameInput.text.length > 0 && _vcard.sipAddresses.length > 0 text: qsTr('save') onClicked: _save() }