sysstatemgmt/ssmcustcmds/ssmsystemcmds/src/ssmsystemcommandsbase.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Implementation of CSsmSystemCommandsBase class.
       
    16 *
       
    17 */
       
    18 
       
    19 #include "ssmsystemcommandsbase.h"
       
    20 #include "ssmmapperutility.h"
       
    21 #include "trace.h"
       
    22 
       
    23 #include <e32property.h>
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // CSsmSystemCommandsBase::~CSsmSystemCommandsBase
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CSsmSystemCommandsBase::~CSsmSystemCommandsBase()
       
    32     {
       
    33     FUNC_LOG;
       
    34     delete iMapperUtility;
       
    35     }
       
    36 
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CSsmSystemCommandsBase::CSsmSystemCommandsBase
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CSsmSystemCommandsBase::CSsmSystemCommandsBase()
       
    43     {
       
    44     
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CSsmSystemCommandsBase::DefineL
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 void CSsmSystemCommandsBase::DefineL(
       
    52     TUid aCategory,
       
    53     TUint aKey,
       
    54     const TSecurityPolicy& aReadPolicy,
       
    55     const TSecurityPolicy& aWritePolicy )
       
    56     {
       
    57     FUNC_LOG;
       
    58     
       
    59     INFO_2( "Defining key 0x%08x::0x%08x", aCategory, aKey );
       
    60 
       
    61     TInt errorCode = RProperty::Define( MapperUtilityL().PsUid( aCategory ),
       
    62                                         aKey,
       
    63                                         RProperty::EInt,
       
    64                                         aReadPolicy,
       
    65                                         aWritePolicy );
       
    66     if ( errorCode == KErrAlreadyExists )
       
    67         {
       
    68         INFO_2( "Key 0x%08x::0x%08x already defined", aCategory, aKey );
       
    69         errorCode = KErrNone;
       
    70         }
       
    71 
       
    72     ERROR_2( errorCode, "Failed to define PS key 0x%08x::0x%08x", aCategory,
       
    73                                                                   aKey );
       
    74     User::LeaveIfError( errorCode );
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // CSsmSystemCommandsBase::DefineL
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 void CSsmSystemCommandsBase::SetL( TUid aCategory, TUint aKey, TInt aValue )
       
    82     {
       
    83     FUNC_LOG;
       
    84     INFO_3( "Setting key 0x%08x::0x%08x value %d", aCategory, aKey, aValue );
       
    85 
       
    86     TInt errorCode = RProperty::Set( MapperUtilityL().PsUid( aCategory ),
       
    87                                      aKey,
       
    88                                      aValue );
       
    89     ERROR_2( errorCode, "Failed to set PS key 0x%08x::0x%08x", aCategory,
       
    90                                                                aKey );
       
    91     User::LeaveIfError( errorCode );
       
    92     }
       
    93 // ---------------------------------------------------------------------------
       
    94 // CSsmSystemCommandsBase::MapperUtilityL
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 CSsmMapperUtility& CSsmSystemCommandsBase::MapperUtilityL()
       
    98     {
       
    99     FUNC_LOG;
       
   100     if ( !iMapperUtility )
       
   101         {
       
   102         iMapperUtility = CSsmMapperUtility::NewL();
       
   103         }
       
   104     return *iMapperUtility;
       
   105     }