Commit 53a8b2f4 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/MainWindow/ContactEdit): name must be given & interpretUrl is used

parent b13763e2
linphone @ 7650064a
Subproject commit e816a335cd1693cdbbde27a69143e1570058ed5f
Subproject commit 7650064a1cb5b914b157c788e4ff8fa22d971f78
......@@ -159,18 +159,35 @@ bool VcardModel::setAddress (const QVariantMap &address) {
}
QVariantList VcardModel::getSipAddresses () const {
shared_ptr<linphone::Core> 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<linphone::Address> 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<linphone::Address> 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::BelCard> belcard = m_vcard->getBelcard();
shared_ptr<belcard::BelCardImpp> value = belcard::BelCardGeneric::create<belcard::BelCardImpp>();
value->setValue(::Utils::qStringToLinphoneString(sip_address));
value->setValue(l_address->asStringUriOnly());
qInfo() << QStringLiteral("Add new sip address: `%1`.").arg(sip_address);
......
......@@ -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()
}
......
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