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

Manages devices that belong to the users account. More...

#include <accountmanager.h>

+ Inheritance diagram for QtDataSync::AccountManager:

Public Slots

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.
 

Signals

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

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

Static Public Member Functions

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

Properties

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...
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- 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

Manages devices that belong to the users account.

It can be used to list the devices that belong to the current account, remove device from the account and to export and import account data in order to add a new device to an existing account

The manager connects to the engine via a QRemoteObjectNode. Internally the class holds a replica of a source that is part of the datasync engine which is created by the setup. Typically, this node is managed by the setup too, but you can specify your own node in the constructor. In order to increase security and performance a special remote object connection is used that utilizes events to deliver messages within the same process only. See Threaded remote objects for details.

See also
Threaded remote objects, Setup::remoteObjectHost

Definition at line 119 of file accountmanager.h.

Constructor & Destructor Documentation

◆ AccountManager() [1/3]

QtDataSync::AccountManager::AccountManager ( QObject parent = nullptr)
explicit

Default constructor, uses the default setup.

Parameters
parentThe parent object
Exceptions
SetupDoesNotExistExceptionThrown if the default setup was not created yet

◆ AccountManager() [2/3]

QtDataSync::AccountManager::AccountManager ( const QString setupName,
QObject parent = nullptr 
)
explicit

Constructor with an explicit setup.

Parameters
setupNameThe name of the setup to connect to
parentThe parent object
Exceptions
SetupDoesNotExistExceptionThrown if the given setup was not created yet

◆ AccountManager() [3/3]

QtDataSync::AccountManager::AccountManager ( QRemoteObjectNode node,
QObject parent = nullptr 
)
explicit

Constructor with a remote object node to connect to.

Parameters
nodeThe remote object node used to connect to the source objects
parentThe parent object

Member Function Documentation

◆ accountAccessGranted

QtDataSync::AccountManager::accountAccessGranted ( const QUuid deviceId,
QPrivateSignal   
)
signal

Is emitted when a device has been granted access to the current account.

Parameters
deviceIdThe device id of the device that has been granted access

This is a private signal. It can be connect to as usual, but can only be emitted by the class it belongs to

Gets emitted when this device accepted the import of another device and sent it the secret keys. Gets only emitted for exports done by this device, not by other devices.

See also
AccountManager::exportAccount, AccountManager::exportAccountTrusted

◆ accountDevices

QtDataSync::AccountManager::accountDevices ( const QList< QtDataSync::DeviceInfo > &  devices,
QPrivateSignal   
)
signal

Is emitted when the accounts devices have been sent by the server.

Parameters
devicesThe devices that currently belong to the current account

This is a private signal. It can be connect to as usual, but can only be emitted by the class it belongs to

The list does not contain this device, it only shows the other devices that belong to the same account as this one. Gets emitted as reply to listDevices(). In case removeDevice() gets called after listDevices() and the device removed was emitted via this signal, the new list without that device gets emittet as well.

See also
AccountManager::listDevices, AccountManager::removeDevice

◆ changeRemote

QtDataSync::AccountManager::changeRemote ( const RemoteConfig config,
bool  keepData = true 
)
slot

Resets the account and connects to the new remote to create a new one.

Parameters
configThe remote config to be used to connect to the new remote
keepDataSpecify whether the stored data should be preserved

Disconnects you from the current remote, and then tries to connect to the new remote defined by the new config. This operation implicitly performs an account reset. See resetAccount() for more details.

See also
AccountManager::importAccount, AccountManager::importAccountTrusted, AccountManager::resetAccount

◆ exportAccount() [1/2]

