NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c File Reference

Attachment functions. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "question/lib.h"
#include "send/lib.h"
#include "attach.h"
#include "functions.h"
#include "mutt_attach.h"
#include "private_data.h"
#include "recvattach.h"
#include "recvcmd.h"
+ Include dependency graph for functions.c:

Go to the source code of this file.

Functions

static void attach_collapse (struct AttachCtx *actx, struct Menu *menu)
 Close the tree of the current attachment.
 
static bool check_attach (struct AttachPrivateData *priv)
 Check if in attach-message mode.
 
static bool check_readonly (struct Mailbox *m)
 Check if the Mailbox is readonly.
 
static void recvattach_extract_pgp_keys (struct AttachCtx *actx, struct Menu *menu)
 Extract PGP keys from attachments.
 
static int recvattach_pgp_check_traditional (struct AttachCtx *actx, struct Menu *menu)
 Is the Attachment inline PGP?
 
static int op_attachment_collapse (struct AttachPrivateData *priv, int op)
 toggle display of subparts - Implements attach_function_t -
 
static int op_attachment_delete (struct AttachPrivateData *priv, int op)
 delete the current entry - Implements attach_function_t -
 
static int op_attachment_edit_type (struct AttachPrivateData *priv, int op)
 edit attachment content type - Implements attach_function_t -
 
static int op_attachment_pipe (struct AttachPrivateData *priv, int op)
 pipe message/attachment to a shell command - Implements attach_function_t -
 
static int op_attachment_print (struct AttachPrivateData *priv, int op)
 print the current entry - Implements attach_function_t -
 
static int op_attachment_save (struct AttachPrivateData *priv, int op)
 save message/attachment to a mailbox/file - Implements attach_function_t -
 
static int op_attachment_undelete (struct AttachPrivateData *priv, int op)
 undelete the current entry - Implements attach_function_t -
 
static int op_attachment_view (struct AttachPrivateData *priv, int op)
 view attachment using mailcap entry if necessary - Implements attach_function_t -
 
static int op_attachment_view_mailcap (struct AttachPrivateData *priv, int op)
 force viewing of attachment using mailcap - Implements attach_function_t -
 
static int op_attachment_view_pager (struct AttachPrivateData *priv, int op)
 view attachment in pager using copiousoutput mailcap - Implements attach_function_t -
 
static int op_attachment_view_text (struct AttachPrivateData *priv, int op)
 view attachment as text - Implements attach_function_t -
 
static int op_bounce_message (struct AttachPrivateData *priv, int op)
 remail a message to another user - Implements attach_function_t -
 
static int op_check_traditional (struct AttachPrivateData *priv, int op)
 check for classic PGP - Implements attach_function_t -
 
static int op_compose_to_sender (struct AttachPrivateData *priv, int op)
 compose new message to the current message sender - Implements attach_function_t -
 
static int op_exit (struct AttachPrivateData *priv, int op)
 exit this menu - Implements attach_function_t -
 
static int op_extract_keys (struct AttachPrivateData *priv, int op)
 extract supported public keys - Implements attach_function_t -
 
static int op_forget_passphrase (struct AttachPrivateData *priv, int op)
 wipe passphrases from memory - Implements attach_function_t -
 
static int op_forward_message (struct AttachPrivateData *priv, int op)
 forward a message with comments - Implements attach_function_t -
 
static int op_list_subscribe (struct AttachPrivateData *priv, int op)
 subscribe to a mailing list - Implements attach_function_t -
 
static int op_list_unsubscribe (struct AttachPrivateData *priv, int op)
 unsubscribe from a mailing list - Implements attach_function_t -
 
static int op_reply (struct AttachPrivateData *priv, int op)
 reply to a message - Implements attach_function_t -
 
static int op_resend (struct AttachPrivateData *priv, int op)
 use the current message as a template for a new one - Implements attach_function_t -
 
static int op_followup (struct AttachPrivateData *priv, int op)
 followup to newsgroup - Implements attach_function_t -
 
static int op_forward_to_group (struct AttachPrivateData *priv, int op)
 forward to newsgroup - Implements attach_function_t -
 
