|
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: data struct for a remote file metadata |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_RSFWFILEENTRY_H |
|
20 #define C_RSFWFILEENTRY_H |
|
21 |
|
22 #include "rsfwinterface.h" |
|
23 #include "rsfwlrulistnode.h" |
|
24 |
|
25 class TDirEntAttr; |
|
26 class CRsfwLockManager; |
|
27 class CRsfwDirEntAttr; |
|
28 class CRsfwFileTable; |
|
29 |
|
30 |
|
31 class CRsfwFileEntry: public CBase |
|
32 { |
|
33 friend class CRsfwFileTable; |
|
34 friend class CRsfwVolumeTable; |
|
35 friend class CRsfwLockManager; |
|
36 |
|
37 public: |
|
38 ~CRsfwFileEntry(); |
|
39 static CRsfwFileEntry* NewLC(const TDesC& aName, CRsfwFileEntry* aParent); |
|
40 static CRsfwFileEntry* NewL(const TDesC& aName, CRsfwFileEntry* aParent); |
|
41 static CRsfwFileEntry* NewL(RReadStream& aStream); |
|
42 |
|
43 CRsfwFileEntry* FindKidByName(const TDesC& aName); |
|
44 void RenameL(const TDesC& aName); |
|
45 void AddKid(CRsfwFileEntry& aFe); |
|
46 TInt RemoveKidL(CRsfwFileEntry* aFep); |
|
47 TInt KidsCount(); |
|
48 void UnmarkKids(); |
|
49 void DropUnmarkedKidsL(); |
|
50 void DropLD(); |
|
51 void GetAttributes(TDirEntAttr& aAttr) const; |
|
52 void GetAttributesL(CRsfwDirEntAttr& aAttr) const; |
|
53 void SetAttributesL(CRsfwDirEntAttr& aAttr, TBool aAllMetaData); |
|
54 TDesC* CacheFileName(); |
|
55 void SetCacheFileName(TDesC* aFn); |
|
56 TBool IsCached() const; |
|
57 TBool IsFullyCached() const; |
|
58 void SetCached(TBool aCached); |
|
59 void SetCachedSize(TInt aFetchedSize); |
|
60 void RemoveCacheFile(); |
|
61 void ValidateCacheFile(); |
|
62 void PrintL(TInt aLevel, TBool aKids, TBool aall) const; |
|
63 HBufC* FullNameLC() const; |
|
64 TInt TotalCachedSize(); |
|
65 TInt TotalEntryCount(); |
|
66 CRsfwFileEntry* Lookup(const TFid& aFid); |
|
67 void SetLockedL(CRsfwLockManager* aLockManager, TDesC8* aLockToken); |
|
68 void RemoveLocked(); |
|
69 static int LockTimerExpiredL(TAny* aParam); |
|
70 TBool UseCachedData(); |
|
71 void SetAttribValidationTime(); |
|
72 void ExternalizeL(RWriteStream& aStream) const; |
|
73 void InternalizeL(RReadStream& aStream); |
|
74 void SetType(TUint8 aType); |
|
75 void SetSize(TInt aSize); |
|
76 void SetModified(const TTime& aModified); |
|
77 void SetAtt(TUint aAtt); |
|
78 void SetMimeTypeL(const TDesC8& aMimeType); |
|
79 void SetOpaqueFileIdL(const TDesC8& aOpaqueFileId); |
|
80 TBool IsLocallyDirty() const; |
|
81 TBool IsCancelled() const; |
|
82 void SetLocallyDirty(); |
|
83 void ResetLocallyDirty(); |
|
84 TBool RemotelyDirty() const; |
|
85 void SetRemotelyDirty(); |
|
86 void ResetRemotelyDirty(); |
|
87 void SetNewlyCreated(); |
|
88 void ResetNewlyCreated(); |
|
89 TBool IsNewlyCreated() const; |
|
90 TBool IsMarked() const; |
|
91 void Mark(); |
|
92 void Unmark(); |
|
93 void SetFlags(TUint aFlags); |
|
94 void ResetFlags(TUint aFlags); |
|
95 void SetOpenedForWriting(TBool aOpenedForWriting); |
|
96 TBool IsOpenedForWriting() const; |
|
97 // for a remote file which has been locally modified, but not yet written back to the |
|
98 // server the cache file is set as read only until the file has been resolved |
|
99 TBool IsLocked() const; |
|
100 void ReportEvent(TInt aEvent); |
|
101 inline const TFid& Fid() const; |
|
102 inline void SetFid(const TFid& aFid); |
|
103 inline const TDesC* Name() const; |
|
104 inline TUint8 Type() const; |
|
105 inline TInt Size() const; |
|
106 inline TTime Modified() const; |
|
107 inline TUint Att() const; |
|
108 inline const TDesC8* MimeType() const; |
|
109 inline const TDesC8* OpaqueFileId() const; |
|
110 inline void SetUid(TUid anUid); |
|
111 inline CRsfwFileEntry* Parent(); |
|
112 inline void SetParent(CRsfwFileEntry* aFep); |
|
113 inline TInt CachePriority() const; |
|
114 inline TBool IsFlagged(TUint aFlag) const; |
|
115 inline RPointerArray<CRsfwFileEntry>* Kids(); |
|
116 inline const TDesC8* LockToken(); |
|
117 inline const TDesC* ProtectionDomainName() const; |
|
118 inline void SetCachePriority(TCachePriority); |
|
119 inline TInt ProtectionDomainId() const; |
|
120 void ResolveDirtyFilesL(); |
|
121 |
|
122 private: |
|
123 void ConstructL(const TDesC& aName, CRsfwFileEntry* aParent); |
|
124 void ConstructL(RReadStream& aStream); |
|
125 |
|
126 void SetLockTimeout(); |
|
127 |
|
128 public: |
|
129 |
|
130 // how much has been cached |
|
131 TInt iCachedSize; |
|
132 |
|
133 // when the file attributes have been fetched from the server |
|
134 TTime iAttribValidation; |
|
135 |
|
136 // uid of the symbian app which handles this datatype |
|
137 TUid iUid; |
|
138 |
|
139 // Timer associated with a possible file locked |
|
140 CPeriodic* iLockTimer; |
|
141 |
|
142 |
|
143 protected: |
|
144 RPointerArray<CRsfwFileEntry> iKids; // contained files and dirs |
|
145 |
|
146 private: |
|
147 TFid iFid; // id |
|
148 HBufC* iName; // name |
|
149 TInt iSize; // file size in bytes |
|
150 TUint iAtt; // attribute bits |
|
151 TUint iFlags; // local state |
|
152 TTime iModified; // last modified |
|
153 TUint8 iType; // type (unknown, file, dir) |
|
154 HBufC8* iMimeType; // MIME type |
|
155 HBufC8* iOpaqueFileId; // e.g. ETag in WebDAV |
|
156 CRsfwFileEntry* iParent; // parent dir |
|
157 TBuf<KMaxPath> iCacheName; // local cache filename |
|
158 TDesC8* iLockToken; // lock token |
|
159 // cache priority is currently always KCachePriorityNormal |
|
160 TInt iCachePriority; |
|
161 |
|
162 // Lock timeout for this locked file |
|
163 // In practise we need to store this per-file |
|
164 // as server may always ignore our request |
|
165 // and e.g. mod_dav allows setting different min timeout |
|
166 // for different directories. |
|
167 TUint iLockTimeout; |
|
168 |
|
169 public: |
|
170 // pointer to lock manager that can be called to refresh the lock |
|
171 CRsfwLockManager* iLockManager; |
|
172 TBool iUseCachedData; |
|
173 // only used at recovery when iParent is not set (yet) |
|
174 TInt iParentNodeId; |
|
175 // the table in which the entry belongs |
|
176 CRsfwFileTable* iFileTable; |
|
177 }; |
|
178 |
|
179 #include "rsfwfileentry.inl" |
|
180 |
|
181 #endif |