Revision: 201004 RCL_3 PDK_3.0.0
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 25 May 2010 13:35:25 +0300
branchRCL_3
changeset 24 523717cdb0ad
parent 23 f5809cfbf6d5
child 27 81da3301b632
Revision: 201004 Kit: 2010121
backupandrestore/backupengine/src/sbebufferhandler.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectinfo.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectproplist.cpp
mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropvalue.cpp
mtpfws/mtpfw/common/inc/uiklafinternalcrkeys.h
mtpfws/mtpfw/daemon/server/group/mtpserver.mmp
mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp
mtpfws/mtpfw/datatypes/group/mtpdatatypes.mmp
mtpfws/mtpfw/datatypes/interface/cmtptypefile.h
mtpfws/mtpfw/datatypes/src/cmtptypefile.cpp
mtpfws/mtpfw/inc/cmtpconnectionmgr.h
mtpfws/mtpfw/inc/mtpframeworkconst.h
mtpfws/mtpfw/src/cmtpconnectionmgr.cpp
mtpfws/mtpfw/src/cmtpdataprovider.cpp
mtpfws/mtpfw/src/cmtpobjectstore.cpp
mtpfws/mtpfw/src/cmtpstoragemgr.cpp
mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbase.h
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp
mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp
--- a/backupandrestore/backupengine/src/sbebufferhandler.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/backupandrestore/backupengine/src/sbebufferhandler.cpp	Tue May 25 13:35:25 2010 +0300
@@ -508,11 +508,29 @@
             __LOG1("CBufferFileReader::WriteToFile() - making directory resulted in fatal error: %d", err);
 			User::Leave(err);
 			} // if
-
-        
+		
+		TEntry entry;
+		TBool isReadOnly = EFalse;
+		err = iFs.Entry(iFileName, entry);
+		if(KErrNone == err)
+			{
+			if(entry.iAtt & KEntryAttReadOnly)
+				{
+				isReadOnly = ETrue;
+				entry.iAtt &= ~KEntryAttReadOnly;
+				iFs.SetAtt(iFileName, entry.iAtt, ~entry.iAtt);
+				}
+			}				
+				
         err = iFileHandle.Replace(iFs, iFileName, EFileWrite);
         __LOG1("CBufferFileReader::WriteToFile() - replacing file returned err: %d", err);
         User::LeaveIfError( err );
+        
+        if(isReadOnly)
+        	{
+			entry.iAtt |= KEntryAttReadOnly;
+        	iFs.SetAtt(iFileName, entry.iAtt, ~entry.iAtt);
+        	}
 			
 		iFileOpen = ETrue;
         __LOG("CBufferFileReader::RecreateFileL() - END");
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectinfo.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectinfo.cpp	Tue May 25 13:35:25 2010 +0300
@@ -114,17 +114,17 @@
     iObjectPropertyMgr.SetCurrentObjectL(*iObjectMeta, EFalse);
     
     //1. storage id
-    TUint32 storageId;
+    TUint32 storageId(0);
     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeStorageID, storageId);
     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EStorageID, storageId);	
     
     //2. object format
-    TUint16 format;
+    TUint16 format(0);
     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeObjectFormat, format);
     iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EObjectFormat, format);
     
     //3. protection status,
-    TUint16 protection;
+    TUint16 protection(0);
     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeProtectionStatus, protection);
     iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EProtectionStatus, protection);
     
@@ -138,10 +138,10 @@
     //9. image pix width
     //10. image pix height
     //11. image bit depth
-    TUint16 thumbFormat;
+    TUint16 thumbFormat(0);
     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleFormat, thumbFormat);
     iObjectInfoToBuild->SetUint16L(CMTPTypeObjectInfo::EThumbFormat, thumbFormat);
-    TUint32 value;
+    TUint32 value(0);
     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleSize, value);
     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EThumbCompressedSize, value);
     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleWidth, value);
@@ -157,7 +157,7 @@
     iObjectInfoToBuild->SetUint32L(CMTPTypeObjectInfo::EImageBitDepth, value);
     
     //12. Parent object
-    TUint32 parent;
+    TUint32 parent(0);
     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeParentObject, parent);
     if(KMTPHandleNoParent == parent)
         {
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectproplist.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectproplist.cpp	Tue May 25 13:35:25 2010 +0300
@@ -363,7 +363,7 @@
         case EMTPObjectPropCodeRepresentativeSampleHeight:
         case EMTPObjectPropCodeRepresentativeSampleWidth:
             {
-            TUint32 value;
+            TUint32 value(0);
             iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), value, EFalse);
             CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, propCode); 
             propElem.SetUint32L(CMTPTypeObjectPropListElement::EValue, value);
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropvalue.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropvalue.cpp	Tue May 25 13:35:25 2010 +0300
@@ -314,7 +314,7 @@
 
 void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleSizeL()
     {
-    TUint32 representativeSampleSize;
+    TUint32 representativeSampleSize(0);
     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleSize, representativeSampleSize, EFalse);
     iMTPTypeUint32.Set(representativeSampleSize);
     
--- a/mtpfws/mtpfw/common/inc/uiklafinternalcrkeys.h	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/common/inc/uiklafinternalcrkeys.h	Tue May 25 13:35:25 2010 +0300
@@ -69,6 +69,25 @@
  */
 const TUint32 KUikOODDiskFreeSpaceWarningNoteLevelMassMemory = 0x00000007;
 
