adium-1.4 3225:e40774a8647e: Blacklist PSD and PDFs as "images" ...
commits at adium.im
commits at adium.im
Mon Nov 8 01:07:19 UTC 2010
details: http://hg.adium.im/adium-1.4/rev/e40774a8647e
revision: 3225:e40774a8647e
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.
diffs (63 lines):
diff -r a39dd283c0b3 -r e40774a8647e Frameworks/AIUtilities Framework/Source/AITextAttachmentAdditions.h
--- a/Frameworks/AIUtilities Framework/Source/AITextAttachmentAdditions.h Wed Nov 03 20:23:49 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 a39dd283c0b3 -r e40774a8647e Frameworks/AIUtilities Framework/Source/AITextAttachmentAdditions.m
--- a/Frameworks/AIUtilities Framework/Source/AITextAttachmentAdditions.m Wed Nov 03 20:23:49 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 a39dd283c0b3 -r e40774a8647e Frameworks/Adium Framework/Source/AITextAttachmentExtension.m
--- a/Frameworks/Adium Framework/Source/AITextAttachmentExtension.m Wed Nov 03 20:23:49 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