61 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) != SQLITE_OK)
65 mutt_error(
_(
"Unable to open autocrypt database %s"), db_path);
94 SQLITE_OPEN_READWRITE, NULL) != SQLITE_OK)
223 const char *val = (
const char *) sqlite3_column_text(stmt, index);
276 "WHERE email_addr = ?",
277 -1, SQLITE_PREPARE_PERSISTENT, &
AccountGetStmt, NULL) != SQLITE_OK)
287 if (result != SQLITE_ROW)
289 if (result == SQLITE_DONE)
298 (*account)->prefer_encrypt = sqlite3_column_int(
AccountGetStmt, 3);
319 const char *keydata,
bool prefer_encrypt)
328 "INSERT INTO account " 334 "VALUES (?, ?, ?, ?, ?);",
343 if (sqlite3_bind_text(
AccountInsertStmt, 2, keyid, -1, SQLITE_STATIC) != SQLITE_OK)
345 if (sqlite3_bind_text(
AccountInsertStmt, 3, keydata, -1, SQLITE_STATIC) != SQLITE_OK)
376 "UPDATE account SET " 379 "prefer_encrypt = ?, " 381 "WHERE email_addr = ?;",
422 "DELETE from account " 423 "WHERE email_addr = ?;",
453 sqlite3_stmt *stmt = NULL;
455 int results_len = 0, results_count = 0;
470 "ORDER BY email_addr",
471 -1, &stmt, NULL) != SQLITE_OK)
476 while ((result = sqlite3_step(stmt)) == SQLITE_ROW)
478 if (results_count == results_len)
485 results[results_count++] = account;
491 account->
enabled = sqlite3_column_int(stmt, 4);
494 if (result == SQLITE_DONE)
497 rc = *num_accounts = results_count;
501 while (results_count > 0)
507 sqlite3_finalize(stmt);
559 "autocrypt_timestamp, " 567 "WHERE email_addr = ?",
568 -1, SQLITE_PREPARE_PERSISTENT, &
PeerGetStmt, NULL) != SQLITE_OK)
574 if (sqlite3_bind_text(
PeerGetStmt, 1, norm_addr->
mailbox, -1, SQLITE_STATIC) != SQLITE_OK)
578 if (result != SQLITE_ROW)
580 if (result == SQLITE_DONE)
587 (*peer)->last_seen = sqlite3_column_int64(
PeerGetStmt, 1);
588 (*peer)->autocrypt_timestamp = sqlite3_column_int64(
PeerGetStmt, 2);
591 (*peer)->prefer_encrypt = sqlite3_column_int(
PeerGetStmt, 5);
592 (*peer)->gossip_timestamp = sqlite3_column_int64(
PeerGetStmt, 6);
614 struct Address *norm_addr = NULL;
624 "autocrypt_timestamp, " 631 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
632 -1, SQLITE_PREPARE_PERSISTENT, &
PeerInsertStmt, NULL) != SQLITE_OK)
683 "autocrypt_timestamp = ?, " 686 "prefer_encrypt = ?, " 687 "gossip_timestamp = ?, " 689 "gossip_keydata = ? " 690 "WHERE email_addr = ?;",
691 -1, SQLITE_PREPARE_PERSISTENT, &
PeerUpdateStmt, NULL) != SQLITE_OK)
768 "INSERT INTO peer_history " 773 "VALUES (?, ?, ?, ?);",
774 -1, SQLITE_PREPARE_PERSISTENT,
784 SQLITE_STATIC) != SQLITE_OK)
845 "INSERT INTO gossip_history " 847 "sender_email_addr, " 851 "VALUES (?, ?, ?, ?, ?);",
852 -1, SQLITE_PREPARE_PERSISTENT,
860 SQLITE_STATIC) != SQLITE_OK)
865 -1, SQLITE_STATIC) != SQLITE_OK)
868 -1, SQLITE_STATIC) != SQLITE_OK)
876 -1, SQLITE_STATIC) != SQLITE_OK)
char * C_AutocryptDir
Config: Location of autocrypt files, including the GPG keyring and SQLite database.
void mutt_autocrypt_db_close(void)
Close the Autocrypt SQLite database connection.
void mutt_autocrypt_db_normalize_addr(struct Address *a)
Normalise an Email Address.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
struct AutocryptPeerHistory * mutt_autocrypt_db_peer_history_new(void)
Create a new AutocryptPeerHistory.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
#define TAILQ_FOREACH(var, head, field)
void mutt_autocrypt_db_account_free(struct AutocryptAccount **ptr)
Free an AutocryptAccount.
Autocrypt end-to-end encryption.
void mutt_autocrypt_db_gossip_history_free(struct AutocryptGossipHistory **ptr)
Free an AutocryptGossipHistory.
int mutt_addrlist_to_local(struct AddressList *al)
Convert an Address list from Punycode.
bool C_Autocrypt
Config: Enables the Autocrypt feature.
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
struct AutocryptPeer * mutt_autocrypt_db_peer_new(void)
Create a new AutocryptPeer.
String manipulation buffer.
char * mutt_str_dup(const char *str)
Copy a string, safely.
struct Address * mutt_addr_new(void)
Create a new Address.
struct AutocryptAccount * mutt_autocrypt_db_account_new(void)
Create a new AutocryptAccount.
char * mailbox
Mailbox and host address.
int mutt_autocrypt_db_init(bool can_create)
Initialise the Autocrypt SQLite database.
void mutt_addr_free(struct Address **ptr)
Free a single Address.
bool mutt_addr_to_local(struct Address *a)
Convert an Address from Punycode.
static sqlite3_stmt * AccountUpdateStmt
int mutt_autocrypt_account_init(bool prompt)
Create a new Autocrypt account.
bool is_intl
International Domain Name.
static sqlite3_stmt * AccountInsertStmt
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
sqlite3_int64 gossip_timestamp
int mutt_autocrypt_db_account_delete(struct AutocryptAccount *acct)
Delete an Account from the Autocrypt database.
sqlite3_int64 autocrypt_timestamp
void mutt_autocrypt_scan_mailboxes(void)
Scan mailboxes for Autocrypt headers.
static struct Address * copy_normalize_addr(struct Address *addr)
Copy a normalised Email Address.
bool prefer_encrypt
false = nopref, true = mutual
bool intl_checked
Checked for IDN?
char * mutt_str_lower(char *s)
Convert all characters in the string to lowercase.
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
static sqlite3_stmt * PeerGetStmt
Autocrypt gossip history.
int mutt_autocrypt_db_account_update(struct AutocryptAccount *acct)
Update Account info in the Autocrypt database.
static sqlite3_stmt * GossipHistoryInsertStmt
int mutt_autocrypt_db_peer_insert(struct Address *addr, struct AutocryptPeer *peer)
Insert a peer into the Autocrypt database.
Shared constants/structs that are private to Autocrypt.
int mutt_autocrypt_schema_init(void)
Set up an Autocrypt database.
struct AutocryptGossipHistory * mutt_autocrypt_db_gossip_history_new(void)
Create a new AutocryptGossipHistory.
static sqlite3_stmt * PeerUpdateStmt
int mutt_autocrypt_db_peer_history_insert(struct Address *addr, struct AutocryptPeerHistory *peerhist)
Insert peer history into the Autocrypt database.
int mutt_autocrypt_db_account_get(struct Address *addr, struct AutocryptAccount **account)
Get Autocrypt Account data from the database.
bool prefer_encrypt
false = nopref, true = mutual
void mutt_autocrypt_db_normalize_addrlist(struct AddressList *al)
Normalise a list of Email Addresses.
int mutt_autocrypt_db_peer_update(struct AutocryptPeer *peer)
Update the peer info in an Autocrypt database.
static int autocrypt_db_create(const char *db_path)
Create an Autocrypt SQLite database.
bool mutt_addr_to_intl(struct Address *a)
Convert an Address to Punycode.
static sqlite3_stmt * AccountDeleteStmt
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
static sqlite3_stmt * AccountGetStmt
static sqlite3_stmt * PeerInsertStmt
size_t mutt_buffer_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
void mutt_autocrypt_db_peer_free(struct AutocryptPeer **ptr)
Free an AutocryptPeer.
static sqlite3_stmt * PeerHistoryInsertStmt
Convenience wrapper for the library headers.
void mutt_autocrypt_db_peer_history_free(struct AutocryptPeerHistory **ptr)
Free an AutocryptPeerHistory.
int mutt_autocrypt_db_peer_get(struct Address *addr, struct AutocryptPeer **peer)
Get peer info from the 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_schema_update(void)
Update the version number of the Autocrypt database schema.
int mutt_autocrypt_db_account_get_all(struct AutocryptAccount ***accounts, int *num_accounts)
Get all accounts from 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.
static char * strdup_column_text(sqlite3_stmt *stmt, int index)
Copy a string from the database.