When loading a service icon from service ID and the pack doesn't specify one, ask the first service with that ID for it.
This also will return 'nil' instead of a dead path for service icons which are not supported by an icon pack, but which a service specifies as a default. Refs #12697. (We don't know the paths of default service icons, yet)
1.1 --- a/Frameworks/Adium Framework/Source/AIServiceIcons.m Sat Oct 17 17:01:56 2009 -0400
1.2 +++ b/Frameworks/Adium Framework/Source/AIServiceIcons.m Sat Oct 17 17:20:24 2009 -0400
1.3 @@ -17,6 +17,7 @@
1.4 #import <Adium/AIListObject.h>
1.5 #import <Adium/AIService.h>
1.6 #import <Adium/AIServiceIcons.h>
1.7 +#import <Adium/AIAccountControllerProtocol.h>
1.8
1.9 static NSMutableDictionary *serviceIcons[NUMBER_OF_SERVICE_ICON_TYPES][NUMBER_OF_ICON_DIRECTIONS];
1.10
1.11 @@ -68,7 +69,13 @@
1.12
1.13 + (NSString *)pathForServiceIconForServiceID:(NSString *)serviceID type:(AIServiceIconType)iconType
1.14 {
1.15 - return [serviceIconBasePath stringByAppendingPathComponent:[serviceIconNames[iconType] objectForKey:serviceID]];
1.16 + NSString *iconName = [serviceIconNames[iconType] objectForKey:serviceID];
1.17 +
1.18 + if (iconName) {
1.19 + return [serviceIconBasePath stringByAppendingPathComponent:iconName];
1.20 + } else {
1.21 + return nil;
1.22 + }
1.23 }
1.24
1.25 //Retrieve the correct service icon for a service by ID
1.26 @@ -85,19 +92,24 @@
1.27
1.28 if (path) {
1.29 serviceIcon = [[NSImage alloc] initWithContentsOfFile:path];
1.30 + } else {
1.31 + AIService *service = [adium.accountController firstServiceWithServiceID:serviceID];
1.32 + if (service) {
1.33 + serviceIcon = [service defaultServiceIconOfType:iconType];
1.34 + }
1.35 + }
1.36
1.37 + if (serviceIcon) {
1.38 + if (iconDirection == AIIconFlipped) [serviceIcon setFlipped:YES];
1.39 + [serviceIcons[iconType][iconDirection] setObject:serviceIcon forKey:serviceID];
1.40 + [serviceIcon release];
1.41 + } else {
1.42 + //Attempt to load the default service icon
1.43 + serviceIcon = [self defaultServiceIconForType:iconType serviceID:serviceID];
1.44 if (serviceIcon) {
1.45 + //Cache the default service icon (until the pack is changed) so we have it immediately next time
1.46 if (iconDirection == AIIconFlipped) [serviceIcon setFlipped:YES];
1.47 [serviceIcons[iconType][iconDirection] setObject:serviceIcon forKey:serviceID];
1.48 - [serviceIcon release];
1.49 - } else {
1.50 - //Attempt to load the default service icon
1.51 - serviceIcon = [self defaultServiceIconForType:iconType serviceID:serviceID];
1.52 - if (serviceIcon) {
1.53 - //Cache the default service icon (until the pack is changed) so we have it immediately next time
1.54 - if (iconDirection == AIIconFlipped) [serviceIcon setFlipped:YES];
1.55 - [serviceIcons[iconType][iconDirection] setObject:serviceIcon forKey:serviceID];
1.56 - }
1.57 }
1.58 }
1.59 }