/
onedrivebackupsyncadaptor.h
106 lines (90 loc) · 3.97 KB
/
onedrivebackupsyncadaptor.h
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
/****************************************************************************
**
** Copyright (C) 2015-2019 Jolla Ltd.
** Copyright (C) 2019 Open Mobile Platform LLC
**
** This program/library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
** version 2.1 as published by the Free Software Foundation.
**
** This program/library 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
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this program/library; if not, write to the Free
** Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
** 02110-1301 USA
**
****************************************************************************/
#ifndef ONEDRIVEBACKUPSYNCADAPTOR_H
#define ONEDRIVEBACKUPSYNCADAPTOR_H
#include "onedrivedatatypesyncadaptor.h"
#include "backuprestoreoptions_p.h"
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QDateTime>
#include <QtCore/QVariantMap>
#include <QtCore/QList>
#include <QtCore/QStringList>
#include <QtCore/QSet>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QSslError>
#include <QtSql/QSqlDatabase>
namespace Buteo {
class ProfileManager;
}
class OneDriveBackupSyncAdaptor : public OneDriveDataTypeSyncAdaptor
{
Q_OBJECT
public:
OneDriveBackupSyncAdaptor(const QString &profileName, QObject *parent);
~OneDriveBackupSyncAdaptor();
QString syncServiceName() const;
void sync(const QString &dataTypeString, int accountId);
protected: // implementing OneDriveDataTypeSyncAdaptor interface
void purgeDataForOldAccount(int oldId, SocialNetworkSyncAdaptor::PurgeMode mode);
void beginSync(int accountId, const QString &accessToken);
void finalize(int accountId);
void finalCleanup();
private:
void initialiseAppFolderRequest(int accountId, const QString &accessToken,
const QString &localPath, const QString &remotePath,
const QString &remoteFile, const QString &syncDirection);
void getRemoteFolderMetadata(int accountId, const QString &accessToken,
const QString &localPath, const QString &remotePath,
const QString &parentId, const QString &remoteDirName);
void requestData(int accountId, const QString &accessToken,
const QString &localPath, const QString &remotePath,
const QString &remoteFile = QString(), const QString &redirectUrl = QString());
void uploadData(int accountId, const QString &accessToken,
const QString &localPath, const QString &remotePath,
const QString &localFile = QString());
void purgeAccount(int accountId);
private Q_SLOTS:
void initialiseAppFolderFinishedHandler();
void getRemoteFolderMetadataFinishedHandler();
void remotePathFinishedHandler();
void remoteFileFinishedHandler();
void createRemotePathFinishedHandler();
void createRemoteFileFinishedHandler();
void downloadProgressHandler(qint64 bytesReceived, qint64 bytesTotal);
void uploadProgressHandler(qint64 bytesSent, qint64 bytesTotal);
private:
void beginListOperation(int accountId, const QString &accessToken, const BackupRestoreOptions &options);
void beginSyncOperation(int accountId, const QString &accessToken, const BackupRestoreOptions &options);
void listOperationFinished();
Buteo::ProfileManager *m_profileManager;
QString m_profileName;
QString m_remoteAppDir;
struct RemoteDirectory {
QString dirName;
QString remoteId;
QString parentPath;
QString parentId;
bool created;
};
QList<RemoteDirectory> m_remoteDirectories;
};
#endif // ONEDRIVEBACKUPSYNCADAPTOR_H