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 };
229 const char *val = (
const char *) sqlite3_column_text(stmt, index);
282 "WHERE email_addr = ?",
283 -1, SQLITE_PREPARE_PERSISTENT, &
AccountGetStmt, NULL) != SQLITE_OK)
290 SQLITE_STATIC) != SQLITE_OK)
296 if (result != SQLITE_ROW)
298 if (result == SQLITE_DONE)
307 (*account)->prefer_encrypt = sqlite3_column_int(
AccountGetStmt, 3);
328 const char *keydata,
bool prefer_encrypt)
337 "INSERT INTO account "
343 "VALUES (?, ?, ?, ?, ?);",
351 -1, SQLITE_STATIC) != SQLITE_OK)
355 if (sqlite3_bind_text(
AccountInsertStmt, 2, keyid, -1, SQLITE_STATIC) != SQLITE_OK)
357 if (sqlite3_bind_text(
AccountInsertStmt, 3, keydata, -1, SQLITE_STATIC) != SQLITE_OK)
388 "UPDATE account SET "
391 "prefer_encrypt = ?, "
393 "WHERE email_addr = ?;",
434 "DELETE from account "
435 "WHERE email_addr = ?;",
467 sqlite3_stmt *stmt = NULL;
479 "ORDER BY email_addr",
480 -1, &stmt, NULL) != SQLITE_OK)
485 int result = SQLITE_ERROR;
486 while ((result = sqlite3_step(stmt)) == SQLITE_ROW)
494 ac->
enabled = sqlite3_column_int(stmt, 4);
499 if (result == SQLITE_DONE)
514 sqlite3_finalize(stmt);
566 "autocrypt_timestamp, "
574 "WHERE email_addr = ?",
575 -1, SQLITE_PREPARE_PERSISTENT, &
PeerGetStmt, NULL) != SQLITE_OK)
582 SQLITE_STATIC) != SQLITE_OK)
588 if (result != SQLITE_ROW)
590 if (result == SQLITE_DONE)
597 (*peer)->last_seen = sqlite3_column_int64(
PeerGetStmt, 1);
598 (*peer)->autocrypt_timestamp = sqlite3_column_int64(
PeerGetStmt, 2);
601 (*peer)->prefer_encrypt = sqlite3_column_int(
PeerGetStmt, 5);
602 (*peer)->gossip_timestamp = sqlite3_column_int64(
PeerGetStmt, 6);
624 struct Address *norm_addr = NULL;
634 "autocrypt_timestamp, "
641 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);",
642 -1, SQLITE_PREPARE_PERSISTENT, &
PeerInsertStmt, NULL) != SQLITE_OK)
649 SQLITE_STATIC) != SQLITE_OK)
696 "autocrypt_timestamp = ?, "
699 "prefer_encrypt = ?, "
700 "gossip_timestamp = ?, "
702 "gossip_keydata = ? "
703 "WHERE email_addr = ?;",
704 -1, SQLITE_PREPARE_PERSISTENT, &
PeerUpdateStmt, NULL) != SQLITE_OK)
781 "INSERT INTO peer_history "
786 "VALUES (?, ?, ?, ?);",
787 -1, SQLITE_PREPARE_PERSISTENT,
795 -1, SQLITE_STATIC) != SQLITE_OK)
800 SQLITE_STATIC) != SQLITE_OK)
863 "INSERT INTO gossip_history "
865 "sender_email_addr, "
869 "VALUES (?, ?, ?, ?, ?);",
870 -1, SQLITE_PREPARE_PERSISTENT,
878 -1, SQLITE_STATIC) != SQLITE_OK)
883 -1, SQLITE_STATIC) != SQLITE_OK)
886 -1, SQLITE_STATIC) != SQLITE_OK)
894 -1, SQLITE_STATIC) != SQLITE_OK)
struct Address * mutt_addr_create(const char *personal, const char *mailbox)
Create and populate a new Address.
void mutt_addr_free(struct Address **ptr)
Free a single 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.
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
#define ARRAY_SIZE(head)
The number of elements stored.
#define ARRAY_FREE(head)
Release all memory.
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_get_all(struct AutocryptAccountArray *aaa)
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.
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.
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_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.
#define MUTT_MEM_CALLOC(n, type)
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.