]> git.saurik.com Git - apple/security.git/blob - keychain/ot/OctagonPendingFlag.m
Security-59306.80.4.tar.gz
[apple/security.git] / keychain / ot / OctagonPendingFlag.m
1
2 #if OCTAGON
3
4 #import "keychain/ot/OctagonPendingFlag.h"
5
6 NSString* OctagonPendingConditionsToString(OctagonPendingConditions cond)
7 {
8 if((cond & OctagonPendingConditionsDeviceUnlocked) != 0x0) {
9 return @"unlock";
10 }
11 if(cond == 0x0) {
12 return @"none";
13 }
14 return [NSString stringWithFormat:@"Unknown conditions: 0x%x", (int)cond];
15 }
16
17 @implementation OctagonPendingFlag
18
19 - (instancetype)initWithFlag:(OctagonFlag*)flag delayInSeconds:(NSTimeInterval)delay
20 {
21 if ((self = [super init])) {
22 _flag = flag;
23 _fireTime = [NSDate dateWithTimeIntervalSinceNow:delay];
24 _conditions = 0;
25 }
26 return self;
27 }
28
29 - (instancetype)initWithFlag:(OctagonFlag*)flag
30 conditions:(OctagonPendingConditions)conditions
31 {
32 if ((self = [super init])) {
33 _flag = flag;
34 _fireTime = nil;
35 _conditions = conditions;
36 }
37 return self;
38 }
39
40 - (NSString*)description {
41 if(self.fireTime) {
42 return [NSString stringWithFormat:@"<OctagonPendingFlag: %@: %@>", self.flag, self.fireTime];
43 } else {
44 return [NSString stringWithFormat:@"<OctagonPendingFlag: %@: %@>", self.flag, OctagonPendingConditionsToString(self.conditions)];
45 }
46 }
47
48 @end
49
50 #endif // OCTAGON