1 /* |
|
2 * Copyright (c) 2003-2006 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: metadata struct for a remote file entry |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <bautils.h> |
|
20 |
|
21 #include "rsfwfileentry.h" |
|
22 #include "rsfwfiletable.h" |
|
23 #include "rsfwconfig.h" |
|
24 #include "rsfwvolumetable.h" |
|
25 #include "rsfwvolume.h" |
|
26 #include "rsfwrfeserver.h" |
|
27 #include "rsfwlockmanager.h" |
|
28 #include "mdebug.h" |
|
29 #include "rsfwdirentattr.h" |
|
30 |
|
31 // ---------------------------------------------------------------------------- |
|
32 // CRsfwFileEntry::NewLC |
|
33 // ---------------------------------------------------------------------------- |
|
34 // |
|
35 CRsfwFileEntry* CRsfwFileEntry::NewLC(const TDesC& aName, CRsfwFileEntry* aParent) |
|
36 { |
|
37 CRsfwFileEntry* self = new (ELeave) CRsfwFileEntry(); |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(aName, aParent); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // CRsfwFileEntry::NewL |
|
45 // ---------------------------------------------------------------------------- |
|
46 // |
|
47 CRsfwFileEntry* CRsfwFileEntry::NewL(const TDesC& aName, CRsfwFileEntry* aParent) |
|
48 { |
|
49 CRsfwFileEntry* self = NewLC(aName, aParent); |
|
50 CleanupStack::Pop(self); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ---------------------------------------------------------------------------- |
|
55 // CRsfwFileEntry::NewL |
|
56 // ---------------------------------------------------------------------------- |
|
57 // |
|
58 CRsfwFileEntry* CRsfwFileEntry::NewL(RReadStream& aStream) |
|
59 { |
|
60 CRsfwFileEntry* self = new (ELeave) CRsfwFileEntry(); |
|
61 CleanupStack::PushL(self); |
|
62 self->ConstructL(aStream); |
|
63 CleanupStack::Pop(self); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // CRsfwFileEntry::ConstructL |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 void CRsfwFileEntry::ConstructL(const TDesC& aName, CRsfwFileEntry* aParent) |
|
72 { |
|
73 iType = KNodeTypeUnknown; |
|
74 iParent = aParent; |
|
75 iName = aName.AllocL(); |
|
76 iAtt = KEntryAttRemote; |
|
77 iCachePriority = ECachePriorityNormal; |
|
78 |
|
79 SetLockTimeout(); |
|
80 // Note that we don't yet attach the kid to its parent |
|
81 } |
|
82 |
|
83 // ---------------------------------------------------------------------------- |
|
84 // CRsfwFileEntry::ConstructL |
|
85 // ---------------------------------------------------------------------------- |
|
86 // |
|
87 void CRsfwFileEntry::ConstructL(RReadStream& aStream) |
|
88 { |
|
89 // aStream >> *this; |
|
90 this->InternalizeL(aStream); |
|
91 SetLockTimeout(); |
|
92 // Note that we don't yet attach the kid to its parent |
|
93 } |
|
94 |
|
95 void CRsfwFileEntry::SetLockTimeout() |
|
96 { |
|
97 // When creating a file entry, the lock timeout is set to default |
|
98 // even when internalizing from stream. |
|
99 // We do not assume any locks that would survive server restarts |
|
100 TInt timeout; |
|
101 TInt err = CRsfwRfeServer::Env()->iRsfwConfig->Get(RsfwConfigKeys::KLockTimeout, |
|
102 timeout); |
|
103 if (!err) |
|
104 { |
|
105 iLockTimeout = (TUint)timeout; |
|
106 } |
|
107 else |
|
108 { |
|
109 iLockTimeout = KDefaultLockTimeout; |
|
110 } |
|
111 |
|
112 } |
|
113 |
|
114 // ---------------------------------------------------------------------------- |
|
115 // CRsfwFileEntry::~CRsfwFileEntry |
|
116 // ---------------------------------------------------------------------------- |
|
117 // |
|
118 CRsfwFileEntry::~CRsfwFileEntry() |
|
119 { |
|
120 if (iFlags & KNodeHasValidLock) |
|
121 { |
|
122 if (iLockManager) |
|
123 { |
|
124 iLockManager->RemoveLockedEntry(this); |
|
125 } |
|
126 } |
|
127 delete iName; |
|
128 delete iMimeType; |
|
129 delete iOpaqueFileId; |
|
130 delete iLockToken; |
|
131 |
|
132 if (!iFileTable || !iFileTable->Permanence()) |
|
133 { |
|
134 RemoveCacheFile(); |
|
135 } |
|
136 |
|
137 if ( iFileTable ) |
|
138 { |
|
139 iFileTable->Volume()->iVolumeTable->RemoveFromMetadataLRUPriorityList(this); |
|
140 } |
|
141 |
|
142 delete iLockTimer; |
|
143 |
|
144 // delete kids |
|
145 TInt i; |
|
146 for(i = 0; i < iKids.Count(); i++) |
|
147 { |
|
148 delete iKids[i]; |
|
149 } |
|
150 iKids.Close(); |
|
151 } |
|
152 |
|
153 // ---------------------------------------------------------------------------- |
|
154 // CRsfwFileEntry::FindKidByName |
|
155 // ---------------------------------------------------------------------------- |
|
156 // |
|
157 CRsfwFileEntry* CRsfwFileEntry::FindKidByName(const TDesC& aName) |
|
158 { |
|
159 DEBUGSTRING(("CRsfwFileEntry::FindKidByName")); |
|
160 // finds a kid from a parent directory |
|
161 TInt i; |
|
162 for (i = 0; i < iKids.Count(); i++) |
|
163 { |
|
164 CRsfwFileEntry* kid = iKids[i]; |
|
165 if (kid->iName->Compare(aName) == 0) |
|
166 { |
|
167 return iKids[i]; |
|
168 } |
|
169 } |
|
170 DEBUGSTRING(("...kid not found!")); |
|
171 return NULL; |
|
172 } |
|
173 |
|
174 // ---------------------------------------------------------------------------- |
|
175 // CRsfwFileEntry::RenameL |
|
176 // ---------------------------------------------------------------------------- |
|
177 // |
|
178 void CRsfwFileEntry::RenameL(const TDesC& aName) |
|
179 { |
|
180 delete iName; |
|
181 iName = NULL; |
|
182 iName = aName.AllocL(); |
|
183 ReportEvent(KNotifyNodeModified); |
|
184 } |
|
185 |
|
186 // ---------------------------------------------------------------------------- |
|
187 // CRsfwFileEntry::AddKid |
|
188 // ---------------------------------------------------------------------------- |
|
189 // |
|
190 void CRsfwFileEntry::AddKid(CRsfwFileEntry& aFe) |
|
191 { |
|
192 // if this is the first kid to be added then probably |
|
193 // we have to remove the entry from metadata LRU list |
|
194 if ( iKids.Count() == 0 ) |
|
195 { |
|
196 iFileTable->Volume()->iVolumeTable->RemoveFromMetadataLRUPriorityList(this); |
|
197 } |
|
198 iKids.Append(&aFe); |
|
199 // (This assignment is sometimes redundant) |
|
200 aFe.SetParent(this); |
|
201 ReportEvent(KNotifyNodeModified); |
|
202 } |
|
203 |
|
204 // ---------------------------------------------------------------------------- |
|
205 // CRsfwFileEntry::RemoveKidL |
|
206 // ---------------------------------------------------------------------------- |
|
207 // |
|
208 TInt CRsfwFileEntry::RemoveKidL(CRsfwFileEntry* aFep) |
|
209 { |
|
210 TInt i; |
|
211 for (i = 0; i < iKids.Count(); i++) |
|
212 { |
|
213 if (iKids[i] == aFep) |
|
214 { |
|
215 ReportEvent(KNotifyNodeModified); |
|
216 iKids.Remove(i); |
|
217 // if we've just removed the last kid of the entry |
|
218 // we can add the entry to metadata LRU list |
|
219 if ( iKids.Count() == 0 ) |
|
220 { |
|
221 iFileTable->Volume()->iVolumeTable->AddToMetadataLRUPriorityListL(this, ECachePriorityNormal); |
|
222 } |
|
223 return KErrNone; |
|
224 } |
|
225 } |
|
226 DEBUGSTRING(("remove kid %d not found in %d", |
|
227 aFep->Fid().iNodeId, |
|
228 Fid().iNodeId)); |
|
229 return KErrNotFound; |
|
230 } |
|
231 |
|
232 // ---------------------------------------------------------------------------- |
|
233 // CRsfwFileEntry::KidsCount |
|
234 // ---------------------------------------------------------------------------- |
|
235 // |
|
236 TInt CRsfwFileEntry::KidsCount() |
|
237 { |
|
238 return iKids.Count(); |
|
239 } |
|
240 |
|
241 |
|
242 // ---------------------------------------------------------------------------- |
|
243 // CRsfwFileEntry::UnmarkKids |
|
244 // ---------------------------------------------------------------------------- |
|
245 // |
|
246 void CRsfwFileEntry::UnmarkKids() |
|
247 { |
|
248 TInt i; |
|
249 for (i = 0; i < iKids.Count(); i++) |
|
250 { |
|
251 iKids[i]->Unmark(); |
|
252 } |
|
253 } |
|
254 |
|
255 // ---------------------------------------------------------------------------- |
|
256 // CRsfwFileEntry::DropUnmarkedKidsL |
|
257 // ---------------------------------------------------------------------------- |
|
258 // |
|
259 void CRsfwFileEntry::DropUnmarkedKidsL() |
|
260 { |
|
261 TInt i = 0; |
|
262 while (i < iKids.Count()) |
|
263 { |
|
264 if (!iKids[i]->IsMarked()) |
|
265 { |
|
266 iKids[i]->DropLD(); |
|
267 } |
|
268 else |
|
269 { |
|
270 i++; |
|
271 } |
|
272 } |
|
273 } |
|
274 |
|
275 // ---------------------------------------------------------------------------- |
|
276 // CRsfwFileEntry::DropLD |
|
277 // ---------------------------------------------------------------------------- |
|
278 // |
|
279 void CRsfwFileEntry::DropLD() |
|
280 { |
|
281 DEBUGSTRING(("CRsfwFileEntry::DropLD")); |
|
282 TInt i = 0; |
|
283 while (i < iKids.Count()) |
|
284 { |
|
285 iKids[i]->DropLD(); |
|
286 } |
|
287 |
|
288 iFileTable->RemoveL(this); |
|
289 delete this; |
|
290 } |
|
291 |
|
292 // ---------------------------------------------------------------------------- |
|
293 // CRsfwFileEntry::GetAttributes |
|
294 // ---------------------------------------------------------------------------- |
|
295 // |
|
296 void CRsfwFileEntry::GetAttributes(TDirEntAttr& aAttr) const |
|
297 { |
|
298 aAttr.iAtt = Att(); |
|
299 aAttr.iSize = Size(); |
|
300 aAttr.iModified = Modified(); |
|
301 } |
|
302 |
|
303 // ---------------------------------------------------------------------------- |
|
304 // CRsfwFileEntry::GetAttributesL |
|
305 // ---------------------------------------------------------------------------- |
|
306 // |
|
307 void CRsfwFileEntry::GetAttributesL(CRsfwDirEntAttr& aAttr) const |
|
308 { |
|
309 aAttr.SetAtt(Att()); |
|
310 aAttr.SetSize(Size()); |
|
311 aAttr.SetModified(Modified()); |
|
312 if (iOpaqueFileId) |
|
313 { |
|
314 aAttr.SetETagL(*OpaqueFileId()); |
|
315 } |
|
316 } |
|
317 |
|
318 // ---------------------------------------------------------------------------- |
|
319 // CRsfwFileEntry::SetAttributesL |
|
320 // ---------------------------------------------------------------------------- |
|
321 // |
|
322 void CRsfwFileEntry::SetAttributesL(CRsfwDirEntAttr& aAttr, |
|
323 TBool aAllMetaData) |
|
324 { |
|
325 SetAtt(aAttr.Att()); |
|
326 if (aAllMetaData) |
|
327 { |
|
328 SetSize(aAttr.Size()); |
|
329 SetModified(aAttr.Modified()); |
|
330 if (aAttr.MimeType()) |
|
331 { |
|
332 SetMimeTypeL(*aAttr.MimeType()); |
|
333 } |
|
334 if (aAttr.ETag()) |
|
335 { |
|
336 SetOpaqueFileIdL(*aAttr.ETag()); |
|
337 } |
|
338 SetUid(aAttr.Uid()); |
|
339 SetAttribValidationTime(); |
|
340 } |
|
341 |
|
342 } |
|
343 |
|
344 // ---------------------------------------------------------------------------- |
|
345 // CRsfwFileEntry::CacheFileName |
|
346 // ---------------------------------------------------------------------------- |
|
347 // |
|
348 TDesC* CRsfwFileEntry::CacheFileName() |
|
349 { |
|
350 DEBUGSTRING(("CRsfwFileEntry::CacheFileName")); |
|
351 if (iCacheName.Length()) |
|
352 { |
|
353 return &iCacheName; |
|
354 } |
|
355 return NULL; |
|
356 } |
|
357 |
|
358 // ---------------------------------------------------------------------------- |
|
359 // CRsfwFileEntry::SetCacheFileName |
|
360 // ---------------------------------------------------------------------------- |
|
361 // |
|
362 void CRsfwFileEntry::SetCacheFileName(TDesC* aFn) |
|
363 { |
|
364 DEBUGSTRING16(("SetCacheFileName for file %S", Name())); |
|
365 if (aFn) |
|
366 { |
|
367 iCacheName = *aFn; |
|
368 ReportEvent(KNotifyNodeModified); |
|
369 } |
|
370 else |
|
371 { |
|
372 if (iCacheName.Length()) |
|
373 { |
|
374 if (IsCached()) |
|
375 { |
|
376 // Remove the cache list entry... |
|
377 iFileTable-> |
|
378 Volume()-> |
|
379 iVolumeTable->RemoveFromLRUPriorityList(this); |
|
380 } |
|
381 // This is a request to discard the container |
|
382 RFs fs = CRsfwRfeServer::Env()->iFs; |
|
383 TInt err = fs.Delete(iCacheName); |
|
384 if (err != KErrNone) |
|
385 { |
|
386 DEBUGSTRING(("Cannot purge cache file (err=%d)", err)); |
|
387 } |
|
388 iCacheName.Zero(); |
|
389 // Reset locally dirty in case this is a directory. |
|
390 // "locally dirty" means that the container |
|
391 // doesn't have the "cached"/"protected" indicator bits up to date |
|
392 // (these indicators refer to files contained in the directory). |
|
393 iFlags &= ~KNodeLocallyDirty; |
|
394 ReportEvent(KNotifyNodeModified); |
|
395 } |
|
396 } |
|
397 } |
|
398 |
|
399 // ---------------------------------------------------------------------------- |
|
400 // CRsfwFileEntry::IsCached |
|
401 // ---------------------------------------------------------------------------- |
|
402 // |
|
403 TBool CRsfwFileEntry::IsCached() const |
|
404 { |
|
405 DEBUGSTRING(("CRsfwFileEntry::IsCached, iAtt = %d, iFlags = %d", iAtt, iFlags)); |
|
406 if (((iAtt & KEntryAttRemote) == 0) || |
|
407 (iFlags & KNodePartlyCached)) |
|
408 { |
|
409 DEBUGSTRING(("returning ETrue")); |
|
410 // File is either fully or partly cached |
|
411 return ETrue; |
|
412 } |
|
413 |
|
414 DEBUGSTRING(("returning EFalse")); |
|
415 return EFalse; |
|
416 } |
|
417 |
|
418 // ---------------------------------------------------------------------------- |
|
419 // CRsfwFileEntry::IsFullyCached |
|
420 // ---------------------------------------------------------------------------- |
|
421 // |
|
422 TBool CRsfwFileEntry::IsFullyCached() const |
|
423 { |
|
424 DEBUGSTRING(("CRsfwFileEntry::IsFullyCached")); |
|
425 DEBUGSTRING(("iCachedSize = %d, iSize = %d", iCachedSize, iSize)); |
|
426 if (Type() == KNodeTypeDir) |
|
427 { |
|
428 return IsCached(); |
|
429 } |
|
430 else |
|
431 { |
|
432 if (iCachedSize == iSize) |
|
433 { |
|
434 return IsCached(); |
|
435 } |
|
436 else |
|
437 { |
|
438 return EFalse; |
|
439 } |
|
440 } |
|
441 } |
|
442 |
|
443 // ---------------------------------------------------------------------------- |
|
444 // CRsfwFileEntry::SetCached |
|
445 // ---------------------------------------------------------------------------- |
|
446 // |
|
447 void CRsfwFileEntry::SetCached(TBool aCached) |
|
448 { |
|
449 DEBUGSTRING(("CRsfwFileEntry::SetCached")); |
|
450 TUint oldAtt = iAtt; |
|
451 if (aCached) |
|
452 { |
|
453 if (Type() == KNodeTypeDir) |
|
454 { |
|
455 // set to fully cached |
|
456 DEBUGSTRING(("set directory to fully cached")); |
|
457 iAtt &= ~KEntryAttRemote; |
|
458 iFlags &= ~KNodePartlyCached; |
|
459 } |
|
460 else |
|
461 { |
|
462 if (iCachedSize == iSize) |
|
463 { |
|
464 // set file to fully cached |
|
465 DEBUGSTRING(("set file to fully cached")); |
|
466 iAtt &= ~KEntryAttRemote; |
|
467 iFlags &= ~KNodePartlyCached; |
|
468 } |
|
469 else |
|
470 { |
|
471 // Set file to partly cached |
|
472 DEBUGSTRING(("set file to partly cached")); |
|
473 iAtt |= KEntryAttRemote; |
|
474 iFlags |= KNodePartlyCached; |
|
475 } |
|
476 } |
|
477 } |
|
478 else |
|
479 { |
|
480 // set to "fully" remote |
|
481 DEBUGSTRING(("set to fully remote")); |
|
482 iFlags &= ~KNodePartlyCached; |
|
483 iAtt |= KEntryAttRemote; |
|
484 iUseCachedData = EFalse; |
|
485 iCachedSize = 0; |
|
486 } |
|
487 if (iAtt != oldAtt) |
|
488 { |
|
489 ReportEvent(KNotifyNodeModified); |
|
490 } |
|
491 } |
|
492 |
|
493 // ---------------------------------------------------------------------------- |
|
494 // CRsfwFileEntry::SetCachedSize |
|
495 // ---------------------------------------------------------------------------- |
|
496 // |
|
497 void CRsfwFileEntry::SetCachedSize(TInt aFetchedSize) |
|
498 { |
|
499 TInt oldCachedSize = iCachedSize; |
|
500 iCachedSize = aFetchedSize; |
|
501 if (iCachedSize != oldCachedSize) |
|
502 { |
|
503 ReportEvent(KNotifyNodeModified); |
|
504 } |
|
505 } |
|
506 |
|
507 // ---------------------------------------------------------------------------- |
|
508 // CRsfwFileEntry::RemoveCacheFile |
|
509 // ---------------------------------------------------------------------------- |
|
510 // |
|
511 void CRsfwFileEntry::RemoveCacheFile() |
|
512 { |
|
513 DEBUGSTRING(("CRsfwFileEntry::RemoveCacheFile")); |
|
514 if (IsCached() && iFileTable) |
|
515 { |
|
516 // Remove the cache list entry... |
|
517 iFileTable->Volume()->iVolumeTable->RemoveFromLRUPriorityList(this); |
|
518 } |
|
519 |
|
520 if (iCacheName.Length()) |
|
521 { |
|
522 RFs fs = CRsfwRfeServer::Env()->iFs; |
|
523 TInt err = fs.Delete(iCacheName); |
|
524 if ((err != KErrNone) && (err != KErrNotFound)) |
|
525 { |
|
526 DEBUGSTRING(("Cannot delete cache file (err=%d)", err)); |
|
527 } |
|
528 iCacheName.Zero(); |
|
529 } |
|
530 SetCached(EFalse); |
|
531 } |
|
532 |
|
533 // ---------------------------------------------------------------------------- |
|
534 // CRsfwFileEntry::ValidateCacheFile |
|
535 // Function checks whether cache file has not been accidentally or intentionally |
|
536 // removed from the cache (which would mean the cache has been corrupted) |
|
537 // In case the corruption has happened, the function sets entry as non-cached |
|
538 // ---------------------------------------------------------------------------- |
|
539 // |
|
540 void CRsfwFileEntry::ValidateCacheFile() |
|
541 { |
|
542 if (iCacheName.Length() > 0) |
|
543 { |
|
544 RFs fs = CRsfwRfeServer::Env()->iFs; |
|
545 if (! BaflUtils::FileExists(fs, iCacheName)) |
|
546 { |
|
547 SetCached(EFalse); |
|
548 } |
|
549 } |
|
550 } |
|
551 |
|
552 // ---------------------------------------------------------------------------- |
|
553 // CRsfwFileEntry::PrintL |
|
554 // ---------------------------------------------------------------------------- |
|
555 // |
|
556 #ifdef _DEBUG |
|
557 void CRsfwFileEntry::PrintL(TInt aLevel, TBool aKids, TBool aAll) const |
|
558 { |
|
559 if (!IsCached() && !aAll) |
|
560 { |
|
561 // Print only information about cached files |
|
562 return; |
|
563 } |
|
564 |
|
565 HBufC* sBuf = HBufC::NewLC(KMaxPath); |
|
566 TPtr s = sBuf->Des(); |
|
567 |
|
568 s.Fill(' ', 4 * aLevel); |
|
569 s.AppendNum(iFid.iNodeId); |
|
570 s.Append('|'); |
|
571 s.Append(*iName); |
|
572 switch (iType) |
|
573 { |
|
574 case KNodeTypeDir: |
|
575 s.Append('/'); |
|
576 break; |
|
577 |
|
578 case KNodeTypeFile: |
|
579 break; |
|
580 |
|
581 default: |
|
582 s.Append('?'); |
|
583 break; |
|
584 } |
|
585 |
|
586 if (IsCached()) |
|
587 { |
|
588 s.Append('|'); |
|
589 s.Append(iCacheName); |
|
590 } |
|
591 |
|
592 DEBUGBUFFER((s)); |
|
593 |
|
594 CleanupStack::PopAndDestroy(sBuf); // sBuf |
|
595 |
|
596 if (aKids) |
|
597 { |
|
598 TInt i; |
|
599 for (i = 0; i < iKids.Count(); i++) |
|
600 { |
|
601 iKids[i]->PrintL(aLevel + 1, aKids, aAll); |
|
602 } |
|
603 } |
|
604 } |
|
605 #else |
|
606 void CRsfwFileEntry::PrintL(TInt, TBool, TBool) const |
|
607 { |
|
608 } |
|
609 #endif //DEBUG |
|
610 |
|
611 |
|
612 // ---------------------------------------------------------------------------- |
|
613 // CRsfwFileEntry::FullNameLC |
|
614 // Construct full name relative to the root. |
|
615 // The caller is responsible for deallocating the return value. |
|
616 // ---------------------------------------------------------------------------- |
|
617 // |
|
618 HBufC* CRsfwFileEntry::FullNameLC() const |
|
619 { |
|
620 // We know that we can't have more than KMaxPath entries, |
|
621 // because each entry is minimally "/" |
|
622 CRsfwFileEntry* entList[KMaxPath / 2]; |
|
623 |
|
624 HBufC* fn = HBufC::NewLC(KMaxPath); |
|
625 TPtr fnp = fn->Des(); |
|
626 CRsfwFileEntry* fep = const_cast<CRsfwFileEntry*>(this); |
|
627 TInt depth = 0; |
|
628 do |
|
629 { |
|
630 if (depth >= (KMaxPath / 2)) |
|
631 { |
|
632 // Too deep hierarchy |
|
633 DEBUGSTRING(("CRsfwFileEntry::FullNameLC - Too deep hierarchy! %d", depth)); |
|
634 User::Leave(KErrGeneral); |
|
635 } |
|
636 entList[depth++] = fep; |
|
637 fep = fep->iParent; |
|
638 } |
|
639 while (fep); |
|
640 |
|
641 // We want to avoid going right to the root to avoid dots |
|
642 depth--; |
|
643 |
|
644 TInt i; |
|
645 for (i = depth - 1; i >= 0; i--) |
|
646 { |
|
647 TPtr name = entList[i]->iName->Des(); |
|
648 if (i != (depth - 1)) |
|
649 { |
|
650 // Skip "this" directories (should not happen) |
|
651 if ((name[0] == '.') && (name.Length() == 1)) |
|
652 { |
|
653 continue; |
|
654 } |
|
655 } |
|
656 if ((fnp.Length() + name.Length()) >= (KMaxPath - 1)) |
|
657 { |
|
658 // Too long name |
|
659 DEBUGSTRING(("CRsfwFileEntry::FullNameLC - Too long name!")); |
|
660 User::Leave(KErrGeneral); |
|
661 } |
|
662 fnp.Append(name); |
|
663 if (i != 0) |
|
664 { |
|
665 fnp.Append('/'); |
|
666 } |
|
667 } |
|
668 |
|
669 return fn; |
|
670 } |
|
671 |
|
672 // ---------------------------------------------------------------------------- |
|
673 // CRsfwFileEntry::TotalCachedSize |
|
674 // ---------------------------------------------------------------------------- |
|
675 // |
|
676 TInt CRsfwFileEntry::TotalCachedSize() |
|
677 { |
|
678 TInt cachedSize = 0; |
|
679 TInt i; |
|
680 |
|
681 for (i = 0; i < iKids.Count(); i++) |
|
682 { |
|
683 TInt newSize = iKids[i]->TotalCachedSize(); |
|
684 cachedSize = cachedSize + newSize; |
|
685 } |
|
686 cachedSize = cachedSize + iCachedSize; |
|
687 return cachedSize; |
|
688 } |
|
689 |
|
690 // ---------------------------------------------------------------------------- |
|
691 // CRsfwFileEntry::TotalEntryCount |
|
692 // ---------------------------------------------------------------------------- |
|
693 // |
|
694 TInt CRsfwFileEntry::TotalEntryCount() |
|
695 { |
|
696 TInt entryCount = 0; |
|
697 TInt i; |
|
698 for (i = 0; i < iKids.Count(); i++) |
|
699 { |
|
700 TInt kidCount = iKids[i]->TotalEntryCount(); |
|
701 entryCount += kidCount; |
|
702 } |
|
703 entryCount += 1; // itself |
|
704 return entryCount; |
|
705 } |
|
706 |
|
707 // ---------------------------------------------------------------------------- |
|
708 // CRsfwFileEntry::Lookup |
|
709 // ---------------------------------------------------------------------------- |
|
710 // |
|
711 CRsfwFileEntry* CRsfwFileEntry::Lookup(const TFid& aFid) |
|
712 { |
|
713 // linear search - immediate kids first |
|
714 TInt i; |
|
715 for (i = 0; i < iKids.Count(); i++) |
|
716 { |
|
717 CRsfwFileEntry* fep = iKids[i]; |
|
718 if (fep->Fid().iNodeId == aFid.iNodeId) |
|
719 { |
|
720 return iKids[i]; |
|
721 } |
|
722 } |
|
723 // Not found - lookup the kids' kids |
|
724 for (i = 0; i < iKids.Count(); i++) |
|
725 { |
|
726 CRsfwFileEntry* fep; |
|
727 fep = iKids[i]->Lookup(aFid); |
|
728 if (fep) |
|
729 { |
|
730 return fep; |
|
731 } |
|
732 } |
|
733 return NULL; |
|
734 } |
|
735 |
|
736 // ---------------------------------------------------------------------------- |
|
737 // CRsfwFileEntry::SetLockedL |
|
738 // ---------------------------------------------------------------------------- |
|
739 // |
|
740 void CRsfwFileEntry::SetLockedL(CRsfwLockManager* lockManager, TDesC8* aLockToken) |
|
741 { |
|
742 DEBUGSTRING16(("Set locked: marking file '%S' locked", Name())); |
|
743 if (iLockTimeout > 0) |
|
744 { |
|
745 if (!iLockTimer) |
|
746 { |
|
747 iLockTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
748 } |
|
749 |
|
750 // attempt to refresh when one third of the timeout has expired |
|
751 TCallBack callBack(CRsfwFileEntry::LockTimerExpiredL, this); |
|
752 iLockTimer->Start(1000000*(iLockTimeout/KLockRefreshAdjustment), |
|
753 1000000*(iLockTimeout/KLockRefreshAdjustment), |
|
754 callBack); |
|
755 } |
|
756 iFlags |= KNodeHasValidLock; |
|
757 iLockManager = lockManager; |
|
758 iLockManager->AddLockedEntryL(this); |
|
759 if (aLockToken) |
|
760 { |
|
761 // We were not just refreshing the lock |
|
762 delete iLockToken; |
|
763 iLockToken = aLockToken; |
|
764 } |
|
765 ReportEvent(KNotifyNodeModified); |
|
766 } |
|
767 |
|
768 // ---------------------------------------------------------------------------- |
|
769 // CRsfwFileEntry::RemoveLocked |
|
770 // ---------------------------------------------------------------------------- |
|
771 // |
|
772 void CRsfwFileEntry::RemoveLocked() |
|
773 { |
|
774 DEBUGSTRING16(("Remove locked: marking file '%S' unlocked", Name())); |
|
775 if (iFlags & KNodeHasValidLock) |
|
776 { |
|
777 iLockManager->RemoveLockedEntry(this); |
|
778 iLockManager = NULL; // will be set in SetLockedL, if needed once again |
|
779 iFlags &= ~KNodeHasValidLock; |
|
780 ReportEvent(KNotifyNodeModified); |
|
781 } |
|
782 |
|
783 if (iLockToken) |
|
784 { |
|
785 delete iLockToken; |
|
786 iLockToken = NULL; |
|
787 } |
|
788 if (iLockTimer) |
|
789 { |
|
790 delete iLockTimer; |
|
791 iLockTimer = NULL; |
|
792 } |
|
793 } |
|
794 |
|
795 // ---------------------------------------------------------------------------- |
|
796 // CRsfwFileEntry::LockTimerExpiredL |
|
797 // ---------------------------------------------------------------------------- |
|
798 // |
|
799 TInt CRsfwFileEntry::LockTimerExpiredL(TAny* aParam) |
|
800 { |
|
801 CRsfwFileEntry* fe = static_cast<CRsfwFileEntry*>(aParam); |
|
802 DEBUGSTRING16(("Lock timer expired for '%S'", fe->Name())); |
|
803 fe->iLockManager->RefreshLockL(fe); |
|
804 return KErrNone; |
|
805 } |
|
806 |
|
807 // ---------------------------------------------------------------------------- |
|
808 // CRsfwFileEntry::UseCachedData |
|
809 // ---------------------------------------------------------------------------- |
|
810 // |
|
811 TBool CRsfwFileEntry::UseCachedData() |
|
812 { |
|
813 // now meta data should tell us whether to use cached data or not |
|
814 return iUseCachedData && !RemotelyDirty(); |
|
815 } |
|
816 |
|
817 // ---------------------------------------------------------------------------- |
|
818 // CRsfwFileEntry::SetAttribValidationTime |
|
819 // ---------------------------------------------------------------------------- |
|
820 // |
|
821 void CRsfwFileEntry::SetAttribValidationTime() |
|
822 { |
|
823 iAttribValidation.UniversalTime(); |
|
824 } |
|
825 |
|
826 // ---------------------------------------------------------------------------- |
|
827 // CRsfwFileEntry::ExternalizeL |
|
828 // ---------------------------------------------------------------------------- |
|
829 // |
|
830 void CRsfwFileEntry::ExternalizeL(RWriteStream& aStream) const |
|
831 { |
|
832 DEBUGSTRING16(("CRsfwFileEntry::ExternalizeL for node %d", iFid.iNodeId)); |
|
833 DEBUGSTRING16(("iFlags: %d", &iFlags)); |
|
834 // The node Id must be the first entry |
|
835 |
|
836 // iNodeId, iParentNodeId, iType, iSize, iAtt, iModified, iFlags, |
|
837 // iCachedSize, iCachePriority |
|
838 // iCacheName, iName, iMimeType, |
|
839 // iOpaqueFileId, iLockToken |
|
840 |
|
841 aStream.WriteInt32L(iFid.iNodeId); |
|
842 if (iParent) |
|
843 { |
|
844 aStream.WriteUint32L(iParent->Fid().iNodeId); |
|
845 } |
|
846 else |
|
847 { |
|
848 // Root |
|
849 aStream.WriteUint32L(0); |
|
850 } |
|
851 aStream.WriteUint8L(iType); |
|
852 aStream.WriteInt32L(iSize); |
|
853 aStream.WriteUint32L(iAtt); |
|
854 aStream.WriteUint32L(I64HIGH(iModified.Int64())); |
|
855 aStream.WriteUint32L(I64LOW(iModified.Int64())); |
|
856 aStream.WriteUint32L(iFlags); |
|
857 aStream.WriteInt32L(iCachedSize); |
|
858 aStream.WriteInt32L(iCachePriority); |
|
859 aStream.WriteInt32L(iUseCachedData); |
|
860 aStream << iCacheName; |
|
861 |
|
862 HBufC* null = HBufC::NewLC(0); |
|
863 if (iName) |
|
864 { |
|
865 aStream << *iName; |
|
866 } |
|
867 else |
|
868 { |
|
869 aStream << *null; |
|
870 } |
|
871 |
|
872 if (iMimeType) |
|
873 { |
|
874 aStream << *iMimeType; |
|
875 } |
|
876 else |
|
877 { |
|
878 aStream << *null; |
|
879 } |
|
880 |
|
881 if (iOpaqueFileId) |
|
882 { |
|
883 aStream << *iOpaqueFileId; |
|
884 } |
|
885 else |
|
886 { |
|
887 aStream << *null; |
|
888 } |
|
889 |
|
890 if (iLockToken) |
|
891 { |
|
892 aStream << *iLockToken; |
|
893 } |
|
894 else |
|
895 { |
|
896 aStream << *null; |
|
897 } |
|
898 |
|
899 CleanupStack::PopAndDestroy(null); // null |
|
900 } |
|
901 |
|
902 // ---------------------------------------------------------------------------- |
|
903 // CRsfwFileEntry::InternalizeL |
|
904 // ---------------------------------------------------------------------------- |
|
905 // |
|
906 void CRsfwFileEntry::InternalizeL(RReadStream& aStream) |
|
907 { |
|
908 DEBUGSTRING16(("CRsfwFileEntry::InternalizeL for node %d", iFid.iNodeId)); |
|
909 // iNodeId, iParentNodeId, iType, iSize, iAtt, iModified, iFlags, |
|
910 // iCachedSize, iCachePriority |
|
911 // iCacheName, iName, iMimeType, |
|
912 // iOpaqueFileId, iLockToken |
|
913 |
|
914 // make some basic checking whether data being internalized is correct |
|
915 iFid.iNodeId = aStream.ReadInt32L(); |
|
916 if (iFid.iNodeId < 0) |
|
917 { |
|
918 User::Leave(KErrCorrupt); |
|
919 } |
|
920 iParentNodeId = aStream.ReadInt32L(); |
|
921 if (iParentNodeId < 0) |
|
922 { |
|
923 User::Leave(KErrCorrupt); |
|
924 } |
|
925 iType = aStream.ReadUint8L(); |
|
926 iSize = aStream.ReadInt32L(); |
|
927 if (iSize < 0) |
|
928 { |
|
929 User::Leave(KErrCorrupt); |
|
930 } |
|
931 iAtt = aStream.ReadUint32L(); |
|
932 TInt highTime = aStream.ReadUint32L(); |
|
933 TInt lowTime = aStream.ReadUint32L(); |
|
934 iModified = MAKE_TINT64(highTime, lowTime); |
|
935 iFlags = aStream.ReadUint32L(); |
|
936 DEBUGSTRING16(("iFlags: %d", &iFlags)); |
|
937 iCachedSize = aStream.ReadInt32L(); |
|
938 if (iCachedSize < 0) |
|
939 { |
|
940 User::Leave(KErrCorrupt); |
|
941 } |
|
942 iCachePriority = aStream.ReadInt32L(); |
|
943 iUseCachedData = aStream.ReadInt32L(); |
|
944 aStream >> iCacheName; |
|
945 |
|
946 HBufC* buf = HBufC::NewL(aStream, KMaxPath); |
|
947 if (buf->Length()) |
|
948 { |
|
949 iName = buf; |
|
950 } |
|
951 else |
|
952 { |
|
953 delete buf; |
|
954 buf = NULL; |
|
955 } |
|
956 |
|
957 // MimeType |
|
958 HBufC8* buf8 = HBufC8::NewL(aStream, KMaxPath); |
|
959 if (buf8->Length()) |
|
960 { |
|
961 iMimeType = buf8; |
|
962 } |
|
963 else |
|
964 { |
|
965 delete buf8; |
|
966 } |
|
967 |
|
968 // OpaqueFileId |
|
969 buf8 = HBufC8::NewL(aStream, KMaxPath); |
|
970 if (buf8->Length()) |
|
971 { |
|
972 iOpaqueFileId = buf8; |
|
973 } |
|
974 else |
|
975 { |
|
976 delete buf8; |
|
977 } |
|
978 |
|
979 // LockToken |
|
980 buf8 = HBufC8::NewL(aStream, KMaxPath); |
|
981 if (buf8->Length()) |
|
982 { |
|
983 iLockToken = buf8; |
|
984 } |
|
985 else |
|
986 { |
|
987 delete buf8; |
|
988 } |
|
989 } |
|
990 |
|
991 // ---------------------------------------------------------------------------- |
|
992 // CRsfwFileEntry::SetType |
|
993 // ---------------------------------------------------------------------------- |
|
994 // |
|
995 void CRsfwFileEntry::SetType(TUint8 aType) |
|
996 { |
|
997 TUint8 oldType = iType; |
|
998 iType = aType; |
|
999 if (aType == KNodeTypeDir) |
|
1000 { |
|
1001 iAtt |= KEntryAttDir; |
|
1002 } |
|
1003 else |
|
1004 { |
|
1005 iAtt &= ~KEntryAttDir; |
|
1006 } |
|
1007 if (iType != oldType) |
|
1008 { |
|
1009 ReportEvent(KNotifyNodeModified); |
|
1010 } |
|
1011 } |
|
1012 |
|
1013 // ---------------------------------------------------------------------------- |
|
1014 // CRsfwFileEntry::SetSize |
|
1015 // ---------------------------------------------------------------------------- |
|
1016 // |
|
1017 void CRsfwFileEntry::SetSize(TInt aSize) |
|
1018 { |
|
1019 TInt oldSize = iSize; |
|
1020 iSize = aSize; |
|
1021 if (iSize != oldSize) |
|
1022 { |
|
1023 ReportEvent(KNotifyNodeModified); |
|
1024 } |
|
1025 } |
|
1026 |
|
1027 // ---------------------------------------------------------------------------- |
|
1028 // CRsfwFileEntry::SetModified |
|
1029 // ---------------------------------------------------------------------------- |
|
1030 // |
|
1031 void CRsfwFileEntry::SetModified(const TTime& aModified) |
|
1032 { |
|
1033 TTime oldModified = iModified; |
|
1034 iModified = aModified; |
|
1035 if (iModified != oldModified) |
|
1036 { |
|
1037 ReportEvent(KNotifyNodeModified); |
|
1038 } |
|
1039 } |
|
1040 |
|
1041 // ---------------------------------------------------------------------------- |
|
1042 // CRsfwFileEntry::SetAtt |
|
1043 // ---------------------------------------------------------------------------- |
|
1044 // |
|
1045 void CRsfwFileEntry::SetAtt(TUint aAtt) |
|
1046 { |
|
1047 // Don't change caching and protected state |
|
1048 TUint oldAtt = iAtt; |
|
1049 if (IsFullyCached()) |
|
1050 { |
|
1051 aAtt &= ~KEntryAttRemote; |
|
1052 } |
|
1053 else |
|
1054 { |
|
1055 aAtt |= KEntryAttRemote; |
|
1056 } |
|
1057 iAtt = aAtt; |
|
1058 |
|
1059 // Set node type |
|
1060 if (iAtt & KEntryAttDir) |
|
1061 { |
|
1062 iType = KNodeTypeDir; |
|
1063 } |
|
1064 else |
|
1065 { |
|
1066 iType = KNodeTypeFile; |
|
1067 } |
|
1068 |
|
1069 if (iAtt != oldAtt) |
|
1070 { |
|
1071 ReportEvent(KNotifyNodeModified); |
|
1072 } |
|
1073 } |
|
1074 |
|
1075 // ---------------------------------------------------------------------------- |
|
1076 // CRsfwFileEntry::SetMimeTypeL |
|
1077 // ---------------------------------------------------------------------------- |
|
1078 // |
|
1079 void CRsfwFileEntry::SetMimeTypeL(const TDesC8& aMimeType) |
|
1080 { |
|
1081 if (iMimeType) |
|
1082 { |
|
1083 delete iMimeType; |
|
1084 iMimeType = NULL; |
|
1085 } |
|
1086 if (aMimeType.Length()) |
|
1087 { |
|
1088 iMimeType = aMimeType.AllocL(); |
|
1089 } |
|
1090 |
|
1091 } |
|
1092 |
|
1093 // ---------------------------------------------------------------------------- |
|
1094 // CRsfwFileEntry::SetOpaqueFileIdL |
|
1095 // ---------------------------------------------------------------------------- |
|
1096 // |
|
1097 void CRsfwFileEntry::SetOpaqueFileIdL(const TDesC8& aOpaqueFileId) |
|
1098 { |
|
1099 if (iOpaqueFileId) |
|
1100 { |
|
1101 delete iOpaqueFileId; |
|
1102 iOpaqueFileId = NULL; |
|
1103 } |
|
1104 if (aOpaqueFileId.Length()) |
|
1105 { |
|
1106 iOpaqueFileId = aOpaqueFileId.AllocL(); |
|
1107 } |
|
1108 } |
|
1109 |
|
1110 // ---------------------------------------------------------------------------- |
|
1111 // CRsfwFileEntry::IsLocallyDirty |
|
1112 // ---------------------------------------------------------------------------- |
|
1113 // |
|
1114 TBool CRsfwFileEntry::IsLocallyDirty() const |
|
1115 { |
|
1116 DEBUGSTRING16(("IsLocallyDirty for file %S", Name())); |
|
1117 return (iFlags & KNodeLocallyDirty) != 0; |
|
1118 } |
|
1119 |
|
1120 // ---------------------------------------------------------------------------- |
|
1121 // CRsfwFileEntry::IsCancelled |
|
1122 // ---------------------------------------------------------------------------- |
|
1123 // |
|
1124 TBool CRsfwFileEntry::IsCancelled() const |
|
1125 { |
|
1126 DEBUGSTRING16(("CRsfwFileEntry::IsCancelled()")); |
|
1127 return (iFlags & KNodeWritingCancelled) != 0; |
|
1128 } |
|
1129 |
|
1130 |
|
1131 // ---------------------------------------------------------------------------- |
|
1132 // CRsfwFileEntry::SetLocallyDirty |
|
1133 // ---------------------------------------------------------------------------- |
|
1134 // |
|
1135 void CRsfwFileEntry::SetLocallyDirty() |
|
1136 { |
|
1137 DEBUGSTRING16(("SetLocallyDirty for file %S", Name())); |
|
1138 TUint oldFlags = iFlags; |
|
1139 iFlags |= KNodeLocallyDirty; |
|
1140 if (iFlags != oldFlags) |
|
1141 { |
|
1142 ReportEvent(KNotifyNodeModified); |
|
1143 } |
|
1144 } |
|
1145 |
|
1146 // ---------------------------------------------------------------------------- |
|
1147 // CRsfwFileEntry::ResetLocallyDirty |
|
1148 // ---------------------------------------------------------------------------- |
|
1149 // |
|
1150 void CRsfwFileEntry::ResetLocallyDirty() |
|
1151 { |
|
1152 DEBUGSTRING16(("ResetLocallyDirty for file %S", Name())); |
|
1153 TUint oldFlags = iFlags; |
|
1154 iFlags &= ~KNodeLocallyDirty; |
|
1155 if (iFlags != oldFlags) |
|
1156 { |
|
1157 ReportEvent(KNotifyNodeModified); |
|
1158 } |
|
1159 } |
|
1160 |
|
1161 // ---------------------------------------------------------------------------- |
|
1162 // CRsfwFileEntry::RemotelyDirty |
|
1163 // ---------------------------------------------------------------------------- |
|
1164 // |
|
1165 TBool CRsfwFileEntry::RemotelyDirty() const |
|
1166 { |
|
1167 return (iFlags & KNodeRemotelyDirty) != 0; |
|
1168 } |
|
1169 |
|
1170 // ---------------------------------------------------------------------------- |
|
1171 // CRsfwFileEntry::SetRemotelyDirty |
|
1172 // ---------------------------------------------------------------------------- |
|
1173 // |
|
1174 void CRsfwFileEntry::SetRemotelyDirty() |
|
1175 { |
|
1176 TUint oldFlags = iFlags; |
|
1177 iFlags |= KNodeRemotelyDirty; |
|
1178 if (iFlags != oldFlags) |
|
1179 { |
|
1180 ReportEvent(KNotifyNodeModified); |
|
1181 } |
|
1182 } |
|
1183 |
|
1184 // ---------------------------------------------------------------------------- |
|
1185 // CRsfwFileEntry::ResetRemotelyDirty |
|
1186 // ---------------------------------------------------------------------------- |
|
1187 // |
|
1188 void CRsfwFileEntry::ResetRemotelyDirty() |
|
1189 { |
|
1190 TUint oldFlags = iFlags; |
|
1191 iFlags &= ~KNodeRemotelyDirty; |
|
1192 if (iFlags != oldFlags) |
|
1193 { |
|
1194 ReportEvent(KNotifyNodeModified); |
|
1195 } |
|
1196 } |
|
1197 |
|
1198 // ---------------------------------------------------------------------------- |
|
1199 // CRsfwFileEntry::IsMarked |
|
1200 // ---------------------------------------------------------------------------- |
|
1201 // |
|
1202 TBool CRsfwFileEntry::IsMarked() const |
|
1203 { |
|
1204 return (iFlags & KNodeMarked) != 0; |
|
1205 } |
|
1206 |
|
1207 // ---------------------------------------------------------------------------- |
|
1208 // CRsfwFileEntry::Mark |
|
1209 // ---------------------------------------------------------------------------- |
|
1210 // |
|
1211 void CRsfwFileEntry::Mark() |
|
1212 { |
|
1213 // This is transient state (so, it need not be saved persistently) |
|
1214 iFlags |= KNodeMarked; |
|
1215 } |
|
1216 |
|
1217 // ---------------------------------------------------------------------------- |
|
1218 // CRsfwFileEntry::Unmark |
|
1219 // ---------------------------------------------------------------------------- |
|
1220 // |
|
1221 void CRsfwFileEntry::Unmark() |
|
1222 { |
|
1223 iFlags &= ~KNodeMarked; |
|
1224 } |
|
1225 |
|
1226 // ---------------------------------------------------------------------------- |
|
1227 // CRsfwFileEntry::SetFlags |
|
1228 // ---------------------------------------------------------------------------- |
|
1229 // |
|
1230 void CRsfwFileEntry::SetFlags(TUint aFlags) |
|
1231 { |
|
1232 TUint oldFlags = iFlags; |
|
1233 iFlags |= aFlags; |
|
1234 if (iFlags != oldFlags) |
|
1235 { |
|
1236 ReportEvent(KNotifyNodeModified); |
|
1237 } |
|
1238 } |
|
1239 |
|
1240 // ---------------------------------------------------------------------------- |
|
1241 // CRsfwFileEntry::ResetFlags |
|
1242 // ---------------------------------------------------------------------------- |
|
1243 // |
|
1244 void CRsfwFileEntry::ResetFlags(TUint aFlags) |
|
1245 { |
|
1246 TUint oldFlags = iFlags; |
|
1247 iFlags &= ~aFlags; |
|
1248 if (iFlags != oldFlags) |
|
1249 { |
|
1250 ReportEvent(KNotifyNodeModified); |
|
1251 } |
|
1252 } |
|
1253 |
|
1254 // ---------------------------------------------------------------------------- |
|
1255 // CRsfwFileEntry::SetOpenedForWriting |
|
1256 // ---------------------------------------------------------------------------- |
|
1257 // |
|
1258 void CRsfwFileEntry::SetOpenedForWriting(TBool aOpenedForWriting) |
|
1259 { |
|
1260 TUint oldFlags = iFlags; |
|
1261 if (aOpenedForWriting) |
|
1262 { |
|
1263 DEBUGSTRING(("CRsfwFileEntry::SetOpenedForWriting TRUE")); |
|
1264 iFlags |= KNodeOpenedForWriting; |
|
1265 } |
|
1266 else |
|
1267 { |
|
1268 DEBUGSTRING(("CRsfwFileEntry::SetOpenedForWriting FALSE")); |
|
1269 iFlags &= ~KNodeOpenedForWriting; |
|
1270 } |
|
1271 if (iFlags != oldFlags) |
|
1272 { |
|
1273 ReportEvent(KNotifyNodeModified); |
|
1274 } |
|
1275 } |
|
1276 |
|
1277 // ---------------------------------------------------------------------------- |
|
1278 // CRsfwFileEntry::IsOpenedForWriting |
|
1279 // ---------------------------------------------------------------------------- |
|
1280 // |
|
1281 TBool CRsfwFileEntry::IsOpenedForWriting() const |
|
1282 { |
|
1283 DEBUGSTRING(("CRsfwFileEntry::IsOpenedForWriting")); |
|
1284 return (iFlags & KNodeOpenedForWriting) != 0; |
|
1285 } |
|
1286 |
|
1287 |
|
1288 // ---------------------------------------------------------------------------- |
|
1289 // CRsfwFileEntry::SetNewlyCreated |
|
1290 // ---------------------------------------------------------------------------- |
|
1291 // |
|
1292 void CRsfwFileEntry::SetNewlyCreated() |
|
1293 { |
|
1294 iFlags |= KNodeNewlyCreated; |
|
1295 } |
|
1296 |
|
1297 // ---------------------------------------------------------------------------- |
|
1298 // CRsfwFileEntry::ResetNewlyCreated |
|
1299 // ---------------------------------------------------------------------------- |
|
1300 // |
|
1301 void CRsfwFileEntry::ResetNewlyCreated() |
|
1302 { |
|
1303 iFlags &= ~KNodeNewlyCreated; |
|
1304 } |
|
1305 |
|
1306 // ---------------------------------------------------------------------------- |
|
1307 // CRsfwFileEntry::IsNewlyCreated |
|
1308 // ---------------------------------------------------------------------------- |
|
1309 // |
|
1310 TBool CRsfwFileEntry::IsNewlyCreated() const |
|
1311 { |
|
1312 return (iFlags & KNodeNewlyCreated) != 0; |
|
1313 } |
|
1314 |
|
1315 |
|
1316 // ---------------------------------------------------------------------------- |
|
1317 // CRsfwFileEntry::IsLocked |
|
1318 // ---------------------------------------------------------------------------- |
|
1319 // |
|
1320 TBool CRsfwFileEntry::IsLocked() const |
|
1321 { |
|
1322 return (iFlags & KNodeHasValidLock) != 0; |
|
1323 } |
|
1324 |
|
1325 // ---------------------------------------------------------------------------- |
|
1326 // CRsfwFileEntry::ReportEvent |
|
1327 // ---------------------------------------------------------------------------- |
|
1328 // |
|
1329 void CRsfwFileEntry::ReportEvent(TInt aEvent) |
|
1330 { |
|
1331 // If there is no file table, |
|
1332 // this is a transient entry |
|
1333 if (iFileTable && iFileTable->Permanence()) |
|
1334 { |
|
1335 iFileTable->HandleMetaDataEvent(aEvent, this); |
|
1336 } |
|
1337 } |
|
1338 |
|
1339 |
|
1340 void CRsfwFileEntry::ResolveDirtyFilesL() |
|
1341 { |
|
1342 DEBUGSTRING(("CRsfwFileEntry::ResolveDirtyFilesL")); |
|
1343 if (this->Type() == KNodeTypeDir) |
|
1344 { |
|
1345 for (int i = 0; i < iKids.Count(); i++) |
|
1346 { |
|
1347 iKids[i]->ResolveDirtyFilesL(); |
|
1348 } |
|
1349 } |
|
1350 else if (this->Type() == KNodeTypeFile) |
|
1351 { |
|
1352 // this is a leaf |
|
1353 iFileTable->ResolveDirtyFileL(this); |
|
1354 } |
|
1355 |
|
1356 } |
|