Commit 001f1fb0 authored by Shashwat Jolly's avatar Shashwat Jolly
Browse files

Add journal cache updation timestamp

parent d1a6a649
...@@ -113,10 +113,6 @@ void EteSyncResource::configure(WId windowId) ...@@ -113,10 +113,6 @@ void EteSyncResource::configure(WId windowId)
void EteSyncResource::retrieveCollections() void EteSyncResource::retrieveCollections()
{ {
if (!mSyncing) {
mCollectionsToSync = 0;
}
mSyncing = true;
setCollectionStreamingEnabled(true); setCollectionStreamingEnabled(true);
// Set up root collection for resource // Set up root collection for resource
mResourceCollection = Collection(); mResourceCollection = Collection();
...@@ -159,7 +155,6 @@ void EteSyncResource::slotCollectionsRetrieved(KJob *job) ...@@ -159,7 +155,6 @@ void EteSyncResource::slotCollectionsRetrieved(KJob *job)
Collection collection; Collection collection;
collection.setParentCollection(mResourceCollection); collection.setParentCollection(mResourceCollection);
setupCollection(collection, *iter); setupCollection(collection, *iter);
mCollectionsToSync++;
list << collection; list << collection;
} }
free(journals); free(journals);
...@@ -217,7 +212,8 @@ void EteSyncResource::setupCollection(Collection &collection, EteSyncJournal *jo ...@@ -217,7 +212,8 @@ void EteSyncResource::setupCollection(Collection &collection, EteSyncJournal *jo
collection.setName(displayName); collection.setName(displayName);
collection.setContentMimeTypes(mimeTypes); collection.setContentMimeTypes(mimeTypes);
mJournals[journalUid] = EteSyncJournalPtr(journal); mJournalsCache[journalUid] = EteSyncJournalPtr(journal);
mJournalsCacheUpdateTime = QDateTime::currentDateTime();
} }
BaseHandler *EteSyncResource::fetchHandlerForMimeType(const QString &mimeType) BaseHandler *EteSyncResource::fetchHandlerForMimeType(const QString &mimeType)
...@@ -250,11 +246,8 @@ BaseHandler *EteSyncResource::fetchHandlerForCollection(const Akonadi::Collectio ...@@ -250,11 +246,8 @@ BaseHandler *EteSyncResource::fetchHandlerForCollection(const Akonadi::Collectio
void EteSyncResource::retrieveItems(const Akonadi::Collection &collection) void EteSyncResource::retrieveItems(const Akonadi::Collection &collection)
{ {
if (mSyncing) { int timeSinceLastCacheUpdate = mJournalsCacheUpdateTime.secsTo(QDateTime::currentDateTime());
mCollectionsToSync--; if (timeSinceLastCacheUpdate <= 30) {
if (mCollectionsToSync == 0) {
mSyncing = false;
}
QString journalUid = collection.remoteId(); QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = getJournal(journalUid); const EteSyncJournalPtr &journal = getJournal(journalUid);
QString lastEntryUid = QStringFromCharPtr(CharPtr(etesync_journal_get_last_uid(journal.get()))); QString lastEntryUid = QStringFromCharPtr(CharPtr(etesync_journal_get_last_uid(journal.get())));
......
...@@ -78,7 +78,7 @@ protected: ...@@ -78,7 +78,7 @@ protected:
const EteSyncJournalPtr &getJournal(QString journalUid) const EteSyncJournalPtr &getJournal(QString journalUid)
{ {
return mJournals[journalUid]; return mJournalsCache[journalUid];
} }
private Q_SLOTS: private Q_SLOTS:
...@@ -91,9 +91,8 @@ private: ...@@ -91,9 +91,8 @@ private:
Akonadi::Collection mResourceCollection; Akonadi::Collection mResourceCollection;
EteSyncClientState *mClientState = nullptr; EteSyncClientState *mClientState = nullptr;
std::vector<BaseHandler::Ptr> mHandlers; std::vector<BaseHandler::Ptr> mHandlers;
std::map<QString, EteSyncJournalPtr> mJournals; std::map<QString, EteSyncJournalPtr> mJournalsCache;
int mCollectionsToSync = 0; QDateTime mJournalsCacheUpdateTime;
bool mSyncing;
ContactHandler::Ptr mContactHandler = nullptr; ContactHandler::Ptr mContactHandler = nullptr;
CalendarHandler::Ptr mCalendarHandler = nullptr; CalendarHandler::Ptr mCalendarHandler = nullptr;
......
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