-
Notifications
You must be signed in to change notification settings - Fork 1
/
ORProviders.xm
96 lines (72 loc) · 2.58 KB
/
ORProviders.xm
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#import "ORProviders.h"
#import "Orangered.h"
@implementation OrangeredProvider
+ (instancetype)sharedInstance {
static OrangeredProvider *sharedInstance;
static dispatch_once_t provider_token = 0;
dispatch_once(&provider_token, ^{
sharedInstance = [[self alloc] init];
sharedInstance.factory = [[OrangeredProviderFactory alloc] init];
});
return sharedInstance;
}
- (NSString *)sectionDisplayName {
if ([self.customSectionID isEqualToString:@"com.apple.mobilesafari"]) {
return @"Safari";
}
return [[[[self sectionIdentifier] componentsSeparatedByString:@"."] lastObject] capitalizedString];
}
- (BBSectionInfo *)defaultSectionInfo {
BBSectionInfo *sectionInfo = [BBSectionInfo defaultSectionInfoForType:0];
sectionInfo.notificationCenterLimit = 10;
sectionInfo.sectionID = [self sectionIdentifier];
sectionInfo.allowsNotifications = YES;
sectionInfo.showsInNotificationCenter = YES;
sectionInfo.showsInLockScreen = YES;
sectionInfo.alertType = 1;
sectionInfo.pushSettings = 63;
return sectionInfo;
}
- (id)sectionIdentifier {
if (!self.customSectionID) {
for (NSString *s in [CLIENTS allKeys]) {
SBApplicationController *controller = (SBApplicationController *)[%c(SBApplicationController) sharedInstance];
if ([controller applicationWithBundleIdentifier:s]) {
return ((self.customSectionID = s));
}
}
return ((self.customSectionID = @"com.apple.mobilesafari"));
}
return self.customSectionID;
}
- (NSArray *)bulletinsFilteredBy:(NSUInteger)filter count:(NSUInteger)count lastCleared:(NSDate *)lastCleared {
return nil;
}
- (NSArray *)sortDescriptors {
return [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"date" ascending:NO]];
}
- (void)fireAway {
ORLOG(@"[Orangered] Sending check message from Timer...");
[[NSDistributedNotificationCenter defaultCenter] postNotificationName:kOrangeredCheckNotificationName object:nil userInfo:@{ @"sender" : @"Timer" }];
}
@end
@implementation OrangeredProviderFactory
- (id)dataProviders {
return @[[OrangeredProvider sharedInstance]];
}
- (NSString *)sectionDisplayName {
return [[self dataProviders][0] sectionDisplayName];
}
- (BBSectionInfo *)defaultSectionInfo {
return [[self dataProviders][0] defaultSectionInfo];
}
- (id)sectionIdentifier {
return [[self dataProviders][0] sectionIdentifier];
}
- (NSArray *)bulletinsFilteredBy:(NSUInteger)filter count:(NSUInteger)count lastCleared:(NSDate *)lastCleared {
return [[self dataProviders][0] bulletinsFilteredBy:filter count:count lastCleared:lastCleared];
}
- (NSArray *)sortDescriptors {
return [[self dataProviders][0] sortDescriptors];
}
@end