+#ifdef __MTP_NAVIENGINE_TEST
+//The free size of C-Drive of NaviEngine env is less than 21M,
+//it will block many ONB test cases
+const TInt KFreeSpaceThreshHoldDefaultValue(0);
+const TInt KFreeSpaceExtraReserved(0);
+
+#else
+//MTP should reserve some disk space to prevent OOD(Out of Disk) monitor 
+//popup 'Out of memory' note.When syncing music through ovi player,
+//sometimes device screen get freeze with this note
+//Be default, this value is read from Central Respository, if error while
+//reading, use this one
+const TInt KFreeSpaceThreshHoldDefaultValue(20*1024*1024);//20M bytes
+
+//Beside the OOD threshold value, we need to reserve extra disk space
+//for harvest server do the harvest, set this as 1M
+const TInt KFreeSpaceExtraReserved(1024*1024);//1M bytes
+
+#endif
 
 #endif __UIKLAF_INTERNAL_CR_KEYS_H__
 
--- a/mtpfws/mtpfw/daemon/server/group/mtpserver.mmp	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/daemon/server/group/mtpserver.mmp	Tue May 25 13:35:25 2010 +0300
@@ -29,6 +29,8 @@
 EPOCHEAPSIZE        0x80000   0x800000   // 8MB
 #endif
 
+EPOCSTACKSIZE       0x5000
+
 MW_LAYER_SYSTEMINCLUDE_SYMBIAN
 
 USERINCLUDE         ../inc/ 
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp	Tue May 25 13:35:25 2010 +0300
@@ -717,7 +717,7 @@
             iFullPath.LowerCase();
             __FLOG_VA((_L8("File Name %S"), &iFullPath));
             TParsePtrC file( iFullPath );
-            if ( file.ExtPresent() && iExceptionList.Find(file.Ext()) != KErrNotFound)
+            if ( file.ExtPresent() && file.Ext().Length()<=KExtensionLength && iExceptionList.Find(file.Ext()) != KErrNotFound)
                 {
                 TUint32 DpId = iFramework.DataProviderId();
                 HBufC* mime = iDpSingletons.MTPUtility().ContainerMimeType(iFullPath);
--- a/mtpfws/mtpfw/datatypes/group/mtpdatatypes.mmp	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/datatypes/group/mtpdatatypes.mmp	Tue May 25 13:35:25 2010 +0300
@@ -39,8 +39,7 @@
 USERINCLUDE     ../inc
 //For UiklafInternalCRKeys.h,should be removed, after we switched to DFs
 USERINCLUDE		../../common/inc
-//For mtpframeworkconst.h
-USERINCLUDE		../../inc
+
 
 SOURCEPATH      ../src
 SOURCE          cmtptypearray.cpp
--- a/mtpfws/mtpfw/datatypes/interface/cmtptypefile.h	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/datatypes/interface/cmtptypefile.h	Tue May 25 13:35:25 2010 +0300
@@ -96,9 +96,9 @@
 	IMPORT_C TInt64 GetByteSent();
     
 private:
-    CMTPTypeFile();
-    void ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode);
-	void ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet);
+    CMTPTypeFile(RFs& aFs);
+    void ConstructL(const TDesC& aName, TFileMode aMode);
+	void ConstructL(const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet);
     void ToggleRdWrBuffer();
 
 protected: // From CActive
@@ -108,8 +108,10 @@
 	
     TInt RunError(TInt aError);
     void RunL();
+    
 private:
 
+    
     /**
     The read and write data stream states.
     */
@@ -213,6 +215,7 @@
      */
     CFileWriter    *iFileWriter2;
 
+    RFs&            iFs;
     };
     
 #endif // CMTPTYPEFILE_H
--- a/mtpfws/mtpfw/datatypes/src/cmtptypefile.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/datatypes/src/cmtptypefile.cpp	Tue May 25 13:35:25 2010 +0300
@@ -21,8 +21,6 @@
 #include <mtp/cmtptypefile.h>
 #include <mtp/mtpdatatypeconstants.h>
 
-#include "mtpframeworkconst.h"
-
 //This file is exported from s60 sdk, now just copy it
 //to make sure onb can run
 #include "UiklafInternalCRKeys.h"
@@ -141,9 +139,9 @@
  */
 EXPORT_C CMTPTypeFile* CMTPTypeFile::NewLC(RFs& aFs, const TDesC& aName, TFileMode aMode)
     {
-    CMTPTypeFile* self = new(ELeave) CMTPTypeFile;
+    CMTPTypeFile* self = new(ELeave) CMTPTypeFile(aFs);
     CleanupStack::PushL(self);
-    self->ConstructL(aFs, aName, aMode);
+    self->ConstructL(aName, aMode);
     return self;
     }
 
@@ -156,9 +154,9 @@
 
 EXPORT_C CMTPTypeFile* CMTPTypeFile::NewLC(RFs& aFs, const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet)
     {
-    CMTPTypeFile* self = new(ELeave) CMTPTypeFile;
+    CMTPTypeFile* self = new(ELeave) CMTPTypeFile(aFs);
     CleanupStack::PushL(self);
-    self->ConstructL(aFs, aName, aMode, aRequiredSize, aOffSet);
+    self->ConstructL(aName, aMode, aRequiredSize, aOffSet);
     return self;
     }
 