int attach_function_dispatcher (struct MuttWindow *win, int op)
 Perform a Attach function - Implements function_dispatcher_t -.
 

Variables

static const char * Function_not_permitted_in_attach_message_mode
 Error message for unavailable functions in attach mode.
 
const struct MenuFuncOp OpAttachment []
 Functions for the Attachment Menu.
 
const struct MenuOpSeq AttachmentDefaultBindings []
 Key bindings for the Attachment Menu.
 
static const struct AttachFunction AttachFunctions []
 All the NeoMutt functions that the Attach supports.
 

Detailed Description

Attachment functions.

Authors
  • Richard Russon
  • Dennis Schön

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file functions.c.

Function Documentation

◆ attach_collapse()

static void attach_collapse ( struct AttachCtx actx,
struct Menu menu 
)
static

Close the tree of the current attachment.

Parameters
actxAttachment context
menuMenu listing Attachments

Definition at line 131 of file functions.c.

132{
133 int rindex, curlevel;
134
135 struct AttachPtr *cur_att = current_attachment(actx, menu);
136 cur_att->collapsed = !cur_att->collapsed;
137 /* When expanding, expand all the children too */
138 if (cur_att->collapsed)
139 return;
140
141 curlevel = cur_att->level;
142 const int index = menu_get_index(menu);
143 rindex = actx->v2r[index] + 1;
144
145 const bool c_digest_collapse = cs_subset_bool(NeoMutt->sub, "digest_collapse");
146 while ((rindex < actx->idxlen) && (actx->idx[rindex]->level > curlevel))
147 {
148 if (c_digest_collapse && (actx->idx[rindex]->body->type == TYPE_MULTIPART) &&
149 mutt_istr_equal(actx->idx[rindex]->body->subtype, "digest"))
150 {
151 actx->idx[rindex]->collapsed = true;
152 }
153 else
154 {
155 actx->idx[rindex]->collapsed = false;
156 }
157 rindex++;
158 }
159}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:160
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition: mime.h:37
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:672
struct AttachPtr * current_attachment(struct AttachCtx *actx, struct Menu *menu)
Get the current attachment.
Definition: recvattach.c:77
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:69
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:73
An email to which things will be attached.
Definition: attach.h:37
struct Body * body
Attachment.
Definition: attach.h:38
bool collapsed
Group is collapsed.
Definition: attach.h:46
int level
Nesting depth of attachment.
Definition: attach.h:42
char * subtype
content-type subtype
Definition: body.h:61
unsigned int type
content-type primary type, ContentType
Definition: body.h:40
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_attach()

static bool check_attach ( struct AttachPrivateData priv)
static

Check if in attach-message mode.

Parameters
privPrivate Attach data
Return values
trueMailbox is readonly

Definition at line 166 of file functions.c.

167{
168 if (priv->attach_msg)
169 {
172 return true;
173 }
174
175 return false;
176}
static const char * Function_not_permitted_in_attach_message_mode
Error message for unavailable functions in attach mode.
Definition: functions.c:55
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition: get.c:58
#define mutt_error(...)
Definition: logging2.h:92
#define _(a)
Definition: message.h:28
bool attach_msg
Are we in "attach message" mode?
Definition: private_data.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_readonly()

static bool check_readonly ( struct Mailbox m)
static

Check if the Mailbox is readonly.

Parameters
mMailbox
Return values
trueMailbox is readonly

Definition at line 183 of file functions.c.

184{
185 if (!m || m->readonly)
186 {
188 mutt_error(_("Mailbox is read-only"));
189 return true;
190 }
191
192 return false;
193}
bool readonly
Don't allow changes to the mailbox.
Definition: mailbox.h:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recvattach_extract_pgp_keys()

static void recvattach_extract_pgp_keys ( struct AttachCtx actx,
struct Menu menu 
)
static

Extract PGP keys from attachments.

Parameters
actxAttachment context
menuMenu listing attachments

Definition at line 200 of file functions.c.