QtDataSync::AccountManager::exportAccount ( bool  includeServer,
const std::function< void(QJsonObject)> &  completedFn,
const std::function< void(QString)> &  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

◆ exportAccount() [2/2]

void QtDataSync::AccountManager::exportAccount ( bool  includeServer,
const std::function< void(QByteArray)> &  completedFn,
const std::function< void(QString)> &  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() [1/2]

QtDataSync::AccountManager::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.

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

◆ exportAccountTrusted() [2/2]

void QtDataSync::AccountManager::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.

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

◆ importAccepted

QtDataSync::AccountManager::importAccepted ( QPrivateSignal  )
signal

Is emitted when the partner accept the account import.

This is a private signal. It can be connect to as usual, but can only be emitted by the class it belongs to

Gets emitted when an import completly succeeded, i.e. as soon as the device that export the data accept this device and shared the secret keys with it.

See also
AccountManager::importAccount, AccountManager::importAccountTrusted

◆ importAccount() [1/2]

QtDataSync::AccountManager::importAccount ( const QJsonObject importData,
const std::function< void(bool, QString)> &  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

◆ importAccount() [2/2]

void QtDataSync::AccountManager::importAccount ( const QByteArray importData,
const std::function< void(bool, QString)> &  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() [1/2]

QtDataSync::AccountManager::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.

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

◆ importAccountTrusted() [2/2]

void QtDataSync::AccountManager::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.

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() [1/2]

QtDataSync::AccountManager::isTrustedImport ( const QJsonObject importData)
static

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

◆ isTrustedImport() [2/2]

static bool QtDataSync::AccountManager::isTrustedImport ( const QByteArray importData)
static

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

◆ listDevices

QtDataSync::AccountManager::listDevices ( )
slot

Sends a request to the server to list all devices that belong to the current account.

The request is processed asynchronously. As soon as the server replied, the accountDevices() signal is emitted with all the device that currently belong to the account except the current device that sent the request. This method will do nothing if the remote is not connected.

See also
AccountManager::accountDevices, AccountManager::removeDevice

◆ loginRequested

QtDataSync::AccountManager::loginRequested ( QtDataSync::LoginRequest  request,
QPrivateSignal   
)
signal

Is emitted when another device requests permission to be added to the current account.

Parameters
requestThe login request to be handeled

This is a private signal. It can be connect to as usual, but can only be emitted by the class it belongs to

Gets emitted when a device imports untrusted account data that was exported from this device. Use the passed login request object to get more details about the device and to react to it.

See also
AccountManager::importAccount, AccountManager::exportAccount, LoginRequest

◆ removeDevice [1/2]

QtDataSync::AccountManager::removeDevice ( const QUuid deviceInfo)
slot

Remove the device with the given id from the current account.

Parameters
deviceInfoThe id of the device to be removed

The device is deleted from the account and disconnected from the server if it was connected. This method cannot be used to remove the current device. Use resetAccount() instead. listDevices() was called before this method and the device was part of the account at that time, accountDevices() will be emitted again, now without the removed device. This method will do nothing if the remote is not connected.

Note
After removing a device you should always update the exchange key to prevent the device from accessing the encrypted data. Use updateExchangeKey() to do so.
See also
AccountManager::resetAccount, AccountManager::accountDevices, AccountManager::listDevices, AccountManager::updateExchangeKey

◆ removeDevice [2/2]

QtDataSync::AccountManager::removeDevice ( const QtDataSync::DeviceInfo deviceInfo)
inlineslot

Remove the given device from the current account.

Parameters
deviceInfoThe id of the device to be removed

The device is deleted from the account and disconnected from the server if it was connected. This method cannot be used to remove the current device. Use resetAccount() instead. listDevices() was called before this method and the device was part of the account at that time, accountDevices() will be emitted again, now without the removed device. This method will do nothing if the remote is not connected.

Note
After removing a device you should always update the exchange key to prevent the device from accessing the encrypted data. Use updateExchangeKey() to do so.
See also
AccountManager::resetAccount, AccountManager::accountDevices, AccountManager::listDevices, AccountManager::updateExchangeKey

Definition at line 181 of file accountmanager.h.

◆ replica()

QtDataSync::AccountManager::replica ( ) const

The internal replica used to connect to the engine.

Returns
A pointer to the interal replica object

Returns a reference to the internally used replica which connects to the engine. The replica is only valid as long as the AccountManager exists. You can use the replica reference to get information about it's state etc.

◆ resetAccount

QtDataSync::AccountManager::resetAccount ( bool  keepData = true)
slot

Removes this device from the current account and then creates a new one.

Parameters
keepDataSpecify whether the stored data should be preserved

If connected to the remote, this device is removed from the current account. If the device was the last device in the account, the account gets deleted as well. If the remote is not connected that step is not performed, and other devices will still see this one as part of their account.

Internally, all private encryption and signing keys are permanently deleted and new ones are created. The engine will reconnect to the server and register a completly new account with new ids.

If keepData is false, all local data is deleted. This is basically a full reset. If it is true (the default) then all data is kept.

See also
AccountManager::importAccount, AccountManager::importAccountTrusted, AccountManager::changeRemote

◆ updateExchangeKey

QtDataSync::AccountManager::updateExchangeKey ( )
slot

Generate a new secret exchange key used to encrypt data.

Generates a new exchange key and sends it to all devices of the current account. This key is used to verify that a device belongs to your account and to encrypt data between the devices. Thi method will do nothing if the remote is not connected.

Property Documentation

◆ deviceFingerprint

QtDataSync::AccountManager::deviceFingerprint
read

The fingerprint of the devices cryptographic keys.

Default: Derived from the public keys

The fingerprint is generated as Sha3 with a length of 256bit by hashing the public keys and schemes used. It should not be used to identify a device, but can be used to verify that the keys belong to a device.

Accessors
READdeviceFingerprint()
NOTIFYdeviceFingerprintChanged()
See also
AccountManager::deviceName, DeviceInfo::fingerprint

Definition at line 128 of file accountmanager.h.

◆ deviceName

QtDataSync::AccountManager::deviceName
readwrite

The display name of the device.

Default: QSysInfo::machineHostName()

This name will be displayed on other devices as name for this device, in combination with the fingerprint.

Accessors
READdeviceName()
WRITEsetDeviceName()
RESETresetDeviceName()
NOTIFYdeviceNameChanged()
See also
AccountManager::deviceFingerprint, DeviceInfo::name

Definition at line 126 of file accountmanager.h.

◆ lastError

QtDataSync::AccountManager::lastError
read

The last internal error that occured.

Default: empty

The last error that happend internally. The returned string is a localized string ment to be displayed to a user. There is no need to log such an error, as interally the error has already been logged with even more details. Use this property to inform the user something went wrong.

Accessors
READlastError()
NOTIFYlastErrorChanged()
See also
SyncManager::lastError

Definition at line 130 of file accountmanager.h.

◆ setupName

QtDataSync::AccountManager::setupName
read

Holds the name of the setup this manager operates on.

Default: QtDataSync::DefaultSetup

The setup name is the name that was passed to the Setup::create method to create the datasync instance this manager is refering to.

Accessors
READsetupName()
NOTIFYsetupNameChanged()
REVISION2
See also
QtDataSync::DefaultSetup, Setup::create

Definition at line 124 of file accountmanager.h.


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