From 0169a6f581931959b63f2175af23cef46732a32f Mon Sep 17 00:00:00 2001 From: Evan Schoenberg Date: Thu, 20 Sep 2007 00:01:33 +0000 Subject: [PATCH] Merged [21089]: * AIEmoticonPack now uses NSBundle to determine the path to an icon for an emoticon without regard to its extension. This also reverts [21084] since it is no longer needed. * Removed extensions specified in the iChat Emoticons.plist git-svn-id: svn://svn.adiumx.com/adium/branches/adium-1.1@21090 1c916fce-81e2-0310-a464-8ca513f45935 --- Frameworks/Adium Framework/Source/AIEmoticonPack.h | 1 + Frameworks/Adium Framework/Source/AIEmoticonPack.m | 36 ++++++++++++---------- .../iChat.AdiumEmoticonset/Emoticons.plist | 32 +++++++++---------- Source/AIEmoticonController.m | 5 --- 4 files changed, 36 insertions(+), 38 deletions(-) diff --git a/Frameworks/Adium Framework/Source/AIEmoticonPack.h b/Frameworks/Adium Framework/Source/AIEmoticonPack.h index c87f18f63..93e71651b 100644 --- a/Frameworks/Adium Framework/Source/AIEmoticonPack.h +++ b/Frameworks/Adium Framework/Source/AIEmoticonPack.h @@ -15,6 +15,7 @@ */ @interface AIEmoticonPack : NSObject { + NSBundle *bundle; NSString *path; NSString *name; NSString *serviceClass; diff --git a/Frameworks/Adium Framework/Source/AIEmoticonPack.m b/Frameworks/Adium Framework/Source/AIEmoticonPack.m index eff0e025c..6467a1b6b 100644 --- a/Frameworks/Adium Framework/Source/AIEmoticonPack.m +++ b/Frameworks/Adium Framework/Source/AIEmoticonPack.m @@ -73,18 +73,19 @@ if ((self = [super init])) { path = [inPath retain]; - NSBundle *xtraBundle = [NSBundle bundleWithPath:path]; + bundle = [[NSBundle bundleWithPath:path] retain]; + + /* if (xtraBundle && ([[xtraBundle objectForInfoDictionaryKey:@"XtraBundleVersion"] intValue] == 1)) { //This checks for a new-style xtra //New style xtras store the same info, but it's in Contents/Resources/ so that we can have an info.plist file and use NSBundle. emoticonLocation = [[xtraBundle resourcePath] retain]; - } else { - emoticonLocation = [path retain]; - } - + } + */ + NSString *localizedName; name = [[path lastPathComponent] stringByDeletingPathExtension]; - if ((localizedName = [[xtraBundle localizedInfoDictionary] objectForKey:name])) { + if ((localizedName = [[bundle localizedInfoDictionary] objectForKey:name])) { name = localizedName; } [name retain]; @@ -102,10 +103,10 @@ - (void)dealloc { [path release]; + [bundle release]; [name release]; [emoticonArray release]; [enabledEmoticonArray release]; - [emoticonLocation release]; [serviceClass release]; [super dealloc]; @@ -241,8 +242,8 @@ newPack->emoticonArray = [emoticonArray mutableCopy]; newPack->serviceClass = [serviceClass retain]; newPack->path = [path retain]; + newPack->bundle = [bundle retain]; newPack->name = [name retain]; - newPack->emoticonLocation = [emoticonLocation retain]; return newPack; } @@ -260,7 +261,7 @@ [serviceClass release]; serviceClass = nil; // - NSString *infoDictPath = [emoticonLocation stringByAppendingPathComponent:EMOTICON_PLIST_FILENAME]; + NSString *infoDictPath = [[bundle resourcePath] stringByAppendingPathComponent:EMOTICON_PLIST_FILENAME]; NSDictionary *infoDict = [NSDictionary dictionaryWithContentsOfFile:infoDictPath]; NSDictionary *localizedInfoDict = [[NSBundle bundleWithPath:path] localizedInfoDictionary]; @@ -268,6 +269,7 @@ if (!infoDict) { [self _upgradeEmoticonPack:path]; infoDict = [NSDictionary dictionaryWithContentsOfFile:infoDictPath]; + [bundle release]; bundle = [[NSBundle bundleWithPath:path] retain]; } //Load the emoticons @@ -312,8 +314,8 @@ */ BOOL isDir; if ([[NSFileManager defaultManager] fileExistsAtPath:possiblePath isDirectory:&isDir] && isDir) { - [emoticonLocation release]; - emoticonLocation = [possiblePath retain]; + [bundle release]; + bundle = [[NSBundle bundleWithPath:possiblePath] retain]; break; } } @@ -352,7 +354,7 @@ { NSEnumerator *enumerator = [emoticons keyEnumerator]; NSString *fileName; - NSBundle *bundle = (!localizationDict ? [NSBundle bundleForClass:[self class]] : nil); + NSBundle *myBundle = (!localizationDict ? [NSBundle bundleForClass:[self class]] : nil); while ((fileName = [enumerator nextObject])) { id dict = [emoticons objectForKey:fileName]; @@ -369,16 +371,16 @@ if (!localizedEmoticonName) { //Otherwise, look at our list of default translations (generated at the bottom of this file) - localizedEmoticonName = [bundle localizedStringForKey:emoticonName - value:emoticonName - table:@"EmoticonNames"]; + localizedEmoticonName = [myBundle localizedStringForKey:emoticonName + value:emoticonName + table:@"EmoticonNames"]; } if (localizedEmoticonName) emoticonName = localizedEmoticonName; } - [emoticonArray addObject:[AIEmoticon emoticonWithIconPath:[emoticonLocation stringByAppendingPathComponent:fileName] + [emoticonArray addObject:[AIEmoticon emoticonWithIconPath:[bundle pathForImageResource:fileName] equivalents:[(NSDictionary *)dict objectForKey:EMOTICON_EQUIVALENTS] name:emoticonName pack:self]]; @@ -397,7 +399,7 @@ while ((fileName = [enumerator nextObject])) { NSDictionary *dict = [emoticons objectForKey:fileName]; - [emoticonArray addObject:[AIEmoticon emoticonWithIconPath:[emoticonLocation stringByAppendingPathComponent:fileName] + [emoticonArray addObject:[AIEmoticon emoticonWithIconPath:[bundle pathForImageResource:fileName] equivalents:[dict objectForKey:@"String Representations"] name:[dict objectForKey:@"Meaning"] pack:self]]; diff --git a/Resources/Emoticons/iChat.AdiumEmoticonset/Emoticons.plist b/Resources/Emoticons/iChat.AdiumEmoticonset/Emoticons.plist index 057825220..6443650a1 100644 --- a/Resources/Emoticons/iChat.AdiumEmoticonset/Emoticons.plist +++ b/Resources/Emoticons/iChat.AdiumEmoticonset/Emoticons.plist @@ -13,7 +13,7 @@ Emoticons - angry.tiff + angry Equivalents @@ -25,7 +25,7 @@ Name Angry - embarrassed.tiff + embarrassed Equivalents @@ -35,7 +35,7 @@ Name Embarrassed - cry.tiff + cry Equivalents @@ -44,7 +44,7 @@ Name Cry - footinmouth.tiff + footinmouth Equivalents @@ -54,7 +54,7 @@ Name Foot In Mouth - frown.tiff + frown Equivalents @@ -64,7 +64,7 @@ Name Frown - gasp.tiff + gasp Equivalents @@ -80,7 +80,7 @@ Name Gasp - laugh.tiff + laugh Equivalents @@ -90,7 +90,7 @@ Name Grin - innocent.tiff + innocent Equivalents @@ -99,7 +99,7 @@ Name Halo - kiss.tiff + kiss Equivalents @@ -109,7 +109,7 @@ Name Kiss - sealed.tiff + sealed Equivalents @@ -119,7 +119,7 @@ Name Lips Are Sealed - moneymouth.tiff + moneymouth Equivalents @@ -129,7 +129,7 @@ Name Money-mouth - smile.tiff + smile Equivalents @@ -139,7 +139,7 @@ Name Smile - yuck.tiff + yuck Equivalents @@ -151,7 +151,7 @@ Name Sticking Out Tongue - slant.tiff + slant Equivalents @@ -163,7 +163,7 @@ Name Undecided - cool.tiff + cool Equivalents @@ -173,7 +173,7 @@ Name Cool - wink.tiff + wink Equivalents diff --git a/Source/AIEmoticonController.m b/Source/AIEmoticonController.m index f62e0c76d..30cc1cb3c 100644 --- a/Source/AIEmoticonController.m +++ b/Source/AIEmoticonController.m @@ -31,8 +31,6 @@ #import #import -#import - #define EMOTICON_DEFAULT_PREFS @"EmoticonDefaults" #define EMOTICONS_PATH_NAME @"Emoticons" @@ -686,9 +684,6 @@ int packSortFunction(id packA, id packB, void *packOrderingArray); AIEmoticonPack *pack = [AIEmoticonPack emoticonPackFromPath:path]; if ([[pack emoticons] count]) { -#warning NDA: fix this better - if([NSApp isOnLeopardOrBetter] && [[pack name] isEqualToString:@"iChat"]) - continue; [_availableEmoticonPacks addObject:pack]; [pack setDisabledEmoticons:[self disabledEmoticonsInPack:pack]]; } -- 2.11.4.GIT