|
1 /* |
|
2 * Copyright (c) 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: Header of TransferBuffer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MMFFILEPRIV_H_ |
|
20 #define __MMFFILEPRIV_H_ |
|
21 |
|
22 #include <f32file.h> |
|
23 |
|
24 #include <mmf/server/mmfclip.h> |
|
25 #include <mmf/server/mmfdatabuffer.h> |
|
26 |
|
27 |
|
28 /** |
|
29 @publishedAll |
|
30 @released |
|
31 |
|
32 Provides the filename and path of file. |
|
33 |
|
34 Used by CFileSource::ConstructL(). |
|
35 */ |
|
36 class TMMFFileParams |
|
37 { |
|
38 public: |
|
39 /** |
|
40 Filename and path of file. |
|
41 */ |
|
42 TFileName iPath ; // Filename and path of file. |
|
43 private: |
|
44 /** |
|
45 This member is internal and not intended for use. |
|
46 */ |
|
47 TInt iReserved1; |
|
48 }; |
|
49 |
|
50 /** |
|
51 @internalTechnology |
|
52 */ |
|
53 const TUid KFileHandleUid = {0x101FFA19}; |
|
54 const TUid KMMFileSourceUid = {0x101F7DA9}; |
|
55 const TUid KMMFileHandleSourceUid = {0x101F7DAA}; |
|
56 const TUid KFileSourceUid = {0x10207B89}; |
|
57 |
|
58 /** |
|
59 @publishedAll |
|
60 @released |
|
61 |
|
62 Provides a pointer to the file handle |
|
63 |
|
64 Used by CFileSource::ConstructL(). |
|
65 */ |
|
66 class TMMFFileHandleParams |
|
67 { |
|
68 public: |
|
69 TMMFFileHandleParams(RFile* aFile) : iUid(KFileHandleUid), iFile(aFile) {} |
|
70 TMMFFileHandleParams() : iUid(KFileHandleUid) {} |
|
71 |
|
72 TUid iUid; |
|
73 /** |
|
74 Handle of file |
|
75 */ |
|
76 RFile* iFile; |
|
77 private: |
|
78 /** |
|
79 This member is internal and not intended for use. |
|
80 */ |
|
81 TInt iReserved1; |
|
82 }; |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 /** |
|
88 @publishedAll |
|
89 @released |
|
90 */ |
|
91 typedef TPckgBuf<TMMFFileParams> TMMFFileConfig ; |
|
92 |
|
93 /** |
|
94 @publishedAll |
|
95 @released |
|
96 */ |
|
97 typedef TPckgBuf<TMMFFileHandleParams> TMMFFileHandleConfig ; |
|
98 |
|
99 |
|
100 /** |
|
101 @publishedAll |
|
102 @released |
|
103 |
|
104 This details how big the iTransferBufferCopies array of CFileSource may |
|
105 become before we start looking to free entries. |
|
106 */ |
|
107 const TInt KAcceptableTransferBufferCopiesSize = 5; |
|
108 |
|
109 /** |
|
110 @publishedAll |
|
111 @released |
|
112 |
|
113 This details how big the iTransferBufferCopies array of CFileSource may |
|
114 become before we start looking to free entries. |
|
115 */ |
|
116 const TInt KMaximumTransferBufferCopiesSize = 100; |
|
117 |
|
118 |
|
119 /** |
|
120 * @publishedAll |
|
121 * |
|
122 * Represents a copy of a KUidMmfTransferBuffer used for reading/writting to the file server |
|
123 */ |
|
124 class CTransferBufferCopy : public CBase |
|
125 { |
|
126 public: |
|
127 static CTransferBufferCopy* NewL(TInt aMaxLength); |
|
128 |
|
129 virtual ~CTransferBufferCopy() |
|
130 {delete iBuffer;} |
|
131 |
|
132 |
|
133 TDes8& Des() {return iBufferDes;} |
|
134 |
|
135 TInt MaxLength() {return iBufferDes.MaxLength();} |
|
136 |
|
137 void ReUse(TInt aMaxLength) {iBufferDes.Set(iBuffer,0, Min(aMaxLength, iMaxLength));} |
|
138 |
|
139 TBool InUse() {return iInUse;} |
|
140 |
|
141 void SetInUse(TBool aInUse) {iInUse=aInUse;} |
|
142 |
|
143 private: |
|
144 CTransferBufferCopy(TInt aMaxLength) : CBase(), iMaxLength(aMaxLength), iBufferDes(0,0,0), iInUse(EFalse){} |
|
145 |
|
146 void ConstructL(); |
|
147 |
|
148 private: |
|
149 TUint8* iBuffer; |
|
150 |
|
151 //Holds the original MaxLength when class constructed. |
|
152 //May be larger than MaxLength of iBufferDes |
|
153 TInt iMaxLength; |
|
154 |
|
155 TPtr8 iBufferDes; |
|
156 |
|
157 TBool iInUse; |
|
158 }; |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 /** |
|
164 * @internalComponent |
|
165 * |
|
166 * A request is created when an external object requests or supplies data. Calls to the File Server are |
|
167 * made asynchronously and a CReadWriteRequest created to notify the caller on completion. |
|
168 * |
|
169 * CReadWriteRequest is an abstract class. Concrete instances are of CReadRequest & CWriteRequest. |
|
170 * Concrete instances need to know whether to call MDataSink::BufferFilledL() or MDataSource::BufferEmptiedL() |
|
171 */ |
|
172 class CReadWriteRequest : public CActive |
|
173 { |
|
174 public: |
|
175 CReadWriteRequest(TAny* aSinkOrSource, CMMFBuffer* aBuffer,TBool aSourceType) |
|
176 : CActive(EPriorityStandard), |
|
177 iSinkOrSource(aSinkOrSource), |
|
178 iBuffer(aBuffer), |
|
179 iSourceType(aSourceType) |
|
180 { |
|
181 CActiveScheduler::Add( this ); |
|
182 } |
|
183 |
|
184 CReadWriteRequest(TAny* aSinkOrSource, CMMFBuffer* aBuffer, CTransferBufferCopy* aOptionalDataBuffer,TBool aSourceType) |
|
185 : CActive(EPriorityStandard), |
|
186 iSinkOrSource(aSinkOrSource), |
|
187 iBuffer(aBuffer), |
|
188 iSourceType(aSourceType), |
|
189 iTransferBufferCopy(aOptionalDataBuffer) |
|
190 { |
|
191 CActiveScheduler::Add( this ); |
|
192 iTransferBufferCopy->SetInUse(ETrue); |
|
193 } |
|
194 |
|
195 CReadWriteRequest(CReadWriteRequest& aRequest) |
|
196 : CActive(EPriorityStandard), |
|
197 iSinkOrSource(aRequest.iSinkOrSource), |
|
198 iBuffer(aRequest.iBuffer), |
|
199 iSourceType(aRequest.iSourceType), |
|
200 iTransferBufferCopy(aRequest.iTransferBufferCopy) |
|
201 { |
|
202 CActiveScheduler::Add( this ); |
|
203 iTransferBufferCopy->SetInUse(ETrue); |
|
204 } |
|
205 |
|
206 |
|
207 TBool Completed() ; |
|
208 TInt SetStatus(TBool aStatus); |
|
209 TDes8& BufferDes() ; |
|
210 TBool SourceType(); |
|
211 const TDesC8& BufferDesC() ; |
|
212 CMMFBuffer* Buffer(); |
|
213 TAny* GetSinkOrSource(); |
|
214 ~CReadWriteRequest() ; |
|
215 |
|
216 |
|
217 // CActive functions. |
|
218 // |
|
219 void SetActive() ; |
|
220 void DoCancel() ; |
|
221 virtual void RunL() = 0 ; |
|
222 virtual TInt RunError( TInt aError ) ; |
|
223 |
|
224 |
|
225 protected : |
|
226 TAny* iSinkOrSource; |
|
227 CMMFBuffer* iBuffer; |
|
228 TBool iSourceType; |
|
229 CTransferBufferCopy* iTransferBufferCopy; |
|
230 |
|
231 TBool iCompleted ; |
|
232 TDes8* iBufferDes ; |
|
233 TInt iError ; |
|
234 TBool iUseTransferBuffer ; |
|
235 void SetTransferBuffer (TBool aTBuffer) ; |
|
236 TBool CanUseTransferBuffer () ; |
|
237 } ; |
|
238 |
|
239 /** |
|
240 * @internalComponent |
|
241 */ |
|
242 class CReadRequest : public CReadWriteRequest |
|
243 { |
|
244 public : |
|
245 CReadRequest(TAny* aParent,TAny* aSinkOrSource, CMMFBuffer* aBuffer, TUint aPosition, TUint aFileSize,TBool aSourceType) |
|
246 : CReadWriteRequest(aSinkOrSource, aBuffer,aSourceType), |
|
247 iPosition(aPosition), iFileSize(aFileSize),iParent(aParent) |
|
248 { } |
|
249 |
|
250 CReadRequest(TAny* aParent,TAny* aSinkOrSource, CMMFBuffer* aBuffer, CTransferBufferCopy* aOptionalDataBuffer, TUint aPosition, TUint aFileSize,TBool aSourceType) |
|
251 : CReadWriteRequest(aSinkOrSource, aBuffer, aOptionalDataBuffer,aSourceType), |
|
252 iPosition(aPosition), iFileSize(aFileSize),iParent(aParent) |
|
253 { } |
|
254 |
|
255 void RunL(); |
|
256 private: |
|
257 TUint iPosition; |
|
258 TUint iFileSize; |
|
259 TAny* iParent; |
|
260 }; |
|
261 |
|
262 #endif |
|
263 |