Commit 6204fbfc authored by Grgory Oestreicher's avatar Grgory Oestreicher
Browse files

CCBUG: 252082

Implement section 5.3.4 of RFC4791 and do not assume that ETag is always
present in responses. This may be the cause of issues with Google Calendar.


svn path=/trunk/KDE/kdepim/runtime/; revision=1190772
parent 1b2a55f5
......@@ -548,6 +548,16 @@ void DavGroupwareResource::onMultigetFinished( KJob *job )
}
void DavGroupwareResource::onRetrieveItemFinished( KJob *job )
{
onItemFetched( job, false );
}
void DavGroupwareResource::onItemRefreshed( KJob* job )
{
onItemFetched( job, true );
}
void DavGroupwareResource::onItemFetched( KJob* job, bool isRefresh )
{
if ( job->error() ) {
cancelTask( i18n( "Unable to retrieve item: %1", job->errorText() ) );
......@@ -592,7 +602,10 @@ void DavGroupwareResource::onRetrieveItemFinished( KJob *job )
item.setRemoteRevision( davItem.etag() );
mEtagCache.setEtag( item.remoteId(), davItem.etag() );
itemRetrieved( item );
if ( isRefresh )
changeCommitted( item );
else
itemRetrieved( item );
}
void DavGroupwareResource::onItemAddedFinished( KJob *job )
......@@ -608,10 +621,18 @@ void DavGroupwareResource::onItemAddedFinished( KJob *job )
Akonadi::Item item = createJob->property( "item" ).value<Akonadi::Item>();
item.setRemoteId( davItem.url() );
item.setRemoteRevision( davItem.etag() );
mEtagCache.setEtag( davItem.url(), davItem.etag() );
changeCommitted( item );
if ( davItem.etag().isEmpty() ) {
const DavUtils::DavUrl davUrl = Settings::self()->davUrlFromCollectionUrl( item.parentCollection().remoteId(), item.remoteId() );
DavItemFetchJob *fetchJob = new DavItemFetchJob( davUrl, davItem );
fetchJob->setProperty( "item", QVariant::fromValue( item ) );
connect( fetchJob, SIGNAL( result( KJob* ) ), SLOT( onItemRefreshed( KJob* ) ) );
fetchJob->start();
} else {
item.setRemoteRevision( davItem.etag() );
mEtagCache.setEtag( davItem.url(), davItem.etag() );
changeCommitted( item );
}
}
void DavGroupwareResource::onItemChangedFinished( KJob *job )
......@@ -626,10 +647,18 @@ void DavGroupwareResource::onItemChangedFinished( KJob *job )
const DavItem davItem = modifyJob->item();
Akonadi::Item item = modifyJob->property( "item" ).value<Akonadi::Item>();
item.setRemoteRevision( davItem.etag() );
mEtagCache.setEtag( item.remoteId(), davItem.etag() );
changeCommitted( item );
if ( davItem.etag().isEmpty() ) {
const DavUtils::DavUrl davUrl = Settings::self()->davUrlFromCollectionUrl( item.parentCollection().remoteId(), item.remoteId() );
DavItemFetchJob *fetchJob = new DavItemFetchJob( davUrl, davItem );
fetchJob->setProperty( "item", QVariant::fromValue( item ) );
connect( fetchJob, SIGNAL( result( KJob* ) ), SLOT( onItemRefreshed( KJob* ) ) );
fetchJob->start();
} else {
item.setRemoteRevision( davItem.etag() );
mEtagCache.setEtag( davItem.url(), davItem.etag() );
changeCommitted( item );
}
}
void DavGroupwareResource::onItemRemovedFinished( KJob *job )
......
......@@ -54,6 +54,15 @@ class DavGroupwareResource : public Akonadi::ResourceBase,
void onRetrieveItemsFinished( KJob* );
void onMultigetFinished( KJob* );
void onRetrieveItemFinished( KJob* );
/**
* Called when a new item has been fetched from the backend.
*
* @param job The job that fetched the item
* @param updatedItem Set to true if the item fetch has been requested
* by a refresh.
*/
void onItemFetched( KJob* job, bool isRefresh = false );
void onItemRefreshed( KJob* job );
void onItemAddedFinished( KJob* );
void onItemChangedFinished( KJob* );
......
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