Ditto 3.0.0-alpha1
Ditto.hpp
1#ifndef _DITTO_DITTO_SYNC_KIT_
2#define _DITTO_DITTO_SYNC_KIT_
3
4#include "Identity.hpp"
5#include "LogLevel.hpp"
6#include "Presence.hpp"
7#include "Store.hpp"
8#include "TransportConfig.hpp"
9
10#include "Helpers.hpp"
11
12#include <memory>
13
14#ifdef __ANDROID__
15#include <jni.h>
16#endif /* __ANDROID__ */
17
18namespace ditto {
19class Authenticator;
20
27class Ditto {
28 friend class Authenticator;
29 friend class ValidityListener;
30
31public:
39 explicit Ditto(
40 std::shared_ptr<Identity> identity = Identity::OfflinePlayground(),
41 std::string persistence_dir = "");
42
43 Ditto(Ditto const &other) = delete;
44 Ditto(Ditto &&other) noexcept;
45 Ditto &operator=(Ditto const &other) = delete;
46 Ditto &operator=(Ditto &&other) noexcept;
47 ~Ditto();
48
55 std::shared_ptr<Authenticator> get_auth() const;
56
62 Store &get_store() const;
63
69 Presence &get_presence() const;
70
77
84 bool get_is_sync_active() const;
85
95 void set_offline_only_license_token(std::string license_token);
96
108 void start_sync() const;
109
116 void stop_sync() const;
117
129 void disable_sync_with_v2() const;
130
141
153 void
154 update_transport_config(std::function<void(TransportConfig &config)> lambda);
155
161 static std::string get_sdk_version();
162
168 static bool get_logging_enabled();
169
176 static void set_logging_enabled(bool enabled);
177
185
192 static void set_emoji_log_level_headings_enabled(bool enabled);
193
199 static LogLevel get_minimum_log_level();
200
208 static void set_minimum_log_level(LogLevel log_level);
209
224 void run_garbage_collection() const;
229 std::string get_app_id() const;
234 std::string get_persistence_directory() const;
235
242 PresenceObserver observe_peers(PresenceCallback cb);
243
244#ifdef __ANDROID__
256 void set_android_context(JNIEnv *env, jobject context);
257
273 std::vector<std::string> missing_permissions() const;
274
287 jobjectArray missing_permissions_jni_array() const;
288#endif
289
290private:
291 class Fields;
292 std::shared_ptr<Fields> fields;
293
294 explicit Ditto(std::shared_ptr<Fields> fields);
295
296 void validity_updated(bool web_valid, bool x509_valid) const;
297};
298} // namespace ditto
299
300#endif
Provides access to authentication information and methods for logging on to Ditto Cloud....
Definition: Authenticator.hpp:26
Definition: Ditto.cpp:35
The entrypoint to the Ditto SDK.
Definition: Ditto.hpp:27
static bool get_logging_enabled()
Gets whether or not logging is enabled for Ditto.
Definition: Ditto.cpp:284
TransportConfig get_transport_config() const
Returns the current transport config.
Definition: Ditto.cpp:217
void stop_sync() const
Stops all network transports.
Definition: Ditto.cpp:247
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:300
void set_transport_config(TransportConfig config)
Assign a new transports configuration.
Definition: Ditto.cpp:262
void run_garbage_collection() const
Removes all sync metadata for any remote peers which aren't currently connected.
Definition: Ditto.cpp:304
void disable_sync_with_v2() const
Explicitly opt-in to disabling the ability to sync with Ditto peers running any version of the SDK in...
Definition: Ditto.cpp:257
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:221
static void set_logging_enabled(bool enabled)
Sets whether or not logging is enabled for Ditto.
Definition: Ditto.cpp:286
std::string get_app_id() const
Get the Ditto application Id.
Definition: Ditto.cpp:381
static bool get_emoji_log_level_headings_enabled()
Gets whether or not emoji log level headings are enabled for Ditto.
Definition: Ditto.cpp:290
Presence & get_presence() const
Provides access to the SDK's presence functionality.
Definition: Ditto.cpp:379
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:97
void update_transport_config(std::function< void(TransportConfig &config)> lambda)
Convenience method to update the current transport config of the receiver.
Definition: Ditto.cpp:270
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:192
static LogLevel get_minimum_log_level()
Gets the minimum log level at which logs will be emitted for Ditto.
Definition: Ditto.cpp:298
Store & get_store() const
Provides access to the SDK's store functionality.
Definition: Ditto.cpp:215
void start_sync() const
Starts the network transports. Ditto will connect to other devices and sync with them where appropria...
Definition: Ditto.cpp:223
std::shared_ptr< Authenticator > get_auth() const
Provides access to authentication information and methods for logging on to Ditto Cloud.
Definition: Ditto.cpp:213
std::string get_persistence_directory() const
Get the persistence directory used by Ditto to persist data.
Definition: Ditto.cpp:383
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:294
static std::string get_sdk_version()
Returns a string identifying the version of the Ditto SDK.
Definition: Ditto.cpp:277
static std::shared_ptr< OfflinePlaygroundIdentity > OfflinePlayground(std::string app_id="", uint64_t site_id=0)
Construct a new OfflinePlaygroundIdentity.
Definition: Identity.cpp:36
Definition: Presence.hpp:25
Provides access to Collections and a write transaction API.
Definition: Store.hpp:20
A configuration object specifying which network transports Ditto should use to sync data.
Definition: TransportConfig.hpp:256