IMPSengine/engsrv/src/impspropertyobserver.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2004 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: Observer for IMPS property.
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    <centralrepository.h>
       
    22 #include    "impspropertyobserver.h"
       
    23 #include    "impsutils.h"
       
    24 
       
    25 // ================= MEMBER FUNCTIONS =======================
       
    26 
       
    27 // ---------------------------------------------------------
       
    28 // CImpsPropertyObserver::NewL
       
    29 // ---------------------------------------------------------
       
    30 //
       
    31 CImpsPropertyObserver* CImpsPropertyObserver::NewL( MImpsPropertyObserver& aObserver,
       
    32                                                     TUid aCategory,
       
    33                                                     TUint32 aKey )
       
    34     {
       
    35     CImpsPropertyObserver* self = new ( ELeave ) CImpsPropertyObserver( aObserver,
       
    36                                                                         aCategory, aKey );
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL();
       
    39     CleanupStack::Pop();
       
    40 #ifndef _NO_IMPS_LOGGING_
       
    41     CImpsClientLogger::Log( _L( "CImpsPropertyObserver Constructor " ) );
       
    42 #endif
       
    43     return self;
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------
       
    47 // CImpsPropertyObserver::~CImpsPropertyObserver
       
    48 // ---------------------------------------------------------
       
    49 //
       
    50 CImpsPropertyObserver::~CImpsPropertyObserver()
       
    51     {
       
    52 #ifndef _NO_IMPS_LOGGING_
       
    53     CImpsClientLogger::Log( _L( "CImpsPropertyObserver Destructor " ) );
       
    54 #endif
       
    55     Cancel();
       
    56     delete iRep;
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // CImpsPropertyObserver::CImpsPropertyObserver
       
    61 // ---------------------------------------------------------
       
    62 //
       
    63 CImpsPropertyObserver::CImpsPropertyObserver( MImpsPropertyObserver& aObserver,
       
    64                                               TUid aCategory,
       
    65                                               TUint32 aKey )
       
    66         : CActive( CActive::EPriorityStandard ),
       
    67         iObserver( aObserver ),
       
    68         iCategory( aCategory ),
       
    69         iKey( aKey )
       
    70     {
       
    71     CActiveScheduler::Add( this );
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------
       
    75 // CImpsPropertyObserver::ConstructL
       
    76 // ---------------------------------------------------------
       
    77 //
       
    78 void CImpsPropertyObserver::ConstructL( )
       
    79     {
       
    80     iRep = CRepository::NewL( iCategory );
       
    81     iStatus = KRequestPending;
       
    82     iRep->NotifyRequest( iKey, iStatus );
       
    83     SetActive( );
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------
       
    87 // CImpsPropertyObserver::RunL
       
    88 // ---------------------------------------------------------
       
    89 //
       
    90 void CImpsPropertyObserver::RunL()
       
    91     {
       
    92 #ifndef _NO_IMPS_LOGGING_
       
    93     CImpsClientLogger::Log( _L( "CImpsPropertyObserver RunL" ) );
       
    94 #endif
       
    95     TInt newValue( 0 );
       
    96     iRep->Get( iKey, newValue );
       
    97     iObserver.HandlePropertyChangeL( newValue );
       
    98     iStatus = KRequestPending;
       
    99     iRep->NotifyRequest( iKey, iStatus );
       
   100     SetActive( );
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------
       
   104 // CImpsPropertyObserver::RunError
       
   105 // ---------------------------------------------------------
       
   106 //
       
   107 TInt CImpsPropertyObserver::RunError( TInt /*aError*/ )
       
   108     {
       
   109 #ifndef _NO_IMPS_LOGGING_
       
   110     CImpsClientLogger::Log( _L( "CImpsPropertyObserver RunError ***" ) );
       
   111 #endif
       
   112     // iObserver.HandlePropertyChangeL cannot actually leave now, so
       
   113     // this is not needed:
       
   114     /*
       
   115     iStatus = KRequestPending;
       
   116     iRep->NotifyRequest( iKey, iStatus );
       
   117     SetActive( );
       
   118     */
       
   119     return KErrNone;
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------
       
   123 // CImpsPropertyObserver::DoCancel
       
   124 // ---------------------------------------------------------
       
   125 //
       
   126 void CImpsPropertyObserver::DoCancel()
       
   127     {
       
   128     /*
       
   129     Central Repository Design Document:
       
   130     It is possible to cancel a notification by supplying the exact
       
   131     same arguments used to set up the notification to the relevant
       
   132     NotifyCancel API. In this situation the TRequestStatus will no
       
   133     be set to KErrCancel but to KInvalidNotificationId.
       
   134     */
       
   135     iRep->NotifyCancelAll();
       
   136     }
       
   137 
       
   138 //  End of File
       
   139 
       
   140 
       
   141