67 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL) != SQLITE_OK)
71 mutt_error(
_(
"Unable to open autocrypt database %s"), db_path);
92 if (!c_autocrypt || !c_autocrypt_dir)
98 struct stat st = { 0 };
230 const char *val = (
const char *) sqlite3_column_text(stmt, index);
283 "WHERE email_addr = ?",
284 -1, SQLITE_PREPARE_PERSISTENT, &
AccountGetStmt, NULL) != SQLITE_OK)
291 SQLITE_STATIC) != SQLITE_OK)
297 if (result != SQLITE_ROW)
299 if (result == SQLITE_DONE)
308 (*account)->prefer_encrypt = sqlite3_column_int(
AccountGetStmt, 3);
329 const char *keydata,
bool prefer_encrypt)
338 "INSERT INTO account "
344 "VALUES (?, ?, ?, ?, ?);",
352 -1, SQLITE_STATIC) != SQLITE_OK)
356 if (sqlite3_bind_text(
AccountInsertStmt, 2, keyid, -1, SQLITE_STATIC) != SQLITE_OK)
358 if (sqlite3_bind_text(
AccountInsertStmt, 3, keydata, -1, SQLITE_STATIC) != SQLITE_OK)
389 "UPDATE account SET "
392 "prefer_encrypt = ?, "
394 "WHERE email_addr = ?;",
435 "DELETE from account "
436 "WHERE email_addr = ?;",
466 sqlite3_stmt *stmt = NULL;
468 int results_len = 0, results_count = 0;
483 "ORDER BY email_addr",
484 -1, &stmt, NULL) != SQLITE_OK)
489 while ((result = sqlite3_step(stmt)) == SQLITE_ROW)
491 if (results_count == results_len)
498 results[results_count++] = account;
504 account->
enabled = sqlite3_column_int(stmt, 4);
507 if (result == SQLITE_DONE)
510 rc = *num_accounts = results_count;
514 while (results_count > 0)
520 sqlite3_finalize(stmt);
572 "autocrypt_timestamp, "
580 "WHERE email_addr = ?",
581 -1, SQLITE_PREPARE_PERSISTENT, &
PeerGetStmt, NULL) != SQLITE_OK)
588 SQLITE_STATIC) != SQLITE_OK)
594 if (result != SQLITE_ROW)
596 if (result == SQLITE_DONE)
603 (*peer)->last_seen = sqlite3_column_int64(
PeerGetStmt, 1);
604 (*peer)->autocrypt_timestamp = sqlite3_column_int64(
PeerGetStmt, 2);
607 (*peer)->prefer_encrypt = sqlite3_column_int(
PeerGetStmt, 5);
608 (*peer)->gossip_timestamp = sqlite3_column_int64(
PeerGetStmt, 6);
630 struct Address *norm_addr = NULL;
640 "autocrypt_timestamp, "
647 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
648 -1, SQLITE_PREPARE_PERSISTENT, &
PeerInsertStmt, NULL) != SQLITE_OK)
655 SQLITE_STATIC) != SQLITE_OK)
702 "autocrypt_timestamp = ?, "
705 "prefer_encrypt = ?, "
706 "gossip_timestamp = ?, "
708 "gossip_keydata = ? "
709 "WHERE email_addr = ?;",
710 -1, SQLITE_PREPARE_PERSISTENT, &
PeerUpdateStmt, NULL) != SQLITE_OK)
787 "INSERT INTO peer_history "
792 "VALUES (?, ?, ?, ?);",
793 -1, SQLITE_PREPARE_PERSISTENT,
801 -1, SQLITE_STATIC) != SQLITE_OK)
806 SQLITE_STATIC) != SQLITE_OK)
869 "INSERT INTO gossip_history "
871 "sender_email_addr, "
875 "VALUES (?, ?, ?, ?, ?);",
876 -1, SQLITE_PREPARE_PERSISTENT,
884 -1, SQLITE_STATIC) != SQLITE_OK)
889 -1, SQLITE_STATIC) != SQLITE_OK)
892 -1, SQLITE_STATIC) != SQLITE_OK)
900 -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.