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