1 #ifndef QTDATASYNC_ACCOUNTMANAGER_H 2 #define QTDATASYNC_ACCOUNTMANAGER_H 6 #include <QtCore/qobject.h> 7 #include <QtCore/quuid.h> 8 #include <QtCore/qshareddata.h> 9 #include <QtCore/qlist.h> 10 #include <QtCore/qiodevice.h> 11 #include <QtCore/qsharedpointer.h> 12 #include <QtCore/qjsonobject.h> 14 #include "QtDataSync/qtdatasync_global.h" 15 #include "QtDataSync/remoteconfig.h" 22 class DeviceInfoPrivate;
29 Q_PROPERTY(
QUuid deviceId READ deviceId WRITE setDeviceId)
31 Q_PROPERTY(
QString name READ name WRITE setName)
33 Q_PROPERTY(
QByteArray fingerprint READ fingerprint WRITE setFingerprint)
52 QUuid deviceId() const;
59 void setDeviceId(const
QUuid &deviceId);
61 void setName(const
QString &name);
63 void setFingerprint(const
QByteArray &fingerprint);
66 bool operator==(const
DeviceInfo &other) const;
68 bool operator!=(const
DeviceInfo &other) const;
77 class LoginRequestPrivate;
87 Q_PROPERTY(
bool handled READ handled CONSTANT)
106 bool handled() const;
109 Q_INVOKABLE
void accept();
111 Q_INVOKABLE
void reject();
117 class AccountManagerPrivateHolder;
124 Q_PROPERTY(
QString setupName READ setupName NOTIFY setupNameChanged REVISION 2)
126 Q_PROPERTY(
QString deviceName READ deviceName WRITE setDeviceName RESET resetDeviceName NOTIFY deviceNameChanged)
128 Q_PROPERTY(
QByteArray deviceFingerprint READ deviceFingerprint NOTIFY deviceFingerprintChanged)
130 Q_PROPERTY(
QString lastError READ lastError NOTIFY lastErrorChanged)
145 static
bool isTrustedImport(const
QJsonObject &importData);
147 static
bool isTrustedImport(const
QByteArray &importData);
150 void exportAccount(
bool includeServer, const
std::function<
void(
QJsonObject)> &completedFn, const
std::function<
void(
QString)> &errorFn = {});
152 void exportAccount(
bool includeServer,
const std::function<
void(
QByteArray)> &completedFn,
const std::function<
void(
QString)> &errorFn = {});
154 void exportAccountTrusted(
bool includeServer,
const QString &password,
const std::function<
void(
QJsonObject)> &completedFn,
const std::function<
void(
QString)> &errorFn = {});
156 void exportAccountTrusted(
bool includeServer,
const QString &password,
const std::function<
void(
QByteArray)> &completedFn,
const std::function<
void(
QString)> &errorFn = {});
158 void importAccount(
const QJsonObject &importData,
const std::function<
void(
bool,
QString)> &completedFn,
bool keepData =
false);
160 void importAccount(
const QByteArray &importData,
const std::function<
void(
bool,
QString)> &completedFn,
bool keepData =
false);
162 void importAccountTrusted(
const QJsonObject &importData,
const QString &password,
const std::function<
void(
bool,
QString)> &completedFn,
bool keepData =
false);
164 void importAccountTrusted(
const QByteArray &importData,
const QString &password,
const std::function<
void(
bool,
QString)> &completedFn,
bool keepData =
false);
179 void removeDevice(
const QUuid &deviceInfo);
182 removeDevice(deviceInfo.
deviceId());
185 void resetAccount(
bool keepData =
true);
187 void changeRemote(
const RemoteConfig &config,
bool keepData =
true);
190 void updateExchangeKey();
193 void setDeviceName(
const QString &deviceName);
195 void resetDeviceName();
203 void importAccepted(QPrivateSignal);
205 void accountAccessGranted(
const QUuid &deviceId, QPrivateSignal);
208 QT_DATASYNC_REVISION_2
void setupNameChanged(
const QString &setupName, QPrivateSignal);
210 void deviceNameChanged(
const QString &deviceName, QPrivateSignal);
212 void deviceFingerprintChanged(
const QByteArray &deviceFingerprint, QPrivateSignal);
214 void lastErrorChanged(
const QString &lastError, QPrivateSignal);
220 void initReplica(
const QString &setupName);
226 void accountExportError(
const QUuid &
id,
const QString &errorString);
227 void accountImportResult(
bool success,
const QString &error);
228 void loginRequestedImpl(
const DeviceInfo &deviceInfo);
255 Q_DECLARE_METATYPE(QtDataSync::JsonObject)
260 #endif // QTDATASYNC_ACCOUNTMANAGER_H
Manages devices that belong to the users account.
A login request done by another device to this device.
QUuid deviceId
The unique id that device is identified by.
Information about a device that is part of an account or wants to be added.
Q_DATASYNC_EXPORT QDataStream & operator<<(QDataStream &stream, const DeviceInfo &deviceInfo)
Stream operator to stream into a QDataStream.
The primary namespace of the QtDataSync library.
Q_DATASYNC_EXPORT QDataStream & operator>>(QDataStream &stream, DeviceInfo &deviceInfo)
Stream operator to stream out of a QDataStream.
A configuration on how to connect to a remote server.
void removeDevice(const QtDataSync::DeviceInfo &deviceInfo)
Remove the given device from the current account.