API  0.9.6
 All Classes Files Functions Variables Macros Groups Pages
CPUserSessionManager.j
Go to the documentation of this file.
1 /*
2  * CPUserSessionManager.j
3  * Foundation
4  *
5  * Created by Francisco Tolmasky.
6  * Copyright 2008, 280 North, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
27 
28 CPUserSessionManagerStatusDidChangeNotification = @"CPUserSessionManagerStatusDidChangeNotification";
29 CPUserSessionManagerUserIdentifierDidChangeNotification = @"CPUserSessionManagerUserIdentifierDidChangeNotification";
30 
32 
33 @implementation CPUserSessionManager : CPObject
34 {
35  CPUserSessionStatus _status;
36 
37  CPString _userIdentifier;
38 }
39 
40 + (id)defaultManager
41 {
44 
46 }
47 
48 - (id)init
49 {
50  self = [super init];
51 
52  if (self)
54 
55  return self;
56 }
57 
58 - (CPUserSessionStatus)status
59 {
60  return _status;
61 }
62 
63 - (void)setStatus:(CPUserSessionStatus)aStatus
64 {
65  if (_status == aStatus)
66  return;
67 
68  _status = aStatus;
69 
71  postNotificationName:CPUserSessionManagerStatusDidChangeNotification
72  object:self];
73 
74  if (_status != CPUserSessionLoggedInStatus)
75  [self setUserIdentifier:nil];
76 }
77 
78 - (CPString)userIdentifier
79 {
80  return _userIdentifier;
81 }
82 
83 - (void)setUserIdentifier:(CPString)anIdentifier
84 {
85  if (_userIdentifier == anIdentifier)
86  return;
87 
88  _userIdentifier = anIdentifier;
89 
91  postNotificationName:CPUserSessionManagerUserIdentifierDidChangeNotification
92  object:self];
93 }
94 
95 @end