Ditto 4.5.3
Loading...
Searching...
No Matches
Ditto.hpp
1#ifndef _DITTO_DITTO_SYNC_KIT_
2#define _DITTO_DITTO_SYNC_KIT_
3
4#include "DiskUsage.hpp"
5#include "Identity.hpp"
6#include "LogLevel.hpp"
7#include "Presence.hpp"
8#include "SmallPeerInfo.hpp"
9
10#include "TransportConfig.hpp"
11
12#include "Helpers.hpp"
13
14#include <memory>
15
16#ifdef __ANDROID__
17#include <jni.h>
18#endif /* __ANDROID__ */
19
20namespace ditto {
21class Authenticator;
22class Store;
23class StoreObserver;
24class Sync;
25class SyncSubscription;
32class Ditto {
33 friend class Authenticator;
34 friend class Store;
35 friend class StoreObserver;
36 friend class Sync;
37 friend class SyncSubscription;
38 friend class ValidityListener;
39
40public:
48 explicit Ditto(
49 std::shared_ptr<Identity> identity = Identity::OfflinePlayground(),
50 std::string persistence_dir = "");
51
52 Ditto(Ditto const &other) = delete;
53 Ditto(Ditto &&other) noexcept;
54 Ditto &operator=(Ditto const &other) = delete;
55 Ditto &operator=(Ditto &&other) noexcept;
56 ~Ditto();
57
64 std::shared_ptr<Authenticator> get_auth() const;
65
71 Store &get_store() const;
72
79
84 Sync &sync() const;
85
91 Presence &get_presence() const;
92
99
106
113 bool get_is_sync_active() const;
114
124 void set_offline_only_license_token(std::string license_token);
125
137 void start_sync() const;
138
145 void stop_sync() const;
146
158 void disable_sync_with_v3() const;
159
170
182 void
183 update_transport_config(std::function<void(TransportConfig &config)> lambda);
184
190 static std::string get_sdk_version();
191
197 static bool get_logging_enabled();
198
205 static void set_logging_enabled(bool enabled);
206
214
221 static void set_emoji_log_level_headings_enabled(bool enabled);
222
228 static LogLevel get_minimum_log_level();
229
237 static void set_minimum_log_level(LogLevel log_level);
238
253 void run_garbage_collection() const;
254
259 std::string get_app_id() const;
260
265 std::string get_persistence_directory() const;
266
273 PresenceObserver observe_peers(PresenceCallback cb);
274
279 void close();
280#ifdef __ANDROID__
292 void set_android_context(JNIEnv *env, jobject context);
293
309 std::vector<std::string> missing_permissions() const;
310
323 jobjectArray missing_permissions_jni_array() const;
324#endif
325
326private:
327 class Fields;
328 std::shared_ptr<Fields> fields;
329 bool is_closable;
330
331 explicit Ditto(std::shared_ptr<Fields> fields);
332
333 void validity_updated(bool web_valid, bool x509_valid) const;
334 void set_is_closable(bool is_closable);
335 std::shared_ptr<DittoHandleWrapper> get_handle_wrapper();
336};
337} // namespace ditto
338
339#endif
Provides access to authentication information and methods for logging on to Ditto Cloud....
Definition Authenticator.hpp:27
Provides an interface to be able to monitor local files.
Definition DiskUsage.hpp:65
Definition Ditto.cpp:40
The entrypoint to the Ditto SDK.
Definition Ditto.hpp:32
static bool get_logging_enabled()
Gets whether or not logging is enabled for Ditto.
Definition Ditto.cpp:345
TransportConfig get_transport_config() const
Returns the current transport config.
Definition Ditto.cpp:273
void stop_sync() const
Stops all network transports.
Definition Ditto.cpp:303
static void set_minimum_log_level(LogLevel log_level)
Sets the minimum log level at which logs should be emitted for Ditto.
Definition Ditto.cpp:361
void set_transport_config(TransportConfig config)
Assign a new transports configuration.
Definition Ditto.cpp:318
void run_garbage_collection() const
Removes all sync metadata for any remote peers which aren't currently connected.
Definition Ditto.cpp:365
void disable_sync_with_v3() const
Explicitly opt-in to disabling the ability to sync with Ditto peers running any version of the SDK in...
Definition Ditto.cpp:313
bool get_is_sync_active() const
Returns a flag indicating whether or not sync is active. Use start_sync to activate sync and stop_syn...
Definition Ditto.cpp:277
static void set_logging_enabled(bool enabled)
Sets whether or not logging is enabled for Ditto.
Definition Ditto.cpp:347
std::string get_app_id() const
Get the Ditto application Id.
Definition Ditto.cpp:442
static bool get_emoji_log_level_headings_enabled()
Gets whether or not emoji log level headings are enabled for Ditto.
Definition Ditto.cpp:351
Sync & sync() const
Provides access to the SDK's sync functionality.
Definition Ditto.cpp:269
DiskUsage & get_disk_usage() const
Provides access to the SDK's disk usage.
Definition Ditto.cpp:271
Presence & get_presence() const
Provides access to the SDK's presence functionality.
Definition Ditto.cpp:440
SmallPeerInfo & get_small_peer_info() const
Provides access to the SDK's Small Peer Info functionality.
Definition Ditto.cpp:265
PresenceObserver observe_peers(PresenceCallback cb)
TODO.
Ditto(std::shared_ptr< Identity > identity=Identity::OfflinePlayground(), std::string persistence_dir="")
Initializes a new Ditto instance.
Definition Ditto.cpp:115
void update_transport_config(std::function< void(TransportConfig &config)> lambda)
Convenience method to update the current transport config of the receiver.
Definition Ditto.cpp:331
void set_offline_only_license_token(std::string license_token)
Activate an offline Ditto instance by setting a license token. You cannot initiate sync on an offline...
Definition Ditto.cpp:240
void close()
Shut down Ditto and release all resources. Must be called before recreating a Ditto instance that use...
Definition Ditto.cpp:465
static LogLevel get_minimum_log_level()
Gets the minimum log level at which logs will be emitted for Ditto.
Definition Ditto.cpp:359
Store & get_store() const
Provides access to the SDK's store functionality.
Definition Ditto.cpp:263
void start_sync() const
Starts the network transports. Ditto will connect to other devices and sync with them where appropria...
Definition Ditto.cpp:279
std::shared_ptr< Authenticator > get_auth() const
Provides access to authentication information and methods for logging on to Ditto Cloud.
Definition Ditto.cpp:261
std::string get_persistence_directory() const
Get the persistence directory used by Ditto to persist data.
Definition Ditto.cpp:450
static void set_emoji_log_level_headings_enabled(bool enabled)
Sets whether or not emoji log level headings are enabled for Ditto.
Definition Ditto.cpp:355
static std::string get_sdk_version()
Returns a string identifying the version of the Ditto SDK.
Definition Ditto.cpp:338
static std::shared_ptr< OfflinePlaygroundIdentity > OfflinePlayground(std::string app_id="", uint64_t site_id=0)
Construct a new OfflinePlaygroundIdentity.
Definition Identity.cpp:25
Definition Presence.hpp:25
The entrypoint for small peer user info collection.
Definition SmallPeerInfo.hpp:18
Provides access to Collections and a write transaction API.
Definition Store.hpp:25
Definition StoreObserver.hpp:45
Definition Sync.hpp:14
A sync subscription configures Ditto to receive updates from remote peers about documents matching th...
Definition SyncSubscription.hpp:18
A configuration object specifying which network transports Ditto should use to sync data.
Definition TransportConfig.hpp:370