calendarui/organizerplugin/aiagendapluginengine/inc/PropertyObserver.h
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2002 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:  
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPROPERTYOBSERVER_H
       
    20 #define CPROPERTYOBSERVER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <e32property.h>
       
    25 
       
    26 // CLASS DECLARATION
       
    27 
       
    28 /**
       
    29  * MPropertyChangeHandler.
       
    30  * Abstract interface for handling property change events.
       
    31  **/
       
    32 NONSHARABLE_CLASS( MPropertyChangeHandler )
       
    33 {
       
    34  public:
       
    35     /**
       
    36      * This is a callback function which is called when a property is changed.
       
    37      *
       
    38      * @param aCategory  UID of the category.
       
    39      * @param aKey       changed key
       
    40      * @param aValue     the new value
       
    41      *
       
    42      * Note! references aKey and aValue are only valid while executing
       
    43      * HandlePropertyChange(). After that the data in which they refer can change.
       
    44      **/
       
    45     virtual void HandlePropertyChange(const TUid& aCategory, const TUint& aKey, const TInt& aValue) = 0;
       
    46 
       
    47 };
       
    48 
       
    49 
       
    50 // CLASS DECLARATION
       
    51 
       
    52 /**
       
    53  * ?one_line_short_description.
       
    54  * ?other_description_lines
       
    55  *
       
    56  * @since Series 60 3.0
       
    57  **/
       
    58 NONSHARABLE_CLASS(CPropertyObserver) : public CActive
       
    59 {
       
    60  public:  // Constructors and destructor
       
    61     /**
       
    62      * Two-phased constructor.
       
    63      * @since Series 60 3.0
       
    64      * @param ?arg1 ?description
       
    65      * @param ?arg2 ?description
       
    66      **/
       
    67     static CPropertyObserver* NewL(MPropertyChangeHandler& aHandler, const TUid& aCategory, const TUint& aKey, const TBool aSkipValue=EFalse)
       
    68     {
       
    69         CPropertyObserver* self = new( ELeave )CPropertyObserver( aHandler, aCategory, aKey, aSkipValue );
       
    70         CleanupStack::PushL( self );
       
    71         self->ConstructL();
       
    72         CleanupStack::Pop( self );
       
    73         return self;
       
    74     };
       
    75 
       
    76     /**
       
    77      * Destructor.
       
    78      **/
       
    79     ~CPropertyObserver()
       
    80     {
       
    81         Deque();
       
    82         iProperty.Cancel();
       
    83         iProperty.Close();
       
    84     };
       
    85 
       
    86  private:
       
    87     /**
       
    88      * C++ default constructor overload.
       
    89      **/
       
    90     CPropertyObserver(MPropertyChangeHandler& aHandler, const TUid& aCategory, const TUint& aKey, const TBool aSkipValue)
       
    91     : CActive( CActive::EPriorityStandard ),
       
    92       iCategory( aCategory ),
       
    93       iKey( aKey ),
       
    94       iHandler( aHandler ),
       
    95       iSkipValue( aSkipValue )
       
    96     {
       
    97     };
       
    98 
       
    99     /**
       
   100      * By default Symbian 2nd phase constructor is private.
       
   101      **/
       
   102     void ConstructL(void)
       
   103     {
       
   104         CActiveScheduler::Add( this );
       
   105 
       
   106         User::LeaveIfError( iProperty.Attach( iCategory, iKey ) );
       
   107 
       
   108         //NotifyCurrentValue(); // notify initial value
       
   109 
       
   110         // Start observing...
       
   111         Subscribe();
       
   112     };
       
   113 
       
   114  protected:  // Functions from base classes
       
   115     /**
       
   116      * From CActive ?member_description
       
   117      **/
       
   118     inline void RunL(void);
       
   119 
       
   120     /**
       
   121      * From CActive ?member_description
       
   122      **/
       
   123     inline void DoCancel(void);
       
   124 
       
   125  private:  // New functions
       
   126     /**
       
   127      * ?member_description.
       
   128      * @since Series 60 3.0
       
   129      **/
       
   130     inline void Subscribe(void);
       
   131 
       
   132     /**
       
   133      * ?member_description.
       
   134      * @since Series 60 3.0
       
   135      **/
       
   136     inline void NotifyCurrentValue(void);
       
   137 
       
   138  private:  // Data
       
   139     // ?one_line_short_description_of_data
       
   140     RProperty iProperty;
       
   141 
       
   142     // ?one_line_short_description_of_data
       
   143     const TUid iCategory;
       
   144 
       
   145     // ?one_line_short_description_of_data
       
   146     const TUint iKey;
       
   147 
       
   148     // ?one_line_short_description_of_data
       
   149     MPropertyChangeHandler& iHandler;
       
   150 
       
   151     // ?one_line_short_description_of_data
       
   152     const TBool iSkipValue;
       
   153 
       
   154 };
       
   155 
       
   156 #include "PropertyObserver.inl"
       
   157 
       
   158 #endif  // CPROPERTYOBSERVER_H
       
   159 
       
   160 
       
   161 // End of File