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