64 struct stat st = { 0 };
67 if (stat(c_autocrypt_dir, &st) == 0)
77 buf_printf(prompt,
_(
"%s does not exist. Create it?"), c_autocrypt_dir);
84 mutt_error(
_(
"Can't create %s: %s"), c_autocrypt_dir, strerror(errno));
106 if (!c_autocrypt || !c_autocrypt_dir)
189 mutt_error(
_(
"Please enter a single email address"));
206 mutt_error(
_(
"That email address already has an autocrypt account"));
220 prefer_encrypt =
true;
239 mutt_error(
_(
"Autocrypt account creation aborted"));
261 struct Buffer *keyid = NULL;
262 bool update_db =
false, insert_db =
false, insert_db_history =
false, import_gpg =
false;
272 if (!e || !e->
body || !env)
308 valid_ac_hdr = ac_hdr;
336 insert_db_history =
true;
341 else if (valid_ac_hdr)
345 insert_db_history =
true;
348 if (!(import_gpg || insert_db || update_db))
377 if (insert_db_history)
408 struct Address *peer_addr = NULL;
409 struct Address ac_hdr_addr = { 0 };
410 bool update_db =
false, insert_db =
false, insert_db_history =
false, import_gpg =
false;
420 if (!e || !e->
env || !prot_headers)
445 ac_hdr = ac_hdr->
next)
486 insert_db_history =
true;
494 insert_db_history =
true;
517 if (insert_db_history)
533 insert_db_history =
false;
564 bool all_encrypt =
true, has_discourage =
false;
565 const char *matching_key = NULL;
567 struct Buffer *keylist_buf = NULL;
637 matching_key = peer->
keyid;
642 has_discourage =
true;
653 has_discourage =
true;
675 else if (has_discourage)
735 bool prefer_encrypt,
const char *keydata)
737 fprintf(fp,
"addr=%s; ", addr);
739 fputs(
"prefer-encrypt=mutual; ", fp);
740 fputs(
"keydata=\n", fp);
746 while (*keydata && count < 75)
783 fputs(
"Autocrypt: ", fp);
808 gossip = gossip->
next)
810 fputs(
"Autocrypt-Gossip: ", fp);
850 const char *keydata = NULL;
870 const char *
addr = NULL;
934 if ((!
mw_enter_fname(
_(
"Scan mailbox"), folderbuf,
true, m_cur,
false, NULL,
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
void mutt_addrlist_append(struct AddressList *al, struct Address *a)
Append an Address to an AddressList.
struct Address * mutt_addr_copy(const struct Address *addr)
Copy the real address.
const struct Address * cs_subset_address(const struct ConfigSubset *sub, const char *name)
Get an Address config item by name.
char * AutocryptSignAs
Autocrypt Key id to sign as.
char * AutocryptDefaultKey
Autocrypt default key id (used for postponing messages)
void mutt_autocrypt_db_normalize_addrlist(struct AddressList *al)
Normalise a list of Email Addresses.
struct AutocryptPeer * mutt_autocrypt_db_peer_new(void)
Create a new AutocryptPeer.
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.
void mutt_autocrypt_db_normalize_addr(struct Address *a)
Normalise an Email Address.
void mutt_autocrypt_db_peer_history_free(struct AutocryptPeerHistory **ptr)
Free an AutocryptPeerHistory.
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.
int mutt_autocrypt_db_init(bool can_create)
Initialise the Autocrypt SQLite database.
int mutt_autocrypt_db_peer_history_insert(struct Address *addr, struct AutocryptPeerHistory *peerhist)
Insert peer history into the Autocrypt database.
AutocryptRec
Recommendation.
@ AUTOCRYPT_REC_DISCOURAGE
Prefer not to use Autocrypt.
@ AUTOCRYPT_REC_NO
Do no use Autocrypt.
@ AUTOCRYPT_REC_OFF
No recommendations.
@ AUTOCRYPT_REC_AVAILABLE
Autocrypt is available.
@ AUTOCRYPT_REC_YES
Autocrypt should be used.
int mutt_autocrypt_process_autocrypt_header(struct Email *e, struct Envelope *env)
Parse an Autocrypt email header.
int mutt_autocrypt_generate_gossip_list(struct Email *e)
Create the gossip list headers.
static int autocrypt_dir_init(bool can_create)
Initialise an Autocrypt directory.
static void write_autocrypt_header_line(FILE *fp, const char *addr, bool prefer_encrypt, const char *keydata)
Write an Autocrypt header to a file.
void mutt_autocrypt_cleanup(void)
Shutdown Autocrypt.
int mutt_autocrypt_write_gossip_headers(struct Envelope *env, FILE *fp)
Write the Autocrypt gossip headers to a file.
enum AutocryptRec mutt_autocrypt_ui_recommendation(const struct Email *e, char **keylist)
Get the recommended action for an Email.
int mutt_autocrypt_account_init(bool prompt)
Create a new Autocrypt account.
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
int mutt_autocrypt_write_autocrypt_header(struct Envelope *env, FILE *fp)
Write the Autocrypt header to a file.
int mutt_autocrypt_set_sign_as_default_key(struct Email *e)
Set the Autocrypt default key for signing.
void mutt_autocrypt_scan_mailboxes(void)
Scan mailboxes for Autocrypt headers.
int mutt_autocrypt_process_gossip_header(struct Email *e, struct Envelope *prot_headers)
Parse an Autocrypt email gossip header.
Select a Mailbox from a list.
#define MUTT_SEL_NO_FLAGS
No flags are set.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
struct Buffer * buf_new(const char *str)
Allocate a new Buffer.
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
bool buf_str_equal(const struct Buffer *a, const struct Buffer *b)
Return if two buffers are equal.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
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.
Structs that make up an email.
struct Envelope * mutt_env_new(void)
Create a new Envelope.
struct AutocryptHeader * mutt_autocrypthdr_new(void)
Create a new AutocryptHeader.
void mutt_autocrypthdr_free(struct AutocryptHeader **ptr)
Free an AutocryptHeader.
int mutt_file_mkdir(const char *path, mode_t mode)
Recursively create directories.
bool mutt_autocrypt_gpgme_is_valid_key(const char *keyid)
Is a key id valid?
int mutt_autocrypt_gpgme_init(void)
Initialise GPGME.
int mutt_autocrypt_gpgme_import_key(const char *keydata, struct Buffer *keyid)
Read a key from GPGME.
int mutt_autocrypt_gpgme_select_or_create_key(struct Address *addr, struct Buffer *keyid, struct Buffer *keydata)
Ask the user to select or create an Autocrypt key.
int mw_enter_fname(const char *prompt, struct Buffer *fname, bool mailbox, struct Mailbox *m, bool multiple, char ***files, int *numfiles, SelectFileFlags flags)
Ask the user to select a file -.
#define mutt_message(...)
Convenience wrapper for the gui headers.
GUI manage the main index (list of emails)
struct Mailbox * get_current_mailbox(void)
Get the current Mailbox.
@ TYPE_MULTIPART
Type: 'multipart/*'.
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Convenience wrapper for the library headers.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
void buf_expand_path_regex(struct Buffer *buf, bool regex)
Create the canonical path (with regex char escaping)
Some miscellaneous functions.
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
#define MUTT_READONLY
Open in read-only mode.
API for encryption/signing of emails.
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
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.
QuadOption
Possible values for a quad-option.
@ MUTT_NO
User answered 'No', or assume 'No'.
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
enum QuadOption query_yesorno_ignore_macro(const char *prompt, enum QuadOption def)
Ask the user a Yes/No question ignoring the macro buffer.
#define TAILQ_FOREACH(var, head, field)
#define TAILQ_FIRST(head)
#define TAILQ_NEXT(elm, field)
#define TAILQ_HEAD_INITIALIZER(head)
#define TAILQ_EMPTY(head)
Convenience wrapper for the send headers.
int mutt_edit_address(struct AddressList *al, const char *field, bool expand_aliases)
Edit an email address.
struct Buffer * personal
Real name of address.
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 * 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 * 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.
struct Envelope * mime_headers
Memory hole protected headers.
char * subtype
content-type subtype
unsigned int type
content-type primary type, ContentType
String manipulation buffer.
The envelope/body of an email.
struct Envelope * env
Envelope information.
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
struct Body * body
List of MIME parts.
time_t date_sent
Time when the message was sent (UTC)
struct AddressList to
Email's 'To' list.
struct AddressList reply_to
Email's 'reply-to'.
char * message_id
Message ID.
struct AutocryptHeader * autocrypt_gossip
Autocrypt Gossip header.
struct AddressList cc
Email's 'Cc' list.
struct AutocryptHeader * autocrypt
Autocrypt header.
struct AddressList bcc
Email's 'Bcc' list.
struct AddressList from
Email's 'From' list.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.