From 859fb90ccbf9fc31c7321f0b070e710762737088 Mon Sep 17 00:00:00 2001 From: Michael Hampton Date: Sun, 21 Dec 2003 20:02:29 +0000 Subject: [PATCH] * When viewing images, append the image filename to the temp filename so that less-intelligent viewers can deal with the images --- citadel/ChangeLog | 6 ++++++ citadel/messages.c | 27 ++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 68d30c3a6..a4394dc1e 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 613.7 2003/12/21 20:02:28 error + * When viewing images, append the image filename to the temp filename so + that less-intelligent viewers can deal with the images + Revision 613.6 2003/12/21 19:07:28 error * Start a new thread and fork() for image viewer (broken/disabled; for refernce only) @@ -5182,3 +5186,5 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + + diff --git a/citadel/messages.c b/citadel/messages.c index b61272e8b..8c8e2bc7c 100644 --- a/citadel/messages.c +++ b/citadel/messages.c @@ -1347,41 +1347,44 @@ void *image_view_thread(void *filename) */ void image_view(CtdlIPC *ipc, unsigned long msg) { - char selected_part[SIZ]; + struct parts *selected_part = NULL; struct parts *ptr = last_message_parts; + char part[SIZ]; int found = 0; - scr_printf("\n"); - /* List available parts */ + /* Run through available parts */ for (ptr = last_message_parts; ptr; ptr = ptr->next) { if ((!strcasecmp(ptr->disposition, "attachment") || !strcasecmp(ptr->disposition, "inline")) && !strncmp(ptr->mimetype, "image/", 6)) { + if (!found) { + found = 1; + selected_part = ptr; + strcpy(part, selected_part->number); + } +#if 0 color(DIM_WHITE); scr_printf("Part "); color(BRIGHT_MAGENTA); scr_printf("%s", ptr->number); - if (!found) { - found = 1; - strncpy(selected_part, ptr->number, SIZ-1); - } color(DIM_WHITE); scr_printf(": "); color(BRIGHT_CYAN); scr_printf("%s", ptr->filename); color(DIM_WHITE); scr_printf(" (%s, %ld bytes)\n", ptr->mimetype, ptr->length); +#endif } } while (found) { found = 0; - strprompt("View which part (0 when done)", selected_part, SIZ-1); + strprompt("View which part (0 when done)", part, SIZ-1); for (ptr = last_message_parts; ptr; ptr = ptr->next) { if ((!strcasecmp(ptr->disposition, "attachment") || !strcasecmp(ptr->disposition, "inline")) && !strncmp(ptr->mimetype, "image/", 6) - && !strcmp(ptr->number, selected_part)) { + && !strcmp(ptr->number, part)) { char tmp[PATH_MAX]; char buf[SIZ]; void *file = NULL; /* The downloaded file */ @@ -1392,7 +1395,7 @@ void image_view(CtdlIPC *ipc, unsigned long msg) // view image found = 1; - r = CtdlIPCAttachmentDownload(ipc, msg, selected_part, &file, progress, buf); + r = CtdlIPCAttachmentDownload(ipc, msg, selected_part->number, &file, progress, buf); if (r / 100 != 2) { scr_printf("%s\n", buf); } else { @@ -1401,7 +1404,9 @@ void image_view(CtdlIPC *ipc, unsigned long msg) len = (size_t)extract_long(buf, 0); progress(len, len); scr_flush(); - strcpy(tmp, tmpnam(NULL)); + snprintf(tmp, sizeof tmp, "%s.%s", + tmpnam(NULL), + selected_part->filename); save_buffer(file, len, tmp); free(file); #if 0 -- 2.39.2