@@ -188,12 +186,10 @@
     //file syncing
     TInt driveNo;
     TDriveInfo driveInfo;
-    iFile.Drive(driveNo,driveInfo);
-    RFs fs;
+    User::LeaveIfError(iFile.Drive(driveNo,driveInfo));
+    
     TVolumeInfo volumeInfo;
-    fs.Connect();
-    fs.Volume(volumeInfo,driveNo);
-    fs.Close();
+    User::LeaveIfError(iFs.Volume(volumeInfo,driveNo));
     
     //Read the threshold value from Central Repository and check against it
     CRepository* repository(NULL);
@@ -571,28 +567,29 @@
     return iByteSent;
     }
 
-CMTPTypeFile::CMTPTypeFile() :
+CMTPTypeFile::CMTPTypeFile(RFs& aFs) :
     CActive(EPriorityUserInput), iBuffer1AvailForWrite(ETrue),
-        iFileRdWrError(EFalse), iCurrentCommitChunk(NULL, 0)
+        iFileRdWrError(EFalse), iCurrentCommitChunk(NULL, 0),
+        iFs(aFs)
     {
     CActiveScheduler::Add(this);
     }
 
-void CMTPTypeFile::ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode)
+void CMTPTypeFile::ConstructL(const TDesC& aName, TFileMode aMode)
     {
     if (aMode & EFileWrite)
         {
         iFileOpenForRead = EFalse;
-        TInt err = iFile.Create(aFs, aName, aMode|EFileWriteDirectIO);
+        TInt err = iFile.Create(iFs, aName, aMode|EFileWriteDirectIO);
         if (err != KErrNone)
             {
-            User::LeaveIfError(iFile.Replace(aFs, aName, aMode|EFileWriteDirectIO));
+            User::LeaveIfError(iFile.Replace(iFs, aName, aMode|EFileWriteDirectIO));
             }
         }
     else
         {
         iFileOpenForRead = ETrue;
-        User::LeaveIfError(iFile.Open(aFs, aName, aMode|EFileReadDirectIO|EFileShareReadersOnly));
+        User::LeaveIfError(iFile.Open(iFs, aName, aMode|EFileReadDirectIO|EFileShareReadersOnly));
 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
         TInt64 size = 0;
 #else
@@ -615,22 +612,22 @@
         }
     }
 
