-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTomatoIChat.m
56 lines (45 loc) · 1.22 KB
/
TomatoIChat.m
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
#import "TomatoIChat.h"
#import "iChat.h"
@interface TomatoIChat(Private)
- (void)getIChatApp;
@end
@implementation TomatoIChat
- (id)init {
if (self = [super init]) {
[self getIChatApp];
}
return self;
}
- (BOOL)isEnabled {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"TOMiChat"];
}
- (void)getIChatApp {
@try {
iChatApp = (iChatApplication *)[[SBApplication applicationWithBundleIdentifier:@"com.apple.iChat"] retain];
}
@catch(NSException *except) {
NSLog(@"Exception %@", except);
}
}
- (void)iChatInTomato {
if ([iChatApp isRunning]) {
iChatApp.status = iChatMyStatusAway;
iChatApp.statusMessage = [[NSUserDefaults standardUserDefaults] stringForKey:@"TOMiChatTomato"];
}
}
- (void)iChatOnBreak {
if ([iChatApp isRunning]) {
iChatApp.status = iChatMyStatusAvailable;
iChatApp.statusMessage = [[NSUserDefaults standardUserDefaults] stringForKey:@"TOMiChatBreak"];
}
}
- (void)tomatoStarted:(NSNotification *)notification {
[self iChatInTomato];
}
- (void)tomatoPopped:(NSNotification *)notification {
[self iChatOnBreak];
}
- (void)breakStarted:(NSNotification *)notification {
[self iChatOnBreak];
}
@end