mtpdataproviders/mtpimagedp/inc/cmtpimagedpsendobjectinfo.h
changeset 0 d0791faffa3f
child 4 60a94a45d437
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19 */
       
    20 
       
    21 #ifndef CMTPIMAGEDPSENDOBJECTINFO_H
       
    22 #define CMTPIMAGEDPSENDOBJECTINFO_H
       
    23 
       
    24 #include <mdccommon.h>
       
    25 #include <mtp/cmtpobjectmetadata.h>
       
    26 #include <mtp/tmtptypenull.h>
       
    27 
       
    28 #include "cmtprequestprocessor.h"
       
    29 
       
    30 class CMTPTypeFile;
       
    31 class CMTPTypeObjectInfo;
       
    32 class CMTPTypeObjectPropList;
       
    33 class CMTPTypeObjectPropListElement;
       
    34 class CMTPImageDpObjectPropertyMgr;
       
    35 class CMTPImageDataProvider;
       
    36 
       
    37 /** 
       
    38 Implements the file data provider's SendObjectInfo request processor.
       
    39 @internalComponent
       
    40 */
       
    41 class CMTPImageDpSendObjectInfo : public CMTPRequestProcessor
       
    42     {
       
    43 public:
       
    44 
       
    45     static MMTPRequestProcessor* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider);
       
    46     ~CMTPImageDpSendObjectInfo();    
       
    47     
       
    48 private:
       
    49 
       
    50     CMTPImageDpSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider);
       
    51     void ConstructL();
       
    52 
       
    53 private: // From CMTPRequestProcessor
       
    54 
       
    55     TBool Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const;
       
    56     TMTPResponseCode CheckRequestL();
       
    57     void ServiceL();
       
    58     TBool DoHandleCompletingPhaseL();
       
    59     TBool DoHandleResponsePhaseL();
       
    60     TBool HasDataphase() const;
       
    61 
       
    62 private:    
       
    63     enum TMTPSendingObjectEvent
       
    64         {
       
    65         EObjectInfoEvent = 0,
       
    66         EObjectPropListEvent,
       
    67         EObjectEvent,
       
    68         EEventEnd
       
    69         }; 
       
    70     
       
    71     enum TMTPSendingObjectState
       
    72         {
       
    73         EStateIdle = 0,        //initail state
       
    74         EObjectInfoCheck,       
       
    75         EObjectInfoServ,    
       
    76         EObjectInfoSucceed,
       
    77         EObjectCheck,
       
    78         EObjectServ,
       
    79         EStateEnd
       
    80         };         
       
    81    
       
    82     typedef TBool (*FsmAction)(CMTPImageDpSendObjectInfo*, TAny*);    
       
    83     struct TInternalFSM
       
    84         {
       
    85         TMTPSendingObjectState iNextSuccessState;
       
    86         TMTPSendingObjectState iNextFailedState;        
       
    87         FsmAction              iFsmAction;               
       
    88         };           
       
    89     
       
    90     typedef void (*RollbackAction)(CMTPImageDpSendObjectInfo*);
       
    91     
       
    92 private:
       
    93     void GetDefaultParentObjectL();
       
    94     TMTPResponseCode GetParentObjectAndStorageIdL();   
       
    95     
       
    96     // check specific request parameters
       
    97     TBool CheckObjectInfoParamsL(TAny *aPtr);
       
    98     TBool CheckObjectPropListParamsL(TAny *aPtr);
       
    99     TBool CheckObjectParams(TAny *aPtr);
       
   100     
       
   101     // static function pointer of FSM
       
   102     static TBool FsmCheckObjectInfoParamsL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
       
   103     static TBool FsmCheckObjectPropListParamsL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
       
   104     static TBool FsmCheckObjectParams(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);    
       
   105     
       
   106     // service functions
       
   107     TBool ServiceSendObjectInfoL(TAny *aPtr);
       
   108     TBool ServiceSendObjectPropListL(TAny *aPtr);
       
   109     TBool ServiceSendObjectL(TAny *aPtr);
       
   110     
       
   111     // static function pointer of FSM
       
   112     static TBool FsmServiceSendObjectInfoL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
       
   113     static TBool FsmServiceSendObjectPropListL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
       
   114     static TBool FsmServiceSendObjectL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);    
       
   115     
       
   116     // response functions
       
   117     TBool DoHandleSendObjectInfoCompleteL(TAny *aPtr);
       
   118     TBool DoHandleSendObjectPropListCompleteL(TAny *aPtr);
       
   119     TBool DoHandleSendObjectCompleteL(TAny *aPtr);
       
   120     
       
   121     // static function pointer of FSM
       
   122     static TBool FsmDoHandleSendObjectInfoCompleteL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
       
   123     static TBool FsmDoHandleSendObjectPropListCompleteL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);
       
   124     static TBool FsmDoHandleSendObjectCompleteL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr);    
       
   125     
       
   126     TBool GetFullPathName(const TDesC& aFileName);    
       
   127     TBool CanStoreFileL(TUint32 aStorageId, TInt64 aObjectSize) const;
       
   128     TBool Exists(const TDesC& aName) const;
       
   129         
       
   130     void ReserveObjectL();
       
   131     void Rollback();
       
   132     void CleanUndoList();
       
   133     
       
   134     // rollback functions
       
   135     void UnreserveObject();
       
   136     void RemoveObjectFromDb();
       
   137     void RemoveObjectFromFs();
       
   138     
       
   139     static void UnreserveObject(CMTPImageDpSendObjectInfo* aObject);
       
   140     static void RemoveObjectFromDb(CMTPImageDpSendObjectInfo* aObject); 
       
   141     static void RemoveObjectFromFs(CMTPImageDpSendObjectInfo* aObject);    
       
   142     
       
   143     TMTPResponseCode ExtractPropertyL(const CMTPTypeObjectPropListElement& aElement);
       
   144     TMTPResponseCode VerifyObjectPropListL(TInt& aInvalidParameterIndex);
       
   145     TMTPResponseCode CheckPropCodeL(const CMTPTypeObjectPropListElement& aElement) const; 
       
   146     
       
   147     void ReturnResponseL();
       
   148     void SetPropertiesL();
       
   149     TBool IsFormatValid(TMTPFormatCode aFormat) const;
       
   150     
       
   151 private: // Owned
       
   152 
       
   153     /**
       
   154     FLOGGER debug trace member variable.
       
   155     */
       
   156     __FLOG_DECLARATION_MEMBER_MUTABLE;
       
   157 
       
   158     CMTPImageDataProvider&   iDataProvider;    
       
   159     CMTPTypeFile*            iFileReceived;
       
   160     CMTPTypeObjectInfo*      iObjectInfo;
       
   161     CMTPTypeObjectPropList*  iObjectPropList;
       
   162     TMTPSendingObjectState   iCurrentState;
       
   163     TMTPSendingObjectEvent   iEvent;
       
   164     TUint16                  iOperationCode;
       
   165     TUint32                  iStorageId;
       
   166     TUint32                  iParentHandle;
       
   167     TUint64                  iObjectSize;
       
   168     HBufC*                   iParentSuid;
       
   169     TFileName                iFullPath;
       
   170     HBufC*                   iDateMod;// To carry modified date extracted from PropertyList
       
   171     HBufC*                   iDateCreated;// To carry created date extracted from PropertyList
       
   172     CMTPObjectMetaData*      iReceivedObject;
       
   173     TMTPTypeRequest          iExpectedSendObjectRequest;
       
   174     TUint16                  iProtectionStatus;
       
   175     TUint16                  iFormatCode;
       
   176     TUint32                  iPreviousTransactionID;
       
   177     CMTPImageDpObjectPropertyMgr&  iObjectPropertyMgr;
       
   178     TFileName                iName;
       
   179     TItemId                  iObjectId;
       
   180     RArray<RollbackAction>   iRollbackList;
       
   181     TBool                    iSuccessful;
       
   182     TInternalFSM             iStateMachine[EStateEnd][EEventEnd];
       
   183     TUint32                  imageWidth;
       
   184     TUint32                  imageHeight;
       
   185     TUint32                  imageBitDepth;    
       
   186     TUint8                   iNonConsumable;
       
   187     };
       
   188     
       
   189 #endif //CMTPIMAGEDPSENDOBJECTINFO_H
       
   190