|
1 /* |
|
2 * Copyright (c) 2009 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: SendObjectInfo/SendObjectPropList/SendObject operation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CSENDOBJECT_H |
|
20 #define CSENDOBJECT_H |
|
21 |
|
22 #include "crequestprocessor.h" |
|
23 |
|
24 // forward declaration |
|
25 class RFs; |
|
26 class CMTPTypeObjectInfo; |
|
27 class MMTPObjectMgr; |
|
28 class CMTPTypeFile; |
|
29 class CMTPTypeObjectPropListElement; |
|
30 class CMTPTypeObjectPropList; |
|
31 class TMTPTypeUint32; |
|
32 class CMTPObjectMetaData; |
|
33 class CMTPObjectPropertyMgr; |
|
34 class MMmMtpDpConfig; |
|
35 |
|
36 /** |
|
37 * Defines SendObjectInfo/SendObject request processor |
|
38 */ |
|
39 class CSendObject : public CRequestProcessor |
|
40 { |
|
41 public: |
|
42 /** |
|
43 * Destructor |
|
44 */ |
|
45 IMPORT_C virtual ~CSendObject(); |
|
46 |
|
47 protected: |
|
48 /** |
|
49 * Standard C++ Constructor |
|
50 * @param aFramework The data provider framework |
|
51 * @param aConnection The connection from which the request comes |
|
52 * @param aWrapper Medadata access interface |
|
53 */ |
|
54 IMPORT_C CSendObject( MMTPDataProviderFramework& aFramework, |
|
55 MMTPConnection& aConnection, |
|
56 MMmMtpDpConfig& aDpConfig ); |
|
57 |
|
58 /** |
|
59 * 2nd Phase Constructor |
|
60 */ |
|
61 IMPORT_C void ConstructL(); |
|
62 |
|
63 protected: |
|
64 // from CRequestProcessor |
|
65 /** |
|
66 * Override to match both the SendObjectInfo and SendObject requests |
|
67 * @param aRequest The request to match |
|
68 * @param aConnection The connection from which the request comes |
|
69 * @return ETrue if the processor can handle the request, otherwise EFalse |
|
70 */ |
|
71 IMPORT_C TBool Match( const TMTPTypeRequest& aRequest, |
|
72 MMTPConnection& aConnection ) const; |
|
73 |
|
74 /** |
|
75 * Verify the reqeust |
|
76 * @return EMTPRespCodeOK if request is verified, otherwise one of the |
|
77 * error response codes |
|
78 */ |
|
79 IMPORT_C TMTPResponseCode CheckRequestL(); |
|
80 |
|
81 /** |
|
82 * Override from CRequestProcessor, can not be neglected |
|
83 * @return ETrue |
|
84 */ |
|
85 IMPORT_C TBool HasDataphase() const; |
|
86 |
|
87 /** |
|
88 * SendObjectInfo/SendObject request handler |
|
89 */ |
|
90 IMPORT_C void ServiceL(); |
|
91 |
|
92 /** |
|
93 * Response Phase Handler |
|
94 */ |
|
95 IMPORT_C TBool DoHandleResponsePhaseL(); |
|
96 |
|
97 /** |
|
98 * Completeing phase Handler |
|
99 */ |
|
100 IMPORT_C TBool DoHandleCompletingPhaseL(); |
|
101 |
|
102 /** |
|
103 * Override from CRequestProcessor, can not be neglected |
|
104 */ |
|
105 IMPORT_C void UsbDisconnect(); |
|
106 |
|
107 // new protected function |
|
108 /** |
|
109 * Called by dp derived processor |
|
110 */ |
|
111 IMPORT_C TMTPResponseCode SetMetaDataToWrapperL( const TUint16 aPropCode, |
|
112 MMTPType& aNewData, |
|
113 const CMTPObjectMetaData& aObjectMetaData ); |
|
114 |
|
115 protected: |
|
116 // new virtual functions |
|
117 /** |
|
118 * |
|
119 */ |
|
120 virtual TMTPResponseCode SetSpecificObjectPropertyL( TUint16 aPropCode, |
|
121 const CMTPObjectMetaData& aObject, |
|
122 const CMTPTypeObjectPropListElement& aElement ) = 0; |
|
123 |
|
124 /** |
|
125 * Check datatypes for DP specific PropCodes |
|
126 */ |
|
127 virtual TMTPResponseCode CheckSepecificPropType( TUint16 aPropCode, TUint16 aDataType ) = 0; |
|
128 |
|
129 virtual TInt HandleSpecificWrapperError(TInt aError, |
|
130 const CMTPObjectMetaData& aObject) = 0; |
|
131 |
|
132 private: |
|
133 /** |
|
134 * Verify if the SendObject request comes after SendObjectInfo request |
|
135 * @return EMTPRespCodeOK if SendObject request comes after a valid |
|
136 * SendObjectInfo request, otherwise |
|
137 * EMTPRespCodeNoValidObjectInfo |
|
138 */ |
|
139 TMTPResponseCode CheckSendingStateL(); |
|
140 |
|
141 /** |
|
142 * Handle request phase of SendObjectInfo operation |
|
143 */ |
|
144 void ServiceInfoL(); |
|
145 |
|
146 /** |
|
147 * Handle request phase of SendObjectPropList operation |
|
148 */ |
|
149 void ServicePropListL(); |
|
150 |
|
151 /** |
|
152 * Handle request phase of SendObject operation |
|
153 */ |
|
154 void ServiceObjectL(); |
|
155 |
|
156 /** |
|
157 * Handle response phase of SendObjectInfo operation |
|
158 */ |
|
159 TBool DoHandleResponsePhaseInfoL(); |
|
160 |
|
161 /** |
|
162 * Handle response phase of SendObject operation |
|
163 */ |
|
164 TBool DoHandleResponsePhasePropListL(); |
|
165 |
|
166 /** |
|
167 * Handle response phase of SendObject operation |
|
168 */ |
|
169 TBool DoHandleResponsePhaseObjectL(); |
|
170 |
|
171 /** |
|
172 * |
|
173 */ |
|
174 TMTPResponseCode VerifyObjectPropListL(TInt& aInvalidParameterIndex); |
|
175 |
|
176 /** |
|
177 * |
|
178 */ |
|
179 TMTPResponseCode CheckPropCodeL(const CMTPTypeObjectPropListElement& aElement); |
|
180 |
|
181 /** |
|
182 * |
|
183 */ |
|
184 TMTPResponseCode ExtractPropertyL(const CMTPTypeObjectPropListElement& aElement); |
|
185 |
|
186 /* |
|
187 * Handle response phase of SetObjectPropListL operation |
|
188 */ |
|
189 TMTPResponseCode SetObjectPropListL( const CMTPTypeObjectPropList& aPropList ); |
|
190 |
|
191 /** |
|
192 * |
|
193 */ |
|
194 TMTPResponseCode MatchStoreAndParentL(); |
|
195 |
|
196 /** |
|
197 * Check if the object is too large |
|
198 * @return ETrue if yes, otherwise EFalse |
|
199 */ |
|
200 TBool IsTooLarge( TUint32 aObjectSize ) const; |
|
201 |
|
202 /** |
|
203 * Check if we can store the file on the storage |
|
204 * @return ETrue if yes, otherwise EFalse |
|
205 */ |
|
206 TBool CanStoreFileL( TUint32 aStorageId, TInt64 aObjectSize ) const; |
|
207 |
|
208 /** |
|
209 * Get the full path name of the object to be saved |
|
210 * @param aFileName, on entry, contains the file name of the object, |
|
211 * on return, contains the full path name of the object to be saved |
|
212 */ |
|
213 TBool GetFullPathNameL( const TDesC& aFileName ); |
|
214 |
|
215 /** |
|
216 * Check if the file already exists on the storage. |
|
217 * @return ETrue if file is exists, otherwise EFalse |
|
218 */ |
|
219 TBool ExistsL( const TDesC& aName ) const; |
|
220 |
|
221 /** |
|
222 * Reserve object information before SendObject |
|
223 */ |
|
224 void ReserveObjectL(); |
|
225 |
|
226 /** |
|
227 * Set protection status of object which could be read/write-only |
|
228 */ |
|
229 void SetProtectionStatusL(); |
|
230 |
|
231 /** |
|
232 * Save object information of object whose size is zero |
|
233 */ |
|
234 void SaveEmptyFileL(); |
|
235 |
|
236 |
|
237 /** |
|
238 * Add file information into database in response phase of SendObject |
|
239 */ |
|
240 void AddMediaToStoreL(); |
|
241 |
|
242 /** |
|
243 * delete the file, which transfer incompletely |
|
244 */ |
|
245 void Rollback(); |
|
246 |
|
247 |
|
248 private: |
|
249 enum TMTPSendingObjectState |
|
250 { |
|
251 EObjectNone, |
|
252 EObjectInfoInProgress, |
|
253 EObjectInfoSucceed, |
|
254 EObjectInfoFail, |
|
255 ESendObjectInProgress, |
|
256 ESendObjectSucceed, |
|
257 ESendObjectFail |
|
258 }; |
|
259 |
|
260 private: |
|
261 RFs& iFs; |
|
262 MMTPObjectMgr& iObjectMgr; |
|
263 MMmMtpDpConfig& iDpConfig; |
|
264 |
|
265 // received dataset |
|
266 CMTPTypeObjectInfo* iObjectInfo; |
|
267 CMTPTypeObjectPropList* iObjectPropList; |
|
268 CMTPTypeFile* iFileReceived; |
|
269 |
|
270 // object which need to reserved |
|
271 CMTPObjectMetaData* iReceivedObjectInfo; |
|
272 |
|
273 // progress of request |
|
274 TMTPSendingObjectState iProgress; |
|
275 |
|
276 // request params |
|
277 TUint16 iOperationCode; |
|
278 TUint32 iStorageId; |
|
279 TUint32 iParentHandle; |
|
280 TUint16 iObjectFormat; |
|
281 TUint64 iObjectSize; |
|
282 |
|
283 // S60 feature doesn't include this. |
|
284 // Reserve for future |
|
285 TUint16 iProtectionStatus; |
|
286 HBufC* iDateMod; |
|
287 |
|
288 // cache info during SendObjectInfo |
|
289 TUint32 iWidth; |
|
290 TUint32 iHeight; |
|
291 |
|
292 TFileName iFullPath; |
|
293 HBufC* iParentSuid; |
|
294 |
|
295 // params which is needed for reserve handle |
|
296 TMTPTypeRequest iExpectedSendObjectRequest; |
|
297 |
|
298 TBool iNoRollback; |
|
299 |
|
300 TUint32 iPreviousTransactionID; |
|
301 TUint32 iPreviousOperation; |
|
302 }; |
|
303 |
|
304 #endif // CSENDOBJECT_H |