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/IAuthenticationManager.h>
23 #include <quentier/types/Account.h>
24 #include <quentier/types/ErrorString.h>
25 #include <quentier/types/LinkedNotebook.h>
26 #include <quentier/utility/Linkage.h>
27 #include <quentier/utility/Macros.h>
28 
29 #include <QObject>
30 
31 namespace quentier {
32 
33 QT_FORWARD_DECLARE_CLASS(IKeychainService)
34 QT_FORWARD_DECLARE_CLASS(INoteStore)
35 QT_FORWARD_DECLARE_CLASS(IUserStore)
36 QT_FORWARD_DECLARE_CLASS(LocalStorageManagerAsync)
37 QT_FORWARD_DECLARE_CLASS(SynchronizationManagerDependencyInjector)
38 QT_FORWARD_DECLARE_CLASS(SynchronizationManagerPrivate)
39 
40 
46 class QUENTIER_EXPORT SynchronizationManager: public QObject
47 {
48  Q_OBJECT
49 public:
67  const QString & host,
68  LocalStorageManagerAsync & localStorageManagerAsync,
69  IAuthenticationManager & authenticationManager,
70  SynchronizationManagerDependencyInjector * pInjector = nullptr);
71 
72  virtual ~SynchronizationManager();
73 
78  bool active() const;
79 
86  bool downloadNoteThumbnailsOption() const;
87 
88 public Q_SLOTS:
103  void setAccount(Account account);
104 
113  void authenticate();
114 
126  void authenticateCurrentAccount();
127 
131  void synchronize();
132 
137  void stop();
138 
145  void revokeAuthentication(const qevercloud::UserID userId);
146 
158  void setDownloadNoteThumbnails(bool flag);
159 
168  void setDownloadInkNoteImages(bool flag);
169 
187  void setInkNoteImagesStoragePath(QString path);
188 
189 Q_SIGNALS:
195  void started();
196 
202  void stopped();
203 
210  void failed(ErrorString errorDescription);
211 
232  void finished(
233  Account account, bool somethingDownloaded, bool somethingSent);
234 
246  void authenticationRevoked(
247  bool success, ErrorString errorDescription, qevercloud::UserID userId);
248 
262  void authenticationFinished(
263  bool success, ErrorString errorDescription, Account account);
264 
269  void remoteToLocalSyncStopped();
270 
275  void sendLocalChangesStopped();
276 
287  void willRepeatRemoteToLocalSyncAfterSendingChanges();
288 
300  void detectedConflictDuringLocalChangesSending();
301 
311  void rateLimitExceeded(qint32 secondsToWait);
312 
326  void remoteToLocalSyncDone(bool somethingDownloaded);
327 
343  void syncChunksDownloadProgress(
344  qint32 highestDownloadedUsn, qint32 highestServerUsn,
345  qint32 lastPreviousUsn);
346 
351  void syncChunksDownloaded();
352 
376  void linkedNotebookSyncChunksDownloadProgress(
377  qint32 highestDownloadedUsn, qint32 highestServerUsn,
378  qint32 lastPreviousUsn, LinkedNotebook linkedNotebook);
379 
384  void linkedNotebooksSyncChunksDownloaded();
385 
394  void notesDownloadProgress(
395  quint32 notesDownloaded, quint32 totalNotesToDownload);
396 
405  void linkedNotebooksNotesDownloadProgress(
406  quint32 notesDownloaded, quint32 totalNotesToDownload);
407 
418  void resourcesDownloadProgress(
419  quint32 resourcesDownloaded, quint32 totalResourcesToDownload);
420 
431  void linkedNotebooksResourcesDownloadProgress(
432  quint32 resourcesDownloaded, quint32 totalResourcesToDownload);
433 
439  void preparedDirtyObjectsForSending();
440 
446  void preparedLinkedNotebooksDirtyObjectsForSending();
447 
453  void setAccountDone(Account account);
454 
459  void setDownloadNoteThumbnailsDone(bool flag);
460 
465  void setDownloadInkNoteImagesDone(bool flag);
466 
471  void setInkNoteImagesStoragePathDone(QString path);
472 
473 private:
474  SynchronizationManager() = delete;
475  Q_DISABLE_COPY(SynchronizationManager)
476 
477  SynchronizationManagerPrivate * d_ptr;
478  Q_DECLARE_PRIVATE(SynchronizationManager)
479 };
480 
481 } // namespace quentier
482 
483 #endif // LIB_QUENTIER_SYNCHRONIZATION_SYNCHRONIZATION_MANAGER_H
Definition: SynchronizationManagerDependencyInjector.h:30
Definition: LinkedNotebook.h:32
The SynchronizationManager class encapsulates methods and signals & slots required to perform the ful...
Definition: SynchronizationManager.h:46
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:43
Definition: LocalStorageManagerAsync.h:44
Definition: DecryptedTextManager.h:26
The Account class encapsulates some details about the account: its name, whether it is local or synch...
Definition: Account.h:39
Definition: IAuthenticationManager.h:36