srsf/devtts/src/devttscenrep.cpp
changeset 0 bf1d17376201
equal deleted inserted replaced
-1:000000000000 0:bf1d17376201
       
     1 /*
       
     2 * Copyright (c) 2006 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:  CenRep handling for DevTTS.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "devttscenrep.h"
       
    21 #include "rubydebug.h"
       
    22 #include "srsfinternalcrkeys.h"
       
    23 
       
    24 // CONSTANTS
       
    25 
       
    26 // Maximum value of the volume setting in Central Repository
       
    27 const TInt KMaxRepositoryVolume = 10;
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ===============================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CDevTtsCenRep::CDevTtsCenRep
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CDevTtsCenRep::CDevTtsCenRep() 
       
    38     {
       
    39     // Nothing
       
    40     }
       
    41 
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CDevTtsCenRep::ConstructL
       
    45 // Symbian 2nd phase constructor can leave.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 void CDevTtsCenRep::ConstructL()
       
    49     {
       
    50     RUBY_DEBUG_BLOCK( "" );
       
    51 	iRepository = CRepository::NewL( KCRUidSRSFSettings );
       
    52     }
       
    53 
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CDevTtsCenRep::NewL
       
    57 // Two-phased constructor.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CDevTtsCenRep* CDevTtsCenRep::NewL()
       
    61     {
       
    62     CDevTtsCenRep* self = new( ELeave ) CDevTtsCenRep();
       
    63  
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop( self );
       
    67     
       
    68     return self;
       
    69     }
       
    70 
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CDevTtsCenRep::~CDevTtsCenRep
       
    74 // Destructor
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 CDevTtsCenRep::~CDevTtsCenRep()
       
    78     {
       
    79     delete iRepository;
       
    80     }
       
    81 
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CDevTtsCenRep::Volume
       
    85 // Returns the volume setting from CenRep
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 TInt CDevTtsCenRep::Volume( TInt aMaxVolume ) 
       
    89     {
       
    90     RUBY_DEBUG0( "" );
       
    91     TInt volume( aMaxVolume );
       
    92     // Get from CenRep
       
    93     TInt error = iRepository->Get( KSRSFPlaybackVolume, volume );
       
    94     if ( error == KErrNone )
       
    95         {
       
    96         RUBY_DEBUG2( "Volume repository value:[%d], maxvolume:[%d]", volume, aMaxVolume );
       
    97         // Scale value
       
    98         volume = ( volume * aMaxVolume ) / KMaxRepositoryVolume;
       
    99         RUBY_DEBUG1( "Scaled volume value:[%d]", volume );
       
   100         
       
   101         return volume;
       
   102         }
       
   103     // Return max volume by default
       
   104     return aMaxVolume;
       
   105     }
       
   106 
       
   107 // End of File