-void CMTPTypeFile::ConstructL(RFs& aFs, const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet)
+void CMTPTypeFile::ConstructL(const TDesC& aName, TFileMode aMode, TInt64 aRequiredSize, TInt64 aOffSet)
 	{
     if (aMode & EFileWrite)
         {
         iFileOpenForRead = EFalse;
-        TInt err = iFile.Create(aFs, aName, aMode|EFileWriteDirectIO);
+        TInt err = iFile.Create(iFs, aName, aMode|EFileWriteDirectIO);
         if (err != KErrNone)
             {
-            User::LeaveIfError(iFile.Replace(aFs, aName, aMode|EFileWriteDirectIO));
+            User::LeaveIfError(iFile.Replace(iFs, aName, aMode|EFileWriteDirectIO));
             }
         }
     else
         {
         iFileOpenForRead = ETrue;
         iOffSet = aOffSet;
-        User::LeaveIfError(iFile.Open(aFs, aName, aMode|EFileReadDirectIO|EFileShareReadersOnly));
+        User::LeaveIfError(iFile.Open(iFs, aName, aMode|EFileReadDirectIO|EFileShareReadersOnly));
 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
         TInt64 size = 0;
 #else
--- a/mtpfws/mtpfw/inc/cmtpconnectionmgr.h	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/inc/cmtpconnectionmgr.h	Tue May 25 13:35:25 2010 +0300
@@ -111,6 +111,10 @@
     TMTPBTRemoteDevice iRemoteDevice;
     
     /**
+     * Set ETrue when Resumetransport need to be called.
+     */
+    TBool                           iResumeCalled;
+    /**
     FLOGGER debug trace member variable.
     */
     __FLOG_DECLARATION_MEMBER_MUTABLE;
--- a/mtpfws/mtpfw/inc/mtpframeworkconst.h	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/inc/mtpframeworkconst.h	Tue May 25 13:35:25 2010 +0300
@@ -81,14 +81,5 @@
 */
 const TUint KMTPProxyDPID = 2; 
 
-//MTP should reserve some disk space to prevent OOD(Out of Disk) monitor 
-//popup 'Out of memory' note.When syncing music through ovi player,
-//sometimes device screen get freeze with this note
-//Be default, this value is read from Central Respository, if error while
-//reading, use this one
-const TInt KFreeSpaceThreshHoldDefaultValue(20*1024*1024);//20M bytes
 
-//Beside the OOD threshold value, we need to reserve extra disk space
-//for harvest server do the harvest, set this as 1M
-const TInt KFreeSpaceExtraReserved(1024*1024);//1M bytes
 #endif // MTPFRAMEWORKCONST_H
--- a/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp	Tue May 25 13:35:25 2010 +0300
@@ -24,6 +24,9 @@
 // Class constants.
 __FLOG_STMT(_LIT8(KComponent,"ConnectionMgr");)
 
+const TUint KMTPUsbTransportUid  = 0x102827B2;
+const TUint KMTPBTTransportUid  = 0x10286FCB;
+
 /**
 CMTPConnectionMgr factory method.
 @leave If a failure occurs, one of the system wide error codes.
@@ -97,17 +100,25 @@
 void CMTPConnectionMgr::ConnectionCloseComplete(const TUint& /*aConnUid*/)
     {
     __FLOG(_L8("ConnectionCloseComplete - Entry"));
-    ResumeSuspendedTransport();
+    if (iTransportUid.iUid != KMTPUsbTransportUid )
+        {
+        ResumeSuspendedTransport();
+        }
+    else
+        {
+        iResumeCalled = ETrue;
+        }
+    
     __FLOG(_L8("ConnectionCloseComplete - exit"));
     }
 
 EXPORT_C void CMTPConnectionMgr::StartTransportL(TUid aTransport)
     {
-    
-    TInt32 bluetoothUid = 0x10286FCB;
-    
+    __FLOG(_L8("StartTransportL - Entry"));
+  
     RUsb usb;
     User::LeaveIfError(usb.Connect());
+    __FLOG(_L8("after connect, and before call get currentpersonalityid"));
     TInt usbMode;
     TUsbServiceState usbStat;
     TInt err = usb.GetCurrentPersonalityId(usbMode);
@@ -133,7 +144,7 @@
     
     
     //When USB plug out, BT will start Master mode to reconnect remote device. Else BT will start slave mode to listen connection.
-    if(aTransport.iUid == bluetoothUid && iRemoteDevice.iDeviceAddr != 0 && aTransport != iTransportUid)
+    if(aTransport.iUid == KMTPBTTransportUid && iRemoteDevice.iDeviceAddr != 0 && aTransport != iTransportUid)
         {
         __FLOG(_L8("StartTransportL with parameter!"));
         TMTPBTRemoteDeviceBuf tmpdata(iRemoteDevice);
@@ -146,7 +157,7 @@
         __FLOG(_L8("StartTransportL without parameter!"));
         StartTransportL( aTransport, NULL );
         }
-    
+    __FLOG(_L8("StartTransportL - Exit"));
     }
 
 /**
@@ -163,8 +174,6 @@
     {
     __FLOG(_L8("StartTransportL - Entry"));
     
-    TInt32 bluetoothUid = 0x10286FCB;
-    
     if (iTransport)
         {
         __FLOG(_L8("The transport is not none."));
@@ -177,7 +186,7 @@
         else
             {
             __FLOG_1(_L8("Relaunch the transport 0x%X"), iTransportUid.iUid);
-            if(aTransport.iUid == bluetoothUid)
+            if(aTransport.iUid == KMTPBTTransportUid)
                 {
                 iTransport->Stop(*this);
                 delete iTransport;
@@ -217,7 +226,7 @@
         
         iTransportCount++;
         
-        if(iTransportUid.iUid != bluetoothUid)
+        if(iTransportUid.iUid != KMTPBTTransportUid)
             {
             UnsuspendTransport( iTransportUid );
             }
@@ -272,7 +281,9 @@
 	
 
     __FLOG_1(_L8("aTransport is 0x%X"), aTransport.iUid);
-    __FLOG_1(_L8("iTransportUid is 0x%X"), aTransport.iUid);
+    __FLOG_1(_L8("iTransportUid is 0x%X"), iTransportUid.iUid);
+    
+    TInt transportId = iTransportUid.iUid;
 
     if ( aByBearer )
         {
@@ -290,6 +301,13 @@
         iTransport = NULL;
         iTransportUid = KNullUid;
         iTransportCount--;
+        //To be sure Resume is done after StopTransport
+        if( transportId == KMTPUsbTransportUid && iResumeCalled)
+            {
+            ResumeSuspendedTransport();
+			iResumeCalled = EFalse;            
+            }
+
         }
     
 	__FLOG(_L8("StopTransport - Exit"));
@@ -390,6 +408,7 @@
     __FLOG_OPEN(KMTPSubsystem, KComponent);
     iRemoteDevice.iDeviceAddr = 0;
     iRemoteDevice.iDeviceServicePort = 0;
+    iResumeCalled = EFalse;
     }
 
 /**
@@ -471,21 +490,28 @@
     __FLOG_1(_L8("The count number is %d"), count);
     __FLOG_1(_L8("The transportport id is 0x%X"), iTransportUid.iUid);
     
-    TInt32 bluetoothUid = 0x10286FCB;
-    
     if ( ( count > 0 )
         // If the transport was just switched and suspended, it shouldn't be resumed.
-        && (( iTransportUid != iSuspendedTransports[count-1] ) || iTransportUid.iUid == bluetoothUid))
+        && (( iTransportUid != iSuspendedTransports[count-1] ) || iTransportUid.iUid == KMTPBTTransportUid))
         {
         __FLOG( _L8("Found suspended transport(s).") );
         if ( !iTransportTrigger )
             {
             iTransportTrigger = new( ELeave ) CAsyncCallBack( CActive::EPriorityStandard );
             }
-        __ASSERT_DEBUG( ( !iTransportTrigger->IsActive() ), User::Invariant() );
-        TCallBack callback( CMTPConnectionMgr::DoResumeSuspendedTransport, this );
-        iTransportTrigger->Set( callback );
-        iTransportTrigger->CallBack();
+       
+        if ( !iTransportTrigger->IsActive())
+            {
+            __FLOG( _L8("Set call back function!") );
+            TCallBack callback( CMTPConnectionMgr::DoResumeSuspendedTransport, this );
+            iTransportTrigger->Set( callback );
+            iTransportTrigger->CallBack();            
+            }
+        else
+            {
+            __FLOG( _L8("Call back has been set!") );
+            }
+
         }
     __FLOG( _L8("-ResumeSuspendedTransport") );
     }
--- a/mtpfws/mtpfw/src/cmtpdataprovider.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/src/cmtpdataprovider.cpp	Tue May 25 13:35:25 2010 +0300
@@ -616,7 +616,8 @@
 		else if (iSingletons.DpController().EnumerateState() < CMTPDataProviderController::EEnumeratingPhaseOneDone)
     	{
         __FLOG(_L8("DP Enumeration is not complete"));
-
+        if (iCurrentRequest != NULL)
+        {
         TUint16 opCode = iCurrentRequest->Uint16(TMTPTypeRequest::ERequestOperationCode);
 
         switch(opCode)
@@ -669,6 +670,7 @@
 	  default:
 		  break;
 		    }
+        }
 	    }
 		}
     else
@@ -678,16 +680,19 @@
         
         //Make ActiveRequest processor and CancelRequest processing to occur synchronously
         if( iCurrentTransactionPhase == ERequestPhase )
-        	{
-        	CMTPSession& session(static_cast<CMTPSession&>(iCurrentConnection->SessionWithMTPIdL(iCurrentRequest->Uint32(TMTPTypeRequest::ERequestSessionID))));
-        	MMTPConnectionProtocol& connection(static_cast<MMTPConnectionProtocol&>(*iCurrentConnection)); 
+            {
+                if( iCurrentRequest != NULL )
+                	{  
+        	        CMTPSession& session(static_cast<CMTPSession&>(iCurrentConnection->SessionWithMTPIdL(iCurrentRequest->Uint32(TMTPTypeRequest::ERequestSessionID))));
+        	        MMTPConnectionProtocol& connection(static_cast<MMTPConnectionProtocol&>(*iCurrentConnection)); 
         	
-        	// Pass transaction to session to check against any pending events
-           	if ( session.CheckPendingEvent(*iCurrentRequest) )
-            	{
-                //Current request matches a pending event, pass event to connection layer event processing
-                connection.ReceivedEventL(session.PendingEvent());
-                }
+        	        // Pass transaction to session to check against any pending events
+           	      if ( session.CheckPendingEvent(*iCurrentRequest) )
+            	    {
+                      //Current request matches a pending event, pass event to connection layer event processing
+                  connection.ReceivedEventL(session.PendingEvent());
+                  }
+                  }
         	}
         
         }
--- a/mtpfws/mtpfw/src/cmtpobjectstore.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/src/cmtpobjectstore.cpp	Tue May 25 13:35:25 2010 +0300
@@ -497,9 +497,15 @@
 			else
 				{
 				aObject.SetUint(CMTPObjectMetaData::EHandle, handle);
-				needUpdateOwner = ETrue;
-				//while enumerating, we ignore the repeatedly INSERT operations.
-				//User::Leave(KErrAlreadyExists);
+				CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
+				if(ObjectL(aObject.DesC(CMTPObjectMetaData::ESuid), *object))
+					{
+					if(object->Uint(CMTPObjectMetaData::EDataProviderId) != aObject.Uint(CMTPObjectMetaData::EDataProviderId))
+						{
+						needUpdateOwner = ETrue;
+						}
+					}
+				CleanupStack::PopAndDestroy(object);
 				}
 			__FLOG_VA(_L8("Not Found in Snapshot"));
 			}
--- a/mtpfws/mtpfw/src/cmtpstoragemgr.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/mtpfws/mtpfw/src/cmtpstoragemgr.cpp	Tue May 25 13:35:25 2010 +0300
@@ -348,54 +348,8 @@
 EXPORT_C TUint32 CMTPStorageMgr::DefaultStorageId() const
     {
     __FLOG(_L8("DefaultStorageId - Entry"));
-    
-    TUint32 ret = iDefaultStorageId;
-    TBool check = EFalse;
-	TInt driveNo = DriveNumber(ret);
-	const TUint KMinFreeSpace(1024 * 512);  
-	if( (KErrNotFound == driveNo) || ( !IsReadWriteStorage(ret) ) )
-		{
-		check = ETrue;
-		}
-	else
-		{
-		TVolumeInfo volumeInfo;
-		if(iSingletons.Fs().Volume(volumeInfo, driveNo) != KErrNone)
-			{
-			check = ETrue;
-			}
-		else if (volumeInfo.iFree < KMinFreeSpace)
-			{
-			check = ETrue;
-			}
-		}
-    	
-    if(check)
-    	{ 
-		const TUint KCount(iMapDriveToStorage.Count());
-		for (TInt i = 0; i < KCount; i++)
-			{
-			if (iMapDriveToStorage[i] == KErrNotFound)
-				{
-				continue;
-				}
-			TVolumeInfo volume;
-			if( !IsReadWriteStorage(iMapDriveToStorage[i]) 
-					|| (iSingletons.Fs().Volume(volume, i) != KErrNone) )
-				{
-				continue;
-				}
-			
-			if (volume.iFree > KMinFreeSpace )
-				{
-				ret = iMapDriveToStorage[i];
-				break;
-				}
-			}
-    	}
-    
     __FLOG(_L8("DefaultStorageId - Exit"));
-    return ret;
+    return iDefaultStorageId;
     }
 
 EXPORT_C TInt CMTPStorageMgr::DriveNumber(TUint32 aStorageId) const
--- a/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbase.h	Tue May 11 16:59:11 2010 +0300
+++ b/mtptransports/mtpusbtransport/usbsic_imp/inc/cmtpusbepbase.h	Tue May 25 13:35:25 2010 +0300
@@ -53,6 +53,8 @@
     void CancelReceiveL(TInt aReason);
     void CancelSendL(TInt aReason);
     
+    void FlushRxDataL();
+    
 protected:
 
     CMTPUsbEpBase(TUint aId, TPriority aPriority, CMTPUsbConnection& aConnection);
@@ -92,7 +94,6 @@
     TBool ValidateUSBHeaderL();
     void InitiateFirstChunkReceiveL();
     void ProcessFirstReceivedChunkL();
-    void FlushRxDataL();
     
 protected: // Owned
 
@@ -204,7 +205,6 @@
     */    
     TUint64 			iDataLength;
     
-    
 private: // Not owned
 
     /**
--- a/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbconnection.cpp	Tue May 25 13:35:25 2010 +0300
@@ -131,21 +131,30 @@
     __FLOG(_L8("CloseConnection - Exit"));
     }
     
-void CMTPUsbConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& /*aRequest*/)
+void CMTPUsbConnection::ReceiveDataL(MMTPType& aData, const TMTPTypeRequest& aRequest)
     {
     __FLOG(_L8("ReceiveDataL - Entry"));
     
     // Update the transaction state.
     SetBulkTransactionState(EDataIToRPhase);
     
-    // Setup the bulk container and initiate the bulk data receive sequence.
-    iUsbBulkContainer->SetPayloadL(&aData);
-    
-    //Expected containerType pre-setup here in case we don't receive IToR dataphase at all so 
-    //Cancel operation can trigger right call inside ReceiveBulkDataCompleteL(). 
-    iUsbBulkContainer->SetUint16L(CMTPUsbContainer::EContainerType, EMTPUsbContainerTypeDataBlock);
-    
-    static_cast<CMTPUsbEpBulkOut*>(iEndpoints[EMTPUsbEpBulkOut])->ReceiveBulkDataL(*iUsbBulkContainer);
+    if (iIsCancelReceived) //cancel received
+        {
+        __FLOG(_L8("Transaction has been cancelled, just flush trash data and complete"));
+        static_cast<CMTPUsbEpBulkOut*>(iEndpoints[EMTPUsbEpBulkOut])->FlushRxDataL();
+        BoundProtocolLayer().ReceiveDataCompleteL(KErrCancel, aData, iMTPRequest);
+        }
+    else
+        {  
+        // Setup the bulk container and initiate the bulk data receive sequence.
+        iUsbBulkContainer->SetPayloadL(&aData);
+        
+        //Expected containerType pre-setup here in case we don't receive IToR dataphase at all so 
+        //Cancel operation can trigger right call inside ReceiveBulkDataCompleteL(). 
+        iUsbBulkContainer->SetUint16L(CMTPUsbContainer::EContainerType, EMTPUsbContainerTypeDataBlock);
+        
+        static_cast<CMTPUsbEpBulkOut*>(iEndpoints[EMTPUsbEpBulkOut])->ReceiveBulkDataL(*iUsbBulkContainer);
+        }
     
     __FLOG(_L8("ReceiveDataL - Exit"));       
     }
