2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3 * with this source distribution.
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #import "AIXtraInfo.h"
18 #import <Adium/AIDockControllerProtocol.h>
20 @implementation AIXtraInfo
32 - (void) setName:(NSString *)inName
34 if(!inName) name = @"Unnamed Xtra";
42 - (NSString *) description
44 return [NSString stringWithFormat:@"%@, %@, %@, retaincount=%d", [self name], [self path], [self type], [self retainCount]];
47 + (AIXtraInfo *) infoWithURL:(NSURL *)url
49 return [[[self alloc] initWithURL:url] autorelease];
52 - (id) initWithURL:(NSURL *)url
54 if((self = [super init]))
56 path = [[url path] retain];
57 type = [[[[url path] pathExtension] lowercaseString] retain];
58 xtraBundle = [[NSBundle alloc] initWithPath:path];
59 if (xtraBundle && ([[xtraBundle objectForInfoDictionaryKey:@"XtraBundleVersion"] intValue] == 1)) { //This checks for a new-style xtra
60 [self setName:[xtraBundle objectForInfoDictionaryKey:(NSString *)kCFBundleNameKey]];
61 resourcePath = [[xtraBundle resourcePath] retain];
62 icon = [[NSImage alloc] initByReferencingFile:[xtraBundle pathForResource:@"Icon" ofType:@"icns"]];
63 readMePath = [[xtraBundle pathForResource:@"ReadMe" ofType:@"rtf"] retain];
64 NSString *previewImagePath = [xtraBundle pathForImageResource:@"PreviewImage"];
66 previewImage = [[NSImage alloc] initByReferencingFile:previewImagePath];
69 if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
73 [self setName:[[path lastPathComponent] stringByDeletingPathExtension]];
74 resourcePath = [path copy];//root of the xtra
77 readMePath = [[[NSBundle mainBundle] pathForResource:@"DefaultXtraReadme" ofType:@"rtf"] retain];
79 if ([[path pathExtension] caseInsensitiveCompare:@"AdiumIcon"] == NSOrderedSame) {
80 icon = [[[[adium dockController] previewStateForIconPackAtPath:path] image] retain];
83 icon = [[[NSWorkspace sharedWorkspace] iconForFileType:[path pathExtension]] retain];
87 previewImage = [icon retain];
100 [previewImage release];
103 [resourcePath release];
105 [readMePath release];
109 - (NSString *)resourcePath
119 - (NSString *)readMePath
129 - (NSImage *)previewImage