1 /* |
|
2 * Copyright (c) 2008 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 the License "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 VCXTESTPSSUBSCRIBER_H |
|
20 #define VCXTESTPSSUBSCRIBER_H |
|
21 |
|
22 #include <e32base.h> // For CActive, link against: euser.lib |
|
23 #include <e32std.h> // For RTimer, link against: euser.lib |
|
24 |
|
25 #include <e32property.h> |
|
26 |
|
27 class MVCXTestPSObserver; |
|
28 |
|
29 class CVCXTestPSSubscriber : public CActive |
|
30 { |
|
31 public: |
|
32 |
|
33 /** |
|
34 * Construction. |
|
35 * |
|
36 * @param aUid category for the property |
|
37 * @param aKey key id for the property |
|
38 * @param aType type of the key (at the moment only int and text are supported) |
|
39 * @param aObserver pointer to observer to who to notify about changes |
|
40 * |
|
41 * @return The newly constructed CVcxConnUtilPubSub |
|
42 */ |
|
43 IMPORT_C static CVCXTestPSSubscriber* NewL( const TUid aUid, |
|
44 const TUint32 aKey, |
|
45 RProperty::TType aType, |
|
46 MVCXTestPSObserver* aObserver ); |
|
47 |
|
48 /** |
|
49 * Destructor. |
|
50 * |
|
51 */ |
|
52 IMPORT_C virtual ~CVCXTestPSSubscriber(); |
|
53 |
|
54 /** |
|
55 * Returns a pubsub value from this property |
|
56 * |
|
57 *@param &aValue value to fetch |
|
58 * |
|
59 *@return TInt KErrNone or some system level error code |
|
60 */ |
|
61 IMPORT_C TInt Get( TInt& aValue ); |
|
62 |
|
63 /** |
|
64 * Returns a pubsub value from this property |
|
65 * |
|
66 *@param &aValue value tofetch |
|
67 * |
|
68 *@return TInt KErrNone or some system level error code |
|
69 */ |
|
70 IMPORT_C TInt Get( TDes& aValue ); |
|
71 |
|
72 /** |
|
73 * Sets a pubsub value from this property |
|
74 * |
|
75 *@param aValue value to set |
|
76 * |
|
77 *@return TInt KErrNone or some system level error code |
|
78 */ |
|
79 IMPORT_C TInt Set( TInt& aValue ); |
|
80 |
|
81 /** |
|
82 * Sets a pubsub value from this property |
|
83 * |
|
84 *@param aValue value to set |
|
85 * |
|
86 *@return TInt KErrNone or some system level error code |
|
87 */ |
|
88 IMPORT_C TInt Set( const TDesC& aValue ); |
|
89 |
|
90 /** |
|
91 * Start subscribing if not already started |
|
92 */ |
|
93 IMPORT_C void Start(); |
|
94 |
|
95 /** |
|
96 * Activate safe wait object to wait modifications |
|
97 */ |
|
98 IMPORT_C void WaitChangeL(); |
|
99 |
|
100 /** |
|
101 * Explicitly ends waiting |
|
102 */ |
|
103 IMPORT_C void EndWait(); |
|
104 |
|
105 private: // constuct / destruct |
|
106 |
|
107 /** |
|
108 * Constructor |
|
109 * |
|
110 */ |
|
111 CVCXTestPSSubscriber( const TUid aUid, |
|
112 const TUint32 aKey, |
|
113 RProperty::TType aType, |
|
114 MVCXTestPSObserver* aObserver ); |
|
115 |
|
116 /** |
|
117 * Symbian 2nd phase construction |
|
118 * |
|
119 */ |
|
120 void ConstructL(); |
|
121 |
|
122 private: // from CActive |
|
123 |
|
124 /** |
|
125 * From CActive. Calles when value subscribed to changes |
|
126 * |
|
127 */ |
|
128 void RunL(); |
|
129 |
|
130 /** |
|
131 * From CActive. Cancels subscribtion |
|
132 * |
|
133 */ |
|
134 void DoCancel(); |
|
135 |
|
136 private: |
|
137 |
|
138 /** |
|
139 * ETrue if object is initialized and subscribtion starts |
|
140 */ |
|
141 TBool iInitialized; |
|
142 |
|
143 /** |
|
144 * Property to subscribe |
|
145 */ |
|
146 RProperty iProperty; |
|
147 |
|
148 /** |
|
149 * Category uid for the property |
|
150 */ |
|
151 const TUid iUid; |
|
152 |
|
153 /** |
|
154 * Key id for the property |
|
155 */ |
|
156 const TUint32 iKey; |
|
157 |
|
158 /** |
|
159 * type of the property |
|
160 */ |
|
161 RProperty::TType iKeyType; |
|
162 |
|
163 /** |
|
164 * Waiter object for data change |
|
165 */ |
|
166 CActiveSchedulerWait* iSafeWait; |
|
167 |
|
168 /** |
|
169 * Observer |
|
170 */ |
|
171 MVCXTestPSObserver* iObserver; |
|
172 }; |
|
173 |
|
174 #endif // VCXTESTPSSUBSCRIBER_H |
|