mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
add dc_has_device_msg()
This commit is contained in:
@@ -1171,6 +1171,21 @@ uint32_t dc_add_device_msg_unlabelled(dc_context_t* context, dc_msg_t* ms
|
||||
void dc_skip_device_msg (dc_context_t* context, const char* label);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check if a device-message was ever added or skipped.
|
||||
* Device-messages can be added or skipped
|
||||
* using dc_add_device_msg_once() or dc_skip_device_msg().
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context as created by dc_context_new().
|
||||
* @param label Label of the message to check.
|
||||
* @return 1=A message with this label was added or skipped at some point,
|
||||
* 0=A message with this label was never added nor skipped.
|
||||
*/
|
||||
int dc_has_device_msg (dc_context_t* context, const char* label);
|
||||
|
||||
|
||||
/**
|
||||
* Get draft for a chat, if any.
|
||||
* See dc_set_draft() for more details about drafts.
|
||||
|
||||
@@ -870,6 +870,23 @@ pub unsafe extern "C" fn dc_skip_device_msg(
|
||||
.unwrap_or(())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_has_device_msg(
|
||||
context: *mut dc_context_t,
|
||||
label: *const libc::c_char,
|
||||
) -> libc::c_int {
|
||||
if context.is_null() || label.is_null() {
|
||||
eprintln!("ignoring careless call to dc_has_device_msg()");
|
||||
return 0;
|
||||
}
|
||||
let ffi_context = &mut *context;
|
||||
ffi_context
|
||||
.with_inner(|ctx| {
|
||||
chat::has_device_msg(ctx, &to_string_lossy(label)).unwrap_or(false) as libc::c_int
|
||||
})
|
||||
.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() {
|
||||
|
||||
Reference in New Issue
Block a user