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: Pubsub handler class for vcxconnectionutility* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CVCX_CONUTILPUBSUB_H__ |
|
21 #define __CVCX_CONUTILPUBSUB_H__ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <e32std.h> |
|
25 #include <e32property.h> |
|
26 |
|
27 |
|
28 class CVcxConnUtilSubscriber; |
|
29 class MConnUtilPubsubObserver; |
|
30 |
|
31 /** |
|
32 * This class defines operations for handling the pub sub keys and their values. |
|
33 * |
|
34 */ |
|
35 NONSHARABLE_CLASS( CVcxConnUtilPubSub ) : public CBase |
|
36 { |
|
37 public: // construction / destruction |
|
38 |
|
39 /** |
|
40 * Construction. |
|
41 * |
|
42 * @return The newly constructed CVcxConnUtilPubSub |
|
43 */ |
|
44 static CVcxConnUtilPubSub* NewL( MConnUtilPubsubObserver *aObserver ); |
|
45 |
|
46 /** |
|
47 * Construction. Object left to cleanupstack |
|
48 * |
|
49 * @return The newly constructed CVcxConnUtilPubSub |
|
50 */ |
|
51 static CVcxConnUtilPubSub* NewLC( MConnUtilPubsubObserver *aObserver ); |
|
52 |
|
53 /** |
|
54 * destructor |
|
55 */ |
|
56 virtual ~CVcxConnUtilPubSub(); |
|
57 |
|
58 private: |
|
59 |
|
60 /** |
|
61 * C++ constructor |
|
62 */ |
|
63 CVcxConnUtilPubSub(); |
|
64 |
|
65 /** |
|
66 * Private 2nd phase construction. |
|
67 * |
|
68 * During instantiation, the availibility of the PS keys is being checked. In case |
|
69 * keys does not exists, they are being created by starting an external executable, |
|
70 * vcxconnutilpsworker, whose UID is being used as the unique category of the PS keys. |
|
71 * This kind of solution is needed to make sure, that category is always unique and |
|
72 * the UID of the category is always known beforehand in vcxconnectionutility library |
|
73 * |
|
74 * @param aObserver observer to be passed subscribers |
|
75 */ |
|
76 void ConstructL( MConnUtilPubsubObserver *aObserver ); |
|
77 |
|
78 |
|
79 public: // new functions |
|
80 |
|
81 /** |
|
82 * Increases a "counter" pub sub value by one. |
|
83 * If given key is not concidered as a counter, |
|
84 * nothing is done |
|
85 * |
|
86 * @param aKey PS key whose value to increase |
|
87 */ |
|
88 void IncCounterPubSubL( TUint32 aKey ); |
|
89 |
|
90 /** |
|
91 * Decreases a "counter" pub sub value by one |
|
92 * If given key is not concidered as a counter, |
|
93 * nothing is done |
|
94 * |
|
95 * @param aKey PS key whose value to decrease |
|
96 */ |
|
97 void DecCounterPubSubL( TUint32 aKey ); |
|
98 |
|
99 /** |
|
100 * Saves given value to the defined PS key. |
|
101 * |
|
102 * @param aKey PS to where to save the value |
|
103 * @param aValue Value to save |
|
104 * |
|
105 * @return TInt KErrNone is succees, KerrNotFound if provided key is |
|
106 * not in the scope of connection util or another |
|
107 * system level error code |
|
108 * |
|
109 */ |
|
110 TInt SetValue( TUint32 aKey, TInt aValue ); |
|
111 |
|
112 /** |
|
113 * Get value from defined PS key. |
|
114 * |
|
115 * @param aKey PS from where to fetch value |
|
116 * @param aValue |
|
117 * |
|
118 * @return TInt KErrNone is succees, KerrNotFound if provided key is |
|
119 * not in the scope of connection util or another |
|
120 * system level error code |
|
121 * |
|
122 */ |
|
123 TInt GetValue( TUint32 aKey, TInt& aValue ); |
|
124 |
|
125 /** |
|
126 * Start subscribers. If using deafult value, starts all. |
|
127 * Otherwise just starts the one defined as aKey |
|
128 * |
|
129 * @param aKey key value of subscriber to start |
|
130 */ |
|
131 void StartSubscibers( TUint32 aKey = 0 ); |
|
132 |
|
133 /** |
|
134 * Cancels subscribers. If using deafult value, cancels all. |
|
135 * Otherwise just cancels the one defined as aKey |
|
136 * |
|
137 * @param aKey key value of subscriber to cancel |
|
138 * |
|
139 */ |
|
140 void CancelValueSubscribers( TUint32 aKey = 0 ); |
|
141 |
|
142 private: |
|
143 |
|
144 /** |
|
145 * Method starts a vcxconnutilpsworker -process |
|
146 * to create PS keys for connectionutility and |
|
147 * waits for the process to finish before returning. |
|
148 * |
|
149 * If another process has already started worker, method |
|
150 * waits for it to finish. |
|
151 * |
|
152 * Method leaves if existing semaphore cannot be opened or |
|
153 * creating of process fails. |
|
154 * |
|
155 */ |
|
156 void DefinePropertiesL(); |
|
157 |
|
158 /** |
|
159 * Internal helper method to get a pointer to RProperty |
|
160 * defined by the aKey -value. |
|
161 * In case aKey refers to a property that does not exists, |
|
162 * a null pointer is returned |
|
163 * |
|
164 * @param aKey a key value for property wanted |
|
165 * |
|
166 * @return RProperty* pointer to property or NULL in case |
|
167 * property is not found |
|
168 */ |
|
169 RProperty* GetProperty( TUint32 aKey ); |
|
170 |
|
171 /** |
|
172 * Internal helper method to get a pointer to Subscriber |
|
173 * defined by the aKey -value. |
|
174 * In case aKey refers to a Subscriber that does not exists, |
|
175 * a null pointer is returned |
|
176 * |
|
177 * @param aKey a key value for subscriber wanted |
|
178 * |
|
179 * @return CVcxConnUtilSubscriber* pointer to Subscriber or NULL in case |
|
180 * property is not found |
|
181 */ |
|
182 CVcxConnUtilSubscriber* GetSubscriber( TUint32 aKey ); |
|
183 |
|
184 /** |
|
185 * Internal helper method to handle actual incrementation or |
|
186 * decrementation (based on the calfactor) of the PS key concidered |
|
187 * to be a counter value in connectionutility's context. |
|
188 * |
|
189 * @leave if PS Get or Set fails |
|
190 * |
|
191 * @param aKey a key value for subscriber wanted |
|
192 * |
|
193 * @param aCalcFactor a value to be added to the PS key value |
|
194 */ |
|
195 void DoPSCounterIncrementL( TUint32 aKey, TInt aCalcFactor ); |
|
196 |
|
197 private: |
|
198 |
|
199 /** |
|
200 * P&S Current IAP's Id |
|
201 */ |
|
202 RProperty iPropertyCurrentIAPId; |
|
203 |
|
204 /** |
|
205 * P&S Current Destination's Id |
|
206 */ |
|
207 RProperty iPropertyCurrentSNAPId; |
|
208 |
|
209 /** |
|
210 * P&S telling how many instances are using connection |
|
211 */ |
|
212 RProperty iPropertyNbrOfInst; |
|
213 |
|
214 /** |
|
215 * P&S telling how many instances |
|
216 * have accepted roaming |
|
217 */ |
|
218 RProperty iPropertyAccepted; |
|
219 |
|
220 /** |
|
221 * P&S telling Connection state property. |
|
222 * Object contains PS property for connection state -key and |
|
223 * subcribe -listener for that value changes |
|
224 */ |
|
225 CVcxConnUtilSubscriber* iConnectionStatePS; |
|
226 |
|
227 /** |
|
228 * P&S telling if we currently have master instance or not |
|
229 * Object contains PS property for masterexist -key and |
|
230 * subcribe -listener for that value changes |
|
231 */ |
|
232 CVcxConnUtilSubscriber* iMasterExistPS; |
|
233 |
|
234 /** |
|
235 * P&S telling the roaming request status from |
|
236 * the instances |
|
237 */ |
|
238 CVcxConnUtilSubscriber* iRoamingReqStatusPS; |
|
239 |
|
240 /** |
|
241 * P&S telling the amount of connection users responded |
|
242 * roaming request |
|
243 */ |
|
244 CVcxConnUtilSubscriber* iNbrInstanceResp; |
|
245 |
|
246 /** |
|
247 * Semaphore to protect critical counter -PS |
|
248 * increment and decrement operations. |
|
249 */ |
|
250 RSemaphore iSemaCounter; |
|
251 |
|
252 }; |
|
253 |
|
254 #endif // __CVCX_CONUTILPUBSUB_H__ |
|