Skip to content
This repository was archived by the owner on Mar 4, 2023. It is now read-only.

Commit 6bf09fb

Browse files
committed
updated doc
1 parent 739b25d commit 6bf09fb

File tree

8 files changed

+124
-5
lines changed

8 files changed

+124
-5
lines changed

doc/asyncdatastore.dox

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ objects after the operations have been completed.
2828
@sa CachingDataStore
2929
*/
3030

31+
/*!
32+
@fn QtDataSync::AsyncDataStore::iterate(const std::function<bool(T)> &, const std::function<void(const QException &)> &)
33+
34+
@param iterator The iterator to be called for each dataset loaded
35+
@param onExcept A handler to be called if reading fails at some point
36+
37+
Inernally, the store will load one dataset after another, and call iterator with the result.
38+
You can return `true` to continue iterating, or `false` to cancel prematurely. The exception
39+
handler is passed to to the Tasks internally used.
40+
41+
@sa Task
42+
*/
43+
44+
/*!
45+
@fn QtDataSync::AsyncDataStore::iterate(int, const std::function<bool(QVariant)> &, const std::function<void(const QException &)> &)
46+
47+
@param metaTypeId The type of datasets to iterate over
48+
@copydetails AsyncDataStore::iterate(const std::function<bool(T)> &, const std::function<void(const QException &)> &)
49+
*/
50+
3151
/*!
3252
@fn QtDataSync::AsyncDataStore::dataChanged
3353

doc/authenticator.dox

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RemoteConnector::createAuthenticator
1515

1616
@param extraData Additional data that is passed to the remote connector, e.g. a password
1717
@param resetLocalStore Specifies, whether the local store should be reset or not
18-
@returns A task to wait on for the completition of the reset.
18+
@returns A task to wait on for the completition of the reset
1919

2020
If you need to perform an operation that will change the currently logged in user, reset his
2121
device identity or somthing similiar, that changes his "identity", use this method. Use the
@@ -29,3 +29,37 @@ use this approach.
2929

3030
@sa RemoteConnector::resetUserId, RemoteConnector::resetUserData
3131
*/
32+
33+
/*!
34+
@fn QtDataSync::Authenticator::exportUserDataImpl
35+
36+
@param device The device to write the exported data to
37+
38+
This method should export all of a users "identity" data. This includes all the keys, ids and
39+
more that are needed to properly synchronize and identify. it's internally called by
40+
exportUserData().
41+
42+
It must be possible to login the user on a different device by exporting data with this method
43+
and importing it with importUserData(). No additional information should be required. (The only
44+
exption beeing a "password". It's up to your implemetation If you want to export passwords too,
45+
or require the user to provide it)
46+
47+
@sa Authenticator::exportUserData, Authenticator::importUserDataImpl
48+
*/
49+
50+
/*!
51+
@fn QtDataSync::Authenticator::importUserDataImpl
52+
53+
@param device The device to read the data to import from
54+
@returns A task to wait on for the completition of the import
55+
56+
This method should import all of a users "identity" data from the given device, that was
57+
previously exported by exportUserData(). it's internally called by importUserData().
58+
59+
It must be possible to login the user on a different device by exporting data and importing it
60+
on the device with this methods. No additional information should be required. (The only
61+
exption beeing a "password". It's up to your implemetation If you want to export passwords too,
62+
or require the user to provide it)
63+
64+
@sa Authenticator::importUserData, Authenticator::exportUserDataImpl
65+
*/

