@dittolive/ditto 4.10.0-rc.1 → 4.10.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +2 -2
  2. package/node/ditto.cjs.js +1 -1
  3. package/node/ditto.darwin-arm64.node +0 -0
  4. package/node/ditto.darwin-x64.node +0 -0
  5. package/node/ditto.linux-arm64.node +0 -0
  6. package/node/ditto.linux-x64.node +0 -0
  7. package/node/ditto.win32-x64.node +0 -0
  8. package/package.json +1 -1
  9. package/react-native/android/dittoffi/src/attachment_observer_interfaces.cpp +1 -0
  10. package/react-native/android/dittoffi/src/attachment_observer_interfaces.h +75 -0
  11. package/react-native/android/dittoffi/src/bus.cpp +1 -0
  12. package/react-native/android/dittoffi/src/bus.h +414 -0
  13. package/react-native/android/dittoffi/src/connection_request.cpp +1 -0
  14. package/react-native/android/dittoffi/src/connection_request.h +56 -0
  15. package/react-native/android/dittoffi/src/crash_reporter.cpp +1 -0
  16. package/react-native/android/dittoffi/src/crash_reporter.h +40 -0
  17. package/react-native/android/dittoffi/src/dittoffi.h +5006 -0
  18. package/react-native/android/dittoffi/src/dittoffi_java.cpp +34299 -0
  19. package/react-native/android/dittoffi/src/dittoffi_java.h +341 -0
  20. package/react-native/android/dittoffi/src/dittoffi_java.i +42 -0
  21. package/react-native/android/dittoffi/src/dittomesh_java.i +47 -0
  22. package/react-native/android/dittoffi/src/dittostore_java.i +476 -0
  23. package/react-native/android/dittoffi/src/ifaddrs.cpp +385 -0
  24. package/react-native/android/dittoffi/src/ifaddrs.h +206 -0
  25. package/react-native/android/dittoffi/src/live_query_java_interfaces.cpp +1 -0
  26. package/react-native/android/dittoffi/src/live_query_java_interfaces.h +64 -0
  27. package/react-native/android/dittoffi/src/logger_cb.cpp +3 -0
  28. package/react-native/android/dittoffi/src/logger_cb.h +47 -0
  29. package/react-native/android/dittoffi/src/logger_export.cpp +1 -0
  30. package/react-native/android/dittoffi/src/logger_export.h +37 -0
  31. package/react-native/android/dittoffi/src/mesh_java_interfaces.cpp +1 -0
  32. package/react-native/android/dittoffi/src/mesh_java_interfaces.h +690 -0
  33. package/react-native/android/dittoffi/src/presence.cpp +1 -0
  34. package/react-native/android/dittoffi/src/presence.h +82 -0
  35. package/react-native/android/dittoffi/src/retainable.cpp +1 -0
  36. package/react-native/android/dittoffi/src/retainable.h +47 -0
  37. package/react-native/android/dittoffi/src/store_observer.cpp +1 -0
  38. package/react-native/android/dittoffi/src/store_observer.h +57 -0
  39. package/react-native/ditto.es6.js +1 -1
  40. package/support/ditto-logo-96x96.png +0 -0
  41. package/web/ditto.es6.js +1 -1
  42. package/web/ditto.umd.js +1 -1
  43. package/web/ditto.wasm +0 -0
package/README.md CHANGED
@@ -3,10 +3,10 @@
3
3
  _Ditto is a cross-platform SDK that allows mobile, web, and IoT apps to sync
4
4
  with and even without connectivity._
5
5
 
6
- Version: **4.10.0-rc.1**
6
+ Version: **4.10.0-rc.3**
7
7
 
