-
Notifications
You must be signed in to change notification settings - Fork 0
/
BTBusinessTimeController.m
73 lines (55 loc) · 1.72 KB
/
BTBusinessTimeController.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// BTBusinessTimeController.m
// BusinessTime
//
// Created by Sam Mcdonald on 2/9/10.
// Copyright 2010 141312 LLC. All rights reserved.
//
#import "BTBusinessTimeController.h"
#import "BTBlackListModel.h"
#import "BTStatusWindowController.h"
#import "BTModel.h"
@implementation BTBusinessTimeController
- (id)init {
self = [super init];
if (self) {
isBusinessTime = NO;
beginningOfSession = [[NSDate alloc] initWithTimeIntervalSinceNow:0];
}
return self;
}
- (void)startBusinessTime {
BTBlackListModel* blackListModel = [[BTModel sharedModel] blackListModel];
if (statusWindowController != nil ) {
[[statusWindowController window] close];
}
[beginningOfSession release];
beginningOfSession = [[NSDate alloc] initWithTimeIntervalSinceNow:0];
[blackListModel enableFilters];
isBusinessTime = YES;
}
- (void)stopBusinessTime {
BTBlackListModel* blackListModel = [[BTModel sharedModel] blackListModel];
statusWindowController = [[BTStatusWindowController alloc] init];
[[statusWindowController window] makeKeyAndOrderFront:nil];
[statusWindowController startTimer];
[beginningOfSession release];
beginningOfSession = [[NSDate alloc] initWithTimeIntervalSinceNow:0];
// Disable the host filtering.
[blackListModel disableFilters];
isBusinessTime = NO;
}
- (void)toggleBusinessTime {
if ( isBusinessTime )
[self stopBusinessTime];
else
[self startBusinessTime];
}
- (BOOL)isBusinessTime {
return isBusinessTime;
}
- (NSTimeInterval)timeOfCurrentSession {
NSLog(@"hello");
return [[NSDate dateWithTimeIntervalSinceNow:0] timeIntervalSinceDate:beginningOfSession];
}
@end