1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
/*********************************************************************************
NixNote - An open-source client for the Evernote service.
Copyright (C) 2013 Randy Baumgarte
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
***********************************************************************************/
#ifndef SYNCRUNNER_H
#define SYNCRUNNER_H
#include <QObject>
#include <QThread>
#include <QString>
#include <QMap>
#include <QHash>
#include <QVector>
#include <QTimer>
#include "communication/communicationmanager.h"
#include "sql/databaseconnection.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <qt5qevercloud/QEverCloud.h>
using namespace qevercloud;
class SyncRunner : public QObject
{
Q_OBJECT
private:
bool idle;
bool init;
int defaultMsgTimeout;
long evernoteUpdateCount;
DatabaseConnection *db;
CommunicationManager *comm;
QVector<QString> errorSharedNotebooks;
QMap<QString,QString> errorSharedNotebooksIgnored;
string consumerKey;
string secret;
string authToken;
string userAgent;
string username;
string password;
long authTimeRemaining;
long authRefreshTime;
bool authRefreshNeeded;
long failedRefreshes;
long sequenceDate;
qint32 updateSequenceNumber;
bool fullSync;
QHash<QString, QString> changedNotebooks;
QHash<QString, QString> changedTags;
void evernoteSync();
bool syncRemoteToLocal(qint32 highSequence);
void syncRemoteExpungedNotes(QList<Guid> guids);
void syncRemoteExpungedNotebooks(QList<Guid> guids);
void processSyncChunk(SyncChunk &chunk, qint32 linkedNotebook=0);
void syncRemoteExpungedTags(QList<Guid> guids);
void syncRemoteExpungedSavedSearches(QList<Guid> guid);
void syncRemoteTags(QList<Tag> tag, qint32 account=0);
void syncRemoteSearches(QList<SavedSearch> searches);
void syncRemoteNotebooks(QList<Notebook> books, qint32 account=0);
void syncRemoteNotes(QList<Note> notes, qint32 account=0);
void syncRemoteResources(QList<Resource> resources);
void syncRemoteLinkedNotebooksChunk(QList<LinkedNotebook> books);
void syncRemoteExpungedLinkedNotebooks(QList<Guid> guids);
bool syncRemoteLinkedNotebooksActual();
//void checkForInkNotes(QList<Resource> &resources);
qint32 uploadSavedSearches();
qint32 uploadTags();
qint32 uploadNotebooks();
qint32 uploadPersonalNotes();
qint32 uploadLinkedNotes(qint32 notebookLid);
public:
bool keepRunning;
string userStoreUrl;
string noteStoreUrl;
SyncRunner();
~SyncRunner();
bool error;
CommunicationError* getError();
void communicationErrorHandler();
bool finalSync;
bool apiRateLimitExceeded;
signals:
void syncComplete();
void setMessage(QString message, int timeout);
void searchUpdated(qint32 lid, QString name);
void tagUpdated(qint32 lid, QString name, QString parentGuid, qint32 account);
void notebookUpdated(qint32 lid, QString name, QString stack, bool linked, bool shared);
void noteUpdated(qint32 lid);
void tagExpunged(qint32 lid);
void notebookExpunged(qint32 lid);
void searchExpunged(qint32 lid);
void noteSynchronized(qint32, bool);
public slots:
void synchronize();
void applicationException(QString);
};
#endif // SYNCRUNNER_H
|