mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/inc/cmoveobject.h
changeset 25 d881023c13eb
parent 0 a2952bb97e68
equal deleted inserted replaced
21:a05c44bc3c61 25:d881023c13eb
    19 #ifndef CMOVEOBJECT_H
    19 #ifndef CMOVEOBJECT_H
    20 #define CMOVEOBJECT_H
    20 #define CMOVEOBJECT_H
    21 
    21 
    22 #include "crequestprocessor.h"
    22 #include "crequestprocessor.h"
    23 
    23 
    24 class CFileMan;
       
    25 class CMTPObjectMetaData;
    24 class CMTPObjectMetaData;
    26 class CMmMtpDpMetadataAccessWrapper;
       
    27 class CMTPTypeObjectPropList;
    25 class CMTPTypeObjectPropList;
    28 class CMTPTypeObjectPropListElement;
    26 class CMTPTypeObjectPropListElement;
    29 class MMmMtpDpConfig;
    27 class MMmMtpDpConfig;
    30 
    28 
    31 /**
    29 /**
    33 */
    31 */
    34 class CMoveObject : public CRequestProcessor
    32 class CMoveObject : public CRequestProcessor
    35     {
    33     {
    36 public:
    34 public:
    37     /**
    35     /**
    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(
       
    45     //        MMTPDataProviderFramework& aFramework,
       
    46     //        MMTPConnection& aConnection,
       
    47     //        CMmMtpDpMetadataAccessWrapper& aWrapper );
       
    48 
       
    49     /**
       
    50     * Destructor
    36     * Destructor
    51     */
    37     */
    52     IMPORT_C virtual ~CMoveObject();
    38     IMPORT_C virtual ~CMoveObject();
    53 
    39 
    54 protected:
    40 protected:
    55     /**
    41     /**
    56     * Standard c++ constructor
    42     * Standard c++ constructor
    57     */
    43     */
    58     IMPORT_C CMoveObject( MMTPDataProviderFramework& aFramework,
    44     IMPORT_C CMoveObject( MMTPDataProviderFramework& aFramework,
    59             MMTPConnection& aConnection,
    45         MMTPConnection& aConnection,
    60             MMmMtpDpConfig& aDpConfig );
    46         MMmMtpDpConfig& aDpConfig );
    61 
    47 
    62     /**
    48     /**
    63     * Second phase constructor
    49     * Second phase constructor
    64     */
    50     */
    65     IMPORT_C void ConstructL();
    51     IMPORT_C void ConstructL();
    69     /**
    55     /**
    70     * MoveObject request handler
    56     * MoveObject request handler
    71     */
    57     */
    72     IMPORT_C void ServiceL();
    58     IMPORT_C void ServiceL();
    73 
    59 
    74     // from CActive
       
    75     IMPORT_C void RunL();
       
    76 
       
    77     IMPORT_C TInt RunError( TInt aError );
       
    78 
       
    79 
       
    80 protected:
    60 protected:
    81     // new virtuals
    61     // new virtuals
    82     /**
    62     /**
    83     * Set MetaData to CMetadataAccessWrapper, for internal use
    63     * Set MetaData to CMetadataAccessWrapper, for internal use
    84     * @param aPropCode, specify property code of aMediaProp
    64     * @param aPropCode, specify property code of an object
    85     * @param aNewData, object property value which will be get from
    65     * @param aHandle, object handles of which the properties are needed
    86     *    aObjectMetaData
    66     * @param aObject, owner of the properties which should be
    87     * @param aObjectMetaData, owner of the property which should be
       
    88     *    inserted or updated into database
    67     *    inserted or updated into database
    89     * @return response code
       
    90     */
    68     */
    91     IMPORT_C TMTPResponseCode ServiceMetaDataToWrapper( const TUint16 aPropCode,
       
    92             MMTPType& aNewData,
       
    93             const CMTPObjectMetaData& aObject );
       
    94 
       
    95     virtual void ServiceGetSpecificObjectPropertyL( TUint16 aPropCode,
    69     virtual void ServiceGetSpecificObjectPropertyL( TUint16 aPropCode,
    96             TUint32 aHandle,
    70         TUint32 aHandle,
    97             const CMTPObjectMetaData& aObject ) = 0;
    71         const CMTPObjectMetaData& aObject ) = 0;
    98 
       
    99     virtual TMTPResponseCode ServiceSetSpecificObjectPropertyL( TUint16 aPropCode,
       
   100                 const CMTPObjectMetaData& aObject,
       
   101                 const CMTPTypeObjectPropListElement& aElement ) = 0;
       
   102 
    72 
   103 private:
    73 private:
   104     /**
    74     /**
   105     * Retrieve the parameters of the request
    75     * Retrieve the parameters of the request
   106     */
    76     */
   113 
    83 
   114     /**
    84     /**
   115     * move object operations
    85     * move object operations
   116     * @return A valid MTP response code.
    86     * @return A valid MTP response code.
   117     */
    87     */
   118     TMTPResponseCode MoveObjectL();
    88     void MoveObjectL();
   119 
    89 
   120     /**
    90     /**
   121     * Check if we can move the file to the new location
    91     * Check if we can move the file to the new location
   122     */
    92     */
   123     TMTPResponseCode CanMoveObjectL( const TDesC& aOldName,
    93     TMTPResponseCode CanMoveObjectL( const TDesC& aOldName,
   124             const TDesC& aNewName ) const;
    94         const TDesC& aNewName ) const;
   125 
    95 
   126     /**
    96     /**
   127     * Save the object properties before moving
    97     * Save the object properties before moving
   128     */
    98     */
   129     void GetPreviousPropertiesL( const CMTPObjectMetaData& aObject );
    99     void GetPreviousPropertiesL( const CMTPObjectMetaData& aObject );
   130 
   100 
   131     /**
   101     /**
   132     * Set the object properties after moving
   102     * Set the object properties after moving
   133     */
   103     */
   134 
   104     void SetPreviousPropertiesL();
   135     void SetPreviousPropertiesL( const CMTPObjectMetaData& aObject );
       
   136     /**
   105     /**
   137     * A helper function of MoveObjectL.
   106     * A helper function of MoveObjectL.
   138     * @param aNewFileName the new file name after the object is moved.
   107     * @param aNewFileName the new file name after the object is moved.
   139     */
   108     */
   140     void MoveFileL( const TDesC& aNewFileName );
   109     void MoveFileL( const TDesC& aNewFileName );
   141 
   110 
   142     /**
   111     /**
   143     * A helper function of MoveObjectL
       
   144     */
       
   145     void MoveFolderL();
       
   146 
       
   147     /* Move the objects through iterations of RunL. It currently move 20 objects
       
   148     * at a time and the number can be adjusted by changing
       
   149     * "KMoveObjectGranularity"
       
   150     */
       
   151     TBool MoveOwnedObjectsL();
       
   152 
       
   153     /**
       
   154     * Set the object properties in the object property store.
   112     * Set the object properties in the object property store.
   155     */
   113     */
   156     void SetPropertiesL( const TDesC& aOldFileName,
   114     void SetPropertiesL( const TDesC& aNewFileName );
   157         const TDesC& aNewFileName,
       
   158         const CMTPObjectMetaData& aNewObject );
       
   159 
       
   160     /*
       
   161     * This function will actually delete the orginal folders from the file system.
       
   162     */
       
   163     TMTPResponseCode FinalPhaseMove();
       
   164 
       
   165     /*
       
   166     * Generate the list of handles that need to be moved to the new location.
       
   167     */
       
   168     void GenerateObjectHandleListL( TUint32 aParentHandle );
       
   169 
   115 
   170     /*
   116     /*
   171     * Move a single object and update the database
   117     * Move a single object and update the database
   172     */
   118     */
   173     void MoveAndUpdateL( TUint32 objectHandle );
   119     void MoveAndUpdateL( TUint32 objectHandle );
   177     CMTPTypeObjectPropListElement* iPropertyElement;
   123     CMTPTypeObjectPropListElement* iPropertyElement;
   178     MMmMtpDpConfig& iDpConfig;
   124     MMmMtpDpConfig& iDpConfig;
   179     CMTPTypeObjectPropList* iPropertyList;
   125     CMTPTypeObjectPropList* iPropertyList;
   180 private:
   126 private:
   181     TBool iSameStorage;
   127     TBool iSameStorage;
   182     CFileMan* iFileMan;
   128     CMTPObjectMetaData* iObjectInfo; // Not owned
   183     CMTPObjectMetaData* iObjectInfo; //Not owned.
       
   184     HBufC* iDest;
   129     HBufC* iDest;
   185     HBufC* iNewRootFolder;
       
   186     TUint32 iNewParentHandle;
   130     TUint32 iNewParentHandle;
   187     TUint32 iStorageId;
   131     TUint32 iStorageId;
   188     TTime iPreviousModifiedTime;
   132     TTime iPreviousModifiedTime;
   189     HBufC* iPathToMove;
   133 
   190     RArray<TUint> iObjectHandles;
       
   191     TInt iMoveObjectIndex;
       
   192     TInt iNumberOfObjects;
       
   193     };
   134     };
   194 
   135 
   195 #endif // CMOVEOBJCT_H
   136 #endif // CMOVEOBJCT_H