201{
202 if (menu->tag_prefix)
203 {
204 for (int i = 0; i < actx->idxlen; i++)
205 {
206 if (actx->idx[i]->body->tagged)
207 {
209 }
210 }
211 }
212 else
213 {
214 struct AttachPtr *cur_att = current_attachment(actx, menu);
216 }
217}
void crypt_pgp_extract_key_from_attachment(FILE *fp, struct Body *b)
Wrapper for CryptModuleSpecs::pgp_extract_key_from_attachment()
Definition: cryptglue.c:394
short idxlen
Number of attachmentes.
Definition: attach.h:70
FILE * fp
Used in the recvattach menu.
Definition: attach.h:39
bool tagged
This attachment is tagged.
Definition: body.h:90
bool tag_prefix
User has pressed <tag-prefix>
Definition: lib.h:85
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recvattach_pgp_check_traditional()

static int recvattach_pgp_check_traditional ( struct AttachCtx actx,
struct Menu menu 
)
static

Is the Attachment inline PGP?

Parameters
actxAttachment to check
menuMenu listing Attachments
Return values
1The (tagged) Attachment(s) are inline PGP
Note
If the menu->tagprefix is set, all the tagged attachments will be checked.

Definition at line 227 of file functions.c.

228{
229 int rc = 0;
230
231 if (menu->tag_prefix)
232 {
233 for (int i = 0; i < actx->idxlen; i++)
234 if (actx->idx[i]->body->tagged)
235 rc = rc || crypt_pgp_check_traditional(actx->idx[i]->fp, actx->idx[i]->body, true);
236 }
237 else
238 {
239 struct AttachPtr *cur_att = current_attachment(actx, menu);
240 rc = crypt_pgp_check_traditional(cur_att->fp, cur_att->body, true);
241 }
242
243 return rc;
244}
bool crypt_pgp_check_traditional(FILE *fp, struct Body *b, bool just_one)
Wrapper for CryptModuleSpecs::pgp_check_traditional()
Definition: cryptglue.c:282
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ Function_not_permitted_in_attach_message_mode

const char* Function_not_permitted_in_attach_message_mode
static
Initial value:
= N_(
"Function not permitted in attach-message mode")
#define N_(a)
Definition: message.h:32

Error message for unavailable functions in attach mode.

Definition at line 55 of file functions.c.

◆ OpAttachment

const struct MenuFuncOp OpAttachment[]

Functions for the Attachment Menu.

Definition at line 62 of file functions.c.

◆ AttachmentDefaultBindings

const struct MenuOpSeq AttachmentDefaultBindings[]
Initial value:
= {
{ OP_ATTACHMENT_COLLAPSE, "v" },
{ OP_ATTACHMENT_DELETE, "d" },
{ OP_ATTACHMENT_EDIT_TYPE, "\005" },
{ OP_EXIT, "q" },
{ OP_PIPE, "|" },
{ OP_ATTACHMENT_PRINT, "p" },
{ OP_ATTACHMENT_SAVE, "s" },
{ OP_ATTACHMENT_UNDELETE, "u" },
{ OP_ATTACHMENT_VIEW, "<keypadenter>" },
{ OP_ATTACHMENT_VIEW, "\n" },
{ OP_ATTACHMENT_VIEW, "\r" },
{ OP_ATTACHMENT_VIEW_MAILCAP, "m" },
{ OP_ATTACHMENT_VIEW_TEXT, "T" },
{ OP_BOUNCE_MESSAGE, "b" },
{ OP_CHECK_TRADITIONAL, "\033P" },
{ OP_DISPLAY_HEADERS, "h" },
{ OP_EXTRACT_KEYS, "\013" },
{ OP_FORGET_PASSPHRASE, "\006" },
{ OP_FORWARD_MESSAGE, "f" },
{ OP_GROUP_REPLY, "g" },
{ OP_LIST_REPLY, "L" },
{ OP_REPLY, "r" },
{ OP_RESEND, "\033e" },
{ 0, NULL },
}

Key bindings for the Attachment Menu.

Definition at line 98 of file functions.c.

◆ AttachFunctions

const struct AttachFunction AttachFunctions[]
static

All the NeoMutt functions that the Attach supports.

Definition at line 674 of file functions.c.