Attachment code. More...
#include "config.h"
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "recvattach.h"
#include "browser/lib.h"
#include "editor/lib.h"
#include "history/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "question/lib.h"
#include "send/lib.h"
#include "attach.h"
#include "external.h"
#include "globals.h"
#include "handler.h"
#include "hook.h"
#include "mailcap.h"
#include "mutt_attach.h"
#include "mutt_thread.h"
#include "muttlib.h"
#include "rfc3676.h"
#include <libintl.h>
Go to the source code of this file.
Functions | |
struct AttachPtr * | current_attachment (struct AttachCtx *actx, struct Menu *menu) |
Get the current attachment. | |
static void | mutt_update_v2r (struct AttachCtx *actx) |
Update the virtual list of attachments. | |
void | mutt_update_tree (struct AttachCtx *actx) |
Refresh the list of attachments. | |
static void | prepend_savedir (struct Buffer *buf) |
Add $attach_save_dir to the beginning of a path. | |
static bool | has_a_message (struct Body *b) |
Determine if the Body has a message (to save) | |
static int | save_attachment_flowed_helper (FILE *fp, struct Body *b, const char *path, enum SaveAttach flags, struct Email *e) |
Helper for unstuffing attachments. | |
static int | query_save_attachment (FILE *fp, struct Body *b, struct Email *e, char **directory) |
Ask the user if we should save the attachment. | |
static int | save_without_prompting (FILE *fp, struct Body *b, struct Email *e) |
Save the attachment, without prompting each time. | |
void | mutt_save_attachment_list (struct AttachCtx *actx, FILE *fp, bool tag, struct Body *b, struct Email *e, struct Menu *menu) |
Save a list of attachments. | |
static void | query_pipe_attachment (const char *command, FILE *fp, struct Body *b, bool filter) |
Ask the user if we should pipe the attachment. | |
static void | pipe_attachment (FILE *fp, struct Body *b, struct State *state) |
Pipe the attachment to a command. | |
static void | pipe_attachment_list (const char *command, struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top, bool filter, struct State *state) |
Pipe a list of attachments to a command. | |
void | mutt_pipe_attachment_list (struct AttachCtx *actx, FILE *fp, bool tag, struct Body *b, bool filter) |
Pipe a list of attachments to a command. | |
static bool | can_print (struct AttachCtx *actx, struct Body *b, bool tag) |
Do we know how to print this attachment type? | |
static void | print_attachment_list (struct AttachCtx *actx, FILE *fp, bool tag, struct Body *b, struct State *state) |
Print a list of Attachments. | |
void | mutt_print_attachment_list (struct AttachCtx *actx, FILE *fp, bool tag, struct Body *b) |
Print a list of Attachments. | |
void | recvattach_edit_content_type (struct AttachCtx *actx, struct Menu *menu, struct Email *e) |
Edit the content type of an attachment. | |
int | mutt_attach_display_loop (struct ConfigSubset *sub, struct Menu *menu, int op, struct Email *e, struct AttachCtx *actx, bool recv) |
Event loop for the Attachment menu. | |
void | mutt_generate_recvattach_list (struct AttachCtx *actx, struct Email *e, struct Body *b, FILE *fp, int parent_type, int level, bool decrypted) |
Create a list of attachments. | |
void | mutt_attach_init (struct AttachCtx *actx) |
Create a new Attachment context. | |
void | mutt_update_recvattach_menu (struct AttachCtx *actx, struct Menu *menu, bool init) |
Update the Attachment Menu. | |
int | ba_add_tagged (struct BodyArray *ba, struct AttachCtx *actx, struct Menu *menu) |
Get an array of tagged Attachments. | |
Attachment code.
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 recvattach.c.
Get the current attachment.
actx | Attachment context |
menu | Menu |
ptr | Current Attachment |
Definition at line 77 of file recvattach.c.
|
static |
Update the virtual list of attachments.
actx | Attachment context |
Update the record of the number of attachments and the status of the tree.
Definition at line 91 of file recvattach.c.
void mutt_update_tree | ( | struct AttachCtx * | actx | ) |
Refresh the list of attachments.
actx | Attachment context |
Definition at line 122 of file recvattach.c.
|
static |
Add $attach_save_dir
to the beginning of a path.
buf | Buffer for the result |
Definition at line 173 of file recvattach.c.
|
static |
Determine if the Body has a message (to save)
[in] | b | Body of the message |
true | Suitable for saving |
Definition at line 201 of file recvattach.c.
|
static |
Helper for unstuffing attachments.
fp | Attachment to work on |
b | Body of email |
path | Path to save the attachment |
flags | Flags, e.g. MUTT_SAVE_APPEND |
e |
0 | Success |
-1 | Failure |
This is a proxy between the mutt_save_attachment_list() calls and mutt_save_attachment(). It (currently) exists solely to unstuff format=flowed text attachments.
Direct modification of mutt_save_attachment() wasn't easily possible because: 1) other callers of mutt_save_attachment() should not have unstuffing performed, such as replying/forwarding attachments. 2) the attachment saving can append to a file, making the unstuffing inside difficult with current functions. 3) we can't unstuff before-hand because decoding hasn't occurred.
So, I apologize for this horrific proxy, but it was the most straightforward method.
Definition at line 232 of file recvattach.c.
|
static |
Ask the user if we should save the attachment.
[in] | fp | File handle to the attachment (OPTIONAL) |
[in] | b | Attachment |
[in] | e | |
[out] | directory | Where the attachment was saved |
0 | Success |
-1 | Failure |
Definition at line 279 of file recvattach.c.
Save the attachment, without prompting each time.
[in] | fp | File handle to the attachment (OPTIONAL) |
[in] | b | Attachment |
[in] | e |
0 | Success |
-1 | Failure |
Definition at line 383 of file recvattach.c.
void mutt_save_attachment_list | ( | struct AttachCtx * | actx, |
FILE * | fp, | ||
bool | tag, | ||
struct Body * | b, | ||
struct Email * | e, | ||
struct Menu * | menu | ||
) |
Save a list of attachments.
actx | Attachment context |
fp | File handle for the attachment (OPTIONAL) |
tag | If true, only save the tagged attachments |
b | First Attachment |
e | |
menu | Menu listing attachments |
Definition at line 433 of file recvattach.c.
|
static |
Ask the user if we should pipe the attachment.
command | Command to pipe the attachment to |
fp | File handle to the attachment (OPTIONAL) |
b | Attachment |
filter | Is this command a filter? |
Definition at line 550 of file recvattach.c.
Pipe the attachment to a command.
fp | File handle to the attachment (OPTIONAL) |
b | Attachment |
state | File state for decoding the attachment |
Definition at line 592 of file recvattach.c.
|
static |
Pipe a list of attachments to a command.
command | Command to pipe the attachment to |
actx | Attachment context |
fp | File handle to the attachment (OPTIONAL) |
tag | If true, only save the tagged attachments |
top | First Attachment |
filter | Is this command a filter? |
state | File state for decoding the attachments |
Definition at line 693 of file recvattach.c.
void mutt_pipe_attachment_list | ( | struct AttachCtx * | actx, |
FILE * | fp, | ||
bool | tag, | ||
struct Body * | b, | ||
bool | filter | ||
) |
Pipe a list of attachments to a command.
actx | Attachment context |
fp | File handle to the attachment (OPTIONAL) |
tag | If true, only save the tagged attachments |
b | First Attachment |
filter | Is this command a filter? |
Definition at line 725 of file recvattach.c.
Do we know how to print this attachment type?
actx | Attachment |
b | Body of email |
tag | Apply to all tagged Attachments |
true | (all) the Attachment(s) are printable |
Definition at line 776 of file recvattach.c.
|
static |
Print a list of Attachments.
actx | Attachment context |
fp | File handle to the attachment (OPTIONAL) |
tag | Apply to all tagged Attachments |
b | First Attachment |
state | File state for decoding the attachments |
Definition at line 816 of file recvattach.c.
Print a list of Attachments.
actx | Attachment context |
fp | File handle to the attachment (OPTIONAL) |
tag | Apply to all tagged Attachments |
b | First Attachment |
Definition at line 888 of file recvattach.c.
Edit the content type of an attachment.
Definition at line 932 of file recvattach.c.
int mutt_attach_display_loop | ( | struct ConfigSubset * | sub, |
struct Menu * | menu, | ||
int | op, | ||
struct Email * | e, | ||
struct AttachCtx * | actx, | ||
bool | recv | ||
) |
Event loop for the Attachment menu.
sub | Config Subset |
menu | Menu listing Attachments |
op | Operation, e.g. OP_ATTACHMENT_VIEW |
e | |
actx | Attachment context |
recv | true if these are received attachments (rather than in compose) |
num | Operation performed |
Definition at line 962 of file recvattach.c.
void mutt_generate_recvattach_list | ( | struct AttachCtx * | actx, |
struct Email * | e, | ||
struct Body * | b, | ||
FILE * | fp, | ||
int | parent_type, | ||
int | level, | ||
bool | decrypted | ||
) |
Create a list of attachments.
actx | Attachment context |
e | |
b | Body of email |
fp | File to read from |
parent_type | Type, e.g. TYPE_MULTIPART |
level | Attachment depth |
decrypted | True if attachment has been decrypted |
Definition at line 1091 of file recvattach.c.
void mutt_attach_init | ( | struct AttachCtx * | actx | ) |
Create a new Attachment context.
actx | Attachment context |
Definition at line 1189 of file recvattach.c.
Update the Attachment Menu.
actx | Attachment context |
menu | Menu listing Attachments |
init | If true, create a new Attachments context |
Definition at line 1214 of file recvattach.c.
Get an array of tagged Attachments.
ba | Empty BodyArray to populate |
actx | List of Attachments |
menu | Menu |
num | Number of selected Attachments |
-1 | Error |
Definition at line 1241 of file recvattach.c.