QtDataSync
4.2.0
A simple offline-first synchronisation framework, to synchronize data of Qt applications between devices
|
The QML binding of QtDataSync::AccountManager. More...
#include <qqmlaccountmanager.h>
Signals | |
void | setupNameChanged (const QString &setupName) |
NOTIFY accessor for AccountManager::setupName. | |
void | nodeChanged (QRemoteObjectNode *node) |
NOTIFY accessor for AccountManager::node. | |
void | validChanged (bool valid) |
NOTIFY accessor for AccountManager::valid. | |
![]() | |
void | accountDevices (const QList< QtDataSync::DeviceInfo > &devices, QPrivateSignal) |
Is emitted when the accounts devices have been sent by the server. More... | |
void | loginRequested (QtDataSync::LoginRequest request, QPrivateSignal) |
Is emitted when another device requests permission to be added to the current account. More... | |
void | importAccepted (QPrivateSignal) |
Is emitted when the partner accept the account import. More... | |
void | accountAccessGranted (const QUuid &deviceId, QPrivateSignal) |
Is emitted when a device has been granted access to the current account. More... | |
QT_DATASYNC_REVISION_2 void | setupNameChanged (const QString &setupName, QPrivateSignal) |
NOTIFY accessor for AccountManager::setupName. | |
void | deviceNameChanged (const QString &deviceName, QPrivateSignal) |
NOTIFY accessor for AccountManager::deviceName. | |
void | deviceFingerprintChanged (const QByteArray &deviceFingerprint, QPrivateSignal) |
NOTIFY accessor for AccountManager::deviceFingerprint. | |
void | lastErrorChanged (const QString &lastError, QPrivateSignal) |
NOTIFY accessor for AccountManager::lastError. | |
Public Member Functions | |
Q_INVOKABLE bool | isTrustedImport (const QJsonObject &importData) const |
Checks if the given data is trusted or not. More... | |
Q_INVOKABLE void | exportAccount (bool includeServer, const QJSValue &completedFn, const QJSValue &errorFn={}) |
Export the current account data as untrusted export. More... | |
Q_INVOKABLE void | exportAccountTrusted (bool includeServer, const QString &password, const QJSValue &completedFn, const QJSValue &errorFn={}) |
Export the current account data as trusted export. More... | |
Q_INVOKABLE void | importAccount (const QJsonObject &importData, const QJSValue &completedFn, bool keepData=false) |
Import an account from the given untrusted export data. More... | |
Q_INVOKABLE void | importAccountTrusted (const QJsonObject &importData, const QString &password, const QJSValue &completedFn, bool keepData=false) |
Import an account from the given trusted export data. More... | |
![]() | |
AccountManager (QObject *parent=nullptr) | |
Default constructor, uses the default setup. More... | |
AccountManager (const QString &setupName, QObject *parent=nullptr) | |
Constructor with an explicit setup. More... | |
AccountManager (QRemoteObjectNode *node, QObject *parent=nullptr) | |
Constructor with a remote object node to connect to. More... | |
Q_INVOKABLE QRemoteObjectReplica * | replica () const |
The internal replica used to connect to the engine. More... | |
void | exportAccount (bool includeServer, const std::function< void(QJsonObject)> &completedFn, const std::function< void(QString)> &errorFn={}) |
Export the current account data as untrusted export. More... | |
void | exportAccount (bool includeServer, const std::function< void(QByteArray)> &completedFn, const std::function< void(QString)> &errorFn={}) |
Export the current account data as untrusted export. More... | |
void | exportAccountTrusted (bool includeServer, const QString &password, const std::function< void(QJsonObject)> &completedFn, const std::function< void(QString)> &errorFn={}) |
Export the current account data as trusted export. More... | |
void | exportAccountTrusted (bool includeServer, const QString &password, const std::function< void(QByteArray)> &completedFn, const std::function< void(QString)> &errorFn={}) |
Export the current account data as trusted export. More... | |
void | importAccount (const QJsonObject &importData, const std::function< void(bool, QString)> &completedFn, bool keepData=false) |
Import an account from the given untrusted export data. More... | |
void | importAccount (const QByteArray &importData, const std::function< void(bool, QString)> &completedFn, bool keepData=false) |
Import an account from the given untrusted export data. More... | |
void | importAccountTrusted (const QJsonObject &importData, const QString &password, const std::function< void(bool, QString)> &completedFn, bool keepData=false) |
Import an account from the given trusted export data. More... | |
void | importAccountTrusted (const QByteArray &importData, const QString &password, const std::function< void(bool, QString)> &completedFn, bool keepData=false) |
Import an account from the given trusted export data. More... | |
QString | setupName () const |
READ accessor for AccountManager::setupName. | |
QString | deviceName () const |
READ accessor for AccountManager::deviceName. | |
QByteArray | deviceFingerprint () const |
READ accessor for AccountManager::deviceFingerprint. | |
QString | lastError () const |
READ accessor for AccountManager::lastError. | |
![]() | |
virtual const QMetaObject * | metaObject () const const |
virtual void * | qt_metacast (const char *) |
virtual int | qt_metacall (QMetaObject::Call, int, void **) |
QObject (QObject *parent) | |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
QString | objectName () const const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
bool | signalsBlocked () const const |
bool | blockSignals (bool block) |
QThread * | thread () const const |
void | moveToThread (QThread *targetThread) |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
void | killTimer (int id) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
const QObjectList & | children () const const |
void | setParent (QObject *parent) |
void | installEventFilter (QObject *filterObj) |
void | removeEventFilter (QObject *obj) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectTree () |
void | dumpObjectInfo () |
void | dumpObjectTree () const const |
void | dumpObjectInfo () const const |
bool | setProperty (const char *name, const QVariant &value) |
QVariant | property (const char *name) const const |
QList< QByteArray > | dynamicPropertyNames () const const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
bool | inherits (const char *className) const const |
void | deleteLater () |
Properties | |
QString | setupName |
Holds the name of the setup this manager operates on. More... | |
QRemoteObjectNode | node |
Allows to directly set the remote object node to use. More... | |
bool | valid |
Specifies if the object was correctly initialized. More... | |
![]() | |
QString | setupName |
Holds the name of the setup this manager operates on. More... | |
QString | deviceName |
The display name of the device. More... | |
QByteArray | deviceFingerprint |
The fingerprint of the devices cryptographic keys. More... | |
QString | lastError |
The last internal error that occured. More... | |
![]() | |
objectName | |
Additional Inherited Members | |
![]() | |
void | listDevices () |
Sends a request to the server to list all devices that belong to the current account. More... | |
void | removeDevice (const QUuid &deviceInfo) |
Remove the device with the given id from the current account. More... | |
void | removeDevice (const QtDataSync::DeviceInfo &deviceInfo) |
Remove the given device from the current account. More... | |
void | resetAccount (bool keepData=true) |
Removes this device from the current account and then creates a new one. More... | |
void | changeRemote (const RemoteConfig &config, bool keepData=true) |
Resets the account and connects to the new remote to create a new one. More... | |
void | updateExchangeKey () |
Generate a new secret exchange key used to encrypt data. More... | |
void | setDeviceName (const QString &deviceName) |
WRITE accessor for AccountManager::deviceName. | |
void | resetDeviceName () |
RESET accessor for AccountManager::deviceName. | |
![]() | |
static bool | isTrustedImport (const QJsonObject &importData) |
Checks if the given data is trusted or not. More... | |
static bool | isTrustedImport (const QByteArray &importData) |
Checks if the given data is trusted or not. More... | |
![]() | |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
![]() | |
QObject * | sender () const const |
int | senderSignalIndex () const const |
int | receivers (const char *signal) const const |
bool | isSignalConnected (const QMetaMethod &signal) const const |
virtual void | timerEvent (QTimerEvent *event) |
virtual void | childEvent (QChildEvent *event) |
virtual void | customEvent (QEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
The QML binding of QtDataSync::AccountManager.
Definition at line 20 of file qqmlaccountmanager.h.
Q_INVOKABLE void de::skycoder42::QtDataSync::AccountManager::exportAccount | ( | bool | includeServer, |
const QJSValue & | completedFn, | ||
const QJSValue & | errorFn = {} |
||
) |
Export the current account data as untrusted export.
includeServer | Specify whether the server address and configuration should be included into the export data |
completedFn | A function that is called with the exported data as parameter |
errorFn | A function that is called if the export fails. |
Semantics of the completedFn
:
Semantics of the errorFn
:
The function initiates an asynchronous export of the user data. When is is finished, one of the two result functions is called on the AccountManagers thread. They are only called as long as the manager still exists.
The export is untrusted, which means a device that uses that data to add itself to the account will trigger the loginRequested() signal and must explicitly be accepted.
The includeServer
parameter can be set to true to include the servers address and configuration. This is needed in cases where the server data is not hard coded into the application (for example when the load balancer is used).
Q_INVOKABLE void de::skycoder42::QtDataSync::AccountManager::exportAccountTrusted | ( | bool | includeServer, |
const QString & | password, | ||
const QJSValue & | completedFn, | ||
const QJSValue & | errorFn = {} |
||
) |
Export the current account data as trusted export.
includeServer | Specify whether the server address and configuration should be included into the export data |
password | The password used to encrypt the exported data with |
completedFn | A function that is called with the exported data as parameter |
errorFn | A function that is called if the export fails. |
Semantics of the completedFn
:
Semantics of the errorFn
:
The function initiates an asynchronous export of the user data. When is is finished, one of the two result functions is called on the AccountManagers thread. They are only called as long as the manager still exists.
The export is trusted, which means that is encrypted with the given password and can only be import by someone who knows the password. Since the password serves as token of trust, no additional confirmation is needed. As soon as the partner requests to be added and can confirm he knows the shared password, the device is added to the account.
The includeServer
parameter can be set to true to include the servers address and configuration. This is needed in cases where the server data is not hard coded into the application (for example when the load balancer is used).
Q_INVOKABLE void de::skycoder42::QtDataSync::AccountManager::importAccount | ( | const QJsonObject & | importData, |
const QJSValue & | completedFn, | ||
bool | keepData = false |
||
) |
Import an account from the given untrusted export data.
importData | The account data to be imported |
completedFn | A function that is called once the import has been finished |
keepData | Specify whether the stored data should be preserved |
Semantics of the completedFn
:
true
if the import was successful, false
if notThe function initiates an asynchronous import of the user data. When is is finished, the result functions is called on the AccountManagers thread. It is only called as long as the manager still exists.
The import is untrusted, which means that the device that created the export must explicitly accept this device to be added to the account.
If keepData
is false (the default), all local data is deleted before the import. This way only the data that already belongs to the account is imported. If true, the local data is kept and will be synchronized to the account as soon as access was granted.
Q_INVOKABLE void de::skycoder42::QtDataSync::AccountManager::importAccountTrusted | ( | const QJsonObject & | importData, |
const QString & | password, | ||
const QJSValue & | completedFn, | ||
bool | keepData = false |
||
) |
Import an account from the given trusted export data.
importData | The account data to be imported |
password | The password used to decrypt the imported data with. Must be the same as used for the export |
completedFn | A function that is called once the import has been finished |
keepData | Specify whether the stored data should be preserved |
Semantics of the completedFn
:
true
if the import was successful, false
if notThe function initiates an asynchronous import of the user data. When is is finished, the result functions is called on the AccountManagers thread. It is only called as long as the manager still exists.
The import is trusted, which means that as long as the password is correct and the export data still valid, the import will be accepted. Event though no confirmation is needed, the device that exported the data must still be connected.
If keepData
is false (the default), all local data is deleted before the import. This way only the data that already belongs to the account is imported. If true, the local data is kept and will be synchronized to the account as soon as access was granted.
Q_INVOKABLE bool de::skycoder42::QtDataSync::AccountManager::isTrustedImport | ( | const QJsonObject & | importData | ) | const |
Checks if the given data is trusted or not.
importData | The import data to be scanned for the trusted flag |
true
if the data is trusted, false
if notNo validity checks are performed. If the data is not valid, simply false
is returned
|
readwrite |
Allows to directly set the remote object node to use.
Default: nullptr
Instead of a setup name, you can directly specify the remote object node via this property.
Accessors | |
---|---|
MEMBER | node |
NOTIFY | nodeChanged() |
Definition at line 64 of file qqmlaccountmanager.h.
|
readwrite |
Holds the name of the setup this manager operates on.
Default: QtDataSync::DefaultSetup
Allows you to specify the name of the setup that this manager should use
Accessors | |
---|---|
MEMBER | setupName |
NOTIFY | setupNameChanged() |
Definition at line 47 of file qqmlaccountmanager.h.
|
read |
Specifies if the object was correctly initialized.
Default: false
Only becomes true if the given setup name resolves to a valid datasync instance or if the given node is valid
Accessors | |
---|---|
MEMBER | valid |
NOTIFY | validChanged() |
READ ONLY |
Definition at line 80 of file qqmlaccountmanager.h.