1 /* |
|
2 * Copyright (c) 2009 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: Abstract interface for handling property change events. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CFMRADIOPROPERTYOBSERVER_H |
|
20 #define CFMRADIOPROPERTYOBSERVER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32property.h> |
|
24 |
|
25 /** |
|
26 * MFMRadioPropertyChangeObserver |
|
27 * |
|
28 * Abstract interface for handling property change events. |
|
29 */ |
|
30 class MFMRadioPropertyChangeObserver |
|
31 { |
|
32 |
|
33 public: |
|
34 |
|
35 /** |
|
36 * This is a callback function which is called when a property value of |
|
37 * type int is changed. |
|
38 * |
|
39 * @param aCategory UID of Publish And Subscribe category |
|
40 * @param aKey subkey to specify the category event; to be used with |
|
41 * Publish And Subscribe |
|
42 * |
|
43 * @param aValue the new value |
|
44 */ |
|
45 virtual void HandlePropertyChangeL( |
|
46 const TUid& aCategory, |
|
47 const TUint aKey, |
|
48 const TInt aValue ) = 0; |
|
49 |
|
50 /** |
|
51 * This is a callback function which is called when a property value of |
|
52 * type text is changed. |
|
53 * |
|
54 * @param aCategory UID of Publish And Subscribe category |
|
55 * @param aKey subkey to specify the category event; to be used with |
|
56 * Publish And Subscribe |
|
57 * @param aValue the new value |
|
58 **/ |
|
59 virtual void HandlePropertyChangeL( |
|
60 const TUid& aCategory, |
|
61 const TUint aKey, |
|
62 const TDesC& aValue ) = 0; |
|
63 |
|
64 /** |
|
65 * This is a callback function which is called when a property value of |
|
66 * type byte array is changed. |
|
67 * |
|
68 * @param aCategory UID of Publish And Subscribe category |
|
69 * @param aKey subkey to specify the category event; to be used with |
|
70 * Publish And Subscribe |
|
71 * @param aValue the new value |
|
72 **/ |
|
73 virtual void HandlePropertyChangeL( |
|
74 const TUid& aCategory, |
|
75 const TUint aKey, |
|
76 const TDesC8& aValue ) = 0; |
|
77 |
|
78 /** |
|
79 * This is a callback function which is called when a P&S components |
|
80 * returns an error |
|
81 * |
|
82 * @param aCategory UID of Publish And Subscribe category |
|
83 * @param aKey subkey to specify the category event |
|
84 * @param aError an error code |
|
85 */ |
|
86 virtual void HandlePropertyChangeErrorL( |
|
87 const TUid& aCategory, |
|
88 const TUint aKey, |
|
89 TInt aError) = 0; |
|
90 }; |
|
91 |
|
92 |
|
93 |
|
94 /** |
|
95 * Observer class that observes changes of Property values and propogates |
|
96 * them further. |
|
97 * The class defines a handle to a property, a single data value representing |
|
98 * an item of state information. |
|
99 * |
|
100 */ |
|
101 class CFMRadioPropertyObserver : public CActive |
|
102 { |
|
103 |
|
104 public: |
|
105 |
|
106 /** |
|
107 * Property type. Cannot use RProperty::TType because EByteArray == EText. |
|
108 */ |
|
109 enum TFMRadioPropertyType |
|
110 { |
|
111 EFMRadioPropertyInt, // Integral property type. |
|
112 EFMRadioPropertyByteArray, // Byte-array (8 bit), max size 512 bytes |
|
113 EFMRadioPropertyText // Text (16 bit), max size 512 bytes |
|
114 }; |
|
115 |
|
116 /** |
|
117 * Two-phased constructor. |
|
118 * |
|
119 * @param aObserver a reference to the observer interface implementer |
|
120 * @param aCategory UID of Publish And Subscribe category |
|
121 * @param aKey subkey to specify the category event; to be used with |
|
122 * Publish And Subscribe |
|
123 * @param aPropertyType property type to observe |
|
124 */ |
|
125 static CFMRadioPropertyObserver* NewL( |
|
126 MFMRadioPropertyChangeObserver& aObserver, |
|
127 const TUid& aCategory, |
|
128 const TUint aKey, |
|
129 const TFMRadioPropertyType aPropertyType); |
|
130 |
|
131 /** |
|
132 * Two-phased constructor. |
|
133 * |
|
134 * @param aObserver a reference to the observer interface implementer |
|
135 * @param aCategory UID of Publish And Subscribe category |
|
136 * @param aKey subkey to specify the category event; to be used with |
|
137 * Publish And Subscribe |
|
138 * @param aPropertyType property type to observe |
|
139 */ |
|
140 static CFMRadioPropertyObserver* NewLC( |
|
141 MFMRadioPropertyChangeObserver& aObserver, |
|
142 const TUid& aCategory, |
|
143 const TUint aKey, |
|
144 const TFMRadioPropertyType aPropertyType); |
|
145 |
|
146 /** |
|
147 * Destructor. |
|
148 */ |
|
149 ~CFMRadioPropertyObserver(); |
|
150 |
|
151 /** |
|
152 * Subscribes the object to listen to the specified key. Does nothing if already active. |
|
153 * Must be called after construction, or after calling Cancel(). |
|
154 */ |
|
155 void ActivateL(); |
|
156 |
|
157 /** |
|
158 * Returns current integer property value |
|
159 * @param aUpdate ETrue if the cache value should be updated |
|
160 * |
|
161 * @return int value |
|
162 */ |
|
163 TInt ValueInt( TBool aUpdate = EFalse ); |
|
164 |
|
165 /** |
|
166 * Returns current byte array property value |
|
167 ** @param aUpdate ETrue if the cache value should be updated |
|
168 * |
|
169 * @return byte array value |
|
170 */ |
|
171 const TDesC8& ValueDes8( TBool aUpdate = EFalse ); |
|
172 |
|
173 /** |
|
174 * Returns current text property value |
|
175 * * @param aUpdate ETrue if the cache value should be updated |
|
176 * |
|
177 * @return text value |
|
178 */ |
|
179 const TDesC& ValueDes( TBool aUpdate = EFalse ); |
|
180 |
|
181 private: |
|
182 |
|
183 /** |
|
184 * C++ default constructor overload. |
|
185 * Two-phased constructor. |
|
186 * |
|
187 * @param aObserver a reference to the observer interface implementer |
|
188 * @param aCategory UID of Publish And Subscribe category |
|
189 * @param aKey subkey to specify the category event; to be used with |
|
190 * Publish And Subscribe |
|
191 * @param aPropertyType property type to observe |
|
192 */ |
|
193 CFMRadioPropertyObserver( |
|
194 MFMRadioPropertyChangeObserver& aObserver, |
|
195 const TUid& aCategory, |
|
196 const TUint aKey, |
|
197 const TFMRadioPropertyType aPropertyType); |
|
198 |
|
199 /** |
|
200 * By default Symbian 2nd phase constructor is private. |
|
201 **/ |
|
202 void ConstructL(); |
|
203 |
|
204 // from base class Cactive |
|
205 /** |
|
206 * From CActive |
|
207 * |
|
208 * @see CActive::RunL() |
|
209 */ |
|
210 void RunL(); |
|
211 |
|
212 /** |
|
213 * From CActive, |
|
214 * |
|
215 * @see CActive::DoCancel() |
|
216 */ |
|
217 void DoCancel(); |
|
218 |
|
219 private: // data |
|
220 |
|
221 /** |
|
222 * Value of a subscribed category property of type int. |
|
223 */ |
|
224 TInt iValueInt; |
|
225 |
|
226 /** |
|
227 * Value of a subscribed category property of type byte array. |
|
228 */ |
|
229 HBufC8* iValueByteArray; |
|
230 |
|
231 /** |
|
232 * Value of a subscribed category property of type text. |
|
233 */ |
|
234 HBufC* iValueText; |
|
235 |
|
236 /** |
|
237 * Handle to Publish And Subscribe component |
|
238 */ |
|
239 RProperty iProperty; |
|
240 |
|
241 /** |
|
242 * Observer to be notified when particular Property value has changed |
|
243 */ |
|
244 MFMRadioPropertyChangeObserver& iObserver; |
|
245 |
|
246 /** |
|
247 * UID of Publish And Subscribe category |
|
248 */ |
|
249 TUid iCategory; |
|
250 |
|
251 /** |
|
252 * Subkey to be used with Publish And Subscribe |
|
253 */ |
|
254 TUint iKey; |
|
255 |
|
256 /** |
|
257 * Type of the observed property. |
|
258 */ |
|
259 TFMRadioPropertyType iPropertyType; |
|
260 |
|
261 }; |
|
262 |
|
263 #endif // CFMRADIOPROPERTYOBSERVER_H |
|
264 |
|