|
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: Move object operation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMOVEOBJECT_H |
|
20 #define CMOVEOBJECT_H |
|
21 |
|
22 #include "crequestprocessor.h" |
|
23 |
|
24 class CFileMan; |
|
25 class CMTPObjectMetaData; |
|
26 class CMmMtpDpMetadataAccessWrapper; |
|
27 class CMTPTypeObjectPropList; |
|
28 class CMTPTypeObjectPropListElement; |
|
29 class MMmMtpDpConfig; |
|
30 |
|
31 /** |
|
32 * Defines MoveObject request processor |
|
33 */ |
|
34 class CMoveObject : public CRequestProcessor |
|
35 { |
|
36 public: |
|
37 /** |
|
38 * Two-phase construction method |
|
39 * @param aFramework The data provider framework |
|
40 * @param aConnection The connection from which the request comes |
|
41 * @param aWrapper medadata access interface |
|
42 * @return a pointer to the created request processor object |
|
43 */ |
|
44 //IMPORT_C static MMmRequestProcessor* NewL( |
|
45 // MMTPDataProviderFramework& aFramework, |
|
46 // MMTPConnection& aConnection, |
|
47 // CMmMtpDpMetadataAccessWrapper& aWrapper ); |
|
48 |
|
49 /** |
|
50 * Destructor |
|
51 */ |
|
52 IMPORT_C virtual ~CMoveObject(); |
|
53 |
|
54 protected: |
|
55 /** |
|
56 * Standard c++ constructor |
|
57 */ |
|
58 IMPORT_C CMoveObject( MMTPDataProviderFramework& aFramework, |
|
59 MMTPConnection& aConnection, |
|
60 MMmMtpDpConfig& aDpConfig ); |
|
61 |
|
62 /** |
|
63 * Second phase constructor |
|
64 */ |
|
65 IMPORT_C void ConstructL(); |
|
66 |
|
67 protected: |
|
68 // from CRequestProcessor |
|
69 /** |
|
70 * MoveObject request handler |
|
71 */ |
|
72 IMPORT_C void ServiceL(); |
|
73 |
|
74 // from CActive |
|
75 IMPORT_C void RunL(); |
|
76 |
|
77 IMPORT_C TInt RunError( TInt aError ); |
|
78 |
|
79 |
|
80 protected: |
|
81 // new virtuals |
|
82 /** |
|
83 * Set MetaData to CMetadataAccessWrapper, for internal use |
|
84 * @param aPropCode, specify property code of aMediaProp |
|
85 * @param aNewData, object property value which will be get from |
|
86 * aObjectMetaData |
|
87 * @param aObjectMetaData, owner of the property which should be |
|
88 * inserted or updated into database |
|
89 * @return response code |
|
90 */ |
|
91 IMPORT_C TMTPResponseCode ServiceMetaDataToWrapper( const TUint16 aPropCode, |
|
92 MMTPType& aNewData, |
|
93 const CMTPObjectMetaData& aObject ); |
|
94 |
|
95 virtual void ServiceGetSpecificObjectPropertyL( TUint16 aPropCode, |
|
96 TUint32 aHandle, |
|
97 const CMTPObjectMetaData& aObject ) = 0; |
|
98 |
|
99 virtual TMTPResponseCode ServiceSetSpecificObjectPropertyL( TUint16 aPropCode, |
|
100 const CMTPObjectMetaData& aObject, |
|
101 const CMTPTypeObjectPropListElement& aElement ) = 0; |
|
102 |
|
103 private: |
|
104 /** |
|
105 * Retrieve the parameters of the request |
|
106 */ |
|
107 void GetParametersL(); |
|
108 |
|
109 /** |
|
110 * Get a default parent object, ff the request does not specify a parent object, |
|
111 */ |
|
112 void SetDefaultParentObjectL(); |
|
113 |
|
114 /** |
|
115 * move object operations |
|
116 * @return A valid MTP response code. |
|
117 */ |
|
118 TMTPResponseCode MoveObjectL(); |
|
119 |
|
120 /** |
|
121 * Check if we can move the file to the new location |
|
122 */ |
|
123 TMTPResponseCode CanMoveObjectL( const TDesC& aOldName, |
|
124 const TDesC& aNewName ) const; |
|
125 |
|
126 /** |
|
127 * Save the object properties before moving |
|
128 */ |
|
129 void GetPreviousPropertiesL( const CMTPObjectMetaData& aObject ); |
|
130 |
|
131 /** |
|
132 * Set the object properties after moving |
|
133 */ |
|
134 |
|
135 void SetPreviousPropertiesL( const CMTPObjectMetaData& aObject ); |
|
136 /** |
|
137 * A helper function of MoveObjectL. |
|
138 * @param aNewFileName the new file name after the object is moved. |
|
139 */ |
|
140 void MoveFileL( const TDesC& aNewFileName ); |
|
141 |
|
142 /** |
|
143 * A helper function of MoveObjectL |
|
144 */ |
|
145 void MoveFolderL(); |
|
146 |
|
147 /* Move the objects through iterations of RunL. It currently move 20 objects |
|
148 * at a time and the number can be adjusted by changing |
|
149 * "KMoveObjectGranularity" |
|
150 */ |
|
151 TBool MoveOwnedObjectsL(); |
|
152 |
|
153 /** |
|
154 * Set the object properties in the object property store. |
|
155 */ |
|
156 void SetPropertiesL( const TDesC& aOldFileName, |
|
157 const TDesC& aNewFileName, |
|
158 const CMTPObjectMetaData& aNewObject ); |
|
159 |
|
160 /* |
|
161 * This function will actually delete the orginal folders from the file system. |
|
162 */ |
|
163 TMTPResponseCode FinalPhaseMove(); |
|
164 |
|
165 /* |
|
166 * Generate the list of handles that need to be moved to the new location. |
|
167 */ |
|
168 void GenerateObjectHandleListL( TUint32 aParentHandle ); |
|
169 |
|
170 /* |
|
171 * Move a single object and update the database |
|
172 */ |
|
173 void MoveAndUpdateL( TUint32 objectHandle ); |
|
174 |
|
175 |
|
176 protected: |
|
177 CMTPTypeObjectPropListElement* iPropertyElement; |
|
178 MMmMtpDpConfig& iDpConfig; |
|
179 CMTPTypeObjectPropList* iPropertyList; |
|
180 private: |
|
181 TBool iSameStorage; |
|
182 CFileMan* iFileMan; |
|
183 CMTPObjectMetaData* iObjectInfo; //Not owned. |
|
184 HBufC* iDest; |
|
185 HBufC* iNewRootFolder; |
|
186 TUint32 iNewParentHandle; |
|
187 TUint32 iStorageId; |
|
188 TTime iPreviousModifiedTime; |
|
189 HBufC* iPathToMove; |
|
190 RArray<TUint> iObjectHandles; |
|
191 TInt iMoveObjectIndex; |
|
192 TInt iNumberOfObjects; |
|
193 }; |
|
194 |
|
195 #endif // CMOVEOBJCT_H |