mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectprotection.cpp
branchRCL_3
changeset 5 3673b591050c
parent 0 d0791faffa3f
child 6 ef55b168cedb
equal deleted inserted replaced
4:60a94a45d437 5:3673b591050c
    35 const TMTPRequestElementInfo KMTPSetObjectProtectionPolicy[] = 
    35 const TMTPRequestElementInfo KMTPSetObjectProtectionPolicy[] = 
    36     {
    36     {
    37         {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrWrite, 0, 0, 0},      
    37         {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrWrite, 0, 0, 0},      
    38      };
    38      };
    39 
    39 
       
    40 const TInt KRetryTimes = 10;
       
    41 const TInt KRetryInterval = 150 * 1000; //150ms
    40 /**
    42 /**
    41 Two-phase construction method
    43 Two-phase construction method
    42 @param aPlugin  The data provider plugin
    44 @param aPlugin  The data provider plugin
    43 @param aFramework   The data provider framework
    45 @param aFramework   The data provider framework
    44 @param aConnection  The connection from which the request comes
    46 @param aConnection  The connection from which the request comes
    95 
    97 
    96 void CMTPSetObjectProtection::ServiceL()
    98 void CMTPSetObjectProtection::ServiceL()
    97     {
    99     {
    98     TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   100     TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
    99     TUint32 statusValue = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   101     TUint32 statusValue = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   100     TMTPResponseCode rsp = EMTPRespCodeOK;
   102     TMTPResponseCode rsp = EMTPRespCodeAccessDenied;
   101     //iFramework.ObjectMgr().ObjectL(TMTPTypeUint32(handle), *iObjMeta);
   103     //iFramework.ObjectMgr().ObjectL(TMTPTypeUint32(handle), *iObjMeta);
   102     
   104     
   103     switch(statusValue)
   105     switch(statusValue)
   104         {
   106         {
   105         case EMTPProtectionNoProtection:
   107         case EMTPProtectionNoProtection:
   106             {
   108             {
   107             iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttNormal,KEntryAttReadOnly);
   109             for(TInt i = 0; i < KRetryTimes; ++ i)
       
   110                 {
       
   111                 if(KErrNone == iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttNormal,KEntryAttReadOnly))
       
   112                     {
       
   113                     rsp = EMTPRespCodeOK;
       
   114                     break;
       
   115                     }
       
   116                 else
       
   117                     {
       
   118                     User::After(KRetryInterval);	
       
   119                     }
       
   120                 }
   108             }
   121             }
   109             break;
   122             break;
   110         case EMTPProtectionReadOnly:
   123         case EMTPProtectionReadOnly:
   111         case EMTPProtectionReadOnlyData:
   124         case EMTPProtectionReadOnlyData:
   112             {
   125             {
   113             iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttReadOnly,KEntryAttNormal);
   126             for(TInt i = 0; i < KRetryTimes; ++ i)
       
   127                 {
       
   128                 if(KErrNone == iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttReadOnly,KEntryAttNormal))
       
   129                     {
       
   130                         rsp = EMTPRespCodeOK;
       
   131                         break;
       
   132                     }
       
   133                     else
       
   134                     {
       
   135                         User::After(KRetryInterval);	
       
   136                     }
       
   137                 }
   114             }
   138             }
   115             break;
   139             break;
   116         default:
   140         default:
   117             rsp = EMTPRespCodeInvalidParameter;
   141             rsp = EMTPRespCodeInvalidParameter;
   118             break;
   142             break;