QtDataSync  4.2.0
A simple offline-first synchronisation framework, to synchronize data of Qt applications between devices
Signals | Public Member Functions | Properties | List of all members
de::skycoder42::QtDataSync::AccountManager Class Reference

The QML binding of QtDataSync::AccountManager. More...

#include <qqmlaccountmanager.h>

+ Inheritance diagram for de::skycoder42::QtDataSync::AccountManager:

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.
 

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...
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () 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)
 
QThreadthread () 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)
 
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 &regExp, 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< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () 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...
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
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)
 
- Protected Member Functions inherited from QObject
QObjectsender () 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)
 

Detailed Description

The QML binding of QtDataSync::AccountManager.

Since
4.0
See also
QtDataSync::AccountManager

Definition at line 20 of file qqmlaccountmanager.h.

Member Function Documentation

◆ exportAccount()

Q_INVOKABLE void de::skycoder42::QtDataSync::AccountManager::exportAccount ( bool  includeServer,
const QJSValue completedFn,
const QJSValue errorFn = {} 
)

Export the current account data as untrusted export.

Parameters
includeServerSpecify whether the server address and configuration should be included into the export data
completedFnA function that is called with the exported data as parameter
errorFnA function that is called if the export fails.

Semantics of the completedFn:

  • Parameter 1: The export data as result of the export

Semantics of the errorFn:

  • Parameter 1: A localized error string to be displayed to the user

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.

Attention
Export data is only valid as long as the datasync instance that created the export is still running. It is not preserved beyond multiple runs and thus is only a temporary allowance

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).

See also
AccountManager::exportAccountTrusted, AccountManager::importAccount, AccountManager::loginRequested

◆ exportAccountTrusted()

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.

Parameters
includeServerSpecify whether the server address and configuration should be included into the export data
passwordThe password used to encrypt the exported data with
completedFnA function that is called with the exported data as parameter
errorFnA function that is called if the export fails.

Semantics of the completedFn:

  • Parameter 1: The export data as result of the export

Semantics of the errorFn:

  • Parameter 1: A localized error string to be displayed to the user

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.

Attention
Export data is only valid as long as the datasync instance that created the export is still running. It is not preserved beyond multiple runs and thus is only a temporary allowance

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).

See also
AccountManager::exportAccount, AccountManager::importAccountTrusted, AccountManager::accountAccessGranted

◆ importAccount()

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.

Parameters
importDataThe account data to be imported
completedFnA function that is called once the import has been finished
keepDataSpecify whether the stored data should be preserved

Semantics of the completedFn:

  • Parameter 1: true if the import was successful, false if not
  • Parameter 2: A localized error string to be displayed to the user. Only set in case of a failed import, otherwise empty

The 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.

Attention
Just because an import succeeded does not mean that the device is accept to the account. It only means that the data was valid import data that can be used to initiate an import. The engine will perform the import in the background, and either emit importAccepted() or lastErrorChanged() as soon as the import finished.

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.

See also
AccountManager::importAccountTrusted, AccountManager::exportAccount, AccountManager::importAccepted, AccountManager::lastErrorChanged, AccountManager::loginRequested

◆ importAccountTrusted()

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.

Parameters
importDataThe account data to be imported
passwordThe password used to decrypt the imported data with. Must be the same as used for the export
completedFnA function that is called once the import has been finished
keepDataSpecify whether the stored data should be preserved

Semantics of the completedFn:

  • Parameter 1: true if the import was successful, false if not
  • Parameter 2: A localized error string to be displayed to the user. Only set in case of a failed import, otherwise empty

The 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.

Attention
Just because an import succeeded does not mean that the device is accept to the account. It only means that the data was valid import data that can be used to initiate an import. The engine will perform the import in the background, and either emit importAccepted() or lastErrorChanged() as soon as the import finished.

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.

See also
AccountManager::importAccount, AccountManager::exportAccountTrusted, AccountManager::importAccepted, AccountManager::lastErrorChanged

◆ isTrustedImport()

Q_INVOKABLE bool de::skycoder42::QtDataSync::AccountManager::isTrustedImport ( const QJsonObject importData) const

Checks if the given data is trusted or not.

Parameters
importDataThe import data to be scanned for the trusted flag
Returns
true if the data is trusted, false if not

No validity checks are performed. If the data is not valid, simply false is returned

See also
AccountManager::importAccount, AccountManager::importAccountTrusted

Property Documentation

◆ node

QRemoteObjectNode de::skycoder42::QtDataSync::AccountManager::node
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.

Warning
This property must only ever be set on construction of the object and must not be changed afterwards. Do not set both, this property and setupName
Accessors
MEMBERnode
NOTIFYnodeChanged()
See also
AccountManager::setupName, AccountManager::valid

Definition at line 64 of file qqmlaccountmanager.h.

◆ setupName

QString de::skycoder42::QtDataSync::AccountManager::setupName
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

Warning
This property must only ever be set on construction of the object and must not be changed afterwards. Do not set both, this property and node
Accessors
MEMBERsetupName
NOTIFYsetupNameChanged()
See also
QtDataSync::AccountManager::setupName, AccountManager::node, AccountManager::valid

Definition at line 47 of file qqmlaccountmanager.h.

◆ valid

bool de::skycoder42::QtDataSync::AccountManager::valid
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
MEMBERvalid
NOTIFYvalidChanged()
READ ONLY
See also
AccountManager::setupName, AccountManager::node

Definition at line 80 of file qqmlaccountmanager.h.


The documentation for this class was generated from the following file: