Ditto 4.0.1
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 "Store.hpp"
9#include "TransportConfig.hpp"
10
11#include "Helpers.hpp"
12
13#include <memory>
14
15#ifdef __ANDROID__
16#include <jni.h>
17#endif /* __ANDROID__ */
18
19namespace ditto {
20class Authenticator;
21
28class Ditto {
29 friend class Authenticator;
30 friend class ValidityListener;
31
32public:
40 explicit Ditto(
41 std::shared_ptr<Identity> identity = Identity::OfflinePlayground(),
42 std::string persistence_dir = "");
43
44 Ditto(Ditto const &other) = delete;
45 Ditto(Ditto &&other) noexcept;
46 Ditto &operator=(Ditto const &other) = delete;
47 Ditto &operator=(Ditto &&other) noexcept;
48 ~Ditto();
49
56 std::shared_ptr<Authenticator> get_auth() const;
57
63 Store &get_store() const;
64
70 Presence &get_presence() const;
71
78
85
92 bool get_is_sync_active() const;
93
103 void set_offline_only_license_token(std::string license_token);
104
116 void start_sync() const;
117
124 void stop_sync() const;
125
137 void disable_sync_with_v3() const;
138
149
161 void
162 update_transport_config(std::function<void(TransportConfig &config)> lambda);
163
169 static std::string get_sdk_version();
170
176 static bool get_logging_enabled();
177
184 static void set_logging_enabled(bool enabled);
185
193
200 static void set_emoji_log_level_headings_enabled(bool enabled);
201
207 static LogLevel get_minimum_log_level();
208
216 static void set_minimum_log_level(LogLevel log_level);
217
232 void run_garbage_collection() const;
237 std::string get_app_id() const;
242 std::string get_persistence_directory() const;
243
250 PresenceObserver observe_peers(PresenceCallback cb);
251
256 void close();
257#ifdef __ANDROID__
269 void set_android_context(JNIEnv *env, jobject context);
270
286 std::vector<std::string> missing_permissions() const;
287
300 jobjectArray missing_permissions_jni_array() const;
301#endif
302
303private:
304 class Fields;
305 std::shared_ptr<Fields> fields;
306
307 explicit Ditto(std::shared_ptr<Fields> fields);
308
309 void validity_updated(bool web_valid, bool x509_valid) const;
310};
311} // namespace ditto
312
313#endif
Provides access to authentication information and methods for logging on to Ditto Cloud....
Definition: Authenticator.hpp:26
Provides an interface to be able to monitor local files.
Definition: DiskUsage.hpp:65
Definition: Ditto.cpp:34
The entrypoint to the Ditto SDK.
Definition: Ditto.hpp:28
static bool get_logging_enabled()
Gets whether or not logging is enabled for Ditto.
Definition: Ditto.cpp:283
TransportConfig get_transport_config() const
Returns the current transport config.
Definition: Ditto.cpp:216
void stop_sync() const
Stops all network transports.
Definition: Ditto.cpp:246
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:299
void set_transport_config(TransportConfig config)
Assign a new transports configuration.
Definition: Ditto.cpp:261
void run_garbage_collection() const
Removes all sync metadata for any remote peers which aren't currently connected.
Definition: Ditto.cpp:303
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:256
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:220
static void set_logging_enabled(bool enabled)
Sets whether or not logging is enabled for Ditto.
Definition: Ditto.cpp:285
std::string get_app_id() const
Get the Ditto application Id.
Definition: Ditto.cpp:380
static bool get_emoji_log_level_headings_enabled()
Gets whether or not emoji log level headings are enabled for Ditto.
Definition: Ditto.cpp:289
DiskUsage & get_disk_usage() const
Provides access to the SDK's disk usage.
Definition: Ditto.cpp:214
Presence & get_presence() const
Provides access to the SDK's presence functionality.
Definition: Ditto.cpp:378
PresenceObserver observe_peers(PresenceCallback cb)
TODO.
void update_transport_config(std::function< void(TransportConfig &config)> lambda)
Convenience method to update the current transport config of the receiver.
Definition: Ditto.cpp:269
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:189
void close()
Shut down Ditto and release all resources. Must be called before recreating a Ditto instance that use...
Definition: Ditto.cpp:386
static LogLevel get_minimum_log_level()
Gets the minimum log level at which logs will be emitted for Ditto.
Definition: Ditto.cpp:297
Store & get_store() const
Provides access to the SDK's store functionality.
Definition: Ditto.cpp:212
void start_sync() const
Starts the network transports. Ditto will connect to other devices and sync with them where appropria...
Definition: Ditto.cpp:222
std::shared_ptr< Authenticator > get_auth() const
Provides access to authentication information and methods for logging on to Ditto Cloud.
Definition: Ditto.cpp:210
std::string get_persistence_directory() const
Get the persistence directory used by Ditto to persist data.
Definition: Ditto.cpp:382
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:293
static std::string get_sdk_version()
Returns a string identifying the version of the Ditto SDK.
Definition: Ditto.cpp:276
static std::shared_ptr< OfflinePlaygroundIdentity > OfflinePlayground(std::string app_id="", uint64_t site_id=0)
Construct a new OfflinePlaygroundIdentity.
Definition: Identity.cpp:38
Definition: Presence.hpp:25
Provides access to Collections and a write transaction API.
Definition: Store.hpp:21
A configuration object specifying which network transports Ditto should use to sync data.
Definition: TransportConfig.hpp:318