sensorservices/tiltcompensationssy/src/tccenrepobserver.cpp
changeset 0 4e1aa6a622a0
child 21 ccb4f6b3db21
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     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:  CTCCenrepObserver class implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <centralrepository.h>
       
    21 #include <cenrepnotifyhandler.h>
       
    22 #include "tccenrepobserver.h"
       
    23 #include "tcprivatecrkeys.h"
       
    24 #include "trace.h"
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CTCCenrepObserver::CTCCenrepObserver
       
    30 // C++ constructor
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CTCCenrepObserver::CTCCenrepObserver( MTCCenrepObserver& aCallback ) :
       
    34     iCallback( aCallback )
       
    35     {
       
    36     FUNC_LOG;
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CTCCenrepObserver::NewL
       
    41 // Two-phased constructor.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CTCCenrepObserver* CTCCenrepObserver::NewL( MTCCenrepObserver& aCallback )
       
    45     {
       
    46     FUNC_LOG;
       
    47 
       
    48     CTCCenrepObserver* self = 
       
    49         new( ELeave ) CTCCenrepObserver( aCallback );
       
    50     CleanupStack::PushL( self );
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop();
       
    53 
       
    54     return self;
       
    55     }
       
    56    
       
    57 // -----------------------------------------------------------------------------
       
    58 // CTCCenrepObserver::ConstructL
       
    59 // Symbian 2nd phase constructor can leave.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 void CTCCenrepObserver::ConstructL()
       
    63     {    
       
    64     FUNC_LOG;
       
    65 
       
    66     iRepository = CRepository::NewL( KCRUidTiltCompensationParameters );
       
    67     iNotifyHandler = CCenRepNotifyHandler::NewL( *this, 
       
    68                                                  *iRepository );
       
    69     iNotifyHandler->StartListeningL();
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------
       
    73 // Destructor
       
    74 // ---------------------------------------------------------
       
    75 //
       
    76 CTCCenrepObserver::~CTCCenrepObserver()
       
    77     {
       
    78     FUNC_LOG;
       
    79 
       
    80     if( iNotifyHandler )
       
    81         {
       
    82         iNotifyHandler->StopListening();
       
    83         delete iNotifyHandler;
       
    84         }
       
    85 
       
    86     delete iRepository;    
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CTCCenrepObserver::GetCenrepHandle
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 CRepository& CTCCenrepObserver::GetCenrepHandle()
       
    94     {
       
    95     return *iRepository;
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CTCCenrepObserver::HandleNotifyGeneric
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void CTCCenrepObserver::HandleNotifyGeneric( TUint32 aKey )
       
   103     {
       
   104     FUNC_LOG;
       
   105 
       
   106     iCallback.CenrepValueChanged( aKey, *iRepository  );
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CTCCenrepObserver::HandleNotifyError
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CTCCenrepObserver::HandleNotifyError(
       
   114     TUint32 /*aKey*/, TInt aError, CCenRepNotifyHandler* aHandler)
       
   115     {
       
   116     ERROR_1( aError, "CTCCenrepObserver::HandleNotifyError - aError: %d ", aError ); 
       
   117     
       
   118     // Retry notification 
       
   119     TRAPD( err, aHandler->StartListeningL() );
       
   120     if ( err != KErrNone )
       
   121         {
       
   122         ERROR_1( err, "CTCCenrepObserver::HandleNotifyError - err: %d ", err ); 
       
   123         }
       
   124     }
       
   125 
       
   126 //  End of File