libquentier  0.5.0
The library for rich desktop clients of Evernote service
SynchronizationManager.h
1 /*
2  * Copyright 2016-2020 Dmitry Ivanov
3  *
4  * This file is part of libquentier
5  *
6  * libquentier is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * libquentier is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libquentier. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef LIB_QUENTIER_SYNCHRONIZATION_SYNCHRONIZATION_MANAGER_H
20 #define LIB_QUENTIER_SYNCHRONIZATION_SYNCHRONIZATION_MANAGER_H
21 
22 #include <quentier/synchronization/ForwardDeclarations.h>
23 #include <quentier/types/Account.h>
24 #include <quentier/types/ErrorString.h>
25 #include <quentier/types/LinkedNotebook.h>
26 #include <quentier/utility/ForwardDeclarations.h>
27 #include <quentier/utility/Linkage.h>
28 
29 #include <QObject>
30 
31 namespace quentier {
32 
33 QT_FORWARD_DECLARE_CLASS(LocalStorageManagerAsync)
34 QT_FORWARD_DECLARE_CLASS(SynchronizationManagerPrivate)
35 
36 
42 class QUENTIER_EXPORT SynchronizationManager : public QObject
43 {
44  Q_OBJECT
45 public:
82  QString host, LocalStorageManagerAsync & localStorageManagerAsync,
83  IAuthenticationManager & authenticationManager,
84  QObject * parent = nullptr, INoteStorePtr pNoteStore = {},
85  IUserStorePtr pUserStore = {},
86  IKeychainServicePtr pKeychainService = {},
87  ISyncStateStoragePtr pSyncStateStorage = {});
88 
89  virtual ~SynchronizationManager();
90 
95  bool active() const;
96 
103  bool downloadNoteThumbnailsOption() const;
104 
105 public Q_SLOTS:
120  void setAccount(Account account);
121 
130  void authenticate();
131 
143  void authenticateCurrentAccount();
144 
148  void synchronize();
149 
154  void stop();
155 
162  void revokeAuthentication(const qevercloud::UserID userId);
163 
175  void setDownloadNoteThumbnails(bool flag);
176 
185  void setDownloadInkNoteImages(bool flag);
186 
204  void setInkNoteImagesStoragePath(QString path);
205 
206 Q_SIGNALS:
212  void started();
213 
219  void stopped();
220 
227  void failed(ErrorString errorDescription);
228 
249  void finished(
250  Account account, bool somethingDownloaded, bool somethingSent);
251 
263  void authenticationRevoked(
264  bool success, ErrorString errorDescription, qevercloud::UserID userId);
265 
279  void authenticationFinished(
280  bool success, ErrorString errorDescription, Account account);
281 
286  void remoteToLocalSyncStopped();
287 
292  void sendLocalChangesStopped();
293 
304  void willRepeatRemoteToLocalSyncAfterSendingChanges();
305 
317  void detectedConflictDuringLocalChangesSending();
318 
328  void rateLimitExceeded(qint32 secondsToWait);
329 
343  void remoteToLocalSyncDone(bool somethingDownloaded);
344 
360  void syncChunksDownloadProgress(
361  qint32 highestDownloadedUsn, qint32 highestServerUsn,
362  qint32 lastPreviousUsn);
363 
368  void syncChunksDownloaded();
369 
393  void linkedNotebookSyncChunksDownloadProgress(
394  qint32 highestDownloadedUsn, qint32 highestServerUsn,
395  qint32 lastPreviousUsn, LinkedNotebook linkedNotebook);
396 
401  void linkedNotebooksSyncChunksDownloaded();
402 
411  void notesDownloadProgress(
412  quint32 notesDownloaded, quint32 totalNotesToDownload);
413 
422  void linkedNotebooksNotesDownloadProgress(
423  quint32 notesDownloaded, quint32 totalNotesToDownload);
424 
435  void resourcesDownloadProgress(
436  quint32 resourcesDownloaded, quint32 totalResourcesToDownload);
437 
448  void linkedNotebooksResourcesDownloadProgress(
449  quint32 resourcesDownloaded, quint32 totalResourcesToDownload);
450 
456  void preparedDirtyObjectsForSending();
457 
463  void preparedLinkedNotebooksDirtyObjectsForSending();
464 
470  void setAccountDone(Account account);
471 
476  void setDownloadNoteThumbnailsDone(bool flag);
477 
482  void setDownloadInkNoteImagesDone(bool flag);
483 
488  void setInkNoteImagesStoragePathDone(QString path);
489 
490 private:
491  SynchronizationManager() = delete;
492  Q_DISABLE_COPY(SynchronizationManager)
493 
494  SynchronizationManagerPrivate * d_ptr;
495  Q_DECLARE_PRIVATE(SynchronizationManager)
496 };
497 
498 } // namespace quentier
499 
500 #endif // LIB_QUENTIER_SYNCHRONIZATION_SYNCHRONIZATION_MANAGER_H
Definition: LinkedNotebook.h:32
The SynchronizationManager class encapsulates methods and signals & slots required to perform the ful...
Definition: SynchronizationManager.h:42
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:43
Definition: LocalStorageManagerAsync.h:43
Definition: DecryptedTextManager.h:26
The Account class encapsulates some details about the account: its name, whether it is local or synch...
Definition: Account.h:38
Definition: IAuthenticationManager.h:36