C12.5: mail accounts, add and remove

ElyMail's window lists accounts and adds Gmail, Microsoft, iCloud
(app-specific password), IMAP and POP3 ones; a check logs in to both
servers and reports each. Accounts live in the store as JSON with a
case-insensitive unique address; secrets go to the keychain. Removal
names the cache it deletes, takes the secret first and puts it back
when local removal fails. Originals are set aside until commit and
restored after a crash. Requests are numbered so late results stay
with their own dialog. The account list is keyboard-navigable.
This commit is contained in:
雷电芽衣 committed 2026-10-19 20:17:19 -04:00
1 parent 5068bc07ca
commit 1c225f6812
39 files changed
+3152 -105

No files matched your search

+4 -15
View File
@@ -10,6 +10,8 @@ use rusqlite::{Connection, OpenFlags, OptionalExtension, params};
use crate::{Error, Result};
mod accounts;
mod aside;
mod html;
mod messages;
mod schema;
@@ -17,6 +19,7 @@ mod search;
#[cfg(test)]
mod tests;
pub use accounts::Cached;
pub use messages::{Fetched, Key, Stored};
const DB: &str = "mail.db";
@@ -63,21 +66,6 @@ impl Store {
}
}
pub fn add_account(&self, address: &str) -> Result<AccountId> {
self.writable()?;
self.conn
.execute("INSERT INTO accounts (address) VALUES (?1)", [address])?;
Ok(AccountId(self.conn.last_insert_rowid()))
}
pub fn accounts(&self) -> Result<Vec<(AccountId, String)>> {
let mut query = self
.conn
.prepare("SELECT id, address FROM accounts ORDER BY id")?;
let rows = query.query_map([], |row| Ok((AccountId(row.get(0)?), row.get(1)?)))?;
Ok(rows.collect::<rusqlite::Result<_>>()?)
}
/// The mailbox by name, made on first use.
pub fn mailbox(&self, account: AccountId, name: &str) -> Result<MailboxId> {
let find = "SELECT id FROM mailboxes WHERE account = ?1 AND name = ?2";
@@ -155,6 +143,7 @@ fn open(dir: &Path, steps: &[&str]) -> Result<Store> {
}
conn.pragma_update(None, "foreign_keys", true)?;
conn.pragma_update(None, "journal_mode", "WAL")?;
aside::recover(&conn, dir)?;
log::info!("mail: store opened at schema v{target}");
Ok(Store {
conn,