NeoMutt  2024-11-14-138-ge5ca67
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
expando.c
Go to the documentation of this file.
1
29#include <stdbool.h>
30#include <stdio.h>
31#include "private.h"
32#include "mutt/lib.h"
33#include "address/lib.h"
34#include "expando.h"
35#include "lib.h"
36#include "expando/lib.h"
37
41static void autocrypt_address(const struct ExpandoNode *node, void *data,
42 MuttFormatFlags flags, struct Buffer *buf)
43{
44 const struct AccountEntry *entry = data;
45
46 buf_copy(buf, entry->addr->mailbox);
47}
48
52static void autocrypt_enabled(const struct ExpandoNode *node, void *data,
53 MuttFormatFlags flags, struct Buffer *buf)
54{
55 const struct AccountEntry *entry = data;
56
57 if (entry->account->enabled)
58 {
59 /* L10N: Autocrypt Account menu.
60 flag that an account is enabled/active */
61 buf_addstr(buf, _("active"));
62 }
63 else
64 {
65 /* L10N: Autocrypt Account menu.
66 flag that an account is disabled/inactive */
67 buf_addstr(buf, _("inactive"));
68 }
69}
70
74static void autocrypt_keyid(const struct ExpandoNode *node, void *data,
75 MuttFormatFlags flags, struct Buffer *buf)
76{
77 const struct AccountEntry *entry = data;
78
79 const char *s = entry->account->keyid;
80 buf_strcpy(buf, s);
81}
82
86static long autocrypt_number_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
87{
88 const struct AccountEntry *entry = data;
89
90 return entry->num;
91}
92
96static void autocrypt_prefer_encrypt(const struct ExpandoNode *node, void *data,
97 MuttFormatFlags flags, struct Buffer *buf)
98{
99 const struct AccountEntry *entry = data;
100
101 if (entry->account->prefer_encrypt)
102 {
103 /* L10N: Autocrypt Account menu.
104 flag that an account has prefer-encrypt set */
105 buf_addstr(buf, _("prefer encrypt"));
106 }
107 else
108 {
109 /* L10N: Autocrypt Account menu.
110 flag that an account has prefer-encrypt unset;
111 thus encryption will need to be manually enabled. */
112 buf_addstr(buf, _("manual encrypt"));
113 }
114}
115
122 // clang-format off
128 { -1, -1, NULL, NULL },
129 // clang-format on
130};
Email Address Handling.
const struct ExpandoRenderCallback AutocryptRenderCallbacks[]
Callbacks for Autocrypt Expandos.
Definition: expando.c:121
@ ED_AUT_ADDRESS
AccountEntry.addr.
Definition: private.h:62
@ ED_AUT_KEYID
AutocryptAccount.keyid.
Definition: private.h:61
@ ED_AUT_NUMBER
AccountEntry.num.
Definition: private.h:63
@ ED_AUT_ENABLED
AutocryptAccount.enabled.
Definition: private.h:60
@ ED_AUT_PREFER_ENCRYPT
AutocryptAccount.prefer_encrypt.
Definition: private.h:64
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:226
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
Definition: buffer.c:601
@ ED_AUTOCRYPT
Autocrypt ED_AUT_ ExpandoDataAutocrypt.
Definition: domain.h:37
Parse Expando string.
static long autocrypt_number_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Autocrypt: Index number - Implements get_number_t -.
Definition: expando.c:86
static void autocrypt_keyid(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Autocrypt: GPG Key - Implements get_string_t -.
Definition: expando.c:74
static void autocrypt_prefer_encrypt(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Autocrypt: Prefer-encrypt flag - Implements get_string_t -.
Definition: expando.c:96
static void autocrypt_address(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Autocrypt: Address - Implements get_string_t -.
Definition: expando.c:41
static void autocrypt_enabled(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Autocrypt: Status flag - Implements get_string_t -.
Definition: expando.c:52
Convenience wrapper for the library headers.
#define _(a)
Definition: message.h:28
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: render.h:32
Sidebar Expando definitions.
GUI display the mailboxes in a side panel.
Key value store.
An entry in the Autocrypt account Menu.
Definition: private.h:46
struct Address * addr
Email address associated with the account.
Definition: private.h:49
struct AutocryptAccount * account
Account details.
Definition: private.h:48
int num
Number in the index.
Definition: private.h:47
struct Buffer * mailbox
Mailbox and host address.
Definition: address.h:38
char * keyid
PGP Key id.
Definition: lib.h:112
bool enabled
Is this account enabled.
Definition: lib.h:115
bool prefer_encrypt
false = nopref, true = mutual
Definition: lib.h:114
String manipulation buffer.
Definition: buffer.h:36
Basic Expando Node.
Definition: node.h:67