]> git.saurik.com Git - apple/security.git/blob - CircleJoinRequested/Applicant.m
Security-59306.140.5.tar.gz
[apple/security.git] / CircleJoinRequested / Applicant.m
1 //
2 // Applicant.m
3 // Security
4 //
5 // Created by J Osborne on 3/7/13.
6 // Copyright (c) 2013 Apple Inc. All Rights Reserved.
7 //
8
9 #import "Applicant.h"
10 #include <utilities/SecCFRelease.h>
11
12 @implementation Applicant
13
14 -(id)initWithPeerInfo:(SOSPeerInfoRef)peerInfo
15 {
16 self = [super init];
17 if (!self) {
18 return self;
19 }
20
21 self.rawPeerInfo = CFRetainSafe(peerInfo);
22 self.applicantUIState = ApplicantWaiting;
23
24 return self;
25 }
26
27 -(NSString*)idString
28 {
29 return (__bridge NSString *)(SOSPeerInfoGetPeerID(self.rawPeerInfo));
30 }
31
32 -(NSString *)name
33 {
34 return (__bridge NSString *)(SOSPeerInfoGetPeerName(self.rawPeerInfo));
35 }
36
37 -(void)dealloc
38 {
39 if (self->_rawPeerInfo) {
40 CFRelease(self->_rawPeerInfo);
41 }
42 }
43
44 -(NSString *)description
45 {
46 return [NSString stringWithFormat:@"%@=%@", self.rawPeerInfo, self.applicantUIStateName];
47 }
48
49 -(NSString *)deviceType
50 {
51 return (__bridge NSString *)(SOSPeerInfoGetPeerDeviceType(self.rawPeerInfo));
52 }
53
54 -(NSString *)applicantUIStateName
55 {
56 switch (self.applicantUIState) {
57 case ApplicantWaiting:
58 return @"Waiting";
59
60 case ApplicantOnScreen:
61 return @"OnScreen";
62
63 case ApplicantRejected:
64 return @"Rejected";
65
66 case ApplicantAccepted:
67 return @"Accepted";
68
69 default:
70 return [NSString stringWithFormat:@"UnknownState#%d", self.applicantUIState];
71 }
72 }
73
74 @end