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: Implementation Class to handle connection creation.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __VCX_CONNUTILIMPL_H_ |
|
21 #define __VCX_CONNUTILIMPL_H_ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <e32property.h> |
|
26 |
|
27 #include <agentdialog.h> |
|
28 |
|
29 #include "vcxconnutilpubsubobserver.h" |
|
30 #include "vcxconnutilextengineobserver.h" |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CRepository; |
|
34 class CVcxConnUtilEngine; |
|
35 class CVcxConnUtilPubSub; |
|
36 class CVcxConnectionUtility; |
|
37 class CVcxConnUtilWaitSch; |
|
38 |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 /** |
|
43 * This class defines operations for handling the networking notifications |
|
44 * from the engine class, notifications from the PS and provides a functionality |
|
45 * for those. |
|
46 * |
|
47 */ |
|
48 NONSHARABLE_CLASS( CVcxConnUtilImpl) : public CBase, |
|
49 public MConnUtilPubsubObserver, |
|
50 public MConnUtilExtEngineObserver |
|
51 { |
|
52 |
|
53 public: // Constructors and destructor |
|
54 |
|
55 /** |
|
56 * Construction. |
|
57 * |
|
58 * @param CVcxConnectionUtility* pointer to main interface class for |
|
59 * for showing dialogs |
|
60 * @return The newly constructed CVcxConnUtilEngine |
|
61 */ |
|
62 static CVcxConnUtilImpl* NewL( CVcxConnectionUtility* aUiInterface ); |
|
63 |
|
64 /** |
|
65 * Construction. Object left to cleanupstack |
|
66 * |
|
67 * @param CVcxConnectionUtility* pointer to main interface class for |
|
68 * for showing dialogs |
|
69 * @return The newly constructed CVcxConnUtilEngine |
|
70 */ |
|
71 static CVcxConnUtilImpl* NewLC( CVcxConnectionUtility* aUiInterface ); |
|
72 |
|
73 /** |
|
74 * Destructor. |
|
75 */ |
|
76 virtual ~CVcxConnUtilImpl(); |
|
77 |
|
78 private: |
|
79 |
|
80 /** |
|
81 * constructor. |
|
82 * |
|
83 * @param CVcxConnectionUtility* pointer to main interface class for |
|
84 * for showing dialogs |
|
85 */ |
|
86 CVcxConnUtilImpl( CVcxConnectionUtility* aUiInterface ); |
|
87 |
|
88 /** |
|
89 * default constructor definition. |
|
90 * |
|
91 */ |
|
92 CVcxConnUtilImpl( ); |
|
93 |
|
94 /** |
|
95 * Private 2nd phase construction. |
|
96 */ |
|
97 void ConstructL(); |
|
98 |
|
99 public: // New functions |
|
100 |
|
101 |
|
102 /** |
|
103 * Returns open IAP, If connection is not opened it will be created |
|
104 * |
|
105 * @param aIapId On return, IAP ID. |
|
106 * @param aSilent If ETrue, tries to open connection silently (without dialogs) |
|
107 * |
|
108 * @return KErrNone or one of the system wide error codes. |
|
109 */ |
|
110 TInt GetIap( TUint32& aIapId, TBool aSilent ); |
|
111 |
|
112 /** |
|
113 * Closes open connection. |
|
114 */ |
|
115 void DisconnectL(); |
|
116 |
|
117 /** |
|
118 * Registers observer |
|
119 * |
|
120 * @param MConnUtilEngineObserver |
|
121 */ |
|
122 void RegisterObserverL( MConnUtilEngineObserver* aObserver ); |
|
123 |
|
124 /** |
|
125 * Removes observer from the array of observers |
|
126 * |
|
127 * @param MConnUtilEngineObserver |
|
128 */ |
|
129 void RemoveObserver( MConnUtilEngineObserver* aObserver ); |
|
130 |
|
131 /** |
|
132 * Returns current connection status |
|
133 * |
|
134 * @return TVCxConnectionStatus |
|
135 */ |
|
136 TVCxConnectionStatus EngineConnectionStatus(); |
|
137 |
|
138 /** |
|
139 * Gets WAP id from IAP id. Leaves with KErrNotFound if no record with given |
|
140 * IAP id is found. |
|
141 * |
|
142 * @return WAP id matching the given IAP id. |
|
143 */ |
|
144 TUint32 WapIdFromIapIdL( TUint32 aIapId ); |
|
145 |
|
146 private: // from MConUtilPubsubObserver |
|
147 |
|
148 /** |
|
149 * Notification about pubsub key (integer) value change |
|
150 * |
|
151 * @param aKey PS key informing the change |
|
152 * @param aValue a new value |
|
153 */ |
|
154 void ValueChangedL(const TUint32& aKey, const TInt& aValue); |
|
155 |
|
156 private: // from MConnUtilExtEngineObserver |
|
157 |
|
158 /** |
|
159 * Engine has gotten mobility event about preferred IAP. Utility must requets permission |
|
160 * from it's clients before connection changing can be done. |
|
161 * |
|
162 * @return TBool ETrue if roaming can be allowed from the applicatin. |
|
163 */ |
|
164 TBool RequestIsRoamingAllowedL(); |
|
165 |
|
166 /** |
|
167 * Notification about IAP change due roaming. If this instance |
|
168 * is master, it should change the IAP to Pubsub |
|
169 * |
|
170 */ |
|
171 void IapChangedL(); |
|
172 |
|
173 /** |
|
174 * Method calls video connection utility's wait scheduler to |
|
175 * put current active object to wait with given id. |
|
176 * |
|
177 * @param aWaitId id for the wait |
|
178 */ |
|
179 void WaitL( TUint32 aWaitId ); |
|
180 |
|
181 /** |
|
182 * Method calls video connection utility's wait scheduler to |
|
183 * end wait for given id |
|
184 * |
|
185 * @param aWaitId id for the wait |
|
186 */ |
|
187 void EndWait( TUint32 aWaitId ); |
|
188 |
|
189 /** |
|
190 * Method return ETrue, if this instance is master |
|
191 * |
|
192 * @return TBool ETrue if is master, EFalse if not master |
|
193 */ |
|
194 TBool IsMaster(); |
|
195 |
|
196 private: // New functions |
|
197 |
|
198 /** |
|
199 * Method reads Video center's connection related settings |
|
200 * from the cenrep. Method also tries to reinit details inside |
|
201 * conn util engine, if it fails, "always ask" is saved to VC settings |
|
202 * |
|
203 * @return KErrNone or one of the system wide error codes. Method can also leave. |
|
204 */ |
|
205 TInt PrepareConnSettings(); |
|
206 |
|
207 /** |
|
208 * Setups the connection creation prefs for "always ask" situation, and calls engine |
|
209 * to start connection or calls DoCreateConnectionL for other cases. |
|
210 * |
|
211 * @param aSilent If ETrue, tries to open connection silently (without dialogs) |
|
212 * |
|
213 * @return KErrNone or one of the system wide error codes. Method can also leave. |
|
214 */ |
|
215 TInt CreateConnection( TBool aSilent ); |
|
216 |
|
217 /** |
|
218 * Setups and tries to open connection via SNAP. |
|
219 * |
|
220 * @param aSilent If ETrue, tries to open connection silently (without dialogs) |
|
221 * @param aSnapId snap (destination) id to use in connection |
|
222 * @param aMasterConnect If true, mobility object needs to be created for receiving events |
|
223 * from network. |
|
224 * |
|
225 * @return KErrNone or one of the system wide error codes. Method can also leave. |
|
226 */ |
|
227 TInt DoCreateConnection( TBool aSilent, TInt32 aSnapId, TBool aMasterConnect ); |
|
228 |
|
229 /** |
|
230 * After connection staring is finished by the engine, this method is to be called. |
|
231 * Method first checks is connection is ne for this inctance and if it is, |
|
232 * utility's internal connection information is setted up. Method also |
|
233 * calls CheckAndChangeSlaveToMaster to setup this inctance to be master if |
|
234 * one does not yet exist. If this inctance is to be master, connection info |
|
235 * is updated to PS as well. |
|
236 * |
|
237 * |
|
238 * @return KErrNone if connection data filled ok and we are connected. |
|
239 */ |
|
240 TInt HandleFinalizeConnection(); |
|
241 |
|
242 /** |
|
243 * Displays a wait note |
|
244 * |
|
245 * @param aConnectionName name of connection to show on the dialog |
|
246 */ |
|
247 void DisplayWaitNote( const TDesC& aConnectionName = KNullDesC ); |
|
248 |
|
249 /** |
|
250 * closes a wait note |
|
251 * |
|
252 */ |
|
253 void CloseWaitNote(); |
|
254 |
|
255 /** |
|
256 * Method queries all observers and requests roaming status from them. |
|
257 * If all observers accept or there is not observers, PS key EVCxPSNbRoamAccepted |
|
258 * is increased by one. After method ends, PS key EVCxPSNbrRoamResp is increased by |
|
259 * one to notify that one response is ready. |
|
260 * |
|
261 * @return TBool ETrue if roaming is allowed |
|
262 */ |
|
263 TBool DoRequestClientRoamingL(); |
|
264 |
|
265 /** |
|
266 * Method saves iap id and name, snap id and name and connection state |
|
267 * to pubsub. |
|
268 * |
|
269 */ |
|
270 void SaveConnectionToPubSubL(); |
|
271 |
|
272 /** |
|
273 * Method handles changing of slave to master when existing |
|
274 * master is diconnecting. If change has occured, reinits |
|
275 * the connection to be used via snap instead of IAP |
|
276 * |
|
277 */ |
|
278 void HandleMasterChangeL(); |
|
279 |
|
280 /** |
|
281 * Method handles the actual change of this instance to be |
|
282 * master if there is not yet any. |
|
283 * |
|
284 * Changing is protected by semaphore, so only one existing |
|
285 * slave instance can check and possible change it's status |
|
286 * at the time. |
|
287 * |
|
288 * Note that KErrNone does not indicate succesfull status |
|
289 * chenge. Caller should also check if iMaster -value has changed. |
|
290 * |
|
291 * @return TInt KErrNone or one of the system wide error codes, |
|
292 */ |
|
293 TInt CheckAndChangeSlaveToMaster(); |
|
294 |
|
295 /** |
|
296 * Method changes slave instance connection status |
|
297 * based on given value. |
|
298 * |
|
299 * @param aNewStatus new status from master |
|
300 * |
|
301 */ |
|
302 void HandleSlaveConnectionStatusL( const TInt& aNewStatus ); |
|
303 |
|
304 /** |
|
305 * Method checks whether there are enough responses for the roaming |
|
306 * request. If there is sets roaming acceptance status to PS. |
|
307 * |
|
308 * @param aNbrOfResps number of responces received so far |
|
309 * |
|
310 */ |
|
311 void HandleRoamingReponsesL( const TInt& aNbrOfResps ); |
|
312 |
|
313 /** |
|
314 * Method notifies observers about IAP changed event |
|
315 * |
|
316 */ |
|
317 void NotifyObserversIAPChanged(); |
|
318 |
|
319 private: // Data |
|
320 |
|
321 |
|
322 /** |
|
323 * Interface for UI related functions for connecting utility: |
|
324 * Showing and hiding connection -dialog |
|
325 */ |
|
326 CVcxConnectionUtility* iUIInterface; |
|
327 |
|
328 /** |
|
329 * Connection utility engine. Handles connection creation, disconnecting and |
|
330 * connection meta data |
|
331 */ |
|
332 CVcxConnUtilEngine* iEngine; |
|
333 |
|
334 /** |
|
335 * pubsub engine, listens pubsub keys |
|
336 * and notify chenges |
|
337 */ |
|
338 CVcxConnUtilPubSub* iPubsub; |
|
339 |
|
340 /** |
|
341 * Wait handler for managing all CactiveSchedulerWaits |
|
342 * used by video connection utility |
|
343 */ |
|
344 CVcxConnUtilWaitSch* iWaitHandler; |
|
345 |
|
346 /** |
|
347 * Array of external network observers. |
|
348 */ |
|
349 RArray<MConnUtilEngineObserver*> iObservers; |
|
350 |
|
351 /** |
|
352 * Is this instance the master |
|
353 */ |
|
354 TBool iMaster; |
|
355 |
|
356 /** |
|
357 * Semaphore to prevent concurrency in master / slave switch |
|
358 */ |
|
359 RSemaphore iSemaSwitchRole; |
|
360 |
|
361 /** |
|
362 * Semaphore to prevent concurrency connection creation |
|
363 */ |
|
364 RSemaphore iSemaCreateConn; |
|
365 |
|
366 /** |
|
367 * Used curing connection creation to tell active objects |
|
368 * that current connection is new. |
|
369 */ |
|
370 TBool iNewConnection; |
|
371 }; |
|
372 #endif // __VCX_CONNUTILIMPL_H_ |
|
373 // End of File |
|