equal
deleted
inserted
replaced
71 Destructor |
71 Destructor |
72 */ |
72 */ |
73 EXPORT_C CMTPSendObjectInfo::~CMTPSendObjectInfo() |
73 EXPORT_C CMTPSendObjectInfo::~CMTPSendObjectInfo() |
74 { |
74 { |
75 __FLOG(_L8("~CMTPSendObjectInfo - Entry")); |
75 __FLOG(_L8("~CMTPSendObjectInfo - Entry")); |
76 |
76 __FLOG_2(_L8("iProgress:%d NoRollback:%d"),iProgress,iNoRollback); |
77 if ((iProgress == EObjectInfoSucceed || |
77 if ((iProgress == EObjectInfoSucceed || |
78 iProgress == EObjectInfoFail || |
78 iProgress == EObjectInfoFail || |
79 iProgress == EObjectInfoInProgress) && !iNoRollback) |
79 iProgress == EObjectInfoInProgress) && !iNoRollback) |
80 { |
80 { |
81 // Not finished SendObjectInfo/PropList SendObject pair detected. |
81 // Not finished SendObjectInfo/PropList SendObject pair detected. |
156 if (IsTooLarge(iObjectSize)) |
156 if (IsTooLarge(iObjectSize)) |
157 { |
157 { |
158 result = EMTPRespCodeObjectTooLarge; |
158 result = EMTPRespCodeObjectTooLarge; |
159 } |
159 } |
160 |
160 |
161 //File size is limited to KMaxTInt64 that is 8ExaBytes |
|
162 //if the object size is more,then report this error. |
|
163 if (!CanStoreFileL(iStorageId, iObjectSize)||(iObjectSize > (KMaxTInt64))) |
|
164 { |
|
165 result = EMTPRespCodeStoreFull; |
|
166 } |
|
167 } |
161 } |
168 } |
162 } |
169 |
163 |
170 // If the previous request is not SendObjectInfo or SendObjectPropList, SendObject fails |
164 // If the previous request is not SendObjectInfo or SendObjectPropList, SendObject fails |
171 if (result == EMTPRespCodeOK && iOperationCode == EMTPOpCodeSendObject) |
165 if (result == EMTPRespCodeOK && iOperationCode == EMTPOpCodeSendObject) |
311 } |
305 } |
312 iProgress = EObjectInfoSucceed; |
306 iProgress = EObjectInfoSucceed; |
313 result = EFalse; |
307 result = EFalse; |
314 } |
308 } |
315 |
309 |
316 __FLOG(_L8("DoHandleCompletingPhaseL - Exit")); |
310 __FLOG_2(_L8("DoHandleCompletingPhaseL - Exit result:%d progress:%d"),result,iProgress); |
317 return result; |
311 return result; |
318 } |
312 } |
319 |
313 |
320 |
314 |
321 /** |
315 /** |
527 if (IsTooLarge(iObjectSize)) |
521 if (IsTooLarge(iObjectSize)) |
528 { |
522 { |
529 SendResponseL(EMTPRespCodeObjectTooLarge); |
523 SendResponseL(EMTPRespCodeObjectTooLarge); |
530 result = EFalse; |
524 result = EFalse; |
531 } |
525 } |
532 if(result && !CanStoreFileL(iStorageId, iObjectSize)) |
|
533 { |
|
534 SendResponseL(EMTPRespCodeStoreFull); |
|
535 result = EFalse; |
|
536 } |
|
537 } |
526 } |
538 |
527 |
539 if (result) |
528 if (result) |
540 { |
529 { |
541 iProtectionStatus = iObjectInfo->Uint16L(CMTPTypeObjectInfo::EProtectionStatus); |
530 iProtectionStatus = iObjectInfo->Uint16L(CMTPTypeObjectInfo::EProtectionStatus); |
569 |
558 |
570 TRAPD(err, CreateFsObjectL()); |
559 TRAPD(err, CreateFsObjectL()); |
571 |
560 |
572 if (err != KErrNone) |
561 if (err != KErrNone) |
573 { |
562 { |
|
563 __FLOG_1(_L8("Fail to create fs object %d"),err); |
574 SendResponseL(ErrorToMTPError(err)); |
564 SendResponseL(ErrorToMTPError(err)); |
|
565 result = EFalse; |
575 } |
566 } |
576 else |
567 else |
577 { |
568 { |
578 ReserveObjectL(); |
569 ReserveObjectL(); |
579 } |
570 } |
638 |
629 |
639 TRAPD(err, CreateFsObjectL()); |
630 TRAPD(err, CreateFsObjectL()); |
640 |
631 |
641 if (err != KErrNone) |
632 if (err != KErrNone) |
642 { |
633 { |
|
634 __FLOG_1(_L8("Fail to create fs object %d"),err); |
643 SendResponseL(ErrorToMTPError(err)); |
635 SendResponseL(ErrorToMTPError(err)); |
|
636 result = EFalse; |
644 } |
637 } |
645 else |
638 else |
646 { |
639 { |
647 ReserveObjectL(); |
640 ReserveObjectL(); |
648 } |
641 } |
796 #endif |
789 #endif |
797 return result; |
790 return result; |
798 } |
791 } |
799 |
792 |
800 /** |
793 /** |
801 Check if we can store the file on the storage |
|
802 @return ETrue if yes, otherwise EFalse |
|
803 */ |
|
804 TBool CMTPSendObjectInfo::CanStoreFileL(TUint32 aStorageId, TInt64 aObjectSize) const |
|
805 { |
|
806 __FLOG(_L8("CanStoreFileL - Entry")); |
|
807 TBool result(ETrue); |
|
808 if (aStorageId == KMTPStorageDefault) |
|
809 { |
|
810 aStorageId = iFramework.StorageMgr().DefaultStorageId(); |
|
811 } |
|
812 TInt drive( iFramework.StorageMgr().DriveNumber(aStorageId) ); |
|
813 User::LeaveIfError(drive); |
|
814 TVolumeInfo volumeInfo; |
|
815 User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive)); |
|
816 if (volumeInfo.iFree < aObjectSize) |
|
817 { |
|
818 result = EFalse; |
|
819 } |
|
820 __FLOG_VA((_L8("Result = %d"), result)); |
|
821 __FLOG(_L8("CanStoreFileL - Exit")); |
|
822 return result; |
|
823 } |
|
824 |
|
825 /** |
|
826 Check if the object is too large |
794 Check if the object is too large |
827 @return ETrue if yes, otherwise EFalse |
795 @return ETrue if yes, otherwise EFalse |
828 */ |
796 */ |
829 TBool CMTPSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const |
797 TBool CMTPSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const |
830 { |
798 { |
1155 |
1123 |
1156 void CMTPSendObjectInfo::Rollback() |
1124 void CMTPSendObjectInfo::Rollback() |
1157 { |
1125 { |
1158 if(iIsFolder) |
1126 if(iIsFolder) |
1159 { |
1127 { |
1160 __FLOG(_L8("It is a folder cancel process.")); |
1128 __FLOG(_L8("Rollback the dir created.")); |
1161 iFramework.Fs().RmDir(iFullPath); |
1129 iFramework.Fs().RmDir(iFullPath); |
1162 // If it is folder, delete it from MTP database, i.e ObjectStore. |
1130 // If it is folder, delete it from MTP database, i.e ObjectStore. |
1163 TRAP_IGNORE(iFramework.ObjectMgr().RemoveObjectL(iFullPath)); |
1131 TRAP_IGNORE(iFramework.ObjectMgr().RemoveObjectL(iFullPath)); |
1164 } |
1132 } |
1165 else |
1133 else |
1166 { |
1134 { |
1167 __FLOG(_L8("It is a file cancel process.")); |
1135 __FLOG(_L8("Rollback the file created.")); |
|
1136 delete iFileReceived; |
|
1137 iFileReceived = NULL; |
1168 // Delete this object from file system. |
1138 // Delete this object from file system. |
1169 iFramework.Fs().Delete(iFullPath); |
1139 iFramework.Fs().Delete(iFullPath); |
1170 TRAP_IGNORE(iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject)); |
1140 TRAP_IGNORE(iFramework.ObjectMgr().UnreserveObjectHandleL(*iReceivedObject)); |
1171 } |
1141 } |
1172 } |
1142 } |
1185 resp = EMTPRespCodeAccessDenied; |
1155 resp = EMTPRespCodeAccessDenied; |
1186 break; |
1156 break; |
1187 |
1157 |
1188 case KErrDiskFull: |
1158 case KErrDiskFull: |
1189 resp = EMTPRespCodeStoreFull; |
1159 resp = EMTPRespCodeStoreFull; |
|
1160 break; |
|
1161 |
|
1162 default: |
1190 break; |
1163 break; |
1191 } |
1164 } |
1192 |
1165 |
1193 return resp; |
1166 return resp; |
1194 } |
1167 } |