add dc_add_device_msg_once() to fii

This commit is contained in:
B. Petersen
2019-11-12 12:22:02 +01:00
committed by holger krekel
parent a42e197634
commit b42d8799b4
2 changed files with 43 additions and 0 deletions

View File

@@ -828,6 +828,27 @@ pub unsafe extern "C" fn dc_add_device_msg(context: *mut dc_context_t, msg: *mut
.unwrap_or(0)
}
#[no_mangle]
pub unsafe extern "C" fn dc_add_device_msg_once(
context: *mut dc_context_t,
label: *const libc::c_char,
msg: *mut dc_msg_t,
) -> u32 {
if context.is_null() || label.is_null() || msg.is_null() {
eprintln!("ignoring careless call to dc_add_device_msg_once()");
return 0;
}
let ffi_context = &mut *context;
let ffi_msg = &mut *msg;
ffi_context
.with_inner(|ctx| {
chat::add_device_msg_once(ctx, &to_string_lossy(label), &mut ffi_msg.message)
.unwrap_or_log_default(ctx, "Failed to add device message once")
})
.map(|msg_id| msg_id.to_u32())
.unwrap_or(0)
}
#[no_mangle]
pub unsafe extern "C" fn dc_get_draft(context: *mut dc_context_t, chat_id: u32) -> *mut dc_msg_t {
if context.is_null() {