NeoMutt  2024-10-02-37-gfa9146
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 * Not_available_in_this_menu = N_("Not available in this menu")
 Error message for unavailable functions.
 
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 133 of file functions.c.

134{
135 int rindex, curlevel;
136
137 struct AttachPtr *cur_att = current_attachment(actx, menu);
138 cur_att->collapsed = !cur_att->collapsed;
139 /* When expanding, expand all the children too */
140 if (cur_att->collapsed)
141 return;
142
143 curlevel = cur_att->level;
144 const int index = menu_get_index(menu);
145 rindex = actx->v2r[index] + 1;
146
147 const bool c_digest_collapse = cs_subset_bool(NeoMutt->sub, "digest_collapse");
148 while ((rindex < actx->idxlen) && (actx->idx[rindex]->level > curlevel))
149 {
150 if (c_digest_collapse && (actx->idx[rindex]->body->type == TYPE_MULTIPART) &&
151 mutt_istr_equal(actx->idx[rindex]->body->subtype, "digest"))
152 {
153 actx->idx[rindex]->collapsed = true;
154 }
155 else
156 {
157 actx->idx[rindex]->collapsed = false;
158 }
159 rindex++;
160 }
161}
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 168 of file functions.c.

169{
170 if (priv->attach_msg)
171 {
174 return true;
175 }
176
177 return false;
178}
static const char * Function_not_permitted_in_attach_message_mode
Error message for unavailable functions in attach mode.
Definition: functions.c:57
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 185 of file functions.c.

186{
187 if (!m || m->readonly)
188 {
190 mutt_error(_("Mailbox is read-only"));
191 return true;
192 }
193
194 return false;
195}
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 202 of file functions.c.

203{
204 if (menu->tag_prefix)
205 {
206 for (int i = 0; i < actx->idxlen; i++)
207 {
208 if (actx->idx[i]->body->tagged)
209 {
211 }
212 }
213 }
214 else
215 {
216 struct AttachPtr *cur_att = current_attachment(actx, menu);
218 }
219}
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 229 of file functions.c.

230{
231 int rc = 0;
232
233 if (menu->tag_prefix)
234 {
235 for (int i = 0; i < actx->idxlen; i++)
236 if (actx->idx[i]->body->tagged)
237 rc = rc || crypt_pgp_check_traditional(actx->idx[i]->fp, actx->idx[i]->body, true);
238 }
239 else
240 {
241 struct AttachPtr *cur_att = current_attachment(actx, menu);
242 rc = crypt_pgp_check_traditional(cur_att->fp, cur_att->body, true);
243 }
244
245 return rc;
246}
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

◆ Not_available_in_this_menu

const char* Not_available_in_this_menu = N_("Not available in this menu")
static

Error message for unavailable functions.

Definition at line 55 of file functions.c.

◆ 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 57 of file functions.c.

◆ OpAttachment

const struct MenuFuncOp OpAttachment[]

Functions for the Attachment Menu.

Definition at line 64 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 100 of file functions.c.

◆ AttachFunctions

const struct AttachFunction AttachFunctions[]
static

All the NeoMutt functions that the Attach supports.

Definition at line 676 of file functions.c.