diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 584e6939f9..9a31f2ff90 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -6284,6 +6284,18 @@ void dc_event_unref(dc_event_t* event); #define DC_EVENT_WEBXDC_INSTANCE_DELETED 2121 +/** + * Data received over an ephemeral peer channel. + * + * @param data1 (int) msg_id + * @param data2 (int) + (char*) binary data. + * length is returned as integer with dc_event_get_data2_int() + * and binary data is returned as dc_event_get_data2_str(). + * Binary data must be passed to dc_str_unref() afterwards. + */ + +#define DC_EVENT_WEBXDC_REALTIME_DATA 2150 + /** * Tells that the Background fetch was completed (or timed out). * diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 3e0cdc6470..61eba53fff 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -658,7 +658,6 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc: | EventType::ConnectivityChanged | EventType::WebxdcInstanceDeleted { .. } | EventType::IncomingMsgBunch { .. } - | EventType::WebxdcRealtimeData { .. } | EventType::SelfavatarChanged | EventType::AccountsBackgroundFetchDone | EventType::ChatlistChanged @@ -679,6 +678,7 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc: status_update_serial, .. } => status_update_serial.to_u32() as libc::c_int, + EventType::WebxdcRealtimeData { data, .. } => data.len() as libc::c_int, } } @@ -725,7 +725,6 @@ pub unsafe extern "C" fn dc_event_get_data2_str(event: *mut dc_event_t) -> *mut | EventType::SelfavatarChanged | EventType::WebxdcStatusUpdate { .. } | EventType::WebxdcInstanceDeleted { .. } - | EventType::WebxdcRealtimeData { .. } | EventType::AccountsBackgroundFetchDone | EventType::ChatEphemeralTimerModified { .. } | EventType::IncomingMsgBunch { .. } @@ -746,6 +745,11 @@ pub unsafe extern "C" fn dc_event_get_data2_str(event: *mut dc_event_t) -> *mut let data2 = key.to_string().to_c_string().unwrap_or_default(); data2.into_raw() } + EventType::WebxdcRealtimeData { data, .. } => { + let ptr = libc::malloc(data.len()); + libc::memcpy(ptr, data.as_ptr() as *mut libc::c_void, data.len()); + ptr as *mut libc::c_char + } } } diff --git a/node/constants.js b/node/constants.js index 30fb5a7b16..f753d2a388 100644 --- a/node/constants.js +++ b/node/constants.js @@ -66,6 +66,7 @@ module.exports = { DC_EVENT_SMTP_MESSAGE_SENT: 103, DC_EVENT_WARNING: 300, DC_EVENT_WEBXDC_INSTANCE_DELETED: 2121, + DC_EVENT_WEBXDC_REALTIME_DATA: 2150, DC_EVENT_WEBXDC_STATUS_UPDATE: 2120, DC_GCL_ADD_ALLDONE_HINT: 4, DC_GCL_ADD_SELF: 2, diff --git a/node/events.js b/node/events.js index 15596a3079..c87f31490d 100644 --- a/node/events.js +++ b/node/events.js @@ -37,6 +37,7 @@ module.exports = { 2111: 'DC_EVENT_CONFIG_SYNCED', 2120: 'DC_EVENT_WEBXDC_STATUS_UPDATE', 2121: 'DC_EVENT_WEBXDC_INSTANCE_DELETED', + 2150: 'DC_EVENT_WEBXDC_REALTIME_DATA', 2200: 'DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE', 2300: 'DC_EVENT_CHATLIST_CHANGED', 2301: 'DC_EVENT_CHATLIST_ITEM_CHANGED' diff --git a/node/lib/constants.ts b/node/lib/constants.ts index e789d17220..e86f41d742 100644 --- a/node/lib/constants.ts +++ b/node/lib/constants.ts @@ -66,6 +66,7 @@ export enum C { DC_EVENT_SMTP_MESSAGE_SENT = 103, DC_EVENT_WARNING = 300, DC_EVENT_WEBXDC_INSTANCE_DELETED = 2121, + DC_EVENT_WEBXDC_REALTIME_DATA = 2150, DC_EVENT_WEBXDC_STATUS_UPDATE = 2120, DC_GCL_ADD_ALLDONE_HINT = 4, DC_GCL_ADD_SELF = 2, @@ -338,6 +339,7 @@ export const EventId2EventName: { [key: number]: string } = { 2111: 'DC_EVENT_CONFIG_SYNCED', 2120: 'DC_EVENT_WEBXDC_STATUS_UPDATE', 2121: 'DC_EVENT_WEBXDC_INSTANCE_DELETED', + 2150: 'DC_EVENT_WEBXDC_REALTIME_DATA', 2200: 'DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE', 2300: 'DC_EVENT_CHATLIST_CHANGED', 2301: 'DC_EVENT_CHATLIST_ITEM_CHANGED',