mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectprotection.cpp
changeset 0 d0791faffa3f
child 16 3673b591050c
child 20 6e82ae192c3a
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <bautils.h>
       
    17 #include <f32file.h>
       
    18 #include <mtp/tmtptyperequest.h>
       
    19 #include <mtp/mmtpdataproviderframework.h>
       
    20 #include <mtp/mtpprotocolconstants.h>
       
    21 #include <mtp/cmtptypestring.h>
       
    22 #include <mtp/mmtpobjectmgr.h>
       
    23 
       
    24 #include "cmtpsetobjectprotection.h"
       
    25 #include "mtpdpconst.h"
       
    26 #include "mtpdppanic.h"
       
    27 #include "cmtpdataprovidercontroller.h"
       
    28 #include "mtpframeworkconst.h"
       
    29 #include "rmtpdpsingletons.h"
       
    30 #include "rmtputility.h"
       
    31 
       
    32 /**
       
    33 Verification data for the SetObjectPropValue request
       
    34 */
       
    35 const TMTPRequestElementInfo KMTPSetObjectProtectionPolicy[] = 
       
    36     {
       
    37         {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrWrite, 0, 0, 0},      
       
    38      };
       
    39 
       
    40 /**
       
    41 Two-phase construction method
       
    42 @param aPlugin  The data provider plugin
       
    43 @param aFramework   The data provider framework
       
    44 @param aConnection  The connection from which the request comes
       
    45 @return a pointer to the created request processor object
       
    46 */ 
       
    47 EXPORT_C MMTPRequestProcessor* CMTPSetObjectProtection::NewL(
       
    48                                             MMTPDataProviderFramework& aFramework,
       
    49                                             MMTPConnection& aConnection)
       
    50     {
       
    51     CMTPSetObjectProtection* self = new (ELeave) CMTPSetObjectProtection(aFramework, aConnection);
       
    52     CleanupStack::PushL(self);
       
    53     self->ConstructL();
       
    54     CleanupStack::Pop(self);
       
    55     return self;
       
    56     }
       
    57 
       
    58 /**
       
    59 Destructor
       
    60 */  
       
    61 EXPORT_C CMTPSetObjectProtection::~CMTPSetObjectProtection()
       
    62     {   
       
    63     delete iObjMeta;
       
    64     }
       
    65 
       
    66 /**
       
    67 Standard c++ constructor
       
    68 */  
       
    69 CMTPSetObjectProtection::CMTPSetObjectProtection(
       
    70                                     MMTPDataProviderFramework& aFramework,
       
    71                                     MMTPConnection& aConnection)
       
    72     :CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPSetObjectProtectionPolicy)/sizeof(TMTPRequestElementInfo), KMTPSetObjectProtectionPolicy),
       
    73     iRfs(aFramework.Fs())
       
    74     {
       
    75     }
       
    76                                     
       
    77 TMTPResponseCode CMTPSetObjectProtection::CheckRequestL()
       
    78     {
       
    79     //TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
       
    80     TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
    81     iFramework.ObjectMgr().ObjectL(TMTPTypeUint32(handle), *iObjMeta);
       
    82     if (!iObjMeta )
       
    83         {
       
    84         return EMTPRespCodeInvalidObjectHandle;
       
    85         }
       
    86     TUint32 statusValue = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
       
    87     //Currently we only support EMTPProtectionNoProtection and EMTPProtectionReadOnly
       
    88     if ( statusValue!=EMTPProtectionNoProtection && statusValue!=EMTPProtectionReadOnly )
       
    89         {
       
    90         return EMTPRespCodeInvalidParameter;
       
    91         }
       
    92     
       
    93     return EMTPRespCodeOK;
       
    94     }
       
    95 
       
    96 void CMTPSetObjectProtection::ServiceL()
       
    97     {
       
    98     TUint32 handle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
    99     TUint32 statusValue = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
       
   100     TMTPResponseCode rsp = EMTPRespCodeOK;
       
   101     //iFramework.ObjectMgr().ObjectL(TMTPTypeUint32(handle), *iObjMeta);
       
   102     
       
   103     switch(statusValue)
       
   104         {
       
   105         case EMTPProtectionNoProtection:
       
   106             {
       
   107             iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttNormal,KEntryAttReadOnly);
       
   108             }
       
   109             break;
       
   110         case EMTPProtectionReadOnly:
       
   111         case EMTPProtectionReadOnlyData:
       
   112             {
       
   113             iRfs.SetAtt(iObjMeta->DesC(CMTPObjectMetaData::ESuid),KEntryAttReadOnly,KEntryAttNormal);
       
   114             }
       
   115             break;
       
   116         default:
       
   117             rsp = EMTPRespCodeInvalidParameter;
       
   118             break;
       
   119 
       
   120         }
       
   121     SendResponseL(rsp);
       
   122     }
       
   123 
       
   124 /**
       
   125 Second-phase construction
       
   126 */          
       
   127 void CMTPSetObjectProtection::ConstructL()
       
   128     {   
       
   129     iObjMeta = CMTPObjectMetaData::NewL();
       
   130     }