adium 3493:ae7213ff882b: Blacklist PSD and PDFs as "images" to b...

commits at adium.im commits at adium.im
Mon Nov 8 03:11:59 UTC 2010


details:	http://hg.adium.im/adium/rev/ae7213ff882b
revision:	3493:ae7213ff882b
author:		Zachary West <zacw at adium.im>
date:		Sun Nov 07 20:07:02 2010 -0500

Blacklist PSD and PDFs as "images" to be sent as such for Direct IM.
(transplanted from e40774a8647e3a0b6e12b7f014f1f17f2e75521f)

diffs (63 lines):

diff -r 0725921c9f9c -r ae7213ff882b Frameworks/AIUtilities Framework/Source/AITextAttachmentAdditions.h
--- a/Frameworks/AIUtilities Framework/Source/AITextAttachmentAdditions.h	Wed Nov 03 20:23:42 2010 -0500
+++ b/Frameworks/AIUtilities Framework/Source/AITextAttachmentAdditions.h	Sun Nov 07 20:07:02 2010 -0500
@@ -7,5 +7,7 @@
 //
 
 @interface NSTextAttachment (AITextAttachmentAdditions)
+- (BOOL)consideredImageForHFSType:(OSType)HFSTypeCode
+					pathExtension:(NSString *)pathExtension;
 - (BOOL)wrapsImage;
 @end
diff -r 0725921c9f9c -r ae7213ff882b Frameworks/AIUtilities Framework/Source/AITextAttachmentAdditions.m
--- a/Frameworks/AIUtilities Framework/Source/AITextAttachmentAdditions.m	Wed Nov 03 20:23:42 2010 -0500
+++ b/Frameworks/AIUtilities Framework/Source/AITextAttachmentAdditions.m	Sun Nov 07 20:07:02 2010 -0500
@@ -9,15 +9,23 @@
 
 @implementation NSTextAttachment (AITextAttachmentAdditions)
 
+- (BOOL)consideredImageForHFSType:(OSType)HFSTypeCode
+					pathExtension:(NSString *)pathExtension
+{
+	NSMutableArray *imageFileTypes = [[NSImage imageFileTypes] mutableCopy];
+	NSArray *removeFileTypes = [NSArray arrayWithObjects:@"pdf", @"PDF", @"psd", @"PSD", @"'PDF '", nil];
+	
+	[imageFileTypes removeObjectsInArray:removeFileTypes];
+	
+	return ([imageFileTypes containsObject:NSFileTypeForHFSTypeCode(HFSTypeCode)] ||
+			([imageFileTypes containsObject:pathExtension]));
+}
+
 - (BOOL)wrapsImage
 {
-	NSFileWrapper	*fileWrapper = [self fileWrapper];
-	NSArray			*imageFileTypes = [NSImage imageFileTypes];
-	OSType			HFSTypeCode = [[fileWrapper fileAttributes] fileHFSTypeCode];
-	NSString		*pathExtension;
-	
-	return ([imageFileTypes containsObject:NSFileTypeForHFSTypeCode(HFSTypeCode)] ||
-			((pathExtension = [[fileWrapper filename] pathExtension]) && [imageFileTypes containsObject:pathExtension]));	
+	NSFileWrapper	*fileWrapper = [self fileWrapper];	
+	return ([self consideredImageForHFSType:[[fileWrapper fileAttributes] fileHFSTypeCode]
+							  pathExtension:[[fileWrapper filename] pathExtension]]);
 }
 
 @end
diff -r 0725921c9f9c -r ae7213ff882b Frameworks/Adium Framework/Source/AITextAttachmentExtension.m
--- a/Frameworks/Adium Framework/Source/AITextAttachmentExtension.m	Wed Nov 03 20:23:42 2010 -0500
+++ b/Frameworks/Adium Framework/Source/AITextAttachmentExtension.m	Sun Nov 07 20:07:02 2010 -0500
@@ -182,12 +182,10 @@
 	BOOL attachesAnImage = (image != nil);
 	
 	if (!attachesAnImage && path) {
-		NSArray			*imageFileTypes = [NSImage imageFileTypes];
 		OSType			HFSTypeCode = [[[NSFileManager defaultManager] fileAttributesAtPath:path traverseLink:YES] fileHFSTypeCode];
-		NSString		*pathExtension;
 		
-		attachesAnImage = ([imageFileTypes containsObject:NSFileTypeForHFSTypeCode(HFSTypeCode)] ||
-					  ((pathExtension = [path pathExtension]) && [imageFileTypes containsObject:pathExtension]));
+		attachesAnImage = [self consideredImageForHFSType:HFSTypeCode
+											pathExtension:[path pathExtension]];
 	}
 
 	return attachesAnImage;




More information about the commits mailing list