libquentier  0.4.0
The library for rich desktop clients of Evernote service
SynchronizationManager.h
1 /*
2  * Copyright 2016 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 #include <QObject>
29 
30 namespace quentier {
31 
32 QT_FORWARD_DECLARE_CLASS(LocalStorageManagerAsync)
33 QT_FORWARD_DECLARE_CLASS(SynchronizationManagerPrivate)
34 
35 
40 class QUENTIER_EXPORT SynchronizationManager: public QObject
41 {
42  Q_OBJECT
43 public:
52  SynchronizationManager(const QString & consumerKey, const QString & consumerSecret,
53  const QString & host, LocalStorageManagerAsync & localStorageManagerAsync,
54  IAuthenticationManager & authenticationManager);
55 
56  virtual ~SynchronizationManager();
57 
61  bool active() const;
62 
67  bool downloadNoteThumbnailsOption() const;
68 
69 public Q_SLOTS:
80  void setAccount(Account account);
81 
89  void authenticate();
90 
94  void synchronize();
95 
100  void stop();
101 
107  void revokeAuthentication(const qevercloud::UserID userId);
108 
118  void setDownloadNoteThumbnails(bool flag);
119 
126  void setDownloadInkNoteImages(bool flag);
127 
141  void setInkNoteImagesStoragePath(QString path);
142 
143 Q_SIGNALS:
148  void started();
149 
154  void stopped();
155 
160  void failed(ErrorString errorDescription);
161 
166  void finished(Account account);
167 
174  void authenticationRevoked(bool success, ErrorString errorDescription,
175  qevercloud::UserID userId);
176 
184  void authenticationFinished(bool success, ErrorString errorDescription,
185  Account account);
186 
190  void remoteToLocalSyncStopped();
191 
195  void sendLocalChangesStopped();
196 
205  void willRepeatRemoteToLocalSyncAfterSendingChanges();
206 
215  void detectedConflictDuringLocalChangesSending();
216 
223  void rateLimitExceeded(qint32 secondsToWait);
224 
229  void remoteToLocalSyncDone();
230 
242  void syncChunksDownloadProgress(qint32 highestDownloadedUsn, qint32 highestServerUsn, qint32 lastPreviousUsn);
243 
248  void syncChunksDownloaded();
249 
264  void linkedNotebookSyncChunksDownloadProgress(qint32 highestDownloadedUsn, qint32 highestServerUsn, qint32 lastPreviousUsn,
265  LinkedNotebook linkedNotebook);
266 
271  void linkedNotebooksSyncChunksDownloaded();
272 
278  void notesDownloadProgress(quint32 notesDownloaded, quint32 totalNotesToDownload);
279 
285  void linkedNotebooksNotesDownloadProgress(quint32 notesDownloaded, quint32 totalNotesToDownload);
286 
295  void resourcesDownloadProgress(quint32 resourcesDownloaded, quint32 totalResourcesToDownload);
296 
305  void linkedNotebooksResourcesDownloadProgress(quint32 resourcesDownloaded, quint32 totalResourcesToDownload);
306 
311  void preparedDirtyObjectsForSending();
312 
317  void preparedLinkedNotebooksDirtyObjectsForSending();
318 
323  void setAccountDone(Account account);
324 
328  void setDownloadNoteThumbnailsDone(bool flag);
329 
333  void setDownloadInkNoteImagesDone(bool flag);
334 
338  void setInkNoteImagesStoragePathDone(QString path);
339 
340 private:
341  SynchronizationManager() Q_DECL_EQ_DELETE;
342  Q_DISABLE_COPY(SynchronizationManager)
343 
344  SynchronizationManagerPrivate * d_ptr;
345  Q_DECLARE_PRIVATE(SynchronizationManager)
346 };
347 
348 } // namespace quentier
349 
350 #endif // LIB_QUENTIER_SYNCHRONIZATION_SYNCHRONIZATION_MANAGER_H
Definition: LinkedNotebook.h:36
The SynchronizationManager class encapsulates methods and signals & slots required to perform the ful...
Definition: SynchronizationManager.h:40
The ErrorString class encapsulates two (or more) strings which are meant to contain translatable (bas...
Definition: ErrorString.h:38
Definition: LocalStorageManagerAsync.h:39
The Account class encapsulates some details about the account: its name, whether it is local or synch...
Definition: Account.h:24
Definition: IAuthenticationManager.h:37