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