Fix CardDAV authentication and allow multiple accounts

CardDAV fixes:
- Extract domain from URI for auth info lookup
- Auto-populate realm from host if empty
- Add domain parameter to createAuthInfo for proper auth matching
- Update liblinphone submodule with setAuthInfo fix

UI improvements:
- Allow multiple CardDAV accounts (removed count==0 restriction)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Eduard Wisch 2026-02-08 06:14:37 +01:00
parent fdee074dc9
commit b19d96f82c
3 changed files with 23 additions and 5 deletions

View file

@ -22,6 +22,7 @@
#include "model/core/CoreModel.hpp" #include "model/core/CoreModel.hpp"
#include "model/setting/SettingsModel.hpp" #include "model/setting/SettingsModel.hpp"
#include "tool/Utils.hpp" #include "tool/Utils.hpp"
#include <QUrl>
DEFINE_ABSTRACT_OBJECT(CarddavModel) DEFINE_ABSTRACT_OBJECT(CarddavModel)
@ -59,16 +60,32 @@ void CarddavModel::save(
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
auto core = CoreModel::getInstance()->getCore(); auto core = CoreModel::getInstance()->getCore();
// Extract domain from URI for auth info lookup
string domain;
QUrl url(QString::fromStdString(uri));
if (url.isValid()) {
domain = url.host().toStdString();
}
// If realm is empty, use domain as default realm
if (realm.empty() && !domain.empty()) {
realm = domain;
lInfo() << log().arg("Using host as default realm:") << realm;
}
lInfo() << log().arg("CardDAV save called with:") << " displayName=" << displayName << " uri=" << uri
<< " username=" << username << " realm=" << realm << " domain=" << domain << " (password hidden)";
// Auth info handled in lazy mode, if provided handle otherwise ignore. // Auth info handled in lazy mode, if provided handle otherwise ignore.
// TODO: add dialog to ask user before removing existing auth info if existing already - (comment from Android) // TODO: add dialog to ask user before removing existing auth info if existing already - (comment from Android)
if (!username.empty() && !realm.empty()) { if (!username.empty() && !realm.empty()) {
mRemovedAuthInfo = core->findAuthInfo(realm, username, ""); mRemovedAuthInfo = core->findAuthInfo(realm, username, domain);
if (mRemovedAuthInfo != nullptr) { if (mRemovedAuthInfo != nullptr) {
lWarning() << log().arg("Auth info with username ") << username << " already exists, removing it first."; lWarning() << log().arg("Auth info with username ") << username << " already exists, removing it first.";
core->removeAuthInfo(mRemovedAuthInfo); core->removeAuthInfo(mRemovedAuthInfo);
} }
lInfo() << log().arg("Adding auth info with username") << username; lInfo() << log().arg("Adding auth info with username ") << username << " and domain " << domain;
mCreatedAuthInfo = linphone::Factory::get()->createAuthInfo(username, "", password, "", realm, ""); mCreatedAuthInfo = linphone::Factory::get()->createAuthInfo(username, "", password, "", realm, domain);
core->addAuthInfo(mCreatedAuthInfo); core->addAuthInfo(mCreatedAuthInfo);
} else { } else {
lInfo() << log().arg("No auth info provided upon saving."); lInfo() << log().arg("No auth info provided upon saving.");

View file

@ -79,7 +79,8 @@ AbstractSettingsLayout {
accessibleUseButtonText: qsTr("use_cardav_server_accessible_name") accessibleUseButtonText: qsTr("use_cardav_server_accessible_name")
proxyModel: CarddavProxy { proxyModel: CarddavProxy {
onModelReset: { onModelReset: {
carddavProvider.showAddButton = carddavProvider.proxyModel.count == 0 // Allow multiple CardDAV accounts
carddavProvider.showAddButton = true
carddavProvider.newItemGui = createGuiObject('Carddav') carddavProvider.newItemGui = createGuiObject('Carddav')
} }
} }

@ -1 +1 @@
Subproject commit 2e6e6b927ce202f6948da02ea33081a52b89bf48 Subproject commit 4193a9481e6d8530bec6f6af26efb59285a53e0e