Add C interface for autodelete timer settings

This commit is contained in:
Alexander Krotov
2020-01-02 01:37:21 +01:00
parent 51133ce0d6
commit d4c4070b3f
2 changed files with 57 additions and 0 deletions

View File

@@ -1451,6 +1451,41 @@ pub unsafe extern "C" fn dc_set_chat_mute_duration(
.unwrap_or(0)
}
#[no_mangle]
pub unsafe extern "C" fn dc_get_chat_autodelete_timer(
context: *mut dc_context_t,
chat_id: u32,
) -> u32 {
if context.is_null() || chat_id <= constants::DC_CHAT_ID_LAST_SPECIAL as u32 {
eprintln!("ignoring careless call to dc_set_chat_autodelete_timer()");
return 0;
}
let ffi_context = &*context;
ffi_context
.with_inner(|ctx| chat::get_autodelete_timer(ctx, ChatId::new(chat_id)))
.unwrap_or_default()
}
#[no_mangle]
pub unsafe extern "C" fn dc_set_chat_autodelete_timer(
context: *mut dc_context_t,
chat_id: u32,
timer: u32,
) -> libc::c_int {
if context.is_null() || chat_id <= constants::DC_CHAT_ID_LAST_SPECIAL as u32 {
eprintln!("ignoring careless call to dc_set_chat_autodelete_timer()");
return 0;
}
let ffi_context = &*context;
ffi_context
.with_inner(|ctx| {
chat::set_autodelete_timer(ctx, ChatId::new(chat_id), timer)
.map(|_| 1)
.unwrap_or_log_default(ctx, "Failed to set autodelete timer")
})
.unwrap_or(0)
}
#[no_mangle]
pub unsafe extern "C" fn dc_get_msg_info(
context: *mut dc_context_t,