-
Notifications
You must be signed in to change notification settings - Fork 14
/
ActivatorIntegrationHelper.h
82 lines (64 loc) · 2.29 KB
/
ActivatorIntegrationHelper.h
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
#ifndef PASSBYACTIVATORHELPER_H
#define PASSBYACTIVATORHELPER_H
#include <libactivator/libactivator.h>
#define PASSBY_UNLOCK_LALISTENER_NAME "com.giorgioiavicoli.passby.unlock"
#define PASSBY_INVALIDATE_LALISTENER_NAME "com.giorgioiavicoli.passby.invalidate"
@interface PassByListener : NSObject <LAListener>
@end
@implementation PassByListener
- (void)activator:(LAActivator *)activator
receiveEvent:(LAEvent *)event
forListenerName:(NSString *)listenerName
{
if ([listenerName isEqualToString:@PASSBY_UNLOCK_LALISTENER_NAME]) {
unlockDevice(YES);
} else {
@synchronized(ManuallyDisabledSyncObj) {
isDisabledUntilNext = YES;
}
}
[event setHandled:YES];
}
- (NSString *)activator:(LAActivator *)activator
requiresLocalizedGroupForListenerName:(NSString *)listenerName
{
return @"PassBy";
}
- (NSString *)activator:(LAActivator *)activator
requiresLocalizedTitleForListenerName:(NSString *)listenerName
{
return
[listenerName isEqualToString:@PASSBY_UNLOCK_LALISTENER_NAME]
? @"PassBy Unlock"
: @"PassBy Disable Temporary";
}
- (NSString *)activator:(LAActivator *)activator
requiresLocalizedDescriptionForListenerName:(NSString *)listenerName
{
return
[listenerName isEqualToString:@PASSBY_UNLOCK_LALISTENER_NAME]
? @"Unlock the device and dismiss the lockscreen"
: @"Disable PassBy until next real unlock";
}
- (NSArray *)activator:(LAActivator *)activator
requiresCompatibleEventModesForListenerWithName:(NSString *)listenerName
{
return
[listenerName isEqualToString:@PASSBY_UNLOCK_LALISTENER_NAME]
? [NSArray arrayWithObjects:@"lockscreen", nil]
: [NSArray arrayWithObjects:@"springboard", @"lockscreen", @"application", nil];
}
- (NSData *)activator:(LAActivator *)activator
requiresIconDataForListenerName:(NSString *)listenerName
{
return [NSData dataWithContentsOfFile:@"/Library/PreferenceBundles/PassByPrefs.bundle/icon@2x.png"];
}
- (NSData *)activator:(LAActivator *)activator
requiresSmallIconDataForListenerName:(NSString *)listenerName
{
return [NSData dataWithContentsOfFile:@"/Library/PreferenceBundles/PassByPrefs.bundle/icon.png"];
}
@end
#else
#error "File already included"
#endif // PASSBYACTIVATORHELPER_H