8
8
  For more information please visit [ditto.live](https://ditto.live), as well as the
9
- [API Reference](https://software.ditto.live/js/Ditto/4.10.0-rc.1/api-reference/) for this particular version.
9
+ [API Reference](https://software.ditto.live/js/Ditto/4.10.0-rc.3/api-reference/) for this particular version.
10
10
 
11
11
  ---
12
12
 
package/node/ditto.cjs.js CHANGED
@@ -2174,7 +2174,7 @@ class AttachmentToken {
2174
2174
 
2175
2175
  // NOTE: this is patched up with the actual build version by Jake task
2176
2176
  // build:package and has to be a valid semantic version as defined here: https://semver.org.
2177
- const fullBuildVersionString = '4.10.0-rc.1';
2177
+ const fullBuildVersionString = '4.10.0-rc.3';
2178
2178
 
2179
2179
  //
2180
2180
  // Copyright © 2021 DittoLive Incorporated. All rights reserved.
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dittolive/ditto",
3
- "version": "4.10.0-rc.1",
3
+ "version": "4.10.0-rc.3",
4
4
  "description": "Ditto is a cross-platform SDK that allows apps to sync with and even without internet connectivity.",
5
5
  "homepage": "https://ditto.live",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -0,0 +1 @@
1
+ #include "attachment_observer_interfaces.h"
@@ -0,0 +1,75 @@
1
+ extern "C" {
2
+ #include "dittoffi.h"
3
+ }
4
+
5
+ #include "retainable.h"
6
+
7
+ #ifdef SWIG
8
+ %feature("director", assumeoverride=1) AttachmentObserverRust;
9
+ %apply(char *STRING, size_t LENGTH) { (const unsigned char *id_ptr, uintptr_t id_len) };
10
+ #endif
11
+ class AttachmentObserverRust: public Retainable {
12
+ public:
13
+ virtual ~AttachmentObserverRust() {}
14
+ virtual void completedEventHandler(
15
+ const struct AttachmentHandle *ah
16
+ ) = 0;
17
+
18
+ virtual void progressEventHandler(
19
+ uint64_t downloadedBytes,
20
+ uint64_t totalBytes
21
+ ) = 0;
22
+
23
+ virtual void deletedEventHandler(
24
+ ) = 0;
25
+
26
+ static void invokeCompletedEventHandler(
27
+ void *ctx,
28
+ struct AttachmentHandle *ah
29
+ ) {
30
+ auto inst = static_cast<AttachmentObserverRust*>(ctx);
31
+ return inst->completedEventHandler(
32
+ ah
33
+ );
34
+ }
35
+
36
+ static void invokeProgressEventHandler(
37
+ void *ctx,
38
+ uint64_t downloadedBytes,
39
+ uint64_t totalBytes
40
+ ) {
41
+ auto inst = static_cast<AttachmentObserverRust*>(ctx);
42
+ return inst->progressEventHandler(
43
+ downloadedBytes,
44
+ totalBytes
45
+ );
46
+ }
47
+
48
+ static void invokeDeletedEventHandler(
49
+ void *ctx
50
+ ) {
51
+ auto inst = static_cast<AttachmentObserverRust*>(ctx);
52
+ return inst->deletedEventHandler(
53
+ );
54
+ }
55
+
56
+ virtual CancelTokenResult_t resolve_attachment(
57
+ struct CDitto *ditto_raw,
58
+ const unsigned char *id_ptr,
59
+ uintptr_t id_len
60
+ ) {
61
+ return ditto_resolve_attachment(
62
+ ditto_raw,
63
+ (slice_ref_uint8_t) {
64
+ .ptr = id_ptr,
65
+ .len = id_len,
66
+ },
67
+ this,
68
+ AttachmentObserverRust::invokeRetain,
69
+ AttachmentObserverRust::invokeRelease,
70
+ AttachmentObserverRust::invokeCompletedEventHandler,
71
+ AttachmentObserverRust::invokeProgressEventHandler,
72
+ AttachmentObserverRust::invokeDeletedEventHandler
73
+ );
74
+ }
75
+ };
@@ -0,0 +1 @@
1
+ #include "bus.h"
@@ -0,0 +1,414 @@
1
+ #ifdef DITTOFFI_EXPERIMENTAL_BUS
2
+ #include <cstring>
3
+ #include <stdexcept>
4
+ #include <vector>
5
+
6
+ extern "C" {
7
+ #include "dittoffi.h"
8
+ #include "retainable.h"
9
+ }
10
+ #ifdef SWIG
11
+ %include <swigmove.i>
12
+ %include <std_string.i>
13
+ %feature("director", assumeoverride=1, allprotected=0) AcceptorSwig;
14
+ %feature("director", assumeoverride=1, allprotected=0) InboundCallbackSwig;
15
+ %feature("director", assumeoverride=1, allprotected=0) StreamCandidateCallbackSwig;
16
+ %feature("director", assumeoverride=1, allprotected=0) ConnectionResultCallbackSwig;
17
+ %feature("director", assumeoverride=1, allprotected=0) SendStatusCallbackSwig;
18
+ %feature("director", assumeoverride=1, allprotected=0) StreamStatusCallbackSwig;
19
+ %feature("director", assumeoverride=1, allprotected=0) BusSwig;
20
+ #endif
21
+ class PeerPubkeySwig {
22
+ void_const_ptr_2_array_t pubkey;
23
+
24
+ public:
25
+ explicit PeerPubkeySwig(char const *peer_key_str) noexcept(false)
26
+ : pubkey({}) {
27
+ slice_ref_uint8_t slice = {.ptr = (const uint8_t *)peer_key_str,
28
+ .len = strlen(peer_key_str)};
29
+ auto parsed = dittoffi_peer_pubkey_from_str(slice);
30
+ if (!parsed._0) {
31
+ throw std::runtime_error("Failed to parse pubkey");
32
+ }
33
+ pubkey = parsed._1;
34
+ }
35
+
36
+ explicit PeerPubkeySwig(void_const_ptr_2_array_t key) noexcept
37
+ : pubkey(key) {}
38
+
39
+ ~PeerPubkeySwig() noexcept { dittoffi_peer_pubkey_delete(pubkey); }
40
+
41
+ std::string to_string() noexcept {
42
+ auto s = dittoffi_peer_pubkey_to_cstr(&pubkey);
43
+ std::string result((const char *)s.ptr, s.len);
44
+ return result;
45
+ }
46
+ };
47
+
48
+ class TopicSwig {
49
+ Topic_t topic;
50
+
51
+ public:
52
+ explicit TopicSwig(Topic_t topic) noexcept : topic(topic) {}
53
+
54
+ std::string to_string() noexcept {
55
+ std::string result((const char *)&this->topic.buffer, this->topic.len);
56
+ return result;
57
+ }
58
+ };
59
+
60
+ class AcceptorSwig {
61
+ Acceptor_t acceptor;
62
+
63
+ public:
64
+ explicit AcceptorSwig(Acceptor_t acceptor) noexcept : acceptor(acceptor) {}
65
+
66
+ AcceptorSwig(AcceptorSwig &&other) noexcept : acceptor(other.acceptor) {
67
+ other.acceptor.inner.ptr = nullptr;
68
+ }
69
+
70
+ AcceptorSwig(AcceptorSwig const &other) noexcept : acceptor(other.acceptor) {
71
+ acceptor.inner.vtable.retain_vptr(acceptor.inner.ptr);
72
+ }
73
+
74
+ virtual ~AcceptorSwig() noexcept {
75
+ if (acceptor.inner.ptr != nullptr) {
76
+ acceptor.inner.vtable.release_vptr(acceptor.inner.ptr);
77
+ }
78
+ }
79
+
80
+ virtual TopicSwig topic() noexcept {
81
+ return TopicSwig(acceptor.inner.vtable.topic(acceptor.inner.ptr));
82
+ }
83
+
84
+ virtual Reliability reliability() noexcept {
85
+ return static_cast<Reliability>(
86
+ acceptor.inner.vtable.reliability(acceptor.inner.ptr));
87
+ }
88
+ };
89
+
90
+ class BytesSwig {
91
+ Bytes_t bytes;
92
+
93
+ public:
94
+ explicit BytesSwig(slice_ref_uint8_t slice) noexcept
95
+ : bytes(dittoffi_bytes_copied_from_slice(slice)) {}
96
+
97
+ explicit BytesSwig(Bytes_t bytes) noexcept : bytes(bytes) {}
98
+
99
+ BytesSwig(BytesSwig &&other) noexcept : bytes(other.bytes) {
100
+ other.bytes.vtable = nullptr;
101
+ }
102
+
103
+ BytesSwig(BytesSwig const &other) noexcept
104
+ : bytes(dittoffi_bytes_clone(&other.bytes)) {}
105
+
106
+ BytesSwig &operator=(BytesSwig const &other) noexcept = default;
107
+
108
+ Bytes_t take() noexcept {
109
+ auto result = bytes;
110
+ bytes.vtable = nullptr;
111
+ return result;
112
+ }
113
+
114
+ slice_ref_uint8_t data() const noexcept {
115
+ return {.ptr = bytes.start, .len = bytes.len};
116
+ }
117
+
118
+ virtual ~BytesSwig() noexcept {
119
+ if (bytes.vtable != nullptr) {
120
+ dittoffi_bytes_drop(&bytes);
121
+ }
122
+ }
123
+ };
124
+
125
+ class SendStatusCallbackSwig : public Retainable {
126
+ public:
127
+ virtual void call(SendStatus data) noexcept = 0;
128
+
129
+ virtual void drop() noexcept = 0;
130
+
131
+ static void invokeCall(void *ctx, SendStatus_t inbound) noexcept {
132
+ auto inst = static_cast<SendStatusCallbackSwig *>(ctx);
133
+ inst->call(static_cast<SendStatus>(inbound));
134
+ }
135
+ };
136
+
137
+ class SendHandleSwig {
138
+ VirtualPtr__Erased_ptr_ISendHandleVTable_t inner;
139
+
140
+ public:
141
+ explicit SendHandleSwig(
142
+ VirtualPtr__Erased_ptr_ISendHandleVTable_t inner) noexcept
143
+ : inner(inner) {}
144
+
145
+ SendHandleSwig(SendHandleSwig &&other) noexcept : inner(other.inner) {
146
+ other.inner.ptr = nullptr;
147
+ }
148
+
149
+ SendHandleSwig(SendHandleSwig const &other) noexcept : inner(other.inner) {
150
+ inner.vtable.retain_vptr(inner.ptr);
151
+ }
152
+
153
+ virtual ~SendHandleSwig() noexcept {
154
+ if (inner.ptr != nullptr) {
155
+ inner.vtable.release_vptr(inner.ptr);
156
+ }
157
+ }
158
+
159
+ virtual SendStatus current_status() noexcept {
160
+ return static_cast<SendStatus>(inner.vtable.poll(inner.ptr));
161
+ }
162
+
163
+ virtual void cancel() noexcept { inner.vtable.cancel(inner.ptr); }
164
+
165
+ virtual void onChange(SendStatusCallbackSwig *callback) {
166
+ callback->java_retain();
167
+ inner.vtable.set_on_change(inner.ptr,
168
+ {.env_ptr = callback,
169
+ .call = callback->invokeCall,
170
+ .free = callback->invokeRelease},
171
+ false);
172
+ }
173
+ };
174
+
175
+ class StreamStatusCallbackSwig : public Retainable {
176
+ public:
177
+ virtual void call(StreamStatus data) noexcept = 0;
178
+
179
+ virtual void drop() noexcept = 0;
180
+
181
+ static void invokeCall(void *ctx, StreamStatus_t inbound) noexcept {
182
+ auto inst = static_cast<StreamStatusCallbackSwig *>(ctx);
183
+ inst->call(static_cast<StreamStatus>(inbound));
184
+ }
185
+ };
186
+
187
+ class StreamSwig {
188
+ Stream_t stream;
189
+
190
+ public:
191
+ explicit StreamSwig(Stream_t stream) noexcept : stream(stream) {}
192
+
193
+ StreamSwig(StreamSwig &&other) noexcept : stream(other.stream) {
194
+ other.stream.inner.ptr = nullptr;
195
+ }
196
+
197
+ StreamSwig(StreamSwig const &other) noexcept : stream(other.stream) {
198
+ stream.inner.vtable.retain_vptr(stream.inner.ptr);
199
+ }
200
+
201
+ virtual ~StreamSwig() noexcept {
202
+ if (stream.inner.ptr != nullptr) {
203
+ stream.inner.vtable.release_vptr(stream.inner.ptr);
204
+ stream.inner.ptr = nullptr;
205
+ }
206
+ }
207
+
208
+ virtual SendHandleSwig send(BytesSwig data) noexcept {
209
+ return SendHandleSwig(
210
+ stream.inner.vtable.send(stream.inner.ptr, data.take()));
211
+ }
212
+
213
+ virtual TopicSwig topic() noexcept {
214
+ return TopicSwig(stream.inner.vtable.topic(stream.inner.ptr));
215
+ }
216
+
217
+ virtual PeerPubkeySwig peer() noexcept {
218
+ return PeerPubkeySwig(stream.inner.vtable.peer_pubkey(stream.inner.ptr));
219
+ }
220
+
221
+ virtual void addOnClose(StreamStatusCallbackSwig *callback) noexcept {
222
+ callback->java_retain();
223
+ stream.inner.vtable.add_on_close(stream.inner.ptr,
224
+ {.env_ptr = callback,
225
+ .call = callback->invokeCall,
226
+ .free = callback->invokeRelease});
227
+ }
228
+
229
+ virtual unsigned size_t max_send_size() noexcept {
230
+ return stream.inner.vtable.max_send_size(stream.inner.ptr);
231
+ }
232
+ };
233
+
234
+ class InboundSwig {
235
+ public:
236
+ BytesSwig payload;
237
+
238
+ explicit InboundSwig(Inbound_t inbound) noexcept : payload(inbound.payload) {}
239
+
240
+ InboundSwig(InboundSwig &&other) noexcept
241
+ : payload(std::move(other.payload)) {}
242
+
243
+ InboundSwig(InboundSwig const &other) noexcept = default;
244
+
245
+ InboundSwig &operator=(InboundSwig const &other) noexcept = default;
246
+ };
247
+
248
+ class InboundCallbackSwig : public Retainable {
249
+ public:
250
+ virtual void call(InboundSwig data) noexcept = 0;
251
+
252
+ virtual void drop() noexcept = 0;
253
+
254
+ static void invokeCall(void *ctx, Inbound_t inbound) noexcept {
255
+ auto inst = static_cast<InboundCallbackSwig *>(ctx);
256
+ inst->call(InboundSwig(inbound));
257
+ }
258
+ };
259
+
260
+ class StreamCandidateSwig {
261
+ StreamCandidate_t candidate;
262
+
263
+ public:
264
+ explicit StreamCandidateSwig(StreamCandidate_t candidate) noexcept
265
+ : candidate(candidate) {}
266
+
267
+ StreamCandidateSwig(StreamCandidateSwig &&other) noexcept
268
+ : candidate(other.candidate) {
269
+ other.candidate.inner.ptr = nullptr;
270
+ }
271
+
272
+ StreamCandidateSwig(StreamCandidateSwig const &other) noexcept
273
+ : candidate(other.candidate) {
274
+ candidate.inner.vtable.retain_vptr(candidate.inner.ptr);
275
+ }
276
+
277
+ virtual ~StreamCandidateSwig() noexcept {
278
+ if (candidate.inner.ptr != nullptr) {
279
+ candidate.inner.vtable.release_vptr(candidate.inner.ptr);
280
+ candidate.inner.ptr = nullptr;
281
+ }
282
+ }
283
+
284
+ virtual StreamSwig open() noexcept(false) {
285
+ auto stream = candidate.inner.vtable.open(
286
+ candidate.inner.ptr,
287
+ Tuple2_bool_BoxDynFnMut1_void_Inbound_t{._0 = false, ._1 = {}});
288
+ if (!stream._0) {
289
+ throw std::runtime_error("Attempted to open StreamCandidate twice");
290
+ }
291
+ return StreamSwig(stream._1);
292
+ }
293
+
294
+ virtual StreamSwig open(InboundCallbackSwig *callback) noexcept(false) {
295
+ callback->java_retain();
296
+ auto stream = candidate.inner.vtable.open(
297
+ candidate.inner.ptr, Tuple2_bool_BoxDynFnMut1_void_Inbound_t{
298
+ ._0 = true,
299
+ ._1 = {.env_ptr = callback,
300
+ .call = callback->invokeCall,
301
+ .free = callback->invokeRelease}});
302
+ if (!stream._0) {
303
+ throw std::runtime_error("Attempted to open StreamCandidate twice");
304
+ }
305
+ return StreamSwig(stream._1);
306
+ }
307
+
308
+ virtual TopicSwig topic() noexcept {
309
+ return TopicSwig(candidate.inner.vtable.topic(candidate.inner.ptr));
310
+ }
311
+
312
+ virtual PeerPubkeySwig peer() noexcept {
313
+ return PeerPubkeySwig(
314
+ candidate.inner.vtable.peer_pubkey(candidate.inner.ptr));
315
+ }
316
+ };
317
+
318
+ class StreamCandidateCallbackSwig : public Retainable {
319
+ public:
320
+ virtual void call(StreamCandidateSwig data) noexcept = 0;
321
+
322
+ virtual void drop() noexcept = 0;
323
+
324
+ static void invokeCall(void *ctx, StreamCandidate_t candidate) noexcept {
325
+ auto inst = static_cast<StreamCandidateCallbackSwig *>(ctx);
326
+ inst->call(StreamCandidateSwig(candidate));
327
+ }
328
+ };
329
+
330
+ class ConnectionResultCallbackSwig : public Retainable {
331
+ public:
332
+ virtual void onSuccess(StreamCandidateSwig data) noexcept = 0;
333
+
334
+ virtual void onFailure() noexcept = 0;
335
+
336
+ virtual void drop() noexcept = 0;
337
+
338
+ static void invokeCall(void *ctx,
339
+ ConnectionResult_Layout_t candidate) noexcept {
340
+ auto inst = static_cast<ConnectionResultCallbackSwig *>(ctx);
341
+ if (candidate.accepted) {
342
+ inst->onSuccess(StreamCandidateSwig(candidate.stream));
343
+ } else {
344
+ inst->onFailure();
345
+ }
346
+ }
347
+ };
348
+
349
+ class BusSwig {
350
+ Bus_t bus;
351
+
352
+ public:
353
+ explicit BusSwig(CDitto_t const *ditto) noexcept
354
+ : bus(dittoffi_get_experimental_bus(ditto)) {}
355
+
356
+ BusSwig(BusSwig const &other) noexcept : bus(other.bus) {
357
+ bus.inner.vtable.retain_vptr(bus.inner.ptr);
358
+ };
359
+
360
+ BusSwig(BusSwig &&other) noexcept : bus(other.bus) {
361
+ other.bus.inner.ptr = nullptr;
362
+ }
363
+
364
+ virtual ~BusSwig() noexcept {
365
+ if (bus.inner.ptr != nullptr) {
366
+ bus.inner.vtable.release_vptr(bus.inner.ptr);
367
+ bus.inner.ptr = nullptr;
368
+ }
369
+ }
370
+
371
+ virtual AcceptorSwig
372
+ bind_topic(const char *topic, Reliability reliability,
373
+ StreamCandidateCallbackSwig *callback) noexcept(false) {
374
+ if (callback == nullptr) {
375
+ throw std::runtime_error("Callback must not be null");
376
+ }
377
+ callback->java_retain();
378
+ auto acceptor = bus.inner.vtable.bind_topic(
379
+ bus.inner.ptr,
380
+ (slice_ref_uint8_t){.ptr = (const uint8_t *)topic,
381
+ .len = strlen(topic)},
382
+ reliability,
383
+ {.env_ptr = callback,
384
+ .call = callback->invokeCall,
385
+ .release = callback->invokeRelease,
386
+ .retain = callback->invokeRetain});
387
+ if (!acceptor.ok) {
388
+ throw std::runtime_error("Failed to bind topic");
389
+ }
390
+ return AcceptorSwig(acceptor.acceptor);
391
+ }
392
+
393
+ virtual void connect(const char *peer_key_str, const char *topic,
394
+ Reliability reliability,
395
+ ConnectionResultCallbackSwig *callback) noexcept {
396
+ callback->java_retain();
397
+ slice_ref_uint8_t peer_key_slice = {.ptr = (const uint8_t *)peer_key_str,
398
+ .len = strlen(peer_key_str)};
399
+ auto parsed = dittoffi_peer_pubkey_from_str(peer_key_slice);
400
+ if (!parsed._0) {
401
+ callback->onFailure();
402
+ callback->java_release();
403
+ return;
404
+ }
405
+ bus.inner.vtable.connect(bus.inner.ptr, parsed._1,
406
+ (slice_ref_uint8_t){.ptr = (const uint8_t *)topic,
407
+ .len = strlen(topic)},
408
+ reliability,
409
+ {.env_ptr = callback,
410
+ .call = callback->invokeCall,
411
+ .free = callback->invokeRelease});
412
+ }
413
+ };
414
+ #endif
@@ -0,0 +1 @@
1
+ #include "connection_request.h"
@@ -0,0 +1,56 @@
1
+ extern "C" {
2
+ #include "dittoffi.h"
3
+ }
4
+
5
+ #include "retainable.h"
6
+
7
+ #ifdef SWIG
8
+ %feature("director", assumeoverride=1) ConnectionRequestHandlerRust;
9
+ #endif
10
+
11
+ /** \brief
12
+ * Context object for Kotlin DittoConnectionRequestHandler which handles wiring up callbacks from
13
+ * Rust across the FFI boundary.
14
+ */
15
+ class ConnectionRequestHandlerRust: public Retainable {
16
+ public:
17
+ virtual ~ConnectionRequestHandlerRust() {}
18
+
19
+ static void invokeEventHandler(
20
+ Erased_t const *ctx,
21
+ dittoffi_connection_request_t *connection_request
22
+ ) {
23
+ auto inst = (ConnectionRequestHandlerRust *)ctx;
24
+ return inst->eventHandler(connection_request);
25
+ }
26
+
27
+ virtual void eventHandler(
28
+ dittoffi_connection_request_t *connection_request
29
+ ) = 0;
30
+
31
+ virtual void registerConnectionRequestHandler(
32
+ struct CDitto *ditto_raw,
33
+ ConnectionRequestHandlerRust *handler
34
+ ) {
35
+ Erased_t* handler_pointer;
36
+ if (handler != nullptr) {
37
+ Retainable::invokeRetain(handler);
38
+ handler_pointer = (Erased_t *)handler;
39
+ } else {
40
+ handler_pointer = NULL; // Pass null to clear the handler
41
+ }
42
+
43
+ FfiConnectionRequestHandlerVTable_t const v_table = {
44
+ .release_vptr = (void (*)(Erased_t *)) ConnectionRequestHandlerRust::invokeRelease,
45
+ .retain_vptr = ConnectionRequestHandlerRust::invokeVirtualPtrRetain,
46
+ .on_connecting = ConnectionRequestHandlerRust::invokeEventHandler
47
+ };
48
+
49
+ VirtualPtr__Erased_ptr_FfiConnectionRequestHandlerVTable_t const ffi_handler = {
50
+ .ptr = handler_pointer,
51
+ .vtable = v_table
52
+ };
53
+
54
+ dittoffi_presence_set_connection_request_handler(ditto_raw, ffi_handler);
55
+ }
56
+ };
@@ -0,0 +1 @@
1
+ #include "crash_reporter.h"
@@ -0,0 +1,40 @@
1
+ extern "C" {
2
+ #include "dittoffi.h"
3
+ }
4
+
5
+ #include "retainable.h"
6
+
7
+ #ifdef SWIG
8
+ %feature("director", assumeoverride=1) CrashReporterFfi;
9
+ #endif
10
+
11
+ class CrashReporterFfi: public Retainable {
12
+ public:
13
+ virtual ~CrashReporterFfi() {}
14
+
15
+ static void ffiInvokeReportCrashKotlinImplementation(
16
+ void *ctx,
17
+ dittoffi_panic_t *panic
18
+ ) {
19
+ auto inst = (CrashReporterFfi *)ctx;
20
+ return inst->reportCrashKotlinImplementation(panic);
21
+ }
22
+
23
+ virtual void reportCrashKotlinImplementation(
24
+ dittoffi_panic_t *panic
25
+ ) = 0;
26
+
27
+ virtual void overrideCrashReporter(
28
+ struct CDitto *ditto_raw
29
+ ) {
30
+ CrashReporterFfi * handler = this;
31
+
32
+ dittoffi_panic_handler_t ffiPanicHandler;
33
+ handler->java_retain();
34
+ ffiPanicHandler.env_ptr = handler;
35
+ ffiPanicHandler.call = CrashReporterFfi::ffiInvokeReportCrashKotlinImplementation;
36
+ ffiPanicHandler.free = CrashReporterFfi::invokeRelease;
37
+
38
+ dittoffi_ditto_set_panic_handler(ffiPanicHandler);
39
+ }
40
+ };