1 #ifndef QTDATASYNC_SETUP_H 2 #define QTDATASYNC_SETUP_H 7 #include <QtCore/qobject.h> 8 #include <QtCore/qlogging.h> 9 #include <QtCore/qurl.h> 12 #include <QtNetwork/qsslconfiguration.h> 14 #include "QtDataSync/qtdatasync_global.h" 15 #include "QtDataSync/exception.h" 16 #include "QtDataSync/remoteconfig.h" 23 template<
typename TRatio>
24 Q_DECL_CONSTEXPR
inline int ratioBytes(intmax_t value);
26 Q_DECL_CONSTEXPR
inline int KB(intmax_t value);
28 Q_DECL_CONSTEXPR
inline int MB(intmax_t value);
30 Q_DECL_CONSTEXPR
inline int GB(intmax_t value);
32 #if __cplusplus >= 201402L 37 Q_DECL_CONSTEXPR
inline int operator "" _kb(
unsigned long long x) {
38 return KB(static_cast<intmax_t>(x));
42 Q_DECL_CONSTEXPR
inline int operator "" _mb(
unsigned long long x) {
43 return MB(static_cast<intmax_t>(x));
47 Q_DECL_CONSTEXPR
inline int operator "" _gb(
unsigned long long x) {
48 return GB(static_cast<intmax_t>(x));
54 class ConflictResolver;
65 Q_PROPERTY(
QString localDir READ localDir WRITE setLocalDir RESET resetLocalDir)
67 Q_PROPERTY(
QUrl remoteObjectHost READ remoteObjectHost WRITE setRemoteObjectHost RESET resetRemoteObjectHost)
69 Q_PROPERTY(
QJsonSerializer* serializer READ serializer WRITE setSerializer RESET resetSerializer)
73 Q_PROPERTY(
FatalErrorHandler fatalErrorHandler READ fatalErrorHandler WRITE setFatalErrorHandler RESET resetFatalErrorHandler)
75 Q_PROPERTY(
int cacheSize READ cacheSize WRITE setCacheSize RESET resetCacheSize)
77 Q_PROPERTY(
bool persistDeletedVersion READ persistDeletedVersion WRITE setPersistDeletedVersion RESET resetPersistDeletedVersion)
79 Q_PROPERTY(
SyncPolicy syncPolicy READ syncPolicy WRITE setSyncPolicy RESET resetSyncPolicy)
81 Q_PROPERTY(
QSslConfiguration sslConfiguration READ sslConfiguration WRITE setSslConfiguration RESET resetSslConfiguration)
83 Q_PROPERTY(
QtDataSync::
RemoteConfig remoteConfiguration READ remoteConfiguration WRITE setRemoteConfiguration RESET resetRemoteConfiguration)
85 Q_PROPERTY(
QString keyStoreProvider READ keyStoreProvider WRITE setKeyStoreProvider RESET resetKeyStoreProvider)
87 Q_PROPERTY(
SignatureScheme signatureScheme READ signatureScheme WRITE setSignatureScheme RESET resetSignatureScheme)
89 Q_PROPERTY(
QVariant signatureKeyParam READ signatureKeyParam WRITE setSignatureKeyParam RESET resetSignatureKeyParam)
91 Q_PROPERTY(
EncryptionScheme encryptionScheme READ encryptionScheme WRITE setEncryptionScheme RESET resetEncryptionScheme)
93 Q_PROPERTY(
QVariant encryptionKeyParam READ encryptionKeyParam WRITE setEncryptionKeyParam RESET resetEncryptionKeyParam)
95 Q_PROPERTY(
CipherScheme cipherScheme READ cipherScheme WRITE setCipherScheme RESET resetCipherScheme)
97 Q_PROPERTY(qint32 cipherKeySize READ cipherKeySize WRITE setCipherKeySize RESET resetCipherKeySize)
99 Q_PROPERTY(
EventMode eventLoggingMode READ eventLoggingMode WRITE setEventLoggingMode RESET resetEventLoggingMode REVISION 2)
118 Q_ENUM(SignatureScheme)
125 Q_ENUM(EncryptionScheme)
167 Q_ENUM(EllipticCurve)
180 static void setCleanupTimeout(
unsigned long timeout);
182 static void removeSetup(
const QString &name,
bool waitForFinished =
false);
189 static bool keystoreAvailable(
const QString &provider);
191 static QString defaultKeystoreProvider();
207 QUrl remoteObjectHost()
const;
213 FatalErrorHandler fatalErrorHandler()
const;
215 int cacheSize()
const;
217 bool persistDeletedVersion()
const;
219 SyncPolicy syncPolicy()
const;
225 QString keyStoreProvider()
const;
227 SignatureScheme signatureScheme()
const;
231 EncryptionScheme encryptionScheme()
const;
233 QVariant encryptionKeyParam()
const;
235 CipherScheme cipherScheme()
const;
237 qint32 cipherKeySize()
const;
239 EventMode eventLoggingMode()
const;
244 Setup &setRemoteObjectHost(
QUrl remoteObjectHost);
250 Setup &setFatalErrorHandler(
const FatalErrorHandler &fatalErrorHandler);
252 Setup &setCacheSize(
int cacheSize);
254 Setup &setPersistDeletedVersion(
bool persistDeletedVersion);
256 Setup &setSyncPolicy(SyncPolicy syncPolicy);
264 Setup &setSignatureScheme(SignatureScheme signatureScheme);
268 Setup &setEncryptionScheme(EncryptionScheme encryptionScheme);
272 Setup &setCipherScheme(CipherScheme cipherScheme);
274 Setup &setCipherKeySize(qint32 cipherKeySize);
276 Setup &setEventLoggingMode(EventMode eventLoggingMode);
279 Setup &resetLocalDir();
281 Setup &resetRemoteObjectHost();
283 Setup &resetSerializer();
285 Setup &resetConflictResolver();
287 Setup &resetFatalErrorHandler();
289 Setup &resetCacheSize();
291 Setup &resetPersistDeletedVersion();
293 Setup &resetSyncPolicy();
295 Setup &resetSslConfiguration();
297 Setup &resetRemoteConfiguration();
299 Setup &resetKeyStoreProvider();
301 Setup &resetSignatureScheme();
303 Setup &resetSignatureKeyParam();
305 Setup &resetEncryptionScheme();
307 Setup &resetEncryptionKeyParam();
309 Setup &resetCipherScheme();
311 Setup &resetCipherKeySize();
313 Setup &resetEventLoggingMode();
316 Setup &setAccount(
const QJsonObject &importData,
bool keepData =
false,
bool allowFailure =
false);
318 Setup &setAccount(
const QByteArray &importData,
bool keepData =
false,
bool allowFailure =
false);
320 Setup &setAccountTrusted(
const QJsonObject &importData,
const QString &password,
bool keepData =
false,
bool allowFailure =
false);
322 Setup &setAccountTrusted(
const QByteArray &importData,
const QString &password,
bool keepData =
false,
bool allowFailure =
false);
350 QByteArray className()
const noexcept
override;
351 void raise()
const final;
373 QByteArray className()
const noexcept
override;
374 QString qWhat()
const override;
375 void raise()
const final;
392 template<
typename TRatio>
393 Q_DECL_CONSTEXPR
inline int ratioBytes(intmax_t value)
395 return static_cast<int>(qMin(TRatio().num * value, static_cast<intmax_t>(INT_MAX)));
398 Q_DECL_CONSTEXPR
inline int KB(intmax_t value)
400 return ratioBytes<std::kilo>(value);
403 Q_DECL_CONSTEXPR
inline int MB(intmax_t value)
405 return ratioBytes<std::mega>(value);
408 Q_DECL_CONSTEXPR
inline int GB(intmax_t value)
410 return ratioBytes<std::giga>(value);
415 #endif // QTDATASYNC_SETUP_H Twofish operating in EAX authenticated encryption mode.
The class to setup and create datasync instances.
IDEA operating in EAX authenticated encryption mode.
Twofish operating in GCM authenticated encryption mode.
The base class for all exceptions of QtDataSync.
std::function< void(QString, QString, const QMessageLogContext &)> FatalErrorHandler
Typedef of an error handler function. See Setup::fatalErrorHandler.
ECDSA on prime curves with Sha3 hash of 512 bits.
AES operating in EAX authenticated encryption mode.
AES operating in GCM authenticated encryption mode.
Exception thrown if a setups storage directory is locked by another instance.
An interface for a generic keystore to securely store secret cryptographic keys.
The primary namespace of the QtDataSync library.
Q_DECL_CONSTEXPR int MB(intmax_t value)
Interprets value as megabytes and returns it converted to bytes.
Q_DATASYNC_EXPORT const QString DefaultSetup
The default setup name.
SignatureScheme
The signature schemes supported for Setup::signatureScheme.
EventMode
Possible values for the event logging mode change.
Serpent operating in EAX authenticated encryption mode.
Exception throw if Setup::create fails.
Interface to implement a custom conflict handler for sync conflicts.
Serpent operating in GCM authenticated encryption mode.
SyncPolicy
Defines the possible policies on how to treat merge conflicts between change and delete.
Exception thrown if a setup with the same name already exsits.
Q_DECL_CONSTEXPR int GB(intmax_t value)
Interprets value as gigabytes and returns it converted to bytes.
RSA in PSS mode with Sha3 hash of 512 bits.
EncryptionScheme
The encryption schemes supported for Setup::encryptionScheme.
A configuration on how to connect to a remote server.
CipherScheme
The symmetric cipher schemes supported for Setup::cipherScheme.
EllipticCurve
Elliptic curves supported as key parameter for Setup::signatureKeyParam and Setup::encryptionKeyParam...
Q_DECL_CONSTEXPR int KB(intmax_t value)
Interprets value as kilobytes and returns it converted to bytes.
RSA in OAEP mode with Sha3 hash of 512 bits.