wvuing/IMPSServiceSettingsUI/SharedDataSrc/CIMPSPropertyObserver.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:  Publish & Subscribe property change observer implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CIMPSPropertyObserver.h"
       
    22 #include "MIMPSPropertyNotificationObserver.h"
       
    23 
       
    24 #include <bautils.h>
       
    25 #include <barsc.h>
       
    26 #include <e32property.h>
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CIMPSPropertyObserver::CMGXPropertyObserver
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CIMPSPropertyObserver::CIMPSPropertyObserver( MIMPSPropertyNotificationObserver& aObserver )
       
    37         : CActive( CActive::EPriorityLow ),
       
    38         iObserver( aObserver )
       
    39     {
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CIMPSPropertyObserver::ConstructL
       
    44 // Symbian 2nd phase constructor can leave.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 void CIMPSPropertyObserver::ConstructL()
       
    48     {
       
    49     CActiveScheduler::Add( this );
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CIMPSPropertyObserver::NewL
       
    54 // Two-phased constructor.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CIMPSPropertyObserver* CIMPSPropertyObserver::NewL( MIMPSPropertyNotificationObserver& aObserver )
       
    58     {
       
    59     CIMPSPropertyObserver* self = new( ELeave ) CIMPSPropertyObserver( aObserver );
       
    60 
       
    61     CleanupStack::PushL( self );
       
    62     self->ConstructL();
       
    63     CleanupStack::Pop();
       
    64 
       
    65     return self;
       
    66     }
       
    67 
       
    68 
       
    69 // Destructor
       
    70 CIMPSPropertyObserver::~CIMPSPropertyObserver()
       
    71     {
       
    72     if ( IsActive() )
       
    73         {
       
    74         Cancel();
       
    75         }
       
    76     }
       
    77 
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CIMPSPropertyObserver::ObservePropertyChangeL
       
    81 // (other items were commented in a header).
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CIMPSPropertyObserver::ObservePropertyChangeL( TUid aCategory, TUint aKey )
       
    85     {
       
    86     if ( IsActive() )
       
    87         {
       
    88         return;
       
    89         }
       
    90     User::LeaveIfError( iProperty.Attach( aCategory, aKey ) );
       
    91     iKey = aKey;
       
    92     iCategory = aCategory;
       
    93     iProperty.Subscribe( iStatus );
       
    94     SetActive();
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CIMPSPropertyObserver::CancelObserve
       
    99 // (other items were commented in a header).
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void CIMPSPropertyObserver::CancelObserve()
       
   103     {
       
   104     if ( IsActive() )
       
   105         {
       
   106         Cancel();
       
   107         }
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CIMPSPropertyObserver::RunL
       
   112 // (other items were commented in a header).
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CIMPSPropertyObserver::RunL()
       
   116     {
       
   117     iProperty.Subscribe( iStatus );
       
   118     SetActive();
       
   119     iObserver.HandlePropertyNotificationEventL( iCategory, iKey );
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CIMPSPropertyObserver::DoCancel
       
   124 // (other items were commented in a header).
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 void CIMPSPropertyObserver::DoCancel()
       
   128     {
       
   129     iProperty.Cancel();
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CIMPSPropertyObserver::Category
       
   134 // (other items were commented in a header).
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 TUid CIMPSPropertyObserver::Category()
       
   138     {
       
   139     return iCategory;
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CIMPSPropertyObserver::Key
       
   144 // (other items were commented in a header).
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 TUint CIMPSPropertyObserver::Key()
       
   148     {
       
   149     return iKey;
       
   150     }
       
   151 
       
   152 //  End of File