64 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) != SQLITE_OK)
68 mutt_error(
_(
"Unable to open autocrypt database %s"), db_path);
89 if (!c_autocrypt || !c_autocrypt_dir)
95 struct stat st = { 0 };
227 const char *val = (
const char *) sqlite3_column_text(stmt, index);
280 "WHERE email_addr = ?",
281 -1, SQLITE_PREPARE_PERSISTENT, &
AccountGetStmt, NULL) != SQLITE_OK)
288 SQLITE_STATIC) != SQLITE_OK)
294 if (result != SQLITE_ROW)
296 if (result == SQLITE_DONE)
305 (*account)->prefer_encrypt = sqlite3_column_int(
AccountGetStmt, 3);
326 const char *keydata,
bool prefer_encrypt)
335 "INSERT INTO account "
341 "VALUES (?, ?, ?, ?, ?);",
349 -1, SQLITE_STATIC) != SQLITE_OK)
353 if (sqlite3_bind_text(
AccountInsertStmt, 2, keyid, -1, SQLITE_STATIC) != SQLITE_OK)
355 if (sqlite3_bind_text(
AccountInsertStmt, 3, keydata, -1, SQLITE_STATIC) != SQLITE_OK)
386 "UPDATE account SET "
389 "prefer_encrypt = ?, "
391 "WHERE email_addr = ?;",
432 "DELETE from account "
433 "WHERE email_addr = ?;",
463 sqlite3_stmt *stmt = NULL;
465 int results_len = 0, results_count = 0;
480 "ORDER BY email_addr",
481 -1, &stmt, NULL) != SQLITE_OK)
486 while ((result = sqlite3_step(stmt)) == SQLITE_ROW)
488 if (results_count == results_len)
495 results[results_count++] = account;
501 account->
enabled = sqlite3_column_int(stmt, 4);
504 if (result == SQLITE_DONE)
507 rc = *num_accounts = results_count;
511 while (results_count > 0)
517 sqlite3_finalize(stmt);
569 "autocrypt_timestamp, "
577 "WHERE email_addr = ?",
578 -1, SQLITE_PREPARE_PERSISTENT, &
PeerGetStmt, NULL) != SQLITE_OK)
585 SQLITE_STATIC) != SQLITE_OK)
591 if (result != SQLITE_ROW)
593 if (result == SQLITE_DONE)
600 (*peer)->last_seen = sqlite3_column_int64(
PeerGetStmt, 1);
601 (*peer)->autocrypt_timestamp = sqlite3_column_int64(
PeerGetStmt, 2);
604 (*peer)->prefer_encrypt = sqlite3_column_int(
PeerGetStmt, 5);
605 (*peer)->gossip_timestamp = sqlite3_column_int64(
PeerGetStmt, 6);
627 struct Address *norm_addr = NULL;
637 "autocrypt_timestamp, "
644 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
645 -1, SQLITE_PREPARE_PERSISTENT, &
PeerInsertStmt, NULL) != SQLITE_OK)
652 SQLITE_STATIC) != SQLITE_OK)
699 "autocrypt_timestamp = ?, "
702 "prefer_encrypt = ?, "
703 "gossip_timestamp = ?, "
705 "gossip_keydata = ? "
706 "WHERE email_addr = ?;",
707 -1, SQLITE_PREPARE_PERSISTENT, &
PeerUpdateStmt, NULL) != SQLITE_OK)
784 "INSERT INTO peer_history "
789 "VALUES (?, ?, ?, ?);",
790 -1, SQLITE_PREPARE_PERSISTENT,
798 -1, SQLITE_STATIC) != SQLITE_OK)
803 SQLITE_STATIC) != SQLITE_OK)
866 "INSERT INTO gossip_history "
868 "sender_email_addr, "
872 "VALUES (?, ?, ?, ?, ?);",
873 -1, SQLITE_PREPARE_PERSISTENT,
881 -1, SQLITE_STATIC) != SQLITE_OK)
886 -1, SQLITE_STATIC) != SQLITE_OK)
889 -1, SQLITE_STATIC) != SQLITE_OK)
897 -1, SQLITE_STATIC) != SQLITE_OK)
void mutt_addr_free(struct Address **ptr)
Free a single Address.
struct Address * mutt_addr_new(void)
Create a new Address.
int mutt_addrlist_to_local(struct AddressList *al)
Convert an Address list from Punycode.
bool mutt_addr_to_local(struct Address *a)
Convert an Address from Punycode.
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
bool mutt_addr_to_intl(struct Address *a)
Convert an Address to Punycode.
void mutt_autocrypt_db_normalize_addrlist(struct AddressList *al)
Normalise a list of Email Addresses.
static sqlite3_stmt * PeerUpdateStmt
Update a peer address.
struct AutocryptPeer * mutt_autocrypt_db_peer_new(void)
Create a new AutocryptPeer.
int mutt_autocrypt_db_account_delete(struct AutocryptAccount *acct)
Delete an Account from the Autocrypt database.
static sqlite3_stmt * PeerGetStmt
Get the matching peer addresses.
int mutt_autocrypt_db_peer_insert(struct Address *addr, struct AutocryptPeer *peer)
Insert a peer into the Autocrypt database.
struct AutocryptGossipHistory * mutt_autocrypt_db_gossip_history_new(void)
Create a new AutocryptGossipHistory.
void mutt_autocrypt_db_close(void)
Close the Autocrypt SQLite database connection.
sqlite3 * AutocryptDB
Handle to the open Autocrypt database.
int mutt_autocrypt_db_gossip_history_insert(struct Address *addr, struct AutocryptGossipHistory *gossip_hist)
Insert a gossip history into the Autocrypt database.
int mutt_autocrypt_db_account_get(struct Address *addr, struct AutocryptAccount **account)
Get Autocrypt Account data from the database.
int mutt_autocrypt_db_peer_get(struct Address *addr, struct AutocryptPeer **peer)
Get peer info from the Autocrypt database.
int mutt_autocrypt_db_peer_update(struct AutocryptPeer *peer)
Update the peer info in an Autocrypt database.
int mutt_autocrypt_db_account_insert(struct Address *addr, const char *keyid, const char *keydata, bool prefer_encrypt)
Insert an Account into the Autocrypt database.
void mutt_autocrypt_db_account_free(struct AutocryptAccount **ptr)
Free an AutocryptAccount.
struct AutocryptAccount * mutt_autocrypt_db_account_new(void)
Create a new AutocryptAccount.
static sqlite3_stmt * AccountInsertStmt
Insert a new autocrypt account.
void mutt_autocrypt_db_normalize_addr(struct Address *a)
Normalise an Email Address.
static sqlite3_stmt * PeerHistoryInsertStmt
Add to the peer history.
static struct Address * copy_normalize_addr(struct Address *addr)
Copy a normalised Email Address.
void mutt_autocrypt_db_peer_history_free(struct AutocryptPeerHistory **ptr)
Free an AutocryptPeerHistory.
static sqlite3_stmt * GossipHistoryInsertStmt
Add to the gossip history.
int mutt_autocrypt_db_account_update(struct AutocryptAccount *acct)
Update Account info in the Autocrypt database.
int mutt_autocrypt_db_account_get_all(struct AutocryptAccount ***accounts, int *num_accounts)
Get all accounts from an Autocrypt database.
static sqlite3_stmt * AccountUpdateStmt
Update an autocrypt account.
void mutt_autocrypt_db_peer_free(struct AutocryptPeer **ptr)
Free an AutocryptPeer.
void mutt_autocrypt_db_gossip_history_free(struct AutocryptGossipHistory **ptr)
Free an AutocryptGossipHistory.
struct AutocryptPeerHistory * mutt_autocrypt_db_peer_history_new(void)
Create a new AutocryptPeerHistory.
static int autocrypt_db_create(const char *db_path)
Create an Autocrypt SQLite database.
static sqlite3_stmt * AccountGetStmt
Get the matching autocrypt accounts.
int mutt_autocrypt_db_init(bool can_create)
Initialise the Autocrypt SQLite database.
static sqlite3_stmt * AccountDeleteStmt
Delete an autocrypt account.
static char * strdup_column_text(sqlite3_stmt *stmt, int index)
Copy a string from the database.
static sqlite3_stmt * PeerInsertStmt
Insert a new peer address.
int mutt_autocrypt_db_peer_history_insert(struct Address *addr, struct AutocryptPeerHistory *peerhist)
Insert peer history into the Autocrypt database.
int mutt_autocrypt_schema_update(void)
Update the version number of the Autocrypt database schema.
int mutt_autocrypt_schema_init(void)
Set up an Autocrypt database.
int mutt_autocrypt_account_init(bool prompt)
Create a new Autocrypt account.
void mutt_autocrypt_scan_mailboxes(void)
Scan mailboxes for Autocrypt headers.
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
size_t buf_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
void buf_lower(struct Buffer *buf)
Sets a buffer to lowercase.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
const char * cs_subset_path(const struct ConfigSubset *sub, const char *name)
Get a path config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Convenience wrapper for the library headers.
char * mutt_str_dup(const char *str)
Copy a string, safely.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define TAILQ_FOREACH(var, head, field)
struct Buffer * mailbox
Mailbox and host address.
bool intl_checked
Checked for IDN?
bool is_intl
International Domain Name.
char * email_addr
Email address.
char * keydata
PGP Key data.
bool enabled
Is this account enabled.
bool prefer_encrypt
false = nopref, true = mutual
Autocrypt gossip history.
char * peer_email_addr
Email addressof the peer.
char * email_msgid
Sender's email's message id.
char * sender_email_addr
Sender's email address.
char * gossip_keydata
Gossip Key data.
sqlite3_int64 timestamp
Timestamp of sender's email.
char * peer_email_addr
Email address of the peer.
char * email_msgid
Message id of the email.
char * keydata
PGP Key data.
sqlite3_int64 timestamp
Timestamp of email.
sqlite3_int64 autocrypt_timestamp
When the email was sent.
char * gossip_keydata
Gossip Key data.
char * gossip_keyid
Gossip Key id.
char * keydata
PGP Key data.
char * email_addr
Email address.
sqlite3_int64 last_seen
When was the peer last seen.
bool prefer_encrypt
false = nopref, true = mutual
sqlite3_int64 gossip_timestamp
Timestamp of Gossip header.
String manipulation buffer.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.