[svn] GpgOL - r298 - in trunk: . src

svn author wk cvs at cvs.gnupg.org
Thu Feb 26 17:55:47 CET 2009


Author: wk
Date: 2009-02-26 17:55:47 +0100 (Thu, 26 Feb 2009)
New Revision: 298

Modified:
   trunk/NEWS
   trunk/src/ChangeLog
   trunk/src/mimeparser.c
Log:
Chmage suffix of unnamed attachments.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-02-26 10:06:18 UTC (rev 297)
+++ trunk/src/ChangeLog	2009-02-26 16:55:47 UTC (rev 298)
@@ -1,5 +1,8 @@
 2009-02-26  Werner Koch  <wk at g10code.com>
 
+	* mimeparser.c (start_attachment): Try to figure out a good file
+	name suffix for the FILENAME property.
+
 	* ext-commands.cpp (InstallCommands): Disable decrypt button for
 	non GpgOl messages.
 

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2009-02-26 10:06:18 UTC (rev 297)
+++ trunk/NEWS	2009-02-26 16:55:47 UTC (rev 298)
@@ -3,7 +3,10 @@
 
  * Save the crypto settings in a message draft.
 
+ * Unnamed attachments are now shown with a suffix matching its MIME
+   type.
 
+
 Noteworthy changes for version 0.10.18 (2009-01-28)
 ===================================================
 

Modified: trunk/src/mimeparser.c
===================================================================
--- trunk/src/mimeparser.c	2009-02-26 10:06:18 UTC (rev 297)
+++ trunk/src/mimeparser.c	2009-02-26 16:55:47 UTC (rev 298)
@@ -1,5 +1,5 @@
 /* mimeparser.c - Parse multipart MIME message
- *	Copyright (C) 2005, 2007, 2008 g10 Code GmbH
+ *	Copyright (C) 2005, 2007, 2008, 2009 g10 Code GmbH
  *
  * This file is part of GpgOL.
  * 
@@ -361,7 +361,13 @@
 
   /* We need to insert a short filename .  Without it, the _displayed_
      list of attachments won't get updated although the attachment has
-     been created. */
+     been created.  If we know the content type we use an appropriate
+     suffix for the filename.  This is useful so that if no filename
+     is known for the attachment (to be stored in
+     PR_ATTACH_LONG_FILENAME), Outlooks gets an idea about the content
+     of the attachment from this made up filename.  This allows for
+     example to click on the attachment and open it with an
+     appropriate application.  */
   prop.ulPropTag = PR_ATTACH_FILENAME_A;
   {
     char buf[100];
@@ -370,7 +376,36 @@
       prop.Value.lpszA = is_body == 2? "gpgol000.htm":"gpgol000.txt";
     else
       {
-        snprintf (buf, 100, "gpgol%03d.dat", ctx->part_counter);
+        static struct {
+          const char *suffix;
+          const char *ct;
+        } suffix_table[] = {
+          { "doc", "application/msword" },
+          { "eml", "message/rfc822" },
+          { "htm", "text/html" },
+          { "jpg", "image/jpeg" },
+          { "pdf", "application/pdf" },
+          { "png", "image/png" },
+          { "pps", "application/vnd.ms-powerpoint" },
+          { "ppt", "application/vnd.ms-powerpoint" },
+          { "ps",  "application/postscript" },
+          { NULL, NULL }
+        };
+        const char *suffix = "dat";  /* Default.  */
+        int idx;
+        
+        if (ctx->mimestruct_cur && ctx->mimestruct_cur->content_type)
+          {
+            for (idx=0; suffix_table[idx].ct; idx++)
+              if (!strcmp (ctx->mimestruct_cur->content_type,
+                           suffix_table[idx].ct))
+                {
+                  suffix = suffix_table[idx].suffix;
+                  break;
+                }
+          }
+
+        snprintf (buf, 100, "gpgol%03d.%s", ctx->part_counter, suffix);
         prop.Value.lpszA = buf;
       }
     hr = HrSetOneProp ((LPMAPIPROP)newatt, &prop);




More information about the Gnupg-commits mailing list