33 */ |
31 */ |
34 class CCopyObject : public CRequestProcessor |
32 class CCopyObject : public CRequestProcessor |
35 { |
33 { |
36 public: |
34 public: |
37 /** |
35 /** |
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( MMTPDataProviderFramework& aFramework, |
|
45 // MMTPConnection& aConnection, |
|
46 // CMmMtpDpMetadataAccessWrapper& aWrapper ); |
|
47 |
|
48 /** |
|
49 * Destructor |
36 * Destructor |
50 */ |
37 */ |
51 IMPORT_C virtual ~CCopyObject(); |
38 IMPORT_C virtual ~CCopyObject(); |
52 |
39 |
53 protected: |
40 protected: |
54 /** |
41 /** |
55 * Standard c++ constructor |
42 * Standard c++ constructor |
56 */ |
43 */ |
57 IMPORT_C CCopyObject( MMTPDataProviderFramework& aFramework, |
44 IMPORT_C CCopyObject( MMTPDataProviderFramework& aFramework, |
58 MMTPConnection& aConnection, |
45 MMTPConnection& aConnection, |
59 MMmMtpDpConfig& aDpConfig ); |
46 MMmMtpDpConfig& aDpConfig ); |
60 |
47 |
61 /** |
48 /** |
62 * Second phase constructor |
49 * Second phase constructor |
63 */ |
50 */ |
64 IMPORT_C void ConstructL(); |
51 IMPORT_C void ConstructL(); |
68 /** |
55 /** |
69 * CopyObject request handler |
56 * CopyObject request handler |
70 */ |
57 */ |
71 IMPORT_C void ServiceL(); |
58 IMPORT_C void ServiceL(); |
72 |
59 |
73 /** |
|
74 * Set MetaData to CMetadataAccessWrapper, for internal use |
|
75 * @param aPropCode, specify property code of aMediaProp |
|
76 * @param aNewData, object property value which will be get from |
|
77 * aObjectMetaData |
|
78 * @param aObjectMetaData, owner of the property which should be |
|
79 * inserted or updated into database |
|
80 * @return response code |
|
81 */ |
|
82 IMPORT_C TMTPResponseCode ServiceMetaDataToWrapper( const TUint16 aPropCode, |
|
83 MMTPType& aNewData, |
|
84 const CMTPObjectMetaData& aObject ); |
|
85 |
|
86 virtual void ServiceGetSpecificObjectPropertyL( TUint16 aPropCode, |
60 virtual void ServiceGetSpecificObjectPropertyL( TUint16 aPropCode, |
87 TUint32 aHandle, |
61 TUint32 aHandle, |
88 const CMTPObjectMetaData& aObjectMetaData ) = 0; |
62 const CMTPObjectMetaData& aObjectMetaData ) = 0; |
89 |
|
90 virtual TMTPResponseCode ServiceSetSpecificObjectPropertyL( TUint16 aPropCode, |
|
91 const CMTPObjectMetaData& aObject, |
|
92 const CMTPTypeObjectPropListElement& aElement ) = 0; |
|
93 |
|
94 // from CActive |
|
95 IMPORT_C void RunL(); |
|
96 |
|
97 IMPORT_C TInt RunError( TInt aError ); |
|
98 |
63 |
99 private: |
64 private: |
100 /** |
65 /** |
101 * Retrieve the parameters of the request |
66 * Retrieve the parameters of the request |
102 */ |
67 */ |
103 void GetParametersL(); |
68 void GetParametersL(); |
104 |
69 |
|
70 /** |
|
71 * Set a default destination if it is not specified |
|
72 */ |
105 void SetDefaultParentObjectL(); |
73 void SetDefaultParentObjectL(); |
106 |
74 |
107 /** |
75 /** |
108 * Copy object operation |
76 * Copy file and metadata and send response to pc |
|
77 * If everything was right, the handle of newly created file |
|
78 * should be sent back |
109 */ |
79 */ |
110 void CopyObjectL( TUint32& aNewHandle ); |
80 void CopyObjectL(); |
111 |
81 |
112 /** |
82 /** |
113 * Check if we can copy the file to the new location |
83 * Check if the file can be copied |
|
84 * @param aOldName used to get file size |
|
85 * @param aNewName the full path name of newly copied file |
114 */ |
86 */ |
115 TMTPResponseCode CanCopyObjectL( const TDesC& aOldName, |
87 TMTPResponseCode CanCopyObjectL( const TDesC& aOldName, |
116 const TDesC& aNewName ) const; |
88 const TDesC& aNewName ) const; |
117 |
89 |
118 /** |
90 /** |
119 * Save the object properties before doing the copy |
91 * Save the object properties before doing the copy |
120 */ |
92 */ |
121 void GetPreviousPropertiesL( const CMTPObjectMetaData& aObject ); |
93 void GetPreviousPropertiesL(); |
122 |
94 |
123 /** |
95 /** |
124 * Set the object properties after doing the copy |
96 * Set the object properties after doing the copy |
125 */ |
97 */ |
126 void SetPreviousPropertiesL( const CMTPObjectMetaData& aObject ); |
98 void SetPreviousPropertiesL(); |
127 |
99 |
128 /** |
100 /** |
129 * A helper function of CopyObjectL. |
101 * A helper function of CopyObjectL. |
130 * @param aNewFileName the new full filename after copy. |
102 * @param aNewFileName the new full filename after copy. |
131 * @return objectHandle of new copy of object. |
103 * @return handle of the newly copied object. |
132 */ |
104 */ |
133 TUint32 CopyFileL( const TDesC& aNewFileName ); |
105 TUint32 CopyFileL( const TDesC& aNewFileName ); |
134 |
106 |
135 /* |
107 /** |
136 * Generate the list of handles that need to be copied to the new location. |
108 * Add metadata of the newly created file into database and |
|
109 * update related references |
|
110 * @param aOldObjectName old reference owner |
|
111 * @param aNewObjectName new reference owner |
|
112 * @return handle of the newly copied object |
137 */ |
113 */ |
138 void GenerateObjectHandleListL( TUint32 aParentHandle ); |
114 TUint32 AddObjectToStoreL( const TDesC& aOldObjectName, |
139 |
115 const TDesC& aNewObjectName ); |
140 /** |
|
141 * A helper function of CopyObjectL. |
|
142 * @param aNewFolderName the new full file folder name after copy. |
|
143 * @return objecthandle of new copy of the folder. |
|
144 */ |
|
145 TUint32 CopyFolderL( const TDesC& aNewFolderName ); |
|
146 |
|
147 /** |
|
148 * Set the object properties in the object property store. |
|
149 */ |
|
150 void SetPropertiesL( const TDesC& aOldFileName, |
|
151 const TDesC& aNewFileName, |
|
152 const CMTPObjectMetaData& aObject ); |
|
153 |
|
154 /** |
|
155 * Update object info in the database. |
|
156 */ |
|
157 TUint32 UpdateObjectInfoL( const TDesC& aOldObjectName, |
|
158 const TDesC& aNewObjectName); |
|
159 |
|
160 /* |
|
161 * A helper function of CopyObjectL |
|
162 * Copy a single object and update the database |
|
163 */ |
|
164 void CopyAndUpdateL( TUint32 objectHandle ); |
|
165 |
116 |
166 protected: |
117 protected: |
167 CMTPTypeObjectPropListElement* iPropertyElement; |
118 CMTPTypeObjectPropListElement* iPropertyElement; |
168 MMmMtpDpConfig& iDpConfig; |
119 MMmMtpDpConfig& iDpConfig; |
169 CMTPTypeObjectPropList* iPropertyList; |
120 CMTPTypeObjectPropList* iPropertyList; |
|
121 |
170 private: |
122 private: |
171 CMTPObjectMetaData* iObjectInfo; // Not owned |
123 TUint32 iStorageId; |
172 RArray<TUint> iObjectHandles; |
124 CMTPObjectMetaData* iSourceObject; |
173 CFileMan* iFileMan; |
125 CMTPObjectMetaData* iTargetObject; |
174 HBufC* iDest; |
126 HBufC* iDest; |
175 TUint32 iNewParentHandle; |
127 TUint32 iNewParentHandle; |
176 TUint32 iHandle; |
|
177 TUint32 iStorageId; |
|
178 TInt iCopyObjectIndex; |
|
179 TInt iNumberOfObjects; |
|
180 HBufC* iPathToCopy; |
|
181 HBufC* iNewRootFolder; |
|
182 TTime iPreviousModifiedTime; |
128 TTime iPreviousModifiedTime; |
183 |
129 |
184 }; |
130 }; |
185 |
131 |
186 #endif // CCOPYOBJECT_H |
132 #endif // CCOPYOBJECT_H |