NeoMutt
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 "globals.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

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

138{
139 int rindex, curlevel;
140
141 struct AttachPtr *cur_att = current_attachment(actx, menu);
142 cur_att->collapsed = !cur_att->collapsed;
143 /* When expanding, expand all the children too */
144 if (cur_att->collapsed)
145 return;
146
147 curlevel = cur_att->level;
148 const int index = menu_get_index(menu);
149 rindex = actx->v2r[index] + 1;
150
151 const bool c_digest_collapse = cs_subset_bool(NeoMutt->sub, "digest_collapse");
152 while ((rindex < actx->idxlen) && (actx->idx[rindex]->level > curlevel))
153 {
154 if (c_digest_collapse && (actx->idx[rindex]->body->type == TYPE_MULTIPART) &&
155 mutt_istr_equal(actx->idx[rindex]->body->subtype, "digest"))
156 {
157 actx->idx[rindex]->collapsed = true;
158 }
159 else
160 {
161 actx->idx[rindex]->collapsed = false;
162 }
163 rindex++;
164 }
165}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:156
@ 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:810
struct AttachPtr * current_attachment(struct AttachCtx *actx, struct Menu *menu)
Get the current attachment.
Definition: recvattach.c:71
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:55
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:59
An email to which things will be attached.
Definition: attach.h:35
struct Body * body
Attachment.
Definition: attach.h:36
bool collapsed
Group is collapsed.
Definition: attach.h:44
int level
Nesting depth of attachment.
Definition: attach.h:40
char * subtype
content-type subtype
Definition: body.h:60
unsigned int type
content-type primary type, ContentType
Definition: body.h:40
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
+ 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 172 of file functions.c.

173{
174 if (priv->attach_msg)
175 {
178 return true;
179 }
180
181 return false;
182}
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:57
#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:41
+ 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 189 of file functions.c.

190{
191 if (!m || m->readonly)
192 {
194 mutt_error(_("Mailbox is read-only"));
195 return true;
196 }
197
198 return false;
199}
bool readonly
Don't allow changes to the mailbox.
Definition: mailbox.h:115
+ 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 206 of file functions.c.

207{
208 if (menu->tag_prefix)
209 {
210 for (int i = 0; i < actx->idxlen; i++)
211 {
212 if (actx->idx[i]->body->tagged)
213 {
215 }
216 }
217 }
218 else
219 {
220 struct AttachPtr *cur_att = current_attachment(actx, menu);
222 }
223}
void crypt_pgp_extract_key_from_attachment(FILE *fp, struct Body *top)
Wrapper for CryptModuleSpecs::pgp_extract_key_from_attachment()
Definition: cryptglue.c:395
short idxlen
Number of attachmentes.
Definition: attach.h:56
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
bool tagged
This attachment is tagged.
Definition: body.h:89
bool tag_prefix
User has pressed <tag-prefix>
Definition: lib.h:76
+ 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 233 of file functions.c.

234{
235 int rc = 0;
236
237 if (menu->tag_prefix)
238 {
239 for (int i = 0; i < actx->idxlen; i++)
240 if (actx->idx[i]->body->tagged)
241 rc = rc || crypt_pgp_check_traditional(actx->idx[i]->fp, actx->idx[i]->body, true);
242 }
243 else
244 {
245 struct AttachPtr *cur_att = current_attachment(actx, menu);
246 rc = crypt_pgp_check_traditional(cur_att->fp, cur_att->body, true);
247 }
248
249 return rc;
250}
bool crypt_pgp_check_traditional(FILE *fp, struct Body *b, bool just_one)
Wrapper for CryptModuleSpecs::pgp_check_traditional()
Definition: cryptglue.c:283
+ 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 104 of file functions.c.

◆ AttachFunctions

const struct AttachFunction AttachFunctions[]
static

All the NeoMutt functions that the Attach supports.

Definition at line 686 of file functions.c.