@@ -472,11 +481,9 @@
 			#endif
             
             isResponseTransactionCancelledNeeded = true;
-            if(  BoundProtocolLayer().TransactionPhaseL(iMTPSessionId) > EIdlePhase   ) 
+            TMTPTransactionPhase transPhase = BoundProtocolLayer().TransactionPhaseL(iMTPSessionId);
+            if( transPhase > EIdlePhase && transPhase < ECompletingPhase ) 
             	{
-            	
-               	  
-
 	            iMTPEvent.Reset();
 	            iMTPEvent.SetUint16(TMTPTypeEvent::EEventCode, iUsbControlRequestCancelData.Uint16(TMTPUsbControlRequestCancelData::ECancellationCode));
 	            iMTPEvent.SetUint32(TMTPTypeEvent::EEventSessionID, iMTPSessionId);
@@ -496,45 +503,27 @@
 	                BoundProtocolLayer().ReceivedEventL(iMTPEvent);
 	                }
             	}
+            else if (transPhase == ECompletingPhase)
+                {
+                __FLOG(_L8("cancel event received at completing phase, flush rx data"));
+
+                //flush rx data.
+                static_cast<CMTPUsbEpBulkOut*>(iEndpoints[EMTPUsbEpBulkOut])->FlushRxDataL();
+                }
             else
             	{
-
-				#ifdef _DEBUG 
-            	RDebug::Print(_L("cancel evnet received at idle state, stop data EPs, flush rx data, restart data eps,statusOK\n"));
-				#endif
-
+                __FLOG(_L8("cancel event received at idle phase, stop data EPs, flush rx data, restart data eps"));
+                
             	// stop data endpoint
             	DataEndpointsStop();
       
-            	//flush rx data
-            	TInt  nbytes = 0;
-            	TInt err = iLdd.QueryReceiveBuffer(EndpointNumber(EMTPUsbEpBulkOut), nbytes);
-				#ifdef _DEBUG
-            	RDebug::Print(_L("QueryReceiveBuffer()-----err is %d , nbytes is %d"), err, nbytes);
-				#endif	  
-
-            	// has data, read it
-            	if( (err == KErrNone) && (nbytes > 0) )
-            		{
-            		// create the read buff
-            		RBuf8 readBuf;
-            		readBuf.CreateL(nbytes);
-            		// synchronously read the data
-            		TRequestStatus status;
-            		iLdd.ReadOneOrMore(status, EndpointNumber(EMTPUsbEpBulkOut), readBuf);
-            		User::WaitForRequest(status);
-            		if (KErrNone == status.Int())
-            			{
-	      		 		#ifdef _DEBUG
-            			RDebug::Print(_L("%d bytes is flushed"), nbytes);
-	      		  		#endif
-            			}
-            		readBuf.Close(); 
-            		}
+                //flush rx data.
+                static_cast<CMTPUsbEpBulkOut*>(iEndpoints[EMTPUsbEpBulkOut])->FlushRxDataL();
+                
             	// initiate bulk request sequence.
-            	InitiateBulkRequestSequenceL();
-                       
-            	SetDeviceStatus(EMTPUsbDeviceStatusOK);                   
+            	InitiateBulkRequestSequenceL();   
+            	
+                SetDeviceStatus(EMTPUsbDeviceStatusOK);
             	}
             }
 
