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