libpurple.framework 2.3.1 as before but with HAVE_OPENSSL defined, which enables...
[adiumx.git] / Source / AIXtraInfo.m
blobd93622f84179233c1d8efa20715157074b59efd5
1 /* 
2  * Adium is the legal property of its developers, whose names are listed in the copyright file included
3  * with this source distribution.
4  * 
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.
8  * 
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.
12  * 
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.
15  */
17 #import "AIXtraInfo.h"
18 #import <Adium/AIDockControllerProtocol.h>
20 @implementation AIXtraInfo
22 - (NSString *)type
24         return type;
27 - (NSString *)name
29         return name;
32 - (void) setName:(NSString *)inName
34         if(!inName) name = @"Unnamed Xtra";
35         else {
36                 [inName retain];
37                 [name autorelease];
38                 name = inName;
39         }
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]))
55         {
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"];
65                         if(previewImagePath)
66                                 previewImage = [[NSImage alloc] initByReferencingFile:previewImagePath];
67                 }
68                 else {
69                         if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
70                                 [self autorelease];
71                                 return nil;
72                         }
73                         [self setName:[[path lastPathComponent] stringByDeletingPathExtension]];
74                         resourcePath = [path copy];//root of the xtra
75                 }       
76                 if (!readMePath)
77                         readMePath = [[[NSBundle mainBundle] pathForResource:@"DefaultXtraReadme" ofType:@"rtf"] retain];
78                 if (!icon) {
79                         if ([[path pathExtension] caseInsensitiveCompare:@"AdiumIcon"] == NSOrderedSame) {
80                                 icon = [[[[adium dockController] previewStateForIconPackAtPath:path] image] retain];
82                         } else {
83                                 icon = [[[NSWorkspace sharedWorkspace] iconForFileType:[path pathExtension]] retain];
84                         }
85                 }
86                 if(!previewImage)
87                         previewImage = [icon retain];
88         }
89         return self;
92 - (NSImage *) icon
94         return icon;
97 - (void) dealloc
99         [icon release];
100         [previewImage release];
101         [path release];
102         [name release];
103         [resourcePath release];
104         [type release];
105         [readMePath release];
106         [super dealloc];
109 - (NSString *)resourcePath
111         return resourcePath;
114 - (NSString *)path
116         return path;
119 - (NSString *)readMePath
121         return readMePath;
124 - (NSBundle *)bundle
126         return xtraBundle;
129 - (NSImage *)previewImage
131         return previewImage;
134 @end