diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 208c6f1b5..d7f215abf 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -1139,6 +1139,24 @@ void dc_set_draft (dc_context_t* context, uint32_t ch uint32_t dc_add_device_msg (dc_context_t* context, const char* label, dc_msg_t* msg); +/** + * Init device-messages and saved-messages chat. + * This function adds the device-chat and saved-messages chat + * and adds one or more welcome or update-messages. + * The ui can add messages on its own using dc_add_device_msg() - + * for ordering, either before or after or even without calling this function. + * + * Chat and message creation is done only once. + * So if the user has manually deleted things, they won't be re-created + * (however, not seen device messages are added and may re-create the device-chat). + * + * @memberof dc_context_t + * @param context The context as created by dc_context_new(). + * @return None. + */ +void dc_update_device_chats (dc_context_t* context); + + /** * Check if a device-message with a given label was ever added. * Device-messages can be added dc_add_device_msg(). diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index f1f8697b8..1a25a84a5 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -851,6 +851,21 @@ pub unsafe extern "C" fn dc_add_device_msg( .unwrap_or(0) } +#[no_mangle] +pub unsafe extern "C" fn dc_update_device_chats(context: *mut dc_context_t) { + if context.is_null() { + eprintln!("ignoring careless call to dc_update_device_chats()"); + return; + } + let ffi_context = &mut *context; + ffi_context + .with_inner(|ctx| { + ctx.update_device_chats() + .unwrap_or_log_default(ctx, "Failed to add device message") + }) + .unwrap_or(()) +} + #[no_mangle] pub unsafe extern "C" fn dc_was_device_msg_ever_added( context: *mut dc_context_t,