mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/inc/ccopyobject.h
changeset 0 a2952bb97e68
child 9 bee149131e4b
child 25 d881023c13eb
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 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:  Copy object operation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CCOPYOBJECT_H
       
    20 #define CCOPYOBJECT_H
       
    21 
       
    22 #include "crequestprocessor.h"
       
    23 
       
    24 class RFs;
       
    25 class CFileMan;
       
    26 class CMTPObjectMetaData;
       
    27 class CMTPTypeObjectPropList;
       
    28 class CMTPTypeObjectPropListElement;
       
    29 class MMmMtpDpConfig;
       
    30 
       
    31 /**
       
    32 * Defines CopyObject request processor
       
    33 */
       
    34 class CCopyObject : public CRequestProcessor
       
    35     {
       
    36 public:
       
    37     /**
       
    38     * Two-phase construction method
       
    39     * @param aFramework    The data provider framework
       
    40     * @param aConnection    The connection from which the request comes
       
    41     * @param aWrapper    medadata access interface
       
    42     * @return a pointer to the created request processor object
       
    43     */
       
    44     //IMPORT_C static MMmRequestProcessor* NewL( MMTPDataProviderFramework& aFramework,
       
    45     //        MMTPConnection& aConnection,
       
    46     //        CMmMtpDpMetadataAccessWrapper& aWrapper );
       
    47 
       
    48     /**
       
    49     * Destructor
       
    50     */
       
    51     IMPORT_C virtual ~CCopyObject();
       
    52 
       
    53 protected:
       
    54     /**
       
    55     * Standard c++ constructor
       
    56     */
       
    57     IMPORT_C CCopyObject( MMTPDataProviderFramework& aFramework,
       
    58             MMTPConnection& aConnection,
       
    59             MMmMtpDpConfig& aDpConfig );
       
    60 
       
    61     /**
       
    62     * Second phase constructor
       
    63     */
       
    64     IMPORT_C void ConstructL();
       
    65 
       
    66 protected:
       
    67     // from CMTPRequestProcessor
       
    68     /**
       
    69     * CopyObject request handler
       
    70     */
       
    71     IMPORT_C void ServiceL();
       
    72 
       
    73     /**
       
    74     * Set MetaData to CMetadataAccessWrapper, for internal use
       
    75     * @param aPropCode, specify property code of aMediaProp
       
    76     * @param aNewData, object property value which will be get from
       
    77     *    aObjectMetaData
       
    78     * @param aObjectMetaData, owner of the property which should be
       
    79     *    inserted or updated into database
       
    80     * @return response code
       
    81     */
       
    82     IMPORT_C TMTPResponseCode ServiceMetaDataToWrapper( const TUint16 aPropCode,
       
    83             MMTPType& aNewData,
       
    84             const CMTPObjectMetaData& aObject );
       
    85 
       
    86     virtual void ServiceGetSpecificObjectPropertyL( TUint16 aPropCode,
       
    87         TUint32 aHandle,
       
    88         const CMTPObjectMetaData& aObjectMetaData ) = 0;
       
    89 
       
    90     virtual TMTPResponseCode ServiceSetSpecificObjectPropertyL( TUint16 aPropCode,
       
    91         const CMTPObjectMetaData& aObject,
       
    92         const CMTPTypeObjectPropListElement& aElement ) = 0;
       
    93 
       
    94     // from CActive
       
    95     IMPORT_C void RunL();
       
    96 
       
    97     IMPORT_C TInt RunError( TInt aError );
       
    98 
       
    99 private:
       
   100     /**
       
   101     * Retrieve the parameters of the request
       
   102     */
       
   103     void GetParametersL();
       
   104 
       
   105     void SetDefaultParentObjectL();
       
   106 
       
   107     /**
       
   108     * Copy object operation
       
   109     */
       
   110     void CopyObjectL( TUint32& aNewHandle );
       
   111 
       
   112     /**
       
   113     * Check if we can copy the file to the new location
       
   114     */
       
   115     TMTPResponseCode CanCopyObjectL( const TDesC& aOldName,
       
   116             const TDesC& aNewName ) const;
       
   117 
       
   118     /**
       
   119     * Save the object properties before doing the copy
       
   120     */
       
   121     void GetPreviousPropertiesL( const CMTPObjectMetaData& aObject );
       
   122 
       
   123     /**
       
   124     * Set the object properties after doing the copy
       
   125     */
       
   126     void SetPreviousPropertiesL( const CMTPObjectMetaData& aObject );
       
   127 
       
   128     /**
       
   129     * A helper function of CopyObjectL.
       
   130     * @param aNewFileName the new full filename after copy.
       
   131     * @return objectHandle of new copy of object.
       
   132     */
       
   133     TUint32 CopyFileL( const TDesC& aNewFileName );
       
   134 
       
   135     /*
       
   136     * Generate the list of handles that need to be copied to the new location.
       
   137     */
       
   138     void GenerateObjectHandleListL( TUint32 aParentHandle );
       
   139 
       
   140     /**
       
   141     * A helper function of CopyObjectL.
       
   142     * @param aNewFolderName the new full file folder name after copy.
       
   143     * @return objecthandle of new copy of the folder.
       
   144     */
       
   145     TUint32 CopyFolderL( const TDesC& aNewFolderName );
       
   146 
       
   147     /**
       
   148     * Set the object properties in the object property store.
       
   149     */
       
   150     void SetPropertiesL( const TDesC& aOldFileName,
       
   151         const TDesC& aNewFileName,
       
   152         const CMTPObjectMetaData& aObject );
       
   153 
       
   154     /**
       
   155     * Update object info in the database.
       
   156     */
       
   157     TUint32 UpdateObjectInfoL( const TDesC& aOldObjectName,
       
   158             const TDesC& aNewObjectName);
       
   159 
       
   160     /*
       
   161     * A helper function of CopyObjectL
       
   162     * Copy a single object and update the database
       
   163     */
       
   164     void CopyAndUpdateL( TUint32 objectHandle );
       
   165 
       
   166 protected:
       
   167     CMTPTypeObjectPropListElement* iPropertyElement;
       
   168     MMmMtpDpConfig& iDpConfig;
       
   169     CMTPTypeObjectPropList* iPropertyList;
       
   170 private:
       
   171     CMTPObjectMetaData* iObjectInfo; // Not owned
       
   172     RArray<TUint> iObjectHandles;
       
   173     CFileMan* iFileMan;
       
   174     HBufC* iDest;
       
   175     TUint32 iNewParentHandle;
       
   176     TUint32 iHandle;
       
   177     TUint32 iStorageId;
       
   178     TInt iCopyObjectIndex;
       
   179     TInt iNumberOfObjects;
       
   180     HBufC* iPathToCopy;
       
   181     HBufC* iNewRootFolder;
       
   182     TTime iPreviousModifiedTime;
       
   183 
       
   184     };
       
   185 
       
   186 #endif // CCOPYOBJECT_H