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/synchronization/ISyncChunksDataCounters.h>
24 #include <quentier/types/Account.h>
25 #include <quentier/types/ErrorString.h>
26 #include <quentier/types/LinkedNotebook.h>
27 #include <quentier/utility/ForwardDeclarations.h>
28 #include <quentier/utility/Linkage.h>
29 
30 #include <QObject>
31 
32 namespace quentier {
33 
34 QT_FORWARD_DECLARE_CLASS(LocalStorageManagerAsync)
35 QT_FORWARD_DECLARE_CLASS(SynchronizationManagerPrivate)
36 
37 
43 class QUENTIER_EXPORT SynchronizationManager : public QObject
44 {
45  Q_OBJECT
46 public:
83  QString host, LocalStorageManagerAsync & localStorageManagerAsync,
84  IAuthenticationManager & authenticationManager,
85  QObject * parent = nullptr, INoteStorePtr pNoteStore = {},
86  IUserStorePtr pUserStore = {},
87  IKeychainServicePtr pKeychainService = {},
88  ISyncStateStoragePtr pSyncStateStorage = {});
89 
90  virtual ~SynchronizationManager();
91 
96  bool active() const;
97 
104  bool downloadNoteThumbnailsOption() const;
105 
106 public Q_SLOTS:
121  void setAccount(Account account);
122 
131  void authenticate();
132 
144  void authenticateCurrentAccount();
145 
149  void synchronize();
150 
155  void stop();
156 
163  void revokeAuthentication(const qevercloud::UserID userId);
164 
176  void setDownloadNoteThumbnails(bool flag);
177 
186  void setDownloadInkNoteImages(bool flag);
187 
205  void setInkNoteImagesStoragePath(QString path);
206 
207 Q_SIGNALS:
213  void started();
214 
220  void stopped();
221 
228  void failed(ErrorString errorDescription);
229 
250  void finished(
251  Account account, bool somethingDownloaded, bool somethingSent);
252 
264  void authenticationRevoked(
265  bool success, ErrorString errorDescription, qevercloud::UserID userId);
266 
280  void authenticationFinished(
281  bool success, ErrorString errorDescription, Account account);
282 
287  void remoteToLocalSyncStopped();
288 
293  void sendLocalChangesStopped();
294 
305  void willRepeatRemoteToLocalSyncAfterSendingChanges();
306 
318  void detectedConflictDuringLocalChangesSending();
319 
329  void rateLimitExceeded(qint32 secondsToWait);
330 
344  void remoteToLocalSyncDone(bool somethingDownloaded);
345 
361  void syncChunksDownloadProgress(
362  qint32 highestDownloadedUsn, qint32 highestServerUsn,
363  qint32 lastPreviousUsn);
364 
369  void syncChunksDownloaded();
370 
375  void syncChunksDataProcessingProgress(ISyncChunksDataCountersPtr counters);
376 
400  void linkedNotebookSyncChunksDownloadProgress(
401  qint32 highestDownloadedUsn, qint32 highestServerUsn,
402  qint32 lastPreviousUsn, LinkedNotebook linkedNotebook);
403 
408  void linkedNotebooksSyncChunksDownloaded();
409 
414  void linkedNotebookSyncChunksDataProcessingProgress(
415  ISyncChunksDataCountersPtr counters);
416 
425  void notesDownloadProgress(
426  quint32 notesDownloaded, quint32 totalNotesToDownload);
427 
436  void linkedNotebooksNotesDownloadProgress(
437  quint32 notesDownloaded, quint32 totalNotesToDownload);
438 
449  void resourcesDownloadProgress(
450  quint32 resourcesDownloaded, quint32 totalResourcesToDownload);
451 
462  void linkedNotebooksResourcesDownloadProgress(
463  quint32 resourcesDownloaded, quint32 totalResourcesToDownload);
464 
470  void preparedDirtyObjectsForSending();
471 
477  void preparedLinkedNotebooksDirtyObjectsForSending();
478 
484  void setAccountDone(Account account);
485 
490  void setDownloadNoteThumbnailsDone(bool flag);
491 
496  void setDownloadInkNoteImagesDone(bool flag);
497 
502  void setInkNoteImagesStoragePathDone(QString path);
503 
504 private:
505  SynchronizationManager() = delete;
506  Q_DISABLE_COPY(SynchronizationManager)
507 
508  SynchronizationManagerPrivate * d_ptr;
509  Q_DECLARE_PRIVATE(SynchronizationManager)
510 };
511 
512 } // namespace quentier
513 
514 #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:43
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