|
1 /* |
|
2 * Copyright (c) 2002 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: Startup place for client & server, message handling. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //INCLUDES |
|
20 #include "WimMgmt.h" |
|
21 #include "WimTrace.h" |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // RWimMgmt::RWimMgmt() |
|
25 // Default constructor |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 RWimMgmt::RWimMgmt() |
|
29 { |
|
30 _WIMTRACE ( _L( "RWimMgmt::RWimMgmt()" ) ); |
|
31 iPinStateRequestBufAllocated = EFalse; |
|
32 iPinParamsBufAllocated = EFalse; |
|
33 iPinInfoLstPtr = NULL; |
|
34 iPinModule = NULL; |
|
35 } |
|
36 |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // RWimMgmt::~RWimMgmt() |
|
40 // Destructor |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 RWimMgmt::~RWimMgmt() |
|
44 { |
|
45 _WIMTRACE ( _L( "RWimMgmt::~RWimMgmt()" ) ); |
|
46 delete iPinInfoLstPtr; |
|
47 delete iPinModule; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // RWimMgmt::WIMCount() |
|
52 // Returns TUint - the number of WIMs |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 TUint RWimMgmt::WIMCount() |
|
56 { |
|
57 _WIMTRACE ( _L( "RWimMgmt::WIMCount()" ) ); |
|
58 |
|
59 TPckgBuf<TUint> pckg; |
|
60 |
|
61 TIpcArgs args; |
|
62 args.Set( 0, &pckg ); |
|
63 |
|
64 if ( SendReceiveData( EGetWIMCount, args ) == KErrNone ) |
|
65 { |
|
66 return pckg(); |
|
67 } |
|
68 else |
|
69 { |
|
70 return 0; |
|
71 } |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // RWimMgmt::IsOpen() |
|
76 // Tests whether WIM is open or not. |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 TBool RWimMgmt::IsOpen( const TWimAddress aWimAddr ) |
|
80 { |
|
81 _WIMTRACE ( _L( "RWimMgmt::IsOpen()" ) ); |
|
82 |
|
83 TPckgBuf<TBool> pckg; |
|
84 |
|
85 TIpcArgs args; |
|
86 args.Set( 0, aWimAddr ); |
|
87 args.Set( 1, &pckg ); |
|
88 |
|
89 SendReceiveData( EIsWIMOpen, args ); |
|
90 |
|
91 return pckg(); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // RWimMgmt::CloseWIM() |
|
96 // Closes the WIM and returns the status of the WIMI_CloseWIM() |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TInt RWimMgmt::CloseWIM( const TWimAddress aWimAddr ) |
|
100 { |
|
101 _WIMTRACE ( _L( "RWimMgmt::CloseWIM()" ) ); |
|
102 |
|
103 TIpcArgs args; |
|
104 args.Set( 0, aWimAddr ); |
|
105 |
|
106 return SendReceiveData( EWIMClose, args ); |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // RWimMgmt::CloseAfter() |
|
111 // Returns the time which is set as WIM closeout time |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 TInt RWimMgmt::CloseAfter() |
|
115 { |
|
116 _WIMTRACE ( _L( "RWimMgmt::CloseAfter()" ) ); |
|
117 |
|
118 TPckgBuf<TInt> pckg; |
|
119 |
|
120 TIpcArgs args; |
|
121 args.Set( 0, &pckg ); |
|
122 |
|
123 if ( SendReceiveData( EGetCloseWIMAfter, args ) == KErrNone ) |
|
124 { |
|
125 return pckg(); |
|
126 } |
|
127 else |
|
128 { |
|
129 return 0; |
|
130 } |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // RWimMgmt::CloseAfter() |
|
135 // Returns TUint - the timeout in minutes, which tells how long |
|
136 // WIM Security Module will be open |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 TInt RWimMgmt::TimeRemaining() |
|
140 { |
|
141 _WIMTRACE ( _L( "RWimMgmt::TimeRemaining()" ) ); |
|
142 |
|
143 TPckgBuf<TInt> pckg; |
|
144 |
|
145 TIpcArgs args; |
|
146 args.Set( 0, &pckg ); |
|
147 |
|
148 if ( SendReceiveData( EWimTimeRemaining, args ) == KErrNone ) |
|
149 { |
|
150 return pckg(); |
|
151 } |
|
152 else |
|
153 { |
|
154 return 0; |
|
155 } |
|
156 } |
|
157 // ----------------------------------------------------------------------------- |
|
158 // RWimMgmt::SetCloseAfter() |
|
159 // Sets closing time for WIM. |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void RWimMgmt::SetCloseAfter( const TUint aCloseAfter ) |
|
163 { |
|
164 _WIMTRACE ( _L( "RWimMgmt::SetCloseAfter()" ) ); |
|
165 |
|
166 TIpcArgs args; |
|
167 args.Set( 0, aCloseAfter ); |
|
168 |
|
169 SendReceiveData( ECloseWIMAfter, args ); |
|
170 } |
|
171 |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // RWimMgmt::WIMRefs() |
|
175 // Gets the array of WIM structures. aCount is the number of WIMs |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 TInt RWimMgmt::WIMRefs( TWimAddressList aWimAddrLst, TUint8 aCount ) |
|
179 { |
|
180 _WIMTRACE ( _L( "RWimMgmt::WIMRefs()" ) ); |
|
181 |
|
182 TInt length = ( TInt )( aCount * sizeof( TWimAddress ) ); |
|
183 TPtr8 pt( ( TUint8* )aWimAddrLst, length, length ); |
|
184 |
|
185 TIpcArgs args; |
|
186 args.Set( 0, &pt ); |
|
187 |
|
188 return SendReceiveData( EGetWIMRefs, args ); |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // RWimMgmt::WIMInfo() |
|
193 // Gets the WIM information in to aTWimSecModuleStruct |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 TInt RWimMgmt::WIMInfo( const TWimAddress aWimAddr, |
|
197 TWimSecModuleStruct& aTWimSecModuleStruct ) |
|
198 { |
|
199 _WIMTRACE ( _L( "RWimMgmt::WIMInfo()" ) ); |
|
200 |
|
201 TPckg<TWimSecModuleStruct> wimModule( aTWimSecModuleStruct ); |
|
202 |
|
203 TIpcArgs args; |
|
204 args.Set( 0, aWimAddr ); |
|
205 args.Set( 1, &wimModule ); |
|
206 |
|
207 return SendReceiveData( EGetWIMInfo, args ); |
|
208 } |
|
209 |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // RWimMgmt::PINCount() |
|
213 // Returns TUint - the number of PINs |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 TUint RWimMgmt::PINCount( const TWimAddress aWimAddr ) |
|
217 { |
|
218 _WIMTRACE ( _L( "RWimMgmt::PINCount()" ) ); |
|
219 |
|
220 TPckgBuf<TUint> pckg; |
|
221 |
|
222 TIpcArgs args; |
|
223 args.Set( 0, aWimAddr ); |
|
224 args.Set( 1, &pckg ); |
|
225 |
|
226 if ( SendReceiveData( EGetPINCount, args ) == KErrNone ) |
|
227 { |
|
228 return pckg(); |
|
229 } |
|
230 else |
|
231 { |
|
232 return 0; |
|
233 } |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // RWimMgmt::IsBlocked() |
|
238 // Checks is PIN blocked or not. |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 TInt RWimMgmt::IsBlocked( const TPinAddress aPinAddr ) |
|
242 { |
|
243 _WIMTRACE ( _L( "RWimMgmt::IsBlocked()" ) ); |
|
244 |
|
245 TIpcArgs args; |
|
246 args.Set( 0, aPinAddr ); |
|
247 |
|
248 return SendReceiveData( EIsPinBlocked, args ); |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // RWimMgmt::IsDisabledPINBlocked() |
|
253 // Checks is PIN blocked or not. |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 TInt RWimMgmt::IsDisabledPINBlocked( const TPinAddress aPinAddr ) |
|
257 { |
|
258 _WIMTRACE ( _L( "RWimMgmt::IsDisabledPINBlocked()" ) ); |
|
259 |
|
260 TIpcArgs args; |
|
261 args.Set( 0, aPinAddr ); |
|
262 |
|
263 return SendReceiveData( EIsDisabledPinBlocked, args ); |
|
264 } |
|
265 |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // RWimMgmt::PINInfo() |
|
269 // Gets the PIN information in to rPinStruct |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 void RWimMgmt::PINInfo( const TPinAddress aPinAddr, |
|
273 TWimPinStruct& aPinStruct, |
|
274 TRequestStatus& aStatus ) |
|
275 { |
|
276 _WIMTRACE ( _L( "RWimMgmt::PINInfo()" ) ); |
|
277 |
|
278 if( iPinModule != NULL ) |
|
279 { |
|
280 delete iPinModule; |
|
281 iPinModule = NULL; |
|
282 } |
|
283 |
|
284 iPinModule = new TPckg<TWimPinStruct>( aPinStruct ); |
|
285 |
|
286 TIpcArgs args; |
|
287 args.Set( 0, aPinAddr ); |
|
288 args.Set( 1, iPinModule ); |
|
289 |
|
290 SendReceiveData( EGetPINInfo, args, aStatus ); |
|
291 } |
|
292 |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // RWimMgmt::PINRefs() |
|
296 // Gets the array of PIN structures. |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 TInt RWimMgmt::PINRefs( const TWimAddress aWimAddr, |
|
300 TUint32& aPinLstAddr, |
|
301 TPinAddressList aPinAddrLst, |
|
302 TUint8 aCount ) |
|
303 { |
|
304 _WIMTRACE ( _L( "RWimMgmt::PINRefs()" ) ); |
|
305 TInt status = 0; |
|
306 |
|
307 TInt16 length = ( TInt16 ) ( aCount * sizeof( TWimAddress ) ); |
|
308 TPtr8 pt( ( TUint8* ) aPinAddrLst, length, length ); |
|
309 TPckgBuf<TUint32> lstAddr; |
|
310 |
|
311 TIpcArgs args; |
|
312 args.Set( 0, aWimAddr ); |
|
313 args.Set( 1, &lstAddr ); |
|
314 args.Set( 2, &pt ); |
|
315 |
|
316 status = SendReceiveData( EGetPINRefs, args ); |
|
317 |
|
318 if ( status == KErrNone ) |
|
319 { |
|
320 aPinLstAddr = lstAddr(); |
|
321 } |
|
322 else |
|
323 { |
|
324 aPinLstAddr = NULL; |
|
325 } |
|
326 |
|
327 return status; |
|
328 } |
|
329 |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // RWimMgmt::PINsInfo() Asynchronous |
|
333 // Initialize elements in PinNR array |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 void RWimMgmt::PINsInfo( const TWimAddress aWimAddr, |
|
337 CArrayFixFlat<TWimPinStruct>& aPinInfoLst, |
|
338 TUint8 aCount, |
|
339 TRequestStatus& aStatus ) |
|
340 { |
|
341 _WIMTRACE ( _L( "RWimMgmt::PINsInfo()" ) ); |
|
342 TInt16 length = ( TInt16 ) ( aCount * sizeof( TWimPinStruct ) ); |
|
343 |
|
344 if( iPinInfoLstPtr == NULL ) |
|
345 { |
|
346 iPinInfoLstPtr = new TPtr8( (TText8*)&aPinInfoLst[0],length, length ); |
|
347 } |
|
348 else |
|
349 { |
|
350 iPinInfoLstPtr->Set( (TText8*)&aPinInfoLst[0], length, length ); |
|
351 } |
|
352 |
|
353 TIpcArgs args; |
|
354 args.Set( 0, aWimAddr ); |
|
355 args.Set( 1, iPinInfoLstPtr ); |
|
356 args.Set( 2, aCount ); |
|
357 |
|
358 aStatus = KRequestPending; |
|
359 SendReceiveData( EGetPINsInfo, args, aStatus ); |
|
360 } |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // RWimMgmt::PINsInfo() Synchronous |
|
364 // Initialize elements in PinNR array |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 TInt RWimMgmt::PINsInfo( const TWimAddress aWimAddr, |
|
368 CArrayFixFlat<TWimPinStruct>& aPinInfoLst, |
|
369 TUint8 aCount ) |
|
370 { |
|
371 _WIMTRACE ( _L( "RWimMgmt::PINsInfo() synchronous" ) ); |
|
372 |
|
373 TInt16 length = ( TInt16 ) ( aCount * sizeof( TWimPinStruct ) ); |
|
374 |
|
375 if( iPinInfoLstPtr == NULL ) |
|
376 { |
|
377 iPinInfoLstPtr = new TPtr8( (TText8*)&aPinInfoLst[0],length,length ); |
|
378 } |
|
379 else |
|
380 { |
|
381 iPinInfoLstPtr->Set( (TText8*)&aPinInfoLst[0], length, length ); |
|
382 } |
|
383 |
|
384 TIpcArgs args; |
|
385 args.Set( 0, aWimAddr ); |
|
386 args.Set( 1, iPinInfoLstPtr ); |
|
387 args.Set( 2, aCount ); |
|
388 |
|
389 return SendReceiveData( EGetPINsInfo, args ); |
|
390 |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // RWimMgmt::EnableDisablePinQueryL() |
|
395 // Handles Enable and Disable PIN requests. Server |
|
396 // knows wanted operation by flag which is set in TPINStateRequest. |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 void RWimMgmt::EnableDisablePinQueryL( const TPinAddress aPinAddr, |
|
400 const TPINStateRequest& aPinStateRequest, |
|
401 const TPINParams& aPinParams, |
|
402 TRequestStatus& aStatus ) |
|
403 { |
|
404 _WIMTRACE ( _L( "RWimMgmt::EnableDisablePinQuery()" ) ); |
|
405 |
|
406 iPinStateRequestBuf = new( ELeave ) |
|
407 CWimCertPckgBuf<TPINStateRequest>( aPinStateRequest ); |
|
408 iPinStateRequestBufAllocated = ETrue; |
|
409 |
|
410 iPinParamsBuf = new( ELeave ) |
|
411 CWimCertPckgBuf<TPINParams>( aPinParams ); |
|
412 iPinParamsBufAllocated = ETrue; |
|
413 |
|
414 TIpcArgs args; |
|
415 args.Set( 0, aPinAddr ); |
|
416 args.Set( 1, iPinStateRequestBuf->PckgBuf() ); |
|
417 args.Set( 2, iPinParamsBuf->PckgBuf() ); |
|
418 |
|
419 aStatus = KRequestPending; |
|
420 SendReceiveData( EEnablePINReq, args, aStatus ); |
|
421 } |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // RWimMgmt::CancelEnableDisablePinQueryL() |
|
425 // Cancel Enable and Disable PIN requests. Server |
|
426 // knows wanted operation by flag which is set in TPINStateRequest. |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 void RWimMgmt::CancelEnableDisablePin( const TPinAddress aPinAddr ) |
|
430 { |
|
431 _WIMTRACE ( _L( "RWimMgmt::CancelEnableDisablePinQuery()" ) ); |
|
432 TIpcArgs args; |
|
433 args.Set( 0, aPinAddr ); |
|
434 SendReceiveData( ECancelEnablePin, args ); |
|
435 } |
|
436 |
|
437 |
|
438 // ----------------------------------------------------------------------------- |
|
439 // RWimMgmt::DeallocMemoryFromEnableDisablePinQuery() |
|
440 // Deallocates memory from pckgBuf member variables |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 void RWimMgmt::DeallocMemoryFromEnableDisablePinQuery() |
|
444 { |
|
445 _WIMTRACE ( _L( "RWimMgmt::DeallocMemoryFromEnableDisablePinQuery()" ) ); |
|
446 |
|
447 if ( iPinStateRequestBufAllocated ) |
|
448 { |
|
449 delete iPinStateRequestBuf; |
|
450 iPinStateRequestBuf = NULL; |
|
451 iPinStateRequestBufAllocated = EFalse; |
|
452 } |
|
453 if ( iPinParamsBufAllocated ) |
|
454 { |
|
455 delete iPinParamsBuf; |
|
456 iPinParamsBuf = NULL; |
|
457 iPinParamsBufAllocated = EFalse; |
|
458 } |
|
459 } |
|
460 |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // RWimMgmt::PinOperationL() |
|
464 // PinOperationL handles several PIN operations: it can be |
|
465 // verify PIN request, change PIN request or unblock PIN request. The |
|
466 // type of request is handled via aOpCode. |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 void RWimMgmt::PinOperationL( const TPinAddress aPinAddr, |
|
470 const TPINParams aPinParams, |
|
471 const TWimServRqst aOpCode, |
|
472 TRequestStatus& aStatus ) |
|
473 { |
|
474 _WIMTRACE ( _L( "RWimMgmt::PinOperationL" ) ); |
|
475 |
|
476 iPinParamsBuf = new( ELeave ) CWimCertPckgBuf<TPINParams>( aPinParams ); |
|
477 iPinParamsBufAllocated = ETrue; |
|
478 |
|
479 TIpcArgs args; |
|
480 args.Set( 0, aPinAddr ); |
|
481 args.Set( 1, iPinParamsBuf->PckgBuf() ); |
|
482 |
|
483 aStatus = KRequestPending; |
|
484 SendReceiveData( aOpCode, args, aStatus ); |
|
485 } |
|
486 |
|
487 // ----------------------------------------------------------------------------- |
|
488 // RWimMgmt::CancelPinOperationL() |
|
489 // PinOperationL handles several PIN operations: it can be |
|
490 // verify PIN request, change PIN request or unblock PIN request. The |
|
491 // type of request is handled via aOpCode. |
|
492 // ----------------------------------------------------------------------------- |
|
493 // |
|
494 void RWimMgmt::CancelPinOperation( const TPinAddress aPinAddr, |
|
495 const TWimServRqst aOpCode ) |
|
496 { |
|
497 _WIMTRACE ( _L( "RWimMgmt::CancelPinOperation" ) ); |
|
498 TIpcArgs args; |
|
499 args.Set( 0, aPinAddr ); |
|
500 SendReceiveData( aOpCode, args ); |
|
501 } |
|
502 |
|
503 // ----------------------------------------------------------------------------- |
|
504 // RWimMgmt::ClientSessionL() |
|
505 // Returns new RWimMgmt object |
|
506 // ----------------------------------------------------------------------------- |
|
507 // |
|
508 RWimMgmt* RWimMgmt::ClientSessionL() |
|
509 { |
|
510 _WIMTRACE ( _L( "RWimMgmt::ClientSessionL()" ) ); |
|
511 return new( ELeave ) RWimMgmt(); |
|
512 } |
|
513 |
|
514 // End of File |