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: Remote File System Plug-in implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CRSFWFSFILECB_H |
|
20 #define CRSFWFSFILECB_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <f32fsys.h> |
|
24 #include "rsfwinterface.h" |
|
25 |
|
26 /** |
|
27 * Classes that a plug-in file system must implement. A plug-in |
|
28 * filesystem must implement CFileSystem, which is a factory class for |
|
29 * a file system. That class must create objects derived from CMountCB, |
|
30 * CFileCB, CDirCB and CFormatCB. These are defined in f32fsys.h |
|
31 * |
|
32 * @lib eremotefs.fsy |
|
33 * @since Series 60 3.2 |
|
34 */ |
|
35 class CRsfwFsFileCB : public CFileCB |
|
36 { |
|
37 public: // Constructors and destructor |
|
38 |
|
39 /** |
|
40 * Constructor. |
|
41 */ |
|
42 CRsfwFsFileCB(); |
|
43 |
|
44 /** |
|
45 * Destructor. |
|
46 */ |
|
47 ~CRsfwFsFileCB(); |
|
48 |
|
49 public: // New functions |
|
50 |
|
51 /** |
|
52 * Prepares the class to read file from a local cache file |
|
53 * @since Series 60 3.2 |
|
54 * @param aPath path of the cache file |
|
55 * @return |
|
56 */ |
|
57 void SetContainerFileL( const TDesC& aPath); |
|
58 |
|
59 public: // Functions from base class |
|
60 |
|
61 /** |
|
62 * From CFileCB Renames the file with the full file name provided. |
|
63 * @since Series 60 3.2 |
|
64 * @param aNewName The new full name of the file. |
|
65 * @return |
|
66 */ |
|
67 void RenameL( const TDesC& aNewName ); |
|
68 |
|
69 /** |
|
70 * From CFileCB Reads from an open file |
|
71 * @since Series 60 3.2 |
|
72 * @param aPos Represents a position relative to the start of the file |
|
73 * where ReadL() starts to read. |
|
74 * @param aLength On entry, specifies the number of bytes to be read |
|
75 * from the file. On return, contains the number of bytes |
|
76 * read, but this is not valid if the function leaves. |
|
77 * @param aDes Pointer to a descriptor into which the data is written. |
|
78 * @param aMessage The client request. |
|
79 * @return |
|
80 */ |
|
81 void ReadL( TInt aPos, |
|
82 TInt& aLength, |
|
83 const TAny* aDes, |
|
84 const RMessagePtr2& aMessage ); |
|
85 |
|
86 /** |
|
87 * From CFileCB Writes to an open file |
|
88 * @since Series 60 3.2 |
|
89 * @param aPos Represents a position relative to the start of the file |
|
90 * where WriteL() starts to write. |
|
91 * @param aLength Specifies the number of bytes to be written to the file. |
|
92 * On return, the number of bytes written, but this is not |
|
93 * valid if the function leaves. |
|
94 * @param aDes Pointer to a descriptor containing the data to be written |
|
95 * to the file. |
|
96 * @param aMessage The client request. |
|
97 * @return |
|
98 */ |
|
99 void WriteL( TInt aPos, |
|
100 TInt& aLength, |
|
101 const TAny* aDes, |
|
102 const RMessagePtr2& aMessage ); |
|
103 |
|
104 /** |
|
105 * From CFileCB Extends or truncates the file by re-setting the file size. |
|
106 * @since Series 60 3.2 |
|
107 * @param aSize The new file size in number of bytes. |
|
108 * @return |
|
109 */ |
|
110 void SetSizeL( TInt aSize ); |
|
111 |
|
112 /** |
|
113 * From CFileCB Sets the attribute mask and the modified time of the file. |
|
114 * @since Series 60 3.2 |
|
115 * @param aTime The new modified time, if the modified flag is set in aMask. |
|
116 * @param aMask Bit mask containing bits set (to 1) that are to be set (to 1) |
|
117 * in iAtt. |
|
118 * @param aVal Bitmask containing bits set (to 1) that are to be unset (to 0) |
|
119 * in iAtt. |
|
120 * @return |
|
121 */ |
|
122 void SetEntryL(const TTime& aTime,TUint aMask,TUint aVal); |
|
123 |
|
124 |
|
125 /** |
|
126 * From CFileCB Flushes, to disk, the cached information necessary for |
|
127 * the integrity of recently written data, such as the file size. |
|
128 * @since Series 60 3.2 |
|
129 * @return |
|
130 */ |
|
131 void FlushDataL(); |
|
132 |
|
133 /** |
|
134 * From CFileCB Flushes, to disk, all cached file data (e.g. attributes, |
|
135 * modification time, file size). |
|
136 * @since Series 60 3.2 |
|
137 * @return |
|
138 */ |
|
139 void FlushAllL(); |
|
140 |
|
141 |
|
142 public: // Data |
|
143 // the fid of this file |
|
144 TFid iThisFid; |
|
145 |
|
146 // the fid of the parent, needed for rename |
|
147 TFid iParentFid; |
|
148 |
|
149 // If flush returned an error, we do not attempt to write the file to server in close() |
|
150 // either, unless new data is written to the cache file. We assume that the application |
|
151 // has handled the flush error, also this is required for example to make File Manager UI |
|
152 // to work correctly (if user presses cancel when flushing), writing should be cancelled. |
|
153 TBool iLastFlushFailed; |
|
154 |
|
155 |
|
156 private: // Data |
|
157 // open file handle on the cache file |
|
158 RFile iContFile; |
|
159 |
|
160 // the path of the local cache |
|
161 TBuf<KMaxPath> iCachePath; |
|
162 |
|
163 // cached size bookkeeping |
|
164 TInt iCachedSize; |
|
165 |
|
166 // indicates whether a file was fetched to the local cache before writing |
|
167 TBool iFetchedBeforeWriting; |
|
168 |
|
169 // some varibles needed when flushing a big file |
|
170 // in continuous parts (currently used in File |
|
171 // Manager copy). |
|
172 |
|
173 // how much already has been flushed |
|
174 TInt iFlushedSize; |
|
175 |
|
176 // how much has been written to since the file was opened |
|
177 TInt iWrittenSize; |
|
178 |
|
179 // the total size of the file, reported by client |
|
180 // via RFile::SetSize() |
|
181 TInt iReportedSize; |
|
182 |
|
183 // does the server support writing the file partially |
|
184 // assumed to be true unless we get KErrNotSupported |
|
185 TBool iPartialWriteSupported; |
|
186 }; |
|
187 |
|
188 #endif // CRSFWFSFILECB_H |
|
189 |
|
190 |
|