adium-1.4 2630:38d242c5c33e: When loading a service icon from se...
commits at adium.im
commits at adium.im
Sat Oct 17 21:20:31 UTC 2009
details: http://hg.adium.im/adium-1.4/rev/38d242c5c33e
revision: 2630:38d242c5c33e
author: Zachary West <zacw at adium.im>
date: Sat Oct 17 17:20:24 2009 -0400
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)
diffs (60 lines):
diff -r eb1cbc7fbb07 -r 38d242c5c33e Frameworks/Adium Framework/Source/AIServiceIcons.m
--- a/Frameworks/Adium Framework/Source/AIServiceIcons.m Sat Oct 17 17:01:56 2009 -0400
+++ b/Frameworks/Adium Framework/Source/AIServiceIcons.m Sat Oct 17 17:20:24 2009 -0400
@@ -17,6 +17,7 @@
#import <Adium/AIListObject.h>
#import <Adium/AIService.h>
#import <Adium/AIServiceIcons.h>
+#import <Adium/AIAccountControllerProtocol.h>
static NSMutableDictionary *serviceIcons[NUMBER_OF_SERVICE_ICON_TYPES][NUMBER_OF_ICON_DIRECTIONS];
@@ -68,7 +69,13 @@
+ (NSString *)pathForServiceIconForServiceID:(NSString *)serviceID type:(AIServiceIconType)iconType
{
- return [serviceIconBasePath stringByAppendingPathComponent:[serviceIconNames[iconType] objectForKey:serviceID]];
+ NSString *iconName = [serviceIconNames[iconType] objectForKey:serviceID];
+
+ if (iconName) {
+ return [serviceIconBasePath stringByAppendingPathComponent:iconName];
+ } else {
+ return nil;
+ }
}
//Retrieve the correct service icon for a service by ID
@@ -85,19 +92,24 @@
if (path) {
serviceIcon = [[NSImage alloc] initWithContentsOfFile:path];
+ } else {
+ AIService *service = [adium.accountController firstServiceWithServiceID:serviceID];
+ if (service) {
+ serviceIcon = [service defaultServiceIconOfType:iconType];
+ }
+ }
+ if (serviceIcon) {
+ if (iconDirection == AIIconFlipped) [serviceIcon setFlipped:YES];
+ [serviceIcons[iconType][iconDirection] setObject:serviceIcon forKey:serviceID];
+ [serviceIcon release];
+ } else {
+ //Attempt to load the default service icon
+ serviceIcon = [self defaultServiceIconForType:iconType serviceID:serviceID];
if (serviceIcon) {
+ //Cache the default service icon (until the pack is changed) so we have it immediately next time
if (iconDirection == AIIconFlipped) [serviceIcon setFlipped:YES];
[serviceIcons[iconType][iconDirection] setObject:serviceIcon forKey:serviceID];
- [serviceIcon release];
- } else {
- //Attempt to load the default service icon
- serviceIcon = [self defaultServiceIconForType:iconType serviceID:serviceID];
- if (serviceIcon) {
- //Cache the default service icon (until the pack is changed) so we have it immediately next time
- if (iconDirection == AIIconFlipped) [serviceIcon setFlipped:YES];
- [serviceIcons[iconType][iconDirection] setObject:serviceIcon forKey:serviceID];
- }
}
}
}
More information about the commits
mailing list