63 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) != SQLITE_OK)
67 mutt_error(
_(
"Unable to open autocrypt database %s"), db_path);
88 if (!c_autocrypt || !c_autocrypt_dir)
94 struct stat st = { 0 };
98 SQLITE_OPEN_READWRITE, NULL) != SQLITE_OK)
227 const char *val = (
const char *) sqlite3_column_text(stmt, index);
280 "WHERE email_addr = ?",
281 -1, SQLITE_PREPARE_PERSISTENT, &
AccountGetStmt, NULL) != SQLITE_OK)
291 if (result != SQLITE_ROW)
293 if (result == SQLITE_DONE)
302 (*account)->prefer_encrypt = sqlite3_column_int(
AccountGetStmt, 3);
323 const char *keydata,
bool prefer_encrypt)
332 "INSERT INTO account "
338 "VALUES (?, ?, ?, ?, ?);",
347 if (sqlite3_bind_text(
AccountInsertStmt, 2, keyid, -1, SQLITE_STATIC) != SQLITE_OK)
349 if (sqlite3_bind_text(
AccountInsertStmt, 3, keydata, -1, SQLITE_STATIC) != SQLITE_OK)
380 "UPDATE account SET "
383 "prefer_encrypt = ?, "
385 "WHERE email_addr = ?;",
426 "DELETE from account "
427 "WHERE email_addr = ?;",
457 sqlite3_stmt *stmt = NULL;
459 int results_len = 0, results_count = 0;
474 "ORDER BY email_addr",
475 -1, &stmt, NULL) != SQLITE_OK)
480 while ((result = sqlite3_step(stmt)) == SQLITE_ROW)
482 if (results_count == results_len)
489 results[results_count++] = account;
495 account->
enabled = sqlite3_column_int(stmt, 4);
498 if (result == SQLITE_DONE)
501 rc = *num_accounts = results_count;
505 while (results_count > 0)
511 sqlite3_finalize(stmt);
563 "autocrypt_timestamp, "
571 "WHERE email_addr = ?",
572 -1, SQLITE_PREPARE_PERSISTENT, &
PeerGetStmt, NULL) != SQLITE_OK)
578 if (sqlite3_bind_text(
PeerGetStmt, 1, norm_addr->
mailbox, -1, SQLITE_STATIC) != SQLITE_OK)
582 if (result != SQLITE_ROW)
584 if (result == SQLITE_DONE)
591 (*peer)->last_seen = sqlite3_column_int64(
PeerGetStmt, 1);
592 (*peer)->autocrypt_timestamp = sqlite3_column_int64(
PeerGetStmt, 2);
595 (*peer)->prefer_encrypt = sqlite3_column_int(
PeerGetStmt, 5);
596 (*peer)->gossip_timestamp = sqlite3_column_int64(
PeerGetStmt, 6);
618 struct Address *norm_addr = NULL;
628 "autocrypt_timestamp, "
635 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
636 -1, SQLITE_PREPARE_PERSISTENT, &
PeerInsertStmt, NULL) != SQLITE_OK)
687 "autocrypt_timestamp = ?, "
690 "prefer_encrypt = ?, "
691 "gossip_timestamp = ?, "
693 "gossip_keydata = ? "
694 "WHERE email_addr = ?;",
695 -1, SQLITE_PREPARE_PERSISTENT, &
PeerUpdateStmt, NULL) != SQLITE_OK)
772 "INSERT INTO peer_history "
777 "VALUES (?, ?, ?, ?);",
778 -1, SQLITE_PREPARE_PERSISTENT,
788 SQLITE_STATIC) != SQLITE_OK)
851 "INSERT INTO gossip_history "
853 "sender_email_addr, "
857 "VALUES (?, ?, ?, ?, ?);",
858 -1, SQLITE_PREPARE_PERSISTENT,
866 SQLITE_STATIC) != SQLITE_OK)
871 -1, SQLITE_STATIC) != SQLITE_OK)
874 -1, SQLITE_STATIC) != SQLITE_OK)
882 -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
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
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.
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
void mutt_autocrypt_db_normalize_addr(struct Address *a)
Normalise an Email Address.
static sqlite3_stmt * PeerHistoryInsertStmt
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
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
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
int mutt_autocrypt_db_init(bool can_create)
Initialise the Autocrypt SQLite database.
static sqlite3_stmt * AccountDeleteStmt
static char * strdup_column_text(sqlite3_stmt *stmt, int index)
Copy a string from the database.
static sqlite3_stmt * PeerInsertStmt
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 mutt_buffer_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
static const char * mutt_buffer_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.
char * mutt_str_lower(char *str)
Convert all characters in the string to lowercase.
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
#define TAILQ_FOREACH(var, head, field)
bool intl_checked
Checked for IDN?
char * mailbox
Mailbox and host address.
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.