|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef _C_GLXDATASOURCETASKMDECOMMAND_H_ |
|
21 #define _C_GLXDATASOURCETASKMDECOMMAND_H_ |
|
22 |
|
23 /** |
|
24 * @internal reviewed 10/07/2007 by M Byrne |
|
25 */ |
|
26 |
|
27 |
|
28 // INCLUDES |
|
29 #include <e32cmn.h> |
|
30 #include <glxcommandparser.h> |
|
31 #include <mdequery.h> |
|
32 #include <mdeitem.h> |
|
33 #include <mglxtnthumbnailcreatorclient.h> |
|
34 #include <glxcommandrequest.h> |
|
35 #include "glxdatasourcetaskmde.h" |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CGlxDataSourceMde; |
|
39 class CGlxRequest; |
|
40 class CMdENamespaceDef; |
|
41 class CMdEObjectDef; |
|
42 class CMdEObjectQuery; |
|
43 class CMdERelationDef; |
|
44 class CMdERelationQuery; |
|
45 class CMdESession; |
|
46 |
|
47 // CONSTANTS |
|
48 |
|
49 // CLASS DECLARATION |
|
50 |
|
51 /** |
|
52 * CGlxDataSourceTaskMdeCommand class |
|
53 * |
|
54 */ |
|
55 NONSHARABLE_CLASS( CGlxDataSourceTaskMdeCommand ) : public CGlxDataSourceTaskMde, |
|
56 public MGlxCommandParserCallback |
|
57 |
|
58 { |
|
59 public: // Constructors / Destructors |
|
60 /** |
|
61 * Constructor. |
|
62 * @param aRequest request to be executed. |
|
63 * @param aObserver observer to be informed when task has completed. |
|
64 * @param aDataSource data source to be used by this object. |
|
65 */ |
|
66 CGlxDataSourceTaskMdeCommand(CGlxCommandRequest* aRequest, MGlxDataSourceRequestObserver& aObserver, |
|
67 CGlxDataSource* aDataSource); |
|
68 |
|
69 /** |
|
70 * Symbian 2nd stage constructor |
|
71 * See @ref CGlxDataSourceTaskMde::ConstructL |
|
72 */ |
|
73 void ConstructL(); |
|
74 |
|
75 /** |
|
76 * Destructor |
|
77 */ |
|
78 ~CGlxDataSourceTaskMdeCommand(); |
|
79 |
|
80 private: // From MGlxCommandParserCallback |
|
81 |
|
82 /** |
|
83 * See @ref MGlxCommandParserCallback::AddContainerL |
|
84 */ |
|
85 void AddContainerL(const TDesC& aContainerName); |
|
86 |
|
87 /** |
|
88 * See @ref MGlxCommandParserCallback::AddToContainerL |
|
89 */ |
|
90 void AddToContainerL(const RArray<TGlxMediaId>& aSourceIds, const RArray<TGlxMediaId>& aTargetContainers); |
|
91 |
|
92 /** |
|
93 * See @ref MGlxCommandParserCallback::AddToContainerL |
|
94 */ |
|
95 void AddToContainerL(const TDesC& aSourceUri, const RArray<TGlxMediaId>& aTargetContainers); |
|
96 |
|
97 /** |
|
98 * See @ref MGlxCommandParserCallback::CopyL |
|
99 */ |
|
100 void CopyL(const RArray<TGlxMediaId>& aSourceIds, const TDesC& aDrive); |
|
101 |
|
102 /** |
|
103 * See @ref MGlxCommandParserCallback::MoveL |
|
104 */ |
|
105 void MoveL(const RArray<TGlxMediaId>& aSourceIds, const TDesC& aDrive); |
|
106 |
|
107 /** |
|
108 * See @ref MGlxCommandParserCallback::RemoveFromContainerL |
|
109 */ |
|
110 void RemoveFromContainerL(const RArray<TGlxMediaId>& aItemIds, const TGlxMediaId& aContainerId); |
|
111 |
|
112 /** |
|
113 * See @ref MGlxCommandParserCallback::DeleteL |
|
114 */ |
|
115 void DeleteL(const RArray<TGlxMediaId>& aItemIds); |
|
116 |
|
117 /** |
|
118 * See @ref MGlxCommandParserCallback::RenameL |
|
119 */ |
|
120 void RenameL(const TGlxMediaId& aSourceItemId, const TDesC& aTitle); |
|
121 |
|
122 /** |
|
123 * See @ref MGlxCommandParserCallback::SetDescriptionL |
|
124 */ |
|
125 void SetDescriptionL(const RArray<TGlxMediaId>& aItemIds, const TDesC& aDescription); |
|
126 |
|
127 /** |
|
128 * See @ref MGlxCommandParserCallback::SetCaptureLocationL |
|
129 */ |
|
130 void SetCaptureLocationL(const RArray<TGlxMediaId>& aItemIds, const TCoordinate& aCoordinate); |
|
131 |
|
132 /** |
|
133 * See @ref MGlxCommandParserCallback::ThumbnailCleanupL |
|
134 */ |
|
135 void ThumbnailCleanupL(); |
|
136 |
|
137 private: // from CGlxDataSourceTaskMde |
|
138 |
|
139 /** |
|
140 * See @ref CGlxDataSourceTaskMde::DoHandleQueryCompletedL |
|
141 */ |
|
142 void DoHandleQueryCompletedL(CMdEQuery& aQuery); |
|
143 |
|
144 /** |
|
145 * See @ref CGlxDataSourceTaskMde::DoNextQueryL |
|
146 */ |
|
147 void DoNextQueryL(); |
|
148 |
|
149 private: |
|
150 |
|
151 /** |
|
152 * Enumeration to describe file operations |
|
153 * (Copy or Move) |
|
154 */ |
|
155 enum TFileOperation |
|
156 { |
|
157 ECopy, |
|
158 EMove |
|
159 }; |
|
160 |
|
161 /** |
|
162 * Perform a file operation (copy or move). |
|
163 * @param aSourceIds an array of media ids to copy or move. |
|
164 * @param aDrive destination drive. |
|
165 * @param aFileOperation file operation to perform (either a copy or a move) |
|
166 */ |
|
167 void FileOperationL(const TArray<TGlxMediaId>& aSourceIds, const TDesC& aDrive, TFileOperation aFileOperation); |
|
168 |
|
169 /** |
|
170 * Gets the container id for a given media id. |
|
171 * If aMedia id is KGlxCollectionRootId (0) then container id |
|
172 * is determined using the collection id. E.g. if the aMediaId |
|
173 * is KGlxCollectionRootId and the collection uid is |
|
174 * KGlxCollectionPluginCameraImplementationUid |
|
175 * then the camera album id is returned by the method. |
|
176 * When aMedia id is not equal to KGlxCollectionRootId, (the |
|
177 * vast majority of cases) the container id returned by the method |
|
178 * will be the same as the media id passed in. |
|
179 * |
|
180 * @param aMediaId should be either a valid container id or KGlxCollectionRootId |
|
181 * @return a container id. |
|
182 */ |
|
183 TMdEItemId ContainerItemId(const TGlxMediaId& aMediaId); |
|
184 |
|
185 /** |
|
186 * Uses the PathInfo class to determine the 'root' path for |
|
187 * a given drive. The 'root' path is C:\data for the C drive and |
|
188 * x:\ for all other drives (where x is a drive letter) |
|
189 * @param aDrive the drive for which the root path is required. |
|
190 * @param aRootPath on return contains the root path. |
|
191 */ |
|
192 void RootPath(const TDesC& aDrive, TDes& aRootPath); |
|
193 |
|
194 /** |
|
195 * Copies items from a TGlxMedia array to a TItemId array. |
|
196 * @param aDestArray destination array. (It is the callers responsibility to ensure that aDestArray is on |
|
197 * the cleanup stack should this be required) |
|
198 * @param aSourceArray source array. |
|
199 */ |
|
200 void CopyArrayL(RArray<TItemId>& aDestArray, const RArray<TGlxMediaId>& aSourceArray); |
|
201 |
|
202 /** |
|
203 * Sends progress messages to the client |
|
204 * @param aCurrentStep number of currently completed steps. |
|
205 * @param aStepCount number of total steps to completion. |
|
206 */ |
|
207 void SendProgressMessageL(TInt aCurrentStep, TInt aStepCount); |
|
208 |
|
209 /** |
|
210 * Returns the container object definition (either album or tag) |
|
211 * the container object definition is calculated based on the |
|
212 * collection plug-in id associated with the task. |
|
213 * @param aContainerObjectDef a pointer to the container object |
|
214 * definition associated with the collection plugin if the |
|
215 * function completes with out error. The caller does not take |
|
216 * ownership of the pointer. |
|
217 * @return KErrNone if the collection plug-in has a container |
|
218 * object definition associated with it or a system wide |
|
219 * error code. |
|
220 */ |
|
221 TInt ContainerObjectDef(CMdEObjectDef*& aContainerObjectDef); |
|
222 |
|
223 /** |
|
224 * Handle the completion of a 'add to container' query. |
|
225 * @param aQuery Query that has been completed. |
|
226 */ |
|
227 void DoHandleAddToContainerQueryCompletedL(CMdEQuery& aQuery); |
|
228 |
|
229 /** |
|
230 * Handle the completion of a 'add container' query. |
|
231 * @param aQuery Query that has been completed. |
|
232 */ |
|
233 void DoHandleAddContainerQueryCompletedL(CMdEQuery& aQuery); |
|
234 |
|
235 /** |
|
236 * Handle the completion of a 'delete containers' query. |
|
237 * @param aQuery Query that has been completed. |
|
238 */ |
|
239 void DoHandleDeleteContainersQueryCompletedL(CMdEQuery& aQuery); |
|
240 |
|
241 /** |
|
242 * Handle the completion of a 'delete items' query. |
|
243 * @param aQuery Query that has been completed. |
|
244 */ |
|
245 void DoHandleDeleteItemsQueryCompletedL(CMdEQuery& aQuery); |
|
246 |
|
247 |
|
248 /** |
|
249 * Handle the completion of a 'rename' query. |
|
250 * @param aQuery Query that has been completed. |
|
251 */ |
|
252 void DoHandleRenameQueryCompletedL(CMdEQuery& aQuery); |
|
253 |
|
254 /** |
|
255 * Handle the completion of a 'rename container' query. |
|
256 * @param aQuery Query that has been completed. |
|
257 */ |
|
258 void DoHandleRenameConainerQueryCompletedL(CMdEQuery& aQuery); |
|
259 |
|
260 /** |
|
261 * Appends a query to the query queue that determines the number |
|
262 * of container objects that have the title aTitle. This |
|
263 * method is used to check to see if a container with a |
|
264 * specific title exists. The container type is determined |
|
265 * using the ContainerObjectDef() method |
|
266 * @aQueryType the query type. |
|
267 * @aTitle title to search for. |
|
268 */ |
|
269 void AppendContainerTitleCountQueryL(const TGlxQueryType& aQueryType, const TDesC& aTitle); |
|
270 |
|
271 private: // from CGlxDataSourceTask |
|
272 /** |
|
273 * See @ref CGlxDataSourceTask::ExecuteRequestL |
|
274 */ |
|
275 void ExecuteRequestL(); |
|
276 |
|
277 private: |
|
278 /** |
|
279 * Default name space definition. |
|
280 */ |
|
281 CMdENamespaceDef* iDefaultNameSpaceDef; |
|
282 |
|
283 /** |
|
284 * Collection uid. |
|
285 */ |
|
286 TUid iCollectionUid; |
|
287 |
|
288 /** |
|
289 * Before new relations are added to the database, a check must be made to see if |
|
290 * identical relations already exist. This is done asynchronously so they need to |
|
291 * be stored temporarily as a member variable. |
|
292 */ |
|
293 RArray<TItemId> iLeftIds; |
|
294 |
|
295 /** |
|
296 * Before new relations are added to the database, a check must be made to see if |
|
297 * identical relations already exist. This is done asynchronously so they need to |
|
298 * be stored temporarily as a member variable. |
|
299 */ |
|
300 RArray<TItemId> iRightIds; |
|
301 |
|
302 /** |
|
303 * Used to store object titles while asynchronous operations are in progress. |
|
304 * (owned) |
|
305 */ |
|
306 HBufC* iTitle; |
|
307 |
|
308 /** |
|
309 * Used to store the object to rename while asynchronous operations are in progress. |
|
310 * (owned) |
|
311 */ |
|
312 CMdEObject* iObjectToRename; |
|
313 }; |
|
314 |
|
315 #endif //_C_GLXDATASOURCETASKMDECOMMAND_H_ |