From 168f6277dac48b8837f461aef91bb1857753a2c5 Mon Sep 17 00:00:00 2001 From: Apoorv Khatreja Date: Fri, 25 Mar 2011 05:25:10 +0800 Subject: [PATCH] Mime type rewriting must be done only when an attachment is viewed. Therefore, removed conflicting references to rewriting code from LocalStore. --- src/com/fsck/k9/mail/internet/MimeUtility.java | 8 ++++---- src/com/fsck/k9/mail/store/LocalStore.java | 2 +- src/com/fsck/k9/provider/AttachmentProvider.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/com/fsck/k9/mail/internet/MimeUtility.java b/src/com/fsck/k9/mail/internet/MimeUtility.java index 42033eda1..32a8b1679 100644 --- a/src/com/fsck/k9/mail/internet/MimeUtility.java +++ b/src/com/fsck/k9/mail/internet/MimeUtility.java @@ -1183,16 +1183,16 @@ public class MimeUtility { // If the MIME type set by the user's mailer is application/octet-stream, try to figure // out whether there's a sane file type extension. if (returnedType != null && !DEFAULT_ATTACHMENT_MIME_TYPE.equalsIgnoreCase(returnedType)) { - return getCorrectedMimeType(returnedType); + return returnedType; } else if (extension != null) { for (String[] contentTypeMapEntry : MIME_TYPE_BY_EXTENSION_MAP) { if (contentTypeMapEntry[0].equals(extension)) { - return getCorrectedMimeType(contentTypeMapEntry[1]); + return contentTypeMapEntry[1]; } } } - return getCorrectedMimeType(DEFAULT_ATTACHMENT_MIME_TYPE); + return DEFAULT_ATTACHMENT_MIME_TYPE; } /** @@ -1202,7 +1202,7 @@ public class MimeUtility { * @param mimeType the MIME type * @return the corrected MIME type */ - public static String getCorrectedMimeType(String mimeType) { + public static String canonicalizeMimeType(String mimeType) { for (String[] mimeTypeMapEntry : MIME_TYPE_REPLACEMENT_MAP) { if (mimeTypeMapEntry[0].equals(mimeType)) { return mimeTypeMapEntry[1]; diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index 7141d18c4..e90e5a64e 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -1010,7 +1010,7 @@ public class LocalStore extends Store implements Serializable { if (MimeUtility.DEFAULT_ATTACHMENT_MIME_TYPE.equalsIgnoreCase(type)) { type = MimeUtility.getMimeTypeByExtension(name); } - return MimeUtility.getCorrectedMimeType(type); + return type; } finally { if (cursor != null) { cursor.close(); diff --git a/src/com/fsck/k9/provider/AttachmentProvider.java b/src/com/fsck/k9/provider/AttachmentProvider.java index 90ac52c89..5deeecd61 100644 --- a/src/com/fsck/k9/provider/AttachmentProvider.java +++ b/src/com/fsck/k9/provider/AttachmentProvider.java @@ -105,7 +105,7 @@ public class AttachmentProvider extends ContentProvider { try { final LocalStore localStore = LocalStore.getLocalInstance(account, K9.app); - return localStore.getAttachmentType(id); + return MimeUtility.canonicalizeMimeType(localStore.getAttachmentType(id)); } catch (MessagingException e) { Log.e(K9.LOG_TAG, "Unable to retrieve LocalStore for " + account, e);