mtpfws/mtpfw/dataproviders/proxydp/src/cmtpdeleteobject.cpp
changeset 17 aabe5387f5ce
parent 0 d0791faffa3f
child 18 1b39655331a3
equal deleted inserted replaced
0:d0791faffa3f 17:aabe5387f5ce
    33 
    33 
    34 __FLOG_STMT( _LIT8( KComponent,"PrxyDelObj" ); )
    34 __FLOG_STMT( _LIT8( KComponent,"PrxyDelObj" ); )
    35 const TUint KInvalidDpId = 0xFF;
    35 const TUint KInvalidDpId = 0xFF;
    36 
    36 
    37 /**
    37 /**
       
    38 Verification data for the DeleteObject request
       
    39 */
       
    40 const TMTPRequestElementInfo KMTPDeleteObjectPolicy[] = 
       
    41     {
       
    42         { TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, (EMTPElementAttrDir | EMTPElementAttrWrite), 1, KMTPHandleAll, 0 }
       
    43     };
       
    44 
       
    45 /**
    38 Two-phase construction method
    46 Two-phase construction method
    39 @param aFramework    The data provider framework
    47 @param aFramework    The data provider framework
    40 @param aConnection    The connection from which the request comes
    48 @param aConnection    The connection from which the request comes
    41 @return a pointer to the created request processor object
    49 @return a pointer to the created request processor object
    42 */ 
    50 */ 
    65 
    73 
    66 /**
    74 /**
    67 Constructor
    75 Constructor
    68 */    
    76 */    
    69 CMTPDeleteObject::CMTPDeleteObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
    77 CMTPDeleteObject::CMTPDeleteObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
    70     CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
    78     CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPDeleteObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPDeleteObjectPolicy),
    71     iDeletedObjectsNumber(0)
    79     iDeletedObjectsNumber(0)
    72     {
    80     {
    73     __FLOG_OPEN( KMTPSubsystem, KComponent );
    81     __FLOG_OPEN( KMTPSubsystem, KComponent );
    74     __FLOG( _L8("+/-Ctor") );
    82     __FLOG( _L8("+/-Ctor") );
    75     }
    83     }
    84     iSingletons.OpenL();
    92     iSingletons.OpenL();
    85     iOwnerDp = KInvalidDpId;
    93     iOwnerDp = KInvalidDpId;
    86     __FLOG( _L8("-ConstructL") );
    94     __FLOG( _L8("-ConstructL") );
    87     }
    95     }
    88     
    96     
       
    97 TMTPResponseCode CMTPDeleteObject::CheckRequestL()
       
    98 	{
       
    99     __FLOG(_L8("CheckRequestL - Entry"));
       
   100     TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();   
       
   101     if ((EMTPRespCodeOK == responseCode) && (iSingletons.DpController().EnumerateState() == CMTPDataProviderController::EEnumeratingSubDirFiles))
       
   102         {
       
   103 		responseCode = EMTPRespCodeDeviceBusy;
       
   104         }
       
   105     
       
   106 	__FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode));
       
   107     return responseCode;
       
   108 	}
       
   109 
    89 /**
   110 /**
    90 DeleteObject request handler
   111 DeleteObject request handler
    91 */ 
   112 */ 
    92 void CMTPDeleteObject::ServiceL()
   113 void CMTPDeleteObject::ServiceL()
    93     {
   114     {
   156     {
   177     {
   157     __FLOG( _L8("+RunL") );
   178     __FLOG( _L8("+RunL") );
   158     
   179     
   159     if ( iStatus == KErrNone )
   180     if ( iStatus == KErrNone )
   160         {
   181         {
   161         NextObjectHandleL();
   182         //First check if the operation has been cancelled or not
   162         if ( iOwnerDp != KInvalidDpId )
   183         if(iCancelled)
   163             {
   184             {
   164             CMTPDataProvider& dp = iSingletons.DpController().DataProviderL( iOwnerDp );
   185             __FLOG(_L8("Initiator cancell delete, send response with cancelled code "));
   165             dp.ExecuteProxyRequestL( iCurrentRequest, Connection(), *this );
   186             SendResponseL(EMTPRespCodeTransactionCancelled);
       
   187             iCancelled = EFalse;
       
   188             }
       
   189         else
       
   190             {
       
   191             NextObjectHandleL();
       
   192             if ( iOwnerDp != KInvalidDpId )
       
   193                 {
       
   194                 CMTPDataProvider& dp = iSingletons.DpController().DataProviderL( iOwnerDp );
       
   195                 dp.ExecuteProxyRequestL( iCurrentRequest, Connection(), *this );
       
   196                 }
   166             }
   197             }
   167         }
   198         }
   168     else
   199     else
   169         {
   200         {
   170         SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
   201         SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
   207     iObjBrowser = CMTPObjectBrowser::NewL( iFramework );
   238     iObjBrowser = CMTPObjectBrowser::NewL( iFramework );
   208     
   239     
   209     iHandles.Reset();
   240     iHandles.Reset();
   210     iCurrentHandle = 0;
   241     iCurrentHandle = 0;
   211     iDeletedObjectsNumber = 0;
   242     iDeletedObjectsNumber = 0;
       
   243     
   212     MMTPType::CopyL( Request(), iCurrentRequest );
   244     MMTPType::CopyL( Request(), iCurrentRequest );
   213     
   245     
   214     CMTPObjectBrowser::TBrowseCallback callback = { CMTPDeleteObject::OnBrowseObjectL, this };
   246     CMTPObjectBrowser::TBrowseCallback callback = { CMTPDeleteObject::OnBrowseObjectL, this };
   215     TUint32 handle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
   247     TUint32 handle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
   216     TUint32 fmtCode = KMTPFormatsAll;
   248     TUint32 fmtCode = KMTPFormatsAll;