gssettingsuis/Gs/GSDisplayPlugin/Src/GSDisplayPluginModel.cpp
changeset 0 8c5d936e5675
child 11 23553eb4e470
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     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     iGSVariationRepository = CRepository::NewL( KCRUidSettingsVariation );
       
   153     iAvkonRepository = CRepository::NewL( KCRUidAvkon );
       
   154     
       
   155     // start listening to CenRep key changes for Operator Logo on/off
       
   156     iNotifyHandlerForOpLogo = CCenRepNotifyHandler::NewL( *this, 
       
   157                            *iPersonalizationRepository,
       
   158                            CCenRepNotifyHandler::EIntKey, 
       
   159                            KSettingsDisplayOperatorLogo );
       
   160     iNotifyHandlerForOpLogo->StartListeningL();
       
   161     iNotifyHandlerForOpLogoVisible = CCenRepNotifyHandler::NewL( *this, 
       
   162                            *iPersonalizationRepository,
       
   163                            CCenRepNotifyHandler::EIntKey, 
       
   164                            KSettingsShowOperatorLogoSetting );
       
   165     iNotifyHandlerForOpLogoVisible->StartListeningL();
       
   166     }
       
   167 
       
   168 // ----------------------------------------------------------------------------
       
   169 // CGSDisplayPluginModel::UninitializeCentralRepositoryL
       
   170 //
       
   171 // Removes Central Repository objects
       
   172 // ----------------------------------------------------------------------------
       
   173 //
       
   174 void CGSDisplayPluginModel::UninitializeCentralRepository()
       
   175     {
       
   176     if ( iStartupConfRepository )
       
   177         {
       
   178         delete iStartupConfRepository;
       
   179         iStartupConfRepository = NULL;
       
   180         }
       
   181     if ( iScreensaverRepository )
       
   182         {
       
   183         delete iScreensaverRepository;
       
   184         iScreensaverRepository = NULL;
       
   185         }
       
   186     if ( iNotifyHandlerForOpLogo )
       
   187         {
       
   188         iNotifyHandlerForOpLogo->StopListening();
       
   189         delete iNotifyHandlerForOpLogo;
       
   190         }
       
   191     if ( iNotifyHandlerForOpLogoVisible )
       
   192         {
       
   193         iNotifyHandlerForOpLogoVisible->StopListening();
       
   194         delete iNotifyHandlerForOpLogoVisible;
       
   195         }
       
   196     if ( iPersonalizationRepository )
       
   197         {
       
   198         delete iPersonalizationRepository;
       
   199         iPersonalizationRepository = NULL;
       
   200         }
       
   201     if ( iLightRepository )
       
   202         {
       
   203         delete iLightRepository;
       
   204         iLightRepository = NULL;
       
   205         }
       
   206     if ( iGSVariationRepository )
       
   207         {
       
   208         delete iGSVariationRepository;
       
   209         iGSVariationRepository = NULL;
       
   210         }
       
   211     if ( iAvkonRepository )
       
   212         {
       
   213         delete iAvkonRepository;
       
   214         iAvkonRepository = NULL;
       
   215         }
       
   216     }
       
   217 
       
   218 
       
   219 // ----------------------------------------------------------------------------
       
   220 // CGSDisplayPluginModel::WelcomeNoteTypeL
       
   221 //
       
   222 // Returns user welcome note type.
       
   223 // ----------------------------------------------------------------------------
       
   224 //
       
   225 TInt CGSDisplayPluginModel::WelcomeNoteTypeL()
       
   226     {
       
   227     TInt type;
       
   228     User::LeaveIfError( iStartupConfRepository->Get( KStartupWelcomeNoteType,
       
   229                                                      type ) );
       
   230 
       
   231     return type;
       
   232     }
       
   233 
       
   234 // ----------------------------------------------------------------------------
       
   235 // CGSDisplayPluginModel::SetWelcomeNoteTypeL
       
   236 //
       
   237 // Sets user welcome note type.
       
   238 // ----------------------------------------------------------------------------
       
   239 //
       
   240 void CGSDisplayPluginModel::SetWelcomeNoteTypeL( const TInt aType )
       
   241     {
       
   242     User::LeaveIfError( iStartupConfRepository->
       
   243                         Set( KStartupWelcomeNoteType, aType ) );
       
   244 
       
   245     if ( aType != KGSWelcomeNoteTypeImage )
       
   246         {
       
   247         // It doesn't matter much if the image deletion fails,
       
   248         // so no need to handle the error.
       
   249         TRAP_IGNORE( iBackgroundApi->DeleteImageL( KGSWelcomeNoteImgPath ) );
       
   250         }
       
   251     }
       
   252 
       
   253 // ----------------------------------------------------------------------------
       
   254 // CGSDisplayPluginModel::GetWelcomeNoteTextL
       
   255 //
       
   256 // Reads welcome note text from shared data and returns it
       
   257 // ----------------------------------------------------------------------------
       
   258 //
       
   259 void CGSDisplayPluginModel::WelcomeNoteTextL( TDes& aNote )
       
   260     {
       
   261     User::LeaveIfError( iStartupConfRepository->Get( KStartupWelcomeNoteText,
       
   262                                                      aNote ) );
       
   263     }
       
   264 
       
   265 // ----------------------------------------------------------------------------
       
   266 // CGSDisplayPluginModel::SetWelcomeNoteTextL
       
   267 //
       
   268 // Writes welcome note text to shared data
       
   269 // ----------------------------------------------------------------------------
       
   270 //
       
   271 void CGSDisplayPluginModel::SetWelcomeNoteTextL( const TDesC& aNote )
       
   272     {
       
   273     User::LeaveIfError( iStartupConfRepository->Set( KStartupWelcomeNoteText,
       
   274                                                      aNote ) );
       
   275     }
       
   276 
       
   277 // ----------------------------------------------------------------------------
       
   278 // CGSDisplayPluginModel::ContrastL
       
   279 //
       
   280 // Returns contrast value.
       
   281 // ----------------------------------------------------------------------------
       
   282 //
       
   283 TInt CGSDisplayPluginModel::ContrastL()
       
   284     {
       
   285     TInt contrast = 0;
       
   286 #ifndef __WINS__
       
   287     if( HAL::Get( HAL::EDisplayContrast, contrast ) == KErrNotSupported )
       
   288         {
       
   289         return KErrNotSupported;
       
   290         }
       
   291 #endif //__WINS__
       
   292     return contrast;
       
   293     }
       
   294 
       
   295 
       
   296 // ----------------------------------------------------------------------------
       
   297 // CGSDisplayPluginModel::SetContrastL
       
   298 //
       
   299 // sets contrast value.
       
   300 // ----------------------------------------------------------------------------
       
   301 //
       
   302 void CGSDisplayPluginModel::SetContrastL( const TInt aContrast )
       
   303     {
       
   304 #ifndef __WINS__
       
   305     __GSLOGSTRING1("[CGSDisplayPluginModel::SetContrastL(%d)]", aContrast );
       
   306     User::LeaveIfError( HAL::Set( HAL::EDisplayContrast, aContrast ) );
       
   307 #endif //__WINS__
       
   308     }
       
   309 
       
   310 
       
   311 // ----------------------------------------------------------------------------
       
   312 // CGSDisplayPluginModel::ScreenSaverObjectL
       
   313 //
       
   314 // Returns screen saver mode.
       
   315 // ----------------------------------------------------------------------------
       
   316 //
       
   317 TInt CGSDisplayPluginModel::ScreenSaverObjectL()
       
   318     {
       
   319     TInt object = KErrNone;
       
   320 
       
   321     User::LeaveIfError( iScreensaverRepository->Get( KScreenSaverObject,
       
   322                                                      object ) );
       
   323 
       
   324     return object;
       
   325     }
       
   326 
       
   327 // ----------------------------------------------------------------------------
       
   328 // CGSDisplayPluginModel::SetScreenSaverObjectL
       
   329 //
       
   330 // Sets screen saver mode.
       
   331 // ----------------------------------------------------------------------------
       
   332 //
       
   333 void CGSDisplayPluginModel::SetScreenSaverObjectL( const TInt aObject )
       
   334     {
       
   335     User::LeaveIfError( iScreensaverRepository->Set( KScreenSaverObject,
       
   336                                                      aObject ) );
       
   337     }
       
   338 
       
   339 
       
   340 // ----------------------------------------------------------------------------
       
   341 // CGSDisplayPluginModel::GetScreenSaverTextL
       
   342 //
       
   343 // Reads screen saver text from shared data and returns it.
       
   344 // ----------------------------------------------------------------------------
       
   345 //
       
   346 void CGSDisplayPluginModel::GetScreenSaverTextL( TDes& aText )
       
   347     {
       
   348     User::LeaveIfError( iScreensaverRepository->Get( KScreenSaverText,
       
   349                                                      aText ) );
       
   350     }
       
   351 
       
   352 // ----------------------------------------------------------------------------
       
   353 // CGSDisplayPluginModel::SetScreenSaverTextL
       
   354 //
       
   355 // Writes screen saver text to shared data.
       
   356 // ----------------------------------------------------------------------------
       
   357 //
       
   358 void CGSDisplayPluginModel::SetScreenSaverTextL( const TDesC& aText )
       
   359     {
       
   360     User::LeaveIfError( iScreensaverRepository->Set( KScreenSaverText,
       
   361                                                      aText ) );
       
   362     }
       
   363 
       
   364 
       
   365 // ----------------------------------------------------------------------------
       
   366 // CGSDisplayPluginModel::ScreenSaverPeriodL
       
   367 //
       
   368 // Reads screen saver period from shared data and returns it.
       
   369 // ----------------------------------------------------------------------------
       
   370 //
       
   371 TInt CGSDisplayPluginModel::ScreenSaverPeriodL()
       
   372     {
       
   373     TInt period = KGSSettingOff;
       
   374     User::LeaveIfError( iPersonalizationRepository->
       
   375             Get( KSettingsScreenSaverPeriod, period ) );
       
   376 
       
   377     return period;
       
   378     }
       
   379 
       
   380 // ----------------------------------------------------------------------------
       
   381 // CGSDisplayPluginModel::SetScreenSaverPeriodL
       
   382 //
       
   383 // Writes screen saver text to shared data.
       
   384 // ----------------------------------------------------------------------------
       
   385 //
       
   386 void CGSDisplayPluginModel::SetScreenSaverPeriodL( const TInt aPeriod )
       
   387     {
       
   388     User::LeaveIfError( iPersonalizationRepository->
       
   389             Set( KSettingsScreenSaverPeriod, aPeriod ) );
       
   390     }
       
   391 
       
   392 
       
   393 // ----------------------------------------------------------------------------
       
   394 // CGSDisplayPluginModel::BacklightPeriodL
       
   395 //
       
   396 // Reads backlight timeout value from shared data and returns it.
       
   397 // ----------------------------------------------------------------------------
       
   398 //
       
   399 TInt CGSDisplayPluginModel::BacklightPeriodL()
       
   400     {
       
   401     TInt period = KGSSettingOff;
       
   402     User::LeaveIfError( iLightRepository->
       
   403                 Get( KDisplayLightsTimeout, period ) );
       
   404 
       
   405     return period;
       
   406     }
       
   407 
       
   408 // ----------------------------------------------------------------------------
       
   409 // CGSDisplayPluginModel::SetBacklightPeriodL
       
   410 //
       
   411 // Writes new backlight timeout value to shared data.
       
   412 // ----------------------------------------------------------------------------
       
   413 //
       
   414 void CGSDisplayPluginModel::SetBacklightPeriodL( const TInt aPeriod )
       
   415     {
       
   416     __GSLOGSTRING1("[CGSDisplayPluginModel::SetBacklightPeriodL(%d)]", aPeriod );
       
   417     User::LeaveIfError( iLightRepository->
       
   418             Set( KDisplayLightsTimeout, aPeriod ) );
       
   419     }
       
   420 
       
   421 
       
   422 // ----------------------------------------------------------------------------
       
   423 // CGSDisplayPluginModel::AmbientLightSensorL
       
   424 //
       
   425 // Returns Ambient Light Sensor value.
       
   426 // ----------------------------------------------------------------------------
       
   427 //
       
   428 TInt CGSDisplayPluginModel::AmbientLightSensorL()
       
   429     {
       
   430     TInt ret;
       
   431     User::LeaveIfError( iLightRepository->Get( KLightSensorSensitivity,
       
   432                                                ret ) );
       
   433 
       
   434     return ScaleLightSensorValues( ret, ETrue );
       
   435     }
       
   436 
       
   437 
       
   438 // ----------------------------------------------------------------------------
       
   439 // CGSDisplayPluginModel::SetAmbientLightSensorL
       
   440 //
       
   441 // Sets Ambient Light Sensor value.
       
   442 // ----------------------------------------------------------------------------
       
   443 //
       
   444 void CGSDisplayPluginModel::SetAmbientLightSensorL(
       
   445                             const TInt aSensorSensitivity )
       
   446     {
       
   447     TInt sensitivity;
       
   448     sensitivity = ScaleLightSensorValues( aSensorSensitivity, EFalse );
       
   449 
       
   450     User::LeaveIfError( iLightRepository->
       
   451         Set( KLightSensorSensitivity, sensitivity ) );
       
   452     }
       
   453 
       
   454 
       
   455 // ----------------------------------------------------------------------------
       
   456 // CGSDisplayPluginModel::ScaleLightSensorValues
       
   457 //
       
   458 // Scaling Ambient Light Sensor values
       
   459 // ----------------------------------------------------------------------------
       
   460 //
       
   461 TInt CGSDisplayPluginModel::ScaleLightSensorValues( TInt aValue,
       
   462                                                     TBool aDirection )
       
   463     {
       
   464     TInt coeff = 25;
       
   465     TInt ret = 0;
       
   466 
       
   467     if( aDirection ) //scaling to slider steps
       
   468         {
       
   469         ret = ( aValue / coeff ) + 1;
       
   470         }
       
   471     else //scaling to sensor percentage
       
   472         {
       
   473         ret = ( aValue - 1 ) * coeff;
       
   474         }
       
   475 
       
   476     return ret;
       
   477     }
       
   478 
       
   479 
       
   480 // ----------------------------------------------------------------------------
       
   481 // CGSDisplayPluginModel::HandleNotifyInt
       
   482 //
       
   483 // Handle notification from MCenRepNotifyHandlerCallback
       
   484 // ----------------------------------------------------------------------------
       
   485 //
       
   486 void CGSDisplayPluginModel::HandleNotifyInt( TUint32 aId, TInt /*aNewValue*/)
       
   487     {
       
   488     if ( aId == KSettingsDisplayOperatorLogo ||
       
   489          aId == KSettingsShowOperatorLogoSetting )
       
   490         {
       
   491         iContainer->UpdateListBoxL(EGSSettIdOperatorLogo);
       
   492         iContainer->CloseDialog();
       
   493         }
       
   494     }
       
   495 
       
   496 
       
   497 // ----------------------------------------------------------------------------
       
   498 // CGSDisplayPluginModel::ScaleIntensityValues
       
   499 //
       
   500 // Converts the slider control steps to Intensity values
       
   501 // ----------------------------------------------------------------------------
       
   502 //
       
   503 TInt CGSDisplayPluginModel::ScaleIntensityValues( TInt aValue, TBool aSample )
       
   504     {
       
   505     TReal sampledValue;
       
   506     TReal intResult;
       
   507     TReal sampleCoeff = 3.226; //100 by 31
       
   508     TInt aDecimalPlaces = 0;
       
   509     TInt32 result;
       
   510 
       
   511     if( aSample )
       
   512         {
       
   513         intResult = sampleCoeff * aValue;
       
   514         }
       
   515     else
       
   516         {
       
   517         intResult = aValue / sampleCoeff;
       
   518         }
       
   519 
       
   520     if( intResult > 1 )
       
   521         {
       
   522         Math::Round( sampledValue, intResult, aDecimalPlaces );
       
   523         Math::Int( result, sampledValue );
       
   524         }
       
   525     else
       
   526         {
       
   527         result = 1;
       
   528         }
       
   529     return result;
       
   530     }
       
   531 
       
   532 
       
   533 // ----------------------------------------------------------------------------
       
   534 // CGSDisplayPluginModel::SetBackLightValueL
       
   535 //
       
   536 // ----------------------------------------------------------------------------
       
   537 //
       
   538 void CGSDisplayPluginModel::SetBackLightValueL()
       
   539     {
       
   540     iCoreAppProperty->Attach( KPSUidCoreApplicationUIs, KLightsControl );
       
   541 
       
   542     TLightsControl value = ELightsUninitialized;
       
   543     iCoreAppProperty->Set( KPSUidCoreApplicationUIs,
       
   544                            KLightsControl, value );
       
   545 
       
   546     iCoreAppProperty->Cancel();
       
   547 
       
   548     delete iCoreAppProperty;
       
   549     iCoreAppProperty = NULL;
       
   550     }
       
   551 
       
   552 // ----------------------------------------------------------------------------
       
   553 // CGSDisplayPluginModel::IsUWNoteSupportedL
       
   554 //
       
   555 // Allow user welcome note item to be disabled, if required
       
   556 // ----------------------------------------------------------------------------
       
   557 //
       
   558 TInt CGSDisplayPluginModel::IsUWNoteSupportedL()
       
   559     {
       
   560     TInt value = KGSSettingOff;
       
   561     User::LeaveIfError( iPersonalizationRepository->
       
   562             Get( KSettingsWelcomeNoteSupported, value ) );
       
   563 
       
   564     return value;
       
   565     }
       
   566 
       
   567 
       
   568 // ----------------------------------------------------------------------------
       
   569 // CGSDisplayPluginModel::BrightnessL
       
   570 //
       
   571 // Returns brightness value from DosLights.
       
   572 // ----------------------------------------------------------------------------
       
   573 //
       
   574 TInt CGSDisplayPluginModel::BrightnessL()
       
   575     {
       
   576     if( FeatureManager::FeatureSupported( KFeatureIdBrightnessControl ) )
       
   577         {
       
   578         TInt brightness;
       
   579         User::LeaveIfError( iLightRepository->Get( KLightIntensity,
       
   580                                                    brightness ) );
       
   581 
       
   582         return ScaleIntensityValues( brightness, EFalse );
       
   583         }
       
   584     else
       
   585         {
       
   586         return KErrNotSupported;
       
   587         }
       
   588     }
       
   589 
       
   590 
       
   591 // ----------------------------------------------------------------------------
       
   592 // CGSDisplayPluginModel::SetBrightnessL
       
   593 //
       
   594 // Sets brightness value to DosLights.
       
   595 // ----------------------------------------------------------------------------
       
   596 //
       
   597 void CGSDisplayPluginModel::SetBrightnessL( const TInt aBrightness )
       
   598     {
       
   599     if( FeatureManager::FeatureSupported( KFeatureIdBrightnessControl ) )
       
   600         {
       
   601         TInt brightness;
       
   602 
       
   603         brightness = ScaleIntensityValues( aBrightness, ETrue );
       
   604         __GSLOGSTRING1("[CGSDisplayPluginModel::SetBrightnessL(%d)]", aBrightness );
       
   605         User::LeaveIfError( iLightRepository->Set( KLightIntensity,
       
   606                                                    brightness ) );
       
   607         }
       
   608     }
       
   609 
       
   610 
       
   611 // ----------------------------------------------------------------------------
       
   612 // CGSDisplayPluginModel::DisplayTextSizeL
       
   613 //
       
   614 // Return current display text size.
       
   615 // ----------------------------------------------------------------------------
       
   616 //
       
   617 TInt CGSDisplayPluginModel::DisplayTextSizeL()
       
   618     {
       
   619     TInt textSize = EAknUiZoomNormal;
       
   620 
       
   621     if ( FeatureManager::FeatureSupported ( KFeatureIdUiZoom ) )
       
   622         {
       
   623         User::LeaveIfError( iAvkonRepository->Get( KAknGlobalUiZoom,
       
   624                                                    textSize ) );
       
   625         }
       
   626 
       
   627     return textSize;
       
   628     }
       
   629 
       
   630 
       
   631 // ----------------------------------------------------------------------------
       
   632 // CGSDisplayPluginModel::SetDisplayTextSizeL
       
   633 //
       
   634 // Sets new display text size.
       
   635 // ----------------------------------------------------------------------------
       
   636 //
       
   637 void CGSDisplayPluginModel::SetDisplayTextSizeL( TInt aSize )
       
   638     {
       
   639     // not checking for feature manager constant to avoid compiler
       
   640     // warning for the input parameter.
       
   641     User::LeaveIfError( iAvkonRepository->Set( KAknGlobalUiZoom, aSize ) );
       
   642     }
       
   643 
       
   644 
       
   645 // ----------------------------------------------------------------------------
       
   646 // CGSDisplayPluginModel::PowerSaveLedL
       
   647 //
       
   648 // Returns Tracking Transaction state value.
       
   649 // ----------------------------------------------------------------------------
       
   650 //
       
   651 TInt CGSDisplayPluginModel::PowerSaveLedL()
       
   652     {
       
   653     TInt ret = 0;
       
   654     User::LeaveIfError( iPersonalizationRepository->Get(
       
   655         KSettingsDisplayTurnoffTimeout, ret ) );
       
   656     return ret;
       
   657     }
       
   658 
       
   659 
       
   660 // ----------------------------------------------------------------------------
       
   661 // CGSDisplayPluginModel::SetPowerSaveLedL
       
   662 //
       
   663 // Sets Tracking Transaction state value.
       
   664 // ----------------------------------------------------------------------------
       
   665 //
       
   666 void CGSDisplayPluginModel::SetPowerSaveLedL( const TInt aPowerLedState )
       
   667     {
       
   668     User::LeaveIfError( iPersonalizationRepository->
       
   669         Set( KSettingsDisplayTurnoffTimeout, aPowerLedState ) );
       
   670 
       
   671     }
       
   672 
       
   673 
       
   674 // ----------------------------------------------------------------------------
       
   675 // CGSDisplayPluginModel::CheckPowerSaveLedSupportL
       
   676 //
       
   677 // Checks local variation flag for supporting Power Save Led feature.
       
   678 // ----------------------------------------------------------------------------
       
   679 //
       
   680 TInt CGSDisplayPluginModel::CheckPowerSaveLedSupportL()
       
   681     {
       
   682     TInt value = 0;
       
   683     User::LeaveIfError( iGSVariationRepository->Get(
       
   684                         KSettingsVariationFlags, value ) );
       
   685 
       
   686     TBool supported = EFalse;
       
   687 
       
   688     if ( value & EGSConfigPowerSaveLed )
       
   689         {
       
   690         supported = ETrue;
       
   691         }
       
   692 
       
   693     return supported;
       
   694     }
       
   695 
       
   696 
       
   697 // ----------------------------------------------------------------------------
       
   698 // CGSDisplayPluginModel::BackgroundImage
       
   699 // ----------------------------------------------------------------------------
       
   700 //
       
   701 CGSBackgroundImage* CGSDisplayPluginModel::BackgroundImage()
       
   702     {
       
   703     return iBackgroundApi;
       
   704     }
       
   705 
       
   706 
       
   707 // ----------------------------------------------------------------------------
       
   708 // CGSDisplayPluginModel::CheckScreenSaverTimeoutSupportL
       
   709 // 
       
   710 // Checks ScreenSaver timeout support
       
   711 // ----------------------------------------------------------------------------
       
   712 //
       
   713 TBool CGSDisplayPluginModel::CheckScreenSaverTimeoutSupportL()
       
   714     {
       
   715     TInt value = 0;
       
   716     User::LeaveIfError( iPersonalizationRepository->Get(
       
   717                         KSettingsScreensaverTimeoutItemVisibility, value ) );
       
   718     
       
   719     if ( value )
       
   720         {
       
   721         return ETrue;
       
   722         }
       
   723     else
       
   724         {
       
   725         return EFalse;
       
   726         }
       
   727     }
       
   728 
       
   729 
       
   730 // ----------------------------------------------------------------------------
       
   731 // CGSDisplayPluginModel::ShowOperatorLogoSettingL
       
   732 //
       
   733 // Checks if Operator Logo item is to be made visible.
       
   734 // ----------------------------------------------------------------------------
       
   735 //
       
   736 TBool CGSDisplayPluginModel::ShowOperatorLogoSettingL()
       
   737     {
       
   738     TInt opLogoSettingState = KGSSettingOff;
       
   739     TBool showSetting = EFalse;
       
   740 
       
   741     User::LeaveIfError( iPersonalizationRepository->
       
   742         Get( KSettingsShowOperatorLogoSetting, opLogoSettingState ) );
       
   743     switch( opLogoSettingState )
       
   744         {
       
   745         case KGSSettingOn:
       
   746             showSetting = ETrue;
       
   747             break;
       
   748         case KGSSettingOff:
       
   749             showSetting = EFalse;
       
   750         default:
       
   751             break;
       
   752         }
       
   753     return showSetting;
       
   754     }
       
   755 
       
   756 
       
   757 // ----------------------------------------------------------------------------
       
   758 // CGSDisplayPluginModel::OperatorLogoL
       
   759 //
       
   760 // Returns operator logo value from shared data.
       
   761 // ----------------------------------------------------------------------------
       
   762 //
       
   763 TInt CGSDisplayPluginModel::OperatorLogoL()
       
   764     {
       
   765     TInt opLogo = KGSSettingOff;
       
   766     User::LeaveIfError( iPersonalizationRepository->
       
   767         Get( KSettingsDisplayOperatorLogo, opLogo ) );
       
   768     return opLogo;
       
   769     }
       
   770 
       
   771 
       
   772 // ----------------------------------------------------------------------------
       
   773 // CGSDisplayPluginModel::SetOperatorLogoL
       
   774 //
       
   775 // Sets operator logo value to shared data.
       
   776 // ----------------------------------------------------------------------------
       
   777 //
       
   778 void CGSDisplayPluginModel::SetOperatorLogoL( TInt aOperatorLogo )
       
   779     {
       
   780     User::LeaveIfError( iPersonalizationRepository->
       
   781         Set( KSettingsDisplayOperatorLogo, aOperatorLogo ) );
       
   782     }
       
   783 
       
   784 // ----------------------------------------------------------------------------
       
   785 // CGSDisplayPluginModel::SetOwner
       
   786 //
       
   787 // Sets its owner.
       
   788 // ----------------------------------------------------------------------------
       
   789 //
       
   790 void CGSDisplayPluginModel::SetOwner( CGSDisplayPluginContainer* aContainer)
       
   791     {
       
   792     iContainer = aContainer;
       
   793     }
       
   794 
       
   795 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   796 
       
   797 // End of File