gssettingsuis/Gs/GSDisplayPlugin/Src/GSDisplayPluginModel.cpp
branchRCL_3
changeset 53 8ee96d21d9bf
parent 51 8bda91a87a00
child 54 7e0eff37aedb
equal deleted inserted replaced
51:8bda91a87a00 53:8ee96d21d9bf
     1 /*
       
     2 * Copyright (c) 2005-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:  Display Settings model implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "GSDisplayPluginModel.h"
       
    21 
       
    22 #include <hal.h>
       
    23 #include <e32math.h>
       
    24 #include <featmgr.h>
       
    25 #include <generalsettingsvariant.hrh>
       
    26 
       
    27 #include <settingsinternalcrkeys.h>
       
    28 #include <startupdomaincrkeys.h>
       
    29 #include <ScreensaverInternalCRKeys.h>
       
    30 #include <hwrmlightdomaincrkeys.h>
       
    31 #include <coreapplicationuisdomainpskeys.h>
       
    32 #include <AvkonInternalCRKeys.h> // for zooming
       
    33 #include <AknDef.hrh>
       
    34 #include "GsLogger.h"
       
    35 #include "SettingsPrivateCRKeys.h"
       
    36 
       
    37 // Used for OperatorLogo
       
    38 #include <commdb.h>
       
    39 #include <telephonydomainpskeys.h>
       
    40 #include "GSDisplayPluginContainer.h"
       
    41 #include "GsDisplayPlugin.hrh"
       
    42 
       
    43 // EXTERNAL DATA STRUCTURES
       
    44 
       
    45 // EXTERNAL FUNCTION PROTOTYPES
       
    46 
       
    47 // CONSTANTS
       
    48 
       
    49 // MACROS
       
    50 
       
    51 // LOCAL CONSTANTS AND MACROS
       
    52 
       
    53 // MODULE DATA STRUCTURES
       
    54 
       
    55 // LOCAL FUNCTION PROTOTYPES
       
    56 
       
    57 // FORWARD DECLARATIONS
       
    58 
       
    59 // ============================= LOCAL FUNCTIONS ==============================
       
    60 
       
    61 // ========================= MEMBER FUNCTIONS =================================
       
    62 
       
    63 // ----------------------------------------------------------------------------
       
    64 // CGSDisplayPluginModel::NewL
       
    65 //
       
    66 // Symbian OS two-phased constructor
       
    67 // ----------------------------------------------------------------------------
       
    68 //
       
    69 CGSDisplayPluginModel* CGSDisplayPluginModel::NewL()
       
    70     {
       
    71     return CGSDisplayPluginModel::NewL( ETrue );
       
    72     }
       
    73 
       
    74 
       
    75 // ----------------------------------------------------------------------------
       
    76 // CGSDisplayPluginModel::NewL
       
    77 //
       
    78 // Symbian OS two-phased constructor
       
    79 // ----------------------------------------------------------------------------
       
    80 //
       
    81 CGSDisplayPluginModel* CGSDisplayPluginModel::NewL( TBool aInitBackgroundApi )
       
    82     {
       
    83     CGSDisplayPluginModel* self = new( ELeave ) CGSDisplayPluginModel;
       
    84     CleanupStack::PushL( self );
       
    85     self->ConstructL( aInitBackgroundApi );
       
    86 
       
    87     CleanupStack::Pop( self );
       
    88     return self;
       
    89     }
       
    90 
       
    91 
       
    92 // ----------------------------------------------------------------------------
       
    93 // CGSDisplayPluginModel::CGSDisplayPluginModel
       
    94 //
       
    95 //
       
    96 // C++ default constructor can NOT contain any code, that might leave.
       
    97 // ----------------------------------------------------------------------------
       
    98 //
       
    99 CGSDisplayPluginModel::CGSDisplayPluginModel()
       
   100     {
       
   101     }
       
   102 
       
   103 
       
   104 // ----------------------------------------------------------------------------
       
   105 // CGSDisplayPluginModel::ConstructL
       
   106 //
       
   107 // EPOC default constructor can leave.
       
   108 // ----------------------------------------------------------------------------
       
   109 //
       
   110 void CGSDisplayPluginModel::ConstructL( TBool aInitBackgroundApi )
       
   111     {
       
   112     //__GSENGINELOGSTRING("CGSDisplayPluginModel::ConstructL begin");
       
   113     FeatureManager::InitializeLibL();
       
   114     
       
   115     InitializeCentralRepositoryL();
       
   116 
       
   117     //Background image DLL initializing
       
   118     if( aInitBackgroundApi ) iBackgroundApi = CGSBackgroundImage::NewL();
       
   119 
       
   120     User::LeaveIfError( iGSVariationRepository->Get(
       
   121                         KSettingsVariationFlags, iLocalVariationValues ) );
       
   122     }
       
   123 
       
   124 
       
   125 // ----------------------------------------------------------------------------
       
   126 // CGSDisplayPluginModel::~CGSDisplayPluginModel
       
   127 //
       
   128 // Destructor
       
   129 // ----------------------------------------------------------------------------
       
   130 //
       
   131 CGSDisplayPluginModel::~CGSDisplayPluginModel()
       
   132     {
       
   133     UninitializeCentralRepository();
       
   134     FeatureManager::UnInitializeLib();
       
   135     if( iBackgroundApi ) delete iBackgroundApi;
       
   136     }
       
   137 
       
   138 
       
   139 // ----------------------------------------------------------------------------
       
   140 // CGSDisplayPluginModel::InitializeCentralRepositoryL
       
   141 //
       
   142 // Creating and setting keys for the Central Repository
       
   143 // ----------------------------------------------------------------------------
       
   144 //
       
   145 void CGSDisplayPluginModel::InitializeCentralRepositoryL()
       
   146     {
       
   147     iStartupConfRepository = CRepository::NewL( KCRUidStartupConf );
       
   148     iScreensaverRepository = CRepository::NewL( KCRUidScreenSaver );
       
   149     iPersonalizationRepository =
       
   150             CRepository::NewL( KCRUidPersonalizationSettings );
       
   151     iLightRepository = CRepository::NewL( KCRUidLightSettings );
       
   152     iSecurityRepository = CRepository::NewL( KCRUidSecuritySettings );
       
   153     iGSVariationRepository = CRepository::NewL( KCRUidSettingsVariation );
       
   154     iAvkonRepository = CRepository::NewL( KCRUidAvkon );
       
   155     
       
   156     // start listening to CenRep key changes for Operator Logo on/off
       
   157     iNotifyHandlerForOpLogo = CCenRepNotifyHandler::NewL( *this, 
       
   158                            *iPersonalizationRepository,
       
   159                            CCenRepNotifyHandler::EIntKey, 
       
   160                            KSettingsDisplayOperatorLogo );
       
   161     iNotifyHandlerForOpLogo->StartListeningL();
       
   162     iNotifyHandlerForOpLogoVisible = CCenRepNotifyHandler::NewL( *this, 
       
   163                            *iPersonalizationRepository,
       
   164                            CCenRepNotifyHandler::EIntKey, 
       
   165                            KSettingsShowOperatorLogoSetting );
       
   166     iNotifyHandlerForOpLogoVisible->StartListeningL();
       
   167     }
       
   168 
       
   169 // ----------------------------------------------------------------------------
       
   170 // CGSDisplayPluginModel::UninitializeCentralRepositoryL
       
   171 //
       
   172 // Removes Central Repository objects
       
   173 // ----------------------------------------------------------------------------
       
   174 //
       
   175 void CGSDisplayPluginModel::UninitializeCentralRepository()
       
   176     {
       
   177     if ( iStartupConfRepository )
       
   178         {
       
   179         delete iStartupConfRepository;
       
   180         iStartupConfRepository = NULL;
       
   181         }
       
   182     if ( iScreensaverRepository )
       
   183         {
       
   184         delete iScreensaverRepository;
       
   185         iScreensaverRepository = NULL;
       
   186         }
       
   187     if ( iNotifyHandlerForOpLogo )
       
   188         {
       
   189         iNotifyHandlerForOpLogo->StopListening();
       
   190         delete iNotifyHandlerForOpLogo;
       
   191         }
       
   192     if ( iNotifyHandlerForOpLogoVisible )
       
   193         {
       
   194         iNotifyHandlerForOpLogoVisible->StopListening();
       
   195         delete iNotifyHandlerForOpLogoVisible;
       
   196         }
       
   197     if ( iPersonalizationRepository )
       
   198         {
       
   199         delete iPersonalizationRepository;
       
   200         iPersonalizationRepository = NULL;
       
   201         }
       
   202     if ( iLightRepository )
       
   203         {
       
   204         delete iLightRepository;
       
   205         iLightRepository = NULL;
       
   206         }
       
   207     if ( iGSVariationRepository )
       
   208         {
       
   209         delete iGSVariationRepository;
       
   210         iGSVariationRepository = NULL;
       
   211         }
       
   212     if ( iAvkonRepository )
       
   213         {
       
   214         delete iAvkonRepository;
       
   215         iAvkonRepository = NULL;
       
   216         }
       
   217     delete iSecurityRepository;
       
   218     iSecurityRepository = NULL;
       
   219     }
       
   220 
       
   221 
       
   222 // ----------------------------------------------------------------------------
       
   223 // CGSDisplayPluginModel::WelcomeNoteTypeL
       
   224 //
       
   225 // Returns user welcome note type.
       
   226 // ----------------------------------------------------------------------------
       
   227 //
       
   228 TInt CGSDisplayPluginModel::WelcomeNoteTypeL()
       
   229     {
       
   230     TInt type;
       
   231     User::LeaveIfError( iStartupConfRepository->Get( KStartupWelcomeNoteType,
       
   232                                                      type ) );
       
   233 
       
   234     return type;
       
   235     }
       
   236 
       
   237 // ----------------------------------------------------------------------------
       
   238 // CGSDisplayPluginModel::SetWelcomeNoteTypeL
       
   239 //
       
   240 // Sets user welcome note type.
       
   241 // ----------------------------------------------------------------------------
       
   242 //
       
   243 void CGSDisplayPluginModel::SetWelcomeNoteTypeL( const TInt aType )
       
   244     {
       
   245     User::LeaveIfError( iStartupConfRepository->
       
   246                         Set( KStartupWelcomeNoteType, aType ) );
       
   247 
       
   248     if ( aType != KGSWelcomeNoteTypeImage )
       
   249         {
       
   250         // It doesn't matter much if the image deletion fails,
       
   251         // so no need to handle the error.
       
   252         TRAP_IGNORE( iBackgroundApi->DeleteImageL( KGSWelcomeNoteImgPath ) );
       
   253         }
       
   254     }
       
   255 
       
   256 // ----------------------------------------------------------------------------
       
   257 // CGSDisplayPluginModel::GetWelcomeNoteTextL
       
   258 //
       
   259 // Reads welcome note text from shared data and returns it
       
   260 // ----------------------------------------------------------------------------
       
   261 //
       
   262 void CGSDisplayPluginModel::WelcomeNoteTextL( TDes& aNote )
       
   263     {
       
   264     User::LeaveIfError( iStartupConfRepository->Get( KStartupWelcomeNoteText,
       
   265                                                      aNote ) );
       
   266     }
       
   267 
       
   268 // ----------------------------------------------------------------------------
       
   269 // CGSDisplayPluginModel::SetWelcomeNoteTextL
       
   270 //
       
   271 // Writes welcome note text to shared data
       
   272 // ----------------------------------------------------------------------------
       
   273 //
       
   274 void CGSDisplayPluginModel::SetWelcomeNoteTextL( const TDesC& aNote )
       
   275     {
       
   276     User::LeaveIfError( iStartupConfRepository->Set( KStartupWelcomeNoteText,
       
   277                                                      aNote ) );
       
   278     }
       
   279 
       
   280 // ----------------------------------------------------------------------------
       
   281 // CGSDisplayPluginModel::ContrastL
       
   282 //
       
   283 // Returns contrast value.
       
   284 // ----------------------------------------------------------------------------
       
   285 //
       
   286 TInt CGSDisplayPluginModel::ContrastL()
       
   287     {
       
   288     TInt contrast = 0;
       
   289 #ifndef __WINS__
       
   290     if( HAL::Get( HAL::EDisplayContrast, contrast ) == KErrNotSupported )
       
   291         {
       
   292         return KErrNotSupported;
       
   293         }
       
   294 #endif //__WINS__
       
   295     return contrast;
       
   296     }
       
   297 
       
   298 
       
   299 // ----------------------------------------------------------------------------
       
   300 // CGSDisplayPluginModel::SetContrastL
       
   301 //
       
   302 // sets contrast value.
       
   303 // ----------------------------------------------------------------------------
       
   304 //
       
   305 void CGSDisplayPluginModel::SetContrastL( const TInt aContrast )
       
   306     {
       
   307 #ifndef __WINS__
       
   308     __GSLOGSTRING1("[CGSDisplayPluginModel::SetContrastL(%d)]", aContrast );
       
   309     User::LeaveIfError( HAL::Set( HAL::EDisplayContrast, aContrast ) );
       
   310 #endif //__WINS__
       
   311     }
       
   312 
       
   313 
       
   314 // ----------------------------------------------------------------------------
       
   315 // CGSDisplayPluginModel::ScreenSaverObjectL
       
   316 //
       
   317 // Returns screen saver mode.
       
   318 // ----------------------------------------------------------------------------
       
   319 //
       
   320 TInt CGSDisplayPluginModel::ScreenSaverObjectL()
       
   321     {
       
   322     TInt object = KErrNone;
       
   323 
       
   324     User::LeaveIfError( iScreensaverRepository->Get( KScreenSaverObject,
       
   325                                                      object ) );
       
   326 
       
   327     return object;
       
   328     }
       
   329 
       
   330 // ----------------------------------------------------------------------------
       
   331 // CGSDisplayPluginModel::SetScreenSaverObjectL
       
   332 //
       
   333 // Sets screen saver mode.
       
   334 // ----------------------------------------------------------------------------
       
   335 //
       
   336 void CGSDisplayPluginModel::SetScreenSaverObjectL( const TInt aObject )
       
   337     {
       
   338     User::LeaveIfError( iScreensaverRepository->Set( KScreenSaverObject,
       
   339                                                      aObject ) );
       
   340     }
       
   341 
       
   342 
       
   343 // ----------------------------------------------------------------------------
       
   344 // CGSDisplayPluginModel::GetScreenSaverTextL
       
   345 //
       
   346 // Reads screen saver text from shared data and returns it.
       
   347 // ----------------------------------------------------------------------------
       
   348 //
       
   349 void CGSDisplayPluginModel::GetScreenSaverTextL( TDes& aText )
       
   350     {
       
   351     User::LeaveIfError( iScreensaverRepository->Get( KScreenSaverText,
       
   352                                                      aText ) );
       
   353     }
       
   354 
       
   355 // ----------------------------------------------------------------------------
       
   356 // CGSDisplayPluginModel::SetScreenSaverTextL
       
   357 //
       
   358 // Writes screen saver text to shared data.
       
   359 // ----------------------------------------------------------------------------
       
   360 //
       
   361 void CGSDisplayPluginModel::SetScreenSaverTextL( const TDesC& aText )
       
   362     {
       
   363     User::LeaveIfError( iScreensaverRepository->Set( KScreenSaverText,
       
   364                                                      aText ) );
       
   365     }
       
   366 
       
   367 
       
   368 // ----------------------------------------------------------------------------
       
   369 // CGSDisplayPluginModel::ScreenSaverAndKeyguardPeriodL
       
   370 //
       
   371 // Reads screen saver period from shared data and returns it.
       
   372 // ----------------------------------------------------------------------------
       
   373 //
       
   374 TInt CGSDisplayPluginModel::ScreenSaverAndKeyguardPeriodL()
       
   375     {
       
   376     TInt period = KGSSettingOff;
       
   377     User::LeaveIfError( iSecurityRepository->
       
   378             Get( KSettingsAutomaticKeyguardTime, period ) );
       
   379 
       
   380     // period is stored in seconds, but the user setting is in minutes
       
   381     return period / 60;
       
   382     }
       
   383 
       
   384 // ----------------------------------------------------------------------------
       
   385 // CGSDisplayPluginModel::SetScreenSaverAndKeyguardPeriodL
       
   386 //
       
   387 // Writes screen saver text to shared data.
       
   388 // ----------------------------------------------------------------------------
       
   389 //
       
   390 void CGSDisplayPluginModel::SetScreenSaverAndKeyguardPeriodL( const TInt aPeriod )
       
   391     {
       
   392     // value is in minutes but keyguard uses seconds
       
   393     User::LeaveIfError( iSecurityRepository->
       
   394             Set( KSettingsAutomaticKeyguardTime, aPeriod * 60 ) );
       
   395     }
       
   396 
       
   397 
       
   398 // ----------------------------------------------------------------------------
       
   399 // CGSDisplayPluginModel::BacklightPeriodL
       
   400 //
       
   401 // Reads backlight timeout value from shared data and returns it.
       
   402 // ----------------------------------------------------------------------------
       
   403 //
       
   404 TInt CGSDisplayPluginModel::BacklightPeriodL()
       
   405     {
       
   406     TInt period = KGSSettingOff;
       
   407     User::LeaveIfError( iLightRepository->
       
   408                 Get( KDisplayLightsTimeout, period ) );
       
   409 
       
   410     return period;
       
   411     }
       
   412 
       
   413 // ----------------------------------------------------------------------------
       
   414 // CGSDisplayPluginModel::SetBacklightPeriodL
       
   415 //
       
   416 // Writes new backlight timeout value to shared data.
       
   417 // ----------------------------------------------------------------------------
       
   418 //
       
   419 void CGSDisplayPluginModel::SetBacklightPeriodL( const TInt aPeriod )
       
   420     {
       
   421     __GSLOGSTRING1("[CGSDisplayPluginModel::SetBacklightPeriodL(%d)]", aPeriod );
       
   422     User::LeaveIfError( iLightRepository->
       
   423             Set( KDisplayLightsTimeout, aPeriod ) );
       
   424     }
       
   425 
       
   426 
       
   427 // ----------------------------------------------------------------------------
       
   428 // CGSDisplayPluginModel::AmbientLightSensorL
       
   429 //
       
   430 // Returns Ambient Light Sensor value.
       
   431 // ----------------------------------------------------------------------------
       
   432 //
       
   433 TInt CGSDisplayPluginModel::AmbientLightSensorL()
       
   434     {
       
   435     TInt ret;
       
   436     User::LeaveIfError( iLightRepository->Get( KLightSensorSensitivity,
       
   437                                                ret ) );
       
   438 
       
   439     return ScaleLightSensorValues( ret, ETrue );
       
   440     }
       
   441 
       
   442 
       
   443 // ----------------------------------------------------------------------------
       
   444 // CGSDisplayPluginModel::SetAmbientLightSensorL
       
   445 //
       
   446 // Sets Ambient Light Sensor value.
       
   447 // ----------------------------------------------------------------------------
       
   448 //
       
   449 void CGSDisplayPluginModel::SetAmbientLightSensorL(
       
   450                             const TInt aSensorSensitivity )
       
   451     {
       
   452     TInt sensitivity;
       
   453     sensitivity = ScaleLightSensorValues( aSensorSensitivity, EFalse );
       
   454 
       
   455     User::LeaveIfError( iLightRepository->
       
   456         Set( KLightSensorSensitivity, sensitivity ) );
       
   457     }
       
   458 
       
   459 
       
   460 // ----------------------------------------------------------------------------
       
   461 // CGSDisplayPluginModel::ScaleLightSensorValues
       
   462 //
       
   463 // Scaling Ambient Light Sensor values
       
   464 // ----------------------------------------------------------------------------
       
   465 //
       
   466 TInt CGSDisplayPluginModel::ScaleLightSensorValues( TInt aValue,
       
   467                                                     TBool aDirection )
       
   468     {
       
   469     TInt coeff = 25;
       
   470     TInt ret = 0;
       
   471 
       
   472     if( aDirection ) //scaling to slider steps
       
   473         {
       
   474         ret = ( aValue / coeff ) + 1;
       
   475         }
       
   476     else //scaling to sensor percentage
       
   477         {
       
   478         ret = ( aValue - 1 ) * coeff;
       
   479         }
       
   480 
       
   481     return ret;
       
   482     }
       
   483 
       
   484 
       
   485 // ----------------------------------------------------------------------------
       
   486 // CGSDisplayPluginModel::HandleNotifyInt
       
   487 //
       
   488 // Handle notification from MCenRepNotifyHandlerCallback
       
   489 // ----------------------------------------------------------------------------
       
   490 //
       
   491 void CGSDisplayPluginModel::HandleNotifyInt( TUint32 aId, TInt /*aNewValue*/)
       
   492     {
       
   493     if ( aId == KSettingsDisplayOperatorLogo ||
       
   494          aId == KSettingsShowOperatorLogoSetting )
       
   495         {
       
   496         iContainer->UpdateListBoxL(EGSSettIdOperatorLogo);
       
   497         iContainer->CloseDialog();
       
   498         }
       
   499     }
       
   500 
       
   501 
       
   502 // ----------------------------------------------------------------------------
       
   503 // CGSDisplayPluginModel::ScaleIntensityValues
       
   504 //
       
   505 // Converts the slider control steps to Intensity values
       
   506 // ----------------------------------------------------------------------------
       
   507 //
       
   508 TInt CGSDisplayPluginModel::ScaleIntensityValues( TInt aValue, TBool aSample )
       
   509     {
       
   510     TReal sampledValue;
       
   511     TReal intResult;
       
   512     TReal sampleCoeff = 3.226; //100 by 31
       
   513     TInt aDecimalPlaces = 0;
       
   514     TInt32 result;
       
   515 
       
   516     if( aSample )
       
   517         {
       
   518         intResult = sampleCoeff * aValue;
       
   519         }
       
   520     else
       
   521         {
       
   522         intResult = aValue / sampleCoeff;
       
   523         }
       
   524 
       
   525     if( intResult > 1 )
       
   526         {
       
   527         Math::Round( sampledValue, intResult, aDecimalPlaces );
       
   528         Math::Int( result, sampledValue );
       
   529         }
       
   530     else
       
   531         {
       
   532         result = 1;
       
   533         }
       
   534     return result;
       
   535     }
       
   536 
       
   537 
       
   538 // ----------------------------------------------------------------------------
       
   539 // CGSDisplayPluginModel::SetBackLightValueL
       
   540 //
       
   541 // ----------------------------------------------------------------------------
       
   542 //
       
   543 void CGSDisplayPluginModel::SetBackLightValueL()
       
   544     {
       
   545     iCoreAppProperty->Attach( KPSUidCoreApplicationUIs, KLightsControl );
       
   546 
       
   547     TLightsControl value = ELightsUninitialized;
       
   548     iCoreAppProperty->Set( KPSUidCoreApplicationUIs,
       
   549                            KLightsControl, value );
       
   550 
       
   551     iCoreAppProperty->Cancel();
       
   552 
       
   553     delete iCoreAppProperty;
       
   554     iCoreAppProperty = NULL;
       
   555     }
       
   556 
       
   557 // ----------------------------------------------------------------------------
       
   558 // CGSDisplayPluginModel::IsUWNoteSupportedL
       
   559 //
       
   560 // Allow user welcome note item to be disabled, if required
       
   561 // ----------------------------------------------------------------------------
       
   562 //
       
   563 TInt CGSDisplayPluginModel::IsUWNoteSupportedL()
       
   564     {
       
   565     TInt value = KGSSettingOff;
       
   566     User::LeaveIfError( iPersonalizationRepository->
       
   567             Get( KSettingsWelcomeNoteSupported, value ) );
       
   568 
       
   569     return value;
       
   570     }
       
   571 
       
   572 
       
   573 // ----------------------------------------------------------------------------
       
   574 // CGSDisplayPluginModel::BrightnessL
       
   575 //
       
   576 // Returns brightness value from DosLights.
       
   577 // ----------------------------------------------------------------------------
       
   578 //
       
   579 TInt CGSDisplayPluginModel::BrightnessL()
       
   580     {
       
   581     if( FeatureManager::FeatureSupported( KFeatureIdBrightnessControl ) )
       
   582         {
       
   583         TInt brightness;
       
   584         User::LeaveIfError( iLightRepository->Get( KLightIntensity,
       
   585                                                    brightness ) );
       
   586 
       
   587         return ScaleIntensityValues( brightness, EFalse );
       
   588         }
       
   589     else
       
   590         {
       
   591         return KErrNotSupported;
       
   592         }
       
   593     }
       
   594 
       
   595 
       
   596 // ----------------------------------------------------------------------------
       
   597 // CGSDisplayPluginModel::SetBrightnessL
       
   598 //
       
   599 // Sets brightness value to DosLights.
       
   600 // ----------------------------------------------------------------------------
       
   601 //
       
   602 void CGSDisplayPluginModel::SetBrightnessL( const TInt aBrightness )
       
   603     {
       
   604     if( FeatureManager::FeatureSupported( KFeatureIdBrightnessControl ) )
       
   605         {
       
   606         TInt brightness;
       
   607 
       
   608         brightness = ScaleIntensityValues( aBrightness, ETrue );
       
   609         __GSLOGSTRING1("[CGSDisplayPluginModel::SetBrightnessL(%d)]", aBrightness );
       
   610         User::LeaveIfError( iLightRepository->Set( KLightIntensity,
       
   611                                                    brightness ) );
       
   612         }
       
   613     }
       
   614 
       
   615 
       
   616 // ----------------------------------------------------------------------------
       
   617 // CGSDisplayPluginModel::DisplayTextSizeL
       
   618 //
       
   619 // Return current display text size.
       
   620 // ----------------------------------------------------------------------------
       
   621 //
       
   622 TInt CGSDisplayPluginModel::DisplayTextSizeL()
       
   623     {
       
   624     TInt textSize = EAknUiZoomNormal;
       
   625 
       
   626     if ( FeatureManager::FeatureSupported ( KFeatureIdUiZoom ) )
       
   627         {
       
   628         User::LeaveIfError( iAvkonRepository->Get( KAknGlobalUiZoom,
       
   629                                                    textSize ) );
       
   630         }
       
   631 
       
   632     return textSize;
       
   633     }
       
   634 
       
   635 
       
   636 // ----------------------------------------------------------------------------
       
   637 // CGSDisplayPluginModel::SetDisplayTextSizeL
       
   638 //
       
   639 // Sets new display text size.
       
   640 // ----------------------------------------------------------------------------
       
   641 //
       
   642 void CGSDisplayPluginModel::SetDisplayTextSizeL( TInt aSize )
       
   643     {
       
   644     // not checking for feature manager constant to avoid compiler
       
   645     // warning for the input parameter.
       
   646     User::LeaveIfError( iAvkonRepository->Set( KAknGlobalUiZoom, aSize ) );
       
   647     }
       
   648 
       
   649 
       
   650 // ----------------------------------------------------------------------------
       
   651 // CGSDisplayPluginModel::PowerSaveLedL
       
   652 //
       
   653 // Returns Tracking Transaction state value.
       
   654 // ----------------------------------------------------------------------------
       
   655 //
       
   656 TInt CGSDisplayPluginModel::PowerSaveLedL()
       
   657     {
       
   658     TInt ret = 0;
       
   659     User::LeaveIfError( iPersonalizationRepository->Get(
       
   660         KSettingsDisplayTurnoffTimeout, ret ) );
       
   661     return ret;
       
   662     }
       
   663 
       
   664 
       
   665 // ----------------------------------------------------------------------------
       
   666 // CGSDisplayPluginModel::SetPowerSaveLedL
       
   667 //
       
   668 // Sets Tracking Transaction state value.
       
   669 // ----------------------------------------------------------------------------
       
   670 //
       
   671 void CGSDisplayPluginModel::SetPowerSaveLedL( const TInt aPowerLedState )
       
   672     {
       
   673     User::LeaveIfError( iPersonalizationRepository->
       
   674         Set( KSettingsDisplayTurnoffTimeout, aPowerLedState ) );
       
   675 
       
   676     }
       
   677 
       
   678 
       
   679 // ----------------------------------------------------------------------------
       
   680 // CGSDisplayPluginModel::CheckPowerSaveLedSupportL
       
   681 //
       
   682 // Checks local variation flag for supporting Power Save Led feature.
       
   683 // ----------------------------------------------------------------------------
       
   684 //
       
   685 TInt CGSDisplayPluginModel::CheckPowerSaveLedSupportL()
       
   686     {
       
   687     TInt value = 0;
       
   688     User::LeaveIfError( iGSVariationRepository->Get(
       
   689                         KSettingsVariationFlags, value ) );
       
   690 
       
   691     TBool supported = EFalse;
       
   692 
       
   693     if ( value & EGSConfigPowerSaveLed )
       
   694         {
       
   695         supported = ETrue;
       
   696         }
       
   697 
       
   698     return supported;
       
   699     }
       
   700 
       
   701 
       
   702 // ----------------------------------------------------------------------------
       
   703 // CGSDisplayPluginModel::BackgroundImage
       
   704 // ----------------------------------------------------------------------------
       
   705 //
       
   706 CGSBackgroundImage* CGSDisplayPluginModel::BackgroundImage()
       
   707     {
       
   708     return iBackgroundApi;
       
   709     }
       
   710 
       
   711 
       
   712 // ----------------------------------------------------------------------------
       
   713 // CGSDisplayPluginModel::CheckScreenSaverTimeoutSupportL
       
   714 // 
       
   715 // Checks ScreenSaver timeout support
       
   716 // ----------------------------------------------------------------------------
       
   717 //
       
   718 TBool CGSDisplayPluginModel::CheckScreenSaverTimeoutSupportL()
       
   719     {
       
   720     TInt value = 0;
       
   721     User::LeaveIfError( iPersonalizationRepository->Get(
       
   722                         KSettingsScreensaverTimeoutItemVisibility, value ) );
       
   723     
       
   724     if ( value )
       
   725         {
       
   726         return ETrue;
       
   727         }
       
   728     else
       
   729         {
       
   730         return EFalse;
       
   731         }
       
   732     }
       
   733 
       
   734 
       
   735 // ----------------------------------------------------------------------------
       
   736 // CGSDisplayPluginModel::ShowOperatorLogoSettingL
       
   737 //
       
   738 // Checks if Operator Logo item is to be made visible.
       
   739 // ----------------------------------------------------------------------------
       
   740 //
       
   741 TBool CGSDisplayPluginModel::ShowOperatorLogoSettingL()
       
   742     {
       
   743     TInt opLogoSettingState = KGSSettingOff;
       
   744     TBool showSetting = EFalse;
       
   745 
       
   746     User::LeaveIfError( iPersonalizationRepository->
       
   747         Get( KSettingsShowOperatorLogoSetting, opLogoSettingState ) );
       
   748     switch( opLogoSettingState )
       
   749         {
       
   750         case KGSSettingOn:
       
   751             showSetting = ETrue;
       
   752             break;
       
   753         case KGSSettingOff:
       
   754             showSetting = EFalse;
       
   755         default:
       
   756             break;
       
   757         }
       
   758     return showSetting;
       
   759     }
       
   760 
       
   761 
       
   762 // ----------------------------------------------------------------------------
       
   763 // CGSDisplayPluginModel::OperatorLogoL
       
   764 //
       
   765 // Returns operator logo value from shared data.
       
   766 // ----------------------------------------------------------------------------
       
   767 //
       
   768 TInt CGSDisplayPluginModel::OperatorLogoL()
       
   769     {
       
   770     TInt opLogo = KGSSettingOff;
       
   771     User::LeaveIfError( iPersonalizationRepository->
       
   772         Get( KSettingsDisplayOperatorLogo, opLogo ) );
       
   773     return opLogo;
       
   774     }
       
   775 
       
   776 
       
   777 // ----------------------------------------------------------------------------
       
   778 // CGSDisplayPluginModel::SetOperatorLogoL
       
   779 //
       
   780 // Sets operator logo value to shared data.
       
   781 // ----------------------------------------------------------------------------
       
   782 //
       
   783 void CGSDisplayPluginModel::SetOperatorLogoL( TInt aOperatorLogo )
       
   784     {
       
   785     User::LeaveIfError( iPersonalizationRepository->
       
   786         Set( KSettingsDisplayOperatorLogo, aOperatorLogo ) );
       
   787     }
       
   788 
       
   789 // ----------------------------------------------------------------------------
       
   790 // CGSDisplayPluginModel::SetOwner
       
   791 //
       
   792 // Sets its owner.
       
   793 // ----------------------------------------------------------------------------
       
   794 //
       
   795 void CGSDisplayPluginModel::SetOwner( CGSDisplayPluginContainer* aContainer)
       
   796     {
       
   797     iContainer = aContainer;
       
   798     }
       
   799 
       
   800 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   801 
       
   802 // End of File