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