|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Interface for WIM Trust Settings Store |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "WimTrustSettingsAPI.h" |
|
22 #include "WimCertInfo.h" |
|
23 #include "WimTrustSettingsMgmt.h" |
|
24 #include "WimTrace.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CWimTrustSettingsAPI::CWimTrustSettingsAPI() |
|
30 // Default constructor. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CWimTrustSettingsAPI::CWimTrustSettingsAPI() : CActive( EPriorityNormal ) |
|
34 { |
|
35 CActiveScheduler::Add( this ); |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CWimTrustSettingsAPI::ConstructL() |
|
40 // Second phase constructor. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 void CWimTrustSettingsAPI::ConstructL() |
|
44 { |
|
45 _WIMTRACE ( _L( "CWimTrustSettingsAPI::ConstructL()" ) ); |
|
46 iConnectionHandle = RWimTrustSettingsMgmt::ClientSessionL(); |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CWimTrustSettingsAPI::NewL() |
|
51 // Two-phased constructor. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 EXPORT_C CWimTrustSettingsAPI* CWimTrustSettingsAPI::NewL() |
|
55 { |
|
56 _WIMTRACE ( _L( "CWimTrustSettingsAPI::NewL()" ) ); |
|
57 CWimTrustSettingsAPI* self = new( ELeave ) CWimTrustSettingsAPI; |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL(); |
|
60 CleanupStack::Pop( self ); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CWimTrustSettingsAPI::~CWimTrustSettingsAPI() |
|
66 // Destructor. If updates has been done, compact databse. |
|
67 // ----------------------------------------------------------------------------- |
|
68 |
|
69 EXPORT_C CWimTrustSettingsAPI::~CWimTrustSettingsAPI() |
|
70 { |
|
71 _WIMTRACE ( _L( "CWimTrustSettingsAPI::~CWimTrustSettingsAPI()" ) ); |
|
72 iConnectionHandle->Close(); |
|
73 delete iConnectionHandle; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CWimTrustSettingsAPI::Close() |
|
78 // Closes all open resources and deletes this instance of the TrustSettingsStore |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 EXPORT_C void CWimTrustSettingsAPI::Close() |
|
82 { |
|
83 _WIMTRACE ( _L( "CWimTrustSettingsAPI::Close()" ) ); |
|
84 delete ( this ); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CWimTrustSettingsAPI::GetTrustSettings() |
|
89 // Return trust settings for given certificate. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C void CWimTrustSettingsAPI::GetTrustSettings( |
|
93 const CWimCertInfo& aCert, |
|
94 TBool& aTrusted, |
|
95 RArray<TUid>& aApplications, |
|
96 TRequestStatus& aStatus ) |
|
97 { |
|
98 _WIMTRACE ( _L( "CWimTrustSettingsAPI::GetTrustSettings()" ) ); |
|
99 |
|
100 iApplications = &aApplications; |
|
101 iTrusted = &aTrusted; |
|
102 |
|
103 iClientStatus = &aStatus; |
|
104 iStatus = KRequestPending; |
|
105 iPhase = EGetTrustSettings; |
|
106 |
|
107 TRAPD( error, iConnectionHandle->GetTrustSettingsL( aCert, |
|
108 iStatus ) ); |
|
109 SetActive(); |
|
110 |
|
111 HandleLeaveError( error ); |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CWimTrustSettingsAPI::SetApplicability() |
|
116 // Set applicability for certificate. |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 EXPORT_C void CWimTrustSettingsAPI::SetApplicability( |
|
120 const CWimCertInfo& aCert, |
|
121 const RArray<TUid>& aApplications, |
|
122 TRequestStatus& aStatus ) |
|
123 { |
|
124 _WIMTRACE ( _L( "CWimTrustSettingsAPI::SetApplicability()" ) ); |
|
125 iClientStatus = &aStatus; |
|
126 iStatus = KRequestPending; |
|
127 iPhase = ESetApplicability; |
|
128 |
|
129 SetActive(); |
|
130 |
|
131 TRAPD( error, |
|
132 iConnectionHandle->SetApplicabilityL( aCert, aApplications, iStatus ) ); |
|
133 |
|
134 HandleLeaveError( error ); |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CWimTrustSettingsAPI::SetTrust() |
|
139 // Set trust flag for certificate. |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 EXPORT_C void CWimTrustSettingsAPI::SetTrust( |
|
143 const CWimCertInfo& aCert, |
|
144 TBool aTrusted, |
|
145 TRequestStatus& aStatus ) |
|
146 { |
|
147 _WIMTRACE ( _L( "CWimTrustSettingsAPI::SetTrust()" ) ); |
|
148 iClientStatus = &aStatus; |
|
149 iStatus = KRequestPending; |
|
150 iPhase = ESetTrust; |
|
151 |
|
152 TRAPD( error, iConnectionHandle->SetTrustL( aCert, aTrusted, iStatus ) ); |
|
153 SetActive(); |
|
154 HandleLeaveError( error ); |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CWimTrustSettingsAPI::SetDefaultTrustSettings() |
|
159 // Set default trust settings for certificate. |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C void CWimTrustSettingsAPI::SetDefaultTrustSettings( |
|
163 const CWimCertInfo& aCert, |
|
164 TBool aAddApps, |
|
165 TRequestStatus& aStatus ) |
|
166 { |
|
167 _WIMTRACE ( _L( "CWimTrustSettingsAPI::SetDefaultTrustSettings()" ) ); |
|
168 |
|
169 iClientStatus = &aStatus; |
|
170 iStatus = KRequestPending; |
|
171 iPhase = ESetDefaultTrustSettings; |
|
172 |
|
173 TRAPD( error, iConnectionHandle->SetDefaultTrustSettingsL( aCert, |
|
174 aAddApps, |
|
175 iStatus ) ); |
|
176 SetActive(); |
|
177 HandleLeaveError( error ); |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CWimTrustSettingsAPI::RemoveTrustSettings() |
|
182 // Remove trust settings of given certificate |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 EXPORT_C void CWimTrustSettingsAPI::RemoveTrustSettings( |
|
186 const CWimCertInfo& aCert, |
|
187 TRequestStatus& aStatus ) |
|
188 { |
|
189 _WIMTRACE( _L( "CWimTrustSettingsAPI::RemoveTrustSettings()" ) ); |
|
190 |
|
191 iClientStatus = &aStatus; |
|
192 iStatus = KRequestPending; |
|
193 iPhase = ERemoveTrustSettings; |
|
194 |
|
195 TRAPD( error, |
|
196 iConnectionHandle->RemoveTrustSettingsL( aCert, iStatus ) ); |
|
197 SetActive(); |
|
198 HandleLeaveError( error ); |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CWimTrustSettingsAPI::CancelDoing() |
|
203 // Cancel ongoing operation |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 EXPORT_C void CWimTrustSettingsAPI::CancelDoing() |
|
207 { |
|
208 _WIMTRACE( _L( "CWimTrustSettingsAPI::CancelDoing()" ) ); |
|
209 iConnectionHandle->CancelDoing(); |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CWimTrustSettingsAPI::RunL() |
|
214 // Handle result of asynchronous Trust Settings Store operation. |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 void CWimTrustSettingsAPI::RunL() |
|
218 { |
|
219 _WIMTRACE2( _L( "CWimTrustSettingsAPI::RunL(), iStatus=%d" ), |
|
220 iStatus.Int() ); |
|
221 |
|
222 switch ( iPhase ) |
|
223 { |
|
224 case EGetTrustSettings: |
|
225 { |
|
226 if ( iStatus.Int() == KErrNone ) |
|
227 { |
|
228 TPckgBuf<TTrustSettings> trustSettingsPckgBuf; |
|
229 |
|
230 trustSettingsPckgBuf = |
|
231 ( *iConnectionHandle->TrustSettingsPckg()->PckgBuf() ); |
|
232 |
|
233 TUid uid; |
|
234 |
|
235 for ( TInt i = 0; |
|
236 i < trustSettingsPckgBuf().iApplicationCount; i++ ) |
|
237 { |
|
238 uid.iUid = trustSettingsPckgBuf().iUids[i]; |
|
239 |
|
240 iApplications->Append( uid ); |
|
241 } |
|
242 *iTrusted = trustSettingsPckgBuf().iTrusted; |
|
243 } |
|
244 |
|
245 break; |
|
246 } |
|
247 |
|
248 default: |
|
249 { |
|
250 break; |
|
251 } |
|
252 } |
|
253 User::RequestComplete( iClientStatus, iStatus.Int() ); |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CWimTrustSettingsAPI::DoCancel() |
|
258 // |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void CWimTrustSettingsAPI::DoCancel() |
|
262 { |
|
263 |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // CWimTrustSettingsAPI::HandleLeaveError() |
|
268 // Handle trapped leave. Complete client request with error code. |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 void CWimTrustSettingsAPI::HandleLeaveError( TInt aError ) |
|
272 { |
|
273 _WIMTRACE2( _L( "CWimTrustSettingsAPI::HandleLeaveError(), aError=%d" ), |
|
274 aError ); |
|
275 if ( aError != KErrNone ) |
|
276 { |
|
277 TRequestStatus* status = &iStatus; |
|
278 User::RequestComplete( status, aError ); |
|
279 } |
|
280 } |
|
281 |
|
282 // End of File |