public
Description: Fixes various annoyances with iCal
Homepage:
Clone URL: git://github.com/groby/iCalFix.git
iCalFix / icfLoader.m
100644 67 lines (52 sloc) 2.068 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#import "icfLoader.h"
#import "icfPlugin.h"
 
 
@implementation icfLoader
 
/**
* Do hooking work as soon as class is loaded
*/
+ (void) load
{
    // If we got here, we are our own input manager. Let's install ourselves
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(installPlugin:) name:NSApplicationWillFinishLaunchingNotification object:nil];
}
 
 
/*
* Installs itself by hooking necessary functions
*/
+ (void) installPlugin:(NSNotification*)_notification
{
NSString* applicationName = [[NSBundle mainBundle] bundleIdentifier];
 
BOOL installAsScheduler = FALSE;
 
// Verify against the iCal scheduler
    if( [applicationName isEqualToString: @"com.apple.iCal.helper"] )
        installAsScheduler = true;
    
// Check if this is really the right application
if( !installAsScheduler && ![applicationName isEqualToString: @"com.apple.iCal" ] )
return;
 
// Next, check for proper version range of iCal
int icalVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleVersion"] intValue];
 
const int minVersion = 1055;
const int maxVersion = 1069;
 
if( icalVersion < minVersion )
{
[icfPlugin
            errorAlert: [NSString stringWithFormat: @"iCal(v%d) is not supported by iCalFix %@(%@).", icalVersion,
                [[icfPlugin sharedInstance] marketingVersion],
                [[icfPlugin sharedInstance] bundleVersion]
            ]
            withDetails: @"Your version of iCal seems out of date. Please update to the newest version."];
 
return;
}
if( icalVersion > maxVersion )
{
[icfPlugin
            errorAlert: [NSString stringWithFormat: @"iCal(v%d) is not supported by iCalFix %@(%@).", icalVersion,
                [[icfPlugin sharedInstance] marketingVersion],
                [[icfPlugin sharedInstance] bundleVersion]
                ]
           withDetails: @"Your version of iCalFix seems out of date. Please update to the newest version."];
 
return;
}
    
// And finally, install iCalFix
[icfPlugin installAsScheduler: installAsScheduler ];
}
@end