diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index e8bdb1c4e..6b3e9dd4a 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -982,6 +982,64 @@ uint32_t dc_send_text_msg (dc_context_t* context, uint32_t ch uint32_t dc_send_videochat_invitation (dc_context_t* context, uint32_t chat_id); +/** + * An w30 instance send a status update to its other members. + * + * In js-land, that would be mapped to sth. as: + * ``` + * success = window.webxdc.sendUpdate('move A3 B4', '{"action":"move","src":"A3","dest":"B4"}'); + * ``` + * `context` and `msg_id` is not needed in js as that is unique within an w30 instance. + * See dc_get_w30_status_updates() for the receiving counterpart. + * + * If the w30 instance is a draft, the update is not send immediately. + * Instead, the updates are collected and sent out in batch when the instance is actually sent. + * This allows preparing w30 instances, + * eg. defining a poll with predefined answers. + * + * Other members will be informed by #DC_EVENT_W30_STATUS_UPDATE that there is a new update. + * You will also get the #DC_EVENT_W30_STATUS_UPDATE yourself + * and the update you're sent will also be included in dc_get_w30_status_updates(). + * + * @memberof dc_context_t + * @param context The context object + * @param msg_id id of the message with the w30 instance + * @param descr user-visible description of the json-data, + * in case of a chess game, eg. the move. + * @param json program-readable data, the actual payload + * @return 1=success, 0=error + */ +int dc_send_w30_status_update (dc_context_t* context, uint32_t msg_id, const char* descr, const char* json); + + +/** + * Get status updates. + * The status updates may be sent by yourself or by other members using dc_send_w30_status_update(). + * In both cases, you will be informed by #DC_EVENT_W30_STATUS_UPDATE + * whenever there is a new update. + * + * In js-land, that would be mapped to sth. as: + * ``` + * window.webxdc.setUpdateListener((update) => { + * if (update.payload.action === "move") { + * print(update.payload.src) + * print(update.payload.dest) + * } + * }); + * ``` + * + * @memberof dc_context_t + * @param context The context object + * @param msg_id id of the message with the w30 instance + * @param status_update_id Can be used to filter out only a concrete status update. + * When set to 0, all known status updates are returned. + * @return JSON-array containing the requested updates, + * each element was created by dc_send_w30_status_update() + * on this or other devices. + * If there are no updates, an empty JSON-array is returned. + */ +char* dc_get_w30_status_updates (dc_context_t* context, uint32_t msg_id, uint32_t status_update_id); + /** * Save a draft for a chat in the database. * @@ -4774,6 +4832,16 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot); */ #define DC_MSG_VIDEOCHAT_INVITATION 70 + +/** + * w30-Message. + * Message with HTML5, CSS and related content. + * + * To send data to a w30 instance, use dc_send_w30_status_update() + */ +#define DC_MSG_W30 80 + + /** * @} */ @@ -5467,6 +5535,21 @@ void dc_event_unref(dc_event_t* event); #define DC_EVENT_SELFAVATAR_CHANGED 2110 +/** + * w30 status update received. + * To get the received status update, use dc_get_w30_status_updates(). + * To send status updates, use dc_send_w30_status_update(). + * + * Note, that you do not get events that arrive when the app is not running; + * instead, you can use dc_get_w30_status_updates() to get all status updates + * and catch up that way. + * + * @param data1 (int) msg_id + * @param data2 (int) status_update_id + */ +#define DC_EVENT_W30_STATUS_UPDATE 2120 + + /** * @} */