# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1272378623 -10800 # Node ID ef55b168cedb6e6df8d3dc6ab90320cc0decf18e # Parent 3673b591050c7ea85b7dca0f5ef8a2693e1cf321 Revision: 201004 Kit: 201017 diff -r 3673b591050c -r ef55b168cedb backupandrestore/backupengine/src/sbedataownermanager.cpp --- a/backupandrestore/backupengine/src/sbedataownermanager.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/backupandrestore/backupengine/src/sbedataownermanager.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -575,12 +575,11 @@ CPackageDataTransfer* pak = FindPackageDataContainerL(packageUid); //renews the drive list TRAP(err, pak->GetDriveListL(driveList)); - if (err != KErrNone) - {//Non-removable, ignore this data owner - iDataOwners.Remove(count); - CleanupStack::PopAndDestroy(pId); - continue; - } + if( err == KErrNotSupported) + { + __LOG("CDataOwnerManager::GetDataOwnersL() - Error KErrNotSupported"); + err = KErrNone; + } } // if else { diff -r 3673b591050c -r ef55b168cedb backupandrestore/backupengine/src/sbpackagedatatransfer.cpp --- a/backupandrestore/backupengine/src/sbpackagedatatransfer.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/backupandrestore/backupengine/src/sbpackagedatatransfer.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -354,12 +354,14 @@ if(KErrNotSupported == err) {//Non-Removable package, nothing to backup iState.iState = ENone; + aLastSection = ETrue; Cleanup(); return; } else if(KErrNone != err) { iState.iState = ENone; + aLastSection = ETrue; Cleanup(); User::Leave(err); } @@ -1413,12 +1415,22 @@ // We now no longer return the Z drive, it has been decided that the Z drive will always be the // ROM. Backing up and restoring the ROM drive should not be possible, as what is the point - // build package files + // build package files if (iMetaData == NULL) { - iMetaData = iSWIBackup.GetMetaDataL(iPackageID, iFiles); - iMetaDataSize = iMetaData->Size(); - BuildPackageFileList(); + TRAPD( err, iMetaData = iSWIBackup.GetMetaDataL(iPackageID, iFiles) ); + + if( err ) + { + iMetaData = NULL; + iMetaDataSize = 0; + User::Leave( err ); + } + else + { + iMetaDataSize = iMetaData->Size(); + BuildPackageFileList(); + } } TDriveList notToBackup = ipDataOwnerManager->Config().ExcludeDriveList(); @@ -1433,6 +1445,7 @@ } aDriveList = iDriveList; + __LOG1("CPackageDataTransfer::GetDriveListL() - end - SID: 0x%08x", iPackageID.iUid); } diff -r 3673b591050c -r ef55b168cedb backupandrestore/backuptest/burtestserver/Group/burtestserver.iby --- a/backupandrestore/backuptest/burtestserver/Group/burtestserver.iby Wed Apr 14 16:49:36 2010 +0300 +++ b/backupandrestore/backuptest/burtestserver/Group/burtestserver.iby Tue Apr 27 17:30:23 2010 +0300 @@ -18,7 +18,6 @@ file=ABI_DIR\BUILD_DIR\burtestserver.exe Sys\bin\burtestserver.exe data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test.ini testdata\scripts\sbetestdata\test.ini -data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\sbeconfig.xml private\10202d56\sbeconfig.xml data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\backup_registration.xml testdata\scripts\sbetestdata\backup_registration.xml data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\increamenttest.xml testdata\scripts\sbetestdata\increamenttest.xml data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test_registration.xml testdata\scripts\sbetestdata\test_registration.xml @@ -36,4 +35,8 @@ data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test_activebackuprestore.script testdata\scripts\sbetestdata\test_activebackuprestore.script data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\test_increament.script testdata\scripts\sbetestdata\test_increament.script +#ifndef __SERIES60_ +data=EPOCROOT##Epoc32\data\z\testdata\scripts\sbetestdata\sbeconfig.xml private\10202d56\sbeconfig.xml +#endif + #endif // __BUR_TEST_SERVER_IBY__ diff -r 3673b591050c -r ef55b168cedb mtpdataproviders/mtpimagedp/inc/cmtpimagedp.h --- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedp.h Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedp.h Tue Apr 27 17:30:23 2010 +0300 @@ -63,8 +63,6 @@ TMTPFormatCode FindFormat(const TDesC& aExtension); const TDesC& FindMimeType(const TDesC& aExtension); - TBool GetCacheParentHandle(const TDesC& aParentPath, TUint32& aParentHandle); - void SetCacheParentHandle(const TDesC& aParentPath, TUint32 aParentHandle); void AppendDeleteObjectsArrayL(const TDesC& aSuid); void HandleDeleteObjectsArray(); void IncreaseNewPictures(TInt aCount); @@ -95,14 +93,7 @@ void SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession); void RenameObjectL(const TMTPNotificationParamsHandle& aParam); - TUint QueryImageObjectCountL(); - -private: - struct SMTPImageDpParentCache - { - TPath iPath; - TUint32 iHandle; - }; + TUint QueryImageObjectCountL(); private: /** @@ -130,9 +121,7 @@ /** * contain the mapping image's extension to mime type */ - RHashMap, TBuf > iMimeMappings; - - SMTPImageDpParentCache iParentCache; + RHashMap, TBuf > iMimeMappings; TInt iActiveProcessor; TBool iActiveProcessorRemoved; diff -r 3673b591050c -r ef55b168cedb mtpdataproviders/mtpimagedp/inc/cmtpimagedpobjectpropertymgr.h --- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedpobjectpropertymgr.h Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpobjectpropertymgr.h Tue Apr 27 17:30:23 2010 +0300 @@ -67,11 +67,11 @@ void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint8& aValue); void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint16& aValue); - void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint32& aValue); + void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint32& aValue, TBool alwaysCreate = ETrue); void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint64& aValue); void GetPropertyL(TMTPObjectPropertyCode aProperty, TMTPTypeUint128& aValue); void GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeString& aValue); - void GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeArray& aValue); + void GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeArray& aValue, TBool alwaysCreate = ETrue); //clear the cache void ClearCacheL(); diff -r 3673b591050c -r ef55b168cedb mtpdataproviders/mtpimagedp/inc/cmtpimagedpsendobjectinfo.h --- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedpsendobjectinfo.h Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpsendobjectinfo.h Tue Apr 27 17:30:23 2010 +0300 @@ -150,6 +150,7 @@ void CreateFsObjectL(); TMTPResponseCode ErrorToMTPError(TInt err)const; + TBool IsTooLarge(TUint64 aObjectSize) const; private: // Owned /** diff -r 3673b591050c -r ef55b168cedb mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -398,29 +398,29 @@ case EFormatExtensionSets: { - _LIT(KFormatExtensionJpg, "0x3801:jpg::3");//3 means file dp will enumerate all image files instead of image dp. + _LIT(KFormatExtensionJpg, "0x3801:jpg:::3");//3 means file dp will enumerate all image files instead of image dp. aStrings.AppendL(KFormatExtensionJpg); - _LIT(KFormatExtensionJpe, "0x3801:jpe::3"); + _LIT(KFormatExtensionJpe, "0x3801:jpe:::3"); aStrings.AppendL(KFormatExtensionJpe); - _LIT(KFormatExtensionJpeg, "0x3801:jpeg::3"); + _LIT(KFormatExtensionJpeg, "0x3801:jpeg:::3"); aStrings.AppendL(KFormatExtensionJpeg); /* * bmp files */ - _LIT(KFormatExtensionBmp, "0x3804:bmp::3"); + _LIT(KFormatExtensionBmp, "0x3804:bmp:::3"); aStrings.AppendL(KFormatExtensionBmp); /* * gif files */ - _LIT(KFormatExtensionGif, "0x3807:gif::3"); + _LIT(KFormatExtensionGif, "0x3807:gif:::3"); aStrings.AppendL(KFormatExtensionGif); /* * png files */ - _LIT(KFormatExtensionPng, "0x380B:png::3"); + _LIT(KFormatExtensionPng, "0x380B:png:::3"); aStrings.AppendL(KFormatExtensionPng); /* @@ -663,6 +663,11 @@ /** * copy file extension by insensitive case */ + if (aExtension.Length() > KMaxExtNameLength) + { + return KNullDesC; + } + TBuf extension; extension.CopyLC(aExtension); @@ -718,29 +723,6 @@ return newPictures; } -TBool CMTPImageDataProvider::GetCacheParentHandle(const TDesC& aParentPath, TUint32& aParentHandle) - { - TBool ret = EFalse; - - if (iParentCache.iPath.Compare(aParentPath) == 0) - { - aParentHandle = iParentCache.iHandle; - ret = ETrue; - } - else - { - aParentHandle = KMTPHandleNone; - } - - return ret; - } - -void CMTPImageDataProvider::SetCacheParentHandle(const TDesC& aParentPath, TUint32 aParentHandle) - { - iParentCache.iPath.Copy(aParentPath); - iParentCache.iHandle = aParentHandle; - } - void CMTPImageDataProvider::AppendDeleteObjectsArrayL(const TDesC& aSuid) { iDeleteObjectsArray.AppendL(aSuid.AllocLC()); diff -r 3673b591050c -r ef55b168cedb mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectproplist.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectproplist.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectproplist.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -364,7 +364,7 @@ case EMTPObjectPropCodeRepresentativeSampleWidth: { TUint32 value; - iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), value); + iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), value, EFalse); CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, propCode); propElem.SetUint32L(CMTPTypeObjectPropListElement::EValue, value); iPropertyList->CommitPropElemL(propElem); @@ -374,7 +374,7 @@ case EMTPObjectPropCodeRepresentativeSampleData: { CMTPTypeArray* value = CMTPTypeArray::NewLC(EMTPTypeAUINT8); - iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), *value); + iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), *value, EFalse); CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, propCode); propElem.SetArrayL(CMTPTypeObjectPropListElement::EValue, *value); iPropertyList->CommitPropElemL(propElem); diff -r 3673b591050c -r ef55b168cedb mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropvalue.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropvalue.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropvalue.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -315,7 +315,7 @@ void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleSizeL() { TUint32 representativeSampleSize; - iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleSize, representativeSampleSize); + iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleSize, representativeSampleSize, EFalse); iMTPTypeUint32.Set(representativeSampleSize); SendDataL(iMTPTypeUint32); @@ -341,7 +341,7 @@ void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleDataL() { - iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleData, *iMTPTypeArray); + iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleData, *iMTPTypeArray, EFalse); SendDataL(*iMTPTypeArray); } diff -r 3673b591050c -r ef55b168cedb mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -422,7 +422,7 @@ __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyL")); } -void CMTPImageDpObjectPropertyMgr::GetPropertyL(TMTPObjectPropertyCode aProperty, TUint32 &aValue) +void CMTPImageDpObjectPropertyMgr::GetPropertyL(TMTPObjectPropertyCode aProperty, TUint32 &aValue, TBool alwaysCreate/* = ETrue*/) { __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetPropertyL")); __ASSERT_DEBUG(iObjectInfo, Panic(EMTPImageDpObjectNull)); @@ -450,11 +450,14 @@ TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry); if (err == KErrNone) { - iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags); - if(fileEntry.FileSize() > KFileSizeMax) + if(fileEntry.FileSize() > KFileSizeMax || !alwaysCreate) { iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate); } + else + { + iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags); + } /** * trap the leave to avoid return general error when PC get object property list @@ -578,7 +581,7 @@ __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyL")); } -void CMTPImageDpObjectPropertyMgr::GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeArray& aValue) +void CMTPImageDpObjectPropertyMgr::GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeArray& aValue, TBool alwaysCreate /*= ETrue*/) { __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetPropertyL -- SmapleData")); @@ -599,11 +602,15 @@ TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry); if (err == KErrNone) { - iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags); - if(fileEntry.FileSize() > KFileSizeMax) + + if(fileEntry.FileSize() > KFileSizeMax || !alwaysCreate) { iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate); } + else + { + iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags); + } /** * trap the leave to avoid return general error when PC get object property list diff -r 3673b591050c -r ef55b168cedb mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -20,9 +20,9 @@ #include #include +#include #include - #include #include #include @@ -322,7 +322,11 @@ { iStorageId = iFramework.StorageMgr().DefaultStorageId(); } - + + if(IsTooLarge(iObjectSize)) + { + *ret = EMTPRespCodeObjectTooLarge; + } } __FLOG(_L8("CMTPImageDpSendObjectInfo::CheckObjectPropListParamsL - Exit")); @@ -608,6 +612,11 @@ if (result) { iObjectSize = iObjectInfo->Uint32L(CMTPTypeObjectInfo::EObjectCompressedSize); + if(IsTooLarge(iObjectSize)) + { + SendResponseL(EMTPRespCodeObjectTooLarge); + result = EFalse; + } } if (result) @@ -1277,3 +1286,40 @@ return resp; } + +/** +Check if the object is too large +@return ETrue if yes, otherwise EFalse +*/ +TBool CMTPImageDpSendObjectInfo::IsTooLarge(TUint64 aObjectSize) const + { + __FLOG(_L8("IsTooLarge - Entry")); + TBool ret(aObjectSize > KMaxTInt64); + + if(!ret) + { + TBuf<255> fsname; + TUint32 storageId = iStorageId; + if (storageId == KMTPStorageDefault) + { + storageId = iFramework.StorageMgr().DefaultStorageId(); + } + TInt drive( iFramework.StorageMgr().DriveNumber(storageId) ); + if(drive != KErrNotFound) + { + iFramework.Fs().FileSystemSubType(drive, fsname); + + const TUint64 KMaxFatFileSize = 0xFFFFFFFF; //Maximal file size supported by all FAT filesystems (4GB-1) + _LIT(KFsFAT16, "FAT16"); + _LIT(KFsFAT32, "FAT32"); + + if((fsname.CompareF(KFsFAT16) == 0 || fsname.CompareF(KFsFAT32) == 0) && aObjectSize > KMaxFatFileSize) + { + ret = ETrue; + } + } + } + __FLOG_VA((_L8("Result = %d"), ret)); + __FLOG(_L8("IsTooLarge - Exit")); + return ret; + } diff -r 3673b591050c -r ef55b168cedb mtpdataproviders/mtpimagedp/src/mtpimagedputilits.cpp --- a/mtpdataproviders/mtpimagedp/src/mtpimagedputilits.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpdataproviders/mtpimagedp/src/mtpimagedputilits.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -64,24 +64,17 @@ return aFramework.StorageMgr().FrameworkStorageId(static_cast(driveNumber)); } -TUint32 MTPImageDpUtilits::FindParentHandleL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider, const TDesC& aFullPath) +TUint32 MTPImageDpUtilits::FindParentHandleL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& /*aDataProvider*/, const TDesC& aFullPath) { TUint32 parentHandle = KMTPHandleNoParent; TParsePtrC parse(aFullPath); if(!parse.IsRoot()) - { - if (!aDataProvider.GetCacheParentHandle(parse.DriveAndPath(), parentHandle)) - { - parentHandle = aFramework.ObjectMgr().HandleL(parse.DriveAndPath()); - if (parentHandle != KMTPHandleNone) - { - aDataProvider.SetCacheParentHandle(parse.DriveAndPath(), parentHandle); - } - } + { + parentHandle = aFramework.ObjectMgr().HandleL(parse.DriveAndPath()); } - return parentHandle; + return parentHandle; } TBool MTPImageDpUtilits::IsNewPicture(const CMTPObjectMetaData& aMetadata) diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/daemon/server/group/mtpserver.mmp --- a/mtpfws/mtpfw/daemon/server/group/mtpserver.mmp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/daemon/server/group/mtpserver.mmp Tue Apr 27 17:30:23 2010 +0300 @@ -24,9 +24,9 @@ #ifdef WINSCW //EPOCHEAPSIZE 0x1400000 0x1400000 // 20MB -EPOCHEAPSIZE 0x80000 0x400000 // 4MB +EPOCHEAPSIZE 0x80000 0x800000 // 8MB #else -EPOCHEAPSIZE 0x80000 0x400000 // 4MB +EPOCHEAPSIZE 0x80000 0x800000 // 8MB #endif MW_LAYER_SYSTEMINCLUDE_SYMBIAN diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/devdp/src/mtpdevicedpprocessor.cpp --- a/mtpfws/mtpfw/dataproviders/devdp/src/mtpdevicedpprocessor.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/devdp/src/mtpdevicedpprocessor.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -51,6 +51,7 @@ #include "cmtpgetserviceids.h" #include "cmtpgetserviceinfo.h" #include "cmtpgetformatcapabilities.h" +#include "cmtpsetobjectprotection.h" /** device data provider mapping table from request ID to factory method of the request processor */ @@ -87,7 +88,8 @@ {EMTPOpCodeResetDevicePropValue, CMTPResetDevicePropValue::NewL}, {EMTPOpCodeGetServiceIDs, CMTPGetServiceIds::NewL}, {EMTPOpCodeGetServiceInfo, CMTPGetServiceInfo::NewL}, - {EMTPOpCodeGetFormatCapabilities,CMTPGetFormatCapabilities::NewL} + {EMTPOpCodeGetFormatCapabilities,CMTPGetFormatCapabilities::NewL}, + {EMTPOpCodeSetObjectProtection, CMTPSetObjectProtection::NewL} }; /** diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/bwins/mtpdataproviderutilityu.def --- a/mtpfws/mtpfw/dataproviders/dputility/bwins/mtpdataproviderutilityu.def Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/bwins/mtpdataproviderutilityu.def Tue Apr 27 17:30:23 2010 +0300 @@ -115,7 +115,7 @@ ?FormatFromFilename@RMTPUtility@@QAE?AW4TMTPFormatCode@@ABVTDesC16@@@Z @ 114 NONAME ; enum TMTPFormatCode RMTPUtility::FormatFromFilename(class TDesC16 const &) ?TTime2MTPTimeStr@RMTPUtility@@QBEHABVTTime@@AAVTDes16@@@Z @ 115 NONAME ; int RMTPUtility::TTime2MTPTimeStr(class TTime const &, class TDes16 &) const ?MTPUtility@RMTPDpSingletons@@QBEAAVRMTPUtility@@XZ @ 116 NONAME ; class RMTPUtility & RMTPDpSingletons::MTPUtility(void) const - ?GetDpId@RMTPUtility@@QAEKABVTDesC16@@0@Z @ 117 NONAME ; unsigned long RMTPUtility::GetDpId(class TDesC16 const &, class TDesC16 const &) + ?GetDpId@RMTPUtility@@QAEKABVTDesC16@@0@Z @ 117 NONAME ABSENT ; unsigned long RMTPUtility::GetDpId(class TDesC16 const &, class TDesC16 const &) ?GetFormatByExtension@RMTPUtility@@QAE?AW4TMTPFormatCode@@ABVTDesC16@@@Z @ 118 NONAME ; enum TMTPFormatCode RMTPUtility::GetFormatByExtension(class TDesC16 const &) ?SessionId@CMTPRequestProcessor@@MAEKXZ @ 119 NONAME ; unsigned long CMTPRequestProcessor::SessionId(void) ?GetEnumerationFlag@RMTPUtility@@QAEIABVTDesC16@@@Z @ 120 NONAME ; unsigned int RMTPUtility::GetEnumerationFlag(class TDesC16 const &) @@ -213,4 +213,7 @@ ?NewL@CMTPFSEntryCache@@SAPAV1@XZ @ 212 NONAME ; class CMTPFSEntryCache * CMTPFSEntryCache::NewL(void) ?FileEntry@CMTPFSEntryCache@@QAEAAVTEntry@@XZ @ 213 NONAME ; class TEntry & CMTPFSEntryCache::FileEntry(void) ?RegisterPendingRequest@CMTPRequestProcessor@@IAEXI@Z @ 214 NONAME ; void CMTPRequestProcessor::RegisterPendingRequest(unsigned int) + ?GetDpIdL@RMTPUtility@@QAEKABVTDesC16@@0@Z @ 215 NONAME ; unsigned long RMTPUtility::GetDpIdL(class TDesC16 const &, class TDesC16 const &) + ?GetSubFormatCodeL@RMTPUtility@@QAEGABVTDesC16@@0@Z @ 216 NONAME ; unsigned short RMTPUtility::GetSubFormatCodeL(class TDesC16 const &, class TDesC16 const &) + ?GetFormatCodeByMimeTypeL@RMTPUtility@@QAE?AW4TMTPFormatCode@@ABVTDesC16@@0@Z @ 217 NONAME ; enum TMTPFormatCode RMTPUtility::GetFormatCodeByMimeTypeL(class TDesC16 const &, class TDesC16 const &) diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/eabi/mtpdataproviderutilityu.def --- a/mtpfws/mtpfw/dataproviders/dputility/eabi/mtpdataproviderutilityu.def Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/eabi/mtpdataproviderutilityu.def Tue Apr 27 17:30:23 2010 +0300 @@ -210,7 +210,7 @@ _ZN11RMTPUtility18FormatFromFilenameERK7TDesC16 @ 209 NONAME _ZN11RMTPUtility20GetFormatByExtensionERK7TDesC16 @ 210 NONAME _ZN11RMTPUtility22FormatExtensionMappingEv @ 211 NONAME - _ZN11RMTPUtility7GetDpIdERK7TDesC16S2_ @ 212 NONAME + _ZN11RMTPUtility7GetDpIdERK7TDesC16S2_ @ 212 NONAME ABSENT _ZNK11RMTPUtility16MTPTimeStr2TTimeERK7TDesC16R5TTime @ 213 NONAME _ZNK11RMTPUtility16TTime2MTPTimeStrERK5TTimeR6TDes16 @ 214 NONAME _ZNK16RMTPDpSingletons10MTPUtilityEv @ 215 NONAME @@ -415,4 +415,7 @@ _ZTI16CMTPFSEntryCache @ 414 NONAME _ZTV16CMTPFSEntryCache @ 415 NONAME _ZN20CMTPRequestProcessor22RegisterPendingRequestEj @ 416 NONAME + _ZN11RMTPUtility17GetSubFormatCodeLERK7TDesC16S2_ @ 417 NONAME + _ZN11RMTPUtility24GetFormatCodeByMimeTypeLERK7TDesC16S2_ @ 418 NONAME + _ZN11RMTPUtility8GetDpIdLERK7TDesC16S2_ @ 419 NONAME diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/inc/cmtpextensionmapping.h --- a/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpextensionmapping.h Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpextensionmapping.h Tue Apr 27 17:30:23 2010 +0300 @@ -34,6 +34,7 @@ const TDesC& Extension() const; TMTPFormatCode FormatCode() const; + TUint16 SubFormatCode() const; const TDesC& MIMEType() const; TUint32 DpId() const; TUint EnumerationFlag() const; @@ -42,6 +43,7 @@ void SetMIMETypeL(const TDesC& aMIMEType); void SetDpId(const TUint32 aDpId); void SetFormatCode(const TMTPFormatCode aFormatCode); + void SetSubFormatCode(TUint16 aSubFormatCode); void SetEnumerationFlag(const TUint aNeedFileDp); static TInt Compare(const CMTPExtensionMapping& aFirst, const CMTPExtensionMapping& aSecond); @@ -57,6 +59,7 @@ HBufC* iMIMEType; TUint32 iDpId; TUint iNeedFileDp; + TUint16 iSubFormatCode; }; #endif // CMTPEXTENSIONMAPPING_H diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/inc/cmtpfsenumerator.h --- a/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpfsenumerator.h Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpfsenumerator.h Tue Apr 27 17:30:23 2010 +0300 @@ -65,7 +65,7 @@ void ScanNextSubdirL(); void ProcessEntriesL(); void AddEntryL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& aEntry, TUint32 aStorageId, TUint32 aParentHandle); - void AddFileEntryForOtherDpL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& aEntry, TUint32 aStorageId, TUint32 aParentHandle); + void AddFileEntryForOtherDpL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& aEntry, TUint32 aStorageId, TUint32 aParentHandle, TUint16 aSubFormatCode = 0); void NotifyObjectAddToDP(const TUint32 aHandle,const TUint DpId); diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/inc/cmtpmoveobject.h --- a/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpmoveobject.h Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpmoveobject.h Tue Apr 27 17:30:23 2010 +0300 @@ -24,10 +24,13 @@ #include "rmtpframework.h" #include "cmtprequestprocessor.h" #include "mtpdebug.h" +#include "rmtpdpsingletons.h" class CFileMan; class CMTPObjectMetaData; +const TInt KMoveObjectTimeOut = 180000000; // 180s + /** Defines data provider MoveObject request processor @@ -48,7 +51,9 @@ private: //from CMTPRequestProcessor virtual void ServiceL(); - TMTPResponseCode CheckRequestL(); + TMTPResponseCode CheckRequestL(); + TBool DoHandleCompletingPhaseL(); + TBool Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const; private: void ConstructL(); @@ -60,19 +65,26 @@ void SetPreviousPropertiesL(const TDesC& aFileName); void MoveFileL(const TDesC& aNewFileName); void MoveFolderL(); + static TInt OnTimeoutL(TAny* aPtr); + void DoOnTimeoutL(); + void RunL(); private: - CFileMan* iFileMan; + CFileMan* iFileMan; CMTPObjectMetaData* iObjectInfo; //Not owned. - HBufC* iDest; - HBufC* iNewRootFolder; - TUint32 iNewParentHandle; - TUint32 iStorageId; - TTime iPreviousModifiedTime; - HBufC* iPathToMove; - RArray iObjectHandles; - TInt iMoveObjectIndex; - RMTPFramework iSingletons; + HBufC* iDest; + HBufC* iNewRootFolder; + TUint32 iNewParentHandle; + TUint32 iStorageId; + TTime iPreviousModifiedTime; + HBufC* iPathToMove; + RArray iObjectHandles; + TInt iMoveObjectIndex; + RMTPFramework iSingletons; + RMTPDpSingletons iDpSingletons; + CPeriodic* iTimer; + HBufC* iNewFileName; + TBool iIsFolder; /** FLOGGER debug trace member variable. */ diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsendobjectinfo.h --- a/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsendobjectinfo.h Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsendobjectinfo.h Tue Apr 27 17:30:23 2010 +0300 @@ -128,6 +128,8 @@ TFileName iName; TBool iNoRollback; RMTPFramework iSingletons; + static const TInt KExtensionLength = 8; + RArray< TBuf > iExceptionList; }; #endif //CMTPSENDOBJECTINFO_H diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsetobjectprotection.h --- a/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsetobjectprotection.h Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/inc/cmtpsetobjectprotection.h Tue Apr 27 17:30:23 2010 +0300 @@ -57,7 +57,7 @@ private: RFs& iRfs; CMTPObjectMetaData* iObjMeta; - + RMTPFramework iSingletons; }; #endif diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/inc/rmtputility.h --- a/mtpfws/mtpfw/dataproviders/dputility/inc/rmtputility.h Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/inc/rmtputility.h Tue Apr 27 17:30:23 2010 +0300 @@ -49,9 +49,20 @@ IMPORT_C TMTPFormatCode FormatFromFilename( const TDesC& aFullFileName ); IMPORT_C void FormatExtensionMapping(); IMPORT_C TMTPFormatCode GetFormatByExtension(const TDesC& aExtension); - IMPORT_C TUint32 GetDpId(const TDesC& aExtension,const TDesC& aMIMEType); + IMPORT_C TUint32 GetDpIdL(const TDesC& aExtension,const TDesC& aMIMEType); + IMPORT_C TUint16 GetSubFormatCodeL(const TDesC& aExtension,const TDesC& aMIMEType); + IMPORT_C TMTPFormatCode GetFormatCodeByMimeTypeL(const TDesC& aExtension,const TDesC& aMIMEType); IMPORT_C TUint GetEnumerationFlag(const TDesC& aExtension); - +private: + enum TParseState + { + EFormatCode, + Extension, + EMimeType, + ESubFormatCode, + EnumerationFlag, + EParseStateEnd + }; private: void RenameAllChildrenL(TUint32 aStorageId, TUint32 aParentHandle, const TDesC& aNewFolderName, const TDesC& aOldFolderName); TBool GetYear(const TDesC& aTimeString, TInt& aYear) const; @@ -63,18 +74,24 @@ TBool GetTenthSecond(const TDesC& aTimeString, TInt& aTenthSecond) const; TBool GetTimeZone(const TDesC& aTimeString, TBool& aPositiveTimeZone, TInt& aTimeZoneInHour, TInt& aTimeZoneInMinute) const; HBufC* OdfMimeTypeL( const TDesC& aFullFileName ); - void AppendFormatExtensionMapping(const CDesCArray& aFormatExtensionMapping,TUint32 aDpId); + void AppendFormatExtensionMappingL(const CDesCArray& aFormatExtensionMapping,TUint32 aDpId); void GetAllDecendents(TUint32 aStorageId, TUint aParentHandle, RArray& aHandles) const; + void ParseFormatCode(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState); + void ParseExtension(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState); + void ParseMimeType(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState); + void ParseSubFormatCode(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState); + void ParseEnumerationFlag(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState); + void Parse(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState); private: /** FLOGGER debug trace member variable. */ __FLOG_DECLARATION_MEMBER_MUTABLE; - MMTPDataProviderFramework* iFramework; RMTPFramework iSingleton; RPointerArray iFormatMappings; + TUint iEnumFlag; //temp code will remove after the correct their format string }; diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/src/cmtpcopyobject.cpp --- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpcopyobject.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpcopyobject.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -127,8 +127,13 @@ { __FLOG(_L8("ServiceL - Entry")); TUint32 handle = KMTPHandleNone; - TMTPResponseCode responseCode = CopyObjectL(handle); - if(responseCode != EMTPRespCodeOK) + TMTPResponseCode responseCode = EMTPRespCodeOK; + TRAPD(err, responseCode = CopyObjectL(handle)); + if(err != KErrNone) + { + SendResponseL(EMTPRespCodeAccessDenied); + } + else if(responseCode != EMTPRespCodeOK) { __FLOG_VA((_L8("ServiceL, sending response with respond code %d"), responseCode)); SendResponseL(responseCode); diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/src/cmtpextensionmapping.cpp --- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpextensionmapping.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpextensionmapping.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -65,6 +65,11 @@ return iFormatCode; } +TUint16 CMTPExtensionMapping::SubFormatCode() const + { + return iSubFormatCode; + } + TUint32 CMTPExtensionMapping::DpId() const { return iDpId; @@ -79,7 +84,6 @@ { delete iExtension; iExtension = NULL; - iExtension = aExtension.AllocL(); } @@ -100,6 +104,10 @@ { iFormatCode = aFormatCode; } +void CMTPExtensionMapping::SetSubFormatCode(TUint16 aSubFormatCode) + { + iSubFormatCode = aSubFormatCode; + } void CMTPExtensionMapping::SetEnumerationFlag(const TUint aNeedFileDp) { diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp --- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -456,7 +456,7 @@ { const TEntry& entry = iEntries[i]; iCurrentPath.Append(entry.iName); - __FLOG_VA((_L8("Process path %S name %S"), &iCurrentPath, &entry.iName)); + __FLOG_VA((_L("Process path %S name %S"), &iCurrentPath, &entry.iName)); #ifdef __FLOG_ACTIVE TBuf8 tmp; tmp.Copy(iCurrentPath); @@ -531,7 +531,7 @@ if (KMTPHandleNone == iFramework.ObjectMgr().HandleL(iCurrentPath)) { format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1)); - TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC); + TUint32 DpId = iDpSingletons.MTPUtility().GetDpIdL(parse.Ext().Mid(1), KNullDesC); AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], iParentHandle); } break; @@ -542,33 +542,23 @@ TUint32 DpId = iFramework.DataProviderId(); if (parse.Ext().CompareF(KTxtExtensionODF)==0) { - format = iDpSingletons.MTPUtility().FormatFromFilename(parse.Ext().Mid(1)); - if ( EMTPFormatCode3GPContainer==format || EMTPFormatCodeMP4Container==format ) + HBufC* mime = iDpSingletons.MTPUtility().ContainerMimeType(iCurrentPath); + CleanupStack::PushL(mime); + if ( mime != NULL ) { - DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1),KNullDesC); - if ( 255 == DpId ) - { - HBufC* mime = NULL; - mime = iDpSingletons.MTPUtility().ContainerMimeType(iCurrentPath); - if ( mime != NULL ) - { - DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1),*mime); - delete mime; - mime = NULL; - } - } - AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], iParentHandle); + __FLOG_VA((_L("mime %S"), mime)); + DpId = iDpSingletons.MTPUtility().GetDpIdL(parse.Ext().Mid(1),*mime); + __FLOG_VA((_L("DpId find %d"), DpId)); } - else - { - format = EMTPFormatCodeUndefined; - AddEntryL(iCurrentPath, handle, format, iDpID, entry, iStorages[iScanPos], iParentHandle); - } + format = iDpSingletons.MTPUtility().GetFormatCodeByMimeTypeL(parse.Ext().Mid(1),*mime); + AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], + iParentHandle, iDpSingletons.MTPUtility().GetSubFormatCodeL(parse.Ext().Mid(1),*mime)); + CleanupStack::PopAndDestroy(mime); } else { format = iDpSingletons.MTPUtility().GetFormatByExtension(parse.Ext().Mid(1)); - TUint32 DpId = iDpSingletons.MTPUtility().GetDpId(parse.Ext().Mid(1), KNullDesC); + TUint32 DpId = iDpSingletons.MTPUtility().GetDpIdL(parse.Ext().Mid(1), KNullDesC); AddFileEntryForOtherDpL(iCurrentPath, handle, format, DpId, entry, iStorages[iScanPos], iParentHandle); } } @@ -637,7 +627,7 @@ __FLOG_VA(_L8("AddEntryL - exit")); } -void CMTPFSEnumerator::AddFileEntryForOtherDpL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& /*aEntry*/, TUint32 aStorageId, TUint32 aParentHandle) +void CMTPFSEnumerator::AddFileEntryForOtherDpL(const TDesC& aPath, TUint32 &aHandle, TMTPFormatCode format, TUint32 aDPId, const TEntry& /*aEntry*/, TUint32 aStorageId, TUint32 aParentHandle, TUint16 aSubFormatCode/* = 0*/) { #ifdef __FLOG_ACTIVE TBuf8 tmp; @@ -646,7 +636,6 @@ __FLOG_VA((_L8("AddFileEntryForOtherDpL - entry: %S"), &tmp)); #endif // __FLOG_ACTIVE - TUint16 assoc = EMTPAssociationTypeUndefined; TParsePtrC pathParser(aPath); TPtrC name(pathParser.Name()); @@ -656,7 +645,7 @@ iObject->SetUint(CMTPObjectMetaData::EFormatCode, format); iObject->SetUint(CMTPObjectMetaData::EStorageId, aStorageId); iObject->SetDesCL(CMTPObjectMetaData::ESuid, aPath); - iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, assoc); + iObject->SetUint(CMTPObjectMetaData::EFormatSubCode, aSubFormatCode); iObject->SetUint(CMTPObjectMetaData::EParentHandle, aParentHandle); iObject->SetUint(CMTPObjectMetaData::ENonConsumable, EMTPConsumable); iObject->SetDesCL(CMTPObjectMetaData::EName, name); diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/src/cmtpmoveobject.cpp --- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpmoveobject.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpmoveobject.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -23,6 +23,7 @@ #include #include +#include "cmtpfsentrycache.h" #include "cmtpstoragemgr.h" #include "cmtpmoveobject.h" #include "mtpdppanic.h" @@ -61,12 +62,17 @@ Destructor */ EXPORT_C CMTPMoveObject::~CMTPMoveObject() - { + { + Cancel(); + iDpSingletons.Close(); + iSingletons.Close(); + + delete iTimer; + delete iNewFileName; delete iDest; delete iFileMan; delete iPathToMove; - delete iNewRootFolder; - iSingletons.Close(); + delete iNewRootFolder; __FLOG_CLOSE; } @@ -75,7 +81,7 @@ */ CMTPMoveObject::CMTPMoveObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) : CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPMoveObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPMoveObjectPolicy), - iMoveObjectIndex(0) + iMoveObjectIndex(0), iTimer(NULL) { __FLOG_OPEN(KMTPSubsystem, KComponent); } @@ -104,6 +110,21 @@ result = EMTPRespCodeStoreReadOnly; } + if(result == EMTPRespCodeOK) + { + const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid)); + iIsFolder = EFalse; + User::LeaveIfError(BaflUtils::IsFolder(iFramework.Fs(), suid, iIsFolder)); + if(!iIsFolder) + { + if(iDpSingletons.MovingBigFileCache().IsOnGoing()) + { + __FLOG(_L8("CheckRequestL - A big file moving is ongoing, respond with access denied")); + result = EMTPRespCodeAccessDenied; + } + } + } + __FLOG(_L8("CheckRequestL - Exit")); return result; } @@ -112,7 +133,8 @@ MoveObject request handler */ void CMTPMoveObject::ServiceL() - { + { + __FLOG(_L8("ServiceL - Entry")); TMTPResponseCode ret = EMTPRespCodeOK; TRAPD(err, ret = MoveObjectL()); if (err != KErrNone) @@ -123,6 +145,7 @@ { SendResponseL(ret); } + __FLOG(_L8("ServiceL - Exit")); } /** @@ -131,6 +154,7 @@ void CMTPMoveObject::ConstructL() { iSingletons.OpenL(); + iDpSingletons.OpenL(iFramework); } @@ -143,12 +167,38 @@ __FLOG(_L8("MoveFileL - Entry")); const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid)); GetPreviousPropertiesL(suid); - User::LeaveIfError(iFileMan->Move(suid, *iDest)); - SetPreviousPropertiesL(aNewFileName); - iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, aNewFileName); - iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId); - iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle); - iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo); + + if(iFramework.StorageMgr().DriveNumber(iObjectInfo->Uint(CMTPObjectMetaData::EStorageId)) == + iFramework.StorageMgr().DriveNumber(iStorageId)) + //Move file to the same storage + { + User::LeaveIfError(iFileMan->Move(suid, *iDest)); + SetPreviousPropertiesL(aNewFileName); + iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, aNewFileName); + iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId); + iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle); + iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo); + SendResponseL(EMTPRespCodeOK); + } + else + //Move file between different storages + { + delete iNewFileName; + iNewFileName = NULL; + iNewFileName = aNewFileName.AllocL(); // Store the new file name + + User::LeaveIfError(iFileMan->Move(suid, *iDest, CFileMan::EOverWrite, iStatus)); + if ( !IsActive() ) + { + SetActive(); + } + + delete iTimer; + iTimer = NULL; + iTimer = CPeriodic::NewL(EPriorityStandard); + TTimeIntervalMicroSeconds32 KMoveObjectIntervalNone = 0; + iTimer->Start(TTimeIntervalMicroSeconds32(KMoveObjectTimeOut), KMoveObjectIntervalNone, TCallBack(CMTPMoveObject::OnTimeoutL, this)); + } __FLOG(_L8("MoveFileL - Exit")); } @@ -206,10 +256,7 @@ TParsePtrC fileNameParser(suid); // Check if the object is a folder or a file. - TBool isFolder = EFalse; - User::LeaveIfError(BaflUtils::IsFolder(iFramework.Fs(), suid, isFolder)); - - if(!isFolder) + if(!iIsFolder) { if((newObjectName.Length() + fileNameParser.NameAndExt().Length()) <= newObjectName.MaxLength()) { @@ -239,10 +286,9 @@ iFileMan = NULL; iFileMan = CFileMan::NewL(iFramework.Fs()); - if(!isFolder) + if(!iIsFolder) { MoveFileL(newObjectName); - SendResponseL(responseCode); } else { @@ -347,7 +393,129 @@ __FLOG(_L8("SetPreviousPropertiesL - Exit")); } +/** + Call back function, called when the timer expired for big file moving. + Send response to initiator and cache the target file entry info, which is used to send response + to getobjectproplist and getobjectinfo. +*/ +TInt CMTPMoveObject::OnTimeoutL(TAny* aPtr) + { + CMTPMoveObject* moveObjectProcessor = static_cast(aPtr); + moveObjectProcessor->DoOnTimeoutL(); + return KErrNone; + } +void CMTPMoveObject::DoOnTimeoutL() + { + __FLOG(_L8("DoOnTimeoutL - Entry")); + + if (iTimer) + { + if (iTimer->IsActive()) + { + iTimer->Cancel(); + } + delete iTimer; + iTimer = NULL; + } + + const TDesC& suid(iObjectInfo->DesC(CMTPObjectMetaData::ESuid)); + TEntry fileEntry; + User::LeaveIfError(iFramework.Fs().Entry(suid, fileEntry)); + TUint32 handle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle); + + iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, *iNewFileName); + iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId); + iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle); + iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo); + + CMTPFSEntryCache& aCache = iDpSingletons.MovingBigFileCache(); + + // Cache the target file entry info, which is used to send response to getobjectproplist and getobjectinfo + aCache.SetOnGoing(ETrue); + aCache.SetTargetHandle(handle); + aCache.SetFileEntry(fileEntry); + + __FLOG(_L8("UpdateFSEntryCache, sending response with respond code OK for a big file move")); + SendResponseL(EMTPRespCodeOK); + + __FLOG(_L8("DoOnTimeoutL - Exit")); + } +/** + CMTPMoveObject::RunL +*/ +void CMTPMoveObject::RunL() + { + __FLOG(_L8("RunL - Entry")); + + User::LeaveIfError(iStatus.Int()); + SetPreviousPropertiesL(*iNewFileName); + CMTPFSEntryCache& aCache = iDpSingletons.MovingBigFileCache(); + // Check to see if we are moving a big file + if(aCache.IsOnGoing()) + { + __FLOG(_L8("RunL - Big file move complete")); + aCache.SetOnGoing(EFalse); + aCache.SetTargetHandle(KMTPHandleNone); + } + else + { + //Cancel the timer + if(iTimer) + { + if(iTimer->IsActive()) + { + iTimer->Cancel(); + } + delete iTimer; + iTimer = NULL; + } + iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, *iNewFileName); + iObjectInfo->SetUint(CMTPObjectMetaData::EStorageId, iStorageId); + iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle); + iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo); + __FLOG(_L8("RunL, sending response with respond code OK for a normal file move")); + SendResponseL(EMTPRespCodeOK); + } + __FLOG(_L8("RunL - Exit")); + } + +/** +Override to handle the complete phase of move object +*/ +TBool CMTPMoveObject::DoHandleCompletingPhaseL() + { + CMTPRequestProcessor::DoHandleCompletingPhaseL(); + + CMTPFSEntryCache& aCache = iDpSingletons.MovingBigFileCache(); + if(aCache.IsOnGoing()) + { + return EFalse; + } + else + { + return ETrue; + } + } + +/** +Override to match MoveObject request +@param aRequest The request to match +@param aConnection The connection from which the request comes +@return ETrue if the processor can handle the request, otherwise EFalse +*/ +TBool CMTPMoveObject::Match(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const + { + __FLOG(_L8("Match - Entry")); + TBool result = EFalse; + TUint16 operationCode = aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode); + if ((operationCode == EMTPOpCodeMoveObject) && &iConnection == &aConnection) + { + result = ETrue; + } + __FLOG_VA((_L8("Match -- Exit with result = %d"), result)); + return result; + } diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp --- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -220,6 +220,10 @@ iDpSingletons.OpenL(iFramework); iNoRollback = EFalse; iSingletons.OpenL(); + _LIT(KM4A, ".m4a"); + _LIT(KODF, ".odf"); + iExceptionList.AppendL(KM4A()); + iExceptionList.AppendL(KODF()); __FLOG(_L8("ConstructL - Exit")); } @@ -707,38 +711,48 @@ //with folder creation. if(!iIsFolder) - { - SetPropertiesL(); - iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject); - - TParsePtrC file( iFullPath ); - _LIT( KTxtExtensionODF, ".odf" ); - if ( file.ExtPresent() && file.Ext().CompareF(KTxtExtensionODF)==0 ) - { - TUint32 DpId = iFramework.DataProviderId(); - DpId = iDpSingletons.MTPUtility().GetDpId(file.Ext().Mid(1),KNullDesC); - //The data provider which owns all mimetypes of a file extension is not found - if ( 255 == DpId ) - { - HBufC* mime = NULL; - mime = iDpSingletons.MTPUtility().ContainerMimeType(iFullPath); - if ( mime != NULL ) - { - DpId = iDpSingletons.MTPUtility().GetDpId(file.Ext().Mid(1),*mime); - delete mime; - mime = NULL; - } - } - if ( DpId!=iFramework.DataProviderId() && DpId!=255) - { - iReceivedObject->SetUint(CMTPObjectMetaData::EDataProviderId,DpId); - //iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode,format); - iFramework.ObjectMgr().ModifyObjectL(*iReceivedObject); - TUint32 handle = iReceivedObject->Uint(CMTPObjectMetaData::EHandle); - iSingletons.DpController().NotifyDataProvidersL(DpId,EMTPObjectAdded,(TAny*)&handle); - } - } - } + { + SetPropertiesL(); + iFramework.ObjectMgr().CommitReservedObjectHandleL(*iReceivedObject); + iFullPath.LowerCase(); + __FLOG_VA((_L8("File Name %S"), &iFullPath)); + TParsePtrC file( iFullPath ); + if ( file.ExtPresent() && iExceptionList.Find(file.Ext()) != KErrNotFound) + { + TUint32 DpId = iFramework.DataProviderId(); + HBufC* mime = iDpSingletons.MTPUtility().ContainerMimeType(iFullPath); + CleanupStack::PushL(mime); + if ( mime != NULL ) + { + DpId = iDpSingletons.MTPUtility().GetDpIdL(file.Ext().Mid(1),*mime); + } + else + { + DpId = iDpSingletons.MTPUtility().GetDpIdL(file.Ext().Mid(1), KNullDesC); + } + if ( DpId!=iFramework.DataProviderId()) + { + iReceivedObject->SetUint(CMTPObjectMetaData::EDataProviderId,DpId); + TUint32 format = EMTPFormatCodeUndefined; + TUint16 subFormat = 0; + if(mime != NULL) + { + format = iDpSingletons.MTPUtility().GetFormatCodeByMimeTypeL(file.Ext().Mid(1),*mime); + subFormat = iDpSingletons.MTPUtility().GetSubFormatCodeL(file.Ext().Mid(1),*mime); + } + else + { + format = iDpSingletons.MTPUtility().GetFormatByExtension(file.Ext().Mid(1)); + } + iReceivedObject->SetUint(CMTPObjectMetaData::EFormatCode,format); + iReceivedObject->SetUint(CMTPObjectMetaData::EFormatSubCode,subFormat); + iFramework.ObjectMgr().ModifyObjectL(*iReceivedObject); + TUint32 handle = iReceivedObject->Uint(CMTPObjectMetaData::EHandle); + iSingletons.DpController().NotifyDataProvidersL(DpId,EMTPObjectAdded,(TAny*)&handle); + } + CleanupStack::PopAndDestroy(mime); + } + } SendResponseL(EMTPRespCodeOK); } diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectpropvalue.cpp --- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectpropvalue.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectpropvalue.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -28,6 +28,7 @@ #include "mtpframeworkconst.h" #include "rmtpdpsingletons.h" #include "rmtputility.h" +#include "cmtpstoragemgr.h" /** Verification data for the SetObjectPropValue request @@ -109,6 +110,11 @@ CMTPObjectMetaData* meta = iRequestChecker->GetObjectInfo(handle); __ASSERT_DEBUG(meta, Panic(EMTPDpObjectNull)); + if(!iSingleton.StorageMgr().IsReadWriteStorage(meta->Uint(CMTPObjectMetaData::EStorageId))) + { + responseCode = EMTPRespCodeAccessDenied; + } + if(responseCode == EMTPRespCodeOK) { TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2); diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectprotection.cpp --- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectprotection.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectprotection.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -28,6 +28,7 @@ #include "mtpframeworkconst.h" #include "rmtpdpsingletons.h" #include "rmtputility.h" +#include "cmtpstoragemgr.h" /** Verification data for the SetObjectPropValue request @@ -63,6 +64,7 @@ EXPORT_C CMTPSetObjectProtection::~CMTPSetObjectProtection() { delete iObjMeta; + iSingletons.Close(); } /** @@ -85,6 +87,11 @@ { return EMTPRespCodeInvalidObjectHandle; } + if(!iSingletons.StorageMgr().IsReadWriteStorage(iObjMeta->Uint(CMTPObjectMetaData::EStorageId))) + { + return EMTPRespCodeAccessDenied; //EMTPRespCodeStoreReadOnly + } + TUint32 statusValue = Request().Uint32(TMTPTypeRequest::ERequestParameter2); //Currently we only support EMTPProtectionNoProtection and EMTPProtectionReadOnly if ( statusValue!=EMTPProtectionNoProtection && statusValue!=EMTPProtectionReadOnly ) @@ -151,4 +158,5 @@ void CMTPSetObjectProtection::ConstructL() { iObjMeta = CMTPObjectMetaData::NewL(); + iSingletons.OpenL(); } diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/dputility/src/rmtputility.cpp --- a/mtpfws/mtpfw/dataproviders/dputility/src/rmtputility.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/dputility/src/rmtputility.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -31,13 +31,14 @@ #include "cmtpdataprovidercontroller.h" #include "cmtpextensionmapping.h" #include "cmtpdataprovider.h" +#include "mtpframeworkconst.h" using namespace ContentAccess; // Class constants. const TInt KMTPDateStringLength = 15; const TInt KMTPDateStringTIndex = 8; const TInt KMimeTypeMaxLength = 76; -const TInt KMAXPackageIDStringLen = 32; +//const TInt KMAXPackageIDStringLen = 32; _LIT( KTxtBackSlash, "\\" ); @@ -373,8 +374,8 @@ if ( file.Ext().CompareF( KTxtExtensionODF ) == 0 ) { TRAP( err, mime = OdfMimeTypeL( aFullPath ) ); + __FLOG_VA((_L("ContainerMimeType err %d mime %S"), err, mime)); } - return mime; } @@ -386,8 +387,10 @@ { CDesCArraySeg* FormatExtensionMapping = new (ELeave) CDesCArraySeg(4); CleanupStack::PushL(FormatExtensionMapping); - TRAP_IGNORE(iSingleton.DpController().DataProviderByIndexL(count).Plugin().SupportedL(EFormatExtensionSets,*FormatExtensionMapping)); - AppendFormatExtensionMapping(*FormatExtensionMapping,iSingleton.DpController().DataProviderByIndexL(count).DataProviderId()); + TRAP_IGNORE( + iSingleton.DpController().DataProviderByIndexL(count).Plugin().SupportedL(EFormatExtensionSets,*FormatExtensionMapping); + AppendFormatExtensionMappingL(*FormatExtensionMapping,iSingleton.DpController().DataProviderByIndexL(count).DataProviderId()); + ); CleanupStack::PopAndDestroy(FormatExtensionMapping); } } @@ -406,7 +409,29 @@ return EMTPFormatCodeUndefined; } -EXPORT_C TUint32 RMTPUtility::GetDpId(const TDesC& aExtension,const TDesC& aMIMEType) +EXPORT_C TUint32 RMTPUtility::GetDpIdL(const TDesC& aExtension,const TDesC& aMIMEType) + { + CMTPExtensionMapping* extensionMapping = CMTPExtensionMapping::NewL(aExtension, EMTPFormatCodeUndefined,aMIMEType); + CleanupStack::PushL(extensionMapping); + TInt found = KErrNotFound; + if(aMIMEType == KNullDesC) + { + found = iFormatMappings.FindInOrder(extensionMapping, TLinearOrder(CMTPExtensionMapping::Compare)); + } + else + { + found = iFormatMappings.FindInOrder(extensionMapping, TLinearOrder(CMTPExtensionMapping::ComparewithMIME)); + } + if ( KErrNotFound != found) + { + CleanupStack::PopAndDestroy(extensionMapping); + return iFormatMappings[found]->DpId(); + } + CleanupStack::PopAndDestroy(extensionMapping); + return KMTPFileDPID; + } + +EXPORT_C TUint16 RMTPUtility::GetSubFormatCodeL(const TDesC& aExtension,const TDesC& aMIMEType) { CMTPExtensionMapping* extensionMapping = CMTPExtensionMapping::NewL(aExtension, EMTPFormatCodeUndefined,aMIMEType); CleanupStack::PushL(extensionMapping); @@ -414,12 +439,27 @@ if ( KErrNotFound != found) { CleanupStack::PopAndDestroy(extensionMapping); - return iFormatMappings[found]->DpId(); + return iFormatMappings[found]->SubFormatCode(); } CleanupStack::PopAndDestroy(extensionMapping); - return 255; + return 0; } +EXPORT_C TMTPFormatCode RMTPUtility::GetFormatCodeByMimeTypeL(const TDesC& aExtension,const TDesC& aMIMEType) + { + CMTPExtensionMapping* extensionMapping = CMTPExtensionMapping::NewL(aExtension, EMTPFormatCodeUndefined,aMIMEType); + CleanupStack::PushL(extensionMapping); + TInt found = iFormatMappings.FindInOrder(extensionMapping, TLinearOrder(CMTPExtensionMapping::ComparewithMIME)); + if ( KErrNotFound != found) + { + CleanupStack::PopAndDestroy(extensionMapping); + return iFormatMappings[found]->FormatCode(); + } + CleanupStack::PopAndDestroy(extensionMapping); + return EMTPFormatCodeUndefined; + } + + EXPORT_C TUint RMTPUtility::GetEnumerationFlag(const TDesC& aExtension) { CMTPExtensionMapping* extensionMapping = CMTPExtensionMapping::NewL(aExtension, EMTPFormatCodeUndefined); @@ -558,25 +598,14 @@ if ( file.Ext().CompareF( KTxtExtensionODF ) == 0 ) { - RFs tempFsSession; - User::LeaveIfError(tempFsSession.Connect()); - CleanupClosePushL(tempFsSession); - User::LeaveIfError(tempFsSession.ShareProtected()); - - RFile tempFile; - User::LeaveIfError(tempFile.Open(tempFsSession, aFullPath, EFileRead|EFileShareAny)); - CleanupClosePushL(tempFile); - - //CContent* content = CContent::NewL( aFullPath ); - CContent* content = CContent::NewL( tempFile ); + CContent* content = CContent::NewL( aFullPath ); CleanupStack::PushL( content ); // + content HBufC* buffer = HBufC::NewL( KMimeTypeMaxLength ); CleanupStack::PushL( buffer ); // + buffer TPtr data = buffer->Des(); - TInt err = content->GetStringAttribute( EMimeType, data ); - + TInt err = content->GetStringAttribute( ContentAccess::EMimeType, data ); if ( err == KErrNone ) { mimebuf = HBufC::New( buffer->Length() ); @@ -585,8 +614,8 @@ { User::LeaveIfError( KErrNotFound ); } + mimebuf->Des().Copy( *buffer ); - mimebuf->Des().Copy( *buffer ); } // leave if NULL @@ -597,8 +626,6 @@ CleanupStack::PopAndDestroy( buffer ); // - buffer CleanupStack::PopAndDestroy( content ); // - content - CleanupStack::PopAndDestroy(&tempFile); // close - CleanupStack::PopAndDestroy(&tempFsSession); // close } else { @@ -607,65 +634,126 @@ return mimebuf; } +void RMTPUtility::ParseFormatCode(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState) + { + + TLex lex(aString.Mid(2)); //skip 0x + TUint formatCode = EMTPFormatCodeUndefined; + lex.Val(formatCode, EHex); + aMapping.SetFormatCode(static_cast(formatCode)); + aState = Extension; + __FLOG_VA((_L("ParseFormatCode %S, 0x%x"), &aString, formatCode)); + } +void RMTPUtility::ParseExtension(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState) + { + aMapping.SetExtensionL(aString); + aState = EMimeType; + __FLOG_VA((_L("ParseExtension %S"), &aString)); + } +void RMTPUtility::ParseMimeType(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState) + { + aMapping.SetMIMETypeL(aString); + aState = ESubFormatCode; + __FLOG_VA((_L("ParseMimeType %S"), &aString)); + } +void RMTPUtility::ParseSubFormatCode(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState) + { + iEnumFlag = 1; + TUint32 subFormatCode = 0; + if(aString != KNullDesC) + { + if(aString.Length() > 2) //temp code will remove after the correct their format string + { + TLex lex(aString.Mid(2)); //skip 0x + lex.Val(subFormatCode, EHex); + } + else//temp code will remove after the correct their format string + { + TLex lex(aString); + lex.Val(iEnumFlag, EDecimal); + } + } + aMapping.SetSubFormatCode(subFormatCode); + aState = EnumerationFlag; + __FLOG_VA((_L("ParseSubFormatCode %S, 0x%x"), &aString, subFormatCode)); + } +void RMTPUtility::ParseEnumerationFlag(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState) + { + TUint enumFlag = iEnumFlag; //default is delegate to file DP + //temp code(iEnumFlag is temp the value should be 1) will remove after the correct their format string + if(aString != KNullDesC) + { + TLex lex(aString); + lex.Val(enumFlag, EDecimal); + } + aMapping.SetEnumerationFlag(enumFlag); + + __FLOG_VA((_L8("ParseEnumerationFlag %S, %d"), &aString, enumFlag)); + aState = EParseStateEnd; + } +void RMTPUtility::Parse(const TDesC& aString, CMTPExtensionMapping& aMapping, TParseState& aState) + { + switch(aState) + { + case EFormatCode: + ParseFormatCode(aString, aMapping, aState); + break; + case Extension: + ParseExtension(aString, aMapping, aState); + break; + case EMimeType: + ParseMimeType(aString, aMapping, aState); + break; + case ESubFormatCode: + ParseSubFormatCode(aString, aMapping, aState); + break; + case EnumerationFlag: + ParseEnumerationFlag(aString, aMapping, aState); + break; + default: + //do nothing; + break; + } + } -void RMTPUtility::AppendFormatExtensionMapping(const CDesCArray& aFormatExtensionMapping,TUint32 aDpId) +void RMTPUtility::AppendFormatExtensionMappingL(const CDesCArray& aFormatExtensionMapping,TUint32 aDpId) { //Parse the descriptor formatcode,fileextension, e.g. 0x3009:mp3 - TBuf stringSeg; - TInt splitter1(0); - TInt splitter2(0); - TInt found(0); - TUint formatCode = 0; - TUint isNeedFileDp = 1; - - for(TInt i=0; i < aFormatExtensionMapping.Count(); ++i) - { - CMTPExtensionMapping* extensionMapping = CMTPExtensionMapping::NewL(KNullDesC, EMTPFormatCodeUndefined); - CleanupStack::PushL(extensionMapping); - _LIT(KSPLITTER,":"); - splitter1 = aFormatExtensionMapping[i].FindF(KSPLITTER); - //Skip "0x", 2 is the length of "0x" - stringSeg = aFormatExtensionMapping[i].Mid(2, 4); - TLex lex(stringSeg); - User::LeaveIfError(lex.Val(formatCode, EHex)); - //Skip ":" - stringSeg = aFormatExtensionMapping[i].Mid(splitter1 + 1); - splitter2 = stringSeg.FindF(KSPLITTER); - if ( splitter2 == KErrNotFound ) - { - extensionMapping->SetExtensionL(stringSeg); - } - else - { - extensionMapping->SetExtensionL(aFormatExtensionMapping[i].Mid(splitter1+1,splitter2)); - stringSeg = stringSeg.Mid(splitter2+1); - splitter1 = stringSeg.FindF(KSPLITTER); - if ( splitter1==KErrNotFound ) - { - extensionMapping->SetMIMETypeL(stringSeg); - } - else if ( splitter1==0 ) - { - TLex lex1(stringSeg.Mid(splitter1+1)); - User::LeaveIfError(lex1.Val(isNeedFileDp, EDecimal)); - } - else - { - extensionMapping->SetMIMETypeL(stringSeg.Mid(0,splitter1)); - TLex lex2(stringSeg.Mid(splitter1+1)); - User::LeaveIfError(lex2.Val(isNeedFileDp, EDecimal)); - } - - } + //FromatCode:extension:MimeType:SubFormatCode:EnumerationFlag - found = iFormatMappings.FindInOrder(extensionMapping, TLinearOrder(CMTPExtensionMapping::ComparewithMIME)); - if (KErrNotFound == found) - { - extensionMapping->SetFormatCode((TMTPFormatCode)formatCode); - extensionMapping->SetDpId(aDpId); - extensionMapping->SetEnumerationFlag(isNeedFileDp); - iFormatMappings.InsertInOrderL(extensionMapping, TLinearOrder(CMTPExtensionMapping::ComparewithMIME)); - } - CleanupStack::Pop(extensionMapping); - } + TChar spliter(':'); + for(TInt i=0; i < aFormatExtensionMapping.Count(); ++i) + { + CMTPExtensionMapping* extensionMapping = CMTPExtensionMapping::NewL(KNullDesC, EMTPFormatCodeUndefined); + + TParseState state = EFormatCode; + TLex lex(aFormatExtensionMapping[i]); + lex.Mark(); + while(!lex.Eos()) + { + if(lex.Peek() == spliter) + { + Parse(lex.MarkedToken(), *extensionMapping, state); + lex.Inc(); //skip : + lex.Mark(); + } + else + { + lex.Inc(); //move to next char + } + } + while(state < EParseStateEnd) + { + Parse(lex.MarkedToken(), *extensionMapping, state); + lex.Mark(); + } + extensionMapping->SetDpId(aDpId); + if(iFormatMappings.InsertInOrder(extensionMapping, TLinearOrder(CMTPExtensionMapping::ComparewithMIME)) != KErrNone) + { + delete extensionMapping; + } + } } + + + diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/dataproviders/proxydp/src/cmtpdeleteobject.cpp --- a/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpdeleteobject.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpdeleteobject.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -19,6 +19,7 @@ #include #include #include +#include #include "cmtpdataprovider.h" #include "cmtpdataprovidercontroller.h" @@ -98,10 +99,6 @@ { __FLOG(_L8("CheckRequestL - Entry")); TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL(); - if ((EMTPRespCodeOK == responseCode) && (iSingletons.DpController().EnumerateState() == CMTPDataProviderController::EEnumeratingSubDirFiles)) - { - responseCode = EMTPRespCodeDeviceBusy; - } __FLOG_VA((_L8("CheckRequestL - Exit with responseCode = 0x%04X"), responseCode)); return responseCode; @@ -119,6 +116,27 @@ router.ParseOperationRequestL(params); router.RouteOperationRequestL(params, iTargetDps); + if (iSingletons.DpController().EnumerateState() == CMTPDataProviderController::EEnumeratingSubDirFiles) + { + TBool hasBaseFileSystemDp = EFalse; + for(TInt i=0; iUint(CMTPObjectMetaData::EStorageId))) + { + iResponseCode = EMTPRespCodeAccessDenied; + } else { RArray targets; diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/datatypes/src/cmtptypefile.cpp --- a/mtpfws/mtpfw/datatypes/src/cmtptypefile.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/datatypes/src/cmtptypefile.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -197,11 +197,20 @@ //Read the threshold value from Central Repository and check against it CRepository* repository(NULL); - TInt thresholdValue(0); + TInt64 thresholdValue(0); TRAPD(err,repository = CRepository::NewL(KCRUidUiklaf)); if (err == KErrNone) { - if (driveNo == EDriveC) + if (driveNo == EDriveE || driveNo == EDriveF) + { + TInt warningValue(0); + err = repository->Get(KUikOODDiskFreeSpaceWarningNoteLevelMassMemory,warningValue); + if (err == KErrNone) + { + thresholdValue = warningValue + KFreeSpaceExtraReserved; + } + } + else { TInt warningUsagePercent(0); err = repository->Get(KUikOODDiskFreeSpaceWarningNoteLevel,warningUsagePercent); @@ -211,14 +220,7 @@ + KFreeSpaceExtraReserved; } } - else - { - err = repository->Get(KUikOODDiskFreeSpaceWarningNoteLevelMassMemory,thresholdValue); - if (err == KErrNone) - { - thresholdValue += KFreeSpaceExtraReserved; - } - } + delete repository; } diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/src/cmtpconnection.cpp --- a/mtpfws/mtpfw/src/cmtpconnection.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/src/cmtpconnection.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -329,6 +329,8 @@ if (aMTPId != KMTPSessionNone) { // Notify the data providers if other than the null session is closing. + // OpenSession Command coming and now it is really connected to host. + PublishConnState(EConnectedToHost); TMTPNotificationParamsSessionChange params = {aMTPId, *this}; iSingletons.DpController().NotifyDataProvidersL(EMTPSessionOpened, ¶ms); } @@ -406,7 +408,7 @@ iTransportConnection = &aTransportConnection; iTransportConnection->BindL(*this); SetState(EStateOpen); - PublishConnState(EConnectedToHost); + } __FLOG(_L8("ConnectionResumed - Exit")); diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/src/cmtpconnectionmgr.cpp --- a/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -182,7 +182,7 @@ { iTransport->Stop(*this); delete iTransport; - + iTransportCount--; iTransport = CMTPTransportPlugin::NewL(aTransport, aParameter); TRAPD(err, iTransport->StartL(*this)); @@ -191,11 +191,12 @@ __FLOG_VA( ( _L8("StartTransportL error, error code = %d"), err) ); delete iTransport; iTransport = NULL; + User::Leave(err); } + iTransportCount++; iTransportUid = aTransport; - iTransportCount++; } } diff -r 3673b591050c -r ef55b168cedb mtpfws/mtpfw/src/cmtpdeltadatamgr.cpp --- a/mtpfws/mtpfw/src/cmtpdeltadatamgr.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtpfws/mtpfw/src/cmtpdeltadatamgr.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -291,7 +291,7 @@ TInt64 puidlow = 1; TBuf8 puidBuffer; - for(TInt count=0;count puidBuffer; - for(TInt count=0;count puidBuffer; - for(TInt count=0;count puidBuffer; - for(TInt count=0;count +#include +#include "mtpdebug.h" + +class CMTPOperator; + +class CMTPControllerTimer : public CTimer + { +private: + + enum { ETimerMultiplier = 1000000 }; + +public: + static CMTPControllerTimer* NewLC( RMTPClient& aMTPClient, CMTPOperator& aMTPOperator ); + static CMTPControllerTimer* NewL( RMTPClient& aMTPClient , CMTPOperator& aMTPOperator ); + void Start( TInt aTimeOut ); + TBool GetStopTransportStatus(); + ~CMTPControllerTimer(); + +private: + CMTPControllerTimer(RMTPClient& aMTPClient, CMTPOperator& aMTPOperator); + void ConstructL(); + void RunL(); + +private: + __FLOG_DECLARATION_MEMBER_MUTABLE; + + RMTPClient& iMTPClient; + CMTPOperator * iMTPOperator; + TBool iStopTransport; + + }; + + +#endif /* CMTPCONTROLLERTIMER_H_ */ diff -r 3673b591050c -r ef55b168cedb mtptransports/mtpcontroller/inc/cmtpoperator.h --- a/mtptransports/mtpcontroller/inc/cmtpoperator.h Wed Apr 14 16:49:36 2010 +0300 +++ b/mtptransports/mtpcontroller/inc/cmtpoperator.h Tue Apr 27 17:30:23 2010 +0300 @@ -24,10 +24,14 @@ #define CMTPOPERATOR_H_ #include -#include +#include + #include "mmtpoperatornotifier.h" +#include "cmtpcontrollertimer.h" #include "mtpdebug.h" + + NONSHARABLE_CLASS( CMTPOperator ) : public CActive { private: @@ -52,6 +56,9 @@ void StartTransport( TUid aTransport ); void StopTransport( TUid aTransport ); + void StartTimer (TInt aSecond); + void SubscribeConnState(); + private:// From CActive void DoCancel(); void RunL(); @@ -62,6 +69,7 @@ TInt AppendOperation( TOperationType aType, TUid aTransport ); void Schedule( TInt aError ); void HandleOperationL( const TOperation& aOperation ); + private: /** * FLOGGER debug trace member variable. @@ -73,6 +81,19 @@ RArray< TOperation > iPendingOperations; RMTPClient iMTPClient; + + RProperty iProperty; + + TBool iConSubscribed; + + TInt iConnState; + + CMTPControllerTimer* iTimer; + }; + +const TInt KInitialValue = -1; +const TInt KStopMTPSeconds = 30; + #endif /* CMTPOPERATOR_H_ */ diff -r 3673b591050c -r ef55b168cedb mtptransports/mtpcontroller/src/cmtpcontrollertimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mtptransports/mtpcontroller/src/cmtpcontrollertimer.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -0,0 +1,97 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + + +/** + @file + @internalComponent +*/ + +#include "cmtpcontrollertimer.h" +#include "cmtpoperator.h" + +__FLOG_STMT( _LIT8( KComponent, "mtpConTimer" ); ) + +const TUid KMTPBtTransportUid = { 0x10286FCB }; +const TInt KStartMTPSeconds = 7; + +CMTPControllerTimer* CMTPControllerTimer::NewLC( RMTPClient& aMTPClient, CMTPOperator & aMTPOperator ) + { + CMTPControllerTimer* self = new(ELeave) CMTPControllerTimer( aMTPClient, aMTPOperator ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +CMTPControllerTimer* CMTPControllerTimer::NewL( RMTPClient& aMTPClient, CMTPOperator & aMTPOperator ) + { + CMTPControllerTimer* self = NewLC( aMTPClient, aMTPOperator ); + CleanupStack::Pop( self ); + return self; + } + +void CMTPControllerTimer::Start( TInt aTimeOut ) + { + CTimer::After( aTimeOut * ETimerMultiplier ); + } + +TBool CMTPControllerTimer::GetStopTransportStatus() + { + return iStopTransport; + } + +CMTPControllerTimer::~CMTPControllerTimer() + { + __FLOG( _L8("CMPTControllerTimer destruction") ); + __FLOG_CLOSE; + } + +CMTPControllerTimer::CMTPControllerTimer( RMTPClient& aMTPClient, CMTPOperator& aMTPOperator ): + CTimer( CActive::EPriorityStandard ), iMTPClient(aMTPClient) + { + __FLOG_OPEN( KMTPSubsystem, KComponent ); + iMTPOperator = &aMTPOperator; + } + +void CMTPControllerTimer::ConstructL() + { + CTimer::ConstructL(); + CActiveScheduler::Add( this ); + iStopTransport = EFalse; + __FLOG( _L8("CMPTControllerTimer construction") ); + } + +void CMTPControllerTimer::RunL() + { + if (KErrNone == iMTPClient.IsProcessRunning() && !iStopTransport) + { + __FLOG( _L8("Stop transport to shut down mtp server") ); + TInt error = iMTPClient.StopTransport(KMTPBtTransportUid); + iMTPClient.Close(); + iStopTransport = ETrue; + __FLOG_1( _L8("The return value of stop transport is: %d"), error ); + iMTPOperator->StartTimer(KStartMTPSeconds); + } + else + { + __FLOG( _L8("Start transport to launch mtp server") ); + + iMTPClient.Connect(); + iMTPClient.StartTransport(KMTPBtTransportUid); + iStopTransport = EFalse; + iMTPOperator->SubscribeConnState(); + } + } diff -r 3673b591050c -r ef55b168cedb mtptransports/mtpcontroller/src/cmtpoperator.cpp --- a/mtptransports/mtpcontroller/src/cmtpoperator.cpp Wed Apr 14 16:49:36 2010 +0300 +++ b/mtptransports/mtpcontroller/src/cmtpoperator.cpp Tue Apr 27 17:30:23 2010 +0300 @@ -24,6 +24,7 @@ __FLOG_STMT( _LIT8( KComponent, "mtpoperator" ); ) + CMTPOperator* CMTPOperator::NewL( MMTPOperatorNotifier& aNotifier ) { CMTPOperator* self = new( ELeave ) CMTPOperator( aNotifier ); @@ -37,6 +38,8 @@ iPendingOperations.Reset(); iPendingOperations.Close(); iMTPClient.Close(); + iProperty.Close(); + delete iTimer; __FLOG( _L8("+/-Dtor") ); __FLOG_CLOSE; } @@ -44,6 +47,7 @@ void CMTPOperator::StartTransport( TUid aTransport ) { __FLOG_1( _L8("+/-StartTransport( 0x%08X )"), aTransport.iUid ); + TInt err = AppendOperation( EStartTransport, aTransport ); if ( KErrNone != err ) { @@ -61,23 +65,82 @@ } } +void CMTPOperator::StartTimer(TInt aSecond) + { + __FLOG(_L8("StartTimer in cmtpoperator!")); + iTimer->Start(aSecond); + } + void CMTPOperator::DoCancel() { __FLOG( _L8("+/-DoCancel") ); + iProperty.Cancel(); + iConSubscribed = EFalse; } void CMTPOperator::RunL() { __FLOG( _L8("+RunL") ); + iConSubscribed = EFalse; TInt count = iPendingOperations.Count(); + + TInt connState = KInitialValue; + if ( count > 0 ) { TOperation& operation = iPendingOperations[0]; TRAP_IGNORE( HandleOperationL( operation ) ); iPendingOperations.Remove( 0 ); } - + else + { + //this will go on to get the updated connection status. + SubscribeConnState(); + + + TInt error = iProperty.Get(KMTPPublishConnStateCat, EMTPConnStateKey, connState); + __FLOG_2(_L8("Before, the iConnState is %d and connState is %d"), iConnState, connState); + if ( KErrNotFound == error ) + { + iConnState = KInitialValue; + __FLOG( _L8("The key is deleted and mtp server shut down!") ); + } + else + { + if (iTimer->IsActive() && !iTimer->GetStopTransportStatus()) + { + __FLOG( _L8("Timer is cancelled!") ); + iTimer->Cancel(); + } + //if the disconnect is not set, set the disconnect + //else if the connState is disconnect, launch the timer to restart the server to unload dps. + if ( KInitialValue == iConnState ) + { + iConnState = connState; + __FLOG( _L8("the first time to launch mtp") ); + } + else + { + if (EDisconnectedFromHost == connState) + { + iConnState = connState; + if (!iTimer->IsActive()) + { + iTimer->Start(KStopMTPSeconds); + } + __FLOG( _L8("Timer is launched.") ); + } + else + { + + iConnState = connState; + } + } + } + __FLOG_2(_L8("After, the iConnState is %d and connState is %d"), iConnState, connState); + } + __FLOG( _L8("-RunL") ); } @@ -93,7 +156,21 @@ { __FLOG( _L8("+ConstructL") ); CActiveScheduler::Add( this ); + //if the server is running, the first disconnction shows the conection is down! + if(KErrNone == iMTPClient.IsProcessRunning()) + { + iConnState = EDisconnectedFromHost; + } + else + { + iConnState = KInitialValue; + } + __FLOG_1( _L8("The connstate is set to %d"), iConnState ); User::LeaveIfError( iMTPClient.Connect() ); + User::LeaveIfError(iProperty.Attach(KMTPPublishConnStateCat, EMTPConnStateKey)); + iTimer = CMTPControllerTimer::NewL(iMTPClient, *this); + + iConSubscribed = EFalse; __FLOG( _L8("-ConstructL") ); } @@ -101,17 +178,33 @@ { TOperation operation = { aType, aTransport }; TInt err = iPendingOperations.Append( operation ); + __FLOG_1( _L8("+AppendOperation returns %d"), err ); if ( ( KErrNone == err ) && !IsActive() ) { Schedule( KErrNone ); } - __FLOG_1( _L8("+/-AppendOperation returns %d"), err ); + else + { + if (iConSubscribed) + { + Cancel(); + if (KErrNone == err) + { + Schedule( KErrNone ); + } + } + } + __FLOG( _L8("-AppendOperation") ); return err; } void CMTPOperator::Schedule( TInt aError ) { __FLOG_1( _L8("+/-Schedule( %d )"), aError ); + if(iTimer->IsActive()) + { + iTimer->Cancel(); + } TRequestStatus* status = &iStatus; User::RequestComplete( status, aError ); SetActive(); @@ -126,13 +219,31 @@ case EStartTransport: err = iMTPClient.StartTransport( aOperation.iTransport ); iNotifier.HandleStartTrasnportCompleteL( err ); + SubscribeConnState(); break; default: __ASSERT_DEBUG( ( EStopTransport == aOperation.iType ), User::Invariant() ); - err = iMTPClient.StopTransport( aOperation.iTransport ); + if(!iTimer->GetStopTransportStatus()) + { + err = iMTPClient.StopTransport( aOperation.iTransport ); + } + iNotifier.HandleStopTrasnportCompleteL( err ); break; } __FLOG( _L8("-HandleOperationL") ); } +void CMTPOperator::SubscribeConnState() + { + if(!IsActive()) + { + __FLOG( _L8("Subscribe connection state changed)") ); + iProperty.Subscribe(iStatus); + iConSubscribed = ETrue; + SetActive(); + } + + } + +