|
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: Declaration of CMMCScBkupDataStrategy |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef __CMMCSCBKUPDATASTRATEGIES_H__ |
|
20 #define __CMMCSCBKUPDATASTRATEGIES_H__ |
|
21 |
|
22 // User includes |
|
23 #include <f32file.h> |
|
24 |
|
25 // Constants |
|
26 const TBool KMMCScBkupUseTempFile = EFalse; |
|
27 |
|
28 |
|
29 /** |
|
30 * |
|
31 * |
|
32 * @since 3.0 |
|
33 */ |
|
34 class CMMCScBkupDataStrategy : public CBase |
|
35 { |
|
36 public: |
|
37 |
|
38 /** |
|
39 * Factory method |
|
40 */ |
|
41 static CMMCScBkupDataStrategy* ReadStrategyLC( const TDesC& aName, RFs& aFsSession ); |
|
42 |
|
43 /** |
|
44 * Factory method |
|
45 */ |
|
46 static CMMCScBkupDataStrategy* ReadStrategyLC( const TDesC& aName, RFs& aFsSession, TInt aStartOffset, TInt aLengthToRead ); |
|
47 |
|
48 /** |
|
49 * Factory method |
|
50 */ |
|
51 static CMMCScBkupDataStrategy* WriteStrategyLC( const TDesC& aName, RFs& aFsSession, TBool aUseTempFile ); |
|
52 |
|
53 public: // Framework API |
|
54 |
|
55 /** |
|
56 * Read data from the source |
|
57 * |
|
58 * @return TInt The amount of data read, or 0 if the end of file has been reached |
|
59 */ |
|
60 virtual TInt Read(TDes8& aSink) = 0; |
|
61 |
|
62 /** |
|
63 * Write data to the source |
|
64 * |
|
65 * @return TInt KErrNone if success, KErrNotSupported if the strategy doesn't support writing |
|
66 * or any of the other System-Wide error codes upon failure. |
|
67 */ |
|
68 virtual TInt Write(const TDesC8& aSource); |
|
69 |
|
70 /** |
|
71 * Perform any final actions |
|
72 * |
|
73 * @return TInt an error code. |
|
74 */ |
|
75 virtual TInt Finalize(); |
|
76 |
|
77 protected: |
|
78 |
|
79 /** |
|
80 * C++ Constructor |
|
81 */ |
|
82 CMMCScBkupDataStrategy(); |
|
83 |
|
84 private: // Internal methods |
|
85 |
|
86 /** |
|
87 * Sets the offset and length |
|
88 */ |
|
89 void SetOffsetAndLength(TInt aStartOffset, TInt aLengthToRead); |
|
90 |
|
91 protected: // Internal |
|
92 inline TInt Offset() const { return iOffset; } |
|
93 inline TInt LengthToRead() const { return iLengthToRead; } |
|
94 inline void SetOffset(TInt64 aOffset) { iOffset = aOffset; } |
|
95 |
|
96 private: // Data members |
|
97 |
|
98 // |
|
99 TInt iOffset; |
|
100 // |
|
101 TInt iLengthToRead; |
|
102 }; |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 /** |
|
111 * |
|
112 * |
|
113 * @since 3.0 |
|
114 */ |
|
115 NONSHARABLE_CLASS(CMMCScBkupDataFileStrategy) : public CMMCScBkupDataStrategy |
|
116 { |
|
117 public: |
|
118 |
|
119 /** |
|
120 * Static constructor |
|
121 */ |
|
122 static CMMCScBkupDataFileStrategy* NewForReadingL( const TDesC& aName, RFs& aFsSession ); |
|
123 |
|
124 /** |
|
125 * Static constructor |
|
126 */ |
|
127 static CMMCScBkupDataFileStrategy* NewForWritingL( const TDesC& aName, RFs& aFsSession, TBool aUseTempFile ); |
|
128 |
|
129 /** |
|
130 * C++ Destructor |
|
131 */ |
|
132 ~CMMCScBkupDataFileStrategy(); |
|
133 |
|
134 private: |
|
135 |
|
136 /** |
|
137 * C++ Constructor |
|
138 */ |
|
139 CMMCScBkupDataFileStrategy( RFs& aFsSession, TBool aUseTempFile = EFalse ); |
|
140 |
|
141 /** |
|
142 * Second phase construction |
|
143 */ |
|
144 void ConstructL( const TDesC& aName, TUint aMode ); |
|
145 |
|
146 public: // From CMMCScBkupDataStrategy |
|
147 TInt Read(TDes8& aSink); |
|
148 TInt Write(const TDesC8& aSource); |
|
149 TInt Finalize(); |
|
150 |
|
151 private: // Internal functions |
|
152 |
|
153 /** |
|
154 * |
|
155 */ |
|
156 static TInt PrepareToOverwriteFile( RFs& aFsSession, const TDesC& aFileName ); |
|
157 |
|
158 private: // Data members |
|
159 |
|
160 RFs& iFsSession; |
|
161 // |
|
162 RFile64 iFile; |
|
163 // |
|
164 TBool iUseTempFile; |
|
165 // |
|
166 HBufC* iFileName; |
|
167 // |
|
168 TFileName iTempFileName; |
|
169 }; |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 /** |
|
178 * |
|
179 * |
|
180 * @since 3.0 |
|
181 */ |
|
182 NONSHARABLE_CLASS(CMMCScBkupDataFileSectionReadStrategy) : public CMMCScBkupDataStrategy |
|
183 { |
|
184 public: |
|
185 |
|
186 /** |
|
187 * Static constructor |
|
188 */ |
|
189 static CMMCScBkupDataFileSectionReadStrategy* NewL(const TDesC& aName, RFs& aFsSession); |
|
190 |
|
191 /** |
|
192 * C++ Destructor |
|
193 */ |
|
194 ~CMMCScBkupDataFileSectionReadStrategy(); |
|
195 |
|
196 private: |
|
197 |
|
198 /** |
|
199 * C++ Constructor |
|
200 */ |
|
201 CMMCScBkupDataFileSectionReadStrategy(RFs& aFsSession); |
|
202 |
|
203 /** |
|
204 * |
|
205 */ |
|
206 void ConstructL(const TDesC& aName); |
|
207 |
|
208 public: // From CMMCScBkupDataStrategy |
|
209 TInt Read(TDes8& aSink); |
|
210 |
|
211 private: // Data members |
|
212 |
|
213 // |
|
214 RFs& iFsSession; |
|
215 // |
|
216 HBufC* iFileName; |
|
217 }; |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 #endif // __CMMCSCBKUPDATASTRATEGIES_H__ |
|
223 |
|
224 //End of File |