@@ -1052,6 +1041,7 @@
     CMTPUsbEpControl& ctrl(*static_cast<CMTPUsbEpControl*>(iEndpoints[EMTPUsbEpControl]));
     if (!ctrl.Stalled())
         {
+
         ctrl.ReceiveControlRequestSetupL(iUsbControlRequestSetup);
         }
     __FLOG(_L8("InitiateControlRequestSequenceL - Exit"));        
@@ -1400,6 +1390,7 @@
         case KErrUsbDeviceClosing:
         case KErrUsbCableDetached:
         case KErrUsbDeviceBusReset:
+        case KErrUsbEpNotReady:
             // Interface state is changing (@see RunL).
             break;
 
--- a/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp	Tue May 11 16:59:11 2010 +0300
+++ b/mtptransports/mtpusbtransport/usbsic_imp/src/cmtpusbepbase.cpp	Tue May 25 13:35:25 2010 +0300
@@ -73,7 +73,7 @@
     iReceiveData(NULL, 0),
     iSendChunkData(NULL, 0),
     iSendData(NULL, 0),
-    iIsFirstChunk(EFalse), 
+    iIsFirstChunk(EFalse),
     iConnection(aConnection)
     {
     CActiveScheduler::Add(this);
@@ -254,7 +254,6 @@
     	Cancel();
       }
     
