Refactored GrowlMail to have a separate singleton notifier object, in order to make the mail-bundle class less dependent on being a singleton. (Assumptions are bad, especially when you're working with private/undocumented APIs.)
2 Copyright (c) The Growl Project, 2004-2005
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
8 1. Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 3. Neither the name of Growl nor the names of its contributors
14 may be used to endorse or promote products derived from this software
15 without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
26 OF THE POSSIBILITY OF SUCH DAMAGE.
32 // Created by Adam Iser on Mon Jul 26 2004.
33 // Copyright (c) 2004-2005 The Growl Project. All rights reserved.
38 #import "GrowlMailNotifier.h"
40 NSBundle *GMGetGrowlMailBundle(void) {
41 return [NSBundle bundleForClass:[GrowlMail class]];
44 @implementation GrowlMail
46 #pragma mark Boring bookkeeping stuff
51 // this image is leaked
52 NSImage *image = [[NSImage alloc] initByReferencingFile:[GMGetGrowlMailBundle() pathForImageResource:@"GrowlMail"]];
53 [image setName:@"GrowlMail"];
55 [GrowlMail registerBundle];
57 NSLog(@"Loaded GrowlMail %@", [GMGetGrowlMailBundle() objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]);
60 + (BOOL) hasPreferencesPanel {
64 + (NSString *) preferencesOwnerClassName {
65 return @"GrowlMailPreferencesModule";
68 + (NSString *) preferencesPanelName {
73 if ((self = [super init])) {
74 NSString *privateFrameworksPath = [GMGetGrowlMailBundle() privateFrameworksPath];
75 NSString *growlBundlePath = [privateFrameworksPath stringByAppendingPathComponent:@"Growl.framework"];
77 NSBundle *growlBundle = [NSBundle bundleWithPath:growlBundlePath];
79 if ([growlBundle load]) {
80 if ([GrowlApplicationBridge respondsToSelector:@selector(frameworkInfoDictionary)]) {
81 //Create or obtain our singleton notifier instance.
82 notifier = [[GrowlMailNotifier alloc] init];
84 NSLog(@"Could not initialize GrowlMail notifier object");
86 NSDictionary *infoDictionary = [GrowlApplicationBridge frameworkInfoDictionary];
87 NSLog(@"Using Growl.framework %@ (%@)",
88 [infoDictionary objectForKey:@"CFBundleShortVersionString"],
89 [infoDictionary objectForKey:(NSString *)kCFBundleVersionKey]);
91 NSLog(@"Using a version of Growl.framework older than 1.1. One of the other installed Mail plugins should be updated to Growl.framework 1.1 or later.");
95 NSLog(@"Could not load Growl.framework, GrowlMail disabled");