83 delete iFileReceived; |
85 delete iFileReceived; |
84 delete iParentSuid; |
86 delete iParentSuid; |
85 delete iReceivedObject; |
87 delete iReceivedObject; |
86 delete iObjectInfo; |
88 delete iObjectInfo; |
87 delete iObjectPropList; |
89 delete iObjectPropList; |
88 |
90 |
89 __FLOG(_L8("CMTPImageDpSendObjectInfo::~CMTPImageDpSendObjectInfo - Exit")); |
91 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CMTPIMAGEDPSENDOBJECTINFO_DES_EXIT ); |
90 __FLOG_CLOSE; |
|
91 } |
92 } |
92 |
93 |
93 /** |
94 /** |
94 Standard c++ constructor |
95 Standard c++ constructor |
95 @param aFramework The data provider framework |
96 @param aFramework The data provider framework |
96 @param aConnection The connection from which the request comes |
97 @param aConnection The connection from which the request comes |
97 */ |
98 */ |
98 CMTPImageDpSendObjectInfo::CMTPImageDpSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider) : |
99 CMTPImageDpSendObjectInfo::CMTPImageDpSendObjectInfo(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider) : |
99 CMTPRequestProcessor(aFramework, aConnection, 0, NULL), |
100 CMTPRequestProcessor(aFramework, aConnection, 0, NULL), |
100 iDataProvider(aDataProvider), |
101 iDataProvider(aDataProvider), |
|
102 iHiddenStatus( EMTPVisible ), |
101 iObjectPropertyMgr(aDataProvider.PropertyMgr()) |
103 iObjectPropertyMgr(aDataProvider.PropertyMgr()) |
102 { |
104 { |
103 |
105 |
104 } |
106 } |
105 |
107 |
145 ADD_FSM_ENTRY(EObjectCheck, EObjectEvent, EObjectServ, EObjectInfoSucceed, FsmServiceSendObjectL); |
146 ADD_FSM_ENTRY(EObjectCheck, EObjectEvent, EObjectServ, EObjectInfoSucceed, FsmServiceSendObjectL); |
146 |
147 |
147 ADD_FSM_ENTRY(EObjectServ, EObjectInfoEvent, EStateEnd, EStateEnd, NULL); |
148 ADD_FSM_ENTRY(EObjectServ, EObjectInfoEvent, EStateEnd, EStateEnd, NULL); |
148 ADD_FSM_ENTRY(EObjectServ, EObjectPropListEvent, EStateEnd, EStateEnd, NULL); |
149 ADD_FSM_ENTRY(EObjectServ, EObjectPropListEvent, EStateEnd, EStateEnd, NULL); |
149 ADD_FSM_ENTRY(EObjectServ, EObjectEvent, EStateIdle, EObjectInfoSucceed, FsmDoHandleSendObjectCompleteL); |
150 ADD_FSM_ENTRY(EObjectServ, EObjectEvent, EStateIdle, EObjectInfoSucceed, FsmDoHandleSendObjectCompleteL); |
150 |
151 |
151 __FLOG(_L8("CMTPImageEnumerator::ConstructL - Exit")); |
152 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CONSTRUCTL_EXIT ); |
152 } |
153 } |
153 |
154 |
154 TBool CMTPImageDpSendObjectInfo::FsmCheckObjectInfoParamsL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr) |
155 TBool CMTPImageDpSendObjectInfo::FsmCheckObjectInfoParamsL(CMTPImageDpSendObjectInfo* aObject, TAny *aPtr) |
155 { |
156 { |
156 return aObject->CheckObjectInfoParamsL(aPtr); |
157 return aObject->CheckObjectInfoParamsL(aPtr); |
251 } |
252 } |
252 else |
253 else |
253 { |
254 { |
254 iCurrentState = iStateMachine[iCurrentState][iEvent].iNextFailedState; |
255 iCurrentState = iStateMachine[iCurrentState][iEvent].iNextFailedState; |
255 } |
256 } |
256 User::LeaveIfError(err); |
257 LEAVEIFERROR(err, |
257 } |
258 OstTrace1( TRACE_ERROR, DUP1_CMTPIMAGEDPSENDOBJECTINFO_CHECKREQUESTL, |
258 __FLOG_1(_L8("CheckRequestL - Result: 0x%04x"), result); |
259 "the request check failed! error code %d", err )); |
259 __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckRequestL - Exit")); |
260 } |
260 |
261 |
|
262 OstTrace1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_CHECKREQUESTL, "Result: 0x%04x", result ); |
|
263 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CHECKREQUESTL_EXIT ); |
261 return result; |
264 return result; |
262 } |
265 } |
263 |
266 |
264 TBool CMTPImageDpSendObjectInfo::HasDataphase() const |
267 TBool CMTPImageDpSendObjectInfo::HasDataphase() const |
265 { |
268 { |
266 return ETrue; |
269 return ETrue; |
267 } |
270 } |
268 |
271 |
269 TBool CMTPImageDpSendObjectInfo::CheckObjectInfoParamsL(TAny *aPtr) |
272 TBool CMTPImageDpSendObjectInfo::CheckObjectInfoParamsL(TAny *aPtr) |
270 { |
273 { |
271 __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectInfoParamsL - Entry")); |
274 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_CHECKOBJECTINFOPARAMSL_ENTRY ); |
272 |
275 |
273 TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr); |
276 TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr); |
274 *ret = EMTPRespCodeOK; |
277 *ret = EMTPRespCodeOK; |
275 |
278 |
276 const TUint32 storeId(Request().Uint32(TMTPTypeRequest::ERequestParameter1)); |
279 const TUint32 storeId(Request().Uint32(TMTPTypeRequest::ERequestParameter1)); |
294 *ret = EMTPRespCodeInvalidObjectHandle; |
297 *ret = EMTPRespCodeInvalidObjectHandle; |
295 } |
298 } |
296 CleanupStack::PopAndDestroy(parentObjInfo); |
299 CleanupStack::PopAndDestroy(parentObjInfo); |
297 } |
300 } |
298 |
301 |
299 __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectInfoParamsL - Exit")); |
302 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CHECKOBJECTINFOPARAMSL_EXIT ); |
300 return (*ret == EMTPRespCodeOK) ? ETrue : EFalse; |
303 return (*ret == EMTPRespCodeOK) ? ETrue : EFalse; |
301 } |
304 } |
302 |
305 |
303 TBool CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL(TAny *aPtr) |
306 TBool CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL(TAny *aPtr) |
304 { |
307 { |
305 __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL - Entry")); |
308 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_CHECKOBJECTPROPLISTPARAMSL_ENTRY ); |
306 TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr); |
309 TMTPResponseCode* ret = static_cast<TMTPResponseCode*>(aPtr); |
307 *ret = EMTPRespCodeOK; |
310 *ret = EMTPRespCodeOK; |
308 |
311 |
309 TMTPFormatCode formatCode = static_cast<TMTPFormatCode>(Request().Uint32(TMTPTypeRequest::ERequestParameter3)); |
312 TMTPFormatCode formatCode = static_cast<TMTPFormatCode>(Request().Uint32(TMTPTypeRequest::ERequestParameter3)); |
310 if (!IsFormatValid(formatCode)) |
313 if (!IsFormatValid(formatCode)) |
345 */ |
348 */ |
346 if ( (iPreviousTransactionID + 1) != Request().Uint32(TMTPTypeRequest::ERequestTransactionID)) |
349 if ( (iPreviousTransactionID + 1) != Request().Uint32(TMTPTypeRequest::ERequestTransactionID)) |
347 { |
350 { |
348 *ret = EMTPRespCodeNoValidObjectInfo; |
351 *ret = EMTPRespCodeNoValidObjectInfo; |
349 } |
352 } |
350 |
353 |
351 __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectParamsL - Exit")); |
354 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CHECKOBJECTPARAMS_EXIT ); |
352 return (*ret == EMTPRespCodeOK) ? ETrue : EFalse; |
355 return (*ret == EMTPRespCodeOK) ? ETrue : EFalse; |
353 } |
356 } |
354 |
357 |
355 /** |
358 /** |
356 SendObjectInfo/SendObject request handler |
359 SendObjectInfo/SendObject request handler |
357 NOTE: SendObjectInfo has to be comes before SendObject requests. To maintain the state information |
360 NOTE: SendObjectInfo has to be comes before SendObject requests. To maintain the state information |
358 between the two requests, the two requests are combined together in one request processor. |
361 between the two requests, the two requests are combined together in one request processor. |
359 */ |
362 */ |
360 void CMTPImageDpSendObjectInfo::ServiceL() |
363 void CMTPImageDpSendObjectInfo::ServiceL() |
361 { |
364 { |
362 __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceL - Entry")); |
365 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_SERVICEL_ENTRY ); |
363 |
366 |
364 FsmAction pService = iStateMachine[iCurrentState][iEvent].iFsmAction; |
367 FsmAction pService = iStateMachine[iCurrentState][iEvent].iFsmAction; |
365 __ASSERT_DEBUG(pService, Panic(EMTPImageDpNoMatchingProcessor)); |
368 __ASSERT_DEBUG(pService, Panic(EMTPImageDpNoMatchingProcessor)); |
366 |
369 |
367 TBool ret = EFalse; |
370 TBool ret = EFalse; |
377 |
380 |
378 if (err != KErrNone) |
381 if (err != KErrNone) |
379 { |
382 { |
380 Rollback(); |
383 Rollback(); |
381 } |
384 } |
382 User::LeaveIfError(err); |
385 LEAVEIFERROR(err, |
383 |
386 OstTrace1( TRACE_ERROR, CMTPIMAGEDPSENDOBJECTINFO_SERVICEL, "Action failed! error code %d", err)); |
384 __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceL - Exit")); |
387 |
|
388 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_SERVICEL_EXIT ); |
385 } |
389 } |
386 |
390 |
387 /** |
391 /** |
388 Override to match both the SendObjectInfo and SendObject requests |
392 Override to match both the SendObjectInfo and SendObject requests |
389 @param aRequest The request to match |
393 @param aRequest The request to match |
390 @param aConnection The connection from which the request comes |
394 @param aConnection The connection from which the request comes |
391 @return ETrue if the processor can handle the request, otherwise EFalse |
395 @return ETrue if the processor can handle the request, otherwise EFalse |
392 */ |
396 */ |
393 TBool CMTPImageDpSendObjectInfo::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const |
397 TBool CMTPImageDpSendObjectInfo::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const |
394 { |
398 { |
395 __FLOG(_L8("CMTPImageDpSendObjectInfo::Match - Entry")); |
399 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_MATCH_ENTRY ); |
396 TBool result = EFalse; |
400 TBool result = EFalse; |
397 TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode); |
401 TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode); |
398 if ((operationCode == EMTPOpCodeSendObjectInfo || |
402 if ((operationCode == EMTPOpCodeSendObjectInfo || |
399 operationCode == EMTPOpCodeSendObject || |
403 operationCode == EMTPOpCodeSendObject || |
400 operationCode == EMTPOpCodeSendObjectPropList) && |
404 operationCode == EMTPOpCodeSendObjectPropList) && |
401 &iConnection == &aConnection) |
405 &iConnection == &aConnection) |
402 { |
406 { |
403 result = ETrue; |
407 result = ETrue; |
404 } |
408 } |
405 __FLOG(_L8("CMTPImageDpSendObjectInfo::Match - Exit")); |
409 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_MATCH_EXIT ); |
406 return result; |
410 return result; |
407 } |
411 } |
408 |
412 |
409 /** |
413 /** |
410 Override to handle the response phase of SendObjectInfo and SendObject requests |
414 Override to handle the response phase of SendObjectInfo and SendObject requests |
411 @return EFalse |
415 @return EFalse |
412 */ |
416 */ |
413 TBool CMTPImageDpSendObjectInfo::DoHandleResponsePhaseL() |
417 TBool CMTPImageDpSendObjectInfo::DoHandleResponsePhaseL() |
414 { |
418 { |
415 __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleResponsePhaseL - Entry")); |
419 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLERESPONSEPHASEL_ENTRY ); |
416 |
420 |
417 //to check if the sending/receiving data is successful |
421 //to check if the sending/receiving data is successful |
418 iSuccessful = !iCancelled; |
422 iSuccessful = !iCancelled; |
419 |
423 |
420 FsmAction pResponse = iStateMachine[iCurrentState][iEvent].iFsmAction; |
424 FsmAction pResponse = iStateMachine[iCurrentState][iEvent].iFsmAction; |
465 { |
470 { |
466 iPreviousTransactionID++; |
471 iPreviousTransactionID++; |
467 } |
472 } |
468 result = EFalse; |
473 result = EFalse; |
469 } |
474 } |
470 |
475 |
471 __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleCompletingPhaseL - Exit")); |
476 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLECOMPLETINGPHASEL_EXIT ); |
472 return result; |
477 return result; |
473 } |
478 } |
474 |
479 |
475 /** |
480 /** |
476 SendObjectInfo request handler |
481 SendObjectInfo request handler |
477 */ |
482 */ |
478 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectInfoL(TAny* /*aPtr*/) |
483 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectInfoL(TAny* /*aPtr*/) |
479 { |
484 { |
480 __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectInfoL - Entry")); |
485 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTINFOL_ENTRY ); |
481 |
486 |
482 delete iObjectInfo; |
487 delete iObjectInfo; |
483 iObjectInfo = NULL; |
488 iObjectInfo = NULL; |
484 iObjectInfo = CMTPTypeObjectInfo::NewL(); |
489 iObjectInfo = CMTPTypeObjectInfo::NewL(); |
485 ReceiveDataL(*iObjectInfo); |
490 ReceiveDataL(*iObjectInfo); |
486 |
491 |
487 __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectInfoL - Exit")); |
492 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTINFOL_EXIT ); |
488 return ETrue; |
493 return ETrue; |
489 } |
494 } |
490 |
495 |
491 /** |
496 /** |
492 SendObjectPropList request handler |
497 SendObjectPropList request handler |
493 */ |
498 */ |
494 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectPropListL(TAny* /*aPtr*/) |
499 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectPropListL(TAny* /*aPtr*/) |
495 { |
500 { |
496 __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectPropListL - Entry")); |
501 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTPROPLISTL_ENTRY ); |
497 |
502 |
498 delete iObjectPropList; |
503 delete iObjectPropList; |
499 iObjectPropList = NULL; |
504 iObjectPropList = NULL; |
500 iObjectPropList = CMTPTypeObjectPropList::NewL(); |
505 iObjectPropList = CMTPTypeObjectPropList::NewL(); |
501 iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32(TMTPTypeRequest::ERequestParameter3)); |
506 iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32(TMTPTypeRequest::ERequestParameter3)); |
502 ReceiveDataL(*iObjectPropList); |
507 ReceiveDataL(*iObjectPropList); |
503 |
508 |
504 __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectPropListL - Exit")); |
509 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTPROPLISTL_EXIT ); |
505 return ETrue; |
510 return ETrue; |
506 } |
511 } |
507 |
512 |
508 /** |
513 /** |
509 SendObject request handler |
514 SendObject request handler |
510 */ |
515 */ |
511 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectL(TAny* /*aPtr*/) |
516 TBool CMTPImageDpSendObjectInfo::ServiceSendObjectL(TAny* /*aPtr*/) |
512 { |
517 { |
513 __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectL - Entry")); |
518 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTL_ENTRY ); |
514 |
519 |
515 iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject); |
520 iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject); |
516 //prepare for rollback |
521 //prepare for rollback |
517 iRollbackList.AppendL(RemoveObjectFromDb); |
522 iRollbackList.AppendL(RemoveObjectFromDb); |
518 |
523 |
519 ReceiveDataL(*iFileReceived); |
524 ReceiveDataL(*iFileReceived); |
520 |
525 |
521 __FLOG(_L8("CMTPImageDpSendObjectInfo::ServiceSendObjectL - Exit")); |
526 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_SERVICESENDOBJECTL_EXIT ); |
522 return ETrue; |
527 return ETrue; |
523 } |
528 } |
524 |
529 |
525 /** |
530 /** |
526 Get a default parent object, if the request does not specify a parent object. |
531 Get a default parent object, if the request does not specify a parent object. |
527 */ |
532 */ |
528 void CMTPImageDpSendObjectInfo::GetDefaultParentObjectL() |
533 void CMTPImageDpSendObjectInfo::GetDefaultParentObjectL() |
529 { |
534 { |
530 __FLOG(_L8("CMTPImageDpSendObjectInfo::GetDefaultParentObjectL - Entry")); |
535 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL_ENTRY ); |
531 |
536 |
532 if (iStorageId == KMTPStorageDefault) |
537 if (iStorageId == KMTPStorageDefault) |
533 { |
538 { |
534 iStorageId = iFramework.StorageMgr().DefaultStorageId(); |
539 iStorageId = iFramework.StorageMgr().DefaultStorageId(); |
535 } |
540 } |
536 TInt drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId))); |
541 TInt drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId))); |
537 User::LeaveIfError(drive); |
542 LEAVEIFERROR(drive, |
|
543 OstTraceExt2( TRACE_ERROR, CMTPIMAGEDPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL, |
|
544 "Can't get drive number for storage %d! error code %d", iStorageId, munged_err )); |
538 |
545 |
539 delete iParentSuid; |
546 delete iParentSuid; |
540 iParentSuid = NULL; |
547 iParentSuid = NULL; |
541 iParentSuid = (iFramework.StorageMgr().StorageL(iStorageId).DesC(CMTPStorageMetaData::EStorageSuid)).AllocL(); |
548 iParentSuid = (iFramework.StorageMgr().StorageL(iStorageId).DesC(CMTPStorageMetaData::EStorageSuid)).AllocL(); |
542 iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent); |
549 iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent); |
543 |
550 |
544 __FLOG(_L8("CMTPImageDpSendObjectInfo::GetDefaultParentObjectL - Exit")); |
551 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL_EXIT ); |
545 } |
552 } |
546 |
553 |
547 /** |
554 /** |
548 Get parent object and storage id |
555 Get parent object and storage id |
549 @return EMTPRespCodeOK if successful, otherwise, EMTPRespCodeInvalidParentObject |
556 @return EMTPRespCodeOK if successful, otherwise, EMTPRespCodeInvalidParentObject |
550 */ |
557 */ |
551 TMTPResponseCode CMTPImageDpSendObjectInfo::GetParentObjectAndStorageIdL() |
558 TMTPResponseCode CMTPImageDpSendObjectInfo::GetParentObjectAndStorageIdL() |
552 { |
559 { |
553 __FLOG(_L8("CMTPImageDpSendObjectInfo::GetParentObjectAndStorageIdL - Entry")); |
560 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL_ENTRY ); |
554 __ASSERT_DEBUG(iRequestChecker, Panic(EMTPImageDpRequestCheckNull)); |
561 __ASSERT_DEBUG(iRequestChecker, Panic(EMTPImageDpRequestCheckNull)); |
555 |
562 |
556 iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
563 iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
557 iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2); |
564 iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2); |
558 //does not take ownership |
565 //does not take ownership |
568 iParentSuid = NULL; |
575 iParentSuid = NULL; |
569 iParentSuid = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL(); |
576 iParentSuid = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL(); |
570 iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle); |
577 iReceivedObject->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle); |
571 } |
578 } |
572 |
579 |
573 __FLOG_VA((_L8("ParentSuid = %S"), iParentSuid)); |
580 OstTraceExt1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL, |
574 __FLOG(_L8("CMTPImageDpSendObjectInfo::GetParentObjectAndStorageIdL - Exit")); |
581 "ParentSuid = %S", *iParentSuid ); |
|
582 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL_EXIT ); |
575 return EMTPRespCodeOK; |
583 return EMTPRespCodeOK; |
576 } |
584 } |
577 |
585 |
578 /** |
586 /** |
579 Handling the completing phase of SendObjectInfo request |
587 Handling the completing phase of SendObjectInfo request |
580 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse |
588 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse |
581 */ |
589 */ |
582 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectInfoCompleteL(TAny* /*aPtr*/) |
590 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectInfoCompleteL(TAny* /*aPtr*/) |
583 { |
591 { |
584 __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectInfoCompleteL - Entry")); |
592 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTINFOCOMPLETEL_ENTRY ); |
585 |
593 |
586 TBool result(ETrue); |
594 TBool result(ETrue); |
587 TUint16 format(iObjectInfo->Uint16L(CMTPTypeObjectInfo::EObjectFormat)); |
595 TUint16 format(iObjectInfo->Uint16L(CMTPTypeObjectInfo::EObjectFormat)); |
588 |
596 |
589 result = IsFormatValid(TMTPFormatCode(format)); |
597 result = IsFormatValid(TMTPFormatCode(format)); |
738 ReturnResponseL(); |
748 ReturnResponseL(); |
739 } |
749 } |
740 } |
750 } |
741 |
751 |
742 iSuccessful = result; |
752 iSuccessful = result; |
743 __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectPropListCompleteL - Exit")); |
753 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTPROPLISTCOMPLETEL_EXIT ); |
744 return result; |
754 return result; |
745 } |
755 } |
746 |
756 |
747 /** |
757 /** |
748 Handling the completing phase of SendObject request |
758 Handling the completing phase of SendObject request |
749 @return ETrue if the object has been successfully saved on the device, otherwise, EFalse |
759 @return ETrue if the object has been successfully saved on the device, otherwise, EFalse |
750 */ |
760 */ |
751 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL(TAny* /*aPtr*/) |
761 TBool CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL(TAny* /*aPtr*/) |
752 { |
762 { |
753 __FLOG(_L8("CMTPImageDpSendObjectInfo::DoHandleSendObjectCompleteL - Entry")); |
763 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL_ENTRY ); |
754 TBool result(ETrue); |
764 TBool result(ETrue); |
755 |
|
756 delete iFileReceived; |
|
757 iFileReceived = NULL; |
|
758 |
765 |
759 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
766 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
760 TInt64 objectsize = 0; |
767 TInt64 objectsize = 0; |
761 #else |
768 #else |
762 TInt objectsize = 0; |
769 TInt objectsize = 0; |
763 #endif |
770 #endif |
764 |
771 |
765 TEntry entry; |
772 iFileReceived->File().Size(objectsize); |
766 User::LeaveIfError(iFramework.Fs().Entry(iFullPath, entry)); |
773 |
767 objectsize = entry.FileSize(); |
|
768 |
|
769 if (objectsize != iObjectSize) |
774 if (objectsize != iObjectSize) |
770 { |
775 { |
771 __FLOG_VA((_L8("object sizes differ %lu != %lu"), objectsize, iObjectSize)); |
776 OstTraceExt2( TRACE_NORMAL, DUP1_CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL, |
|
777 "object sizes differ %Lu != %Lu", objectsize, iObjectSize ); |
772 iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection); |
778 iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection); |
773 Rollback(); |
779 Rollback(); |
774 |
780 |
775 TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge; |
781 TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge; |
776 if (objectsize < iObjectSize) |
782 if (objectsize < iObjectSize) |
782 } |
788 } |
783 |
789 |
784 // SendObject is cancelled or connection is dropped. |
790 // SendObject is cancelled or connection is dropped. |
785 if(result && iCancelled) |
791 if(result && iCancelled) |
786 { |
792 { |
787 __FLOG(_L8("It is a cancel for sendObject.")); |
793 OstTrace0( TRACE_NORMAL, DUP2_CMTPIMAGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL, "It is a cancel for sendObject." ); |
788 iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection); |
794 iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection); |
789 Rollback(); |
795 Rollback(); |
790 SendResponseL(EMTPRespCodeTransactionCancelled); |
796 SendResponseL(EMTPRespCodeTransactionCancelled); |
791 } |
797 } |
792 else if (result && !iCancelled) |
798 else if (result && !iCancelled) |
793 { |
799 { |
|
800 TUint attValue = 0; |
|
801 User::LeaveIfError(iFileReceived->File().Att(attValue)); |
794 if (iProtectionStatus == EMTPProtectionNoProtection || |
802 if (iProtectionStatus == EMTPProtectionNoProtection || |
795 iProtectionStatus == EMTPProtectionReadOnly) |
803 iProtectionStatus == EMTPProtectionReadOnly) |
796 { |
804 { |
797 entry.iAtt &= ~(KEntryAttNormal | KEntryAttReadOnly); |
805 attValue &= ~(KEntryAttNormal | KEntryAttReadOnly); |
|
806 |
798 if (iProtectionStatus == EMTPProtectionNoProtection) |
807 if (iProtectionStatus == EMTPProtectionNoProtection) |
799 { |
808 { |
800 entry.iAtt |= KEntryAttNormal; |
809 attValue |= KEntryAttNormal; |
801 } |
810 } |
802 else |
811 else |
803 { |
812 { |
804 entry.iAtt |= KEntryAttReadOnly; |
813 attValue |= KEntryAttReadOnly; |
805 } |
814 } |
806 User::LeaveIfError(iFramework.Fs().SetAtt(iFullPath, entry.iAtt, ~entry.iAtt)); |
815 User::LeaveIfError(iFileReceived->File().SetAtt(attValue, ~attValue)); |
807 } |
816 } |
808 |
817 if ( iHiddenStatus == EMTPHidden ) |
|
818 { |
|
819 attValue &= ~KEntryAttHidden; |
|
820 attValue |= KEntryAttHidden; |
|
821 User::LeaveIfError(iFileReceived->File().SetAtt(attValue, ~attValue)); |
|
822 } |
809 TTime modifiedTime; |
823 TTime modifiedTime; |
810 //update datemodified property. |
824 //update datemodified property. |
811 if(iDateMod != NULL && iDateMod->Length()) |
825 if(iDateMod != NULL && iDateMod->Length()) |
812 { |
826 { |
813 iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateMod, modifiedTime); |
827 iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateMod, modifiedTime); |
814 } |
828 } |
815 else if(iDateCreated != NULL && iDateCreated->Length()) |
829 else if(iDateCreated != NULL && iDateCreated->Length()) |
816 { |
830 { |
817 iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateCreated, modifiedTime); |
831 iObjectPropertyMgr.ConvertMTPTimeStr2TTimeL(*iDateCreated, modifiedTime); |
818 } |
832 } |
819 User::LeaveIfError(iFramework.Fs().SetModified(iFullPath, modifiedTime)); |
833 User::LeaveIfError(iFileReceived->File().SetModified(modifiedTime)); |
820 |
834 |
821 iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection); |
835 iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection); |
822 |
836 |
823 //The MTP spec states that it is not mandatory for SendObjectInfo/SendObjectPropList |
837 //The MTP spec states that it is not mandatory for SendObjectInfo/SendObjectPropList |
824 //to be followed by a SendObject. An object is reserved in the ObjectStore on |
838 //to be followed by a SendObject. An object is reserved in the ObjectStore on |
917 on return, contains the full path name of the object to be saved |
936 on return, contains the full path name of the object to be saved |
918 @return ETrue if the name is valid, EFalse otherwise |
937 @return ETrue if the name is valid, EFalse otherwise |
919 */ |
938 */ |
920 TBool CMTPImageDpSendObjectInfo::GetFullPathName(const TDesC& aFileName) |
939 TBool CMTPImageDpSendObjectInfo::GetFullPathName(const TDesC& aFileName) |
921 { |
940 { |
922 __FLOG_1(_L8("CMTPImageDpSendObjectInfo::GetFullPathNameL - FileName: %S"), &aFileName); |
941 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_GETFULLPATHNAME_ENTRY ); |
|
942 OstTraceExt1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_GETFULLPATHNAME, "FileName: %S", aFileName ); |
923 TBool result(EFalse); |
943 TBool result(EFalse); |
924 if (aFileName.Length() > 0) |
944 if (aFileName.Length() > 0) |
925 { |
945 { |
926 iFullPath = *iParentSuid; |
946 iFullPath = *iParentSuid; |
927 if (iFullPath.Length() + aFileName.Length() < iFullPath.MaxLength()) |
947 if (iFullPath.Length() + aFileName.Length() < iFullPath.MaxLength()) |
928 { |
948 { |
929 iFullPath.Append(aFileName); |
949 iFullPath.Append(aFileName); |
930 result = iFramework.Fs().IsValidName(iFullPath); |
950 result = iFramework.Fs().IsValidName(iFullPath); |
931 } |
951 } |
932 __FLOG_1(_L16("FullPath: %S"), &iFullPath); |
952 OstTraceExt1( TRACE_NORMAL, DUP1_CMTPIMAGEDPSENDOBJECTINFO_GETFULLPATHNAME, "FullPath: %S", iFullPath ); |
933 } |
953 } |
934 |
954 |
935 __FLOG(_L8("CMTPImageDpSendObjectInfo::GetFullPathNameL - Exit")); |
955 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_GETFULLPATHNAME_EXIT ); |
936 return result; |
956 return result; |
937 } |
957 } |
938 |
958 |
939 /** |
959 /** |
940 Check if the file already exists on the storage. |
960 Check if the file already exists on the storage. |
941 @return ETrue if file is exists, otherwise EFalse |
961 @return ETrue if file is exists, otherwise EFalse |
942 */ |
962 */ |
943 TBool CMTPImageDpSendObjectInfo::Exists(const TDesC& aName) const |
963 TBool CMTPImageDpSendObjectInfo::Exists(const TDesC& aName) const |
944 { |
964 { |
945 __FLOG(_L8("CMTPImageDpSendObjectInfo::Exists - Entry")); |
965 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_EXISTS_ENTRY ); |
946 // This detects both files and folders |
966 // This detects both files and folders |
947 TBool ret(EFalse); |
967 TBool ret(EFalse); |
948 ret = BaflUtils::FileExists(iFramework.Fs(), aName); |
968 ret = BaflUtils::FileExists(iFramework.Fs(), aName); |
949 __FLOG_VA((_L16("Exists: %S (%d)"), &aName, ret)); |
969 OstTraceExt2( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_EXISTS, "Exists: %S (%d)", aName, ret); |
950 __FLOG(_L8("CMTPImageDpSendObjectInfo::IsTooLarge - Exit")); |
970 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_EXISTS_EXIT ); |
951 return ret; |
971 return ret; |
952 } |
972 } |
953 |
973 |
954 /** |
974 /** |
955 Check if the property list is valid and extract properties (file name) |
975 Check if the property list is valid and extract properties (file name) |
956 @param aInvalidParameterIndex if invalid, contains the index of the property. Undefined, if it is valid. |
976 @param aInvalidParameterIndex if invalid, contains the index of the property. Undefined, if it is valid. |
957 @return if error, one of the error response code; otherwise EMTPRespCodeOK |
977 @return if error, one of the error response code; otherwise EMTPRespCodeOK |
958 */ |
978 */ |
959 TMTPResponseCode CMTPImageDpSendObjectInfo::VerifyObjectPropListL(TInt& aInvalidParameterIndex) |
979 TMTPResponseCode CMTPImageDpSendObjectInfo::VerifyObjectPropListL(TInt& aInvalidParameterIndex) |
960 { |
980 { |
961 __FLOG(_L8("CMTPImageDpSendObjectInfo::VerifyObjectPropListL - Entry")); |
981 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_VERIFYOBJECTPROPLISTL_ENTRY ); |
962 |
982 |
963 TMTPResponseCode responseCode(EMTPRespCodeOK); |
983 TMTPResponseCode responseCode(EMTPRespCodeOK); |
964 const TUint KCount(iObjectPropList->NumberOfElements()); |
984 const TUint KCount(iObjectPropList->NumberOfElements()); |
965 iObjectPropList->ResetCursor(); |
985 iObjectPropList->ResetCursor(); |
966 for (TUint i(0); (i < KCount); i++) |
986 for (TUint i(0); (i < KCount); i++) |
1174 break; |
1197 break; |
1175 default: |
1198 default: |
1176 responseCode = EMTPRespCodeInvalidObjectPropCode; |
1199 responseCode = EMTPRespCodeInvalidObjectPropCode; |
1177 break; |
1200 break; |
1178 } |
1201 } |
1179 __FLOG_VA((_L8("Result = 0x%04X"), responseCode)); |
1202 OstTrace1( TRACE_NORMAL, CMTPIMAGEDPSENDOBJECTINFO_CHECKPROPCODEL, "Result = 0x%04X", responseCode ); |
1180 __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckPropCode - Exit")); |
1203 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CHECKPROPCODEL_EXIT ); |
1181 return responseCode; |
1204 return responseCode; |
1182 } |
1205 } |
1183 |
1206 |
1184 /** |
1207 /** |
1185 Reserves space for and assigns an object handle to the received object, then |
1208 Reserves space for and assigns an object handle to the received object, then |
1186 sends a success response. |
1209 sends a success response. |
1187 */ |
1210 */ |
1188 void CMTPImageDpSendObjectInfo::ReserveObjectL() |
1211 void CMTPImageDpSendObjectInfo::ReserveObjectL() |
1189 { |
1212 { |
1190 __FLOG(_L8("CMTPImageDpSendObjectInfo::ReserveObjectL - Entry")); |
1213 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_RESERVEOBJECTL_ENTRY ); |
1191 const TInt objectStatusBitmask = 0x8000;//the most significant bit represents importing flag |
1214 const TInt objectStatusBitmask = 0x8000;//the most significant bit represents importing flag |
1192 |
1215 |
1193 iReceivedObject->SetUint(CMTPObjectMetaData::EFormatSubCode, objectStatusBitmask);//mark object imported due to it sent by PC |
1216 iReceivedObject->SetUint(CMTPObjectMetaData::EFormatSubCode, objectStatusBitmask);//mark object imported due to it sent by PC |
1194 iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId); |
1217 iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId); |
1195 iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize); |
1218 iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize); |
1196 |
1219 |
1197 // prepare for rollback |
1220 // prepare for rollback |
1198 iRollbackList.AppendL(UnreserveObject); |
1221 iRollbackList.AppendL(UnreserveObject); |
1199 __FLOG(_L8("CMTPImageDpSendObjectInfo::ReserveObjectL - Exit")); |
1222 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_RESERVEOBJECTL_EXIT ); |
1200 } |
1223 } |
1201 |
1224 |
1202 /** |
1225 /** |
1203 Sets the read only status on the current file to match the sent object. |
1226 Sets the read only status on the current file to match the sent object. |
1204 */ |
1227 */ |
1205 void CMTPImageDpSendObjectInfo::SetPropertiesL() |
1228 void CMTPImageDpSendObjectInfo::SetPropertiesL() |
1206 { |
1229 { |
1207 __FLOG(_L8("CMTPImageDpSendObjectInfo::SetPropertiesL - Entry")); |
1230 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_SETPROPERTIESL_ENTRY ); |
1208 |
1231 |
1209 iObjectPropertyMgr.SetCurrentObjectL(*iReceivedObject, ETrue, ETrue); |
1232 iObjectPropertyMgr.SetCurrentObjectL(*iReceivedObject, ETrue, ETrue); |
1210 iReceivedObject->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath); |
1233 iReceivedObject->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath); |
1211 if (iName.Length() == 0) |
1234 if (iName.Length() == 0) |
1212 { |
1235 { |
1223 if(iDateCreated != NULL && iDateCreated->Length()) |
1246 if(iDateCreated != NULL && iDateCreated->Length()) |
1224 {//currently image dp can not support this property |
1247 {//currently image dp can not support this property |
1225 iObjectPropertyMgr.SetPropertyL(EMTPObjectPropCodeDateCreated, *iDateCreated); |
1248 iObjectPropertyMgr.SetPropertyL(EMTPObjectPropCodeDateCreated, *iDateCreated); |
1226 } |
1249 } |
1227 |
1250 |
1228 __FLOG(_L8("CMTPImageDpSendObjectInfo::SetPropertiesL - Exit")); |
1251 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_SETPROPERTIESL_EXIT ); |
1229 } |
1252 } |
1230 |
1253 |
1231 void CMTPImageDpSendObjectInfo::Rollback() |
1254 void CMTPImageDpSendObjectInfo::Rollback() |
1232 { |
1255 { |
1233 __FLOG(_L8("CMTPImageDpSendObjectInfo::Rollback - Entry")); |
1256 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_ROLLBACK_ENTRY ); |
1234 |
1257 |
1235 TInt count = iRollbackList.Count(); |
1258 TInt count = iRollbackList.Count(); |
1236 while(--count >= 0) |
1259 while(--count >= 0) |
1237 { |
1260 { |
1238 TRAP_IGNORE((*iRollbackList[count])(this)); |
1261 TRAP_IGNORE((*iRollbackList[count])(this)); |
1239 } |
1262 } |
1240 iRollbackList.Reset(); |
1263 iRollbackList.Reset(); |
1241 |
1264 |
1242 __FLOG(_L8("CMTPImageDpSendObjectInfo::Rollback - Exit")); |
1265 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_ROLLBACK_EXIT ); |
1243 } |
1266 } |
1244 |
1267 |
1245 void CMTPImageDpSendObjectInfo::CleanUndoList() |
1268 void CMTPImageDpSendObjectInfo::CleanUndoList() |
1246 { |
1269 { |
1247 __FLOG(_L8("CMTPImageDpSendObjectInfo::CleanUndoList - Entry")); |
1270 OstTraceFunctionEntry0( CMTPIMAGEDPSENDOBJECTINFO_CLEANUNDOLIST_ENTRY ); |
1248 |
1271 |
1249 iRollbackList.Reset(); |
1272 iRollbackList.Reset(); |
1250 |
1273 |
1251 __FLOG(_L8("CMTPImageDpSendObjectInfo::CleanUndoList - Exit")); |
1274 OstTraceFunctionExit0( CMTPIMAGEDPSENDOBJECTINFO_CLEANUNDOLIST_EXIT ); |
1252 } |
1275 } |
1253 |
1276 |
1254 void CMTPImageDpSendObjectInfo::CreateFsObjectL() |
1277 void CMTPImageDpSendObjectInfo::CreateFsObjectL() |
1255 { |
1278 { |
1256 delete iFileReceived; |
1279 delete iFileReceived; |