mirror of
https://github.com/chatmail/core.git
synced 2026-05-13 03:46:32 +03:00
make accounts sortable
This commit is contained in:
@@ -3119,6 +3119,18 @@ dc_context_t* dc_accounts_get_selected_account (dc_accounts_t* accounts);
|
||||
int dc_accounts_select_account (dc_accounts_t* accounts, uint32_t account_id);
|
||||
|
||||
|
||||
/**
|
||||
* Move an account and change the order returned by dc_accounts_get_all().
|
||||
*
|
||||
* @param accounts
|
||||
* @param to_move_id The account ID to move.
|
||||
* @param predecessor_id `to_move_id` will be sorted below `predecessor_id`.
|
||||
* Set to 0 to move `to_move_id` to the top of the list returned by dc_accounts_get_all().
|
||||
* @return 1=success, 0=error
|
||||
*/
|
||||
int dc_accounts_move_below (dc_accounts_t* accounts, uint32_t to_move_id, uint32_t predecessor_id);
|
||||
|
||||
|
||||
/**
|
||||
* Start job and IMAP/SMTP tasks for all accounts managed by the account manager.
|
||||
* If IO is already running, nothing happens.
|
||||
|
||||
@@ -4703,6 +4703,35 @@ pub unsafe extern "C" fn dc_accounts_select_account(
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_accounts_move_below(
|
||||
accounts: *mut dc_accounts_t,
|
||||
to_move_id: u32,
|
||||
predecessor_id: u32,
|
||||
) -> libc::c_int {
|
||||
if accounts.is_null() {
|
||||
eprintln!("ignoring careless call to dc_accounts_move_below()");
|
||||
return 0;
|
||||
}
|
||||
|
||||
let accounts = &*accounts;
|
||||
let predecessor_id = if predecessor_id == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(predecessor_id)
|
||||
};
|
||||
block_on(async move {
|
||||
let mut accounts = accounts.write().await;
|
||||
match accounts.move_below(to_move_id, predecessor_id).await {
|
||||
Ok(()) => 1,
|
||||
Err(err) => {
|
||||
accounts.emit_event(EventType::Error(format!("Failed to move account: {err:#}")));
|
||||
0
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_accounts_add_account(accounts: *mut dc_accounts_t) -> u32 {
|
||||
if accounts.is_null() {
|
||||
|
||||
Reference in New Issue
Block a user