|
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, |
|
46 const TUint& aKey, |
|
47 const TInt& aValue) = 0; |
|
48 }; |
|
49 |
|
50 |
|
51 // CLASS DECLARATION |
|
52 |
|
53 /** |
|
54 * ?one_line_short_description. |
|
55 * ?other_description_lines |
|
56 * |
|
57 * @lib ? |
|
58 * @since Series 60 3.0 |
|
59 **/ |
|
60 NONSHARABLE_CLASS(CPropertyObserver) : public CActive |
|
61 { |
|
62 public: // Constructors and destructor |
|
63 /** |
|
64 * Two-phased constructor. |
|
65 * @since Series 60 3.0 |
|
66 * @param MPropertyChangeHandler aHandler |
|
67 * @param aCategory |
|
68 * @param aKey |
|
69 **/ |
|
70 static CPropertyObserver* NewL(MPropertyChangeHandler& aHandler, |
|
71 const TUid& aCategory, |
|
72 const TUint& aKey); |
|
73 |
|
74 /** |
|
75 * Destructor. |
|
76 **/ |
|
77 ~CPropertyObserver(); |
|
78 |
|
79 private: |
|
80 /** |
|
81 * C++ default constructor overload. |
|
82 **/ |
|
83 CPropertyObserver(MPropertyChangeHandler& aHandler, |
|
84 const TUid& aCategory, |
|
85 const TUint& aKey); |
|
86 |
|
87 /** |
|
88 * By default Symbian 2nd phase constructor is private. |
|
89 **/ |
|
90 void ConstructL(); |
|
91 |
|
92 protected: // Functions from base classes |
|
93 /** |
|
94 * From CActive |
|
95 **/ |
|
96 void RunL(); |
|
97 |
|
98 /** |
|
99 * From CActive |
|
100 **/ |
|
101 void DoCancel(); |
|
102 |
|
103 private: // New functions |
|
104 /** |
|
105 * @since Series 60 3.0 |
|
106 **/ |
|
107 void Subscribe(); |
|
108 |
|
109 /** |
|
110 * @since Series 60 3.0 |
|
111 **/ |
|
112 void NotifyCurrentValue(); |
|
113 |
|
114 private: // Data |
|
115 // Owns |
|
116 RProperty iProperty; |
|
117 |
|
118 // Observed PubSub category |
|
119 const TUid iCategory; |
|
120 |
|
121 // Observed key |
|
122 const TUint iKey; |
|
123 |
|
124 // Refs. Interface towards observants |
|
125 MPropertyChangeHandler& iHandler; |
|
126 |
|
127 }; |
|
128 |
|
129 |
|
130 #endif // CPROPERTYOBSERVER_H |
|
131 |
|
132 |
|
133 // End of File |