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