Commit 6871cd18 authored by chriadam's avatar chriadam

[buteo-sync-plugin-carddav] Allow addressbook path as home set url. Contributes to JB#38586

In some cases, the endpoint which some providers (e.g. Kerio) provide
to users will not be an addressbook path but instead a home-set-url.
This commit ensures that if addressbook discovery fails at the given
path, that we try to treat the path as a home-set-url, which then
allows discovery of the addressbook paths.

It also ensures that we compare the ctag or sync-token for a given
addressbook path correctly with the one stored from the previous sync.

Contributes to MER#1751 and JB#38586
parent cdc2423b
......@@ -387,6 +387,7 @@ CardDav::CardDav(Syncer *parent,
, m_addressbookPath(addressbookPath)
, m_discoveryStage(CardDav::DiscoveryStarted)
, m_addressbooksListOnly(false)
, m_triedAddressbookPathAsHomeSetUrl(false)
, m_downsyncRequests(0)
, m_upsyncRequests(0)
{
......@@ -666,9 +667,17 @@ void CardDav::addressbooksInformationResponse()
QList<ReplyParser::AddressBookInformation> infos = m_parser->parseAddressbookInformation(data, addressbooksHomePath);
if (infos.isEmpty()) {
LOG_WARNING(Q_FUNC_INFO << "unable to parse addressbook info from response");
emit error();
return;
if (!m_addressbookPath.isEmpty() && !m_triedAddressbookPathAsHomeSetUrl) {
// the user provided an addressbook path during account creation, which didn't work.
// it may not be an addressbook path but instead the home set url; try that.
LOG_DEBUG(Q_FUNC_INFO << "Given path is not addressbook path; trying as home set url");
m_triedAddressbookPathAsHomeSetUrl = true;
fetchAddressbookUrls(m_addressbookPath);
} else {
LOG_WARNING(Q_FUNC_INFO << "unable to parse addressbook info from response");
emit error();
return;
}
}
if (m_addressbooksListOnly) {
......@@ -702,7 +711,7 @@ void CardDav::downsyncAddressbookContent(const QList<ReplyParser::AddressBookInf
fetchContactMetadata(infos[i].url);
} else if (infos[i].syncToken.isEmpty()) {
// we cannot use sync-token for this addressbook, but instead ctag.
const QString &existingCtag(q->m_addressbookCtags[infos[i].url]); // from OOB
const QString existingCtag(q->m_addressbookCtags[infos[i].url]); // from OOB
if (existingCtag.isEmpty()) {
// first time sync
q->m_addressbookCtags[infos[i].url] = infos[i].ctag; // insert
......@@ -722,7 +731,7 @@ void CardDav::downsyncAddressbookContent(const QList<ReplyParser::AddressBookInf
}
} else {
// the server supports webdav-sync for this addressbook.
const QString &existingSyncToken(q->m_addressbookSyncTokens[infos[i].url]); // from OOB
const QString existingSyncToken(q->m_addressbookSyncTokens[infos[i].url]); // from OOB
// store the ctag anyway just in case the server has
// forgotten the syncToken we cached from last time.
if (!infos[i].ctag.isEmpty()) {
......
......@@ -114,6 +114,7 @@ private:
QString m_addressbookPath;
DiscoveryStage m_discoveryStage;
bool m_addressbooksListOnly;
bool m_triedAddressbookPathAsHomeSetUrl;
QList<QContact> m_remoteAdditions;
QList<QContact> m_remoteModifications;
......
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