# browser you have configured as the system default.
#urlcmd=open "%s"
+# If OPENCMD is defined, users can hit 'O' after reading a message which
+# contains attachments, to open the attachments using that command. This
+# allows attachments to be opened directly from the Citadel client without
+# having to first save them in a file. The "allow_attachments" option (see
+# above) must be enabled in order for this to work.
+#
+# xdg-open works on most newer Linux systems
+opencmd=xdg-open "%s"
+#
+# This probably will work on a Macintosh
+#opencmd=open "%s"
+
# If GOTMAILCMD is defined, the specified command will be executed. This
# might be nice for playing sounds or providing any other type of notification.
#
int rc_prompt_control = 0;
time_t rc_idle_threshold = (time_t)900;
char rc_url_cmd[SIZ];
+char rc_open_cmd[SIZ];
char rc_gotmail_cmd[SIZ];
char *gl_string;
rc_ansi_color = 0;
rc_color_use_bg = 0;
strcpy(rc_url_cmd, "");
+ strcpy(rc_open_cmd, "");
strcpy(rc_gotmail_cmd, "");
#ifdef HAVE_OPENSSL
rc_encrypt = RC_DEFAULT;
if (!strncasecmp(buf, "urlcmd=", 7))
strcpy(rc_url_cmd, &buf[7]);
+ if (!strncasecmp(buf, "opencmd=", 7))
+ strcpy(rc_open_cmd, &buf[8]);
+
if (!strncasecmp(buf, "gotmailcmd=", 11))
strcpy(rc_gotmail_cmd, &buf[11]);
int num_msgs;
char rc_alt_semantics;
extern char room_name[];
+extern char tempdir[];
extern unsigned room_flags;
extern unsigned room_flags2;
extern long highest_msg_read;
char filename[PATH_MAX];
char save_to[PATH_MAX];
void *attachment = NULL; /* Downloaded attachment */
- FILE *dest = NULL; /* Alternate destination other than screen */
+ FILE *dest = NULL; /* Alternate destination other than screen */
int r; /* IPC response code */
+ static int att_seq = 0; /* Attachment download sequence number */
if (c < 0)
b = (num_msgs - 1);
&& (e != 'q') && (e != 'b') && (e != 'h')
&& (e != 'r') && (e != 'f') && (e != '?')
&& (e != 'u') && (e != 'c') && (e != 'y')
- && (e != 'i'));
+ && (e != 'i') && (e != 'o') );
switch (e) {
case 's':
scr_printf("Stop");
case 'r':
scr_printf("Reply");
break;
+ case 'o':
+ scr_printf("Open attachments");
+ break;
case 'f':
scr_printf("File");
break;
" H Headers (display message headers only)\n");
if (is_mail)
scr_printf(" R Reply to this message\n");
- if (rc_allow_attachments)
- scr_printf
- (" F (save attachments to a file)\n");
+ if (rc_allow_attachments) {
+ scr_printf(" O (Open attachments)\n");
+ scr_printf(" F (save attachments to a File)\n");
+ }
if (!IsEmptyStr(rc_url_cmd))
scr_printf(" U (list URL's for display)\n");
if (!IsEmptyStr(imagecmd) && has_images > 0)
if (r / 100 != 2) /* r will be init'ed, FIXME */
goto RMSGREAD; /* the logic here sucks */
break;
+ case 'o':
case 'f':
- newprompt("Which section? ", filename,
- ((sizeof filename) - 1));
+ newprompt("Which section? ", filename, ((sizeof filename) - 1));
r = CtdlIPCAttachmentDownload(ipc, msg_arr[a],
filename, &attachment, progress, cmd);
if (r / 100 != 2) {
* Part 1 won't have a filename; use the
* subject of the message instead. IO
*/
- if (IsEmptyStr(filename))
+ if (IsEmptyStr(filename)) {
strcpy(filename, reply_subject);
- destination_directory(save_to, filename);
- save_buffer(attachment,
- extract_unsigned_long(cmd, 0),
- save_to);
+ }
+ if (e == 'o') { /* open attachment */
+ mkdir(tempdir, 0700);
+ snprintf(save_to, sizeof save_to, "%s/%04x.%s",
+ tempdir,
+ ++att_seq,
+ filename);
+ save_buffer(attachment, extract_unsigned_long(cmd, 0), save_to);
+ snprintf(cmd, sizeof cmd, rc_open_cmd, save_to);
+ system(cmd);
+ }
+ else { /* save attachment to disk */
+ destination_directory(save_to, filename);
+ save_buffer(attachment, extract_unsigned_long(cmd, 0), save_to);
+ }
}
if (attachment) {
free(attachment);