|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Header file for CIRControlEventObserver |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CIRCONTROLEVENTOBSERVER_H |
|
20 #define CIRCONTROLEVENTOBSERVER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32property.h> |
|
24 #include "irui.h" |
|
25 |
|
26 #define KMAXLENGTH 256 |
|
27 |
|
28 |
|
29 NONSHARABLE_CLASS( CIRControlEventObserver ) : public CActive |
|
30 { |
|
31 |
|
32 public: |
|
33 |
|
34 /** |
|
35 * Property type. Cannot use RProperty::TType because EByteArray == EText. |
|
36 */ |
|
37 enum TVRPropertyType |
|
38 { |
|
39 EVRPropertyInt, // Integral property type. |
|
40 EVRPropertyByteArray, // Byte-array (8 bit), max size 512 bytes |
|
41 EVRPropertyText // Text (16 bit), max size 512 bytes |
|
42 }; |
|
43 |
|
44 /** |
|
45 * Two-phased constructor. |
|
46 * |
|
47 * @param aObserver a reference to the observer interface implementer |
|
48 * @param aCategory UID of Publish And Subscribe category |
|
49 * @param aKey subkey to specify the category event; to be used with |
|
50 * Publish And Subscribe |
|
51 * @param aPropertyType property type to observe |
|
52 */ |
|
53 IMPORT_C static CIRControlEventObserver* NewL( |
|
54 CIRUi& aObserver, |
|
55 const TUid& aCategory, |
|
56 const TUint aKey, |
|
57 const RProperty::TType aPropertyType); |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 */ |
|
62 ~CIRControlEventObserver(); |
|
63 |
|
64 /** |
|
65 * Subscribes the object to listen to the specified key. Does nothing if already active. |
|
66 * Must be called after construction, or after calling Cancel(). |
|
67 */ |
|
68 IMPORT_C void SecondConstructL(); |
|
69 |
|
70 |
|
71 private: |
|
72 |
|
73 /** |
|
74 * C++ default constructor overload. |
|
75 * Two-phased constructor. |
|
76 * |
|
77 * @param aObserver a reference to the observer interface implementer |
|
78 * @param aCategory UID of Publish And Subscribe category |
|
79 * @param aKey subkey to specify the category event; to be used with |
|
80 * Publish And Subscribe |
|
81 * @param aPropertyType property type to observe |
|
82 */ |
|
83 CIRControlEventObserver( |
|
84 CIRUi& aObserver, |
|
85 const TUid& aCategory, |
|
86 const TUint aKey, |
|
87 const RProperty::TType aPropertyType); |
|
88 |
|
89 /** |
|
90 * By default Symbian 2nd phase constructor is private. |
|
91 **/ |
|
92 void ConstructL(); |
|
93 |
|
94 protected: |
|
95 |
|
96 // from base class Cactive |
|
97 /** |
|
98 * From CActive |
|
99 * |
|
100 * @see CActive::RunL() |
|
101 */ |
|
102 void RunL(); |
|
103 |
|
104 /** |
|
105 * From CActive, |
|
106 * |
|
107 * @see CActive::DoCancel() |
|
108 */ |
|
109 void DoCancel(); |
|
110 |
|
111 private: // data |
|
112 |
|
113 |
|
114 /** |
|
115 * Observer to be notified when particular Property value has changed |
|
116 */ |
|
117 CIRUi& iObserver; |
|
118 |
|
119 /** |
|
120 * UID of Publish And Subscribe category |
|
121 */ |
|
122 TUid iCategory; |
|
123 |
|
124 /** |
|
125 * Subkey to be used with Publish And Subscribe |
|
126 */ |
|
127 TUint iKey; |
|
128 |
|
129 RProperty iProperty; |
|
130 |
|
131 RProperty::TType iPropertyType; |
|
132 |
|
133 /** The cached value of the key. */ |
|
134 mutable TBuf8<KMAXLENGTH> iText; |
|
135 TInt iValue; |
|
136 }; |
|
137 |
|
138 #endif // CIRCONTROLEVENTOBSERVER_H |
|
139 |