mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/ccopyobject.cpp
branchRCL_3
changeset 14 05b0d2323768
parent 9 bee149131e4b
child 17 780c925249c1
equal deleted inserted replaced
9:bee149131e4b 14:05b0d2323768
   148     TParsePtrC fileNameParser( suid );
   148     TParsePtrC fileNameParser( suid );
   149     if ( ( newObjectName.Length() + fileNameParser.NameAndExt().Length() )
   149     if ( ( newObjectName.Length() + fileNameParser.NameAndExt().Length() )
   150         <= newObjectName.MaxLength() )
   150         <= newObjectName.MaxLength() )
   151         {
   151         {
   152         newObjectName.Append( fileNameParser.NameAndExt() );
   152         newObjectName.Append( fileNameParser.NameAndExt() );
   153         }
   153         responseCode = CanCopyObjectL( suid, newObjectName );
   154     responseCode = CanCopyObjectL( suid, newObjectName );
   154 
   155 
   155         TUint32 newHandle = KMTPHandleNone;
   156     TUint32 newHandle = KMTPHandleNone;
   156         if ( responseCode == EMTPRespCodeOK )
   157     if ( responseCode == EMTPRespCodeOK )
   157             {
   158         {
   158             newHandle = CopyFileL( newObjectName );
   159         newHandle = CopyFileL( newObjectName );
   159             SendResponseL( EMTPRespCodeOK, 1, &newHandle );
   160         SendResponseL( EMTPRespCodeOK, 1, &newHandle );
   160             PRINT2( _L( "MM MTP <= CCopyObject::CopyObjectL responseCode = 0x%x, aNewHandle = 0x%x" ),
       
   161                 responseCode,
       
   162                 newHandle );
       
   163             }
       
   164         else
       
   165             SendResponseL( responseCode );
   161         }
   166         }
   162     else
   167     else
   163         SendResponseL( responseCode );
   168         // Destination is not appropriate for the full path name shouldn't be longer than 255
       
   169         SendResponseL( EMTPRespCodeInvalidDataset );
   164 
   170 
   165     CleanupStack::PopAndDestroy( &newObjectName ); // - newObjectName
   171     CleanupStack::PopAndDestroy( &newObjectName ); // - newObjectName
   166     PRINT2( _L( "MM MTP <= CCopyObject::CopyObjectL responseCode = 0x%x, aNewHandle = 0x%x" ),
       
   167         responseCode,
       
   168         newHandle );
       
   169     }
   172     }
   170 
   173 
   171 // -----------------------------------------------------------------------------
   174 // -----------------------------------------------------------------------------
   172 // CCopyObject::GetParametersL
   175 // CCopyObject::GetParametersL
   173 // Retrieve the parameters of the request
   176 // Retrieve the parameters of the request
   300         &suid,
   303         &suid,
   301         &aNewFileName );
   304         &aNewFileName );
   302 
   305 
   303     GetPreviousPropertiesL( *iObjectInfo );
   306     GetPreviousPropertiesL( *iObjectInfo );
   304 
   307 
       
   308     // TODO: Need rollback mechanism for consistant with image dp in fw.
       
   309     // Not sure if it should be trap if something wrong with MPX db.
   305     TUint32 handle = AddObjectToStoreL( suid, aNewFileName );
   310     TUint32 handle = AddObjectToStoreL( suid, aNewFileName );
   306 
   311 
       
   312     // Only leave when getting proplist element from data received by fw.
       
   313     // It should not happen after ReceiveDataL in which construction of proplist already succeed.
   307     SetPreviousPropertiesL( *iObjectInfo );
   314     SetPreviousPropertiesL( *iObjectInfo );
   308 
   315 
   309     CFileMan* fileMan = CFileMan::NewL( iFramework.Fs() );
   316     CFileMan* fileMan = CFileMan::NewL( iFramework.Fs() );
   310     User::LeaveIfError( fileMan->Copy( suid, aNewFileName ) );
   317     User::LeaveIfError( fileMan->Copy( suid, aNewFileName ) );
   311     delete fileMan;
   318     delete fileMan;
   386                         {
   393                         {
   387                         iPropertyElement = &( iPropertyList->ReservePropElemL( handle, propCode ) );
   394                         iPropertyElement = &( iPropertyList->ReservePropElemL( handle, propCode ) );
   388                         iPropertyElement->SetStringL( CMTPTypeObjectPropListElement::EValue,
   395                         iPropertyElement->SetStringL( CMTPTypeObjectPropListElement::EValue,
   389                             textData->StringChars() );
   396                             textData->StringChars() );
   390                         }
   397                         }
   391                     else if ( err == KErrNotFound )
   398                     else
   392                         {
   399                         {
   393                         iPropertyElement = NULL;
   400                         iPropertyElement = NULL;
   394                         }
       
   395                     else
       
   396                         {
       
   397                         User::Leave( err );
       
   398                         }
   401                         }
   399 
   402 
   400                     CleanupStack::PopAndDestroy( textData ); // - textData
   403                     CleanupStack::PopAndDestroy( textData ); // - textData
   401                     }
   404                     }
   402                 break;
   405                 break;
   468 
   471 
   469             case EMTPObjectPropCodeName:
   472             case EMTPObjectPropCodeName:
   470                 {
   473                 {
   471                 CMTPTypeString *stringData = CMTPTypeString::NewLC( element.StringL( CMTPTypeObjectPropListElement::EValue ) ); // + stringData
   474                 CMTPTypeString *stringData = CMTPTypeString::NewLC( element.StringL( CMTPTypeObjectPropListElement::EValue ) ); // + stringData
   472 
   475 
   473                 respcode = iDpConfig.PropSettingUtility()->SetMetaDataToWrapperL( iDpConfig,
   476                 respcode = iDpConfig.PropSettingUtility()->SetMetaDataToWrapper( iDpConfig,
   474                     propertyCode,
   477                     propertyCode,
   475                     *stringData,
   478                     *stringData,
   476                     aObject );
   479                     aObject );
   477 
   480 
   478                 CleanupStack::PopAndDestroy( stringData ); // - stringData
   481                 CleanupStack::PopAndDestroy( stringData ); // - stringData
   489                 break;
   492                 break;
   490             }
   493             }
   491         } // end of for loop
   494         } // end of for loop
   492 
   495 
   493     // ignore errors
   496     // ignore errors
       
   497     if ( respcode == EMTPRespCodeOK )
       
   498         {
       
   499         // do nothing, just to get rid of build warning
       
   500         }
   494 
   501 
   495     PRINT1( _L( "MM MTP <= CCopyObject::SetPreviousPropertiesL respcode = 0x%x" ), respcode );
   502     PRINT1( _L( "MM MTP <= CCopyObject::SetPreviousPropertiesL respcode = 0x%x" ), respcode );
   496     }
   503     }
   497 
   504 
   498 // -----------------------------------------------------------------------------
   505 // -----------------------------------------------------------------------------