doc/encryptor.dox

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*!
2+
@class QtDataSync::Encryptor
3+
4+
It is used by the datasync engine to encrypt user data before it is sent to the server, and
5+
decrypt the data loaded from the server. It provides an abstract interface to perform encryption
6+
with whatever algorithm you want to use. The default implementation uses [QTinyAes](https://github.com/Skycoder42/QTinyAes),
7+
a Qt wrapper around [tiny-AES128-C](https://github.com/kokke/tiny-AES128-C).
8+
9+
If you implement the methods, you must do it synchronously. Since the datasync instance
10+
engine, as well as this holder, run on their own thread, you won't block the ui.
11+
12+
@attention The encryptor is constructed on the main thread, and then later moved to the datasync
13+
instance thread. The initialize() function is the first to be called after changing the thread.
14+
You should do nothing in the constructor, and all the initialization inside of that function,
15+
to ensure a fast and smooth usage.
16+
17+
@sa Setup::setEncryptor, Setup::encryptor, RemoteConnector::cryptor
18+
*/
19+
20+
/*!
21+
@fn QtDataSync::Encryptor::encrypt
22+
23+
@param key The object key (type and key) of the object to be encrypted
24+
@param object The object to be encrypted
25+
@param keyProperty The property of the object that is the key property (the USER-property)
26+
@returns The encrypted data, wrapped inside a json value
27+
@throws QException If encryption failed
28+
29+
@sa Encryptor::decrypt, RemoteConnector::upload
30+
*/
31+
32+
/*!
33+
@fn QtDataSync::Encryptor::decrypt
34+
35+
@param key The object key (type and key) of the object to be decrypted
36+
@param data The encrypted data, wrapped inside a json value
37+
@param keyProperty The property of the object that is the key property (the USER-property)
38+
@returns The decrypted json object
39+
@throws QException If decryption failed
40+
41+
@sa Encryptor::encrypt, RemoteConnector::download
42+
*/

doc/remoteconnector.dox

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ the object. Since the object already contains the key (as the keyProperty proper
8585
can simply check the value of that property as the key. You do not have to use this property,
8686
but you can. One example would be a document store.
8787

88+
@attention If cryptor() is valid, you should use the encryptor to decrypt the received data.
89+
Of course that is only if your implementation encrypts data as well.
90+
8891
The result of this operation must be reported by calling operationDone(). The result
8992
parameter must be the downloaded json object, passed via the json value.
9093

9194
If your operation fails, emit operationFailed() with an error message.
9295

93-
@sa RemoteConnector::operationDone, RemoteConnector::operationFailed
96+
@sa RemoteConnector::operationDone, RemoteConnector::operationFailed,
97+
RemoteConnector::cryptor, Encryptor::encrypt
9498
*/
9599

96100
/*!
@@ -105,6 +109,9 @@ the object. Since the object already contains the key (as the keyProperty proper
105109
can simply save the object only, and use the key property for indexing etc. One example would
106110
be a document store.
107111

112+
@attention If cryptor() is valid, you should use the encryptor to encrypt the `object` before
113+
sending it to the server
114+
108115
The result of this operation must be reported by calling operationDone(). The result
109116
parameter is ignored, you can set it to QJsonValue::Undefined.
110117

@@ -115,7 +122,7 @@ client. The server should implicitly do the same as for a markUnchanged() operat
115122
uploading.
116123

117124
@sa RemoteConnector::operationDone, RemoteConnector::operationFailed,
118-
RemoteConnector::markUnchanged
125+
RemoteConnector::markUnchanged, RemoteConnector::cryptor, Encryptor::encrypt
119126
*/
120127

121128
/*!

doc/task.dox

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@ the future has finished, the handlers will *not* be called anymore.
3939
@param parent The parent object to bind the handlers to
4040
@copydetails Task::onResult(const std::function<void(QVariant)> &, const std::function<void(const QException &)> &)
4141
*/
42+
43+
/*!
44+
@class QtDataSync::UpdateTask
45+
46+
Instead of creating a new object for the loaded data, this class will be given an existing
47+
instance of the target object type. The result and onResult methods do not return a new object,
48+
instead they update the existing object to the result of the task. This way pointer classes
49+
can be easily updated, without having to exchange the references everywhere. The task is used
50+
by AsyncDataStore::loadInto.
51+
52+
@sa AsyncDataStore::loadInto
53+
*/

src/datasync/authenticator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class Q_DATASYNC_EXPORT Authenticator : public QObject
3737
//! Call this method to reset the users identity.
3838
GenericTask<void> resetIdentity(const QVariant &extraData = {}, bool resetLocalStore = true);
3939

40+
//! Implements the user data export
4041
virtual void exportUserDataImpl(QIODevice *device) const = 0;
42+
//! Implements the user data import
4143
virtual GenericTask<void> importUserDataImpl(QIODevice *device) = 0;
4244

4345
//! Returns a reference to the connector this authenticator belongs to

src/datasync/encryptor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace QtDataSync {
1010

11+
//! The class responsible for en/decrypting user data before exchaning it with the remote
1112
class Encryptor : public QObject
1213
{
1314
Q_OBJECT
@@ -28,7 +29,7 @@ class Encryptor : public QObject
2829

2930
//! Encrypts the given dataset
3031
virtual QJsonValue encrypt(const ObjectKey &key, const QJsonObject &object, const QByteArray &keyProperty) const = 0;
31-
//! Encrypts the given dataset
32+
//! Decrypts the given dataset
3233
virtual QJsonObject decrypt(const ObjectKey &key, const QJsonValue &data, const QByteArray &keyProperty) const = 0;
3334
};
3435

src/datasync/task.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,15 @@ class Q_DATASYNC_EXPORT GenericTask<void> : public Task
8989
};
9090

9191
template <typename T>
92+
//! Generic Task that updates an existing dataset instead of creating a new one (objects only)
9293
class UpdateTask : public Task
9394
{
9495
static_assert(std::is_base_of<QObject, typename std::remove_pointer<T>::type>::value, "T must inherit QObject");
9596

9697
friend class AsyncDataStore;
9798

9899
public:
99-
//! Constructor with future interface
100+
//! Constructor with future interface and the dataset to be updated
100101
UpdateTask(T data, QFutureInterface<QVariant> d = {});
101102

102103
//! @copydoc Task::onResult(QObject *, const std::function<void(QVariant)> &, const std::function<void(const QException &)> &)

0 commit comments

Comments
 (0)