--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectprotection.cpp Fri Apr 16 15:51:48 2010 +0300
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectprotection.cpp Mon May 03 13:19:02 2010 +0300
@@ -28,6 +28,7 @@
#include "mtpframeworkconst.h"
#include "rmtpdpsingletons.h"
#include "rmtputility.h"
+#include "cmtpstoragemgr.h"
/**
Verification data for the SetObjectPropValue request
@@ -37,6 +38,8 @@
{TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrWrite, 0, 0, 0},
};
+const TInt KRetryTimes = 10;
+const TInt KRetryInterval = 150 * 1000; //150ms
/**
Two-phase construction method
@param aPlugin The data provider plugin
@@ -61,6 +64,7 @@
EXPORT_C CMTPSetObjectProtection::~CMTPSetObjectProtection()
{
delete iObjMeta;
+ iSingletons.Close();
}
/**
@@ -83,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 )
@@ -97,20 +106,42 @@
{
TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
TUint32 statusValue = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
- TMTPResponseCode rsp = EMTPRespCodeOK;
+ TMTPResponseCode rsp = EMTPRespCodeAccessDenied;
//iFramework.ObjectMgr().ObjectL(TMTPTypeUint32(handle), *iObjMeta);
switch(statusValue)
{
case EMTPProtectionNoProtection:
{
- iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttNormal,KEntryAttReadOnly);
+ for(TInt i = 0; i < KRetryTimes; ++ i)
+ {
+ if(KErrNone == iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttNormal,KEntryAttReadOnly))
+ {
+ rsp = EMTPRespCodeOK;
+ break;
+ }
+ else
+ {
+ User::After(KRetryInterval);
+ }
+ }
}
break;
case EMTPProtectionReadOnly:
case EMTPProtectionReadOnlyData:
{
- iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttReadOnly,KEntryAttNormal);
+ for(TInt i = 0; i < KRetryTimes; ++ i)
+ {
+ if(KErrNone == iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttReadOnly,KEntryAttNormal))
+ {
+ rsp = EMTPRespCodeOK;
+ break;
+ }
+ else
+ {
+ User::After(KRetryInterval);
+ }
+ }
}
break;
default:
@@ -127,4 +158,5 @@
void CMTPSetObjectProtection::ConstructL()
{
iObjMeta = CMTPObjectMetaData::NewL();
+ iSingletons.OpenL();
}