|
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: Operation independent remote file handling functions |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_RSFWFILEENGINE_H |
|
19 #define C_RSFWFILEENGINE_H |
|
20 |
|
21 #include "rsfwinterface.h" |
|
22 #include "rsfwremoteaccess.h" |
|
23 |
|
24 class CRsfwLockManager; |
|
25 class TDirEnt; |
|
26 class CRsfwFileTable; |
|
27 class CRsfwRfeStateMachine; |
|
28 class CRsfwVolume; |
|
29 class CRsfwFileEntry; |
|
30 |
|
31 // Default values for various operation parameters |
|
32 const TInt KDefaultMaxCacheSize = (16 * 1024 * 1024); // 16 MB |
|
33 const TInt KDefaultMaxEntryCount = 1024; |
|
34 const TInt KDefaultCacheValidity = 30; // in seconds |
|
35 const TInt KDefaultDirCacheValidity = 30; |
|
36 const TInt KDefaultRecognizerLimit = 256; |
|
37 const TInt KDefaultJpegLimit = 0; |
|
38 const TInt KDefaultMpegLimit = 10000; |
|
39 |
|
40 |
|
41 class CRsfwFileEngine: public CBase, public MRsfwRemoteAccessObserver |
|
42 { |
|
43 public: |
|
44 static CRsfwFileEngine* NewL(CRsfwVolume* aVolume); |
|
45 static CRsfwFileEngine* NewLC(CRsfwVolume* aVolume); |
|
46 ~CRsfwFileEngine(); |
|
47 |
|
48 void DispatchL(TRfeInArgs& aIn, TRfeOutArgs& aOut); |
|
49 HBufC* FullNameLC(CRsfwFileEntry& aFe); |
|
50 HBufC* FullNameL(CRsfwFileEntry& aFe); |
|
51 void SetupAttributes(CRsfwFileEntry& aFe); |
|
52 void MakeDirectoryEntry(CRsfwFileEntry& aFe, TDirEnt& aDirEnt); |
|
53 void UpdateDirectoryContainerL(CRsfwFileEntry& aFe); |
|
54 TBool DataChanged(const CRsfwDirEntAttr& oldAttr, const CRsfwDirEntAttr& newAttr); |
|
55 TBool UseCachedData(CRsfwFileEntry& aFe); |
|
56 TBool UseCachedAttributes(CRsfwFileEntry& aFe); |
|
57 void GetAttributesL(CRsfwFileEntry& aFe, |
|
58 CRsfwDirEntAttr*& aAttr, |
|
59 TUint aNodeType, |
|
60 CRsfwRfeStateMachine* aCaller = NULL); |
|
61 void UpdateAttributesL(TDesC& aPath, |
|
62 TDesC& aName, |
|
63 CRsfwDirEntAttr*& aAttr, |
|
64 TUint aNodeType, |
|
65 MRsfwRemoteAccessResponseHandler* aCaller = NULL); |
|
66 void UpdateAttributesL(CRsfwFileEntry& aFe, |
|
67 CRsfwDirEntAttr*& aAttr, |
|
68 TUint aNodeType, |
|
69 MRsfwRemoteAccessResponseHandler* aCaller = NULL); |
|
70 void UpdateAttributesL(TDesC& aFullPath, |
|
71 CRsfwDirEntAttr*& aAttr, |
|
72 TUint aNodeType, |
|
73 MRsfwRemoteAccessResponseHandler* aCaller = NULL); |
|
74 void CreateContainerFileL(CRsfwFileEntry& aFe); |
|
75 TUint FetchAndCacheL(CRsfwFileEntry& aFe, |
|
76 TInt aFirstByte, |
|
77 TInt* aLength, |
|
78 RPointerArray<CRsfwDirEnt>* aDirEntsp, |
|
79 CRsfwRfeStateMachine* aCaller = NULL); |
|
80 TUint RequestConnectionStateL(TUint aConnectionState, |
|
81 CRsfwRfeStateMachine* aCaller = NULL); |
|
82 void EnteredConnectionStateL(TUint aConnectionState, TBool aRequested); |
|
83 TUint ConnectionState(); |
|
84 CRsfwLockManager* LockManager(); |
|
85 void SetPermanenceL(TBool aPermanence); |
|
86 TBool Disconnected(); |
|
87 TBool WriteDisconnected(); |
|
88 TInt AddToCacheL(CRsfwFileEntry& aFe, |
|
89 RPointerArray<CRsfwDirEnt>* aDirEnts, |
|
90 CRsfwFileEngine *aFileEngine, |
|
91 TUint cachedSize); |
|
92 CRsfwRemoteAccess* RemoteAccessL(); |
|
93 void OperationCompleted(); |
|
94 void CancelTransactionL(TDesC& aPathName); |
|
95 void CancelTransaction(TUint aTransactionId); |
|
96 void SetFailedLookup(TDesC& aPath, TDesC& aKidName); |
|
97 void ResetFailedLookup(); |
|
98 CRsfwVolume* Volume(); |
|
99 TInt PurgeFromCache(const TDesC& aPath); |
|
100 HBufC8* GetContentType(TDesC& aName); |
|
101 CRsfwFileEntry* FetchFep(const TDesC& aPath); |
|
102 |
|
103 private: |
|
104 void ConstructL(CRsfwVolume* aVolume); |
|
105 void PrepareCacheL(); |
|
106 TInt UpdateDirectoryL(CRsfwFileEntry& aFe, TDesC* aFullName); |
|
107 TInt UpdateDirectoryL(CRsfwFileEntry& aFe); |
|
108 TUint GetDirectoryL(CRsfwFileEntry& aFe, |
|
109 TDesC& aFullName, |
|
110 RFile& aF, |
|
111 RPointerArray<CRsfwDirEnt>* aDirEntsp, |
|
112 MRsfwRemoteAccessResponseHandler* aCaller = NULL); |
|
113 void BuildContainerPathL(CRsfwFileEntry& aFe, TDes& aPath); |
|
114 void ApplyMultiDirCacheL(TDes& aPath); |
|
115 void CreateContainerFileL(CRsfwFileEntry& aFe, TDes& aPath, RFile& aF); |
|
116 void DoCreateL(TRfeCreateInArgs& aIn, TRfeCreateOutArgs& aOut); |
|
117 void DoIoctlL(TRfeIoctlInArgs& aIn,TRfeOutArgs& aOut); |
|
118 void DoRootL(TRfeRootInArgs& aIn, TRfeRootOutArgs& aOut); |
|
119 void DoSetAttrL(TRfeSetAttrInArgs& aIn, TRfeOutArgs& aOut); |
|
120 void SetupRootL(TBool aPermanence); |
|
121 void CleanupCorruptedCacheL(); |
|
122 TUint ConnectL(TBool aRestart, CRsfwRfeStateMachine* aCaller = NULL); |
|
123 void DisconnectL(); |
|
124 void StartInactivityTimer(); |
|
125 void StopInactivityTimer(); |
|
126 static TInt InactivityTimerExpired(TAny* aArg); |
|
127 |
|
128 |
|
129 // the purpose of these functions is to give capability info |
|
130 // for the access protocol plugin used |
|
131 |
|
132 // whether getting the directory listing also gives reliable file metadata |
|
133 TBool DirectoryListingContainsFileMetadata(); |
|
134 |
|
135 // from MRsfwRemoteAccessObserver |
|
136 void HandleRemoteAccessEventL(TInt aEventType, TInt aEvent, TAny* aArg); |
|
137 |
|
138 public: |
|
139 CRsfwFileTable* iFileTable; // table of known vnodes, by fid |
|
140 TUint iConnectionState; // connection state |
|
141 CRsfwRemoteAccess* iRemoteAccess; // remote file transport module |
|
142 CRsfwLockManager* iLockManager; // implement locking for files |
|
143 |
|
144 private: |
|
145 |
|
146 // Data |
|
147 CRsfwFileEntry* iRootFep; // root file entry |
|
148 CRsfwVolume* iVolume; // volume info |
|
149 const TFid* iRootFid; // root file id |
|
150 TFileName iCacheRoot; // location of local cache files |
|
151 RFs iFs; // fileserver handle |
|
152 TInt iInactivityTimeout; // inactivity timeout |
|
153 CPeriodic* iInactivityTimer; // remote access inactivity watch dog |
|
154 TBool iConnectionStateChanged; |
|
155 TFileName iLastFailedLookup; // path of the last failed lookup, cached |
|
156 TTime iLookupTime; // then this failed lookup happened |
|
157 }; |
|
158 |
|
159 |
|
160 #endif |