~ubuntu-branches/ubuntu/raring/kdepim-runtime/raring-proposed

« back to all changes in this revision

Viewing changes to resources/dav/resource/davgroupwareresource.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2013-06-20 04:29:34 UTC
  • mfrom: (0.4.43)
  • Revision ID: package-import@ubuntu.com-20130620042934-nip7je5a27wideg2
Tags: 4:4.10.4-0ubuntu0.1
New upstream bugfix release (LP: #1187574)

Show diffs side-by-side

added added

removed removed

Lines of Context:
257
257
  // work around the fact that Akonadi will rightfully try to retrieve items
258
258
  // from it. So just return an empty list
259
259
  if ( collection.remoteId() == identifier() ) {
260
 
    itemsRetrieved( Akonadi::Item::List() );
 
260
    itemsRetrievalDone();
261
261
    return;
262
262
  }
263
263
 
293
293
    return false;
294
294
  }
295
295
 
296
 
  const DavProtocolBase *protocol = DavManager::self()->davProtocol( davUrl.protocol() );
297
 
  if ( !protocol ) {
298
 
    cancelTask();
299
 
    return false;
300
 
  }
301
 
 
302
 
  if ( protocol->useMultiget() ) {
303
 
    // Item is already in the cache as it's been fetched with multiget
304
 
    itemRetrieved( item );
305
 
    return true;
306
 
  }
307
 
 
308
296
  DavItem davItem;
309
297
  davItem.setUrl( item.remoteId() );
310
298
  davItem.setContentType( "text/calendar" );
557
545
 
558
546
  const DavItemsListJob *listJob = qobject_cast<DavItemsListJob*>( job );
559
547
 
560
 
  Akonadi::Item::List items;
 
548
  Akonadi::Item::List changedItems;
 
549
  Akonadi::Item::List removedItems;
561
550
  QSet<QString> seenRids;
562
551
  QStringList changedRids;
563
552
 
566
555
    seenRids.insert( davItem.url() );
567
556
 
568
557
    Akonadi::Item item;
 
558
    item.setParentCollection( collection );
569
559
    item.setRemoteId( davItem.url() );
570
560
    item.setMimeType( davItem.contentType() );
 
561
    item.setRemoteRevision( davItem.etag() );
571
562
 
572
563
    if ( mEtagCache.etagChanged( item.remoteId(), davItem.etag() ) ) {
573
564
      mEtagCache.markAsChanged( item.remoteId() );
574
565
      changedRids << item.remoteId();
 
566
      changedItems << item;
575
567
 
576
568
      // Only clear the payload (and therefor trigger a refetch from the backend) if we
577
569
      // do not use multiget, because in this case we fetch the complete payload
581
573
        item.clearPayload();
582
574
      }
583
575
    }
584
 
 
585
 
    item.setRemoteRevision( davItem.etag() );
586
 
 
587
 
    items << item;
588
576
  }
589
577
 
590
578
  QSet<QString> removedRids = mItemsRidCache[collection.remoteId()];
591
579
  mItemsRidCache[collection.remoteId()] = seenRids;
592
580
  removedRids.subtract( seenRids );
593
 
  foreach ( const QString &rmd, removedRids )
 
581
  foreach ( const QString &rmd, removedRids ) {
 
582
    Akonadi::Item item;
 
583
    item.setRemoteId( rmd );
 
584
    removedItems << item;
594
585
    mEtagCache.removeEtag( rmd );
 
586
  }
595
587
 
596
588
  // If the protocol supports multiget then deviate from the expected behavior
597
589
  // and fetch all items with payload now instead of waiting for Akonadi to
601
593
  if ( protocolSupportsMultiget && !changedRids.isEmpty() ) {
602
594
    DavItemsFetchJob *fetchJob = new DavItemsFetchJob( davUrl, changedRids );
603
595
    connect( fetchJob, SIGNAL(result(KJob*)), this, SLOT(onMultigetFinished(KJob*)) );
604
 
    fetchJob->setProperty( "items", QVariant::fromValue( items ) );
 
596
    fetchJob->setProperty( "items", QVariant::fromValue( changedItems ) );
 
597
    fetchJob->setProperty( "removedItems", QVariant::fromValue( removedItems ) );
605
598
    fetchJob->start();
606
 
 
607
599
    // delay the call of itemsRetrieved() to onMultigetFinished()
608
600
  } else {
609
 
    itemsRetrieved( items );
 
601
    itemsRetrievedIncremental( changedItems, removedItems );
610
602
  }
611
603
}
612
604
 
624
616
  }
625
617
 
626
618
  const Akonadi::Item::List origItems = job->property( "items" ).value<Akonadi::Item::List>();
 
619
  const Akonadi::Item::List removedItems = job->property( "removedItems" ).value<Akonadi::Item::List>();
627
620
  const DavItemsFetchJob *davJob = qobject_cast<DavItemsFetchJob*>( job );
628
621
 
629
622
  Akonadi::Item::List items;
669
662
    items << item;
670
663
  }
671
664
 
672
 
  itemsRetrieved( items );
 
665
  itemsRetrievedIncremental( items, removedItems );
673
666
}
674
667
 
675
668
void DavGroupwareResource::onRetrieveItemFinished( KJob *job )