|
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: Implements one store entry of the storage server |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPEngDataEntry.h" |
|
21 #include <e32svr.h> |
|
22 #include <s32mem.h> |
|
23 #include <f32file.h> |
|
24 |
|
25 #include "MPEngHandlerListenSIDs.h" |
|
26 #include "PEngStorageGlobals.h" |
|
27 #include "PEngStorageServerCommon.h" |
|
28 #include "PresenceDebugPrint.h" |
|
29 |
|
30 |
|
31 |
|
32 // ================= MEMBER FUNCTIONS ======================= |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CPEngDataEntry::CPEngDataEntry |
|
36 // C++ default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CPEngDataEntry::CPEngDataEntry( |
|
41 RFs& aFs, |
|
42 const TDesC& aTempFolder, |
|
43 TPEngStorageType aType ) |
|
44 : iFs( aFs ), |
|
45 iTempFolder( aTempFolder ), |
|
46 // Lock ignore bit is always set to one |
|
47 // for local copy of type |
|
48 iType( |
|
49 static_cast<TPEngStorageType> |
|
50 ( aType | EPEngStorageLockIgnored ) ) |
|
51 { |
|
52 } |
|
53 |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CPEngDataEntry::BaseConstructL |
|
57 // Symbian 2nd phase constructor can leave. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CPEngDataEntry::BaseConstructL( |
|
61 const TDesC& aKey ) |
|
62 { |
|
63 iKey = aKey.AllocL(); |
|
64 } |
|
65 |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CPEngDataEntry::NewL |
|
69 // Two-phased constructor. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CPEngDataEntry* CPEngDataEntry::NewL( |
|
73 RFs& aFs, |
|
74 const TDesC& aTempFolder, |
|
75 const TDesC& aKey, |
|
76 TPEngStorageType aType ) |
|
77 { |
|
78 CPEngDataEntry* self = NewLC( aFs, aTempFolder, aKey, aType ); |
|
79 |
|
80 CleanupStack::Pop(); // self |
|
81 |
|
82 return self; |
|
83 } |
|
84 |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CPEngDataEntry::NewLC |
|
88 // Two-phased constructor. |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CPEngDataEntry* CPEngDataEntry::NewLC( |
|
92 RFs& aFs, |
|
93 const TDesC& aTempFolder, |
|
94 const TDesC& aKey, |
|
95 TPEngStorageType aType ) |
|
96 { |
|
97 CPEngDataEntry* self = new( ELeave ) CPEngDataEntry( aFs, |
|
98 aTempFolder, |
|
99 aType ); |
|
100 |
|
101 CleanupStack::PushL( self ); |
|
102 self->BaseConstructL( aKey ); |
|
103 |
|
104 return self; |
|
105 } |
|
106 |
|
107 |
|
108 // Destructor |
|
109 CPEngDataEntry::~CPEngDataEntry() |
|
110 { |
|
111 // notify observers about delete |
|
112 TInt count( iObservers.Count() ); |
|
113 for ( TInt x( 0 ) ; x < count ; ++x ) |
|
114 { |
|
115 iObservers[ x ]->EntryDeleted( *this ); |
|
116 } |
|
117 iObservers.Reset(); |
|
118 delete iData; |
|
119 delete iKey; |
|
120 delete iHashedPath; |
|
121 } |
|
122 |
|
123 |
|
124 // ============================================================================= |
|
125 // =============== New Functions of the base class ============================= |
|
126 // ============================================================================= |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CPEngDataEntry::DataL() |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 const TDesC8& CPEngDataEntry::DataL() const |
|
133 { |
|
134 if ( !iData ) |
|
135 { |
|
136 User::Leave( KErrNotFound ); |
|
137 } |
|
138 return *iData; |
|
139 } |
|
140 |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CPEngDataEntry::Key() |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 const TDesC& CPEngDataEntry::Key() const |
|
147 { |
|
148 // key cannot be NULL since it has been created at construction |
|
149 return *iKey; |
|
150 } |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CPEngDataEntry::KeyBuffer() |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 HBufC** CPEngDataEntry::KeyBuffer() |
|
158 { |
|
159 return &iKey; |
|
160 } |
|
161 |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CPEngDataEntry::LockStatus() |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 TBool CPEngDataEntry::LockStatus( |
|
168 TPengStorageLockPriority aPriority ) const |
|
169 { |
|
170 |
|
171 if ( aPriority > iLockPriority ) |
|
172 { |
|
173 return 0; |
|
174 } |
|
175 return iLockCount; |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CPEngDataEntry::LockCount() |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 TInt CPEngDataEntry::LockCount() const |
|
183 { |
|
184 return iLockCount; |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CPEngDataEntry::IncrementLockCountL() |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TInt CPEngDataEntry::IncreaseLockCountL( |
|
192 TInt32 aSessionID, |
|
193 TInt aSubSessionID, |
|
194 TPengStorageLockPriority aPriority ) |
|
195 { |
|
196 // check the priority first |
|
197 if ( aPriority > iLockPriority ) |
|
198 { |
|
199 // update the lock in the way it will replace old lock |
|
200 iLockSession = aSessionID; |
|
201 iLockSubSession = aSubSessionID; |
|
202 iLockPriority = aPriority; |
|
203 // 1 as locked once |
|
204 iLockCount = 1; |
|
205 return iLockCount; |
|
206 } |
|
207 // priority is not higher, continue |
|
208 CheckLockSubSessionL( aSessionID, aSubSessionID ); |
|
209 if ( iLockCount == 0 ) |
|
210 { |
|
211 iLockSession = aSessionID; |
|
212 iLockSubSession = aSubSessionID; |
|
213 iLockPriority = aPriority; |
|
214 } |
|
215 // increase lock count |
|
216 iLockCount++; |
|
217 return iLockCount; |
|
218 } |
|
219 |
|
220 |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CPEngDataEntry::DecreaseLockCountL() |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 TInt CPEngDataEntry::DecreaseLockCountL( |
|
227 TBool aNotifyActive, |
|
228 TInt32 aSessionID, |
|
229 TInt aSubSessionID, |
|
230 CPEngDataEntry*& aNotifEntry ) |
|
231 { |
|
232 // check Sub Session validity |
|
233 CheckLockSubSessionL( aSessionID, aSubSessionID ); |
|
234 // decrease lock count |
|
235 iLockCount--; |
|
236 |
|
237 // notify if lock count reached zero |
|
238 if ( iLockCount == 0 ) |
|
239 { |
|
240 if ( aNotifyActive ) |
|
241 { |
|
242 NotifyUpdate(); |
|
243 } |
|
244 else |
|
245 { |
|
246 aNotifEntry = this; |
|
247 } |
|
248 } |
|
249 |
|
250 // Check that lock count is not negative |
|
251 iLockCount = ( iLockCount < 0 ? 0 : iLockCount ); |
|
252 return iLockCount; |
|
253 } |
|
254 |
|
255 |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CPEngDataEntry::Version() |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 TInt CPEngDataEntry::Version() const |
|
262 { |
|
263 return iVersion; |
|
264 } |
|
265 |
|
266 |
|
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // CPEngDataEntry::LastModification() |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 const TTime& CPEngDataEntry::LastModification() const |
|
273 { |
|
274 return iModified; |
|
275 } |
|
276 |
|
277 |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CPEngDataEntry::AssertStorageTypeL() |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void CPEngDataEntry::AssertStorageTypeL( TPEngStorageType aType ) const |
|
284 { |
|
285 // check type, if it matches, store lock is not included in type check |
|
286 if ( ( aType | EPEngStorageLockIgnored ) != iType ) |
|
287 { |
|
288 PENG_DP( D_PENG_LIT( "CPEngDataEntry::AssertStorageTypeL() - type missmatch: aType %d, iType %d" ), |
|
289 aType, iType ); |
|
290 |
|
291 User::Leave( KErrArgument ); |
|
292 } |
|
293 } |
|
294 |
|
295 |
|
296 |
|
297 // ============================================================================= |
|
298 // ===== New Functions of the base class with default implementation=========== |
|
299 // ============================================================================= |
|
300 |
|
301 // ----------------------------------------------------------------------------- |
|
302 // CPEngDataEntry::SetDataLX() |
|
303 // ----------------------------------------------------------------------------- |
|
304 // |
|
305 const CPEngDataEntry* CPEngDataEntry::SetDataLX( HBufC8* aNewData, |
|
306 TPEngStorageType aType, |
|
307 TBool aNotifyActive, |
|
308 TInt32 aSessionID, |
|
309 TInt aSubSessionID ) |
|
310 { |
|
311 //Verify storage type match |
|
312 AssertStorageTypeL( aType ); |
|
313 |
|
314 // shall lock be obeyed |
|
315 if ( !( aType & EPEngStorageLockIgnored ) ) |
|
316 { |
|
317 CheckLockSubSessionL( aSessionID, aSubSessionID ); |
|
318 } |
|
319 |
|
320 CheckVersionNumberL( *aNewData, aType ); |
|
321 if ( aType & EPEngStorageBasicPermanent ) |
|
322 { |
|
323 // Update first permanent version |
|
324 UpdatePermanentPartL( *aNewData ); |
|
325 } |
|
326 |
|
327 delete iData; |
|
328 iData = aNewData; |
|
329 |
|
330 CleanupStack::Pop(); // aNewData |
|
331 UpdateVersionNumber(); |
|
332 if ( aNotifyActive ) |
|
333 { |
|
334 NotifyUpdate(); |
|
335 return NULL; |
|
336 } |
|
337 else |
|
338 { |
|
339 return this; |
|
340 } |
|
341 } |
|
342 |
|
343 |
|
344 // ----------------------------------------------------------------------------- |
|
345 // CPEngDataEntry::DeleteStoreEntry() |
|
346 // ----------------------------------------------------------------------------- |
|
347 // |
|
348 void CPEngDataEntry::DeleteStoreEntry() |
|
349 { |
|
350 if ( !( iType & EPEngStorageBasicPermanent ) ) |
|
351 { |
|
352 // nothing to do |
|
353 return; |
|
354 } |
|
355 // delete file from disc, ignore if does not exists |
|
356 if ( iHashedPath ) |
|
357 { |
|
358 iFs.Delete( *iHashedPath ); |
|
359 } |
|
360 } |
|
361 |
|
362 |
|
363 |
|
364 // ----------------------------------------------------------------------------- |
|
365 // CPEngDataEntry::InitializeStoreEntryL() |
|
366 // ----------------------------------------------------------------------------- |
|
367 // |
|
368 void CPEngDataEntry::SetHashedPath( HBufC* aPath ) // CSI: 60 # |
|
369 { |
|
370 delete iHashedPath; |
|
371 iHashedPath = aPath; |
|
372 } |
|
373 |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // CPEngDataEntry::InitializeStoreEntryL() |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 TBool CPEngDataEntry::InitializeStoreEntryL() |
|
380 { |
|
381 delete iData; |
|
382 iData = NULL; |
|
383 iVersion = KErrNone; |
|
384 iLockCount = EFalse; |
|
385 |
|
386 TInt entrySize = KStoreVersionSize; |
|
387 HBufC8* permanentData = NULL; |
|
388 |
|
389 if ( iType & EPEngStorageBasicPermanent ) |
|
390 { |
|
391 permanentData = PermanentFromFileOrNullL(); |
|
392 } |
|
393 |
|
394 |
|
395 if ( permanentData ) |
|
396 { |
|
397 CleanupStack::PushL( permanentData ); |
|
398 entrySize += permanentData->Size(); |
|
399 |
|
400 // permanent data loaded => update version to number 1 |
|
401 iVersion = ETrue; |
|
402 } |
|
403 else |
|
404 { |
|
405 // permanent data not loaded, file does not exists or type |
|
406 // does even have permanent part. |
|
407 return EFalse; |
|
408 } |
|
409 |
|
410 |
|
411 //Setup write stream |
|
412 CBufFlat* buf = CBufFlat::NewL( entrySize ); |
|
413 CleanupStack::PushL( buf ); |
|
414 |
|
415 RBufWriteStream ws; |
|
416 CleanupClosePushL( ws ); |
|
417 ws.Open( *buf ); // CSI: 65 # |
|
418 |
|
419 // Write current version of the entry |
|
420 ws.WriteInt32L( iVersion ); |
|
421 |
|
422 |
|
423 // Go through all types and init ones needed by this entry |
|
424 TPEngStorageType currentType( EPEngStorageBasicFirst ); |
|
425 while ( !( currentType & EPEngStorageBasicLast ) ) |
|
426 { |
|
427 if ( iType & currentType ) |
|
428 { |
|
429 //Write empty part information |
|
430 ws.WriteInt32L( currentType ); |
|
431 ws.WriteInt32L( KErrNotFound ); |
|
432 |
|
433 //If currently handling permanent part and having permanent data, |
|
434 //insert permanent part and update length holder |
|
435 if ( ( currentType & EPEngStorageBasicPermanent ) && permanentData ) |
|
436 { |
|
437 |
|
438 MStreamBuf* rawStream = ws.Sink(); |
|
439 |
|
440 TStreamPos typeStartPos = rawStream->TellL( MStreamBuf::EWrite ); |
|
441 ws.WriteL( *permanentData ); |
|
442 TStreamPos typeEndPos = rawStream->TellL( MStreamBuf::EWrite ); |
|
443 |
|
444 TInt typeLength = typeEndPos - typeStartPos; |
|
445 |
|
446 typeStartPos -= 4; //length holder is TInt32 (4 bytes), just before the actual data |
|
447 rawStream->SeekL( MStreamBuf::EWrite, typeStartPos ); |
|
448 ws.WriteInt32L( typeLength ); |
|
449 rawStream->SeekL( MStreamBuf::EWrite, typeEndPos ); |
|
450 } |
|
451 } |
|
452 |
|
453 currentType = static_cast<TPEngStorageType>( currentType << 1 ); // rotate once to left |
|
454 } |
|
455 |
|
456 iData = buf->Ptr( 0 ).AllocL(); |
|
457 CleanupStack::PopAndDestroy( 2, buf ); |
|
458 |
|
459 |
|
460 if ( permanentData ) |
|
461 { |
|
462 CleanupStack::PopAndDestroy( permanentData ); |
|
463 return ETrue; |
|
464 } |
|
465 else |
|
466 { |
|
467 return EFalse; |
|
468 } |
|
469 } |
|
470 |
|
471 |
|
472 // ============================================================================= |
|
473 // =============== New Protected Functions of the base class =================== |
|
474 // ============================================================================= |
|
475 |
|
476 // ----------------------------------------------------------------------------- |
|
477 // CPEngDataEntry::AddObserverL() |
|
478 // ----------------------------------------------------------------------------- |
|
479 // |
|
480 void CPEngDataEntry::AddObserverL( |
|
481 MPEngHandlerListenSIDs& aObserver ) |
|
482 { |
|
483 TInt err( iObservers.InsertInAddressOrder( &aObserver ) ); |
|
484 err = err == KErrAlreadyExists ? KErrNone : err; |
|
485 User::LeaveIfError( err ); |
|
486 } |
|
487 |
|
488 // ----------------------------------------------------------------------------- |
|
489 // CPEngDataEntry::RemoveObserver() |
|
490 // ----------------------------------------------------------------------------- |
|
491 // |
|
492 void CPEngDataEntry::RemoveObserver( |
|
493 MPEngHandlerListenSIDs& aObserver ) |
|
494 { |
|
495 TInt index( iObservers.FindInAddressOrder( &aObserver ) ); |
|
496 if ( KErrNotFound != index ) |
|
497 { |
|
498 iObservers.Remove( index ); |
|
499 } |
|
500 } |
|
501 |
|
502 // ============================================================================= |
|
503 // =============== New Protected Functions of the base class =================== |
|
504 // ============================================================================= |
|
505 |
|
506 // ----------------------------------------------------------------------------- |
|
507 // CPEngDataEntry::CheckVersionNumberL() |
|
508 // ----------------------------------------------------------------------------- |
|
509 // |
|
510 void CPEngDataEntry::CheckVersionNumberL( |
|
511 const TDesC8& aNewData, |
|
512 TPEngStorageType aType ) |
|
513 { |
|
514 if ( !( aType & EPEngStorageFlagVersionChecked ) ) |
|
515 { |
|
516 return; |
|
517 } |
|
518 |
|
519 |
|
520 // check version |
|
521 RDesReadStream drs( aNewData ); |
|
522 CleanupClosePushL( drs ); |
|
523 TInt clVersion = drs.ReadInt32L(); |
|
524 CleanupStack::PopAndDestroy(); //drs |
|
525 |
|
526 |
|
527 // client version will be by 1 ahead, increased by manager |
|
528 clVersion--; |
|
529 if ( ( iVersion != clVersion ) ) |
|
530 { |
|
531 // leave with error, Session will complete rest |
|
532 User::Leave( KErrAccessDenied ); |
|
533 } |
|
534 } |
|
535 |
|
536 |
|
537 // ----------------------------------------------------------------------------- |
|
538 // CPEngDataEntry::CheckLockSubSessionL() |
|
539 // ----------------------------------------------------------------------------- |
|
540 // |
|
541 void CPEngDataEntry::CheckLockSubSessionL( |
|
542 TInt32 aSessionID, |
|
543 TInt aSubSessionID ) |
|
544 { |
|
545 if ( ( iLockCount > 0 ) |
|
546 && ( ( aSessionID != iLockSession ) |
|
547 || ( aSubSessionID != iLockSubSession ) ) ) |
|
548 { |
|
549 User::Leave( KErrLocked ); |
|
550 } |
|
551 } |
|
552 |
|
553 |
|
554 // ----------------------------------------------------------------------------- |
|
555 // CPEngDataEntry::UpdateVersionNumber() |
|
556 // ----------------------------------------------------------------------------- |
|
557 // |
|
558 void CPEngDataEntry::UpdateVersionNumber() |
|
559 { |
|
560 iVersion = iVersion % KMaxTInt + 1; |
|
561 } |
|
562 |
|
563 |
|
564 |
|
565 // ============================================================================= |
|
566 // =============== New Private Functions of the base class ===================== |
|
567 // ============================================================================= |
|
568 |
|
569 // ----------------------------------------------------------------------------- |
|
570 // CPEngDataEntry::UpdatePermanentPartL() |
|
571 // Updates permanent part on the disc |
|
572 // (other items were commented in a header). |
|
573 // ----------------------------------------------------------------------------- |
|
574 // |
|
575 void CPEngDataEntry::UpdatePermanentPartL( const TDesC8& aNewData ) |
|
576 { |
|
577 RDesReadStream drs( aNewData ); |
|
578 CleanupClosePushL( drs ); |
|
579 |
|
580 drs.ReadInt32L(); // store version of the entry |
|
581 TInt permanentDataLength = KErrNotFound; |
|
582 |
|
583 //Try locate permanent part |
|
584 TrySeekPermanentPartL( drs, permanentDataLength ); |
|
585 |
|
586 //Store permanent part if having one |
|
587 if ( permanentDataLength > 0 ) |
|
588 { |
|
589 HBufC8* permanentDataBuf = HBufC8::NewLC( permanentDataLength ); |
|
590 TPtr8 permanentData( permanentDataBuf->Des() ); |
|
591 drs.ReadL( permanentData, permanentDataLength ); |
|
592 |
|
593 |
|
594 // open temp file, write date into it and rename it to the correct file |
|
595 RFile temp; |
|
596 TFileName fName; |
|
597 User::LeaveIfError( temp.Temp( iFs, |
|
598 iTempFolder, |
|
599 fName, |
|
600 EFileShareExclusive ) ); |
|
601 CleanupClosePushL( temp ); |
|
602 temp.Write( permanentData ); |
|
603 TInt err( iFs.Delete( *iHashedPath ) ); |
|
604 err = err == KErrNotFound ? KErrNone : err; |
|
605 User::LeaveIfError( err ); |
|
606 User::LeaveIfError( temp.Flush() ); |
|
607 CleanupStack::PopAndDestroy(); // temp |
|
608 User::LeaveIfError( iFs.Rename( fName, * iHashedPath ) ) ; |
|
609 |
|
610 CleanupStack::PopAndDestroy( permanentDataBuf ); |
|
611 } |
|
612 |
|
613 CleanupStack::PopAndDestroy(); //drs |
|
614 } |
|
615 |
|
616 |
|
617 // ----------------------------------------------------------------------------- |
|
618 // CPEngDataEntry::TrySeekPermanentPartL() |
|
619 // ----------------------------------------------------------------------------- |
|
620 // |
|
621 void CPEngDataEntry::TrySeekPermanentPartL( RReadStream& aStream, |
|
622 TInt& aPermanentDataLength ) const |
|
623 { |
|
624 TPEngStorageType currentType( EPEngStorageBasicFirst ); |
|
625 while ( !( currentType & EPEngStorageBasicLast ) ) |
|
626 { |
|
627 TInt partType = aStream.ReadInt32L(); |
|
628 if ( partType & EPEngStorageBasicPermanent ) |
|
629 { |
|
630 // quite from loop, we have it |
|
631 aPermanentDataLength = aStream.ReadInt32L(); |
|
632 break; |
|
633 } |
|
634 else |
|
635 { |
|
636 //proceed to next part |
|
637 TInt partLength = aStream.ReadInt32L(); |
|
638 aStream.ReadL( partLength ); |
|
639 } |
|
640 |
|
641 currentType = static_cast<TPEngStorageType>( currentType << 1 ); // rotate once to left |
|
642 } |
|
643 } |
|
644 |
|
645 |
|
646 // ----------------------------------------------------------------------------- |
|
647 // CPEngDataEntry::PermanentFromFileOrNullL() |
|
648 // ----------------------------------------------------------------------------- |
|
649 // |
|
650 HBufC8* CPEngDataEntry::PermanentFromFileOrNullL() const |
|
651 { |
|
652 // if there is no hashed path, return NULL |
|
653 if ( !iHashedPath ) |
|
654 { |
|
655 return NULL; |
|
656 } |
|
657 |
|
658 HBufC8* permanentData = NULL; |
|
659 RFile file; |
|
660 |
|
661 TInt err ( file.Open( iFs, *iHashedPath, EFileRead ) ); |
|
662 if ( err == KErrNotFound ) |
|
663 { |
|
664 permanentData = NULL; |
|
665 } |
|
666 |
|
667 else |
|
668 { |
|
669 User::LeaveIfError( err ); |
|
670 CleanupClosePushL( file ); |
|
671 TInt size; |
|
672 User::LeaveIfError( file.Size( size ) ); |
|
673 |
|
674 permanentData = HBufC8::NewLC( size ); |
|
675 TPtr8 permanentPtr = permanentData->Des(); |
|
676 User::LeaveIfError( file.Read( permanentPtr ) ); |
|
677 |
|
678 CleanupStack::Pop( permanentData ); |
|
679 CleanupStack::PopAndDestroy(); //file |
|
680 } |
|
681 |
|
682 return permanentData; |
|
683 } |
|
684 |
|
685 // ----------------------------------------------------------------------------- |
|
686 // CPEngDataEntry::NotifyUpdate() |
|
687 // ----------------------------------------------------------------------------- |
|
688 // |
|
689 void CPEngDataEntry::NotifyUpdate() |
|
690 { |
|
691 TInt count( iObservers.Count() ); |
|
692 for ( TInt x( 0 ) ; x < count ; ++x ) |
|
693 { |
|
694 iObservers[ x ]->EntryUpdated( *this ); |
|
695 } |
|
696 } |
|
697 |
|
698 |
|
699 // End of File |