* When viewing images, append the image filename to the temp filename so
authorMichael Hampton <io_error@uncensored.citadel.org>
Sun, 21 Dec 2003 20:02:29 +0000 (20:02 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Sun, 21 Dec 2003 20:02:29 +0000 (20:02 +0000)
  that less-intelligent viewers can deal with the images

citadel/ChangeLog
citadel/messages.c

index 68d30c3a646836c9766a22f6333ef04f8dcf9180..a4394dc1e247bc58af1239e9a44da09692ec7386 100644 (file)
@@ -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 <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
+
index b61272e8b9f6a336603fc441062b6a4c19020d76..8c8e2bc7c080cf3004ec792e5d8df0ea6f58deed 100644 (file)
@@ -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