-
     __ASSERT_DEBUG(iState == EIdle, Panic(EMTPUsbBadState));
     
     iReceiveDataSink    = &aSink;
@@ -528,6 +527,12 @@
 	TUint16 containerType(Connection().BulkContainer().Uint16L(CMTPUsbContainer::EContainerType));
 	iDataLength = Connection().BulkContainer().Uint32L(CMTPUsbContainer::EContainerLength);
 	
+#ifdef __FLOG_ACTIVE
+    TUint32 transactionId(Connection().BulkContainer().Uint32L(CMTPUsbContainer::ETransactionID));
+	TUint16 code(Connection().BulkContainer().Uint16L(CMTPUsbContainer::ECode));
+    __FLOG_VA((_L8("ContainerLength = %lu, containerType = 0x%x, code = 0x%x, transactionID = 0x%x"), iDataLength, containerType, code, transactionId));
+#endif
+	
 	//Due to an issue of Windows OS, the value of CMTPUsbContainer::EContainerLength is incorrect if the
 	//object >= 4G-12. The value should be KMaxTUint32 in this kind of cases, but in current Windows
 	//implementation it will be a value between 0 and 11.
@@ -540,23 +545,14 @@
 	
 	__FLOG_VA((_L8("containerType = %u , dataLength = %lu bytes"), containerType, iDataLength));
 	
-	if (iDataLength >= KUSBHeaderSize && 
-		(containerType == EMTPUsbContainerTypeCommandBlock || containerType == EMTPUsbContainerTypeDataBlock))
-		{
-		result = ETrue;
-		iDataCounter = 0;
-#ifdef _DEBUG
- 		RDebug::Print(_L("Find the valid usb header------------------------------------------------------\n"));
- 		TUint16 code(Connection().BulkContainer().Uint16L(CMTPUsbContainer::ECode));
- 		TUint32 transactionID(Connection().BulkContainer().Uint32L(CMTPUsbContainer::ETransactionID));
- 		RDebug::Print(_L("ContainerLength = 0x%x, containerType = 0x%x , code = 0x%x , transactionID = 0x%x "),  iDataLength, containerType, code, transactionID);
- 		}
- 	else
- 		{
- 		RDebug::Print(_L("inValid usb Header read..........................................................."));
-#endif
- 		}
-	__FLOG(_L8("CMTPUsbEpBase::ValidateUSBHeader - Exit"));
+    if (iDataLength >= KUSBHeaderSize && 
+        (containerType == EMTPUsbContainerTypeCommandBlock || containerType == EMTPUsbContainerTypeDataBlock))
+        {	
+        result = ETrue;
+        iDataCounter = 0;
+        }
+	
+	__FLOG_VA((_L8("CMTPUsbEpBase::ValidateUSBHeader - Exit with the result of %d"), result));
 	return result;
 	}
 
