photosgallery/collectionframework/datasource/plugins/glxdatasourcemde/inc/glxdatasourcetaskmdecommand.h
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     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:    Data Source Task MDE Command
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef _C_GLXDATASOURCETASKMDECOMMAND_H_
       
    22 #define _C_GLXDATASOURCETASKMDECOMMAND_H_
       
    23 
       
    24 /**
       
    25  * @internal reviewed 10/07/2007 by M Byrne
       
    26  */
       
    27 
       
    28 
       
    29 // INCLUDES
       
    30 #include <e32cmn.h>
       
    31 #include <glxcommandparser.h>
       
    32 #include <mdequery.h>
       
    33 #include <mdeitem.h>
       
    34 #include <mglxtnthumbnailcreatorclient.h>
       
    35 #include <glxcommandrequest.h>
       
    36 #include "glxdatasourcetaskmde.h"
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CGlxDataSourceMde;
       
    40 class CGlxRequest;
       
    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 	TMdEItemId 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     /**
       
   196      * Copies items from a TGlxMedia array to a TItemId array.
       
   197      * @param aDestArray destination array. (It is the callers responsibility to ensure that aDestArray is on
       
   198      *                                       the cleanup stack should this be required)
       
   199      * @param aSourceArray source array.
       
   200      */
       
   201     void CopyArrayL(RArray<TItemId>& aDestArray, const RArray<TGlxMediaId>& aSourceArray); 
       
   202     
       
   203     /**
       
   204      * Sends progress messages to the client
       
   205      * @param aCurrentStep number of currently completed steps.
       
   206      * @param aStepCount number of total steps to completion.
       
   207      */
       
   208     void SendProgressMessageL(TInt aCurrentStep, TInt aStepCount);
       
   209     
       
   210     /** 
       
   211      * Returns the container object definition (either album or tag)
       
   212      * the container object definition is calculated based on the
       
   213      * collection plug-in id associated with the task.
       
   214      * @param aContainerObjectDef a pointer to the container object
       
   215      * definition associated with the collection plugin if the 
       
   216      * function completes with out error. The caller does not take
       
   217      * ownership of the pointer.
       
   218      * @return KErrNone if the collection plug-in has a container
       
   219      * object definition associated with it or a system wide
       
   220      * error code.
       
   221      */
       
   222     TInt ContainerObjectDef(CMdEObjectDef*& aContainerObjectDef);
       
   223     
       
   224     /**
       
   225      * Handle the completion of a 'add to container' query.
       
   226      * @param aQuery Query that has been completed.
       
   227      */
       
   228     void DoHandleAddToContainerQueryCompletedL(CMdEQuery& aQuery);
       
   229 
       
   230     /**
       
   231      * Handle the completion of a 'add container' query.
       
   232      * @param aQuery Query that has been completed.
       
   233      */
       
   234     void DoHandleAddContainerQueryCompletedL(CMdEQuery& aQuery);
       
   235     
       
   236     /**
       
   237      * Handle the completion of a 'delete containers' query.
       
   238      * @param aQuery Query that has been completed.
       
   239      */
       
   240     void DoHandleDeleteContainersQueryCompletedL(CMdEQuery& aQuery);
       
   241     
       
   242     /**
       
   243      * Handle the completion of a 'delete items' query.
       
   244      * @param aQuery Query that has been completed.
       
   245      */
       
   246     void DoHandleDeleteItemsQueryCompletedL(CMdEQuery& aQuery);
       
   247     
       
   248     
       
   249     /**
       
   250      * Handle the completion of a 'rename' query.
       
   251      * @param aQuery Query that has been completed.
       
   252      */
       
   253     void DoHandleRenameQueryCompletedL(CMdEQuery& aQuery);
       
   254     
       
   255     /**
       
   256      * Handle the completion of a 'rename container' query.
       
   257      * @param aQuery Query that has been completed.
       
   258      */
       
   259     void DoHandleRenameConainerQueryCompletedL(CMdEQuery& aQuery);
       
   260     
       
   261     /**
       
   262      * Appends a query to the query queue that determines the number
       
   263      * of container objects that have the title aTitle. This
       
   264      * method is used to check to see if a container with a
       
   265      * specific title exists. The container type is determined 
       
   266      * using the ContainerObjectDef() method
       
   267      * @aQueryType the query type.
       
   268      * @aTitle title to search for.
       
   269      */
       
   270     void AppendContainerTitleCountQueryL(const TGlxQueryType& aQueryType, const TDesC& aTitle);
       
   271     
       
   272 private: // from CGlxDataSourceTask
       
   273 	/**
       
   274      * See @ref CGlxDataSourceTask::ExecuteRequestL
       
   275      */
       
   276 	void ExecuteRequestL();
       
   277 
       
   278 private:	
       
   279 	/**
       
   280 	 * Default name space definition.
       
   281 	 */
       
   282 	CMdENamespaceDef* iDefaultNameSpaceDef; 
       
   283 	
       
   284 	/**
       
   285 	 * Collection uid.
       
   286 	 */
       
   287 	TUid iCollectionUid;
       
   288 	
       
   289 	/**
       
   290 	 * Before new relations are added to the database, a check must be made to see if 
       
   291      * identical relations already exist. This is done asynchronously so they need to 
       
   292      * be stored temporarily as a member variable.
       
   293 	 */
       
   294 	RArray<TItemId> iLeftIds;
       
   295     
       
   296     /**
       
   297      * Before new relations are added to the database, a check must be made to see if 
       
   298      * identical relations already exist. This is done asynchronously so they need to 
       
   299      * be stored temporarily as a member variable.
       
   300      */
       
   301     RArray<TItemId> iRightIds;
       
   302     
       
   303     /**
       
   304      * Used to store object titles while asynchronous operations are in progress.
       
   305      * (owned)
       
   306      */
       
   307     HBufC* iTitle;
       
   308     
       
   309     /**
       
   310      * Used to store the object to rename while asynchronous operations are in progress.
       
   311      * (owned)
       
   312      */
       
   313     CMdEObject* iObjectToRename;
       
   314 	};
       
   315 
       
   316 #endif //_C_GLXDATASOURCETASKMDECOMMAND_H_