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