1 #if !defined(lint) && !defined(DOS)
2 static char rcsid
[] = "$Id: mailpart.c 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $";
6 * ========================================================================
7 * Copyright 2006-2008 University of Washington
8 * Copyright 2013-2016 Eduardo Chappa
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
19 /*======================================================================
21 The meat and pototoes of attachment processing here.
43 #include "../pith/state.h"
44 #include "../pith/conf.h"
45 #include "../pith/store.h"
46 #include "../pith/msgno.h"
47 #include "../pith/detach.h"
48 #include "../pith/handle.h"
49 #include "../pith/filter.h"
50 #include "../pith/bitmap.h"
51 #include "../pith/charset.h"
52 #include "../pith/mimedesc.h"
53 #include "../pith/mailcap.h"
54 #include "../pith/newmail.h"
55 #include "../pith/rfc2231.h"
56 #include "../pith/flag.h"
57 #include "../pith/text.h"
58 #include "../pith/editorial.h"
59 #include "../pith/save.h"
60 #include "../pith/pipe.h"
61 #include "../pith/util.h"
62 #include "../pith/detoken.h"
63 #include "../pith/busy.h"
64 #include "../pith/mimetype.h"
65 #include "../pith/icache.h"
66 #include "../pith/list.h"
67 #include "../pith/ablookup.h"
68 #include "../pith/options.h"
69 #include "../pith/smime.h"
73 * Information used to paint and maintain a line on the attachment
76 typedef struct atdisp_line
{
77 char *dstring
; /* alloc'd var value string */
78 ATTACH_S
*attp
; /* actual attachment pointer */
79 struct atdisp_line
*next
, *prev
;
84 * struct defining attachment screen's current state
86 typedef struct att_screen
{
89 COLOR_PAIR
*titlecolor
;
92 static ATT_SCREEN_S
*att_screen
;
95 #define next_attline(p) ((p) ? (p)->next : NULL)
96 #define prev_attline(p) ((p) ? (p)->prev : NULL)
101 * local global pointer to scroll attachment popup menu
103 static ATTACH_S
*scrat_attachp
;
107 #define FETCH_READC g_fr_desc->readc
110 /* used to keep track of detached MIME segments total length */
111 static long save_att_length
;
114 * Internal Prototypes
116 ATDISP_S
*new_attline(ATDISP_S
**);
117 void free_attline(ATDISP_S
**);
118 int attachment_screen_updater(struct pine
*, ATDISP_S
*, ATT_SCREEN_S
*);
119 void attachment_screen_redrawer(void);
120 void update_att_screen_titlebar(void);
121 ATDISP_S
*first_attline(ATDISP_S
*);
122 int init_att_progress(char *, MAILSTREAM
*, BODY
*);
123 long save_att_piped(int);
124 int save_att_percent(void);
125 void save_attachment(int, long, ATTACH_S
*);
126 void export_attachment(int, long, ATTACH_S
*);
127 char *write_attached_msg(long, ATTACH_S
**, STORE_S
*, int);
128 void save_msg_att(long, ATTACH_S
*);
129 void save_digest_att(long, ATTACH_S
*);
130 int save_msg_att_work(long int, ATTACH_S
*, MAILSTREAM
*, char *,
131 CONTEXT_S
*, char *);
132 void export_msg_att(long, ATTACH_S
*);
133 void export_digest_att(long, ATTACH_S
*);
134 void print_attachment(int, long, ATTACH_S
*);
135 int print_msg_att(long, ATTACH_S
*, int);
136 void print_digest_att(long, ATTACH_S
*);
137 void run_viewer(char *, BODY
*, int);
138 STORE_S
*format_text_att(long, ATTACH_S
*, HANDLE_S
**);
139 int display_text_att(long, ATTACH_S
*, int);
140 int display_msg_att(long, ATTACH_S
*, int);
141 void display_digest_att(long, ATTACH_S
*, int);
142 int scroll_attachment(char *, STORE_S
*, SourceType
, HANDLE_S
*, ATTACH_S
*, int);
143 int process_attachment_cmd(int, MSGNO_S
*, SCROLL_S
*);
144 int format_msg_att(long, ATTACH_S
**, HANDLE_S
**, gf_io_t
, int);
145 void display_vcard_att(long, ATTACH_S
*, int);
146 void display_attach_info(long, ATTACH_S
*);
147 void forward_attachment(MAILSTREAM
*, long, ATTACH_S
*);
148 void forward_msg_att(MAILSTREAM
*, long, ATTACH_S
*);
149 void reply_msg_att(MAILSTREAM
*, long, ATTACH_S
*);
150 void bounce_msg_att(MAILSTREAM
*, long, char *, char *);
151 void pipe_attachment(long, ATTACH_S
*);
152 int delete_attachment(long, ATTACH_S
*);
153 int undelete_attachment(long, ATTACH_S
*, int *);
155 int scroll_att_popup(SCROLL_S
*, int);
156 void display_text_att_window(ATTACH_S
*);
157 void display_msg_att_window(ATTACH_S
*);
161 /*----------------------------------------------------------------------
162 Provide attachments in browser for selected action
164 Args: ps -- pointer to pine structure
165 msgmap -- struct containing current message to display
169 Handle painting and navigation of attachment index. It would be nice
170 to someday handle message/rfc822 segments in a neat way (i.e., enable
171 forwarding, take address, etc.).
174 attachment_screen(struct pine
*ps
)
178 maxnumwid
= 0, maxsizewid
= 0, old_cols
= -1, km_popped
= 0, expbits
,
179 last_type
= TYPEOTHER
;
181 char *q
, *last_subtype
= NULL
, backtag
[64], *utf8str
;
184 ATDISP_S
*current
= NULL
, *ctmp
= NULL
;
187 ps
->prev_screen
= attachment_screen
;
188 ps
->next_screen
= SCREEN_FUN_NULL
;
190 ps
->some_quoting_was_suppressed
= 0;
192 if(ps
->ttyo
->screen_rows
- HEADER_ROWS(ps
) - FOOTER_ROWS(ps
) < 1){
193 q_status_message(SM_ORDER
| SM_DING
, 0, 3,
194 _("Screen too small to view attachment"));
195 ps
->next_screen
= mail_view_screen
;
199 if(mn_total_cur(ps
->msgmap
) > 1L){
200 q_status_message(SM_ORDER
| SM_DING
, 0, 3,
201 _("Can only view one message's attachments at a time."));
204 else if(ps
->atmts
&& ps
->atmts
->description
&& !(ps
->atmts
+ 1)->description
)
205 q_status_message1(SM_ASYNC
, 0, 3,
206 _("Message %s has only one part (the message body), and no attachments."),
207 long2string(mn_get_cur(ps
->msgmap
)));
209 /*----- Figure max display widths -----*/
210 for(a
= ps
->atmts
; a
&& a
->description
!= NULL
; a
++){
211 if((n
= utf8_width(a
->number
)) > maxnumwid
)
214 if((n
= utf8_width(a
->size
)) > maxsizewid
)
219 * Then, allocate and initialize attachment line list...
221 for(a
= ps
->atmts
; a
&& a
->description
; a
++)
222 new_attline(¤t
)->attp
= a
;
224 memset(&screen
, 0, sizeof(screen
));
225 msgno
= mn_m2raw(ps
->msgmap
, mn_get_cur(ps
->msgmap
));
226 ps
->mangled_screen
= 1; /* build display */
227 ps
->redrawer
= attachment_screen_redrawer
;
228 att_screen
= &screen
;
229 current
= first_attline(current
);
233 * Advance to next attachment if it's likely that we've already
234 * shown it to the user...
237 if (current
== NULL
){
238 q_status_message1(SM_ORDER
| SM_DING
, 0, 3,
239 _("Malformed message: %s"),
240 ps
->c_client_error
? ps
->c_client_error
: "?");
241 ps
->next_screen
= mail_view_screen
;
243 else if(current
->attp
->shown
&& (ctmp
= next_attline(current
)))
246 while(ps
->next_screen
== SCREEN_FUN_NULL
){
247 ps
->user_says_cancel
= 0;
252 ps
->mangled_body
= 1;
256 if(ps
->mangled_screen
){
258 * build/rebuild display lines
260 if(old_cols
!= ps
->ttyo
->screen_cols
){
261 int avail
, s1
, s2
, s4
, s5
, dwid
, sizewid
, descwid
;
263 avail
= ps_global
->ttyo
->screen_cols
;
265 s1
= MAX(MIN(1, avail
), 0);
268 dwid
= MAX(MIN(1, avail
), 0);
271 s2
= MAX(MIN(1, avail
), 0);
274 /* Only give up a third of the display to part numbers */
275 maxnumwid
= MIN(maxnumwid
, (ps_global
->ttyo
->screen_cols
/3));
276 maxnumwid
= MAX(MIN(maxnumwid
, avail
), 0);
279 s4
= MAX(MIN(3, avail
), 0);
282 sizewid
= MAX(MIN(maxsizewid
, avail
), 0);
285 s5
= MAX(MIN(3, avail
), 0);
288 descwid
= MAX(0, avail
);
290 old_cols
= ps
->ttyo
->screen_cols
;
292 for(ctmp
= first_attline(current
);
293 ctmp
&& (a
= ctmp
->attp
) && a
->description
;
294 ctmp
= next_attline(ctmp
)){
297 char description
[1000];
300 fs_give((void **)&ctmp
->dstring
);
302 len
= 6 * MAX(80, ps
->ttyo
->screen_cols
) * sizeof(char);
303 ctmp
->dstring
= (char *)fs_get(len
+ 1);
308 q
= a
->body
->description
;
309 if(!(q
&& q
[0]) && (MIME_MSG_A(a
) && a
->body
->nested
.msg
->env
))
310 q
= a
->body
->nested
.msg
->env
->subject
;
315 strncpy(buftmp
, q
, sizeof(buftmp
));
316 buftmp
[sizeof(buftmp
)-1] = '\0';
318 q
= (char *) rfc1522_decode_to_utf8((unsigned char *) tmp_20k_buf
,
319 SIZEOF_20KBUF
, buftmp
);
325 snprintf(description
, sizeof(description
), "%s%s%s%s", type_desc(a
->body
->type
, a
->body
->subtype
, a
->body
->parameter
, a
->body
->disposition
.type
? a
->body
->disposition
.parameter
: NULL
, 1), q
? ", \"" : "", q
? q
: "", q
? "\"" : "");
326 description
[sizeof(description
)-1] = '\0';
328 utf8_snprintf(ctmp
->dstring
, len
+1,
329 "%*.*s%*.*w%*.*s%-*.*w%*.*s%*.*w%*.*s%-*.*w",
332 msgno_part_deleted(ps
->mail_stream
, msgno
, a
->number
) ? "D" : "",
334 maxnumwid
, maxnumwid
,
336 ? short_str(a
->number
, numbuf
, sizeof(numbuf
), maxnumwid
, FrontDots
)
340 a
->size
? a
->size
: "",
342 descwid
, descwid
, description
);
344 ctmp
->dstring
[len
] = '\0';
348 ps
->mangled_header
= 1;
349 ps
->mangled_footer
= 1;
350 ps
->mangled_body
= 1;
353 /*----------- Check for new mail -----------*/
354 if(new_mail(0, NM_TIMING(ch
), NM_STATUS_MSG
| NM_DEFER_SORT
) >= 0)
355 ps
->mangled_header
= 1;
358 * If an expunge of the current message happened during the
359 * new mail check we want to bail out of here. See mm_expunged.
361 if(ps
->next_screen
!= SCREEN_FUN_NULL
)
364 if(ps
->mangled_header
){
365 update_att_screen_titlebar();
366 ps
->mangled_header
= 0;
369 if(ps
->mangled_screen
){
371 ps
->mangled_screen
= 0;
374 dline
= attachment_screen_updater(ps
, current
, &screen
);
376 /*---- This displays new mail notification, or errors ---*/
379 mark_status_unknown();
385 mark_status_unknown();
388 if(ps
->mangled_footer
389 || current
->attp
->body
->type
!= last_type
390 || !(last_subtype
&& current
->attp
->body
->subtype
)
391 || strucmp(last_subtype
, current
->attp
->body
->subtype
)){
393 struct key_menu
*km
= &att_index_keymenu
;
397 ps
->mangled_footer
= 0;
398 last_type
= current
->attp
->body
->type
;
399 last_subtype
= current
->attp
->body
->subtype
;
401 snprintf(backtag
, sizeof(backtag
), "Msg #%ld", mn_get_cur(ps
->msgmap
));
402 backtag
[sizeof(backtag
)-1] = '\0';
403 km
->keys
[ATT_PARENT_KEY
].label
= backtag
;
405 if(F_OFF(F_ENABLE_PIPE
, ps
))
406 clrbitn(ATT_PIPE_KEY
, bitmap
);
409 * If message or digest, leave Reply and Save and,
410 * conditionally, Bounce on...
412 if(MIME_MSG(last_type
, last_subtype
)){
413 if(F_OFF(F_ENABLE_BOUNCE
, ps
))
414 clrbitn(ATT_BOUNCE_KEY
, bitmap
);
416 km
->keys
[ATT_EXPORT_KEY
].name
= "";
417 km
->keys
[ATT_EXPORT_KEY
].label
= "";
419 else if(MIME_DGST(last_type
, last_subtype
)){
420 clrbitn(ATT_BOUNCE_KEY
, bitmap
);
421 clrbitn(ATT_REPLY_KEY
, bitmap
);
423 km
->keys
[ATT_EXPORT_KEY
].name
= "";
424 km
->keys
[ATT_EXPORT_KEY
].label
= "";
427 clrbitn(ATT_BOUNCE_KEY
, bitmap
);
428 clrbitn(ATT_REPLY_KEY
, bitmap
);
430 if(last_type
!= TYPETEXT
)
431 clrbitn(ATT_PRINT_KEY
, bitmap
);
433 km
->keys
[ATT_EXPORT_KEY
].name
= "E";
434 km
->keys
[ATT_EXPORT_KEY
].label
= N_("Export");
442 if(F_ON(F_ARROW_NAV
, ps
)){
443 menu_add_binding(km
, KEY_LEFT
, MC_EXIT
);
444 menu_add_binding(km
, KEY_RIGHT
, MC_VIEW_ATCH
);
447 menu_clear_binding(km
, KEY_LEFT
);
448 menu_clear_binding(km
, KEY_RIGHT
);
451 draw_keymenu(km
, bitmap
, ps
->ttyo
->screen_cols
, 1-FOOTER_ROWS(ps
),
456 mark_keymenu_dirty();
460 if(F_ON(F_SHOW_CURSOR
, ps
))
461 MoveCursor(dline
, 0);
463 MoveCursor(MAX(0, ps
->ttyo
->screen_rows
- FOOTER_ROWS(ps
)), 0);
465 /*------ Prepare to read the command from the keyboard ----*/
467 mouse_in_content(KEY_MOUSE
, -1, -1, 0, 0); /* prime the handler */
468 register_mfunc(mouse_in_content
, HEADER_ROWS(ps_global
), 0,
469 ps_global
->ttyo
->screen_rows
-(FOOTER_ROWS(ps_global
)+1),
470 ps_global
->ttyo
->screen_cols
);
472 ch
= READ_COMMAND(&utf8str
);
474 clear_mfunc(mouse_in_content
);
477 cmd
= menu_command(ch
, &att_index_keymenu
);
495 if(FOOTER_ROWS(ps
) == 1 && km_popped
== 0){
497 ps
->mangled_footer
= 1;
501 helper(h_attachment_screen
, _("HELP FOR ATTACHMENT INDEX"), 0);
502 ps
->mangled_screen
= 1;
507 ps
->mangled_footer
= 1;
512 if(ps
->full_header
== 1){
513 if(!(ps
->quote_suppression_threshold
514 && (ps
->some_quoting_was_suppressed
/* || in_index != View */)))
517 else if(ps
->full_header
> 2)
520 switch(ps
->full_header
){
522 q_status_message(SM_ORDER
, 0, 3,
523 _("Display of full headers is now off."));
527 q_status_message1(SM_ORDER
, 0, 3,
528 _("Quotes displayed, use %s to see full headers"),
529 F_ON(F_USE_FK
, ps
) ? "F9" : "H");
533 q_status_message(SM_ORDER
, 0, 3,
534 _("Display of full headers is now on."));
541 case MC_EXIT
: /* exit attachment screen */
542 ps
->next_screen
= mail_view_screen
;
546 ps
->next_screen
= quit_screen
;
550 ps
->next_screen
= main_menu_screen
;
554 ps
->next_screen
= mail_index_screen
;
558 if((ctmp
= next_attline(current
)) != NULL
)
561 q_status_message(SM_ORDER
, 0, 1, _("Already on last attachment"));
566 if((ctmp
= prev_attline(current
)) != NULL
)
569 q_status_message(SM_ORDER
, 0, 1, _("Already on first attachment"));
573 case MC_PAGEDN
: /* page forward */
574 if(next_attline(current
)){
575 while(dline
++ < ps
->ttyo
->screen_rows
- FOOTER_ROWS(ps
))
576 if((ctmp
= next_attline(current
)) != NULL
)
582 q_status_message(SM_ORDER
, 0, 1,
583 _("Already on last page of attachments"));
587 case MC_PAGEUP
: /* page backward */
588 if(prev_attline(current
)){
589 while(dline
-- > HEADER_ROWS(ps
))
590 if((ctmp
= prev_attline(current
)) != NULL
)
595 while(++dline
< ps
->ttyo
->screen_rows
- FOOTER_ROWS(ps
))
596 if((ctmp
= prev_attline(current
)) != NULL
)
602 q_status_message(SM_ORDER
, 0, 1,
603 _("Already on first page of attachments"));
612 mouse_get_last (NULL
, &mp
);
613 mp
.row
-= HEADER_ROWS(ps
);
614 ctmp
= screen
.top_line
;
615 while (mp
.row
&& ctmp
!= NULL
) {
624 if(mp
.button
== M_BUTTON_LEFT
)
625 display_attachment(msgno
, current
->attp
, DA_SAVE
);
628 else if(mp
.button
== M_BUTTON_RIGHT
){
629 MPopup atmt_popup
[20];
630 int i
= -1, exoffer
= 0;
632 dline
= attachment_screen_updater(ps
,current
,&screen
);
634 if(dispatch_attachment(current
->attp
) != MCD_NONE
){
635 atmt_popup
[++i
].type
= tQueue
;
636 atmt_popup
[i
].data
.val
= 'V';
637 atmt_popup
[i
].label
.style
= lNormal
;
638 atmt_popup
[i
].label
.string
= "&View";
640 if(!(current
->attp
->can_display
& MCD_EXTERNAL
)
641 && (current
->attp
->body
->type
== TYPETEXT
642 || MIME_MSG_A(current
->attp
)
643 || MIME_DGST_A(current
->attp
))){
645 atmt_popup
[++i
].type
= tIndex
;
646 atmt_popup
[i
].label
.style
= lNormal
;
647 atmt_popup
[i
].label
.string
=
648 "View in New Window";
652 atmt_popup
[++i
].type
= tQueue
;
653 atmt_popup
[i
].data
.val
= 'S';
654 atmt_popup
[i
].label
.style
= lNormal
;
655 atmt_popup
[i
].label
.string
= "&Save";
657 atmt_popup
[++i
].type
= tQueue
;
658 atmt_popup
[i
].label
.style
= lNormal
;
659 if(current
->dstring
[1] == 'D'){
660 atmt_popup
[i
].data
.val
= 'U';
661 atmt_popup
[i
].label
.string
= "&Undelete";
664 atmt_popup
[i
].data
.val
= 'D';
665 atmt_popup
[i
].label
.string
= "&Delete";
668 if(MIME_MSG_A(current
->attp
)){
669 atmt_popup
[++i
].type
= tQueue
;
670 atmt_popup
[i
].label
.style
= lNormal
;
671 atmt_popup
[i
].label
.string
= "&Reply...";
672 atmt_popup
[i
].data
.val
= 'R';
674 atmt_popup
[++i
].type
= tQueue
;
675 atmt_popup
[i
].label
.style
= lNormal
;
676 atmt_popup
[i
].label
.string
= "&Forward...";
677 atmt_popup
[i
].data
.val
= 'F';
680 atmt_popup
[++i
].type
= tQueue
;
681 atmt_popup
[i
].label
.style
= lNormal
;
682 atmt_popup
[i
].label
.string
= "&About...";
683 atmt_popup
[i
].data
.val
= 'A';
685 atmt_popup
[++i
].type
= tSeparator
;
687 atmt_popup
[++i
].type
= tQueue
;
688 snprintf(backtag
, sizeof(backtag
), "View Message #%ld",
689 mn_get_cur(ps
->msgmap
));
690 backtag
[sizeof(backtag
)-1] = '\0';
691 atmt_popup
[i
].label
.string
= backtag
;
692 atmt_popup
[i
].label
.style
= lNormal
;
693 atmt_popup
[i
].data
.val
= '<';
695 atmt_popup
[++i
].type
= tTail
;
697 if(mswin_popup(atmt_popup
) == 1 && exoffer
)
698 display_att_window(current
->attp
);
701 else if(mp
.button
== M_BUTTON_RIGHT
){
702 MPopup atmt_popup
[2];
704 atmt_popup
[0].type
= tQueue
;
705 snprintf(backtag
, sizeof(backtag
), "View Message #%ld",
706 mn_get_cur(ps
->msgmap
));
707 backtag
[sizeof(backtag
)-1] = '\0';
708 atmt_popup
[0].label
.string
= backtag
;
709 atmt_popup
[0].label
.style
= lNormal
;
710 atmt_popup
[0].data
.val
= '<';
712 atmt_popup
[1].type
= tTail
;
714 mswin_popup(atmt_popup
);
721 case MC_WHEREIS
: /* whereis */
722 /*--- get string ---*/
724 char *result
= NULL
, buf
[64];
725 static char last
[64], tmp
[64];
728 ps
->mangled_footer
= 1;
730 snprintf(tmp
, sizeof(tmp
), "Word to find %s%s%s: ",
731 (last
[0]) ? "[" : "",
732 (last
[0]) ? last
: "",
733 (last
[0]) ? "]" : "");
734 tmp
[sizeof(tmp
)-1] = '\0';
737 int flags
= OE_APPEND_CURRENT
| OE_SEQ_SENSITIVE
;
739 rc
= optionally_enter(buf
,-FOOTER_ROWS(ps
),0,sizeof(buf
),
740 tmp
,NULL
,help
,&flags
);
742 help
= help
== NO_HELP
? h_attach_index_whereis
: NO_HELP
;
743 else if(rc
== 0 || rc
== 1 || !buf
[0]){
744 if(rc
== 0 && !buf
[0] && last
[0]){
745 strncpy(buf
, last
, sizeof(buf
));
746 buf
[sizeof(buf
)-1] = '\0';
753 if(rc
== 0 && buf
[0]){
755 while((ctmp
= next_attline(ctmp
)) != NULL
)
756 if(srchstr(ctmp
->dstring
, buf
)){
762 ctmp
= first_attline(current
);
764 while(ctmp
!= current
)
765 if(srchstr(ctmp
->dstring
, buf
)){
770 ctmp
= next_attline(ctmp
);
774 result
= _("WhereIs cancelled");
777 strncpy(last
, buf
, sizeof(last
));
778 last
[sizeof(last
)-1] = '\0';
779 result
= "Word found";
783 q_status_message(SM_ORDER
, 0, 3,
784 result
? result
: _("Word not found"));
790 if(delete_attachment(msgno
, current
->attp
)){
791 int l
= current
? strlen(current
->attp
->number
) : 0;
793 current
->dstring
[1] = 'D';
795 /* Also indicate any children that will be deleted */
797 for(ctmp
= current
; ctmp
; ctmp
= next_attline(ctmp
))
798 if(!strncmp(ctmp
->attp
->number
, current
->attp
->number
, l
)
799 && ctmp
->attp
->number
[l
] == '.'){
800 ctmp
->dstring
[1] = 'D';
801 ps
->mangled_screen
= 1;
808 if(undelete_attachment(msgno
, current
->attp
, &expbits
)){
809 int l
= current
? strlen(current
->attp
->number
) : 0;
811 current
->dstring
[1] = ' ';
813 /* And unflag anything implicitly undeleted */
814 for(ctmp
= current
; ctmp
; ctmp
= next_attline(ctmp
))
815 if(!strncmp(ctmp
->attp
->number
, current
->attp
->number
, l
)
816 && ctmp
->attp
->number
[l
] == '.'
817 && (!msgno_exceptions(ps
->mail_stream
, msgno
,
818 ctmp
->attp
->number
, &expbits
, FALSE
)
819 || !(expbits
& MSG_EX_DELETE
))){
820 ctmp
->dstring
[1] = ' ';
821 ps
->mangled_screen
= 1;
828 reply_msg_att(ps
->mail_stream
, msgno
, current
->attp
);
832 forward_attachment(ps
->mail_stream
, msgno
, current
->attp
);
836 bounce_msg_att(ps
->mail_stream
, msgno
, current
->attp
->number
,
837 current
->attp
->body
->nested
.msg
->env
->subject
);
838 ps
->mangled_footer
= 1;
842 display_attach_info(msgno
, current
->attp
);
845 case MC_VIEW_ATCH
: /* View command */
846 display_attachment(msgno
, current
->attp
, DA_SAVE
);
848 /* fall thru to repaint */
850 case MC_REPAINT
: /* redraw */
852 ps
->mangled_screen
= 1;
856 export_attachment(-FOOTER_ROWS(ps
), msgno
, current
->attp
);
857 ps
->mangled_footer
= 1;
860 case MC_SAVETEXT
: /* Save command */
861 save_attachment(-FOOTER_ROWS(ps
), msgno
, current
->attp
);
862 ps
->mangled_footer
= 1;
865 case MC_PRINTMSG
: /* Save command */
866 print_attachment(-FOOTER_ROWS(ps
), msgno
, current
->attp
);
867 ps
->mangled_footer
= 1;
870 case MC_PIPE
: /* Pipe command */
871 if(F_ON(F_ENABLE_PIPE
, ps
)){
872 pipe_attachment(msgno
, current
->attp
);
873 ps
->mangled_footer
= 1;
875 } /* fall thru to complain */
877 case MC_NONE
: /* simple timeout */
881 bogus_utf8_command(utf8str
, F_ON(F_USE_FK
, ps
) ? "F1" : "?");
892 bogus_command(ch
, F_ON(F_USE_FK
, ps
) ? "F1" : "?");
897 for(current
= first_attline(current
); current
;){ /* clean up */
898 ctmp
= current
->next
;
899 free_attline(¤t
);
903 if(screen
.titlecolor
)
904 free_color_pair(&screen
.titlecolor
);
908 /*----------------------------------------------------------------------
909 allocate and attach a fresh attachment line struct
911 Args: current -- display line to attache new struct to
913 Returns: newly alloc'd attachment display line
916 new_attline(ATDISP_S
**current
)
920 p
= (ATDISP_S
*)fs_get(sizeof(ATDISP_S
));
921 memset((void *)p
, 0, sizeof(ATDISP_S
));
924 p
->next
= (*current
)->next
;
925 (*current
)->next
= p
;
938 /*----------------------------------------------------------------------
939 Release system resources associated with attachment display line
941 Args: p -- line to free
946 free_attline(ATDISP_S
**p
)
950 fs_give((void **)&(*p
)->dstring
);
957 /*----------------------------------------------------------------------
958 Manage display of the attachment screen menu body.
960 Args: ps -- pine struct pointer
961 current -- currently selected display line
962 screen -- reference points for display painting
967 attachment_screen_updater(struct pine
*ps
, ATDISP_S
*current
, ATT_SCREEN_S
*screen
)
969 int dline
, return_line
= HEADER_ROWS(ps
);
970 ATDISP_S
*top_line
, *ctmp
;
972 /* calculate top line of display */
974 ctmp
= top_line
= first_attline(current
);
976 if(((dline
++)%(ps
->ttyo
->screen_rows
-HEADER_ROWS(ps
)-FOOTER_ROWS(ps
)))==0)
978 while(ctmp
!= current
&& (ctmp
= next_attline(ctmp
)));
981 /* Don't know how to manage scroll bar for attachment screen yet. */
982 scroll_setrange (0L, 0L);
985 /* mangled body or new page, force redraw */
986 if(ps
->mangled_body
|| screen
->top_line
!= top_line
)
987 screen
->current
= NULL
;
989 /* loop thru painting what's needed */
990 for(dline
= 0, ctmp
= top_line
;
991 dline
< ps
->ttyo
->screen_rows
- FOOTER_ROWS(ps
) - HEADER_ROWS(ps
);
992 dline
++, ctmp
= next_attline(ctmp
)){
995 * only fall thru painting if something needs painting...
997 if(!(!screen
->current
|| ctmp
== screen
->current
|| ctmp
== current
))
1000 if(ctmp
&& ctmp
->dstring
){
1001 char *p
= tmp_20k_buf
;
1002 int i
, col
, x
= 0, totlen
;
1004 if(F_ON(F_FORCE_LOW_SPEED
,ps
) || ps
->low_speed
){
1006 if(ctmp
== current
){
1007 return_line
= dline
+ HEADER_ROWS(ps
);
1008 PutLine0(dline
+ HEADER_ROWS(ps
), 0, "->");
1011 PutLine0(dline
+ HEADER_ROWS(ps
), 0, " ");
1014 * Only paint lines if we have to...
1019 else if(ctmp
== current
){
1020 return_line
= dline
+ HEADER_ROWS(ps
);
1024 totlen
= strlen(ctmp
->dstring
);
1027 * Copy the value to a temp buffer expanding tabs.
1028 * Assume the caller set the widths so as not to overflow the
1031 for(i
=0,col
=x
; ctmp
->dstring
[i
]; i
++){
1032 if(ctmp
->dstring
[i
] == TAB
){
1033 if((p
-tmp_20k_buf
) < SIZEOF_20KBUF
-8)
1036 while((++col
)&0x07);
1039 col
+= width_at_this_position((unsigned char *) &ctmp
->dstring
[i
], totlen
-i
);
1040 if((p
-tmp_20k_buf
) < SIZEOF_20KBUF
)
1041 *p
++ = ctmp
->dstring
[i
];
1046 if((p
-tmp_20k_buf
) < SIZEOF_20KBUF
)
1049 PutLine0(dline
+ HEADER_ROWS(ps
), x
, tmp_20k_buf
+ x
);
1052 && !(F_ON(F_FORCE_LOW_SPEED
,ps
) || ps
->low_speed
))
1056 ClearLine(dline
+ HEADER_ROWS(ps
));
1059 ps
->mangled_body
= 0;
1060 screen
->top_line
= top_line
;
1061 screen
->current
= current
;
1062 return(return_line
);
1066 /*----------------------------------------------------------------------
1067 Redraw the attachment screen based on the global "att_screen" struct
1074 attachment_screen_redrawer(void)
1078 update_att_screen_titlebar();
1079 ps_global
->mangled_header
= 0;
1082 ps_global
->mangled_body
= 1;
1083 (void)attachment_screen_updater(ps_global
,att_screen
->current
,att_screen
);
1086 draw_keymenu(&att_index_keymenu
, bitmap
, ps_global
->ttyo
->screen_cols
,
1087 1-FOOTER_ROWS(ps_global
), 0, SameMenu
);
1092 update_att_screen_titlebar(void)
1095 COLOR_PAIR
*returned_color
= NULL
;
1096 COLOR_PAIR
*titlecolor
= NULL
;
1098 SEARCHSET
*ss
= NULL
;
1099 PAT_STATE
*pstate
= NULL
;
1101 if(ps_global
->titlebar_color_style
!= TBAR_COLOR_DEFAULT
){
1102 raw_msgno
= mn_m2raw(ps_global
->msgmap
, mn_get_cur(ps_global
->msgmap
));
1103 ss
= mail_newsearchset();
1104 ss
->first
= ss
->last
= (unsigned long) raw_msgno
;
1107 colormatch
= get_index_line_color(ps_global
->mail_stream
,
1108 ss
, &pstate
, &returned_color
);
1109 mail_free_searchset(&ss
);
1112 * This is a bit tricky. If there is a colormatch but
1114 * is NULL, that means that the user explicitly wanted the
1115 * Normal color used in this index line, so that is what we
1116 * use. If no colormatch then we will use the TITLE color
1117 * instead of Normal.
1121 titlecolor
= returned_color
;
1123 titlecolor
= new_color_pair(ps_global
->VAR_NORM_FORE_COLOR
,
1124 ps_global
->VAR_NORM_BACK_COLOR
);
1128 && ps_global
->titlebar_color_style
== TBAR_COLOR_REV_INDEXLINE
){
1129 char cbuf
[MAXCOLORLEN
+1];
1131 strncpy(cbuf
, titlecolor
->fg
, sizeof(cbuf
));
1132 cbuf
[sizeof(cbuf
)-1] = '\0';
1133 strncpy(titlecolor
->fg
, titlecolor
->bg
, MAXCOLORLEN
);
1134 titlecolor
->fg
[MAXCOLORLEN
] = '\0';
1135 strncpy(titlecolor
->bg
, cbuf
, MAXCOLORLEN
);
1136 titlecolor
->bg
[MAXCOLORLEN
] = '\0';
1140 /* Did the color change? */
1141 if((!titlecolor
&& att_screen
->titlecolor
)
1143 (titlecolor
&& !att_screen
->titlecolor
)
1145 (titlecolor
&& att_screen
->titlecolor
1146 && (strcmp(titlecolor
->fg
, att_screen
->titlecolor
->fg
)
1147 || strcmp(titlecolor
->bg
, att_screen
->titlecolor
->bg
)))){
1149 if(att_screen
->titlecolor
)
1150 free_color_pair(&att_screen
->titlecolor
);
1152 att_screen
->titlecolor
= titlecolor
;
1157 free_color_pair(&titlecolor
);
1160 set_titlebar(_("ATTACHMENT INDEX"), ps_global
->mail_stream
,
1161 ps_global
->context_current
, ps_global
->cur_folder
,
1162 ps_global
->msgmap
, 1, MessageNumber
, 0, 0,
1163 att_screen
->titlecolor
);
1167 /*----------------------------------------------------------------------
1168 Seek back from the given display line to the beginning of the list
1170 Args: p -- display linked list
1175 first_attline(ATDISP_S
*p
)
1185 init_att_progress(char *msg
, MAILSTREAM
*stream
, struct mail_bodystruct
*body
)
1187 if((save_att_length
= body
->size
.bytes
) != 0){
1188 /* if there are display filters, factor in extra copy */
1189 if(body
->type
== TYPETEXT
&& ps_global
->VAR_DISPLAY_FILTERS
)
1190 save_att_length
+= body
->size
.bytes
;
1192 /* if remote folder and segment not cached, factor in IMAP fetch */
1193 if(stream
&& stream
->mailbox
&& IS_REMOTE(stream
->mailbox
)
1194 && !((body
->type
== TYPETEXT
&& body
->contents
.text
.data
)
1195 || ((body
->type
== TYPEMESSAGE
)
1196 && body
->nested
.msg
&& body
->nested
.msg
->text
.text
.data
)
1197 || body
->contents
.text
.data
))
1198 save_att_length
+= body
->size
.bytes
;
1200 gf_filter_init(); /* reset counters */
1203 return(busy_cue(msg
, save_att_percent
, 0));
1211 save_att_piped(int reset
)
1219 else if((y
= gf_bytes_piped()) >= x
){
1229 save_att_percent(void)
1231 int i
= (int) (((pine_gets_bytes(0) + save_att_piped(0)) * 100)
1233 return(MIN(i
, 100));
1237 /*----------------------------------------------------------------------
1238 Save the given attachment associated with the given message no
1245 save_attachment(int qline
, long int msgno
, ATTACH_S
*a
)
1247 if(ps_global
->restricted
){
1248 q_status_message(SM_ORDER
| SM_DING
, 0, 4,
1249 "Alpine demo can't save attachments");
1254 save_msg_att(msgno
, a
);
1255 else if(MIME_DGST_A(a
))
1256 save_digest_att(msgno
, a
);
1257 else if(MIME_VCARD_A(a
))
1258 save_vcard_att(ps_global
, qline
, msgno
, a
);
1260 write_attachment(qline
, msgno
, a
, "SAVE");
1264 /*----------------------------------------------------------------------
1265 Save the given attachment associated with the given message no
1272 export_attachment(int qline
, long int msgno
, ATTACH_S
*a
)
1274 if(ps_global
->restricted
){
1275 q_status_message(SM_ORDER
| SM_DING
, 0, 4,
1276 "Alpine demo can't export attachments");
1281 export_msg_att(msgno
, a
);
1282 else if(MIME_DGST_A(a
))
1283 export_digest_att(msgno
, a
);
1285 q_status_message1(SM_ORDER
, 0, 3,
1286 _("Can't Export %s. Use \"Save\" to write file, \"<\" to leave index."),
1287 body_type_names(a
->body
->type
));
1292 write_attachment(int qline
, long int msgno
, ATTACH_S
*a
, char *method
)
1294 char filename
[MAXPATH
+1], full_filename
[MAXPATH
+1],
1295 title_buf
[64], *err
;
1296 int r
, rflags
= GER_NONE
, we_cancel
= 0, flags
;
1297 static HISTORY_S
*history
= NULL
;
1298 static ESCKEY_S att_save_opts
[] = {
1299 {ctrl('T'), 10, "^T", N_("To Files")},
1300 {-1, 0, NULL
, NULL
},
1301 {-1, 0, NULL
, NULL
},
1302 {-1, 0, NULL
, NULL
}};
1304 /*------- Figure out suggested file name ----*/
1305 filename
[0] = full_filename
[0] = '\0';
1306 (void) get_filename_parameter(filename
, sizeof(filename
), a
->body
, NULL
);
1308 dprint((9, "export_attachment(name: %s)\n",
1309 filename
? filename
: "?"));
1312 #if !defined(DOS) && !defined(MAC) && !defined(OS2)
1313 if(ps_global
->VAR_DOWNLOAD_CMD
&& ps_global
->VAR_DOWNLOAD_CMD
[0]){
1314 att_save_opts
[++r
].ch
= ctrl('V');
1315 att_save_opts
[r
].rval
= 12;
1316 att_save_opts
[r
].name
= "^V";
1317 att_save_opts
[r
].label
= N_("Downld Msg");
1319 #endif /* !(DOS || MAC) */
1321 if(F_ON(F_ENABLE_TAB_COMPLETE
,ps_global
)){
1322 att_save_opts
[++r
].ch
= ctrl('I');
1323 att_save_opts
[r
].rval
= 11;
1324 att_save_opts
[r
].name
= "TAB";
1325 att_save_opts
[r
].label
= N_("Complete");
1328 att_save_opts
[++r
].ch
= -1;
1330 snprintf(title_buf
, sizeof(title_buf
), "%s ATTACHMENT", method
);
1331 title_buf
[sizeof(title_buf
)-1] = '\0';
1333 flags
= (a
&& a
->body
&& a
->body
->type
== TYPETEXT
? GE_BINARY
: 0)
1336 r
= get_export_filename(ps_global
, filename
, NULL
, full_filename
,
1337 sizeof(filename
), "attachment", title_buf
,
1338 att_save_opts
, &rflags
, qline
, flags
, &history
);
1343 cmd_cancelled((char *) lcase((unsigned char *) title_buf
+ 1) - 1);
1347 q_status_message1(SM_ORDER
, 0, 2,
1348 _("Can't save to file outside of %s"),
1349 ps_global
->VAR_OPER_DIR
);
1355 #if !defined(DOS) && !defined(MAC) && !defined(OS2)
1356 else if(r
== 12){ /* Download */
1357 char cmd
[MAXPATH
], *tfp
= NULL
;
1362 char prompt_buf
[256];
1364 if(ps_global
->restricted
){
1365 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
1366 "Download disallowed in restricted mode");
1371 tfp
= temp_nam(NULL
, "pd");
1372 dprint((1, "Download attachment called!\n"));
1373 if((store
= so_get(FileStar
, tfp
, WRITE_ACCESS
|OWNER_ONLY
|WRITE_TO_LOCALE
)) != NULL
){
1375 snprintf(prompt_buf
, sizeof(prompt_buf
), "Saving to \"%s\"", tfp
);
1376 prompt_buf
[sizeof(prompt_buf
)-1] = '\0';
1377 we_cancel
= init_att_progress(prompt_buf
,
1378 ps_global
->mail_stream
,
1381 gf_set_so_writec(&pc
, store
);
1382 if((err
= detach(ps_global
->mail_stream
, msgno
,
1383 a
->number
, 0L, &len
, pc
, NULL
, 0)) != NULL
)
1384 q_status_message2(SM_ORDER
| SM_DING
, 3, 5,
1385 "%s: Error writing attachment to \"%s\"",
1388 /* cancel regardless, so it doesn't get in way of xfer */
1391 gf_clear_so_writec(store
);
1392 if(so_give(&store
)) /* close file */
1393 err
= "Error writing tempfile for download";
1396 build_updown_cmd(cmd
, sizeof(cmd
), ps_global
->VAR_DOWNLOAD_CMD_PREFIX
,
1397 ps_global
->VAR_DOWNLOAD_CMD
, tfp
);
1398 if((syspipe
= open_system_pipe(cmd
, NULL
, NULL
,
1399 PIPE_USER
| PIPE_RESET
,
1400 0, pipe_callback
, pipe_report_error
)) != NULL
)
1401 (void)close_system_pipe(&syspipe
, NULL
, pipe_callback
);
1403 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
1404 err
= "Error running download command");
1408 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
1409 err
= "Error building temp file for download");
1413 fs_give((void **)&tfp
);
1417 q_status_message1(SM_ORDER
, 0, 4, "Part %s downloaded",
1422 #endif /* !(DOS || MAC) */
1424 (void) write_attachment_to_file(ps_global
->mail_stream
, msgno
, a
,
1425 rflags
, full_filename
);
1431 * msgno -- raw message number
1432 * a -- attachment struct
1433 * flags -- comes from get_export_filename
1434 * GER_OVER -- the file was truncated before we wrote
1435 * GER_APPEND -- the file was not truncated prior to our writing,
1436 * so we were appending
1437 * else -- the file didn't previously exist
1438 * file -- the full pathname of the file
1440 * Returns 1 for successful write, 0 for nothing to write, -1 for error
1443 write_attachment_to_file(MAILSTREAM
*stream
, long int msgno
, ATTACH_S
*a
, int flags
, char *file
)
1445 char *l_string
, sbuf
[256], *err
;
1446 int is_text
, we_cancel
= 0, dt_flags
= 0, so_flags
;
1447 long len
, orig_size
;
1451 if(!(a
&& a
->body
&& a
->number
&& a
->number
[0] && file
&& file
[0]
1455 is_text
= (a
&& a
->body
&& a
->body
->type
== TYPETEXT
);
1457 if(flags
& GER_APPEND
)
1458 orig_size
= name_file_size(file
);
1460 if(flags
& GER_BINARY
)
1461 dt_flags
|= DT_BINARY
;
1463 so_flags
= (is_text
& !(flags
& GER_BINARY
) ? WRITE_TO_LOCALE
: 0)
1466 store
= so_get(FileStar
, file
, so_flags
);
1468 q_status_message2(SM_ORDER
| SM_DING
, 3, 5,
1469 /* TRANSLATORS: Error opening destination <filename>: <error text> */
1470 _("Error opening destination %s: %s"),
1471 file
, error_description(errno
));
1475 snprintf(sbuf
, sizeof(sbuf
), "Saving to \"%s\"", file
);
1476 sbuf
[sizeof(sbuf
)-1] = '\0';
1477 we_cancel
= init_att_progress(sbuf
, stream
, a
->body
);
1479 gf_set_so_writec(&pc
, store
);
1480 err
= detach(stream
, msgno
, a
->number
, 0L, &len
, pc
, NULL
, dt_flags
);
1481 gf_clear_so_writec(store
);
1486 if(so_give(&store
)) /* close file */
1487 err
= error_description(errno
);
1490 if(!(flags
& (GER_APPEND
| GER_OVER
)))
1493 our_truncate(file
, (flags
& GER_APPEND
) ? (off_t
) orig_size
: (off_t
) 0);
1495 q_status_message2(SM_ORDER
| SM_DING
, 3, 5,
1496 /* TRANSLATORS: <error text>: Error writing attachment to <filename> */
1497 _("%s: Error writing attachment to \"%s\""),
1502 l_string
= cpystr(byte_string(len
));
1503 q_status_message8(SM_ORDER
, 0, 4,
1504 "Part %s, %s%s %s to \"%s\"%s%s%s",
1507 ? comatose(a
->body
->size
.lines
) : l_string
,
1508 is_text
? " lines" : "",
1511 : flags
& GER_APPEND
? "appended" : "written",
1513 (is_text
|| len
== a
->body
->size
.bytes
)
1514 ? "" : "(decoded from ",
1515 (is_text
|| len
== a
->body
->size
.bytes
)
1516 ? "" : byte_string(a
->body
->size
.bytes
),
1517 is_text
|| len
== a
->body
->size
.bytes
1519 fs_give((void **)&l_string
);
1526 write_attached_msg(long int msgno
, ATTACH_S
**ap
, STORE_S
*store
, int newfile
)
1529 long start_of_append
;
1533 if(ap
&& *ap
&& (*ap
)->body
&& (*ap
)->body
->nested
.msg
1534 && (*ap
)->body
->nested
.msg
->env
){
1535 start_of_append
= so_tell(store
);
1537 gf_set_so_writec(&pc
, store
);
1538 if(!(ps_global
->mail_stream
&& msgno
> 0L
1539 && msgno
<= ps_global
->mail_stream
->nmsgs
1540 && (mc
= mail_elt(ps_global
->mail_stream
, msgno
)) && mc
->valid
))
1543 if(!bezerk_delimiter((*ap
)->body
->nested
.msg
->env
, mc
, pc
, newfile
)
1544 || !format_msg_att(msgno
, ap
, NULL
, pc
, FM_NOINDENT
))
1545 err
= error_description(errno
);
1547 gf_clear_so_writec(store
);
1550 ftruncate(fileno((FILE *)store
->txt
), (off_t
) start_of_append
);
1553 err
= "Can't export message. Missing Envelope data";
1559 /*----------------------------------------------------------------------
1560 Save the attachment message/rfc822 to specified folder
1567 save_msg_att(long int msgno
, ATTACH_S
*a
)
1569 char newfolder
[MAILTMPLEN
], *save_folder
, *flags
= NULL
;
1570 char date
[64], nmsgs
[80];
1571 CONTEXT_S
*cntxt
= NULL
;
1572 int our_stream
= 0, rv
;
1573 MAILSTREAM
*save_stream
;
1576 snprintf(nmsgs
, sizeof(nmsgs
), _("Attached Msg (part %s) "), a
->number
);
1577 nmsgs
[sizeof(nmsgs
)-1] = '\0';
1578 if(save_prompt(ps_global
, &cntxt
, newfolder
, sizeof(newfolder
), nmsgs
,
1579 a
->body
->nested
.msg
->env
, msgno
, a
->number
, NULL
, NULL
)){
1580 if(strucmp(newfolder
, ps_global
->inbox_name
) == 0){
1581 save_folder
= ps_global
->VAR_INBOX_PATH
;
1585 save_folder
= newfolder
;
1587 save_stream
= save_msg_stream(cntxt
, save_folder
, &our_stream
);
1589 mc
= (msgno
> 0L && ps_global
->mail_stream
1590 && msgno
<= ps_global
->mail_stream
->nmsgs
)
1591 ? mail_elt(ps_global
->mail_stream
, msgno
) : NULL
;
1592 flags
= flag_string(ps_global
->mail_stream
, msgno
, F_ANS
|F_FLAG
|F_SEEN
|F_KEYWORD
);
1594 mail_date(date
, mc
);
1598 if(pith_opt_save_size_changed_prompt
)
1599 (*pith_opt_save_size_changed_prompt
)(0L, SSCP_INIT
);
1601 rv
= save_msg_att_work(msgno
, a
, save_stream
, save_folder
, cntxt
, date
);
1603 if(pith_opt_save_size_changed_prompt
)
1604 (*pith_opt_save_size_changed_prompt
)(0L, SSCP_END
);
1607 fs_give((void **) &flags
);
1610 q_status_message2(SM_ORDER
, 0, 4,
1611 _("Attached message (part %s) saved to \"%s\""),
1615 cmd_cancelled("Attached message Save");
1616 /* else whatever broke in save_fetch_append shoulda bitched */
1619 mail_close(save_stream
);
1624 /*----------------------------------------------------------------------
1625 Save the message/rfc822 in the given digest to the specified folder
1632 save_digest_att(long int msgno
, ATTACH_S
*a
)
1634 char newfolder
[MAILTMPLEN
], *save_folder
,
1635 date
[64], nmsgs
[80];
1636 CONTEXT_S
*cntxt
= NULL
;
1637 int our_stream
= 0, rv
, cnt
= 0;
1638 MAILSTREAM
*save_stream
;
1643 && !strncmp(a
->number
, ap
->number
, strlen(a
->number
));
1645 if(MIME_MSG(ap
->body
->type
, ap
->body
->subtype
))
1648 snprintf(nmsgs
, sizeof(nmsgs
), "%d Msg Digest (part %s) ", cnt
, a
->number
);
1649 nmsgs
[sizeof(nmsgs
)-1] = '\0';
1651 if(save_prompt(ps_global
, &cntxt
, newfolder
, sizeof(newfolder
),
1652 nmsgs
, NULL
, 0, NULL
, NULL
, NULL
)){
1653 save_folder
= (strucmp(newfolder
, ps_global
->inbox_name
) == 0)
1654 ? ps_global
->VAR_INBOX_PATH
: newfolder
;
1656 save_stream
= save_msg_stream(cntxt
, save_folder
, &our_stream
);
1658 if(pith_opt_save_size_changed_prompt
)
1659 (*pith_opt_save_size_changed_prompt
)(0L, SSCP_INIT
);
1663 && !strncmp(a
->number
, ap
->number
, strlen(a
->number
));
1665 if(MIME_MSG(ap
->body
->type
, ap
->body
->subtype
)){
1667 rv
= save_msg_att_work(msgno
, ap
, save_stream
, save_folder
, cntxt
, date
);
1672 if(pith_opt_save_size_changed_prompt
)
1673 (*pith_opt_save_size_changed_prompt
)(0L, SSCP_END
);
1676 q_status_message2(SM_ORDER
, 0, 4,
1677 _("Attached digest (part %s) saved to \"%s\""),
1681 cmd_cancelled("Attached digest Save");
1682 /* else whatever broke in save_fetch_append shoulda bitched */
1685 mail_close(save_stream
);
1691 save_msg_att_work(long int msgno
, ATTACH_S
*a
, MAILSTREAM
*save_stream
,
1692 char *save_folder
, CONTEXT_S
*cntxt
, char *date
)
1697 if(a
&& a
->body
&& MIME_MSG(a
->body
->type
, a
->body
->subtype
)){
1698 if((so
= so_get(CharStar
, NULL
, WRITE_ACCESS
)) != NULL
){
1700 rv
= save_fetch_append(ps_global
->mail_stream
, msgno
,
1702 save_stream
, save_folder
, cntxt
,
1703 a
->body
->size
.bytes
,
1707 dprint((1, "Can't allocate store for save: %s\n",
1708 error_description(errno
)));
1709 q_status_message(SM_ORDER
| SM_DING
, 3, 4,
1710 _("Problem creating space for message text."));
1719 /*----------------------------------------------------------------------
1720 Export the attachment message/rfc822 to specified file
1727 export_msg_att(long int msgno
, ATTACH_S
*a
)
1729 char filename
[MAXPATH
+1], full_filename
[MAXPATH
+1], *err
;
1730 int rv
, rflags
= GER_NONE
, i
= 1;
1733 static HISTORY_S
*history
= NULL
;
1734 static ESCKEY_S opts
[] = {
1735 {ctrl('T'), 10, "^T", N_("To Files")},
1736 {-1, 0, NULL
, NULL
},
1737 {-1, 0, NULL
, NULL
}};
1739 if(F_ON(F_ENABLE_TAB_COMPLETE
,ps_global
)){
1740 opts
[i
].ch
= ctrl('I');
1742 opts
[i
].name
= "TAB";
1743 opts
[i
].label
= N_("Complete");
1746 filename
[0] = full_filename
[0] = '\0';
1748 rv
= get_export_filename(ps_global
, filename
, NULL
, full_filename
,
1749 sizeof(filename
), "msg attachment",
1750 /* TRANSLATORS: Message Attachment (a screen title) */
1751 _("MSG ATTACHMENT"), opts
,
1752 &rflags
, -FOOTER_ROWS(ps_global
),
1753 GE_IS_EXPORT
| GE_SEQ_SENSITIVE
, &history
);
1758 cmd_cancelled("Export");
1762 q_status_message1(SM_ORDER
, 0, 2,
1763 _("Can't export to file outside of %s"),
1764 ps_global
->VAR_OPER_DIR
);
1771 /* With name in hand, allocate storage object and save away... */
1772 if((store
= so_get(FileStar
, full_filename
, WRITE_ACCESS
)) != NULL
){
1773 if((err
= write_attached_msg(msgno
, &ap
, store
, !(rflags
& GER_APPEND
))) != NULL
)
1774 q_status_message(SM_ORDER
| SM_DING
, 3, 4, err
);
1776 q_status_message3(SM_ORDER
, 0, 4,
1777 _("Attached message (part %s) %s to \"%s\""),
1781 : rflags
& GER_APPEND
? _("appended") : _("written"),
1785 q_status_message2(SM_ORDER
| SM_DING
, 3, 4,
1786 _("Error writing %s: %s"),
1787 full_filename
, error_description(errno
));
1790 q_status_message2(SM_ORDER
| SM_DING
, 3, 4,
1791 /* TRANSLATORS: Error opening file <filename> to export message: <error text> */
1792 _("Error opening file \"%s\" to export message: %s"),
1793 full_filename
, error_description(errno
));
1797 /*----------------------------------------------------------------------
1798 Export the message/rfc822 in the given digest to the specified file
1805 export_digest_att(long int msgno
, ATTACH_S
*a
)
1807 char filename
[MAXPATH
+1], full_filename
[MAXPATH
+1], *err
= NULL
;
1808 int rv
, rflags
= GER_NONE
, i
= 1;
1811 static HISTORY_S
*history
= NULL
;
1813 static ESCKEY_S opts
[] = {
1814 {ctrl('T'), 10, "^T", N_("To Files")},
1815 {-1, 0, NULL
, NULL
},
1816 {-1, 0, NULL
, NULL
}};
1818 if(F_ON(F_ENABLE_TAB_COMPLETE
,ps_global
)){
1819 opts
[i
].ch
= ctrl('I');
1821 opts
[i
].name
= "TAB";
1822 opts
[i
].label
= N_("Complete");
1825 filename
[0] = full_filename
[0] = '\0';
1827 rv
= get_export_filename(ps_global
, filename
, NULL
, full_filename
,
1828 sizeof(filename
), "digest", _("DIGEST ATTACHMENT"),
1829 opts
, &rflags
, -FOOTER_ROWS(ps_global
),
1830 GE_IS_EXPORT
| GE_SEQ_SENSITIVE
, &history
);
1835 cmd_cancelled("Export");
1839 q_status_message1(SM_ORDER
, 0, 2,
1840 _("Can't export to file outside of %s"),
1841 ps_global
->VAR_OPER_DIR
);
1848 /* With name in hand, allocate storage object and save away... */
1849 if((store
= so_get(FileStar
, full_filename
, WRITE_ACCESS
)) != NULL
){
1854 && !strncmp(a
->number
, ap
->number
, strlen(a
->number
))
1857 if(MIME_MSG(ap
->body
->type
, ap
->body
->subtype
)){
1859 err
= write_attached_msg(msgno
, &ap
, store
,
1860 !count
&& !(rflags
& GER_APPEND
));
1865 err
= error_description(errno
);
1868 q_status_message1(SM_ORDER
| SM_DING
, 3, 3,
1869 _("Error exporting: %s"), err
);
1870 q_status_message1(SM_ORDER
| SM_DING
, 3, 3,
1871 _("%s messages exported before error occurred"), err
);
1874 q_status_message4(SM_ORDER
, 0, 4,
1875 "%s messages in digest (part %s) %s to \"%s\"",
1880 : rflags
& GER_APPEND
? "appended" : "written",
1884 q_status_message2(SM_ORDER
| SM_DING
, 3, 4,
1885 _("Error opening file \"%s\" to export digest: %s"),
1886 full_filename
, error_description(errno
));
1890 /*----------------------------------------------------------------------
1891 Print the given attachment associated with the given message no
1898 print_attachment(int qline
, long int msgno
, ATTACH_S
*a
)
1902 if(ps_global
->restricted
){
1903 q_status_message(SM_ORDER
| SM_DING
, 0, 4,
1904 "Alpine demo can't Print attachments");
1908 snprintf(prompt
, sizeof(prompt
), "attach%s %s",
1909 (a
->body
->type
== TYPETEXT
) ? "ment" : "ed message",
1910 MIME_DGST_A(a
) ? "digest" : a
->number
);
1911 prompt
[sizeof(prompt
)-1] = '\0';
1912 if(open_printer(prompt
) >= 0){
1914 (void) print_msg_att(msgno
, a
, 1);
1915 else if(MIME_DGST_A(a
))
1916 print_digest_att(msgno
, a
);
1918 (void) decode_text(a
, msgno
, print_char
, NULL
, QStatus
, FM_NOINDENT
);
1926 * Print the attachment message/rfc822 to specified file
1928 * Returns 1 on success, 0 on failure.
1931 print_msg_att(long int msgno
, ATTACH_S
*a
, int first
)
1936 if(!(ps_global
->mail_stream
&& msgno
> 0L
1937 && msgno
<= ps_global
->mail_stream
->nmsgs
1938 && (mc
= mail_elt(ps_global
->mail_stream
, msgno
)) && mc
->valid
))
1941 if(((!first
&& F_ON(F_AGG_PRINT_FF
, ps_global
)) ? print_char(FORMFEED
) : 1)
1942 && pine_mail_fetchstructure(ps_global
->mail_stream
, msgno
, NULL
)
1943 && (F_ON(F_FROM_DELIM_IN_PRINT
, ps_global
)
1944 ? bezerk_delimiter(a
->body
->nested
.msg
->env
, mc
, print_char
, !first
)
1946 && format_msg_att(msgno
, &ap
, NULL
, print_char
, FM_NOINDENT
))
1950 q_status_message2(SM_ORDER
| SM_DING
, 3, 3,
1951 _("Error printing message %s, part %s"),
1952 long2string(msgno
), a
->number
);
1957 /*----------------------------------------------------------------------
1958 Print the attachment message/rfc822 to specified file
1965 print_digest_att(long int msgno
, ATTACH_S
*a
)
1972 && !strncmp(a
->number
, ap
->number
, strlen(a
->number
));
1974 if(MIME_MSG(ap
->body
->type
, ap
->body
->subtype
)){
1975 char *p
= part_desc(ap
->number
, ap
->body
->nested
.msg
->body
,
1976 0, 80, FM_NOINDENT
, print_char
);
1978 q_status_message1(SM_ORDER
| SM_DING
, 3, 3,
1979 _("Can't print digest: %s"), p
);
1982 else if(!print_msg_att(msgno
, ap
, !next
))
1991 /*----------------------------------------------------------------------
1992 Unpack and display the given attachment associated with given message no.
1994 Args: msgno -- message no attachment is part of
1995 a -- attachment to display
1997 Returns: 0 on success, non-zero (and error message queued) otherwise
2000 display_attachment(long int msgno
, ATTACH_S
*a
, int flags
)
2002 char *filename
= NULL
;
2003 char sender_filename
[1000];
2008 int we_cancel
= 0, rv
;
2013 /*------- Display the attachment -------*/
2014 if(dispatch_attachment(a
) == MCD_NONE
){
2015 /*----- Can't display this type ------*/
2016 if(a
->body
->encoding
< ENCOTHER
)
2017 q_status_message4(SM_ORDER
| SM_DING
, 3, 5,
2018 /* TRANSLATORS: Don't know how to display <certain type> attachments. <might say Try Save.> */
2019 _("Don't know how to display %s%s%s attachments.%s"),
2020 body_type_names(a
->body
->type
),
2021 a
->body
->subtype
? "/" : "",
2022 a
->body
->subtype
? a
->body
->subtype
:"",
2023 (flags
& DA_SAVE
) ? _(" Try Save.") : "");
2025 q_status_message1(SM_ORDER
| SM_DING
, 3, 5,
2026 _("Don't know how to unpack \"%s\" encoding"),
2027 body_encodings
[(a
->body
->encoding
<= ENCMAX
)
2028 ? a
->body
->encoding
: ENCOTHER
]);
2032 else if(!(a
->can_display
& MCD_EXTERNAL
)){
2033 if(a
->body
->type
== TYPEMULTIPART
){
2034 if(a
->body
->subtype
){
2035 if(!strucmp(a
->body
->subtype
, "digest"))
2036 display_digest_att(msgno
, a
, flags
);
2038 q_status_message1(SM_ORDER
, 3, 5,
2039 _("Can't display Multipart/%s"),
2043 q_status_message(SM_ORDER
, 3, 5,
2044 _("Can't display unknown Multipart Subtype"));
2046 else if(MIME_VCARD_A(a
))
2047 display_vcard_att(msgno
, a
, flags
);
2048 else if(a
->body
->type
== TYPETEXT
){
2050 rv
= display_text_att(msgno
, a
, flags
);
2051 } while(rv
== MC_FULLHDR
);
2053 else if(a
->body
->type
== TYPEMESSAGE
){
2055 rv
= display_msg_att(msgno
, a
, flags
);
2056 } while(rv
== MC_FULLHDR
);
2059 ps_global
->mangled_screen
= 1;
2063 /* arrive here if MCD_EXTERNAL */
2065 if(F_OFF(F_QUELL_ATTACH_EXTRA_PROMPT
, ps_global
)
2066 && (!(flags
& DA_DIDPROMPT
)))
2067 if(want_to(_("View selected Attachment"), 'y',
2068 0, NO_HELP
, WT_NORM
) == 'n'){
2069 cmd_cancelled(NULL
);
2073 sender_filename
[0] = '\0';
2077 if(F_OFF(F_QUELL_ATTACH_EXT_WARN
, ps_global
)
2078 && (a
->can_display
& MCD_EXT_PROMPT
)){
2081 (void) get_filename_parameter(sender_filename
, sizeof(sender_filename
),
2083 snprintf(prompt
, sizeof(prompt
),
2084 "Attachment %s%s unrecognized. %s%s%s",
2086 strlen(a
->body
->subtype
) > 12 ? "..." : "",
2087 (extp
&& extp
[0]) ? "Try open by file extension (." : "Try opening anyway",
2088 (extp
&& extp
[0]) ? extp
: "",
2089 (extp
&& extp
[0]) ? ")" : "");
2091 if(want_to(prompt
, 'n', 0, NO_HELP
, WT_NORM
) == 'n'){
2092 cmd_cancelled(NULL
);
2097 /*------ Write the image to a temporary file ------*/
2099 /* create type/subtype in mtype */
2100 strncpy(mtype
, body_type_names(a
->body
->type
), sizeof(mtype
));
2101 mtype
[sizeof(mtype
)-1] = '\0';
2102 if(a
->body
->subtype
){
2103 strncat(mtype
, "/", sizeof(mtype
)-strlen(mtype
)-1);
2104 mtype
[sizeof(mtype
)-1] = '\0';
2105 strncat(mtype
, a
->body
->subtype
, sizeof(mtype
)-strlen(mtype
)-1);
2106 mtype
[sizeof(mtype
)-1] = '\0';
2110 * If we haven't already gotten the filename parameter, get it
2111 * now. It may be used in the temporary filename and possibly
2112 * for its extension.
2114 if(!sender_filename
[0])
2115 (void) get_filename_parameter(sender_filename
, sizeof(sender_filename
),
2118 if(!set_mime_extension_by_type(ext
, mtype
)){ /* extension from type */
2119 if(extp
&& extp
[0]){ /* extension from filename */
2120 strncpy(ext
, extp
, sizeof(ext
));
2121 ext
[sizeof(ext
)-1] = '\0';
2125 /* create a temp file */
2126 if(sender_filename
){
2129 /* get rid of any extension */
2130 if(mt_get_file_ext(sender_filename
, &q
) && q
&& q
> sender_filename
)
2133 /* be careful about what is allowed in the filename */
2134 for(p
= sender_filename
; *p
; p
++)
2135 if(!(isascii((unsigned char) *p
)
2136 && (isalnum((unsigned char) *p
)
2137 || *p
== '-' || *p
== '_' || *p
== '+' || *p
== '.' || *p
== '=')))
2140 if(!*p
) /* filename was ok to use */
2141 snprintf(prefix
, sizeof(prefix
), "img-%s-", sender_filename
);
2144 /* didn't get it yet */
2146 snprintf(prefix
, sizeof(prefix
), "img-%s-", (a
->body
->subtype
)
2147 ? a
->body
->subtype
: "unk");
2150 /* We are creating a temporary name. This is just a prefix. If you
2151 * need the original name, use the save command, so if the prefix
2152 * is too long, shorten it.
2154 if (strlen(prefix
) > 9){
2159 filename
= temp_nam_ext(NULL
, prefix
, ext
);
2162 q_status_message1(SM_ORDER
| SM_DING
, 3, 5,
2163 _("Error \"%s\", Can't create temporary file"),
2164 error_description(errno
));
2168 if((store
= so_get(FileStar
, filename
, WRITE_ACCESS
|OWNER_ONLY
)) == NULL
){
2169 q_status_message2(SM_ORDER
| SM_DING
, 3, 5,
2170 _("Error \"%s\", Can't write file %s"),
2171 error_description(errno
), filename
);
2173 our_unlink(filename
);
2174 fs_give((void **)&filename
);
2181 if(a
->body
->size
.bytes
){
2184 snprintf(msg_buf
, sizeof(msg_buf
), "Decoding %s%s%s%s",
2185 a
->description
? "\"" : "",
2186 a
->description
? a
->description
: "attachment number ",
2187 a
->description
? "" : a
->number
,
2188 a
->description
? "\"" : "");
2189 msg_buf
[sizeof(msg_buf
)-1] = '\0';
2190 we_cancel
= init_att_progress(msg_buf
, ps_global
->mail_stream
,
2194 if(a
->body
->type
== TYPEMULTIPART
){
2195 char *h
= mail_fetch_mime(ps_global
->mail_stream
, msgno
, a
->number
,
2198 /* Write to store while converting newlines */
2200 if(*h
== '\015' && *(h
+1) == '\012'){
2201 so_puts(store
, NEWLINE
);
2205 so_writec(*h
++, store
);
2208 gf_set_so_writec(&pc
, store
);
2210 err
= detach(ps_global
->mail_stream
, msgno
, a
->number
, 0L, NULL
, pc
, NULL
, 0);
2212 gf_clear_so_writec(store
);
2220 q_status_message2(SM_ORDER
| SM_DING
, 3, 5,
2221 "%s: Error saving image to temp file %s",
2224 our_unlink(filename
);
2225 fs_give((void **)&filename
);
2231 /*----- Run the viewer process ----*/
2232 run_viewer(filename
, a
->body
, a
->can_display
& MCD_EXT_PROMPT
);
2234 fs_give((void **)&filename
);
2240 /*----------------------------------------------------------------------
2241 Fish the required command from mailcap and run it
2243 Args: image_file -- The name of the file to pass viewer
2244 body -- body struct containing type/subtype of part
2246 A side effect may be that scrolltool is called as well if
2247 exec_mailcap_cmd has any substantial output...
2250 run_viewer(char *image_file
, struct mail_bodystruct
*body
, int chk_extension
)
2252 MCAP_CMD_S
*mc_cmd
= NULL
;
2253 int needs_terminal
= 0, we_cancel
= 0;
2255 we_cancel
= busy_cue("Displaying attachment", NULL
, 0);
2257 if((mc_cmd
= mailcap_build_command(body
->type
, body
->subtype
,
2259 &needs_terminal
, chk_extension
)) != NULL
){
2261 cancel_busy_cue(-1);
2263 exec_mailcap_cmd(mc_cmd
, image_file
, needs_terminal
);
2265 fs_give((void **)&mc_cmd
->command
);
2266 fs_give((void **)&mc_cmd
);
2270 cancel_busy_cue(-1);
2272 q_status_message1(SM_ORDER
, 3, 4, _("Cannot display %s attachment"),
2273 type_desc(body
->type
, body
->subtype
,
2274 body
->parameter
, NULL
, 1));
2279 /*----------------------------------------------------------------------
2280 Detach and provide for browsing a text body part
2282 Args: msgno -- raw message number to get part from
2283 a -- attachment struct for the desired part
2288 format_text_att(long int msgno
, ATTACH_S
*a
, HANDLE_S
**handlesp
)
2293 if((store
= so_get(CharStar
, NULL
, EDIT_ACCESS
)) != NULL
){
2295 init_handles(handlesp
);
2297 gf_set_so_writec(&pc
, store
);
2298 (void) decode_text(a
, msgno
, pc
, handlesp
, QStatus
, FM_DISPLAY
);
2299 gf_clear_so_writec(store
);
2306 /*----------------------------------------------------------------------
2307 Detach and provide for browsing a text body part
2309 Args: msgno -- raw message number to get part from
2310 a -- attachment struct for the desired part
2315 display_text_att(long int msgno
, ATTACH_S
*a
, int flags
)
2318 HANDLE_S
*handles
= NULL
;
2322 clear_index_cache_ent(ps_global
->mail_stream
, msgno
, 0);
2324 if((store
= format_text_att(msgno
, a
, &handles
)) != NULL
){
2325 rv
= scroll_attachment("ATTACHED TEXT", store
, CharStar
, handles
, a
, flags
);
2326 free_handles(&handles
);
2327 so_give(&store
); /* free resources associated with store */
2330 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
2331 _("Error allocating space for attachment."));
2337 /*----------------------------------------------------------------------
2338 Detach and provide for browsing a body part of type "MESSAGE"
2340 Args: msgno -- message number to get partrom
2341 a -- attachment struct for the desired part
2346 display_msg_att(long int msgno
, ATTACH_S
*a
, int flags
)
2351 HANDLE_S
*handles
= NULL
;
2355 clear_index_cache_ent(ps_global
->mail_stream
, msgno
, 0);
2357 /* BUG, should check this return code */
2358 (void) pine_mail_fetchstructure(ps_global
->mail_stream
, msgno
, NULL
);
2360 /* initialize a storage object */
2361 if(!(store
= so_get(CharStar
, NULL
, EDIT_ACCESS
))){
2362 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
2363 _("Error allocating space for message."));
2367 gf_set_so_writec(&pc
, store
);
2369 if(format_msg_att(msgno
, &ap
, &handles
, pc
, FM_DISPLAY
)){
2370 if(ps_global
->full_header
== 2)
2371 q_status_message(SM_INFO
, 0, 3,
2372 _("Full header mode ON. All header text being included"));
2374 rv
= scroll_attachment((a
->body
->subtype
2375 && !strucmp(a
->body
->subtype
, "delivery-status"))
2376 ? "DELIVERY STATUS REPORT" : "ATTACHED MESSAGE",
2377 store
, CharStar
, handles
, a
, flags
);
2378 free_handles(&handles
);
2381 gf_clear_so_writec(store
);
2383 so_give(&store
); /* free resources associated with store */
2388 /*----------------------------------------------------------------------
2389 Detach and provide for browsing a multipart body part of type "DIGEST"
2391 Args: msgno -- message number to get partrom
2392 a -- attachment struct for the desired part
2397 display_digest_att(long int msgno
, ATTACH_S
*a
, int flags
)
2401 HANDLE_S
*handles
= NULL
;
2403 SourceType src
= CharStar
;
2407 clear_index_cache_ent(ps_global
->mail_stream
, msgno
, 0);
2409 /* BUG, should check this return code */
2410 (void) pine_mail_fetchstructure(ps_global
->mail_stream
, msgno
, NULL
);
2412 if(!(store
= so_get(src
, NULL
, EDIT_ACCESS
))){
2413 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
2414 _("Error allocating space for message."));
2418 gf_set_so_writec(&pc
, store
);
2421 * While in a subtype of this message
2425 && !strncmp(a
->number
, ap
->number
, strlen(a
->number
))
2428 if(ap
->body
->type
== TYPEMESSAGE
){
2431 if(ap
->body
->subtype
&& strucmp(ap
->body
->subtype
, "rfc822")){
2434 tsub
= cpystr(ap
->body
->subtype
);
2435 convert_possibly_encoded_str_to_utf8((char **) &tsub
);
2436 snprintf(tmp_20k_buf
, SIZEOF_20KBUF
, "Unknown Message subtype: %s", tsub
);
2437 tmp_20k_buf
[SIZEOF_20KBUF
-1] = '\0';
2439 if((errstr
= format_editorial(tmp_20k_buf
,
2440 ps_global
->ttyo
->screen_cols
, 0,
2441 NULL
, pc
)) != NULL
){
2442 q_status_message1(SM_ORDER
| SM_DING
, 3, 3,
2443 _("Can't format digest: %s"), errstr
);
2446 else if(!gf_puts(NEWLINE
, pc
))
2449 fs_give((void **) &tsub
);
2452 if((errstr
= part_desc(ap
->number
, ap
->body
->nested
.msg
->body
,
2453 0, ps_global
->ttyo
->screen_cols
, FM_DISPLAY
, pc
)) != NULL
){
2454 q_status_message1(SM_ORDER
| SM_DING
, 3, 3,
2455 _("Can't format digest: %s"), errstr
);
2458 else if(!format_msg_att(msgno
, &ap
, &handles
, pc
, FM_DISPLAY
))
2462 else if(ap
->body
->type
== TYPETEXT
2463 && decode_text(ap
, msgno
, pc
, NULL
, QStatus
, FM_DISPLAY
))
2465 else if(!gf_puts("Unknown type in Digest", pc
))
2470 if(ps_global
->full_header
== 2)
2471 q_status_message(SM_INFO
, 0, 3,
2472 _("Full header mode ON. All header text being included"));
2474 scroll_attachment(_("ATTACHED MESSAGES"), store
, src
, handles
, a
, flags
);
2477 free_handles(&handles
);
2479 gf_clear_so_writec(store
);
2480 so_give(&store
); /* free resources associated with store */
2485 scroll_attachment(char *title
, STORE_S
*store
, SourceType src
, HANDLE_S
*handles
, ATTACH_S
*a
, int flags
)
2489 memset(&sargs
, 0, sizeof(SCROLL_S
));
2490 sargs
.text
.text
= so_text(store
);
2491 sargs
.text
.src
= src
;
2492 sargs
.text
.desc
= "attachment";
2493 sargs
.text
.handles
= handles
;
2494 sargs
.bar
.title
= title
;
2495 sargs
.proc
.tool
= process_attachment_cmd
;
2496 sargs
.proc
.data
.p
= (void *) a
;
2497 sargs
.help
.text
= h_mail_text_att_view
;
2498 sargs
.help
.title
= _("HELP FOR ATTACHED TEXT VIEW");
2499 sargs
.keys
.menu
= &att_view_keymenu
;
2500 setbitmap(sargs
.keys
.bitmap
);
2502 /* First, fix up "back" key */
2503 if(flags
& DA_FROM_VIEW
){
2504 att_view_keymenu
.keys
[ATV_BACK_KEY
].label
= N_("MsgText");
2507 att_view_keymenu
.keys
[ATV_BACK_KEY
].label
= N_("AttchIndex");
2511 clrbitn(ATV_VIEW_HILITE
, sargs
.keys
.bitmap
);
2512 clrbitn(ATV_PREV_URL
, sargs
.keys
.bitmap
);
2513 clrbitn(ATV_NEXT_URL
, sargs
.keys
.bitmap
);
2516 if(F_OFF(F_ENABLE_PIPE
, ps_global
))
2517 clrbitn(ATV_PIPE_KEY
, sargs
.keys
.bitmap
);
2519 if(!(a
->body
->type
== TYPETEXT
|| MIME_MSG_A(a
) || MIME_DGST_A(a
)))
2520 clrbitn(ATV_PRINT_KEY
, sargs
.keys
.bitmap
);
2523 * If message or digest, leave Reply and Save and,
2524 * conditionally, Bounce on...
2527 if(F_OFF(F_ENABLE_BOUNCE
, ps_global
))
2528 clrbitn(ATV_BOUNCE_KEY
, sargs
.keys
.bitmap
);
2531 clrbitn(ATV_BOUNCE_KEY
, sargs
.keys
.bitmap
);
2532 clrbitn(ATV_REPLY_KEY
, sargs
.keys
.bitmap
);
2533 clrbitn(ATV_EXPORT_KEY
, sargs
.keys
.bitmap
);
2536 if(!(ps_global
->smime
&& ps_global
->smime
->need_passphrase
))
2537 clrbitn(ATV_DECRYPT_KEY
, sargs
.keys
.bitmap
);
2539 if(F_ON(F_DONT_DO_SMIME
, ps_global
) || !MIME_MSG_A(a
)){
2540 clrbitn(ATV_DECRYPT_KEY
, sargs
.keys
.bitmap
);
2541 clrbitn(ATV_SECURITY_KEY
, sargs
.keys
.bitmap
);
2545 sargs
.use_indexline_color
= 1;
2547 if(DA_RESIZE
& flags
)
2548 sargs
.resize_exit
= 1;
2552 sargs
.mouse
.popup
= scroll_att_popup
;
2555 return(scrolltool(&sargs
));
2560 display_smime_info_att(struct pine
*ps
, ATTACH_S
*a
)
2562 if(smime_check(a
->body
->nested
.msg
->body
) == 0){
2563 q_status_message(SM_ORDER
| SM_DING
, 0, 3,
2564 _("Not a signed or encrypted message"));
2568 display_smime_info(ps
, a
->body
->nested
.msg
->env
, a
->body
->nested
.msg
->body
);
2573 process_attachment_cmd(int cmd
, MSGNO_S
*msgmap
, SCROLL_S
*sparms
)
2576 long rawno
= mn_m2raw(msgmap
, mn_get_cur(msgmap
));
2577 #define AD(X) ((ATTACH_S *) (X)->proc.data.p)
2585 ps_global
->next_screen
= quit_screen
;
2589 ps_global
->next_screen
= main_menu_screen
;
2593 reply_msg_att(ps_global
->mail_stream
, rawno
, sparms
->proc
.data
.p
);
2597 forward_attachment(ps_global
->mail_stream
, rawno
, sparms
->proc
.data
.p
);
2601 bounce_msg_att(ps_global
->mail_stream
, rawno
, AD(sparms
)->number
,
2602 AD(sparms
)->body
->nested
.msg
->env
->subject
);
2603 ps_global
->mangled_footer
= 1;
2607 delete_attachment(rawno
, sparms
->proc
.data
.p
);
2611 if(undelete_attachment(rawno
, sparms
->proc
.data
.p
, &n
))
2612 q_status_message1(SM_ORDER
, 0, 3,
2613 "Part %s UNdeleted", AD(sparms
)->number
);
2618 save_attachment(-FOOTER_ROWS(ps_global
), rawno
, sparms
->proc
.data
.p
);
2619 ps_global
->mangled_footer
= 1;
2623 export_attachment(-FOOTER_ROWS(ps_global
), rawno
, sparms
->proc
.data
.p
);
2624 ps_global
->mangled_footer
= 1;
2628 print_attachment(-FOOTER_ROWS(ps_global
), rawno
, sparms
->proc
.data
.p
);
2629 ps_global
->mangled_footer
= 1;
2633 pipe_attachment(rawno
, sparms
->proc
.data
.p
);
2634 ps_global
->mangled_footer
= 1;
2638 ps_global
->full_header
++;
2639 if(ps_global
->full_header
== 1){
2640 if(!(ps_global
->quote_suppression_threshold
2641 && (ps_global
->some_quoting_was_suppressed
/* || in_index != View*/)))
2642 ps_global
->full_header
++;
2644 else if(ps_global
->full_header
> 2)
2645 ps_global
->full_header
= 0;
2647 switch(ps_global
->full_header
){
2649 q_status_message(SM_ORDER
, 0, 3,
2650 _("Display of full headers is now off."));
2654 q_status_message1(SM_ORDER
, 0, 3,
2655 _("Quotes displayed, use %s to see full headers"),
2656 F_ON(F_USE_FK
, ps_global
) ? "F9" : "H");
2660 q_status_message(SM_ORDER
, 0, 3,
2661 _("Display of full headers is now on."));
2671 if(ps_global
->smime
&& ps_global
->smime
->need_passphrase
)
2672 smime_get_passphrase();
2676 display_smime_info_att(ps_global
, sparms
->proc
.data
.p
);
2681 alpine_panic("Unexpected command case");
2690 * Returns 1 on success, 0 on error.
2693 format_msg_att(long int msgno
, ATTACH_S
**a
, HANDLE_S
**handlesp
, gf_io_t pc
, int flags
)
2697 if((*a
)->body
->type
!= TYPEMESSAGE
)
2698 return(gf_puts("[ Undisplayed Attachment of Type ", pc
)
2699 && gf_puts(body_type_names((*a
)->body
->type
), pc
)
2700 && gf_puts(" ]", pc
) && gf_puts(NEWLINE
, pc
));
2702 if((*a
)->body
->subtype
&& strucmp((*a
)->body
->subtype
, "rfc822") == 0){
2705 HD_INIT(&h
, ps_global
->VAR_VIEW_HEADERS
, ps_global
->view_all_except
,
2707 switch(format_header(ps_global
->mail_stream
, msgno
, (*a
)->number
,
2708 (*a
)->body
->nested
.msg
->env
, &h
, NULL
, NULL
,
2710 case -1 : /* write error */
2713 case 1 : /* fetch error */
2714 if(!(gf_puts("[ Error fetching header ]", pc
)
2715 && !gf_puts(NEWLINE
, pc
)))
2721 gf_puts(NEWLINE
, pc
);
2726 if((*a
)->body
&& (*a
)->body
->subtype
&& (strucmp((*a
)->body
->subtype
, OUR_PKCS7_ENCLOSURE_SUBTYPE
)==0)){
2727 if((*a
)->description
){
2728 if(!(!format_editorial((*a
)->description
,
2729 ps_global
->ttyo
->screen_cols
,
2731 && gf_puts(NEWLINE
, pc
) && gf_puts(NEWLINE
, pc
)))
2739 if(((*a
))->description
2740 && (*a
)->body
&& (*a
)->body
->type
== TYPETEXT
){
2741 if(decode_text(*a
, msgno
, pc
, NULL
, QStatus
, flags
))
2744 else if(!(gf_puts("[Can't display ", pc
)
2745 && gf_puts(((*a
)->description
&& (*a
)->body
)
2746 ? "first non-" : "missing ", pc
)
2747 && gf_puts("text segment]", pc
)
2748 && gf_puts(NEWLINE
, pc
)))
2754 else if((*a
)->body
->subtype
2755 && strucmp((*a
)->body
->subtype
, "external-body") == 0) {
2756 if(format_editorial("This part is not included and can be fetched as follows:",
2757 ps_global
->ttyo
->screen_cols
, flags
, NULL
, pc
)
2758 || !gf_puts(NEWLINE
, pc
)
2759 || format_editorial(display_parameters((*a
)->body
->parameter
),
2760 ps_global
->ttyo
->screen_cols
, flags
, handlesp
, pc
))
2763 else if(decode_text(*a
, msgno
, pc
, NULL
, QStatus
, flags
))
2771 display_vcard_att(long int msgno
, ATTACH_S
*a
, int flags
)
2773 STORE_S
*in_store
, *out_store
= NULL
;
2774 HANDLE_S
*handles
= NULL
;
2777 char **lines
, **ll
, *errstr
= NULL
, tmp
[MAILTMPLEN
], *p
;
2778 int cmd
, indent
, begins
= 0;
2780 lines
= detach_vcard_att(ps_global
->mail_stream
,
2781 msgno
, a
->body
, a
->number
);
2783 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
2784 _("Error accessing attachment."));
2788 if(!(in_store
= so_get(CharStar
, NULL
, EDIT_ACCESS
))){
2789 free_list_array(&lines
);
2790 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
2791 _("Error allocating space for attachment."));
2795 for(ll
= lines
, indent
= 0; ll
&& *ll
; ll
++)
2796 if((p
= strindex(*ll
, ':')) && p
- *ll
> indent
)
2800 for(ll
= lines
; ll
&& *ll
; ll
++){
2801 if((p
= strindex(*ll
, ':')) != NULL
){
2802 if(begins
< 2 && struncmp(*ll
, "begin:", 6) == 0)
2805 snprintf(tmp
, sizeof(tmp
), " %-*.*s : ", indent
- 5,
2806 (int) MIN(p
- *ll
, sizeof(tmp
)-5), *ll
);
2807 tmp
[sizeof(tmp
)-1] = '\0';
2808 so_puts(in_store
, tmp
);
2813 so_puts(in_store
, repeat_char(indent
, SPACE
));
2816 snprintf(tmp
, sizeof(tmp
), "%.200s", p
);
2817 tmp
[sizeof(tmp
)-1] = '\0';
2819 (char *)rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf
,
2820 SIZEOF_20KBUF
, tmp
));
2821 so_puts(in_store
, "\015\012");
2824 free_list_array(&lines
);
2826 so_puts(in_store
, "\015\012\015\012");
2829 if((out_store
= so_get(CharStar
, NULL
, EDIT_ACCESS
)) != NULL
){
2830 so_seek(in_store
, 0L, 0);
2832 init_handles(&handles
);
2835 if(F_ON(F_VIEW_SEL_URL
, ps_global
)
2836 || F_ON(F_VIEW_SEL_URL_HOST
, ps_global
)
2837 || F_ON(F_SCAN_ADDR
, ps_global
))
2838 gf_link_filter(gf_line_test
,
2839 gf_line_test_opt(url_hilite
,
2840 gf_url_hilite_opt(&uh
,&handles
,0)));
2842 gf_link_filter(gf_wrap
,
2843 gf_wrap_filter_opt(ps_global
->ttyo
->screen_cols
- 4,
2844 ps_global
->ttyo
->screen_cols
,
2845 NULL
, indent
, GFW_HANDLES
));
2846 gf_link_filter(gf_nvtnl_local
, NULL
);
2848 gf_set_so_readc(&gc
, in_store
);
2849 gf_set_so_writec(&pc
, out_store
);
2851 errstr
= gf_pipe(gc
, pc
);
2853 gf_clear_so_readc(in_store
);
2856 #define VCARD_TEXT_ONE _("This is a vCard which has been forwarded to you. You may add parts of it to your address book with the Save command. You will have a chance to edit it before committing it to your address book.")
2857 #define VCARD_TEXT_MORE _("This is a vCard which has been forwarded to you. You may add the entries to your address book with the Save command.")
2858 errstr
= format_editorial((begins
> 1)
2859 ? VCARD_TEXT_MORE
: VCARD_TEXT_ONE
,
2860 ps_global
->ttyo
->screen_cols
, 0, NULL
, pc
);
2863 gf_clear_so_writec(out_store
);
2866 cmd
= scroll_attachment(_("ADDRESS BOOK ATTACHMENT"), out_store
,
2867 CharStar
, handles
, a
, flags
| DA_RESIZE
);
2869 free_handles(&handles
);
2870 so_give(&out_store
);
2873 errstr
= _("Error allocating space");
2875 while(!errstr
&& (cmd
== MC_RESIZE
|| cmd
== MC_FULLHDR
));
2878 q_status_message1(SM_ORDER
| SM_DING
, 3, 3,
2879 _("Can't format entry : %s"), errstr
);
2885 /*----------------------------------------------------------------------
2886 Display attachment information
2888 Args: msgno -- message number to get partrom
2889 a -- attachment struct for the desired part
2891 Result: a screen containing information about attachment:
2894 display_attach_info(long int msgno
, ATTACH_S
*a
)
2896 int i
, indent
, cols
;
2897 char buf1
[100], *folded
;
2902 (void) dispatch_attachment(a
);
2904 if(!(store
= so_get(CharStar
, NULL
, EDIT_ACCESS
))){
2905 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
2906 _("Error allocating space for message."));
2910 cols
= ps_global
->ttyo
->screen_cols
;
2914 * 16 for text (longest is Display Method == 14)
2919 /* don't try stupid folding */
2920 cols
= MAX(indent
+10, cols
);
2922 so_puts(store
, "Details about Attachment #");
2923 so_puts(store
, a
->number
);
2924 so_puts(store
, " :\n\n");
2925 utf8_snprintf(buf1
, sizeof(buf1
), " %-*.*w: ", indent
-4, indent
-4, "Type");
2926 so_puts(store
, buf1
);
2927 so_puts(store
, body_type_names(a
->body
->type
));
2928 so_puts(store
, "\n");
2929 utf8_snprintf(buf1
, sizeof(buf1
), " %-*.*w: ", indent
-4, indent
-4, "Subtype");
2930 so_puts(store
, buf1
);
2931 so_puts(store
, a
->body
->subtype
? a
->body
->subtype
: "Unknown");
2932 so_puts(store
, "\n");
2933 utf8_snprintf(buf1
, sizeof(buf1
), " %-*.*w: ", indent
-4, indent
-4, "Encoding");
2934 so_puts(store
, buf1
);
2935 so_puts(store
, a
->body
->encoding
< ENCMAX
2936 ? body_encodings
[a
->body
->encoding
]
2938 so_puts(store
, "\n");
2939 if((plist
= rfc2231_newparmlist(a
->body
->parameter
)) != NULL
){
2940 utf8_snprintf(buf1
, sizeof(buf1
), " %-*.*w: ", indent
-4, indent
-4, "Parameters");
2941 so_puts(store
, buf1
);
2943 while(rfc2231_list_params(plist
)){
2945 so_puts(store
, repeat_char(indent
, ' '));
2947 so_puts(store
, plist
->attrib
);
2948 so_puts(store
, " = ");
2949 so_puts(store
, plist
->value
? plist
->value
: "");
2950 so_puts(store
, "\n");
2953 rfc2231_free_parmlist(&plist
);
2956 if(a
->body
->description
&& a
->body
->description
[0]){
2957 char buftmp
[MAILTMPLEN
];
2960 utf8_snprintf(buf1
, sizeof(buf1
), " %-*.*w: ", indent
-4, indent
-4, "Description");
2962 snprintf(buftmp
, sizeof(buftmp
), "%s", a
->body
->description
);
2963 buftmp
[sizeof(buftmp
)-1] = '\0';
2964 q
= rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf
, SIZEOF_20KBUF
, buftmp
);
2965 folded
= fold((char *) q
, cols
, cols
, buf1
, repeat_char(indent
+1, ' '), FLD_NONE
);
2968 so_puts(store
, folded
);
2969 fs_give((void **) &folded
);
2973 /* BUG: no a->body->language support */
2975 if(a
->body
->disposition
.type
){
2976 utf8_snprintf(buf1
, sizeof(buf1
), " %-*.*w: ", indent
-4, indent
-4, "Disposition");
2977 so_puts(store
, buf1
);
2978 so_puts(store
, a
->body
->disposition
.type
);
2979 so_puts(store
, "\n");
2980 if((plist
= rfc2231_newparmlist(a
->body
->disposition
.parameter
)) != NULL
){
2981 while(rfc2231_list_params(plist
)){
2982 so_puts(store
, repeat_char(indent
, ' '));
2983 so_puts(store
, plist
->attrib
);
2984 so_puts(store
, " = ");
2985 so_puts(store
, plist
->value
? plist
->value
: "");
2986 so_puts(store
, "\n");
2989 rfc2231_free_parmlist(&plist
);
2993 utf8_snprintf(buf1
, sizeof(buf1
), " %-*.*w: ", indent
-4, indent
-4, "Approx. Size");
2994 so_puts(store
, buf1
);
2995 so_puts(store
, comatose((a
->body
->encoding
== ENCBASE64
)
2996 ? ((a
->body
->size
.bytes
* 3)/4)
2997 : a
->body
->size
.bytes
));
2998 so_puts(store
, " bytes\n");
2999 utf8_snprintf(buf1
, sizeof(buf1
), " %-*.*w: ", indent
-4, indent
-4, "Display Method");
3000 so_puts(store
, buf1
);
3001 if(a
->can_display
== MCD_NONE
) {
3002 so_puts(store
, "Can't, ");
3003 so_puts(store
, (a
->body
->encoding
< ENCOTHER
)
3004 ? "Unknown Attachment Format"
3005 : "Unknown Encoding");
3007 else if(!(a
->can_display
& MCD_EXTERNAL
)){
3008 so_puts(store
, "Alpine's Internal Pager");
3011 int nt
, free_pretty_cmd
;
3015 if((mc_cmd
= mailcap_build_command(a
->body
->type
, a
->body
->subtype
,
3016 a
->body
, "<datafile>", &nt
,
3017 a
->can_display
& MCD_EXT_PROMPT
)) != NULL
){
3018 so_puts(store
, "\"");
3019 if((pretty_cmd
= execview_pretty_command(mc_cmd
, &free_pretty_cmd
)) != NULL
)
3020 so_puts(store
, pretty_cmd
);
3021 so_puts(store
, "\"");
3022 if(free_pretty_cmd
&& pretty_cmd
)
3023 fs_give((void **)&pretty_cmd
);
3025 fs_give((void **)&mc_cmd
->command
);
3026 fs_give((void **)&mc_cmd
);
3030 so_puts(store
, "\n");
3032 memset(&sargs
, 0, sizeof(SCROLL_S
));
3033 sargs
.text
.text
= so_text(store
);
3034 sargs
.text
.src
= CharStar
;
3035 sargs
.text
.desc
= "attachment info";
3036 sargs
.bar
.title
= _("ABOUT ATTACHMENT");
3037 sargs
.help
.text
= h_simple_text_view
;
3038 sargs
.help
.title
= _("HELP FOR \"ABOUT ATTACHMENT\"");
3040 sargs
.use_indexline_color
= 1;
3044 so_give(&store
); /* free resources associated with store */
3045 ps_global
->mangled_screen
= 1;
3049 /*----------------------------------------------------------------------
3053 forward_attachment(MAILSTREAM
*stream
, long int msgno
, ATTACH_S
*a
)
3061 forward_msg_att(stream
, msgno
, a
);
3064 ACTION_S
*role
= NULL
;
3065 REDRAFT_POS_S
*redraft_pos
= NULL
;
3066 long rflags
= ROLE_FORWARD
;
3069 outgoing
= mail_newenvelope();
3070 outgoing
->message_id
= generate_message_id();
3071 outgoing
->subject
= cpystr("Forwarded attachment...");
3073 if(nonempty_patterns(rflags
, &dummy
)){
3075 * There is no message, but a Current Folder Type might match.
3077 * This has been changed to check against the message
3078 * containing the attachment.
3080 role
= set_role_from_msg(ps_global
, ROLE_FORWARD
, msgno
, NULL
);
3081 if(confirm_role(rflags
, &role
))
3082 role
= combine_inherited_role(role
);
3085 cmd_cancelled("Forward");
3086 mail_free_envelope(&outgoing
);
3092 q_status_message1(SM_ORDER
, 3, 4,
3093 _("Forwarding using role \"%s\""), role
->nick
);
3096 * as with all text bound for the composer, build it in
3097 * a storage object of the type it understands...
3099 if((msgtext
= (void *) so_get(PicoText
, NULL
, EDIT_ACCESS
)) != NULL
){
3100 int impl
, template_len
= 0;
3102 if(role
&& role
->template){
3106 filtered
= detoken(role
, NULL
, 0, 0, 0, &redraft_pos
, &impl
);
3109 so_puts((STORE_S
*)msgtext
, filtered
);
3111 template_len
= strlen(filtered
);
3114 fs_give((void **)&filtered
);
3120 if((sig
= detoken(role
, NULL
, 2, 0, 1, &redraft_pos
, &impl
)) != NULL
){
3122 redraft_pos
->offset
+= template_len
;
3124 so_puts((STORE_S
*)msgtext
, *sig
? sig
: NEWLINE
);
3126 fs_give((void **)&sig
);
3129 so_puts((STORE_S
*)msgtext
, NEWLINE
);
3131 /*---- New Body to start with ----*/
3132 body
= mail_newbody();
3133 body
->type
= TYPEMULTIPART
;
3135 /*---- The TEXT part/body ----*/
3136 body
->nested
.part
= mail_newbody_part();
3137 body
->nested
.part
->body
.type
= TYPETEXT
;
3138 body
->nested
.part
->body
.contents
.text
.data
= msgtext
;
3140 /*---- The corresponding things we're attaching ----*/
3141 body
->nested
.part
->next
= mail_newbody_part();
3142 body
->nested
.part
->next
->body
.id
= generate_message_id();
3143 copy_body(&body
->nested
.part
->next
->body
, a
->body
);
3145 if(fetch_contents(stream
, msgno
, a
->number
,
3146 &body
->nested
.part
->next
->body
)){
3147 pine_send(outgoing
, &body
, "FORWARD MESSAGE",
3148 role
, NULL
, NULL
, redraft_pos
, NULL
, NULL
, 0);
3150 ps_global
->mangled_screen
= 1;
3151 pine_free_body(&body
);
3152 free_redraft_pos(&redraft_pos
);
3155 mail_free_body(&body
);
3156 so_give((STORE_S
**) &msgtext
);
3157 free_redraft_pos(&redraft_pos
);
3158 q_status_message(SM_ORDER
| SM_DING
, 4, 5,
3159 _("Error fetching message contents. Can't forward message."));
3163 q_status_message(SM_ORDER
| SM_DING
, 3, 4,
3164 _("Error allocating message text"));
3166 mail_free_envelope(&outgoing
);
3173 forward_msg_att(MAILSTREAM
*stream
, long int msgno
, ATTACH_S
*a
)
3175 char *p
, *sig
= NULL
;
3180 ACTION_S
*role
= NULL
;
3182 REDRAFT_POS_S
*redraft_pos
= NULL
;
3184 outgoing
= mail_newenvelope();
3185 outgoing
->message_id
= generate_message_id();
3187 memset((void *)&reply
, 0, sizeof(reply
));
3189 if((outgoing
->subject
= forward_subject(a
->body
->nested
.msg
->env
, 0)) != NULL
){
3191 * as with all text bound for the composer, build it in
3192 * a storage object of the type it understands...
3194 if((msgtext
= (void *) so_get(PicoText
, NULL
, EDIT_ACCESS
)) != NULL
){
3195 int impl
, template_len
= 0;
3196 long rflags
= ROLE_FORWARD
;
3200 if(ps_global
->full_header
== 2)
3201 ret
= want_to(_("Forward message as an attachment"), 'n', 0,
3202 NO_HELP
, WT_SEQ_SENSITIVE
);
3203 /* Setup possible role */
3204 if(nonempty_patterns(rflags
, &dummy
)){
3205 role
= set_role_from_msg(ps_global
, rflags
, msgno
, a
->number
);
3206 if(confirm_role(rflags
, &role
))
3207 role
= combine_inherited_role(role
);
3208 else{ /* cancel reply */
3210 cmd_cancelled("Forward");
3211 mail_free_envelope(&outgoing
);
3212 so_give((STORE_S
**) &msgtext
);
3218 q_status_message1(SM_ORDER
, 3, 4,
3219 _("Forwarding using role \"%s\""), role
->nick
);
3221 if(role
&& role
->template){
3225 filtered
= detoken(role
, a
->body
->nested
.msg
->env
,
3226 0, 0, 0, &redraft_pos
, &impl
);
3229 so_puts((STORE_S
*)msgtext
, filtered
);
3231 template_len
= strlen(filtered
);
3234 fs_give((void **)&filtered
);
3240 if((sig
= detoken(role
, a
->body
->nested
.msg
->env
,
3241 2, 0, 1, &redraft_pos
, &impl
)) != NULL
){
3243 redraft_pos
->offset
+= template_len
;
3245 so_puts((STORE_S
*)msgtext
, *sig
? sig
: NEWLINE
);
3247 fs_give((void **)&sig
);
3250 so_puts((STORE_S
*)msgtext
, NEWLINE
);
3253 /*---- New Body to start with ----*/
3254 body
= mail_newbody();
3255 body
->type
= TYPEMULTIPART
;
3257 /*---- The TEXT part/body ----*/
3258 body
->nested
.part
= mail_newbody_part();
3259 body
->nested
.part
->body
.type
= TYPETEXT
;
3260 body
->nested
.part
->body
.contents
.text
.data
= msgtext
;
3262 if(!forward_mime_msg(stream
, msgno
,
3263 p
= body_partno(stream
, msgno
, a
->body
),
3264 a
->body
->nested
.msg
->env
,
3265 &body
->nested
.part
->next
, msgtext
))
3266 mail_free_body(&body
);
3270 if(a
->body
->nested
.msg
->body
){
3274 = parameter_val(a
->body
->nested
.msg
->body
->parameter
,
3277 if(charset
&& strucmp(charset
, "us-ascii") != 0){
3281 * There is a non-ascii charset,
3282 * is there conversion happening?
3284 if(!(ct
=conversion_table(charset
, ps_global
->posting_charmap
))
3286 reply
.orig_charset
= charset
;
3292 fs_give((void **) &charset
);
3295 body
= forward_body(stream
, a
->body
->nested
.msg
->env
,
3296 a
->body
->nested
.msg
->body
, msgno
,
3297 p
= body_partno(stream
, msgno
, a
->body
),
3301 fs_give((void **) &p
);
3304 pine_send(outgoing
, &body
,
3307 reply
.forw
? &reply
: NULL
,
3308 redraft_pos
, NULL
, NULL
, 0);
3310 ps_global
->mangled_screen
= 1;
3311 pine_free_body(&body
);
3312 free_redraft_pos(&redraft_pos
);
3316 so_give((STORE_S
**) &msgtext
);
3317 q_status_message(SM_ORDER
| SM_DING
, 4, 5,
3318 _("Error fetching message contents. Can't forward message."));
3322 q_status_message(SM_ORDER
| SM_DING
, 3, 4,
3323 _("Error allocating message text"));
3326 q_status_message1(SM_ORDER
,3,4,
3327 _("Error fetching message %s. Can't forward it."),
3328 long2string(msgno
));
3330 if(reply
.orig_charset
)
3331 fs_give((void **)&reply
.orig_charset
);
3333 mail_free_envelope(&outgoing
);
3338 reply_msg_att(MAILSTREAM
*stream
, long int msgno
, ATTACH_S
*a
)
3340 ADDRESS
*saved_from
, *saved_to
, *saved_cc
, *saved_resent
;
3344 char *tp
, *prefix
= NULL
, *fcc
= NULL
, *errmsg
= NULL
;
3345 int include_text
= 0, flags
= RSF_QUERY_REPLY_ALL
;
3346 int rolemsg
= 0, copytomsg
= 0;
3349 REDRAFT_POS_S
*redraft_pos
= NULL
;
3350 ACTION_S
*role
= NULL
;
3352 outgoing
= mail_newenvelope();
3354 dprint((4,"\n - attachment reply \n"));
3356 saved_from
= (ADDRESS
*) NULL
;
3357 saved_to
= (ADDRESS
*) NULL
;
3358 saved_cc
= (ADDRESS
*) NULL
;
3359 saved_resent
= (ADDRESS
*) NULL
;
3360 outgoing
->subject
= NULL
;
3362 prefix
= reply_quote_str(a
->body
->nested
.msg
->env
);
3364 * For consistency, the first question is always "include text?"
3366 if((include_text
= reply_text_query(ps_global
, 1, &prefix
)) >= 0
3367 && reply_news_test(a
->body
->nested
.msg
->env
, outgoing
) > 0
3368 && reply_harvest(ps_global
, msgno
, a
->number
,
3369 a
->body
->nested
.msg
->env
, &saved_from
,
3370 &saved_to
, &saved_cc
, &saved_resent
, &flags
)){
3371 outgoing
->subject
= reply_subject(a
->body
->nested
.msg
->env
->subject
,
3374 reply_seed(ps_global
, outgoing
, a
->body
->nested
.msg
->env
,
3375 saved_from
, saved_to
, saved_cc
, saved_resent
,
3376 &fcc
, flags
& RSF_FORCE_REPLY_ALL
, &errmsg
);
3379 q_status_message1(SM_ORDER
, 3, 3, "%.200s", errmsg
);
3380 display_message(NO_OP_COMMAND
);
3383 fs_give((void **)&errmsg
);
3386 if(sp_expunge_count(stream
)) /* current msg was expunged */
3389 /* Setup possible role */
3390 rflags
= ROLE_REPLY
;
3391 if(nonempty_patterns(rflags
, &dummy
)){
3392 role
= set_role_from_msg(ps_global
, rflags
, msgno
, a
->number
);
3393 if(confirm_role(rflags
, &role
))
3394 role
= combine_inherited_role(role
);
3395 else{ /* cancel reply */
3397 cmd_cancelled("Reply");
3405 /* override fcc gotten in reply_seed */
3406 if(role
->fcc
&& fcc
)
3407 fs_give((void **) &fcc
);
3410 if(F_ON(F_COPY_TO_TO_FROM
, ps_global
) && !(role
&& role
->from
)){
3411 ADDRESS
*us_in_to_and_cc
, *ap
;
3413 us_in_to_and_cc
= (ADDRESS
*) NULL
;
3414 if(a
->body
->nested
.msg
->env
&& a
->body
->nested
.msg
->env
->to
)
3415 if((ap
=reply_cp_addr(ps_global
, 0L, NULL
,
3416 NULL
, us_in_to_and_cc
, NULL
,
3417 a
->body
->nested
.msg
->env
->to
, RCA_ONLY_US
)) != NULL
)
3418 reply_append_addr(&us_in_to_and_cc
, ap
);
3420 if(a
->body
->nested
.msg
->env
&& a
->body
->nested
.msg
->env
->cc
)
3421 if((ap
=reply_cp_addr(ps_global
, 0L, NULL
,
3422 NULL
, us_in_to_and_cc
, NULL
,
3423 a
->body
->nested
.msg
->env
->cc
, RCA_ONLY_US
)) != NULL
)
3424 reply_append_addr(&us_in_to_and_cc
, ap
);
3427 * A list of all of our addresses that appear in the To
3428 * and cc fields is in us_in_to_and_cc.
3429 * If there is exactly one address in that list then
3430 * use it for the outgoing From.
3432 if(us_in_to_and_cc
&& !us_in_to_and_cc
->next
){
3433 PINEFIELD
*custom
, *pf
;
3438 * Check to see if this address is different from what
3439 * we would have used anyway. If it is, notify the user
3440 * with a status message. This is pretty hokey because we're
3441 * mimicking how pine_send would set the From address and
3442 * there is no coordination between the two.
3445 /* in case user has a custom From value */
3446 custom
= parse_custom_hdrs(ps_global
->VAR_CUSTOM_HDRS
, UseAsDef
);
3448 pf
= (PINEFIELD
*) fs_get(sizeof(*pf
));
3449 memset((void *) pf
, 0, sizeof(*pf
));
3450 pf
->name
= cpystr("From");
3452 if(set_default_hdrval(pf
, custom
) >= UseAsDef
3453 && pf
->textbuf
&& pf
->textbuf
[0]){
3454 removing_trailing_white_space(pf
->textbuf
);
3455 (void)removing_double_quotes(pf
->textbuf
);
3456 build_address(pf
->textbuf
, &addr
, NULL
, NULL
, NULL
);
3457 rfc822_parse_adrlist(pf
->addr
, addr
, ps_global
->maildomain
);
3459 fs_give((void **) &addr
);
3463 *pf
->addr
= generate_from();
3465 if(*pf
->addr
&& !address_is_same(*pf
->addr
, us_in_to_and_cc
)){
3468 role
= (ACTION_S
*) fs_get(sizeof(*role
));
3469 memset((void *) role
, 0, sizeof(*role
));
3470 role
->is_a_role
= 1;
3473 role
->from
= us_in_to_and_cc
;
3474 us_in_to_and_cc
= NULL
;
3477 free_customs(custom
);
3482 mail_free_address(&us_in_to_and_cc
);
3487 if(rolemsg
&& copytomsg
)
3488 q_status_message1(SM_ORDER
, 3, 4,
3489 _("Replying using role \"%s\" and To as From"), role
->nick
);
3491 q_status_message1(SM_ORDER
, 3, 4,
3492 _("Replying using role \"%s\""), role
->nick
);
3494 q_status_message(SM_ORDER
, 3, 4,
3495 _("Replying using incoming To as outgoing From"));
3498 outgoing
->in_reply_to
= reply_in_reply_to(a
->body
->nested
.msg
->env
);
3499 outgoing
->references
= reply_build_refs(a
->body
->nested
.msg
->env
);
3500 outgoing
->message_id
= generate_message_id();
3502 if(!outgoing
->to
&& !outgoing
->cc
3503 && !outgoing
->bcc
&& !outgoing
->newsgroups
)
3504 q_status_message(SM_ORDER
| SM_DING
, 3, 6,
3505 _("Warning: no valid addresses to reply to!"));
3508 * Now fix up the body...
3510 if((msgtext
= (void *) so_get(PicoText
, NULL
, EDIT_ACCESS
)) != NULL
){
3513 memset((void *)&reply
, 0, sizeof(reply
));
3515 if(a
->body
->nested
.msg
->body
){
3519 = parameter_val(a
->body
->nested
.msg
->body
->parameter
,
3522 if(charset
&& strucmp(charset
, "us-ascii") != 0){
3526 * There is a non-ascii charset,
3527 * is there conversion happening?
3529 if(!(ct
=conversion_table(charset
, ps_global
->posting_charmap
))
3531 reply
.orig_charset
= charset
;
3537 fs_give((void **) &charset
);
3540 if((body
= reply_body(stream
, a
->body
->nested
.msg
->env
,
3541 a
->body
->nested
.msg
->body
, msgno
,
3542 tp
= body_partno(stream
, msgno
, a
->body
),
3543 msgtext
, prefix
, include_text
, role
,
3544 1, &redraft_pos
)) != NULL
){
3545 /* partially formatted outgoing message */
3546 pine_send(outgoing
, &body
, "COMPOSE MESSAGE REPLY",
3547 role
, fcc
, &reply
, redraft_pos
, NULL
, NULL
, 0);
3549 pine_free_body(&body
);
3550 ps_global
->mangled_screen
= 1;
3553 q_status_message(SM_ORDER
| SM_DING
, 3, 4,
3554 _("Error building message body"));
3556 fs_give((void **) &tp
);
3557 if(reply
.orig_charset
)
3558 fs_give((void **)&reply
.orig_charset
);
3561 q_status_message(SM_ORDER
| SM_DING
, 3, 4,
3562 _("Error allocating message text"));
3566 mail_free_envelope(&outgoing
);
3567 mail_free_address(&saved_from
);
3568 mail_free_address(&saved_to
);
3569 mail_free_address(&saved_cc
);
3570 mail_free_address(&saved_resent
);
3573 fs_give((void **) &prefix
);
3576 fs_give((void **) &fcc
);
3578 free_redraft_pos(&redraft_pos
);
3584 bounce_msg_att(MAILSTREAM
*stream
, long int msgno
, char *part
, char *subject
)
3588 if((errstr
= bounce_msg(stream
, msgno
, part
, NULL
, NULL
, subject
, NULL
, NULL
)) != NULL
)
3589 q_status_message(SM_ORDER
| SM_DING
, 3, 3, errstr
);
3594 pipe_attachment(long int msgno
, ATTACH_S
*a
)
3596 char *err
, *resultfilename
= NULL
, prompt
[80], *p
;
3597 int rc
, capture
= 1, raw
= 0, we_cancel
= 0, j
= 0;
3601 char pipe_command
[MAXPATH
+1];
3602 unsigned flagsforhist
= 1; /* raw=2 /capture=1 */
3603 static HISTORY_S
*history
= NULL
;
3604 ESCKEY_S pipe_opt
[6];
3606 if(ps_global
->restricted
){
3607 q_status_message(SM_ORDER
| SM_DING
, 0, 4,
3608 "Alpine demo can't pipe attachments");
3613 pipe_command
[0] = '\0';
3615 init_hist(&history
, HISTSIZE
);
3616 flagsforhist
= (raw
? 0x2 : 0) + (capture
? 0x1 : 0);
3617 if((p
= get_prev_hist(history
, "", flagsforhist
, NULL
)) != NULL
){
3618 strncpy(pipe_command
, p
, sizeof(pipe_command
));
3619 pipe_command
[sizeof(pipe_command
)-1] = '\0';
3620 if(history
->hist
[history
->curindex
]){
3621 flagsforhist
= history
->hist
[history
->curindex
]->flags
;
3622 raw
= (flagsforhist
& 0x2) ? 1 : 0;
3623 capture
= (flagsforhist
& 0x1) ? 1 : 0;
3628 pipe_opt
[j
].rval
= 0;
3629 pipe_opt
[j
].name
= "";
3630 pipe_opt
[j
++].label
= "";
3632 pipe_opt
[j
].ch
= ctrl('W');
3633 pipe_opt
[j
].rval
= 10;
3634 pipe_opt
[j
].name
= "^W";
3635 pipe_opt
[j
++].label
= NULL
;
3637 pipe_opt
[j
].ch
= ctrl('Y');
3638 pipe_opt
[j
].rval
= 11;
3639 pipe_opt
[j
].name
= "^Y";
3640 pipe_opt
[j
++].label
= NULL
;
3642 pipe_opt
[j
].ch
= KEY_UP
;
3643 pipe_opt
[j
].rval
= 30;
3644 pipe_opt
[j
].name
= "";
3646 pipe_opt
[j
++].label
= "";
3648 pipe_opt
[j
].ch
= KEY_DOWN
;
3649 pipe_opt
[j
].rval
= 31;
3650 pipe_opt
[j
].name
= "";
3651 pipe_opt
[j
++].label
= "";
3653 pipe_opt
[j
].ch
= -1;
3658 snprintf(prompt
, sizeof(prompt
), "Pipe %sattachment %s to %s: ", raw
? "RAW " : "",
3659 a
->number
, capture
? "" : "(Free Output) ");
3660 prompt
[sizeof(prompt
)-1] = '\0';
3661 pipe_opt
[1].label
= raw
? "DecodedData" : "Raw Data";
3662 pipe_opt
[2].label
= capture
? "Free Output" : "Capture Output";
3665 * 2 is really 1 because there will be one real entry and
3666 * one entry of "" because of the get_prev_hist above.
3668 if(items_in_hist(history
) > 2){
3669 pipe_opt
[ku
].name
= HISTORY_UP_KEYNAME
;
3670 pipe_opt
[ku
].label
= HISTORY_KEYLABEL
;
3671 pipe_opt
[ku
+1].name
= HISTORY_DOWN_KEYNAME
;
3672 pipe_opt
[ku
+1].label
= HISTORY_KEYLABEL
;
3675 pipe_opt
[ku
].name
= "";
3676 pipe_opt
[ku
].label
= "";
3677 pipe_opt
[ku
+1].name
= "";
3678 pipe_opt
[ku
+1].label
= "";
3681 flags
= OE_APPEND_CURRENT
| OE_SEQ_SENSITIVE
;
3682 rc
= optionally_enter(pipe_command
, -FOOTER_ROWS(ps_global
), 0,
3683 sizeof(pipe_command
), prompt
,
3684 pipe_opt
, help
, &flags
);
3686 q_status_message(SM_ORDER
| SM_DING
, 3, 4,
3687 "Internal problem encountered");
3691 raw
= !raw
; /* flip raw text */
3694 capture
= !capture
; /* flip capture output */
3697 flagsforhist
= (raw
? 0x2 : 0) + (capture
? 0x1 : 0);
3698 if((p
= get_prev_hist(history
, pipe_command
, flagsforhist
, NULL
)) != NULL
){
3699 strncpy(pipe_command
, p
, sizeof(pipe_command
));
3700 pipe_command
[sizeof(pipe_command
)-1] = '\0';
3701 if(history
->hist
[history
->curindex
]){
3702 flagsforhist
= history
->hist
[history
->curindex
]->flags
;
3703 raw
= (flagsforhist
& 0x2) ? 1 : 0;
3704 capture
= (flagsforhist
& 0x1) ? 1 : 0;
3711 flagsforhist
= (raw
? 0x2 : 0) + (capture
? 0x1 : 0);
3712 if((p
= get_next_hist(history
, pipe_command
, flagsforhist
, NULL
)) != NULL
){
3713 strncpy(pipe_command
, p
, sizeof(pipe_command
));
3714 pipe_command
[sizeof(pipe_command
)-1] = '\0';
3715 if(history
->hist
[history
->curindex
]){
3716 flagsforhist
= history
->hist
[history
->curindex
]->flags
;
3717 raw
= (flagsforhist
& 0x2) ? 1 : 0;
3718 capture
= (flagsforhist
& 0x1) ? 1 : 0;
3725 if(pipe_command
[0] == '\0'){
3726 cmd_cancelled("Pipe command");
3730 flagsforhist
= (raw
? 0x2 : 0) + (capture
? 0x1 : 0);
3731 save_hist(history
, pipe_command
, flagsforhist
, NULL
);
3733 flags
= PIPE_USER
| PIPE_WRITE
| PIPE_STDERR
;
3734 flags
|= (raw
? PIPE_RAW
: 0);
3740 ps_global
->mangled_screen
= 1;
3742 flags
|= PIPE_RESET
;
3745 if((syspipe
= open_system_pipe(pipe_command
,
3746 (flags
&PIPE_RESET
) ? NULL
: &resultfilename
,
3747 NULL
, flags
, 0, pipe_callback
, pipe_report_error
)) != NULL
){
3749 gf_io_t pc
; /* wire up a generic putchar */
3751 is_text
= (a
&& a
->body
&& a
->body
->type
== TYPETEXT
);
3753 gf_set_writec(&pc
, syspipe
, 0L, PipeStar
,
3754 (is_text
&& !raw
) ? WRITE_TO_LOCALE
: 0);
3756 /*------ Write the image to a temporary file ------*/
3757 if(raw
){ /* pipe raw text */
3758 FETCH_READC_S fetch_part
;
3763 we_cancel
= busy_cue(NULL
, NULL
, 1);
3768 fetch_readc_init(&fetch_part
, ps_global
->mail_stream
,
3769 msgno
, a
->number
, a
->body
->size
.bytes
, 0, 0);
3770 gf_link_filter(gf_nvtnl_local
, NULL
);
3771 err
= gf_pipe(FETCH_READC
, pc
);
3781 /* BUG: there's got to be a better way */
3783 ps_global
->print
= (PRINT_S
*) 1;
3786 err
= detach(ps_global
->mail_stream
, msgno
,
3787 a
->number
, 0L, (long *)NULL
, pc
, NULL
, 0);
3788 ps_global
->print
= (PRINT_S
*) NULL
;
3792 (void) close_system_pipe(&syspipe
, NULL
, pipe_callback
);
3795 q_status_message1(SM_ORDER
| SM_DING
, 3, 4,
3796 _("Error detaching for pipe: %s"), err
);
3798 display_output_file(resultfilename
,
3800 ? _("PIPE ATTACHMENT (ERROR)")
3801 : _("PIPE ATTACHMENT"),
3804 fs_give((void **) &resultfilename
);
3807 q_status_message(SM_ORDER
| SM_DING
, 3, 4,
3808 _("Error opening pipe"));
3813 cmd_cancelled("Pipe");
3817 help
= (help
== NO_HELP
) ? h_pipe_attach
: NO_HELP
;
3823 delete_attachment(long int msgno
, ATTACH_S
*a
)
3825 int expbits
, rv
= 0;
3827 if(!msgno_exceptions(ps_global
->mail_stream
, msgno
,
3828 a
->number
, &expbits
, FALSE
)
3829 || !(expbits
& MSG_EX_DELETE
)){
3830 expbits
|= MSG_EX_DELETE
;
3831 msgno_exceptions(ps_global
->mail_stream
, msgno
,
3832 a
->number
, &expbits
, TRUE
);
3834 q_status_message1(SM_ORDER
, 0, 3,
3835 _("Part %s will be omitted only if message is Saved"),
3840 q_status_message1(SM_ORDER
, 0, 3, _("Part %s already deleted"),
3848 undelete_attachment(long int msgno
, ATTACH_S
*a
, int *expbitsp
)
3852 if(msgno_exceptions(ps_global
->mail_stream
, msgno
,
3853 a
->number
, expbitsp
, FALSE
)
3854 && ((*expbitsp
) & MSG_EX_DELETE
)){
3855 (*expbitsp
) ^= MSG_EX_DELETE
;
3856 msgno_exceptions(ps_global
->mail_stream
, msgno
,
3857 a
->number
, expbitsp
, TRUE
);
3861 q_status_message1(SM_ORDER
, 0, 3, _("Part %s already UNdeleted"),
3868 /*----------------------------------------------------------------------
3869 Resolve any deferred tests for attachment displayability
3871 Args: attachment structure
3873 Returns: undefer's attachment's displayability test
3876 dispatch_attachment(ATTACH_S
*a
)
3878 if(a
->test_deferred
){
3879 a
->test_deferred
= 0;
3880 a
->can_display
= mime_can_display(a
->body
->type
, a
->body
->subtype
, a
->body
);
3883 return(a
->can_display
);
3889 scroll_att_popup(sparms
, in_handle
)
3893 MPopup scrat_popup
[20];
3897 scrat_popup
[++i
].type
= tIndex
;
3898 scrat_popup
[i
].label
.style
= lNormal
;
3899 scrat_popup
[i
].label
.string
= "View Selectable Item";
3900 scrat_popup
[i
].data
.val
= ctrl('L');
3903 scrat_popup
[++i
].type
= tQueue
;
3904 scrat_popup
[i
].label
.style
= lNormal
;
3905 scrat_popup
[i
].label
.string
= "&Save";
3906 scrat_popup
[i
].data
.val
= 'S';
3908 scrat_popup
[++i
].type
= tQueue
;
3909 scrat_popup
[i
].label
.style
= lNormal
;
3910 if(msgno_exceptions(ps_global
->mail_stream
,
3911 mn_m2raw(ps_global
->msgmap
,
3912 mn_get_cur(ps_global
->msgmap
)),
3913 scrat_attachp
->number
, &n
, FALSE
)
3914 && (n
& MSG_EX_DELETE
)){
3915 scrat_popup
[i
].label
.string
= "&Undelete";
3916 scrat_popup
[i
].data
.val
= 'U';
3919 scrat_popup
[i
].label
.string
= "&Delete";
3920 scrat_popup
[i
].data
.val
= 'D';
3923 if(MIME_MSG_A(scrat_attachp
) || MIME_DGST_A(scrat_attachp
)){
3924 scrat_popup
[++i
].type
= tQueue
;
3925 scrat_popup
[i
].label
.style
= lNormal
;
3926 scrat_popup
[i
].label
.string
= "&Reply";
3927 scrat_popup
[i
].data
.val
= 'R';
3929 scrat_popup
[++i
].type
= tQueue
;
3930 scrat_popup
[i
].label
.style
= lNormal
;
3931 scrat_popup
[i
].label
.string
= "&Forward";
3932 scrat_popup
[i
].data
.val
= 'f';
3935 scrat_popup
[++i
].type
= tSeparator
;
3937 scrat_popup
[++i
].type
= tQueue
;
3938 scrat_popup
[i
].label
.style
= lNormal
;
3939 scrat_popup
[i
].label
.string
= "Attachment Index";
3940 scrat_popup
[i
].data
.val
= '<';
3942 scrat_popup
[++i
].type
= tTail
;
3944 return(mswin_popup(scrat_popup
) == 0 && in_handle
);
3949 display_att_window(a
)
3952 #if !defined(DOS) && !defined(OS2)
3956 if(a
->body
->type
== TYPEMULTIPART
){
3957 if(a
->body
->subtype
){
3958 /* if(!strucmp(a->body->subtype, "digest"))
3959 display_digest_att(msgno, a, flags);
3961 q_status_message1(SM_ORDER
, 3, 5,
3962 "Can't display Multipart/%s",
3966 q_status_message(SM_ORDER
, 3, 5,
3967 "Can't display unknown Multipart Subtype");
3969 /* else if(MIME_VCARD_A(a))
3970 display_vcard_att_window(msgno, a, flags);*/
3971 else if(a
->body
->type
== TYPETEXT
)
3972 display_text_att_window(a
);
3973 else if(a
->body
->type
== TYPEMESSAGE
)
3974 display_msg_att_window(a
);
3979 display_text_att_window(a
)
3985 msgno
= mn_m2raw(ps_global
->msgmap
, mn_get_cur(ps_global
->msgmap
));
3987 if(store
= format_text_att(msgno
, a
, NULL
)){
3988 if (mswin_displaytext("ATTACHED TEXT",
3990 strlen((char *) so_text(store
)),
3991 NULL
, NULL
, 0) >= 0)
3992 store
->txt
= (void *) NULL
; /* free'd in mswin_displaytext */
3994 so_give(&store
); /* free resources associated with store */
3997 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
3998 "Error allocating space for attachment.");
4003 display_msg_att_window(a
)
4011 msgno
= mn_m2raw(ps_global
->msgmap
, mn_get_cur(ps_global
->msgmap
));
4013 /* BUG, should check this return code */
4014 (void) pine_mail_fetchstructure(ps_global
->mail_stream
, msgno
, NULL
);
4016 /* initialize a storage object */
4017 if(store
= so_get(CharStar
, NULL
, EDIT_ACCESS
)){
4019 gf_set_so_writec(&pc
, store
);
4021 if(format_msg_att(msgno
, &ap
, NULL
, pc
, FM_DISPLAY
)
4022 && mswin_displaytext("ATTACHED MESSAGE", so_text(store
),
4023 strlen((char *) so_text(store
)),
4024 NULL
, NULL
, 0) >= 0)
4025 /* free'd in mswin_displaytext */
4026 store
->txt
= (void *) NULL
;
4028 gf_clear_so_writec(store
);
4033 q_status_message(SM_ORDER
| SM_DING
, 3, 3,
4034 "Error allocating space for message.");