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 
87 
88 public Q_SLOTS:
103  void setAccount(Account account);
104 
113  void authenticate();
114 
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 
247  bool success, ErrorString errorDescription, qevercloud::UserID userId);
248 
263  bool success, ErrorString errorDescription, Account account);
264 
270 
276 
288 
301 
311  void rateLimitExceeded(qint32 secondsToWait);
312 
326  void remoteToLocalSyncDone(bool somethingDownloaded);
327 
344  qint32 highestDownloadedUsn, qint32 highestServerUsn,
345  qint32 lastPreviousUsn);
346 
352 
377  qint32 highestDownloadedUsn, qint32 highestServerUsn,
378  qint32 lastPreviousUsn, LinkedNotebook linkedNotebook);
379 
385 
395  quint32 notesDownloaded, quint32 totalNotesToDownload);
396 
406  quint32 notesDownloaded, quint32 totalNotesToDownload);
407 
419  quint32 resourcesDownloaded, quint32 totalResourcesToDownload);
420 
432  quint32 resourcesDownloaded, quint32 totalResourcesToDownload);
433 
440 
447 
453  void setAccountDone(Account account);
454 
460 
466 
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
The Account class encapsulates some details about the account: its name, whether it is local or synch...
Definition: Account.h:40
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:44
Definition: IAuthenticationManager.h:37
Definition: LinkedNotebook.h:33
Definition: LocalStorageManagerAsync.h:45
Definition: SynchronizationManagerDependencyInjector.h:31
The SynchronizationManager class encapsulates methods and signals & slots required to perform the ful...
Definition: SynchronizationManager.h:47
void notesDownloadProgress(quint32 notesDownloaded, quint32 totalNotesToDownload)
void linkedNotebooksResourcesDownloadProgress(quint32 resourcesDownloaded, quint32 totalResourcesToDownload)
void setInkNoteImagesStoragePath(QString path)
void rateLimitExceeded(qint32 secondsToWait)
void syncChunksDownloadProgress(qint32 highestDownloadedUsn, qint32 highestServerUsn, qint32 lastPreviousUsn)
void authenticationFinished(bool success, ErrorString errorDescription, Account account)
void remoteToLocalSyncDone(bool somethingDownloaded)
void linkedNotebooksNotesDownloadProgress(quint32 notesDownloaded, quint32 totalNotesToDownload)
void revokeAuthentication(const qevercloud::UserID userId)
void setDownloadInkNoteImages(bool flag)
void setDownloadNoteThumbnailsDone(bool flag)
void setInkNoteImagesStoragePathDone(QString path)
SynchronizationManager(const QString &host, LocalStorageManagerAsync &localStorageManagerAsync, IAuthenticationManager &authenticationManager, SynchronizationManagerDependencyInjector *pInjector=nullptr)
void finished(Account account, bool somethingDownloaded, bool somethingSent)
void setDownloadNoteThumbnails(bool flag)
void failed(ErrorString errorDescription)
void setDownloadInkNoteImagesDone(bool flag)
void setAccount(Account account)
void authenticationRevoked(bool success, ErrorString errorDescription, qevercloud::UserID userId)
void setAccountDone(Account account)
void linkedNotebookSyncChunksDownloadProgress(qint32 highestDownloadedUsn, qint32 highestServerUsn, qint32 lastPreviousUsn, LinkedNotebook linkedNotebook)
void resourcesDownloadProgress(quint32 resourcesDownloaded, quint32 totalResourcesToDownload)