-
Notifications
You must be signed in to change notification settings - Fork 10
/
IBWiFiNetwork.m
47 lines (39 loc) · 1.51 KB
/
IBWiFiNetwork.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
#import "IBWiFiNetwork.h"
@implementation IBWiFiNetwork
- (instancetype) initWithNetwork:(WiFiNetworkRef) network {
if(self = [super init]) {
self.name = (__bridge NSString *) WiFiNetworkGetSSID(network);
self.password = (__bridge NSString *) WiFiNetworkCopyPassword(network);
self.allRecords = (__bridge NSDictionary *) WiFiNetworkCopyRecord(network);
self.channel = [[self.allRecords objectForKey:@"CHANNEL"] integerValue];
self.added = [self.allRecords objectForKey:@"addedAt"];
self.isHidden = [[self.allRecords objectForKey:@"HIDDEN_NETWORK"] boolValue];
self.lastManualJoin = [self.allRecords objectForKey:@"lastJoined"];
self.lastAutoJoin = [self.allRecords objectForKey:@"lastAutoJoined"];
if (WiFiNetworkIsWEP(network)) {
self.encryption = WEP;
} else if (WiFiNetworkIsWPA(network)) {
self.encryption = WPA;
} else if (WiFiNetworkIsEAP(network)) {
self.encryption = EAP;
} else {
self.encryption = NONE;
}
}
return self;
}
- (NSDate *) lastJoinDate {
if (!self.lastManualJoin && !self.lastAutoJoin) {
return [NSDate dateWithTimeIntervalSince1970:0];
} else if ([self.lastManualJoin compare:self.lastAutoJoin] == NSOrderedDescending) {
return self.lastManualJoin;
}
return self.lastAutoJoin;
}
- (NSDate *) dateForSorting {
if (!self.added) {
return [NSDate dateWithTimeIntervalSince1970:0];
}
return self.added;
}
@end