mirror of
https://github.com/chatmail/core.git
synced 2026-05-11 19:06:29 +03:00
api: add APIs to stop background fetch
New APIs are JSON-RPC method stop_background_fetch(), Rust method Accounts.stop_background_fetch() and C method dc_accounts_stop_background_fetch(). These APIs allow to cancel background fetch early even before the initially set timeout, for example on Android when the system calls `Service.onTimeout()` for a `dataSync` foreground service.
This commit is contained in:
@@ -5027,6 +5027,17 @@ pub unsafe extern "C" fn dc_accounts_background_fetch(
|
||||
1
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_accounts_stop_background_fetch(accounts: *mut dc_accounts_t) {
|
||||
if accounts.is_null() {
|
||||
eprintln!("ignoring careless call to dc_accounts_stop_background_fetch()");
|
||||
return;
|
||||
}
|
||||
|
||||
let accounts = &*accounts;
|
||||
block_on(accounts.read()).stop_background_fetch();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_accounts_set_push_device_token(
|
||||
accounts: *mut dc_accounts_t,
|
||||
|
||||
Reference in New Issue
Block a user