1 /* |
|
2 * Copyright (c) 2005 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: SW Installer DM Adapter. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE |
|
19 #include <implementationproxy.h> |
|
20 #include <smldmadapter.h> |
|
21 #include <data_caging_path_literals.hrh> |
|
22 #include <centralrepository.h> |
|
23 #include <hwrmpowerstatesdkpskeys.h> // For power state |
|
24 #include <DevEncExternalCRKeys.h> |
|
25 #include <DevEncDef.h> |
|
26 #include "DevEncLog.h" |
|
27 #include "DevEncAdapter.h" |
|
28 #include "DevEncUids.hrh" |
|
29 |
|
30 |
|
31 // CONSTANTS |
|
32 _LIT8( KIntType,"int" ); // Leaf inputs |
|
33 _LIT8( KTextType,"text/plain" ); // Leaf inputs |
|
34 _LIT8( KDevEncAdapterVersion, "1.0" ); // Adapter version |
|
35 _LIT8( KDevEncRootNode, "DevEnc" ); // root URI |
|
36 _LIT8( KPhoneMemoryCmdNode, "PhoneMemoryCmd" ); // URI postfix |
|
37 _LIT8( KMemoryCardCmdNode, "MemoryCardCmd" ); // URI postfix |
|
38 _LIT8( KPhoneMemoryStatusNode, "PhoneMemoryStatus" ); // URI postfix |
|
39 _LIT8( KMemoryCardStatusNode, "MemoryCardStatus" ); // URI postfix |
|
40 _LIT8( KMemoryCardEncKeyNode, "MemoryCardEncKey" ); // URI postfix |
|
41 _LIT8( KUIStateNode, "UIState" ); // URI postfix |
|
42 _LIT8( KPhoneMemoryProgNode, "PhoneMemoryProgress" ); // URI postfix |
|
43 _LIT8( KMemoryCardProgNode, "MemoryCardProgress" ); // URI postfix |
|
44 _LIT8( KPhoneMemoryCmdDescription, "Phone memory encryption command" ); // Description |
|
45 _LIT8( KMemoryCardCmdDescription, "Memory card encryption command" ); // Description |
|
46 _LIT8( KPhoneMemoryStatusDescription, "Phone memory encryption status" ); // Description |
|
47 _LIT8( KMemoryCardStatusDescription, "Memory card encryption status" ); // Description |
|
48 _LIT8( KMemoryCardEncKeyDescription, "Memory card encryption key" ); // Description |
|
49 _LIT8( KUIStateDescription, "State of encryption settings" ); // Description |
|
50 _LIT8( KPhoneMemoryProgDescription, "En/Decryption progress in percents (phone)" ); // Description |
|
51 _LIT8( KMemoryCardProgDescription, "En/Decryption progress in percents (memory card)" ); // Description |
|
52 _LIT8( KSeparator, "/" ); |
|
53 |
|
54 static const TUint32 KSizeOfSettingId = 16; // Contanst size declaration |
|
55 static const TInt KBufGranularity = 8; |
|
56 static const TDriveNumber KPhoneMemoryDriveNum = EDriveC; |
|
57 static const TDriveNumber KMemoryCardDriveNum = EDriveF; |
|
58 static const TUid KPSCategory = { 0x101F9A02 }; // DM client SID |
|
59 static const TInt KPkcs5PSKey = KDevEncOmaDmPluginImplUid; |
|
60 |
|
61 // ============================= MEMBER FUNCTIONS ============================= |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // CDevEncAdapter::NewL |
|
65 // Symbian 1st phase contructor |
|
66 // (static, may leave) |
|
67 // Status : Draft |
|
68 // ---------------------------------------------------------------------------- |
|
69 // |
|
70 CDevEncAdapter* CDevEncAdapter::NewL( MSmlDmCallback* aCallback ) |
|
71 { |
|
72 CDevEncAdapter* self = NewLC( aCallback ); |
|
73 CleanupStack::Pop( self ); |
|
74 return self; |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // CDevEncAdapter::NewLC |
|
79 // Symbian 1st phase contructor. Push object to cleanup-stack |
|
80 // (static, may leave) |
|
81 // Status : Draft |
|
82 // ---------------------------------------------------------------------------- |
|
83 // |
|
84 CDevEncAdapter* CDevEncAdapter::NewLC( MSmlDmCallback* aCallback ) |
|
85 { |
|
86 CDevEncAdapter* self = new ( ELeave ) CDevEncAdapter( aCallback ); |
|
87 CleanupStack::PushL( self ); |
|
88 self->ConstructL(); |
|
89 return self; |
|
90 } |
|
91 |
|
92 // ---------------------------------------------------------------------------- |
|
93 // CDevEncAdapter::CDevEncAdapter() |
|
94 // C++ Constructor |
|
95 // Status : Draft |
|
96 // ---------------------------------------------------------------------------- |
|
97 CDevEncAdapter::CDevEncAdapter( TAny* aEcomArguments ) |
|
98 : CSmlDmAdapter::CSmlDmAdapter( aEcomArguments ), |
|
99 iPhoneMemOpPending( EFalse ), |
|
100 iMemCardOpPending( EFalse ) |
|
101 { |
|
102 DFLOG( "CDevEncAdapter Constructor" ); |
|
103 } |
|
104 |
|
105 // ---------------------------------------------------------------------------- |
|
106 // CDevEncAdapter::ConstructL |
|
107 // 2nd phase contructor |
|
108 // (may leave) |
|
109 // Status : Draft |
|
110 // ---------------------------------------------------------------------------- |
|
111 // |
|
112 void CDevEncAdapter::ConstructL() |
|
113 { |
|
114 DFLOG( "CDevEncAdapter::ConstructL Begin" ); |
|
115 iDiskUtils = new (ELeave) CDevEncDiskUtils(); |
|
116 iKeyUtils = new (ELeave) CDevEncKeyUtils(); |
|
117 iPhoneMemorySession = new (ELeave) CDevEncSession( KPhoneMemoryDriveNum ); |
|
118 iMemoryCardSession = new (ELeave) CDevEncSession( KMemoryCardDriveNum ); |
|
119 User::LeaveIfError(iPhoneMemorySession->Connect()); |
|
120 User::LeaveIfError(iMemoryCardSession->Connect()); |
|
121 iTimer.CreateLocal(); |
|
122 iUiCenRep = CRepository::NewL( TUid::Uid( KCRDevEncUiSettings ) ); |
|
123 DFLOG( "CDevEncAdapter::ConstructL End" ); |
|
124 } |
|
125 |
|
126 // ---------------------------------------------------------------------------- |
|
127 // CDevEncAdapter::~CDevEncAdapter() |
|
128 // C++ Destructor |
|
129 // Status : Draft |
|
130 // ---------------------------------------------------------------------------- |
|
131 // |
|
132 CDevEncAdapter::~CDevEncAdapter() |
|
133 { |
|
134 DFLOG( "CDevEncAdapter Destructor Begin" ); |
|
135 if (iDiskUtils) |
|
136 { |
|
137 delete iDiskUtils; |
|
138 iDiskUtils = NULL; |
|
139 } |
|
140 |
|
141 if (iKeyUtils) |
|
142 { |
|
143 delete iKeyUtils; |
|
144 iKeyUtils = NULL; |
|
145 } |
|
146 |
|
147 if (iPhoneMemorySession) |
|
148 { |
|
149 iPhoneMemorySession->Close(); |
|
150 delete iPhoneMemorySession; |
|
151 iPhoneMemorySession = NULL; |
|
152 } |
|
153 |
|
154 if (iMemoryCardSession) |
|
155 { |
|
156 iMemoryCardSession->Close(); |
|
157 delete iMemoryCardSession; |
|
158 iMemoryCardSession = NULL; |
|
159 } |
|
160 |
|
161 if ( iPkcs5Key ) |
|
162 { |
|
163 delete iPkcs5Key; |
|
164 iPkcs5Key = NULL; |
|
165 } |
|
166 if (iTimer.Handle()) |
|
167 iTimer.Close(); |
|
168 |
|
169 if (iUiCenRep) |
|
170 { |
|
171 delete iUiCenRep; |
|
172 iUiCenRep = NULL; |
|
173 } |
|
174 DFLOG( "CDevEncAdapter Destructor End" ); |
|
175 } |
|
176 |
|
177 // ---------------------------------------------------------------------------- |
|
178 // CDevEncAdapter::DDFVersionL |
|
179 // Return DM plug-in version |
|
180 // (may leave) |
|
181 // Status : Draft |
|
182 // ---------------------------------------------------------------------------- |
|
183 // |
|
184 void CDevEncAdapter::DDFVersionL( CBufBase& aDDFVersion ) |
|
185 { |
|
186 // Insert version information |
|
187 DFLOG( "CDevEncAdapter::DDFVersionL Begin" ); |
|
188 aDDFVersion.InsertL( 0, KDevEncAdapterVersion ); |
|
189 DFLOG( "CDevEncAdapter::DDFVersionL End" ); |
|
190 } |
|
191 |
|
192 // ---------------------------------------------------------------------------- |
|
193 // CDevEncAdapter::DDFStructureL |
|
194 // Return DM plug-in structure |
|
195 // (may leave) |
|
196 // Status : Draft |
|
197 // ---------------------------------------------------------------------------- |
|
198 // |
|
199 void CDevEncAdapter::DDFStructureL( MSmlDmDDFObject& aDDF ) |
|
200 { |
|
201 // Declare accesses |
|
202 DFLOG( "CDevEncAdapter::DDFStructureL Begin" ); |
|
203 TSmlDmAccessTypes accessTypes; |
|
204 accessTypes.SetGet(); |
|
205 |
|
206 // Create root node |
|
207 MSmlDmDDFObject& root = aDDF.AddChildObjectL( KDevEncRootNode ); |
|
208 FillNodeInfoL( root, |
|
209 accessTypes, |
|
210 MSmlDmDDFObject::EPermanent, |
|
211 MSmlDmDDFObject::ENode, |
|
212 MSmlDmDDFObject::EOne, |
|
213 KNullDesC8(), |
|
214 KNullDesC8() ); |
|
215 |
|
216 // Create leaf nodes |
|
217 |
|
218 accessTypes.Reset(); |
|
219 accessTypes.SetReplace(); // Command nodes are write-only |
|
220 |
|
221 MSmlDmDDFObject& node1 = root.AddChildObjectL( KPhoneMemoryCmdNode ); |
|
222 FillNodeInfoL( node1, |
|
223 accessTypes, |
|
224 MSmlDmDDFObject::EPermanent, |
|
225 MSmlDmDDFObject::EInt, |
|
226 MSmlDmDDFObject::EOne, |
|
227 KPhoneMemoryCmdDescription, |
|
228 KIntType ); |
|
229 |
|
230 MSmlDmDDFObject& node2 = root.AddChildObjectL( KMemoryCardCmdNode ); |
|
231 FillNodeInfoL( node2, |
|
232 accessTypes, |
|
233 MSmlDmDDFObject::EPermanent, |
|
234 MSmlDmDDFObject::EInt, |
|
235 MSmlDmDDFObject::EOne, |
|
236 KMemoryCardCmdDescription, |
|
237 KIntType ); |
|
238 |
|
239 accessTypes.Reset(); |
|
240 accessTypes.SetGet(); // Status nodes are read-only |
|
241 |
|
242 MSmlDmDDFObject& node3 = root.AddChildObjectL( KPhoneMemoryStatusNode ); |
|
243 FillNodeInfoL( node3, |
|
244 accessTypes, |
|
245 MSmlDmDDFObject::EPermanent, |
|
246 MSmlDmDDFObject::EInt, |
|
247 MSmlDmDDFObject::EOne, |
|
248 KPhoneMemoryStatusDescription, |
|
249 KIntType ); |
|
250 |
|
251 MSmlDmDDFObject& node4 = root.AddChildObjectL( KMemoryCardStatusNode ); |
|
252 FillNodeInfoL( node4, |
|
253 accessTypes, |
|
254 MSmlDmDDFObject::EPermanent, |
|
255 MSmlDmDDFObject::EInt, |
|
256 MSmlDmDDFObject::EOne, |
|
257 KMemoryCardStatusDescription, |
|
258 KIntType ); |
|
259 |
|
260 accessTypes.SetReplace(); |
|
261 |
|
262 MSmlDmDDFObject& node5 = root.AddChildObjectL( KMemoryCardEncKeyNode ); |
|
263 FillNodeInfoL( node5, |
|
264 accessTypes, |
|
265 MSmlDmDDFObject::EPermanent, |
|
266 MSmlDmDDFObject::EB64, |
|
267 MSmlDmDDFObject::EOne, |
|
268 KMemoryCardEncKeyDescription, |
|
269 KTextType ); |
|
270 |
|
271 MSmlDmDDFObject& node6 = root.AddChildObjectL( KUIStateNode ); |
|
272 FillNodeInfoL( node6, |
|
273 accessTypes, |
|
274 MSmlDmDDFObject::EPermanent, |
|
275 MSmlDmDDFObject::EInt, |
|
276 MSmlDmDDFObject::EOne, |
|
277 KUIStateDescription, |
|
278 KIntType ); |
|
279 |
|
280 accessTypes.Reset(); |
|
281 accessTypes.SetGet(); // Progress nodes are read-only |
|
282 |
|
283 MSmlDmDDFObject& node7 = root.AddChildObjectL( KPhoneMemoryProgNode ); |
|
284 FillNodeInfoL( node7, |
|
285 accessTypes, |
|
286 MSmlDmDDFObject::EPermanent, |
|
287 MSmlDmDDFObject::EInt, |
|
288 MSmlDmDDFObject::EOne, |
|
289 KPhoneMemoryProgDescription, |
|
290 KIntType ); |
|
291 |
|
292 MSmlDmDDFObject& node8 = root.AddChildObjectL( KMemoryCardProgNode ); |
|
293 FillNodeInfoL( node8, |
|
294 accessTypes, |
|
295 MSmlDmDDFObject::EPermanent, |
|
296 MSmlDmDDFObject::EInt, |
|
297 MSmlDmDDFObject::EOne, |
|
298 KMemoryCardProgDescription, |
|
299 KIntType ); |
|
300 DFLOG( "CDevEncAdapter::DDFStructureL End" ); |
|
301 } |
|
302 |
|
303 // ---------------------------------------------------------------------------- |
|
304 // CDevEncAdapter::StreamingSupport |
|
305 // Return streaming support status, set supported item size |
|
306 // Status : Draft |
|
307 // ---------------------------------------------------------------------------- |
|
308 // |
|
309 TBool CDevEncAdapter::StreamingSupport( TInt& /* aItemSize */ ) |
|
310 { |
|
311 // Not supported |
|
312 DFLOG( "CDevEncAdapter::StreamingSupport" ); |
|
313 return EFalse; |
|
314 } |
|
315 |
|
316 // ---------------------------------------------------------------------------- |
|
317 // CDevEncAdapter::StreamCommittedL |
|
318 // Commit stream buffer |
|
319 // (may leave) |
|
320 // Status : Draft |
|
321 // ---------------------------------------------------------------------------- |
|
322 // |
|
323 void CDevEncAdapter::StreamCommittedL() |
|
324 { |
|
325 DFLOG( "CDevEncAdapter::StreamCommitted" ); |
|
326 // Intentionally left empty |
|
327 } |
|
328 |
|
329 // ---------------------------------------------------------------------------- |
|
330 // CDevEncAdapter::CompleteOutstandingCmdsL |
|
331 // Complete outstanding commands |
|
332 // (may leave) |
|
333 // Status : Draft |
|
334 // ---------------------------------------------------------------------------- |
|
335 // |
|
336 void CDevEncAdapter::CompleteOutstandingCmdsL() |
|
337 { |
|
338 DFLOG( "CDevEncAdapter::CompleteOutstandingCmdsL Begin" ); |
|
339 MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk; |
|
340 TInt status; |
|
341 |
|
342 TRequestStatus reqStatus; |
|
343 TBool pending = ( iPhoneMemOpPending || iMemCardOpPending ); |
|
344 DFLOG2( "CDevEncAdapter: pending %d", ( pending ? 1 : 0 ) ); |
|
345 |
|
346 if ( iPhoneMemOpPending ) |
|
347 { |
|
348 iPhoneMemOpPending = EFalse; |
|
349 DFLOG2( "CDevEncAdapter: iPendingCommand %d", iPendingCommand ); |
|
350 switch ( iPendingCommand ) |
|
351 { |
|
352 case EDmDecrypt: |
|
353 iPhoneMemorySession->DiskStatus( status ); |
|
354 if ( status == EEncrypted ) |
|
355 { |
|
356 DFLOG( "CDevEncAdapter: phone memory decrypt" ); |
|
357 iPhoneMemorySession->StartDiskDecrypt(); |
|
358 } |
|
359 else |
|
360 { |
|
361 DFLOG2( "CDevEncAdapter: Cannot decrypt, phone mem status %d", |
|
362 status ); |
|
363 retValue = CSmlDmAdapter::EError; |
|
364 } |
|
365 break; |
|
366 case EDmEncryptDefault: |
|
367 iPhoneMemorySession->DiskStatus( status ); |
|
368 if ( status == EDecrypted ) |
|
369 { |
|
370 // if FOTA couldn't be disabled then the encryption cannot be performed |
|
371 if( retValue != CSmlDmAdapter::EError ) |
|
372 { |
|
373 DFLOG( "CDevEncAdapter: phone memory encrypt" ); |
|
374 iPhoneMemorySession->StartDiskEncrypt(); |
|
375 } |
|
376 } |
|
377 else |
|
378 { |
|
379 DFLOG2( "CDevEncAdapter: Cannot encrypt, phone mem status %d", |
|
380 status ); |
|
381 retValue = CSmlDmAdapter::EError; |
|
382 } |
|
383 break; |
|
384 default: |
|
385 // Unknown or not valid command for phone memory |
|
386 DFLOG2( "CDevEncAdapter: Invalid command %d", |
|
387 iPendingCommand ); |
|
388 retValue = CSmlDmAdapter::EInvalidObject; |
|
389 break; |
|
390 } |
|
391 } |
|
392 |
|
393 if ( iMemCardOpPending ) |
|
394 { |
|
395 iMemCardOpPending = EFalse; |
|
396 switch ( iPendingCommand ) |
|
397 { |
|
398 case EDmDecrypt: |
|
399 iMemoryCardSession->DiskStatus( status ); |
|
400 if ( status == EEncrypted ) |
|
401 { |
|
402 DFLOG( "CDevEncAdapter: memory card decrypt" ); |
|
403 TInt opStatus = iMemoryCardSession->StartDiskDecrypt(); |
|
404 } |
|
405 else |
|
406 { |
|
407 DFLOG2( "CDevEncAdapter: Cannot decrypt, card status %d", |
|
408 status ); |
|
409 retValue = CSmlDmAdapter::EError; |
|
410 } |
|
411 break; |
|
412 case EDmEncryptRestore: |
|
413 case EDmEncryptBackup: |
|
414 iMemoryCardSession->DiskStatus( status ); |
|
415 if ( status == EDecrypted ) |
|
416 { |
|
417 HBufC8* passwd = AskPassWordL(); |
|
418 if ( iPendingCommand == EDmEncryptBackup ) |
|
419 { |
|
420 DFLOG( "CDevEncAdapter: memory card backup" ); |
|
421 _LIT_SECURITY_POLICY_S0( KPSSecurityPolicy, KPSCategory.iUid ); |
|
422 |
|
423 RProperty::Define( KPkcs5PSKey, |
|
424 RProperty::EByteArray, |
|
425 KPSSecurityPolicy, |
|
426 KPSSecurityPolicy ); |
|
427 iKeyUtils->CreateSetKey( reqStatus, |
|
428 iPkcs5Key, |
|
429 *passwd, |
|
430 KEncryptionKeyLength ); |
|
431 User::WaitForRequest( reqStatus ); |
|
432 User::LeaveIfError( reqStatus.Int() ); |
|
433 TInt ret = RProperty::Set( KPSCategory, |
|
434 KPkcs5PSKey, |
|
435 *iPkcs5Key ); |
|
436 if ( ret != KErrNone ) |
|
437 { |
|
438 DFLOG2( "CDevEncAdapter: Error storing key: %d", ret ); |
|
439 User::Leave( ret ); |
|
440 } |
|
441 } |
|
442 else if ( iPendingCommand == EDmEncryptRestore ) |
|
443 { |
|
444 DFLOG( "CDevEncAdapter: memory card restore" ); |
|
445 iKeyUtils->SetKey( reqStatus, *iPkcs5Key, *passwd ); |
|
446 User::WaitForRequest( reqStatus ); |
|
447 DFLOG2( "CDevEncAdapter::CompleteOutstandingCmdsL: \ |
|
448 SetKey: %d", reqStatus.Int() ); |
|
449 User::LeaveIfError( reqStatus.Int() ); |
|
450 } |
|
451 DFLOG( "CDevEncAdapter: memory card encrypt" ); |
|
452 TInt opStatus = iMemoryCardSession->StartDiskEncrypt(); |
|
453 delete passwd; |
|
454 passwd = NULL; |
|
455 } |
|
456 else |
|
457 { |
|
458 DFLOG2( "CDevEncAdapter: Cannot encrypt, card status %d", |
|
459 status ); |
|
460 retValue = CSmlDmAdapter::EError; |
|
461 } |
|
462 break; |
|
463 case EDmEncryptDefault: |
|
464 iMemoryCardSession->DiskStatus( status ); |
|
465 if ( status == EDecrypted ) |
|
466 { |
|
467 DFLOG( "CDevEncAdapter: memory card encrypt" ); |
|
468 TInt opStatus = iMemoryCardSession->StartDiskEncrypt(); |
|
469 } |
|
470 else |
|
471 { |
|
472 DFLOG2( "CDevEncAdapter: Cannot encrypt, card status %d", |
|
473 status ); |
|
474 retValue = CSmlDmAdapter::EError; |
|
475 } |
|
476 break; |
|
477 default: |
|
478 // Unknown or not valid command for memory card |
|
479 DFLOG2( "CDevEncAdapter: Invalid command %d", |
|
480 iPendingCommand ); |
|
481 retValue = CSmlDmAdapter::EInvalidObject; |
|
482 break; |
|
483 } |
|
484 } |
|
485 |
|
486 if ( pending ) |
|
487 { |
|
488 Callback().SetStatusL( iStatusRef, retValue ); |
|
489 } |
|
490 DFLOG( "CDevEncAdapter::CompleteOutstandingCmdsL End" ); |
|
491 } |
|
492 |
|
493 // ---------------------------------------------------------------------------- |
|
494 // CDevEncAdapter::FillNodeInfoL |
|
495 // Fill node info |
|
496 // (may leave) |
|
497 // Status : Draft |
|
498 // ---------------------------------------------------------------------------- |
|
499 // |
|
500 void CDevEncAdapter::FillNodeInfoL( MSmlDmDDFObject& aDDFObject, |
|
501 TSmlDmAccessTypes& aAccessTypes, |
|
502 MSmlDmDDFObject::TScope aScope, |
|
503 MSmlDmDDFObject::TDFFormat aFormat, |
|
504 MSmlDmDDFObject::TOccurence aOccurence, |
|
505 const TDesC8& aDescription, |
|
506 const TDesC8& aMIMEType ) |
|
507 { |
|
508 DFLOG( "CDevEncAdapter::FillNodeInfoL Begin" ); |
|
509 aDDFObject.SetAccessTypesL( aAccessTypes ); |
|
510 aDDFObject.SetScopeL( aScope ); |
|
511 aDDFObject.SetOccurenceL( aOccurence ); |
|
512 aDDFObject.SetDFFormatL( aFormat ); |
|
513 aDDFObject.SetDescriptionL( aDescription ); |
|
514 if ( aFormat != MSmlDmDDFObject::ENode ) |
|
515 { |
|
516 aDDFObject.AddDFTypeMimeTypeL( aMIMEType ); |
|
517 } |
|
518 DFLOG( "CDevEncAdapter::FillNodeInfoL End" ); |
|
519 } |
|
520 |
|
521 // ---------------------------------------------------------------------------- |
|
522 // CDevEncAdapter::CopyCommandL |
|
523 // Copy object |
|
524 // (may leave) |
|
525 // Status : Draft |
|
526 // ---------------------------------------------------------------------------- |
|
527 // |
|
528 void CDevEncAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/, |
|
529 const TDesC8& /*aTargetLUID*/, |
|
530 const TDesC8& /*aSourceURI*/, |
|
531 const TDesC8& /*aSourceLUID*/, |
|
532 const TDesC8& /*aType*/, |
|
533 TInt aStatusRef ) |
|
534 { |
|
535 // Not supported |
|
536 DFLOG( "CDevEncAdapter::CopyCommandL Begin" ); |
|
537 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
538 DFLOG( "CDevEncAdapter::CopyCommandL End" ); |
|
539 } |
|
540 |
|
541 // ---------------------------------------------------------------------------- |
|
542 // DeleteObjectL |
|
543 // Delete object |
|
544 // (may leave) |
|
545 // Status : Draft |
|
546 // ---------------------------------------------------------------------------- |
|
547 // |
|
548 void CDevEncAdapter::DeleteObjectL( const TDesC8& /* aURI */, |
|
549 const TDesC8& /* aLUID */, |
|
550 TInt aStatusRef ) |
|
551 |
|
552 { |
|
553 // Not supported |
|
554 DFLOG( "CDevEncAdapter::DeleteObjectL Begin" ); |
|
555 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
556 DFLOG( "CDevEncAdapter::DeleteObjectL End" ); |
|
557 } |
|
558 |
|
559 // ---------------------------------------------------------------------------- |
|
560 // CDevEncAdapter::FetchLeafObjectL |
|
561 // Fetch leaf |
|
562 // (may leave) |
|
563 // Status : Draft |
|
564 // ---------------------------------------------------------------------------- |
|
565 // |
|
566 void CDevEncAdapter::FetchLeafObjectL( const TDesC8& aURI, |
|
567 const TDesC8& /* aLUID */, |
|
568 const TDesC8& aType, |
|
569 TInt aResultsRef, |
|
570 TInt aStatusRef ) |
|
571 { |
|
572 DFLOG( "CDevEncAdapter::FetchLeafObjectL Begin" ); |
|
573 |
|
574 MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk; |
|
575 CBufFlat* result = CBufFlat::NewL( KBufGranularity ); |
|
576 CleanupStack::PushL( result ); |
|
577 |
|
578 if ( aURI.Compare( KDevEncRootNode ) >= 0 ) |
|
579 { |
|
580 TPtrC8 leaf = LastURISeg( aURI ); |
|
581 TBuf8<KSizeOfSettingId> buf; |
|
582 |
|
583 if ( leaf == KPhoneMemoryStatusNode ) |
|
584 { |
|
585 TInt status; |
|
586 iPhoneMemorySession->DiskStatus( status ); |
|
587 buf.Num( status ); |
|
588 result->InsertL( 0, buf ); |
|
589 } |
|
590 else if ( leaf == KMemoryCardStatusNode ) |
|
591 { |
|
592 TInt status; |
|
593 iMemoryCardSession->DiskStatus( status ); |
|
594 buf.Num( status ); |
|
595 result->InsertL( 0, buf ); |
|
596 } |
|
597 else if ( leaf == KMemoryCardEncKeyNode ) |
|
598 { |
|
599 iPkcs5Key = HBufC8::NewL( RProperty::KMaxPropertySize ); |
|
600 TPtr8 keyPtr = iPkcs5Key->Des(); |
|
601 keyPtr.FillZ( RProperty::KMaxPropertySize ); |
|
602 TInt ret = RProperty::Get( KPSCategory, |
|
603 KPkcs5PSKey, |
|
604 keyPtr ); |
|
605 if ( ret != KErrNone ) |
|
606 { |
|
607 DFLOG2( "CDevEncAdapter::FetchLeafObjectL: Error reading key: %d", ret ); |
|
608 User::Leave( ret ); |
|
609 } |
|
610 result->InsertL( 0, *iPkcs5Key ); |
|
611 } |
|
612 else if ( leaf == KUIStateNode ) |
|
613 { |
|
614 TInt status; |
|
615 iUiCenRep->Get( KDevEncUiDmControl, status ); |
|
616 buf.Num( status ); |
|
617 result->InsertL( 0, buf ); |
|
618 } |
|
619 else if ( leaf == KPhoneMemoryProgNode ) |
|
620 { |
|
621 TInt progress = -1; |
|
622 iPhoneMemorySession->Progress( progress ); |
|
623 buf.Num( progress ); |
|
624 result->InsertL( 0, buf ); |
|
625 } |
|
626 else if ( leaf == KMemoryCardProgNode ) |
|
627 { |
|
628 TInt progress = -1; |
|
629 iMemoryCardSession->Progress( progress ); |
|
630 buf.Num( progress ); |
|
631 result->InsertL( 0, buf ); |
|
632 } |
|
633 else |
|
634 { |
|
635 retValue = CSmlDmAdapter::ENotFound; |
|
636 } |
|
637 } |
|
638 else |
|
639 { |
|
640 retValue = CSmlDmAdapter::ENotFound; |
|
641 } |
|
642 |
|
643 if ( retValue == CSmlDmAdapter::EOk ) |
|
644 { |
|
645 result->Compress(); |
|
646 Callback().SetResultsL( aResultsRef, *result, aType ); |
|
647 } |
|
648 |
|
649 CleanupStack::PopAndDestroy( result ); |
|
650 // Respond |
|
651 Callback().SetStatusL( aStatusRef, retValue ); |
|
652 DFLOG( "CDevEncAdapter::FetchLeafObjectL End" ); |
|
653 } |
|
654 |
|
655 // ---------------------------------------------------------------------------- |
|
656 // CDevEncAdapter::FetchLeafObjectSizeL |
|
657 // Calculate leaf object size |
|
658 // (may leave) |
|
659 // Status : Draft |
|
660 // ---------------------------------------------------------------------------- |
|
661 // |
|
662 void CDevEncAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, |
|
663 const TDesC8& /* aLUID */, |
|
664 const TDesC8& /* aType */, |
|
665 TInt aResultsRef, |
|
666 TInt aStatusRef ) |
|
667 { |
|
668 DFLOG( "CDevEncAdapter::FetchLeafObjectSizeL Begin" ); |
|
669 |
|
670 MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk; |
|
671 CBufFlat* result = CBufFlat::NewL( KBufGranularity ); |
|
672 CleanupStack::PushL( result ); |
|
673 |
|
674 if ( aURI.Compare( KDevEncRootNode ) >= 0 ) |
|
675 { |
|
676 TPtrC8 leaf = LastURISeg( aURI ); |
|
677 TBuf8<KSizeOfSettingId> buf; |
|
678 |
|
679 if ( leaf == KPhoneMemoryStatusNode ) |
|
680 { |
|
681 buf.AppendNum( sizeof(TInt) ); |
|
682 result->InsertL( 0, buf ); |
|
683 } |
|
684 else if ( leaf == KMemoryCardStatusNode ) |
|
685 { |
|
686 buf.AppendNum( sizeof(TInt) ); |
|
687 result->InsertL( 0, buf ); |
|
688 } |
|
689 else if ( leaf == KMemoryCardEncKeyNode ) |
|
690 { |
|
691 buf.AppendNum( KEncryptionKeyLength ); |
|
692 result->InsertL( 0, buf ); |
|
693 } |
|
694 else if ( leaf == KUIStateNode ) |
|
695 { |
|
696 buf.AppendNum( sizeof(TInt) ); |
|
697 result->InsertL( 0, buf ); |
|
698 } |
|
699 else if ( leaf == KPhoneMemoryProgNode ) |
|
700 { |
|
701 buf.AppendNum( sizeof(TInt) ); |
|
702 result->InsertL( 0, buf ); |
|
703 } |
|
704 else if ( leaf == KMemoryCardProgNode ) |
|
705 { |
|
706 buf.AppendNum( sizeof(TInt) ); |
|
707 result->InsertL( 0, buf ); |
|
708 } |
|
709 else |
|
710 { |
|
711 retValue = CSmlDmAdapter::ENotFound; |
|
712 } |
|
713 } |
|
714 else |
|
715 { |
|
716 retValue = CSmlDmAdapter::ENotFound; |
|
717 } |
|
718 |
|
719 if ( retValue == CSmlDmAdapter::EOk ) |
|
720 { |
|
721 result->Compress(); |
|
722 Callback().SetResultsL( aResultsRef, *result, KIntType ); |
|
723 } |
|
724 |
|
725 CleanupStack::PopAndDestroy( result ); |
|
726 // Respond |
|
727 Callback().SetStatusL( aStatusRef, retValue ); |
|
728 DFLOG( "CDevEncAdapter::FetchLeafObjectSizeL End" ); |
|
729 } |
|
730 |
|
731 // ---------------------------------------------------------------------------- |
|
732 // CDevEncAdapter::ChildURIListL |
|
733 // Create child URI list |
|
734 // (may leave) |
|
735 // Status : Draft |
|
736 // ---------------------------------------------------------------------------- |
|
737 // |
|
738 void CDevEncAdapter::ChildURIListL( const TDesC8& aURI, |
|
739 const TDesC8& /* aLUID */, |
|
740 const CArrayFix<TSmlDmMappingInfo>& /* aPreviousURISegmentList */, |
|
741 TInt aResultsRef, |
|
742 TInt aStatusRef ) |
|
743 { |
|
744 DFLOG( "CDevEncAdapter::ChildURIListL Begin" ); |
|
745 MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk; |
|
746 |
|
747 if ( aURI.Compare( KDevEncRootNode ) == 0 ) |
|
748 { |
|
749 CBufFlat* buf = CBufFlat::NewL( KBufGranularity ); |
|
750 CleanupStack::PushL( buf ); |
|
751 buf->InsertL( 0, KPhoneMemoryCmdNode ); |
|
752 buf->InsertL( buf->Size(), KSeparator ); |
|
753 buf->InsertL( buf->Size(), KMemoryCardCmdNode ); |
|
754 buf->InsertL( buf->Size(), KSeparator ); |
|
755 buf->InsertL( buf->Size(), KPhoneMemoryStatusNode ); |
|
756 buf->InsertL( buf->Size(), KSeparator ); |
|
757 buf->InsertL( buf->Size(), KMemoryCardStatusNode ); |
|
758 buf->InsertL( buf->Size(), KSeparator ); |
|
759 buf->InsertL( buf->Size(), KMemoryCardEncKeyNode ); |
|
760 buf->InsertL( buf->Size(), KSeparator ); |
|
761 buf->InsertL( buf->Size(), KUIStateNode ); |
|
762 buf->InsertL( buf->Size(), KSeparator ); |
|
763 buf->InsertL( buf->Size(), KPhoneMemoryProgNode ); |
|
764 buf->InsertL( buf->Size(), KSeparator ); |
|
765 buf->InsertL( buf->Size(), KMemoryCardProgNode ); |
|
766 |
|
767 buf->Compress(); |
|
768 Callback().SetResultsL( aResultsRef, *buf, KNullDesC8 ); |
|
769 CleanupStack::PopAndDestroy( buf ); |
|
770 } |
|
771 else |
|
772 { |
|
773 retValue = CSmlDmAdapter::ENotFound; |
|
774 } |
|
775 |
|
776 // Respond |
|
777 Callback().SetStatusL( aStatusRef, retValue ); |
|
778 DFLOG( "CDevEncAdapter::ChildURIListL End" ); |
|
779 } |
|
780 |
|
781 // ---------------------------------------------------------------------------- |
|
782 // CDevEncAdapter::AddNodeObjectL |
|
783 // Add node |
|
784 // (may leave) |
|
785 // Status : Draft |
|
786 // ---------------------------------------------------------------------------- |
|
787 // |
|
788 void CDevEncAdapter::AddNodeObjectL( const TDesC8& /* aURI */, |
|
789 const TDesC8& /* aParentLUID */, |
|
790 TInt aStatusRef ) |
|
791 { |
|
792 // Not supported |
|
793 DFLOG( "CDevEncAdapter::AddNodeObjectL Begin" ); |
|
794 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
795 DFLOG( "CDevEncAdapter::AddNodeObjectL End" ); |
|
796 } |
|
797 |
|
798 // ---------------------------------------------------------------------------- |
|
799 // CDevEncAdapter::ExecuteCommandL |
|
800 // Execute command |
|
801 // (may leave) |
|
802 // Status : Draft |
|
803 // ---------------------------------------------------------------------------- |
|
804 // |
|
805 void CDevEncAdapter::ExecuteCommandL( const TDesC8& /* aURI */, |
|
806 const TDesC8& /* aLUID */, |
|
807 const TDesC8& /* aArgument */, |
|
808 const TDesC8& /* aType */, |
|
809 TInt aStatusRef ) |
|
810 { |
|
811 // Not supported |
|
812 DFLOG( "CDevEncAdapter::ExecuteCommandL Begin" ); |
|
813 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
814 DFLOG( "CDevEncAdapter::ExecuteCommandL End" ); |
|
815 } |
|
816 |
|
817 // ---------------------------------------------------------------------------- |
|
818 // CDevEncAdapter::ExecuteCommandL |
|
819 // Execute command, streaming enabled |
|
820 // (may leave) |
|
821 // Status : Draft |
|
822 // ---------------------------------------------------------------------------- |
|
823 // |
|
824 void CDevEncAdapter::ExecuteCommandL( const TDesC8& /* aURI */, |
|
825 const TDesC8& /* aLUID */, |
|
826 RWriteStream*& /* aStream */, |
|
827 const TDesC8& /* aType */, |
|
828 TInt aStatusRef ) |
|
829 { |
|
830 // Not supported |
|
831 DFLOG( "CDevEncAdapter::ExecuteCommandL Begin" ); |
|
832 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
833 DFLOG( "CDevEncAdapter::ExecuteCommandL End" ); |
|
834 } |
|
835 |
|
836 // ---------------------------------------------------------------------------- |
|
837 // CDevEncAdapter::UpdateLeafObjectL |
|
838 // Update leaf object |
|
839 // (may leave) |
|
840 // Status : Draft |
|
841 // ---------------------------------------------------------------------------- |
|
842 // |
|
843 void CDevEncAdapter::UpdateLeafObjectL( const TDesC8& aURI, |
|
844 const TDesC8& /* aLUID */, |
|
845 const TDesC8& aObject, |
|
846 const TDesC8& /* aType */, |
|
847 TInt aStatusRef ) |
|
848 { |
|
849 DFLOG( "CDevEncAdapter::UpdateLeafObjectL Begin" ); |
|
850 MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk; |
|
851 DFLOG2( "CDevEncAdapter: Object: %S", &aObject ); |
|
852 |
|
853 if ( aURI.Compare( KDevEncRootNode ) >= 0 ) |
|
854 { |
|
855 TPtrC8 leaf = LastURISeg( aURI ); |
|
856 TLex8 lex; |
|
857 |
|
858 if ( leaf == KPhoneMemoryCmdNode ) |
|
859 { |
|
860 DFLOG( "CDevEncAdapter: leaf: KPhoneMemoryCmdNode" ); |
|
861 DFLOG2( "CDevEncAdapter: iMemCardOpPending %d", ( iMemCardOpPending ? 1 : 0 ) ); |
|
862 if ( iMemCardOpPending ) |
|
863 { |
|
864 retValue = CSmlDmAdapter::EObjectInUse; |
|
865 } |
|
866 else |
|
867 { |
|
868 if( !CheckBatteryL() ) |
|
869 { |
|
870 retValue = CSmlDmAdapter::EError; |
|
871 } |
|
872 else |
|
873 { |
|
874 lex.Assign( aObject ); |
|
875 lex.Val( iPendingCommand ); |
|
876 iPhoneMemOpPending = ETrue; |
|
877 iStatusRef = aStatusRef; |
|
878 return; // Completed in CompleteOutstandingCmdsL |
|
879 } |
|
880 } |
|
881 } |
|
882 else if ( leaf == KMemoryCardCmdNode ) |
|
883 { |
|
884 DFLOG( "CDevEncAdapter: leaf: KMemoryCardCmdNode" ); |
|
885 DFLOG2( "CDevEncAdapter: iPhoneMemOpPending %d", ( iPhoneMemOpPending ? 1 : 0 ) ); |
|
886 if ( iPhoneMemOpPending ) |
|
887 { |
|
888 retValue = CSmlDmAdapter::EObjectInUse; |
|
889 } |
|
890 else |
|
891 { |
|
892 if( !CheckBatteryL() ) |
|
893 { |
|
894 retValue = CSmlDmAdapter::EError; |
|
895 } |
|
896 else |
|
897 { |
|
898 lex.Assign( aObject ); |
|
899 lex.Val( iPendingCommand ); |
|
900 iMemCardOpPending = ETrue; |
|
901 iStatusRef = aStatusRef; |
|
902 return; // Completed in CompleteOutstandingCmdsL |
|
903 } |
|
904 } |
|
905 } |
|
906 else if ( leaf == KMemoryCardEncKeyNode ) |
|
907 { |
|
908 DFLOG( "CDevEncAdapter: leaf: KMemoryCardEncKeyNode" ); |
|
909 iPkcs5Key = aObject.AllocL(); |
|
910 } |
|
911 else if ( leaf == KUIStateNode ) |
|
912 { |
|
913 DFLOG( "CDevEncAdapter: leaf: KUIStateNode" ); |
|
914 lex.Assign( aObject ); |
|
915 TInt value; |
|
916 lex.Val( value ); |
|
917 iUiCenRep->Set( KDevEncUiDmControl, value ); |
|
918 } |
|
919 else |
|
920 { |
|
921 retValue = CSmlDmAdapter::ENotFound; |
|
922 DFLOG( "CDevEncAdapter: Not Found" ); |
|
923 } |
|
924 } |
|
925 else |
|
926 { |
|
927 retValue = CSmlDmAdapter::ENotFound; |
|
928 DFLOG( "CDevEncAdapter: Not Found" ); |
|
929 } |
|
930 Callback().SetStatusL( aStatusRef, retValue ); |
|
931 DFLOG( "CDevEncAdapter::UpdateLeafObjectL End" ); |
|
932 } |
|
933 |
|
934 // ---------------------------------------------------------------------------- |
|
935 // CDevEncAdapter::UpdateLeafObjectL |
|
936 // Update leaf object, streaming enabled |
|
937 // (may leave) |
|
938 // Status : Draft |
|
939 // ---------------------------------------------------------------------------- |
|
940 // |
|
941 void CDevEncAdapter::UpdateLeafObjectL( const TDesC8& /* aURI */, |
|
942 const TDesC8& /* aLUID */, |
|
943 RWriteStream*& /* aStream */, |
|
944 const TDesC8& /* aType */, |
|
945 TInt aStatusRef ) |
|
946 { |
|
947 // Not supported |
|
948 DFLOG( "CDevEncAdapter::UpdateLeafObjectL Begin" ); |
|
949 Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); |
|
950 DFLOG( "CDevEncAdapter::UpdateLeafObjectL End" ); |
|
951 } |
|
952 |
|
953 // ---------------------------------------------------------------------------- |
|
954 // CDevEncAdapter::StartAtomicL |
|
955 // Start atomic |
|
956 // (may leave) |
|
957 // Status : Draft |
|
958 // ---------------------------------------------------------------------------- |
|
959 // |
|
960 void CDevEncAdapter::StartAtomicL() |
|
961 { |
|
962 DFLOG( "CDevEncAdapter::StartAtomicL" ); |
|
963 } |
|
964 |
|
965 // ---------------------------------------------------------------------------- |
|
966 // CDevEncAdapter::CommitAtomicL |
|
967 // Commit atomic commands |
|
968 // (may leave) |
|
969 // Status : Draft |
|
970 // ---------------------------------------------------------------------------- |
|
971 // |
|
972 void CDevEncAdapter::CommitAtomicL() |
|
973 { |
|
974 DFLOG( "CDevEncAdapter::CommitAtomicL" ); |
|
975 } |
|
976 |
|
977 // ---------------------------------------------------------------------------- |
|
978 // CDevEncAdapter::RollbackAtomicL |
|
979 // Lose all modifications after 'StartAtomicL' command |
|
980 // (may leave) |
|
981 // Status : Draft |
|
982 // ---------------------------------------------------------------------------- |
|
983 // |
|
984 void CDevEncAdapter::RollbackAtomicL() |
|
985 { |
|
986 DFLOG( "CDevEncAdapter::RollbackAtomicL" ); |
|
987 } |
|
988 |
|
989 TPtrC8 CDevEncAdapter::LastURISeg( const TDesC8& aURI ) |
|
990 { |
|
991 DFLOG( "CDevEncAdapter::LastURISeg Begin" ); |
|
992 TInt i; |
|
993 for ( i = aURI.Length()-1; i >= 0; i-- ) |
|
994 { |
|
995 if ( aURI[i] == '/' ) |
|
996 { |
|
997 break; |
|
998 } |
|
999 } |
|
1000 DFLOG( "CDevEncAdapter::LastURISeg End" ); |
|
1001 return aURI.Mid( i+1 ); |
|
1002 } |
|
1003 |
|
1004 HBufC8* CDevEncAdapter::AskPassWordL() |
|
1005 { |
|
1006 DFLOG( "CDevEncAdapter::AskPassWordL Begin" ); |
|
1007 RNotifier notif; |
|
1008 TInt err = notif.Connect(); |
|
1009 DFLOG2( "CDevEncAdapter::AskPassWordL notif.Connect(): %d", err ); |
|
1010 User::LeaveIfError( err ); |
|
1011 TBuf8<KMaxPasswordLength> passwd; |
|
1012 passwd.SetLength(KMaxPasswordLength); |
|
1013 TRequestStatus status = KRequestPending; |
|
1014 DFLOG( "CDevEncAdapter::AskPassWordL StartNotifierAndGetResponse" ); |
|
1015 notif.StartNotifierAndGetResponse( |
|
1016 status, |
|
1017 TUid::Uid( KDevEncPasswdDlgUid ), |
|
1018 KNullDesC8, |
|
1019 passwd ); |
|
1020 User::WaitForRequest( status ); |
|
1021 notif.Close(); |
|
1022 err = status.Int(); |
|
1023 DFLOG2( "CDevEncAdapter::AskPassWordL status.Int(): %d", err ); |
|
1024 User::LeaveIfError( err ); |
|
1025 HBufC8* passwdBuf = passwd.AllocL(); |
|
1026 DFLOG( "CDevEncAdapter::AskPassWordL End" ); |
|
1027 return passwdBuf; |
|
1028 } |
|
1029 |
|
1030 // --------------------------------------------------------------------------- |
|
1031 // CDevEncAdapter::CheckBatteryL() |
|
1032 // Checks if there's enough battery power to update |
|
1033 // --------------------------------------------------------------------------- |
|
1034 // |
|
1035 TBool CDevEncAdapter::CheckBatteryL() |
|
1036 { |
|
1037 #ifdef __WINS__ |
|
1038 |
|
1039 // In the emulator, the battery level is always 0 and the charger is never |
|
1040 // connected, so just return ETrue. |
|
1041 return ETrue; |
|
1042 |
|
1043 #else // __WINS__ |
|
1044 |
|
1045 // Running on target. Check the real battery and charger status |
|
1046 |
|
1047 TInt chargingstatus( EChargingStatusError ); |
|
1048 TInt batterylevel( 1 ); |
|
1049 TBool enoughPower( EFalse ); |
|
1050 |
|
1051 // Read battery |
|
1052 DFLOG( "CDevEncAdapter::CheckBatteryL" ); |
|
1053 RProperty pw; |
|
1054 User::LeaveIfError( pw.Attach( KPSUidHWRMPowerState, KHWRMBatteryLevel ) ); |
|
1055 User::LeaveIfError( pw.Get( batterylevel ) ); |
|
1056 pw.Close(); |
|
1057 |
|
1058 User::LeaveIfError( pw.Attach( KPSUidHWRMPowerState, KHWRMChargingStatus ) ); |
|
1059 User::LeaveIfError( pw.Get( chargingstatus )); |
|
1060 pw.Close(); |
|
1061 |
|
1062 // Too low battery, power insufficient |
|
1063 if ( batterylevel >= EBatteryLevelLevel4 ) |
|
1064 { |
|
1065 enoughPower = ETrue; |
|
1066 } |
|
1067 // But charger is connected, power sufficient |
|
1068 if ( ( chargingstatus != EChargingStatusError ) && |
|
1069 ( chargingstatus != EChargingStatusNotConnected ) ) |
|
1070 { |
|
1071 enoughPower = ETrue; |
|
1072 } |
|
1073 |
|
1074 DFLOG3( "CDevEncAdapter: Battery level: %d (0..7), chargingstatus %d", |
|
1075 batterylevel, chargingstatus ); |
|
1076 DFLOG2( "CDevEncAdapter: CheckBatteryL %d", ( enoughPower ? 1 : 0 ) ); |
|
1077 return enoughPower; |
|
1078 |
|
1079 #endif // __WINS__ |
|
1080 } |
|
1081 |
|
1082 // ========================= OTHER EXPORTED FUNCTIONS ========================= |
|
1083 |
|
1084 // End of File |
|