API  1.0.0
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 
24 @typedef CPUserSessionStatus
28 
29 CPUserSessionManagerStatusDidChangeNotification = @"CPUserSessionManagerStatusDidChangeNotification";
30 CPUserSessionManagerUserIdentifierDidChangeNotification = @"CPUserSessionManagerUserIdentifierDidChangeNotification";
31 
33 
34 @implementation CPUserSessionManager : CPObject
35 {
36  CPUserSessionStatus _status;
37 
38  CPString _userIdentifier;
39 }
40 
41 + (id)defaultManager
42 {
45 
47 }
48 
49 - (id)init
50 {
51  self = [super init];
52 
53  if (self)
55 
56  return self;
57 }
58 
59 - (CPUserSessionStatus)status
60 {
61  return _status;
62 }
63 
64 - (void)setStatus:(CPUserSessionStatus)aStatus
65 {
66  if (_status == aStatus)
67  return;
68 
69  _status = aStatus;
70 
72  postNotificationName:CPUserSessionManagerStatusDidChangeNotification
73  object:self];
74 
75  if (_status != CPUserSessionLoggedInStatus)
76  [self setUserIdentifier:nil];
77 }
78 
79 - (CPString)userIdentifier
80 {
81  return _userIdentifier;
82 }
83 
84 - (void)setUserIdentifier:(CPString)anIdentifier
85 {
86  if (_userIdentifier == anIdentifier)
87  return;
88 
89  _userIdentifier = anIdentifier;
90 
92  postNotificationName:CPUserSessionManagerUserIdentifierDidChangeNotification
93  object:self];
94 }
95 
96 @end
id init()
Definition: CALayer.j:126
void postNotificationName:object:(CPString aNotificationName, [object] id anObject)
CPNotificationCenter defaultCenter()
var CPDefaultUserSessionManager
void setUserIdentifier:(CPString anIdentifier)
An immutable string (collection of characters).
Definition: CPString.h:2
CPUserSessionLoggedInStatus
CPUserSessionLoggedOutStatus
id init()
Definition: CPObject.j:145
Sends messages (CPNotification) between objects.
CPUserSessionManagerUserIdentifierDidChangeNotification
CPUserSessionManagerStatusDidChangeNotification
CPUserSessionStatus CPUserSessionUndeterminedStatus
id alloc()
Definition: CPObject.j:130