From e44d7169a6e8b35e34fb87262dda1257f2504b69 Mon Sep 17 00:00:00 2001 From: Kris Wong Date: Fri, 16 Nov 2012 14:24:28 -0600 Subject: [PATCH] Fix for attachment content type handling on iOS. --- MailCore.xcodeproj/project.pbxproj | 4 + Resources/types.plist | 568 +++++++++++++++++++++++++++++ Source/CTCoreAttachment.m | 4 +- 3 files changed, 574 insertions(+), 2 deletions(-) create mode 100644 Resources/types.plist diff --git a/MailCore.xcodeproj/project.pbxproj b/MailCore.xcodeproj/project.pbxproj index 3541428..709e68a 100644 --- a/MailCore.xcodeproj/project.pbxproj +++ b/MailCore.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 0F134A871656D718000D1E83 /* types.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0F134A861656D718000D1E83 /* types.plist */; }; 0F369D03162DF5030043A3ED /* CTXlistResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F369D01162DF5030043A3ED /* CTXlistResult.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0F369D04162DF5030043A3ED /* CTXlistResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F369D02162DF5030043A3ED /* CTXlistResult.m */; }; 0FFA954C16559D4F00A89EA0 /* CTXlistResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F369D02162DF5030043A3ED /* CTXlistResult.m */; }; @@ -215,6 +216,7 @@ /* Begin PBXFileReference section */ 0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 0F134A861656D718000D1E83 /* types.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = types.plist; path = Resources/types.plist; sourceTree = ""; }; 0F369D01162DF5030043A3ED /* CTXlistResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTXlistResult.h; path = Source/CTXlistResult.h; sourceTree = ""; }; 0F369D02162DF5030043A3ED /* CTXlistResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CTXlistResult.m; path = Source/CTXlistResult.m; sourceTree = ""; }; 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; @@ -381,6 +383,7 @@ 089C1665FE841158C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( + 0F134A861656D718000D1E83 /* types.plist */, F81B88700A74AAD800143DF6 /* Info.plist */, ); name = Resources; @@ -772,6 +775,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 0F134A871656D718000D1E83 /* types.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Resources/types.plist b/Resources/types.plist new file mode 100644 index 0000000..312a6cb --- /dev/null +++ b/Resources/types.plist @@ -0,0 +1,568 @@ + + + + + application/andrew-inset + + ez + + application/java-archive + + jar + + application/mac-binhex40 + + hqx + + application/mac-compactpro + + cpt + + application/msword + + doc + + application/octet-stream + + dms + lha + lzh + exe + class + so + dll + iso + fla + + application/oda + + oda + + application/pdf + + pdf + + application/postscript + + eps + ai + ps + + application/smil + + smil + + application/vnd.adobe.xdp+xml + + xdp + + application/vnd.adobe.xfd+xml + + xfd + + application/vnd.adobe.xfdf + + xfdf + + application/vnd.fdf + + fdf + + application/vnd.mif + + mif + + application/vnd.ms-excel + + xls + + application/vnd.ms-powerpoint + + ppt + + application/vnd.wap.wbxml + + wbxml + + application/vnd.wap.wmlc + + wmlc + + application/vnd.wap.wmlscriptc + + wmlsc + + application/x-bcpio + + bcpio + + application/x-cdlink + + vcd + + application/x-chess-pgn + + pgn + + application/x-compress + + Z + + application/x-cpio + + cpio + + application/x-csh + + csh + + application/x-director + + dcr + dir + dxr + + application/x-diskcopy + + smi + dmg + + application/x-dvi + + dvi + + application/x-filemaker + + fp6 + fp5 + fp4 + fp3 + fp2 + fp + + application/x-futuresplash + + spl + + application/x-gtar + + gtar + + application/x-gzip + + gz + tgz + cpgz + + application/x-hdf + + hdf + + application/x-java-jnlp-file + + jnlp + + application/x-javascript + + js + + application/x-koan + + skp + skd + skt + skm + + application/x-latex + + latex + + application/x-ms-wmd + + wmd + + application/x-netcdf + + nc + cdf + + application/x-photoshop + + psd + + application/x-sh + + sh + + application/x-shar + + shar + + application/x-shockwave-flash + + swf + + application/x-stuffit + + sit + + application/x-sv4cpio + + sv4cpio + + application/x-sv4crc + + sv4crc + + application/x-tar + + tar + + application/x-tcl + + tcl + + application/x-tex + + tex + + application/x-texinfo + + texinfo + texi + + application/x-troff + + t + tr + roff + + application/x-troff-man + + man + + application/x-troff-me + + me + + application/x-troff-ms + + ms + + application/x-ustar + + ustar + + application/x-wais-source + + src + + application/x-webarchive + + webarchive + + application/xhtml+xml + + xhtml + xhtm + + application/xml + + xml + + application/zip + + zip + + audio/basic + + au + snd + + audio/midi + + mid + midi + kar + + audio/mpeg + + mp3 + mpga + mp2 + + audio/scpls + + pls + + audio/x-aiff + + aif + aiff + aifc + + audio/x-m4p + + m4p + + audio/x-mpegurl + + m3u + + audio/x-ms-wma + + wma + + audio/x-pn-realaudio + + ram + rm + + audio/x-pn-realaudio-plugin + + rpm + + audio/x-realaudio + + ra + + audio/x-wav + + wav + + chemical/x-pdb + + pdb + + chemical/x-xyz + + xyz + + image/bmp + + bmp + + image/gif + + gif + + image/ief + + ief + + image/jp2 + + jp2 + + image/jpeg + + jpg + jpeg + jpe + + image/pict + + pict + pic + + image/png + + png + + image/quicktime + + qti + qtif + + image/svg+xml + + svg + svgz + + image/tiff + + tiff + tif + + image/vnd.wap.wbmp + + wbmp + + image/x-cmu-raster + + ras + + image/x-icon + + ico + + image/x-macpaint + + pnt + pntg + mac + + image/x-pcx + + pcx + + image/x-portable-anymap + + pnm + + image/x-portable-bitmap + + pbm + + image/x-portable-graymap + + pgm + + image/x-portable-pixmap + + ppm + + image/x-rgb + + rgb + + image/x-targa + + targa + + image/x-xbitmap + + xbm + + image/x-xpixmap + + xpm + + image/x-xwindowdump + + xwd + + model/iges + + igs + iges + + model/mesh + + msh + mesh + silo + + model/vrml + + wrl + vrml + + text/calendar + + ics + + text/css + + css + + text/html + + html + htm + shtml + jhtml + + text/plain + + txt + asc + text + + text/qif + + qif + + text/richtext + + rtx + + text/rtf + + rtf + + text/sgml + + sgml + sgm + + text/tab-separated-values + + tsv + + text/vcard + + vcf + + text/vnd.wap.wml + + wml + + text/vnd.wap.wmlscript + + wmls + + text/x-setext + + etx + + text/xml + + xml + xsl + + video/mpeg + + mpeg + mpg + mpe + + video/quicktime + + qt + mov + + video/vnd.mpegurl + + mxu + + video/x-ms-asf + + asf + + video/x-ms-wmv + + wmv + + video/x-ms-wmx + + wmx + + video/x-ms.wmp + + wmp + + video/x-msvideo + + avi + + video/x-sgi-movie + + movie + + x-conference/x-cooltalk + + ice + + + diff --git a/Source/CTCoreAttachment.m b/Source/CTCoreAttachment.m index 7879417..abfb453 100644 --- a/Source/CTCoreAttachment.m +++ b/Source/CTCoreAttachment.m @@ -41,8 +41,8 @@ - (id)initWithContentsOfFile:(NSString *)path { NSString *filePathExt = [path pathExtension]; NSString *contentType = nil; - //TODO: This won't work on iOS - NSDictionary *contentTypes = [NSDictionary dictionaryWithContentsOfFile:CTContentTypesPath]; + NSString *typesPath = [[NSBundle mainBundle] pathForResource:@"types" ofType:@"plist"]; + NSDictionary *contentTypes = [NSDictionary dictionaryWithContentsOfFile:typesPath]; for (NSString *key in [contentTypes allKeys]) { NSArray *fileExtensions = [contentTypes objectForKey:key]; for (NSString *ext in fileExtensions) {