|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : strtsimstatusmgr.cpp |
|
15 // Part of : System Startup / Starter |
|
16 // Implementation of TStrtSimStatusMgr class. |
|
17 // Version : %version: 7 % |
|
18 // This material, including documentation and any related computer |
|
19 // programs, is protected by copyright controlled by Nokia. All |
|
20 // rights are reserved. Copying, including reproducing, storing, |
|
21 // adapting or translating, any or all of this material requires the |
|
22 // prior written consent of Nokia. This material also contains |
|
23 // confidential information which may not be disclosed to others |
|
24 // without the prior written consent of Nokia. |
|
25 // Template version: 4.1 |
|
26 // Nokia Core OS * |
|
27 // |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 /** |
|
33 @file |
|
34 @internalComponent |
|
35 @released |
|
36 */ |
|
37 |
|
38 #include "ssmuiproviderdll.h" |
|
39 #include "swppolicy_simstatus.h" |
|
40 |
|
41 #include <ssm/ssmswppolicy.h> |
|
42 #include <ssm/ssmstatemanager.h> |
|
43 #include <ssm/ssmcommandlist.h> |
|
44 #include <ssm/startupdomainpskeys.h> |
|
45 #include <ssm/ssmcommandfactory.h> |
|
46 |
|
47 EXPORT_C MSsmSwpPolicy* CSimStatuspolicy::NewL() |
|
48 { |
|
49 CSimStatuspolicy* self = new (ELeave) CSimStatuspolicy; |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop(self); |
|
53 return self; |
|
54 } |
|
55 |
|
56 CSimStatuspolicy::CSimStatuspolicy() |
|
57 { |
|
58 } |
|
59 |
|
60 CSimStatuspolicy::~CSimStatuspolicy() |
|
61 { |
|
62 delete iCommandList; |
|
63 iProperty.Close(); |
|
64 } |
|
65 |
|
66 void CSimStatuspolicy::ConstructL() |
|
67 { |
|
68 User::LeaveIfError(iProperty.Attach(CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey())); |
|
69 } |
|
70 |
|
71 void CSimStatuspolicy::Initialize(TRequestStatus& aStatus) |
|
72 { |
|
73 TRequestStatus* rs = &aStatus; |
|
74 User::RequestComplete(rs, KErrNone); |
|
75 } |
|
76 |
|
77 void CSimStatuspolicy::InitializeCancel() |
|
78 { |
|
79 } |
|
80 |
|
81 void CSimStatuspolicy::Release() |
|
82 { |
|
83 delete this; |
|
84 } |
|
85 |
|
86 MSsmSwpPolicy::TResponse CSimStatuspolicy::TransitionAllowed(const TSsmSwp& aSwp, const RMessagePtr2& aMessage) |
|
87 { |
|
88 MSsmSwpPolicy::TResponse isTransitionAllowed = ENotAllowed; |
|
89 TBool hasCapability = aMessage.HasCapability(ECapabilityWriteDeviceData, __PLATSEC_DIAGNOSTIC_STRING( "Platsec violation for sim status transition" )); |
|
90 |
|
91 //Return as transition not allowed if it doesnt have sufficient capability |
|
92 if(!hasCapability) |
|
93 { |
|
94 return isTransitionAllowed; |
|
95 } |
|
96 |
|
97 switch (aSwp.Value()) |
|
98 { |
|
99 case ESimNotSupported: |
|
100 isTransitionAllowed = IsSimNotSupportedTransitionAllowed(); |
|
101 break; |
|
102 case ESimNotPresent: |
|
103 isTransitionAllowed = IsSimRemovedTransitionAllowed(); |
|
104 break; |
|
105 case ESimReadable: |
|
106 isTransitionAllowed = IsSimReadableTransitionAllowed(); |
|
107 break; |
|
108 case ESimUsable: |
|
109 isTransitionAllowed = IsSimUsableTransitionAllowed(); |
|
110 break; |
|
111 case ESimNotReady: |
|
112 isTransitionAllowed = EAllowed; |
|
113 break; |
|
114 } |
|
115 |
|
116 return isTransitionAllowed; |
|
117 } |
|
118 |
|
119 MSsmSwpPolicy::TResponse CSimStatuspolicy::IsSimReadableTransitionAllowed() |
|
120 { |
|
121 TInt simStatus; |
|
122 iProperty.Get(simStatus); |
|
123 |
|
124 if ((ESimStatusUninitialized == simStatus || |
|
125 ESimNotPresent == simStatus || |
|
126 ESimReadable == simStatus || |
|
127 (iSimHasBeenReadable && ESimUsable ==simStatus) || |
|
128 (iSimHasBeenReadable && ESimNotReady == simStatus) ) && |
|
129 CSsmUiSpecific::IsSimStateChangeAllowed()) |
|
130 { |
|
131 iSimHasBeenReadable = ETrue; |
|
132 return EAllowed; |
|
133 } |
|
134 return ENotAllowed; |
|
135 } |
|
136 |
|
137 MSsmSwpPolicy::TResponse CSimStatuspolicy::IsSimUsableTransitionAllowed() |
|
138 { |
|
139 TInt simStatus; |
|
140 iProperty.Get(simStatus); |
|
141 if ((ESimReadable == simStatus || |
|
142 ESimNotPresent == simStatus || |
|
143 ESimUsable == simStatus || |
|
144 (iSimHasBeenUsable && ESimNotReady ==simStatus)) && |
|
145 CSsmUiSpecific::IsSimStateChangeAllowed()) |
|
146 { |
|
147 iSimHasBeenUsable = ETrue; |
|
148 return EAllowed; |
|
149 } |
|
150 return ENotAllowed; |
|
151 } |
|
152 |
|
153 MSsmSwpPolicy::TResponse CSimStatuspolicy::IsSimNotSupportedTransitionAllowed() |
|
154 { |
|
155 TInt simStatus; |
|
156 iProperty.Get(simStatus); |
|
157 if (ESimStatusUninitialized == simStatus || |
|
158 ESimNotSupported == simStatus) |
|
159 { |
|
160 return EAllowed; |
|
161 } |
|
162 return ENotAllowed; |
|
163 } |
|
164 |
|
165 MSsmSwpPolicy::TResponse CSimStatuspolicy::IsSimRemovedTransitionAllowed() |
|
166 { |
|
167 TInt simStatus; |
|
168 iProperty.Get(simStatus); |
|
169 |
|
170 if ((ESimStatusUninitialized == simStatus || |
|
171 ESimUsable == simStatus || |
|
172 ESimReadable == simStatus || |
|
173 ESimNotReady == simStatus || |
|
174 ESimNotPresent == simStatus) && |
|
175 CSsmUiSpecific::IsSimStateChangeAllowed()) |
|
176 { |
|
177 return EAllowed; |
|
178 } |
|
179 return ENotAllowed; |
|
180 } |
|
181 |
|
182 void CSimStatuspolicy::PrepareCommandList(const TSsmSwp& aSwp, TRequestStatus& aStatus) |
|
183 { |
|
184 TRAPD(err, DoPrepareCommandListL(aSwp)); |
|
185 TRequestStatus* rs = &aStatus; |
|
186 User::RequestComplete(rs, err); |
|
187 } |
|
188 |
|
189 void CSimStatuspolicy::DoPrepareCommandListL(const TSsmSwp& aSwp) |
|
190 { |
|
191 // Reset the command list |
|
192 delete iCommandList; |
|
193 iCommandList = NULL; |
|
194 iCommandList = CSsmCommandList::NewL(); |
|
195 |
|
196 // Create a PS command to change the sim status PS for compatibility reasons |
|
197 MSsmCommand* cmdPS = SsmCommandFactory::ConstructSetPAndSKeyCommandLC(ECmdCriticalSeverity, CSsmUiSpecific::StartupPSUid(), CSsmUiSpecific::SimStatusPropertyKey(), aSwp.Value()); |
|
198 iCommandList->AppendL(cmdPS); |
|
199 CleanupStack::Pop(cmdPS); |
|
200 |
|
201 // Create a command to publish the SwP value |
|
202 MSsmCommand* cmdSwp = SsmCommandFactory::ConstructPublishSwpCommandLC(ECmdCriticalSeverity, ESsmWaitForSignal, aSwp); |
|
203 iCommandList->AppendL(cmdSwp); |
|
204 CleanupStack::Pop(cmdSwp); |
|
205 } |
|
206 |
|
207 void CSimStatuspolicy::PrepareCommandListCancel() |
|
208 { |
|
209 delete iCommandList; |
|
210 iCommandList = NULL; |
|
211 } |
|
212 |
|
213 CSsmCommandList* CSimStatuspolicy::CommandList() |
|
214 { |
|
215 CSsmCommandList* list = iCommandList; |
|
216 iCommandList = NULL; |
|
217 return list; |
|
218 } |
|
219 |
|
220 void CSimStatuspolicy::HandleCleReturnValue(const TSsmSwp& aSwp, TInt aError, TInt aSeverity, TRequestStatus& aStatus) |
|
221 { |
|
222 (void)aSwp; |
|
223 (void)aSeverity; |
|
224 |
|
225 TRequestStatus* rs = &aStatus; |
|
226 User::RequestComplete(rs, aError); |
|
227 } |
|
228 |
|
229 void CSimStatuspolicy::HandleCleReturnValueCancel() |
|
230 { |
|
231 } |