contextframework/cfw/tsrc/public/basic/common/cfenvutils.cpp
branchRCL_3
changeset 20 c2c61fdca848
parent 0 2e3d3ce01487
equal deleted inserted replaced
19:924385140d98 20:c2c61fdca848
       
     1 /*
       
     2 * Copyright (c) 2008-2008 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:  CFEnvUtils class implamentation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // SYSTEM INCLUDES
       
    20 #include <eunitmacros.h>
       
    21 #include <e32property.h>
       
    22 #include <ScreenSaverInternalPSKeys.h>
       
    23 
       
    24 // USER INCLUDES
       
    25 #include "cfenvutils.h"
       
    26 
       
    27 const TInt KScreenSaverNotAllowed = 666;
       
    28 const TInt KScreenSaverAllowed = 0;
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // C++ constructor.
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CFEnvUtils::CFEnvUtils ( )
       
    37     {
       
    38 
       
    39     }
       
    40 
       
    41 //------------------------------------------------------------------------------
       
    42 // CFEnvUtils::EnableScreenSaver
       
    43 //------------------------------------------------------------------------------
       
    44 //
       
    45 TInt CFEnvUtils::EnableScreenSaver( TBool& aWasEnabled, const TBool aEnable )
       
    46     {
       
    47     TInt err( KErrNone );
       
    48     TInt val( KScreenSaverNotAllowed );
       
    49     
       
    50     err = RProperty::Get( KPSUidScreenSaver,  KScreenSaverAllowScreenSaver, val );
       
    51     EUNIT_PRINT( _L("Get screen saver mode: %d"), err );
       
    52     if( err == KErrNone )
       
    53         {
       
    54         aWasEnabled = ( val != KScreenSaverAllowed );
       
    55         err = EnableScreenSaver( aEnable );
       
    56         }
       
    57     
       
    58     return err;
       
    59     }
       
    60 
       
    61 //------------------------------------------------------------------------------
       
    62 // CFEnvUtils::EnableScreenSaver
       
    63 //------------------------------------------------------------------------------
       
    64 //
       
    65 TInt CFEnvUtils::EnableScreenSaver( const TBool aEnable )
       
    66     {
       
    67     TInt err( KErrNone );
       
    68 
       
    69     TInt val = 0;
       
    70     if( aEnable )
       
    71         {
       
    72         val = KScreenSaverAllowed;
       
    73         }
       
    74     else
       
    75         {
       
    76         val = KScreenSaverNotAllowed;
       
    77         }
       
    78     err = RProperty::Set( KPSUidScreenSaver,  KScreenSaverAllowScreenSaver, val );
       
    79     EUNIT_PRINT( _L("Set screen saver mode: %d"), err );
       
    80     
       
    81     User::ResetInactivityTime();
       
    82     
       
    83     return err;
       
    84     }
       
    85 
       
    86 // End of file