]> git.saurik.com Git - apple/security.git/blob - CircleJoinRequested/Applicant.m
Security-59754.41.1.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 if ((self = [super init])) {
17 self.rawPeerInfo = CFRetainSafe(peerInfo);
18 self.applicantUIState = ApplicantWaiting;
19 }
20 return self;
21 }
22
23 -(NSString*)idString
24 {
25 return (__bridge NSString *)(SOSPeerInfoGetPeerID(self.rawPeerInfo));
26 }
27
28 -(NSString *)name
29 {
30 return (__bridge NSString *)(SOSPeerInfoGetPeerName(self.rawPeerInfo));
31 }
32
33 -(void)dealloc
34 {
35 if (self->_rawPeerInfo) {
36 CFRelease(self->_rawPeerInfo);
37 }
38 }
39
40 -(NSString *)description
41 {
42 return [NSString stringWithFormat:@"%@=%@", self.rawPeerInfo, self.applicantUIStateName];
43 }
44
45 -(NSString *)deviceType
46 {
47 return (__bridge NSString *)(SOSPeerInfoGetPeerDeviceType(self.rawPeerInfo));
48 }
49
50 -(NSString *)applicantUIStateName
51 {
52 switch (self.applicantUIState) {
53 case ApplicantWaiting:
54 return @"Waiting";
55
56 case ApplicantOnScreen:
57 return @"OnScreen";
58
59 case ApplicantRejected:
60 return @"Rejected";
61
62 case ApplicantAccepted:
63 return @"Accepted";
64
65 default:
66 return [NSString stringWithFormat:@"UnknownState#%d", self.applicantUIState];
67 }
68 }
69
70 @end