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 for CMMCScBkupReadDataTransferRequestBase |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef __CMMCSCBKUPTRANSFERREADREQUEST_H__ |
|
20 #define __CMMCSCBKUPTRANSFERREADREQUEST_H__ |
|
21 |
|
22 // User includes |
|
23 #include "MMCScBkupConfig.h" |
|
24 #include "MMCScBkupSBEUtils.h" |
|
25 #include "TMMCScBkupOwnerDataType.h" |
|
26 #include "CMMCScBkupDataOwnerInfo.h" |
|
27 #include "CMMCScBkupTransferRequest.h" |
|
28 #include "CMMCScBkupIndexWithIdentifier.h" |
|
29 |
|
30 // Classes referenced |
|
31 class MMMCScBkupDriver; |
|
32 class CMMCScBkupArchiveFooter; |
|
33 |
|
34 // Constants |
|
35 const TInt KMMCScBkupDefaultChunkReadSize = 4096; // 4k read chunks |
|
36 |
|
37 // CMMCScBkupIndexEntry |
|
38 |
|
39 /** |
|
40 * |
|
41 * |
|
42 * @since 3.0 |
|
43 */ |
|
44 NONSHARABLE_CLASS(CMMCScBkupReadDataTransferRequestBase) : public CMMCScBkupTransferRequestBase |
|
45 { |
|
46 public: |
|
47 |
|
48 /** |
|
49 * C++ destructor |
|
50 */ |
|
51 ~CMMCScBkupReadDataTransferRequestBase(); |
|
52 |
|
53 protected: |
|
54 |
|
55 /** |
|
56 * C++ default constructor |
|
57 */ |
|
58 CMMCScBkupReadDataTransferRequestBase( MMMCScBkupDriver& aDriver, |
|
59 TMMCScBkupOwnerDataType aElementType, |
|
60 TInt aChunkSize = KMMCScBkupDefaultChunkReadSize, |
|
61 TInt aPriority = CActive::EPriorityIdle ); |
|
62 |
|
63 public: // API |
|
64 |
|
65 /** |
|
66 * |
|
67 */ |
|
68 void RequestL( CMMCScBkupDataOwnerInfo& aOwner, TRequestStatus& aObserver, const RArray<TMMCScBkupArchiveDriveAndVector>& aEntries ); |
|
69 |
|
70 protected: // New Framework API |
|
71 |
|
72 /** |
|
73 * |
|
74 */ |
|
75 virtual CSBGenericTransferType* PrepareTransferTypeL( const CSBGenericDataType& aGeneric, |
|
76 TDriveNumber aDrive, TInt aVersion ) const = 0; |
|
77 |
|
78 private: // From CMMCScBkupTransferRequest |
|
79 TBool ProcessChunkOfDataL(); |
|
80 void PrepareDataTransferL(); |
|
81 |
|
82 private: // Internal methods |
|
83 |
|
84 /** |
|
85 * |
|
86 */ |
|
87 void ReadChunkL( TDes8& aSink, TInt aLength ); |
|
88 |
|
89 /** |
|
90 * |
|
91 */ |
|
92 TBool DoProcessChunkOfDataL(); |
|
93 |
|
94 /** |
|
95 * |
|
96 */ |
|
97 TBool PrepareForNextEntry(); |
|
98 |
|
99 /** |
|
100 * |
|
101 */ |
|
102 TDriveNumber CurrentDrive() const; |
|
103 |
|
104 /** |
|
105 * |
|
106 */ |
|
107 const TMMCScBkupArchiveVector& CurrentReadInfo() const; |
|
108 |
|
109 /** |
|
110 * |
|
111 */ |
|
112 const TMMCScBkupArchiveDriveAndVector& CurrentEntry() const; |
|
113 |
|
114 /** |
|
115 * |
|
116 */ |
|
117 inline TInt CurrentOffset() const { return iCurrentOffset; } |
|
118 |
|
119 private: // From CActive |
|
120 TInt RunError( TInt aError ); |
|
121 |
|
122 private: // Debugging support |
|
123 |
|
124 /** |
|
125 * |
|
126 */ |
|
127 #ifdef DEBUGGING_DATA_TRANSFER |
|
128 void DumpTransferDataL( RFs& aFsSession, const TDesC8& aData ) const; |
|
129 #endif |
|
130 |
|
131 private: // Member data |
|
132 |
|
133 // Owned externally |
|
134 // |
|
135 const RArray<TMMCScBkupArchiveDriveAndVector>* iEntries; |
|
136 |
|
137 // Owned by this object |
|
138 |
|
139 // Pointer to the SBE's shared chunk. It *must* be a reference |
|
140 // because otherwise the SBE loses track of what we actually write |
|
141 // to the chunk! |
|
142 TPtr8* iTransferChunkPointer; |
|
143 // |
|
144 const TInt iReadChunkSize; |
|
145 // |
|
146 TInt iCurrentIndex; |
|
147 // |
|
148 TBool iFinishedSupplyingData; |
|
149 // |
|
150 CSBGenericTransferType* iTransferType; |
|
151 // |
|
152 TInt iCurrentOffset; |
|
153 // |
|
154 HBufC8* iTemporaryTransferSink; |
|
155 }; |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 /** |
|
166 * |
|
167 * |
|
168 * @since 3.0 |
|
169 */ |
|
170 template <class Type> |
|
171 class CMMCScBkupReadDataTransferRequest : public CMMCScBkupReadDataTransferRequestBase |
|
172 { |
|
173 public: // Construction |
|
174 |
|
175 /** |
|
176 * |
|
177 */ |
|
178 inline static CMMCScBkupReadDataTransferRequest* NewL( MMMCScBkupDriver& aDriver, |
|
179 TMMCScBkupOwnerDataType aElementType, |
|
180 Type aTransferEnumType, |
|
181 TInt aChunkSize = KMMCScBkupDefaultChunkReadSize, |
|
182 TInt aPriority = CActive::EPriorityIdle ) |
|
183 { |
|
184 CMMCScBkupReadDataTransferRequest<Type>* self = new(ELeave) CMMCScBkupReadDataTransferRequest<Type>( aDriver, aElementType, aTransferEnumType, aChunkSize, aPriority ); |
|
185 return self; |
|
186 } |
|
187 |
|
188 private: // Internal construction |
|
189 |
|
190 /** |
|
191 * C++ default constructor |
|
192 */ |
|
193 inline CMMCScBkupReadDataTransferRequest( MMMCScBkupDriver& aDriver, |
|
194 TMMCScBkupOwnerDataType aElementType, |
|
195 Type aTransferEnumType, |
|
196 TInt aChunkSize = KMMCScBkupDefaultChunkReadSize, |
|
197 TInt aPriority = CActive::EPriorityIdle ) |
|
198 : CMMCScBkupReadDataTransferRequestBase( aDriver, aElementType, aChunkSize, aPriority), |
|
199 iTransferEnumType( aTransferEnumType ) |
|
200 { |
|
201 } |
|
202 |
|
203 private: // From CMMCScBkupTransferRequest |
|
204 inline CSBGenericTransferType* PrepareTransferTypeL( const CSBGenericDataType& aGeneric, |
|
205 TDriveNumber aDrive, TInt aVersion ) const |
|
206 { |
|
207 CSBGenericTransferType* transferType = MMCScBkupSBEUtils::TransferTypeLC( aGeneric, aDrive, |
|
208 iTransferEnumType, aVersion ); |
|
209 CleanupStack::Pop( transferType ); |
|
210 return transferType; |
|
211 } |
|
212 |
|
213 private: // Member data |
|
214 |
|
215 // |
|
216 Type iTransferEnumType; |
|
217 }; |
|
218 |
|
219 |
|
220 |
|
221 #endif // __CMMCSCBKUPTRANSFERREADREQUEST_H__ |
|
222 |
|
223 // End of File |
|