locationsystemui/locationsysui/locblidsatelliteinfo/src/csatellitemeasurementsetting.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     1 /*
       
     2 * Copyright (c) 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:  Adapter for System of Measurement.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System Include
       
    20 #include <centralrepository.h>
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "csatellitemeasurementsetting.h"
       
    24 #include "msatellitemeasurementsettingobserver.h"
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ==============================
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // CSatelliteMeasurementSetting::CSatelliteMeasurementSetting
       
    33 // Overloaded Constructor
       
    34 //
       
    35 // ---------------------------------------------------------------------------
       
    36 //	
       
    37 CSatelliteMeasurementSetting::CSatelliteMeasurementSetting(  
       
    38                                 MSatelliteMeasurementSettingObserver&	aAdapterObsrv )
       
    39 	:CActive(EPriorityStandard),
       
    40 	iObserver(aAdapterObsrv)
       
    41 	{
       
    42 	}
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CSatelliteMeasurementSetting::~CSatelliteMeasurementSetting
       
    46 // Destructor
       
    47 //
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CSatelliteMeasurementSetting::~CSatelliteMeasurementSetting()
       
    51 	{
       
    52 	Cancel();
       
    53 	delete iRepository;
       
    54 	}
       
    55 	
       
    56 // ---------------------------------------------------------------------------
       
    57 // CSatelliteMeasurementSetting* CSatelliteMeasurementSetting::NewL
       
    58 // Creates new System of Measurement Adapter
       
    59 // ---------------------------------------------------------------------------
       
    60 //    
       
    61 CSatelliteMeasurementSetting* CSatelliteMeasurementSetting::NewL( 
       
    62                             MSatelliteMeasurementSettingObserver&	aAdapterObsrv )
       
    63 	{	
       
    64     CSatelliteMeasurementSetting* self = 
       
    65                         CSatelliteMeasurementSetting::NewLC( aAdapterObsrv );
       
    66 	CleanupStack::Pop(self);
       
    67 	return self;
       
    68 	}
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CSatelliteMeasurementSetting* CSatelliteMeasurementSetting::NewLC
       
    72 // Creates new System of Measurement Adapter. Leaves the object on the clean-up
       
    73 // stack
       
    74 // ---------------------------------------------------------------------------
       
    75 // 
       
    76 CSatelliteMeasurementSetting* CSatelliteMeasurementSetting::NewLC( 
       
    77                             MSatelliteMeasurementSettingObserver&	aAdapterObsrv )
       
    78 	{	
       
    79     CSatelliteMeasurementSetting* self = 
       
    80                         new(ELeave) CSatelliteMeasurementSetting( aAdapterObsrv );
       
    81 	CleanupStack::PushL(self);
       
    82 	self->ConstructL();
       
    83 	return self;
       
    84 	}
       
    85 	
       
    86 // ---------------------------------------------------------------------------
       
    87 // void CSatelliteMeasurementSetting::ConstructL
       
    88 // Second Phase Constructor
       
    89 //
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 void CSatelliteMeasurementSetting::ConstructL()
       
    93 	{
       
    94 	CActiveScheduler::Add( this );
       
    95 	
       
    96 	// Create the Central repository object for manipulating Avkon Central
       
    97 	// repository for System of measurements settings
       
    98 	iRepository = CRepository::NewL(TUid::Uid( KCRUidLocNotationPref ));
       
    99 	
       
   100 	StartNotification();	
       
   101 	}
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // TReal32 CSatelliteMeasurementSetting::SysofMeasurementL
       
   105 // Returns the current value of the System of measurements settings
       
   106 //
       
   107 // @return TLocSystemofMeasurementValues  Current value of the 
       
   108 // 																				System of measurements settings
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 TLocSystemofMeasurementValues CSatelliteMeasurementSetting::SysofMeasurementL()
       
   112     {
       
   113     
       
   114     TInt settingsValue = 0;
       
   115     User::LeaveIfError( iRepository->Get( KLocSystemofMeasurements,
       
   116                                           settingsValue ));  
       
   117     return ( static_cast<TLocSystemofMeasurementValues>( settingsValue ));
       
   118     }
       
   119 
       
   120 	    
       
   121 // --------------------------------------------------------------------------
       
   122 // void CSatelliteMeasurementSetting::RunL
       
   123 // Inherited from CActive
       
   124 //
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 void CSatelliteMeasurementSetting::RunL()
       
   128     {
       
   129     // Issue Notification
       
   130     iObserver.HandleSysMeasureValueL();
       
   131     
       
   132     // Schedule for listening to change events again
       
   133     StartNotification();
       
   134     }
       
   135 
       
   136 // --------------------------------------------------------------------------
       
   137 // void CSatelliteMeasurementSetting::DoCancel
       
   138 // Inherited from CActive
       
   139 //
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 void CSatelliteMeasurementSetting::DoCancel()
       
   143     {
       
   144     // Cancel the outstanding CR notification request
       
   145     iRepository->NotifyCancel( KLocSystemofMeasurements );
       
   146     }
       
   147     
       
   148 // --------------------------------------------------------------------------
       
   149 // void CSatelliteMeasurementSetting::StartNotification
       
   150 // Start notification from the Central repository server for any changes in the
       
   151 // System of measurements key value
       
   152 //
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 void CSatelliteMeasurementSetting::StartNotification()
       
   156     {
       
   157     if( !IsActive())
       
   158         {
       
   159         iStatus = KRequestPending;
       
   160         // Request for notification
       
   161         iRepository->NotifyRequest( KLocSystemofMeasurements, iStatus);
       
   162         SetActive();          
       
   163         }  
       
   164     }
       
   165 	
       
   166 // End of File
       
   167