QtDataSync  4.2.0
A simple offline-first synchronisation framework, to synchronize data of Qt applications between devices
defaults.h
1 #ifndef QTDATASYNC_DEFAULTS_H
2 #define QTDATASYNC_DEFAULTS_H
3 
4 #include <QtCore/qglobal.h>
5 #include <QtCore/qobject.h>
6 #include <QtCore/qdir.h>
7 #include <QtCore/qsettings.h>
8 #include <QtCore/qloggingcategory.h>
9 #include <QtCore/qdebug.h>
10 
11 #include <QtRemoteObjects/qremoteobjectnode.h>
12 
13 #include "QtDataSync/qtdatasync_global.h"
14 #include "QtDataSync/exception.h"
15 #include "QtDataSync/setup.h"
16 
17 class QSqlDatabase;
18 class QJsonSerializer;
19 
20 namespace QtDataSync {
21 
22 class Logger;
23 class Defaults;
24 class EmitterAdapter;
25 
26 class DatabaseRefPrivate;
28 class Q_DATASYNC_EXPORT DatabaseRef
29 {
30  Q_DISABLE_COPY(DatabaseRef)
31 
32 public:
34  DatabaseRef();
35  ~DatabaseRef();
37  DatabaseRef(DatabaseRefPrivate *d);
39  DatabaseRef(DatabaseRef &&other) noexcept;
41  DatabaseRef &operator=(DatabaseRef &&other) noexcept;
42 
44  bool isValid() const;
46  QSqlDatabase database() const;
48  operator QSqlDatabase() const;
50  QSqlDatabase *operator->() const;
51 
53  void drop();
54 
55 private:
57 };
58 
59 class DefaultsPrivate;
61 class Q_DATASYNC_EXPORT Defaults
62 {
63  Q_GADGET
64  friend class DefaultsPrivate;
65 
66 public:
68  enum PropertyKey {
81  EventLoggingMode
82  };
83  Q_ENUM(PropertyKey)
84 
85 
86  Defaults();
90  Defaults(const Defaults &other);
92  Defaults(Defaults &&other) noexcept;
94  Defaults &operator=(const Defaults &other);
96  Defaults &operator=(Defaults &&other) noexcept;
97  ~Defaults();
98 
100  bool isValid() const;
102  void drop();
103 
105  Logger *createLogger(const QByteArray &subCategory, QObject *parent = nullptr) const;
106 
108  QString setupName() const;
110  QDir storageDir() const;
112  QUrl remoteAddress() const;
114  QRemoteObjectNode *remoteNode() const;
116  QSettings *createSettings(QObject *parent = nullptr, const QString &group = {}) const;
118  const QJsonSerializer *serializer() const;
120  const ConflictResolver *conflictResolver() const;
122  QVariant property(PropertyKey key) const;
123 
125  static QVariant defaultParam(Setup::SignatureScheme scheme);
127  static QVariant defaultParam(Setup::EncryptionScheme scheme);
128 
130  DatabaseRef aquireDatabase(QObject *object) const;
131 
133  EmitterAdapter *createEmitter(QObject *parent = nullptr) const;
135  QVariant cacheHandle() const;
136 
137 private:
139 };
140 
141 }
142 
143 #endif // QTDATASYNC_DEFAULTS_H
The configuration to be used to connect to the remote.
Definition: defaults.h:73
A wrapper around QSqlDatabase to manage the connections.
Definition: defaults.h:28
The generation parameter for the signature key.
Definition: defaults.h:76
The policiy for how to handle conflicts.
Definition: defaults.h:71
Specify whether deleted datasets should persist.
Definition: defaults.h:70
The algorithmic scheme to be used for new signature keys.
Definition: defaults.h:75
The size of the internal database cache, in bytes.
Definition: defaults.h:69
The primary namespace of the QtDataSync library.
SignatureScheme
The signature schemes supported for Setup::signatureScheme.
Definition: setup.h:113
The algorithmic scheme to be used for new encryption keys.
Definition: defaults.h:77
The name of the preferred keystore provider.
Definition: defaults.h:74
A helper class to get defaults per datasync instance (threadsafe)
Definition: defaults.h:61
EncryptionScheme
The encryption schemes supported for Setup::encryptionScheme.
Definition: setup.h:121
The algorithmic scheme to be used for new secret exchange keys (which are symmetric) ...
Definition: defaults.h:79
PropertyKey
The keys of special properties set on the defaults.
Definition: defaults.h:68
The ssl configuration to be used to connect to the remote.
Definition: defaults.h:72
The generation parameter for the encryption key.
Definition: defaults.h:78
The size in bytes for the secret exchange key (which is symmetric)
Definition: defaults.h:80
A Helper class for simple and structured logging.
Definition: logger.h:14