33 #include "mtppictbridgedpconst.h" |
33 #include "mtppictbridgedpconst.h" |
34 #include "cmtppictbridgeprinter.h" |
34 #include "cmtppictbridgeprinter.h" |
35 #include "cptpserver.h" |
35 #include "cptpserver.h" |
36 #include "cmtpconnection.h" |
36 #include "cmtpconnection.h" |
37 #include "cmtpconnectionmgr.h" |
37 #include "cmtpconnectionmgr.h" |
|
38 #include "mtpdebug.h" |
|
39 #include "OstTraceDefinitions.h" |
|
40 #ifdef OST_TRACE_COMPILER_IN_USE |
|
41 #include "cmtppictbridgedpsendobjectinfoTraces.h" |
|
42 #endif |
|
43 |
38 |
44 |
39 /** |
45 /** |
40 Verification data for the SendObjectInfo request |
46 Verification data for the SendObjectInfo request |
41 */ |
47 */ |
42 const TMTPRequestElementInfo KMTPSendObjectInfoPolicy[] = |
48 const TMTPRequestElementInfo KMTPSendObjectInfoPolicy[] = |
67 /** |
73 /** |
68 Destructor |
74 Destructor |
69 */ |
75 */ |
70 CMTPPictBridgeDpSendObjectInfo::~CMTPPictBridgeDpSendObjectInfo() |
76 CMTPPictBridgeDpSendObjectInfo::~CMTPPictBridgeDpSendObjectInfo() |
71 { |
77 { |
72 __FLOG_VA((_L8(">> CMTPPictBridgeDpSendObjectInfo::~CMTPPictBridgeDpSendObjectInfo iProgress=%d iNoRollback=%d "), iProgress, iNoRollback)); |
78 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_CMTPPICTBRIDGEDPSENDOBJECTINFO_DES_ENTRY ); |
73 __FLOG_2(_L8("iProgress:%d NoRollback:%d"),iProgress,iNoRollback); |
79 OstTraceExt2( TRACE_NORMAL, CMTPPICTBRIDGEDPSENDOBJECTINFO_CMTPPICTBRIDGEDPSENDOBJECTINFO, |
|
80 "iProgress=%d iNoRollback=%d ", iProgress, iNoRollback ); |
74 |
81 |
75 if ((iProgress == EObjectInfoSucceed || |
82 if ((iProgress == EObjectInfoSucceed || |
76 iProgress == EObjectInfoFail || |
83 iProgress == EObjectInfoFail || |
77 iProgress == EObjectInfoInProgress) && !iNoRollback) |
84 iProgress == EObjectInfoInProgress) && !iNoRollback) |
78 { |
85 { |
188 } |
195 } |
189 } |
196 } |
190 else |
197 else |
191 { |
198 { |
192 ServiceSendObjectL(); |
199 ServiceSendObjectL(); |
193 } |
200 } |
194 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::ServiceL")); |
201 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_SERVICEL_EXIT ); |
195 } |
202 } |
196 |
203 |
197 /** |
204 /** |
198 Second-phase construction |
205 Second-phase construction |
199 */ |
206 */ |
200 void CMTPPictBridgeDpSendObjectInfo::ConstructL() |
207 void CMTPPictBridgeDpSendObjectInfo::ConstructL() |
201 { |
208 { |
202 __FLOG_OPEN(KMTPSubsystem, KComponent); |
209 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_CONSTRUCTL_ENTRY ); |
203 __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::ConstructL")); |
|
204 iExpectedSendObjectRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, EMTPOpCodeSendObject); |
210 iExpectedSendObjectRequest.SetUint16(TMTPTypeRequest::ERequestOperationCode, EMTPOpCodeSendObject); |
205 iReceivedObjectP = CMTPObjectMetaData::NewL(); |
211 iReceivedObjectP = CMTPObjectMetaData::NewL(); |
206 iReceivedObjectP->SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId()); |
212 iReceivedObjectP->SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId()); |
207 iDpSingletons.OpenL(iFramework); |
213 iDpSingletons.OpenL(iFramework); |
208 iNoRollback = EFalse; |
214 iNoRollback = EFalse; |
209 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::ConstructL")); |
215 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_CONSTRUCTL_EXIT ); |
210 } |
216 } |
211 |
217 |
212 /** |
218 /** |
213 Override to match both the SendObjectInfo and SendObject requests |
219 Override to match both the SendObjectInfo and SendObject requests |
214 @param aRequest The request to match |
220 @param aRequest The request to match |
215 @param aConnection The connection from which the request comes |
221 @param aConnection The connection from which the request comes |
216 @return ETrue if the processor can handle the request, otherwise EFalse |
222 @return ETrue if the processor can handle the request, otherwise EFalse |
217 */ |
223 */ |
218 TBool CMTPPictBridgeDpSendObjectInfo::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const |
224 TBool CMTPPictBridgeDpSendObjectInfo::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const |
219 { |
225 { |
220 __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::Match")); |
226 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_MATCH_ENTRY ); |
221 TBool result = EFalse; |
227 TBool result = EFalse; |
222 TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode); |
228 TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode); |
223 if ((operationCode == EMTPOpCodeSendObjectInfo || |
229 if ((operationCode == EMTPOpCodeSendObjectInfo || |
224 operationCode == EMTPOpCodeSendObject || |
230 operationCode == EMTPOpCodeSendObject || |
225 operationCode == EMTPOpCodeSendObjectPropList) && |
231 operationCode == EMTPOpCodeSendObjectPropList) && |
226 &iConnection == &aConnection) |
232 &iConnection == &aConnection) |
227 { |
233 { |
228 result = ETrue; |
234 result = ETrue; |
229 } |
235 } |
230 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::Match")); |
236 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_MATCH_EXIT ); |
231 return result; |
237 return result; |
232 } |
238 } |
233 |
239 |
234 /** |
240 /** |
235 Override to handle the response phase of SendObjectInfo and SendObject requests |
241 Override to handle the response phase of SendObjectInfo and SendObject requests |
236 @return EFalse |
242 @return EFalse |
237 */ |
243 */ |
238 TBool CMTPPictBridgeDpSendObjectInfo::DoHandleResponsePhaseL() |
244 TBool CMTPPictBridgeDpSendObjectInfo::DoHandleResponsePhaseL() |
239 { |
245 { |
240 __FLOG_VA((_L8(">> CMTPPictBridgeDpSendObjectInfo::DoHandleResponsePhaseL iProgress==%d opCode==0x%x"),iProgress, iOperationCode)); |
246 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLERESPONSEPHASEL_ENTRY ); |
|
247 OstTraceExt2( TRACE_NORMAL, CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLERESPONSEPHASEL, |
|
248 "iProgress==%d opCode==0x%x",iProgress, iOperationCode ); |
241 //to check if the sending/receiving data is successful |
249 //to check if the sending/receiving data is successful |
242 TBool successful = !iCancelled; |
250 TBool successful = !iCancelled; |
243 if (iProgress == EObjectInfoInProgress) |
251 if (iProgress == EObjectInfoInProgress) |
244 { |
252 { |
245 if (iOperationCode == EMTPOpCodeSendObjectInfo) |
253 if (iOperationCode == EMTPOpCodeSendObjectInfo) |
254 } |
262 } |
255 else if (iProgress == ESendObjectInProgress) |
263 else if (iProgress == ESendObjectInProgress) |
256 { |
264 { |
257 successful = DoHandleSendObjectCompleteL(); |
265 successful = DoHandleSendObjectCompleteL(); |
258 iProgress = (successful ? ESendObjectSucceed : ESendObjectFail); |
266 iProgress = (successful ? ESendObjectSucceed : ESendObjectFail); |
259 } |
267 } |
260 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::DoHandleResponsePhaseL")); |
268 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLERESPONSEPHASEL_EXIT ); |
261 return EFalse; |
269 return EFalse; |
262 } |
270 } |
263 |
271 |
264 /** |
272 /** |
265 Override to handle the completing phase of SendObjectInfo and SendObject requests |
273 Override to handle the completing phase of SendObjectInfo and SendObject requests |
266 @return ETrue if succesfully received the file, otherwise EFalse |
274 @return ETrue if succesfully received the file, otherwise EFalse |
267 */ |
275 */ |
268 TBool CMTPPictBridgeDpSendObjectInfo::DoHandleCompletingPhaseL() |
276 TBool CMTPPictBridgeDpSendObjectInfo::DoHandleCompletingPhaseL() |
269 { |
277 { |
270 __FLOG_VA((_L8(">> CMTPPictBridgeDpSendObjectInfo::DoHandleCompletingPhaseL iProgress==%d opCode==0x%x"),iProgress, iOperationCode)); |
278 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLECOMPLETINGPHASEL_ENTRY ); |
|
279 OstTraceExt2( TRACE_NORMAL, CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLECOMPLETINGPHASEL, |
|
280 " iProgress==%d opCode==0x%x",iProgress, iOperationCode ); |
|
281 |
271 TBool result = ETrue; |
282 TBool result = ETrue; |
272 CMTPRequestProcessor::DoHandleCompletingPhaseL(); |
283 CMTPRequestProcessor::DoHandleCompletingPhaseL(); |
273 if (iProgress == EObjectInfoSucceed) |
284 if (iProgress == EObjectInfoSucceed) |
274 { |
285 { |
275 if (( iOperationCode == EMTPOpCodeSendObjectInfo ) || ( iOperationCode == EMTPOpCodeSendObjectPropList )) |
286 if (( iOperationCode == EMTPOpCodeSendObjectInfo ) || ( iOperationCode == EMTPOpCodeSendObjectPropList )) |
289 iPreviousTransactionID++; |
300 iPreviousTransactionID++; |
290 } |
301 } |
291 iProgress = EObjectInfoSucceed; |
302 iProgress = EObjectInfoSucceed; |
292 result = EFalse; |
303 result = EFalse; |
293 } |
304 } |
294 |
305 |
295 __FLOG_2(_L8("<< CMTPPictBridgeDpSendObjectInfo::DoHandleCompletingPhaseL result:%d progress %d"),result,iProgress); |
306 OstTraceExt2( TRACE_NORMAL, DUP1_CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLECOMPLETINGPHASEL, |
|
307 " result:%d progress %d",result,iProgress ); |
|
308 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLECOMPLETINGPHASEL_EXIT ); |
|
309 |
296 return result; |
310 return result; |
297 } |
311 } |
298 |
312 |
299 /** |
313 /** |
300 Verify if the SendObject request comes after SendObjectInfo request |
314 Verify if the SendObject request comes after SendObjectInfo request |
301 @return EMTPRespCodeOK if SendObject request comes after a valid SendObjectInfo request, otherwise |
315 @return EMTPRespCodeOK if SendObject request comes after a valid SendObjectInfo request, otherwise |
302 EMTPRespCodeNoValidObjectInfo |
316 EMTPRespCodeNoValidObjectInfo |
303 */ |
317 */ |
304 TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::CheckSendingStateL() |
318 TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::CheckSendingStateL() |
305 { |
319 { |
306 __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::CheckSendingStateL")); |
320 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_CHECKSENDINGSTATEL_ENTRY ); |
307 TMTPResponseCode result = EMTPRespCodeOK; |
321 TMTPResponseCode result = EMTPRespCodeOK; |
308 iOperationCode = Request().Uint16(TMTPTypeRequest::ERequestOperationCode); |
322 iOperationCode = Request().Uint16(TMTPTypeRequest::ERequestOperationCode); |
309 |
323 |
310 if (iOperationCode == EMTPOpCodeSendObject) |
324 if (iOperationCode == EMTPOpCodeSendObject) |
311 { |
325 { |
385 /** |
402 /** |
386 Get a default parent object, if the request does not specify a parent object. |
403 Get a default parent object, if the request does not specify a parent object. |
387 */ |
404 */ |
388 void CMTPPictBridgeDpSendObjectInfo::GetDefaultParentObjectL() |
405 void CMTPPictBridgeDpSendObjectInfo::GetDefaultParentObjectL() |
389 { |
406 { |
390 __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::GetDefaultParentObjectL")); |
407 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL_ENTRY ); |
391 |
408 |
392 if (iStorageId == KMTPStorageDefault) |
409 if (iStorageId == KMTPStorageDefault) |
393 { |
410 { |
394 iStorageId = iFramework.StorageMgr().DefaultStorageId(); |
411 iStorageId = iFramework.StorageMgr().DefaultStorageId(); |
395 } |
412 } |
396 TInt drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId))); |
413 TInt drive(static_cast<TDriveNumber>(iFramework.StorageMgr().DriveNumber(iStorageId))); |
397 User::LeaveIfError(drive); |
414 LEAVEIFERROR(drive, |
|
415 OstTrace1( TRACE_ERROR, CMTPPICTBRIDGEDPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL, |
|
416 "Can't identify drive number for storage %d", iStorageId )); |
398 |
417 |
399 // Obtain the root of the drive. Logical storages can sometimes have a filesystem root |
418 // Obtain the root of the drive. Logical storages can sometimes have a filesystem root |
400 // other than <drive>:\ . For example an MP3 DP might have a root of c:\media\music\ |
419 // other than <drive>:\ . For example an MP3 DP might have a root of c:\media\music\ |
401 |
420 |
402 delete iParentSuidP; |
421 delete iParentSuidP; |
403 iParentSuidP = NULL; |
422 iParentSuidP = NULL; |
404 iParentSuidP=(iFramework.StorageMgr().StorageL(iStorageId).DesC(CMTPStorageMetaData::EStorageSuid)).AllocL(); |
423 iParentSuidP=(iFramework.StorageMgr().StorageL(iStorageId).DesC(CMTPStorageMetaData::EStorageSuid)).AllocL(); |
405 iReceivedObjectP->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent); |
424 iReceivedObjectP->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent); |
406 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::GetDefaultParentObjectL")); |
425 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_GETDEFAULTPARENTOBJECTL_EXIT ); |
407 } |
426 } |
408 |
427 |
409 /** |
428 /** |
410 Get parent object and storage id |
429 Get parent object and storage id |
411 @return EMTPRespCodeOK if successful, otherwise, EMTPRespCodeInvalidParentObject |
430 @return EMTPRespCodeOK if successful, otherwise, EMTPRespCodeInvalidParentObject |
412 */ |
431 */ |
413 TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::GetParentObjectAndStorageIdL() |
432 TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::GetParentObjectAndStorageIdL() |
414 { |
433 { |
415 __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::GetParentObjectAndStorageIdL")); |
434 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL_ENTRY ); |
416 __ASSERT_DEBUG(iRequestChecker, Panic(EMTPPictBridgeDpRequestCheckNull)); |
435 __ASSERT_DEBUG(iRequestChecker, Panic(EMTPPictBridgeDpRequestCheckNull)); |
417 |
436 |
418 iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
437 iStorageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
419 iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2); |
438 iParentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter2); |
420 //does not take ownership |
439 //does not take ownership |
430 iParentSuidP = NULL; |
449 iParentSuidP = NULL; |
431 iParentSuidP = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL(); |
450 iParentSuidP = parentObjectInfo->DesC(CMTPObjectMetaData::ESuid).AllocL(); |
432 iReceivedObjectP->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle); |
451 iReceivedObjectP->SetUint(CMTPObjectMetaData::EParentHandle, iParentHandle); |
433 } |
452 } |
434 |
453 |
435 __FLOG_VA((_L16("<< CMTPPictBridgeDpSendObjectInfo::GetParentObjectAndStorageIdL %S"), iParentSuidP)); |
454 OstTraceExt1( TRACE_NORMAL, CMTPPICTBRIDGEDPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL, |
|
455 "iParentSuidP: %S", *iParentSuidP ); |
|
456 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_GETPARENTOBJECTANDSTORAGEIDL_EXIT ); |
436 return EMTPRespCodeOK; |
457 return EMTPRespCodeOK; |
437 } |
458 } |
438 |
459 |
439 /** |
460 /** |
440 Handling the completing phase of SendObjectInfo request |
461 Handling the completing phase of SendObjectInfo request |
441 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse |
462 @return ETrue if the specified object can be saved on the specified location, otherwise, EFalse |
442 */ |
463 */ |
443 TBool CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectInfoCompleteL() |
464 TBool CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectInfoCompleteL() |
444 { |
465 { |
445 __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectInfoCompleteL")); |
466 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTINFOCOMPLETEL_ENTRY ); |
446 TBool result(ETrue); |
467 TBool result(ETrue); |
447 TUint16 format(iObjectInfoP->Uint16L(CMTPTypeObjectInfo::EObjectFormat)); |
468 TUint16 format(iObjectInfoP->Uint16L(CMTPTypeObjectInfo::EObjectFormat)); |
448 |
469 |
449 result = IsFormatValid(TMTPFormatCode(format)); |
470 result = IsFormatValid(TMTPFormatCode(format)); |
450 |
471 |
518 iPictBridgeDP.PtpServer()->Printer()->DpsDiscovery(iFullPath, &iConnection); |
539 iPictBridgeDP.PtpServer()->Printer()->DpsDiscovery(iFullPath, &iConnection); |
519 TRAPD(err, CreateFsObjectL()); |
540 TRAPD(err, CreateFsObjectL()); |
520 |
541 |
521 if (err != KErrNone) |
542 if (err != KErrNone) |
522 { |
543 { |
523 __FLOG_1(_L8("Fail to create fs object %d"),err); |
544 OstTrace1( TRACE_WARNING, CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTINFOCOMPLETEL, |
|
545 "Fail to create fs object %d", err ); |
524 SendResponseL(ErrorToMTPError(err)); |
546 SendResponseL(ErrorToMTPError(err)); |
525 result = EFalse; |
547 result = EFalse; |
526 } |
548 } |
527 else |
549 else |
528 { |
550 { |
529 ReserveObjectL(); |
551 ReserveObjectL(); |
530 } |
552 } |
531 } |
553 } |
532 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectInfoCompleteL")); |
554 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTINFOCOMPLETEL_EXIT ); |
533 return result; |
555 return result; |
534 } |
556 } |
535 |
557 |
536 |
558 |
537 TBool CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectPropListCompleteL() |
559 TBool CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectPropListCompleteL() |
538 { |
560 { |
539 __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectPropListCompleteL")); |
561 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTPROPLISTCOMPLETEL_ENTRY ); |
540 TBool result(ETrue); |
562 TBool result(ETrue); |
541 TMTPResponseCode responseCode( GetParentObjectAndStorageIdL() ); |
563 TMTPResponseCode responseCode( GetParentObjectAndStorageIdL() ); |
542 if ( responseCode != EMTPRespCodeOK ) |
564 if ( responseCode != EMTPRespCodeOK ) |
543 { |
565 { |
544 SendResponseL( responseCode ); |
566 SendResponseL( responseCode ); |
566 iReceivedObjectP->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32( TMTPTypeRequest::ERequestParameter3 )); |
588 iReceivedObjectP->SetUint(CMTPObjectMetaData::EFormatCode, iRequest->Uint32( TMTPTypeRequest::ERequestParameter3 )); |
567 iPictBridgeDP.PtpServer()->Printer()->DpsDiscovery(iFullPath, &iConnection); |
589 iPictBridgeDP.PtpServer()->Printer()->DpsDiscovery(iFullPath, &iConnection); |
568 TRAPD(err, CreateFsObjectL()); |
590 TRAPD(err, CreateFsObjectL()); |
569 if ( err != KErrNone ) |
591 if ( err != KErrNone ) |
570 { |
592 { |
571 __FLOG_1(_L8("Fail to create fs object %d"),err); |
593 OstTrace1( TRACE_WARNING, CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTPROPLISTCOMPLETEL, |
|
594 "Fail to create fs object %d", err ); |
572 SendResponseL(ErrorToMTPError(err)); |
595 SendResponseL(ErrorToMTPError(err)); |
573 result = EFalse; |
596 result = EFalse; |
574 } |
597 } |
575 else |
598 else |
576 { |
599 { |
577 ReserveObjectL(); |
600 ReserveObjectL(); |
578 } |
601 } |
579 } |
602 } |
580 |
603 |
581 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectPropListCompleteL")); |
604 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTPROPLISTCOMPLETEL_EXIT ); |
582 return result; |
605 return result; |
583 } |
606 } |
584 |
607 |
585 /** |
608 /** |
586 */ |
609 */ |
587 TBool CMTPPictBridgeDpSendObjectInfo::IsFormatValid(TMTPFormatCode aFormat) const |
610 TBool CMTPPictBridgeDpSendObjectInfo::IsFormatValid(TMTPFormatCode aFormat) const |
588 { |
611 { |
589 __FLOG_VA((_L8(">> CMTPPictGetObjectPropDesc::IsFormatValid %d"),aFormat)); |
612 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_ISFORMATVALID_ENTRY ); |
|
613 OstTrace1( TRACE_NORMAL, CMTPPICTBRIDGEDPSENDOBJECTINFO_ISFORMATVALID, "aFormat : %d", aFormat ); |
590 TInt count(sizeof(KMTPValidCodeExtensionMappings) / sizeof(KMTPValidCodeExtensionMappings[0])); |
614 TInt count(sizeof(KMTPValidCodeExtensionMappings) / sizeof(KMTPValidCodeExtensionMappings[0])); |
591 for(TInt i = 0; i < count; i++) |
615 for(TInt i = 0; i < count; i++) |
592 { |
616 { |
593 if (KMTPValidCodeExtensionMappings[i].iFormatCode == aFormat) |
617 if (KMTPValidCodeExtensionMappings[i].iFormatCode == aFormat) |
594 { |
618 { |
595 __FLOG(_L8("<< CMTPPictGetObjectPropDesc::IsFormatValid ETrue")); |
619 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_ISFORMATVALID_EXIT ); |
596 return ETrue; |
620 return ETrue; |
597 } |
621 } |
598 } |
622 } |
599 __FLOG(_L8("<< CMTPPictGetObjectPropDesc::IsFormatValid EFalse")); |
623 OstTraceFunctionExit0( DUP1_CMTPPICTBRIDGEDPSENDOBJECTINFO_ISFORMATVALID_EXIT ); |
600 return EFalse; |
624 return EFalse; |
601 } |
625 } |
602 |
626 |
603 /** |
627 /** |
604 Handling the completing phase of SendObject request |
628 Handling the completing phase of SendObject request |
605 @return ETrue if the object has been successfully saved on the device, otherwise, EFalse |
629 @return ETrue if the object has been successfully saved on the device, otherwise, EFalse |
606 */ |
630 */ |
607 TBool CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectCompleteL() |
631 TBool CMTPPictBridgeDpSendObjectInfo::DoHandleSendObjectCompleteL() |
608 { |
632 { |
609 __FLOG_VA((_L8(">> CMTPPictGetObjectPropDesc::DoHandleSendObjectCompleteL size=%d cancelled=%d"), iObjectSize, iCancelled)); |
633 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL_ENTRY ); |
|
634 OstTraceExt2( TRACE_NORMAL, CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL, |
|
635 " size=%d cancelled=%d", iObjectSize, iCancelled ); |
610 TBool result(ETrue); |
636 TBool result(ETrue); |
611 |
637 |
612 delete iFileReceivedP; |
638 delete iFileReceivedP; |
613 iFileReceivedP = NULL; |
639 iFileReceivedP = NULL; |
614 |
640 |
615 TEntry fileEntry; |
641 TEntry fileEntry; |
616 User::LeaveIfError(iFramework.Fs().Entry(iFullPath, fileEntry)); |
642 LEAVEIFERROR(iFramework.Fs().Entry(iFullPath, fileEntry), |
|
643 OstTraceExt2( TRACE_ERROR, DUP2_CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL, |
|
644 "Can't get entry details for %S! error code %d", iFullPath, munged_err )); |
617 |
645 |
618 if (fileEntry.FileSize() != iObjectSize) |
646 if (fileEntry.FileSize() != iObjectSize) |
619 { |
647 { |
620 __FLOG_VA((_L8(" sizes differ %d!=%d"),fileEntry.FileSize(), iObjectSize)); |
648 OstTraceExt2( TRACE_NORMAL, DUP1_CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL, |
|
649 " sizes differ %d!=%d", (TUint32)fileEntry.FileSize(), (TUint32)iObjectSize); |
621 iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection); |
650 iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection); |
622 |
651 |
623 iFramework.Fs().Delete(iFullPath); |
652 iFramework.Fs().Delete(iFullPath); |
624 iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObjectP); |
653 iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObjectP); |
625 TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge; |
654 TMTPResponseCode responseCode = EMTPRespCodeObjectTooLarge; |
657 //on receiving the corresponding SendObject request. With Associations however |
686 //on receiving the corresponding SendObject request. With Associations however |
658 //we commit the object straight away as the SendObject phase is often absent |
687 //we commit the object straight away as the SendObject phase is often absent |
659 //with folder creation. |
688 //with folder creation. |
660 |
689 |
661 |
690 |
662 TRAPD(err, iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObjectP)); |
691 TRAPD(err, iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObjectP)); |
663 __FLOG_VA((_L8(" Entry error %d"),err)); |
692 OstTrace1( TRACE_NORMAL, DUP3_CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL, " Entry error %d", err); |
664 if( KErrAlreadyExists == err ) |
693 if( KErrAlreadyExists == err ) |
665 { |
694 { |
666 iReceivedObjectP->SetUint(CMTPObjectMetaData::EHandle, iFramework.ObjectMgr().HandleL(iFullPath)); |
695 iReceivedObjectP->SetUint(CMTPObjectMetaData::EHandle, iFramework.ObjectMgr().HandleL(iFullPath)); |
667 } |
696 } |
668 else |
697 else |
669 { |
698 { |
670 User::LeaveIfError(err); |
699 User::LeaveIfError(err); |
671 } |
700 } |
672 SendResponseL(EMTPRespCodeOK); |
701 SendResponseL(EMTPRespCodeOK); |
673 } |
702 } |
674 __FLOG(_L8("<< CMTPPictGetObjectPropDesc::DoHandleSendObjectCompleteL")); |
703 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_DOHANDLESENDOBJECTCOMPLETEL_EXIT ); |
675 return result; |
704 return result; |
676 } |
705 } |
677 |
706 |
678 /** |
707 /** |
679 Get the full path name of the object to be saved |
708 Get the full path name of the object to be saved |
681 on return, contains the full path name of the object to be saved |
710 on return, contains the full path name of the object to be saved |
682 @return ETrue if the name is valid, EFalse otherwise |
711 @return ETrue if the name is valid, EFalse otherwise |
683 */ |
712 */ |
684 TBool CMTPPictBridgeDpSendObjectInfo::GetFullPathNameL(const TDesC& aFileName) |
713 TBool CMTPPictBridgeDpSendObjectInfo::GetFullPathNameL(const TDesC& aFileName) |
685 { |
714 { |
686 __FLOG_VA((_L16(">> CMTPPictBridgeDpSendObjectInfo::GetFullPathNameL file %S"), &aFileName)); |
715 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_GETFULLPATHNAMEL_ENTRY ); |
|
716 OstTraceExt1( TRACE_NORMAL, CMTPPICTBRIDGEDPSENDOBJECTINFO_GETFULLPATHNAMEL, "file %S", aFileName ); |
|
717 |
687 TBool result(EFalse); |
718 TBool result(EFalse); |
688 if (aFileName.Length() > 0) |
719 if (aFileName.Length() > 0) |
689 { |
720 { |
690 iFullPath = *iParentSuidP; |
721 iFullPath = *iParentSuidP; |
691 if (iFullPath.Length() + aFileName.Length() < iFullPath.MaxLength()) |
722 if (iFullPath.Length() + aFileName.Length() < iFullPath.MaxLength()) |
873 { |
905 { |
874 responseCode = EMTPRespCodeInvalidObjectPropCode; |
906 responseCode = EMTPRespCodeInvalidObjectPropCode; |
875 } |
907 } |
876 break; |
908 break; |
877 } |
909 } |
878 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::CheckPropCodeL")); |
910 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_CHECKPROPCODEL_EXIT ); |
879 return responseCode; |
911 return responseCode; |
880 } |
912 } |
881 |
913 |
882 TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::MatchStoreAndParentL() const |
914 TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::MatchStoreAndParentL() const |
883 { |
915 { |
884 __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::MatchStoreAndParentL")); |
916 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_MATCHSTOREANDPARENTL_ENTRY ); |
885 TMTPResponseCode ret = EMTPRespCodeOK; |
917 TMTPResponseCode ret = EMTPRespCodeOK; |
886 const TUint32 storeId(Request().Uint32(TMTPTypeRequest::ERequestParameter1)); |
918 const TUint32 storeId(Request().Uint32(TMTPTypeRequest::ERequestParameter1)); |
887 const TUint32 parentHandle(Request().Uint32(TMTPTypeRequest::ERequestParameter2)); |
919 const TUint32 parentHandle(Request().Uint32(TMTPTypeRequest::ERequestParameter2)); |
888 if (parentHandle != KMTPHandleAll && parentHandle != KMTPHandleNone) |
920 if (parentHandle != KMTPHandleAll && parentHandle != KMTPHandleNone) |
889 { |
921 { |
893 if (parentObjInfo->Uint(CMTPObjectMetaData::EStorageId) != storeId) |
925 if (parentObjInfo->Uint(CMTPObjectMetaData::EStorageId) != storeId) |
894 { |
926 { |
895 ret = EMTPRespCodeInvalidObjectHandle; |
927 ret = EMTPRespCodeInvalidObjectHandle; |
896 } |
928 } |
897 } |
929 } |
898 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::MatchStoreAndParentL")); |
930 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_MATCHSTOREANDPARENTL_EXIT ); |
899 return ret; |
931 return ret; |
900 } |
932 } |
901 |
933 |
902 /** |
934 /** |
903 Reserves space for and assigns an object handle to the received object, then |
935 Reserves space for and assigns an object handle to the received object, then |
904 sends a success response. |
936 sends a success response. |
905 */ |
937 */ |
906 void CMTPPictBridgeDpSendObjectInfo::ReserveObjectL() |
938 void CMTPPictBridgeDpSendObjectInfo::ReserveObjectL() |
907 { |
939 { |
908 __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::ReserveObjectL")); |
940 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_RESERVEOBJECTL_ENTRY ); |
909 iReceivedObjectP->SetUint(CMTPObjectMetaData::EStorageId, iStorageId); |
941 iReceivedObjectP->SetUint(CMTPObjectMetaData::EStorageId, iStorageId); |
910 iReceivedObjectP->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath); |
942 iReceivedObjectP->SetDesCL(CMTPObjectMetaData::ESuid, iFullPath); |
911 |
943 |
912 iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObjectP, iObjectSize); |
944 iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObjectP, iObjectSize); |
913 |
945 |
916 TUint32 parameters[3]; |
948 TUint32 parameters[3]; |
917 parameters[0] = iStorageId; |
949 parameters[0] = iStorageId; |
918 parameters[1] = iParentHandle; |
950 parameters[1] = iParentHandle; |
919 parameters[2] = iReceivedObjectP->Uint(CMTPObjectMetaData::EHandle); |
951 parameters[2] = iReceivedObjectP->Uint(CMTPObjectMetaData::EHandle); |
920 SendResponseL(EMTPRespCodeOK, (sizeof(parameters) / sizeof(parameters[0])), parameters); |
952 SendResponseL(EMTPRespCodeOK, (sizeof(parameters) / sizeof(parameters[0])), parameters); |
921 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::ReserveObjectL")); |
953 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_RESERVEOBJECTL_EXIT ); |
922 } |
954 } |
923 |
955 |
924 void CMTPPictBridgeDpSendObjectInfo::CreateFsObjectL() |
956 void CMTPPictBridgeDpSendObjectInfo::CreateFsObjectL() |
925 { |
957 { |
926 __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::CreateFsObjectL")); |
958 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_CREATEFSOBJECTL_ENTRY ); |
927 delete iFileReceivedP; |
959 delete iFileReceivedP; |
928 iFileReceivedP = NULL; |
960 iFileReceivedP = NULL; |
929 iFileReceivedP = CMTPTypeFile::NewL(iFramework.Fs(), iFullPath, EFileWrite); |
961 iFileReceivedP = CMTPTypeFile::NewL(iFramework.Fs(), iFullPath, EFileWrite); |
930 iFileReceivedP->SetSizeL(iObjectSize); |
962 iFileReceivedP->SetSizeL(iObjectSize); |
931 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::CreateFsObjectL")); |
963 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_CREATEFSOBJECTL_EXIT ); |
932 } |
964 } |
933 |
965 |
934 void CMTPPictBridgeDpSendObjectInfo::Rollback() |
966 void CMTPPictBridgeDpSendObjectInfo::Rollback() |
935 { |
967 { |
936 __FLOG(_L8(">> CMTPPictBridgeDpSendObjectInfo::Rollback")); |
968 OstTraceFunctionEntry0( CMTPPICTBRIDGEDPSENDOBJECTINFO_ROLLBACK_ENTRY ); |
937 // Delete this object from file system. |
969 // Delete this object from file system. |
938 delete iFileReceivedP; |
970 delete iFileReceivedP; |
939 iFileReceivedP=NULL; |
971 iFileReceivedP=NULL; |
940 TInt err=iFramework.Fs().Delete(iFullPath); |
972 TInt err=iFramework.Fs().Delete(iFullPath); |
941 __FLOG_VA((_L16(">> CMTPPictBridgeDpSendObjectInfo::Rollback deleted %S with return code %d"), &iFullPath, err)); |
973 OstTraceExt2( TRACE_NORMAL, CMTPPICTBRIDGEDPSENDOBJECTINFO_ROLLBACK, |
|
974 "deleted %S with return code %d", iFullPath, err ); |
942 TRAP_IGNORE(iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObjectP)); |
975 TRAP_IGNORE(iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObjectP)); |
943 __FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::Rollback")); |
976 OstTraceFunctionExit0( CMTPPICTBRIDGEDPSENDOBJECTINFO_ROLLBACK_EXIT ); |
944 } |
977 } |
945 |
978 |
946 TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::ErrorToMTPError(TInt aError) const |
979 TMTPResponseCode CMTPPictBridgeDpSendObjectInfo::ErrorToMTPError(TInt aError) const |
947 { |
980 { |
948 TMTPResponseCode resp = EMTPRespCodeGeneralError; |
981 TMTPResponseCode resp = EMTPRespCodeGeneralError; |