profilesservices/ProfileEngine/EngSrc/CProfileFeedbackSettingsImpl.cpp
changeset 0 8c5d936e5675
child 24 8ee96d21d9bf
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Implementation of the CProfileFeedbackSettingsImpl.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CProfileFeedbackSettingsImpl.h"
       
    22 #include <centralrepository.h>
       
    23 #include "ProfileEngUtils.h"
       
    24 #include "ProfileEnginePrivateCRKeys.h"
       
    25 #include "ProfilesDebug.h"
       
    26 
       
    27 #include <hwrmvibrasdkcrkeys.h>
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CProfileFeedbackSettingsImpl::NewL
       
    32 // Two-phased constructor.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CProfileFeedbackSettingsImpl* CProfileFeedbackSettingsImpl::NewL()
       
    36     {
       
    37     CProfileFeedbackSettingsImpl* self = new( ELeave ) CProfileFeedbackSettingsImpl;
       
    38     return self;
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CProfileFeedbackSettingsImpl::NewL
       
    43 // Two-phased constructor.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CProfileFeedbackSettingsImpl* CProfileFeedbackSettingsImpl::NewL(
       
    47     const MProfileFeedbackSettings& aProfileFeedbackSettings )
       
    48     {
       
    49     CProfileFeedbackSettingsImpl* self = new( ELeave ) CProfileFeedbackSettingsImpl;
       
    50 
       
    51     self->iTactileFeedback = aProfileFeedbackSettings.TactileFeedback();
       
    52     self->iAudioFeedback = aProfileFeedbackSettings.AudioFeedback();
       
    53 
       
    54     return self;
       
    55     }
       
    56 
       
    57 
       
    58 // Destructor
       
    59 CProfileFeedbackSettingsImpl::~CProfileFeedbackSettingsImpl()
       
    60     {
       
    61     }
       
    62 
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CProfileFeedbackSettingsImpl::InternalizeL
       
    66 //
       
    67 // (other items were commented in a header).
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 void CProfileFeedbackSettingsImpl::InternalizeL( CRepository& aCenRep,
       
    71                                                TInt aProfileId )
       
    72     {
       
    73     PRODEBUG( "CProfileFeedbackSettings::InternalizeL begin" );
       
    74     
       
    75     InitPowerSaveMode();
       
    76 
       
    77     if ( iPowerSaveMode )
       
    78         {
       
    79         iTactileFeedback = TProfileTactileFeedback( iPsmConfigTactileFeedback );
       
    80         iAudioFeedback =  TProfileAudioFeedback( iPsmConfigAudioFeedback );
       
    81         return;
       
    82         }
       
    83         
       
    84     TInt tmp( 0 );
       
    85     // Tactile feedback
       
    86     User::LeaveIfError(
       
    87             aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngTactileFeedback,
       
    88             aProfileId ), tmp ) );
       
    89     iTactileFeedback = TProfileTactileFeedback( tmp );
       
    90 
       
    91     // Audio feedback
       
    92     User::LeaveIfError(
       
    93             aCenRep.Get( ProfileEngUtils::ResolveKey( KProEngAudioFeedback,
       
    94             aProfileId ), tmp ) );
       
    95     iAudioFeedback = TProfileAudioFeedback( tmp );
       
    96     PRODEBUG( "CProfileFeedbackSettings::InternalizeL return" );
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CProfileFeedbackSettingsImpl::ExternalizeL
       
   101 //
       
   102 // (other items were commented in a header).
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CProfileFeedbackSettingsImpl::ExternalizeL( CRepository& aCenRep,
       
   106                                                TInt aProfileId ) const
       
   107     {
       
   108     if ( ProfileEngUtils::PowerSaveMode() )
       
   109         {
       
   110         return;
       
   111         }
       
   112         
       
   113     // Tactile feedback
       
   114     User::LeaveIfError(
       
   115             aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngTactileFeedback,
       
   116             aProfileId ), iTactileFeedback ) );
       
   117 
       
   118     // Audio feedback
       
   119     User::LeaveIfError(
       
   120             aCenRep.Set( ProfileEngUtils::ResolveKey( KProEngAudioFeedback,
       
   121             aProfileId ), iAudioFeedback ) );
       
   122 
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CProfileFeedbackSettingsImpl::TactileFeedback
       
   127 //
       
   128 // (other items were commented in a header).
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 TProfileTactileFeedback CProfileFeedbackSettingsImpl::TactileFeedback() const
       
   132     {
       
   133     return iTactileFeedback;
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CProfileFeedbackSettingsImpl::SetTactileFeedback
       
   138 //
       
   139 // (other items were commented in a header).
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 void CProfileFeedbackSettingsImpl::SetTactileFeedback( TProfileTactileFeedback aTactileFeedback )
       
   143     {
       
   144     iTactileFeedback = aTactileFeedback;
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CProfileFeedbackSettingsImpl::AudioFeedback
       
   149 //
       
   150 // (other items were commented in a header).
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 TProfileAudioFeedback CProfileFeedbackSettingsImpl::AudioFeedback() const
       
   154     {
       
   155     return iAudioFeedback;
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CProfileFeedbackSettingsImpl::SetAudioFeedback
       
   160 //
       
   161 // (other items were commented in a header).
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 void CProfileFeedbackSettingsImpl::SetAudioFeedback( TProfileAudioFeedback aAudioFeedback )
       
   165     {
       
   166     iAudioFeedback = aAudioFeedback;
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CProfileFeedbackSettingsImpl::InitPowerSaveMode
       
   171 //
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 void CProfileFeedbackSettingsImpl::InitPowerSaveMode()
       
   175     {
       
   176     const TInt KTactileFeedbackOff = 0;
       
   177     const TInt KAudioFeedbackOff = 0;
       
   178 
       
   179     iPsmConfigTactileFeedback = KTactileFeedbackOff;
       
   180     iPsmConfigAudioFeedback = KAudioFeedbackOff;
       
   181 
       
   182     iPowerSaveMode = ProfileEngUtils::PowerSaveMode();
       
   183     
       
   184     if ( iPowerSaveMode )
       
   185         {
       
   186         TRAP_IGNORE( ReadPowerSaveConfigL() );
       
   187         }
       
   188     }
       
   189 
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CProfileFeedbackSettingsImpl::ReadPowerSaveConfigL
       
   193 //
       
   194 // -----------------------------------------------------------------------------
       
   195 //
       
   196 void CProfileFeedbackSettingsImpl::ReadPowerSaveConfigL()
       
   197     {
       
   198     CRepository* cenrep = CRepository::NewLC( KCRUidVibraCtrl );
       
   199     User::LeaveIfError( cenrep->Get( KVibraCtrlProfileFeedbackEnabled,
       
   200                                      iPsmConfigTactileFeedback ) );
       
   201     CleanupStack::PopAndDestroy( cenrep );
       
   202     
       
   203     
       
   204     cenrep = CRepository::NewLC( KCRUidProfileEngine );
       
   205     User::LeaveIfError( cenrep->Get( KProEngActiveAudioFeedback,
       
   206                                      iPsmConfigAudioFeedback ) );
       
   207     CleanupStack::PopAndDestroy( cenrep );
       
   208     }
       
   209 
       
   210 
       
   211 //  End of File
       
   212