sysstatemgmt/ssmcustcmds/ssmsystemcmds/src/ssmsystemcommandsbase.cpp
author Dario Sestito <darios@symbian.org>
Fri, 07 May 2010 16:55:32 +0100
branchRCL_3
changeset 20 d80caf2a6605
parent 0 4e1aa6a622a0
permissions -rw-r--r--
Still on bug 2620, ssm.state.policy.0001.dll is not conflicting

/*
* Copyright (c) 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:
* Implementation of CSsmSystemCommandsBase class.
*
*/

#include "ssmsystemcommandsbase.h"
#include "ssmmapperutility.h"
#include "trace.h"

#include <e32property.h>
// ======== MEMBER FUNCTIONS ========


// ---------------------------------------------------------------------------
// CSsmSystemCommandsBase::~CSsmSystemCommandsBase
// ---------------------------------------------------------------------------
//
CSsmSystemCommandsBase::~CSsmSystemCommandsBase()
    {
    FUNC_LOG;
    delete iMapperUtility;
    }


// ---------------------------------------------------------------------------
// CSsmSystemCommandsBase::CSsmSystemCommandsBase
// ---------------------------------------------------------------------------
//
CSsmSystemCommandsBase::CSsmSystemCommandsBase()
    {
    
    }

// ---------------------------------------------------------------------------
// CSsmSystemCommandsBase::DefineL
// ---------------------------------------------------------------------------
//
void CSsmSystemCommandsBase::DefineL(
    TUid aCategory,
    TUint aKey,
    const TSecurityPolicy& aReadPolicy,
    const TSecurityPolicy& aWritePolicy )
    {
    FUNC_LOG;
    
    INFO_2( "Defining key 0x%08x::0x%08x", aCategory, aKey );

    TInt errorCode = RProperty::Define( MapperUtilityL().PsUid( aCategory ),
                                        aKey,
                                        RProperty::EInt,
                                        aReadPolicy,
                                        aWritePolicy );
    if ( errorCode == KErrAlreadyExists )
        {
        INFO_2( "Key 0x%08x::0x%08x already defined", aCategory, aKey );
        errorCode = KErrNone;
        }

    ERROR_2( errorCode, "Failed to define PS key 0x%08x::0x%08x", aCategory,
                                                                  aKey );
    User::LeaveIfError( errorCode );
    }

// ---------------------------------------------------------------------------
// CSsmSystemCommandsBase::DefineL
// ---------------------------------------------------------------------------
//
void CSsmSystemCommandsBase::SetL( TUid aCategory, TUint aKey, TInt aValue )
    {
    FUNC_LOG;
    INFO_3( "Setting key 0x%08x::0x%08x value %d", aCategory, aKey, aValue );

    TInt errorCode = RProperty::Set( MapperUtilityL().PsUid( aCategory ),
                                     aKey,
                                     aValue );
    ERROR_2( errorCode, "Failed to set PS key 0x%08x::0x%08x", aCategory,
                                                               aKey );
    User::LeaveIfError( errorCode );
    }
// ---------------------------------------------------------------------------
// CSsmSystemCommandsBase::MapperUtilityL
// ---------------------------------------------------------------------------
//
CSsmMapperUtility& CSsmSystemCommandsBase::MapperUtilityL()
    {
    FUNC_LOG;
    if ( !iMapperUtility )
        {
        iMapperUtility = CSsmMapperUtility::NewL();
        }
    return *iMapperUtility;
    }