From d4ba5071da8076914b99e6a3cc32c9042b3730bc Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 28 Mar 2017 16:40:26 +0200 Subject: Cleanup --- common/domain/applicationdomaintype.h | 4 ---- common/storage.h | 6 +++--- common/store.cpp | 2 +- common/synchronizer.cpp | 5 +++++ common/synchronizer.h | 5 +++++ examples/imapresource/imapresource.cpp | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index aa6a192..d84bda4 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -321,8 +321,6 @@ struct SINK_EXPORT SinkAccount : public ApplicationDomainType { SINK_PROPERTY(QString, Icon, icon); SINK_PROPERTY(QString, AccountType, type); SINK_STATUS_PROPERTY(int, Status, status); - SINK_STATUS_PROPERTY(ApplicationDomain::Error, Error, error); - SINK_STATUS_PROPERTY(ApplicationDomain::Progress, Progress, progress); }; @@ -344,8 +342,6 @@ struct SINK_EXPORT SinkResource : public ApplicationDomainType { SINK_PROPERTY(QByteArray, ResourceType, type); SINK_PROPERTY(QByteArrayList, Capabilities, capabilities); SINK_STATUS_PROPERTY(int, Status, status); - SINK_STATUS_PROPERTY(ApplicationDomain::Error, Error, error); - SINK_STATUS_PROPERTY(ApplicationDomain::Progress, Progress, progress); }; struct SINK_EXPORT Entity : public ApplicationDomainType { diff --git a/common/storage.h b/common/storage.h index fd349f3..589c738 100644 --- a/common/storage.h +++ b/common/storage.h @@ -128,14 +128,14 @@ public: public: Transaction(); ~Transaction(); - bool commit(const std::function &errorHandler = std::function()); + bool commit(const std::function &errorHandler = {}); void abort(); QList getDatabaseNames() const; bool validateNamedDatabases(); - NamedDatabase openDatabase(const QByteArray &name = QByteArray("default"), - const std::function &errorHandler = std::function(), bool allowDuplicates = false) const; + NamedDatabase openDatabase(const QByteArray &name = {"default"}, + const std::function &errorHandler = {}, bool allowDuplicates = false) const; Transaction(Transaction &&other); Transaction &operator=(Transaction &&other); diff --git a/common/store.cpp b/common/store.cpp index 8c0a985..d266098 100644 --- a/common/store.cpp +++ b/common/store.cpp @@ -251,7 +251,7 @@ KAsync::Job Store::remove(const Sink::Query &query) KAsync::Job Store::removeDataFromDisk(const QByteArray &identifier) { // All databases are going to become invalid, nuke the environments - // TODO: all clients should react to a notification the resource + // TODO: all clients should react to a notification from the resource Sink::Storage::DataStore::clearEnv(); SinkTrace() << "Remove data from disk " << identifier; auto time = QSharedPointer::create(); diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index d3de20b..e004d64 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp @@ -303,6 +303,11 @@ void Synchronizer::emitNotification(Notification::NoticationType type, int code, emit notify(n); } +void Synchronizer::reportProgress(int progress, int total) +{ + SinkLogCtx(mLogCtx) << "Progress: " << progress << " out of " << total; +} + KAsync::Job Synchronizer::processRequest(const SyncRequest &request) { if (request.options & SyncRequest::RequestFlush) { diff --git a/common/synchronizer.h b/common/synchronizer.h index 751542d..32e93c4 100644 --- a/common/synchronizer.h +++ b/common/synchronizer.h @@ -184,6 +184,11 @@ protected: void emitNotification(Notification::NoticationType type, int code, const QString &message, const QByteArray &id = QByteArray{}, const QByteArrayList &entiteis = QByteArrayList{}); + /** + * Report progress for current task + */ + void reportProgress(int progress, int total); + protected: Sink::Log::Context mLogCtx; diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 175f75a..e74a8f1 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp @@ -542,7 +542,7 @@ public: synchronizeMails(folderRemoteId, m); }, [=](int progress, int total) { - SinkLogCtx(mLogCtx) << "Progress: " << progress << " out of " << total; + reportProgress(progress, total); //commit every 100 messages if ((progress % 100) == 0) { commit(); -- cgit v1.2.3