1 /* |
|
2 * Copyright (c) 2007 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 for wrapping RConnection* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __CCRCONNECTION_H |
|
21 #define __CCRCONNECTION_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "MCRConnectionObserver.h" |
|
25 #include <e32base.h> |
|
26 #include <es_sock.h> |
|
27 #include <CommDbConnPref.h> |
|
28 #include <es_enum.h> |
|
29 #include <rconnmon.h> |
|
30 |
|
31 // CONSTANTS |
|
32 /** Max Bandwidth constants -- from Helix Player, R1_Mobile_4_0_Factory.cfg : GRPS */ |
|
33 const TInt KCRBandwidthGPRS( 40200 ); |
|
34 /** Max Bandwidth constants -- from Helix Player, R1_Mobile_4_0_Factory.cfg : EGRPS */ |
|
35 const TInt KCRBandwidthEdgeGPRS( 89600 ); |
|
36 /** Max Bandwidth constants -- from Helix Player, R1_Mobile_4_0_Factory.cfg : 3G */ |
|
37 const TInt KCRBandwidthWCDMA( 384000 ); |
|
38 /** Max Bandwidth constants -- from Helix Player, R1_Mobile_4_0_Factory.cfg : WLAN */ |
|
39 const TInt KCRBandwidthWLAN( 1432572 ); |
|
40 /** Max Bandwidth constants -- from Helix Player, R1_Mobile_4_0_Factory.cfg : LAN */ |
|
41 const TInt KCRBandwidthLAN( 3000000 ); |
|
42 |
|
43 // MACROS |
|
44 // None |
|
45 |
|
46 // DATA TYPES |
|
47 // None |
|
48 |
|
49 // FORWARD DECLARATIONS |
|
50 class CCRConnection; |
|
51 |
|
52 // CLASS DECLARATION |
|
53 |
|
54 /** |
|
55 * RConnection wrapper |
|
56 */ |
|
57 class CCRConnection : public CActive, |
|
58 public MConnectionMonitorObserver |
|
59 { |
|
60 |
|
61 public: // Data types |
|
62 |
|
63 /** |
|
64 * Enumeration for different connection stages |
|
65 */ |
|
66 enum TConnectionState |
|
67 { |
|
68 EIdle, /**< Connection idle */ |
|
69 EFindingAP, /**< Search access point */ |
|
70 EFindingBearer, /**< Finding bearer */ |
|
71 EOpen, /**< Opening connection */ |
|
72 EConnecting /**< Connecting */ |
|
73 }; |
|
74 |
|
75 /** |
|
76 * Heuristics for the connection, ie, characteristics from the |
|
77 * connection discovered during run-time and that may affect it's usage. |
|
78 */ |
|
79 enum TConnectionHeuristic |
|
80 { |
|
81 /** |
|
82 * Connection is unable to stream RTP over UDP, |
|
83 * most likely due to firewall blocking. |
|
84 */ |
|
85 EUdpStreamingBlocked = 0 |
|
86 }; |
|
87 |
|
88 public: // Constructors and destructor |
|
89 |
|
90 /** |
|
91 * Two-phased constructor. |
|
92 * @param aSockServer |
|
93 * @return CCRConnection pointer to CCRConnection class |
|
94 */ |
|
95 static CCRConnection* NewL( RSocketServ& aSockServer ); |
|
96 |
|
97 /** |
|
98 * Destructor. |
|
99 */ |
|
100 virtual ~CCRConnection( ); |
|
101 |
|
102 public: // New methods |
|
103 /** |
|
104 * Method for starting and attaching a connection. |
|
105 * @since Series 60 3.0 |
|
106 * @param aConnectionId Connection id. |
|
107 * @return none. |
|
108 */ |
|
109 void Attach( TUint aConnectionId ); |
|
110 |
|
111 /** |
|
112 * Method for getting the rconnection to use. This is useful only |
|
113 * when connection state is open. |
|
114 * @since Series 60 3.0 |
|
115 * @param none. |
|
116 * @return reference to RConnection. |
|
117 */ |
|
118 RConnection& Connection( void ); |
|
119 |
|
120 /** |
|
121 * Method for getting state of the connection. |
|
122 * @since Series 60 3.0 |
|
123 * @param none. |
|
124 * @return connection state. |
|
125 */ |
|
126 TConnectionState State( void ) const; |
|
127 |
|
128 /** |
|
129 * Gets bearer for current connection. |
|
130 * @since Series 60 3.0 |
|
131 * @param none. |
|
132 * @return bearer type |
|
133 */ |
|
134 TConnMonBearerType BearerType() const; |
|
135 |
|
136 /** |
|
137 * Gets (estimated) maximum available connection bandwidth. |
|
138 * @since Series 60 3.0 |
|
139 * @param none. |
|
140 * @return bandwidth in bit/s, zero if unkown or connection not available. |
|
141 */ |
|
142 TInt MaximumBandwidth(); |
|
143 |
|
144 /** |
|
145 * Check if bearer is considered 3G, WLAN or similar |
|
146 * @since Series 60 3.0 |
|
147 * @param none. |
|
148 * @return TBool |
|
149 */ |
|
150 TBool IsBearerWLANor3G( TConnMonBearerType aBearer ); |
|
151 |
|
152 /** |
|
153 * Add observer for connection status. |
|
154 * @since Series 60 3.0 |
|
155 * @param aObserver new observer |
|
156 * @return TInt |
|
157 */ |
|
158 TInt RegisterObserver( MCRConnectionObserver* aObserver ); |
|
159 |
|
160 /** |
|
161 * remove observer for connection status. |
|
162 * @since Series 60 3.0 |
|
163 * @param aObserver observer to be removed. |
|
164 * @return TInt. |
|
165 */ |
|
166 TInt UnregisterObserver( MCRConnectionObserver* aObserver ); |
|
167 |
|
168 /** |
|
169 * Retrives a heuristic associated with the connection. |
|
170 * @since Series 60 3.0 |
|
171 * @param aHeuristic |
|
172 * @return value associated with the heuristic. |
|
173 */ |
|
174 TBool GetHeuristic( TConnectionHeuristic aHeuristic ); |
|
175 |
|
176 /** |
|
177 * Sets a heuristic associated with the connection |
|
178 * @since Series 60 3.0 |
|
179 * @param aHeuristic |
|
180 * @param aValue value associated with the heuristic. |
|
181 * @return none. |
|
182 */ |
|
183 void SetHeuristic( TConnectionHeuristic aHeuristic, |
|
184 TBool aValue ); |
|
185 |
|
186 private: // Methods from base classes |
|
187 |
|
188 /** |
|
189 * From CActive. |
|
190 * Cancel protocol implementation. |
|
191 * @since Series 60 3.0 |
|
192 * @param none. |
|
193 * @return none. |
|
194 */ |
|
195 void DoCancel(); |
|
196 |
|
197 /** |
|
198 * From CActive. |
|
199 * Outstanding request completed. |
|
200 * @since Series 60 3.0 |
|
201 * @param none. |
|
202 * @return none. |
|
203 */ |
|
204 void RunL(); |
|
205 |
|
206 /** |
|
207 * From CActive. |
|
208 * Handle error. |
|
209 * @since Series 60 3.0 |
|
210 * @param aError Error code. |
|
211 * @return KErrNone. |
|
212 */ |
|
213 TInt RunError( TInt aError ); |
|
214 |
|
215 /** |
|
216 * From MConnectionMonitorObserver. |
|
217 * Receives event notifications from connection monitor, |
|
218 * specifically for bearer changes. |
|
219 * @since Series 60 3.0 |
|
220 * @param aConnMonEvent |
|
221 * @return none. |
|
222 */ |
|
223 void EventL( const CConnMonEventBase& aConnMonEvent ); |
|
224 |
|
225 private: // New methods |
|
226 |
|
227 /** |
|
228 * Method for sending connection error events to message queue. |
|
229 * @since Series 60 3.0 |
|
230 * @param aError is Error code. |
|
231 * @return none |
|
232 */ |
|
233 void SendConnectionErrorToQueue( TInt aError ); |
|
234 |
|
235 /** |
|
236 * Close internal RConnection iConnection. |
|
237 * @since Series 60 3.0 |
|
238 * @param none. |
|
239 * @return none |
|
240 */ |
|
241 void CloseRConnection(); |
|
242 |
|
243 /** |
|
244 * Finds access point. |
|
245 * @since Series 60 3.0 |
|
246 * @param none. |
|
247 * @return none |
|
248 */ |
|
249 TInt FindApL(); |
|
250 |
|
251 /** |
|
252 * Finds bearer. |
|
253 * @since Series 60 3.0 |
|
254 * @param none. |
|
255 * @return none |
|
256 */ |
|
257 void FindBearerL(); |
|
258 |
|
259 /** |
|
260 * Notify UI about connection. |
|
261 * @since Series 60 3.0 |
|
262 * @param none. |
|
263 * @return none |
|
264 */ |
|
265 void NotificationL(); |
|
266 |
|
267 private: // Constructors and destructors |
|
268 |
|
269 /** |
|
270 * default constructor |
|
271 * @param aSockServer a reference to socket server. |
|
272 */ |
|
273 CCRConnection( RSocketServ& aSockServer ); |
|
274 |
|
275 /** |
|
276 * 2nd phase constructor |
|
277 */ |
|
278 void ConstructL(); |
|
279 |
|
280 private: // Data |
|
281 |
|
282 /** |
|
283 * Socker server. |
|
284 */ |
|
285 RSocketServ& iSockServer; |
|
286 |
|
287 /** |
|
288 * Connection. |
|
289 */ |
|
290 RConnection iConnection; |
|
291 |
|
292 /** |
|
293 * Observers. |
|
294 */ |
|
295 RPointerArray<MCRConnectionObserver> iObservers; |
|
296 |
|
297 /** |
|
298 * Current state. |
|
299 */ |
|
300 TConnectionState iState; |
|
301 |
|
302 /** |
|
303 * Connection preference. |
|
304 */ |
|
305 TCommDbConnPref iConnPref; |
|
306 |
|
307 /** |
|
308 * variable for getting notification when interface goes up or down |
|
309 */ |
|
310 TNifProgressBuf iNotification; |
|
311 |
|
312 /** |
|
313 * Connection id to be used |
|
314 */ |
|
315 TUint iCurrentConnectionId; |
|
316 |
|
317 /** |
|
318 * Connection monitor |
|
319 */ |
|
320 RConnectionMonitor iConMon; |
|
321 |
|
322 /** |
|
323 * How many active connections were found by connection monitor |
|
324 */ |
|
325 TUint iConnectionCount; |
|
326 |
|
327 /** |
|
328 * Heuristics for connection |
|
329 */ |
|
330 TUint32 iHeuristics; |
|
331 |
|
332 /** |
|
333 * Bearer type for current connection |
|
334 */ |
|
335 TConnMonBearerType iBearerType; |
|
336 |
|
337 /** |
|
338 * Bearer type detected after change |
|
339 */ |
|
340 TConnMonBearerType iNewBearerType; |
|
341 |
|
342 /** |
|
343 * Whether we have connection progress notification pending or not |
|
344 */ |
|
345 TBool iConMonProgressNotifyPending ; |
|
346 |
|
347 }; |
|
348 |
|
349 #endif // __CCRCONNECTION_H |
|
350 |
|
351 // End of file |
|