@@ -600,28 +596,19 @@
 	    // USB Header validation
 	    if (!ValidateUSBHeaderL())
 		    {
-			// If device has received trash data, flush the rest of the packet and try again.
-  	  	 	// This will occur when cancelling a transfer and the PC sends buffered data after 
-  	  	 	// the cancellation.
-		    TRequestStatus status;
-  	  		do
-				{
-				// Keep looking for headers.
-				// The case we are trying to catch is when we have 12 garbage bytes followed by 12 good bytes.
-				// In this case the ReadOneOrMore is acting on the next packet rather than the current packet.
-				// If the garbage data is a multiple of 12 bytes, we should still be able to catch the next good
-				// header. Otherwise the ReadOneOrMore will return will <12 bytes and we will fall through
-				// to the retry code below. 
-				iReceiveData.Zero();
-				Connection().Ldd().ReadOneOrMore(status, EndpointNumber(), iReceiveData, KUSBHeaderSize);
-				User::WaitForRequest(status);
-				} while (iReceiveData.Length()==KUSBHeaderSize && !ValidateUSBHeaderL());
+            //trash data, continue to flush.
+            TRequestStatus status;
+            RBuf8 readBuf;
+            readBuf.CreateL(KMaxPacketTypeBulkHS);
+            Connection().Ldd().ReadPacket(status, EndpointNumber(), readBuf, KMaxPacketTypeBulkHS);
+            User::WaitForRequest(status);    
+            RDebug::Print(_L("CMTPUsbEpBase::ProcessFirstReceivedChunkL(), trash data length = %d"), readBuf.Length());
+            readBuf.Close();
+            
+            InitiateFirstChunkReceiveL();  
+            return;
+            
 
-			if(!ValidateUSBHeaderL())
-				{ 
-				InitiateFirstChunkReceiveL();  
-				return;
-				}
 			}
 			
 		if ((iDataLength - KUSBHeaderSize) == 0)
@@ -1034,7 +1021,7 @@
 
 void CMTPUsbEpBase::FlushRxDataL()
     {
-    				  
+    __FLOG(_L8("FlushRxDataL - Entry"));    				  
     // create the read buff
     RBuf8 readBuf;
     readBuf.CreateL(KFlushBufferMaxLen);
@@ -1046,27 +1033,42 @@
       // get the data size in the receive buffer ready to read
       TInt nbytes = 0;
       TInt err = Connection().Ldd().QueryReceiveBuffer(EndpointNumber(), nbytes);
-#ifdef _DEBUG
-      RDebug::Print(_L("FlushRxDataL()--1---err is %d , nbytes is %d"), err, nbytes);	  
-#endif
+
+      __FLOG_VA((_L8("FlushRxDataL()--1---err is %d , nbytes is %d"), err, nbytes));	  
  					  
       // has data, read it
       if( (err == KErrNone) && (nbytes > 0) )
-         {
-   
+         {   
          // synchronously read the data
          TRequestStatus status;
          Connection().Ldd().ReadOneOrMore(status, EndpointNumber(), readBuf);
          User::WaitForRequest(status);
 	 		 
          if(status.Int() != KErrNone)  break;
-         			               
-         // whenever some data read, reset the rest wait time .
+
+#ifdef __FLOG_ACTIVE
+         TInt length =  readBuf.Length();
+         __FLOG_VA((_L8("The length of trash data is %d"), length));
+         
+         __FLOG(_L8("Begining of trash data"));       
+         for (int i=0; i<4&&(i*4+4)<=length; i++)
+             {
+             __FLOG_VA((_L8("0x%x 0x%x 0x%x 0x%x"), readBuf[i*4], readBuf[i*4+1], readBuf[i*4+2], readBuf[i*4+3]));            
+             }
+         
+         __FLOG(_L8("Residual of trash data if any"));          
+         TInt residualLength = length%512;
+         for (int i=0; i<4&&(i*4+4)<=residualLength; i++)
+             {
+             TInt beginIndex = length - residualLength;
+             __FLOG_VA((_L8("0x%x 0x%x 0x%x 0x%x"), readBuf[beginIndex + i*4], readBuf[beginIndex + i*4+1], readBuf[beginIndex + i*4+2], readBuf[beginIndex + i*4+3]));            
+             }
+#endif
+         
+         // whenever some data read, reset the rest wait time.
          uRestTimeToWait = INTERVAL_FOR_FLUSH_TRASH_DATA;
- 			               
-#ifdef _DEBUG 			               
-         RDebug::Print(_L("FlushRxDataL()---Reset the rest wait time"));	  
-#endif             
+ 			                          
+         __FLOG(_L8("FlushRxDataL()---Reset the rest wait time"));	          
          }
        else 
          {	
@@ -1075,13 +1077,11 @@
          // reduce the rest time to wait 
          uRestTimeToWait -=  INTERVAL_FOR_READ_TRASH_DATA ;
          }	
- 	  
-#ifdef _DEBUG 	  
-       RDebug::Print(_L("FlushRxDataL()---uRestTimeToWait is %d"), uRestTimeToWait);	  
-#endif
+ 	    
+      __FLOG_VA((_L8("FlushRxDataL()---uRestTimeToWait is %d"), uRestTimeToWait));
  			    	
     }while( uRestTimeToWait > 0);
 			    	
     readBuf.Close();
- 
+    __FLOG(_L8("FlushRxDataL - Exit"));    
 }