|
1 /** |
|
2 * Copyright (c) 2003-2009 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 "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 * Header for Psd State Machines |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file PSDAGT.H |
|
24 @internalComponent |
|
25 */ |
|
26 |
|
27 #ifndef __PSDAGT_H__ |
|
28 #define __PSDAGT_H__ |
|
29 |
|
30 #include <etelpckt.h> |
|
31 #include <etelqos.h> |
|
32 #include <pcktcs.h> |
|
33 #include <comms-infras/cagentsmbase.h> |
|
34 #include <comms-infras/dbaccess.h> |
|
35 |
|
36 #include "psdpanic.h" |
|
37 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
38 #include <comms-infras/nifprvar_internal.h> |
|
39 #endif |
|
40 |
|
41 #define INCOMING_NOT_SUPORTED 1 ///< Comment out to enable incoming connections |
|
42 |
|
43 //class CCommsDbPsdAccess; |
|
44 class CEventLogger; |
|
45 class CDataLogger; |
|
46 class CPsdContextConfig; |
|
47 class CPsdContextQoSConfig; |
|
48 |
|
49 class MPsdEnv |
|
50 /** |
|
51 This class defines the interface for a set of utility functions which must |
|
52 be implemented by a derived class providing those services |
|
53 |
|
54 @internalComponent |
|
55 */ |
|
56 { |
|
57 public: |
|
58 /** |
|
59 Network modes |
|
60 */ |
|
61 enum TNetworkMode |
|
62 { |
|
63 /** Unknown Mode |
|
64 */ |
|
65 EModeUnknown, |
|
66 /** WCDMA Mode - 3GPP family i.e. GSM, GPRS, UMTS |
|
67 */ |
|
68 EModeWCDMA |
|
69 }; |
|
70 public: |
|
71 /** |
|
72 Provides a reference to the class that provides the base environment functions |
|
73 |
|
74 @return MAgentStateMachineEnv& the base environment class |
|
75 */ |
|
76 virtual MAgentStateMachineEnv& BaseEnv()=0; |
|
77 |
|
78 /** |
|
79 Provides a reference to a centrally held RTelServer handle |
|
80 |
|
81 @return RTelServer& the RTelServer handle |
|
82 */ |
|
83 virtual RTelServer& TelServer()=0; |
|
84 |
|
85 /** |
|
86 Provides a reference to a centrally held RPhone handle |
|
87 |
|
88 @return RPhone& the RPhone handle |
|
89 */ |
|
90 virtual RPhone& Phone()=0; |
|
91 |
|
92 /** |
|
93 Provides a reference to a centrally held RPacketService handle |
|
94 |
|
95 @return RPacketService& the RPacketService handle |
|
96 */ |
|
97 virtual RPacketService& PacketNetwork()=0; |
|
98 |
|
99 /** |
|
100 Provides a reference to a centrally held RPacketContext handle |
|
101 |
|
102 @return RPacketContext& the RPacketContext handle |
|
103 */ |
|
104 virtual RPacketContext& Context()=0; |
|
105 |
|
106 /** |
|
107 Function to allow clients to inquire if QoS is supported. |
|
108 |
|
109 @return TBool flag indicating if QoS is supported. |
|
110 */ |
|
111 virtual TBool IsQoSSupported()const=0; |
|
112 |
|
113 /** |
|
114 Function to allow clients to set if QoS is supported. |
|
115 |
|
116 @param TBool isSupported reference to if QoS is supported or not. |
|
117 */ |
|
118 virtual void SetQoSSupported(TBool isSupported)=0; |
|
119 |
|
120 /** |
|
121 Provides a reference to a centrally held RPacketQoS handle |
|
122 |
|
123 @return RPacketQoS& the RPacketQoS handle |
|
124 */ |
|
125 virtual RPacketQoS& QoS()=0; |
|
126 |
|
127 /** |
|
128 Provides a reference to a centrally held context config parameters object |
|
129 |
|
130 @return CPsdContextConfig& the context config parameter object |
|
131 */ |
|
132 virtual const CPsdContextConfig& Config() const =0; |
|
133 |
|
134 /** |
|
135 Provides a reference to a centrally held QoS config parameters object |
|
136 |
|
137 @return CPsdContextQoSConfig& the QoS config parameter object |
|
138 */ |
|
139 virtual const CPsdContextQoSConfig& QoSConfig() const =0; |
|
140 |
|
141 /** |
|
142 Provides a pointer to a centrally held CEventLogger object |
|
143 |
|
144 @return CEventLogger* the event logger object |
|
145 */ |
|
146 virtual CEventLogger* Logger()=0; |
|
147 |
|
148 /** |
|
149 Provides a pointer to a centrally held CDataLogger object |
|
150 |
|
151 @return CDataLogger* the data logger object |
|
152 */ |
|
153 virtual CDataLogger* DataLogger()=0; |
|
154 |
|
155 /** |
|
156 Provides a reference to a centrally held TInt that allows clients |
|
157 to set or get the cause of the last error |
|
158 |
|
159 @return TInt& reference to the last error |
|
160 */ |
|
161 virtual TInt& ErrorCause() =0; |
|
162 |
|
163 /** |
|
164 Function indicates the direction of the connection which is in progress |
|
165 |
|
166 @return TCommDbConnectionDirection the connection direction |
|
167 */ |
|
168 virtual TCommDbConnectionDirection Direction()=0; |
|
169 |
|
170 /** |
|
171 Function to allow clients to set whether logging is in progress |
|
172 and also to inquire if logging is in progress |
|
173 |
|
174 @return TBool& reference to the Flag indicating if logging in progress or not |
|
175 @deprecated Depracated since logging requests are stored in a queue now |
|
176 */ |
|
177 virtual TBool& AmLogging() =0; |
|
178 |
|
179 /** |
|
180 Function to allow clients to inquire whether the TSY has been loaded |
|
181 |
|
182 @return TBool Flag indicating if the TSY has been loaded or not |
|
183 */ |
|
184 virtual TBool TsyLoaded() const =0; |
|
185 |
|
186 /** |
|
187 Function to allow clients to set whether the TSY has been loaded or not |
|
188 |
|
189 @param TBool aStatus Flag indicating if the TSY has been loaded or not |
|
190 */ |
|
191 virtual void SetTsyLoaded(TBool aStatus)=0; |
|
192 |
|
193 /** |
|
194 Function to allow clients to inquire the mode of the current connection |
|
195 |
|
196 @return TNetworkMode the current mode |
|
197 */ |
|
198 virtual TNetworkMode Mode() const =0; |
|
199 }; |
|
200 |
|
201 |
|
202 class MPsdCommDbAccess |
|
203 /** |
|
204 This class defines the interface for a set of database enquiry functions which must |
|
205 be implemented by a derived class providing those services |
|
206 |
|
207 @internalComponent |
|
208 */ |
|
209 { |
|
210 public: |
|
211 /** |
|
212 Function to allow clients to inquire if incomming connections are allowed |
|
213 |
|
214 @return TBool flag indicating if incomming connections allowed |
|
215 */ |
|
216 virtual TBool IsIncomingAllowedL() const =0; |
|
217 |
|
218 /** |
|
219 Function to allow clients to inquire the name of the remote party in the connection |
|
220 |
|
221 @param TDes& aRemoteParty reference to a descriptor into which the remote party name will be written. |
|
222 */ |
|
223 virtual void GetRemotePartyL(TDes& aRemoteParty) const=0; |
|
224 }; |
|
225 |
|
226 class CAgentSMBase; |
|
227 |
|
228 class CPsdAgentSMBase : public CAgentSMBase, public MPsdEnv, public MPsdCommDbAccess |
|
229 /** |
|
230 CPsdAgentSMBase is the base class for Psd state machines, both inbound and outbound. |
|
231 It contains data which must be persistent for the lifetime of the SM, and accessor functions |
|
232 for the state objects to use. |
|
233 |
|
234 @internalComponent |
|
235 */ |
|
236 { |
|
237 public: |
|
238 // These virtuals are from MPsdEnv |
|
239 |
|
240 virtual MAgentStateMachineEnv& BaseEnv(); |
|
241 virtual RTelServer& TelServer(); |
|
242 virtual RPhone& Phone(); |
|
243 virtual RPacketService& PacketNetwork(); |
|
244 virtual RPacketContext& Context(); |
|
245 virtual TBool IsQoSSupported()const; |
|
246 virtual void SetQoSSupported(TBool isSupported); |
|
247 virtual RPacketQoS& QoS(); |
|
248 virtual const CPsdContextConfig& Config() const; |
|
249 virtual const CPsdContextQoSConfig& QoSConfig() const; |
|
250 virtual TInt& ErrorCause(); |
|
251 virtual CEventLogger* Logger(); |
|
252 virtual CDataLogger* DataLogger(); |
|
253 virtual TBool& AmLogging(); //* Depracated since logging requests are stored in a queue now |
|
254 virtual TBool TsyLoaded() const; |
|
255 virtual void SetTsyLoaded(TBool aStatus); |
|
256 virtual TNetworkMode Mode() const; |
|
257 |
|
258 // These virtuals are from MPsdCommDbAccess |
|
259 virtual TBool IsIncomingAllowedL() const; |
|
260 virtual void GetRemotePartyL(TDes& aRemoteParty) const; |
|
261 |
|
262 // These virtuals are from CAgentSMBase |
|
263 virtual TInt GetExcessData(TDes8& aBuffer); |
|
264 virtual TInt Notification(TNifToAgentEventType aEvent, TAny* aInfo); |
|
265 virtual void GetLastError(TInt& aError); |
|
266 |
|
267 protected: |
|
268 CPsdAgentSMBase(MAgentNotify& aObserver, CDialogProcessor* aDlgPrc, CCommsDbAccess& aDbAccess); |
|
269 virtual ~CPsdAgentSMBase(); |
|
270 void ConstructL(); |
|
271 private: |
|
272 void InquireModeL(); |
|
273 private: |
|
274 RTelServer iTelServer; |
|
275 TBool iTsyLoaded; |
|
276 RPhone iPhone; |
|
277 RPacketService iPacketNetwork; |
|
278 RPacketContext iContext; |
|
279 RPacketQoS iQoS; |
|
280 CPsdContextConfig* iConfig; |
|
281 CPsdContextQoSConfig* iQoSConfig; |
|
282 CEventLogger* iEventLogger; |
|
283 CDataLogger* iDataLogger; |
|
284 TBool iAmLogging; //* Depracated since logging requests are stored in a queue now |
|
285 TInt iErrorCause; |
|
286 TNetworkMode iNetworkMode; |
|
287 TBool iIsQoSSupported; |
|
288 }; |
|
289 |
|
290 |
|
291 class CPsdOutSM : public CPsdAgentSMBase |
|
292 /** |
|
293 CPsdOutSM is the outbound state machine. It instantiates the first state appropriate to |
|
294 this SM, and implements the Direction() function so states can discover which SM they are |
|
295 currently part of, outbound or inbound. |
|
296 |
|
297 @internalComponent |
|
298 */ |
|
299 { |
|
300 public: |
|
301 static CPsdOutSM* NewL(MAgentNotify& aObserver, CDialogProcessor* aDlgPrc, CCommsDbAccess& aDbAccess); |
|
302 virtual ~CPsdOutSM(); |
|
303 virtual TCommDbConnectionDirection Direction(); |
|
304 protected: |
|
305 void ConstructL(); |
|
306 CPsdOutSM(MAgentNotify& aObserver, CDialogProcessor* aDlgPrc, CCommsDbAccess& aDbAccess); |
|
307 }; |
|
308 |
|
309 |
|
310 #ifndef INCOMING_NOT_SUPORTED |
|
311 |
|
312 class CPsdInSM : public CPsdAgentSMBase |
|
313 /** |
|
314 CPsdInSM is the inbound state machine. |
|
315 |
|
316 @internalComponent |
|
317 */ |
|
318 { |
|
319 public: |
|
320 static CPsdInSM* NewL(MAgentObserver& aObserver, CDialogProcessor* aDlgPrc, CCommsDbAccess& aDbAccess); |
|
321 virtual ~CPsdInSM(); |
|
322 virtual TCommDbConnectionDirection Direction(); |
|
323 protected: |
|
324 void ConstructL(); |
|
325 CPsdInSM(MAgentObserver& aObserver, CDialogProcessor* aDlgPrc, CCommsDbAccess& aDbAccess); |
|
326 }; |
|
327 #endif // #ifndef INCOMING_NOT_SUPORTED |
|
328 |
|
329 |
|
330 class CPsdContextConfig : public CBase |
|
331 /** |
|
332 CPsdContextConfig encapulates the context config parameters |
|
333 |
|
334 @internalComponent |
|
335 */ |
|
336 { |
|
337 public: |
|
338 static CPsdContextConfig* NewL(CCommsDbAccess& aDbAccess, MPsdEnv::TNetworkMode aMode); |
|
339 ~CPsdContextConfig(); |
|
340 public: // Access functions |
|
341 const TPacketDataConfigBase& Config() const; |
|
342 TDesC8& PackedConfig() const; |
|
343 TBool IsConfigSupportedL(const RPacketService& aPacketData, TCommDbConnectionDirection aDirection) const; |
|
344 TBool TsySupportsDataTransferInfoL(const RPacketService& aPacketData) const; |
|
345 TBool QueryIfConfigAcceptable(TDesC8& aNewConfig) const; |
|
346 TBool QueryIfIncommingConnectionAcceptable(const RPacketContext::TProtocolType& aProtocolType, const RPacketContext::TProtocolAddress& aProtocolAddress) const; |
|
347 private: // Creational functions |
|
348 CPsdContextConfig(CCommsDbAccess& aDbAccess, MPsdEnv::TNetworkMode aMode); |
|
349 void ConstructL(); |
|
350 private: // internal functions |
|
351 void GprsConfigConstructL(); |
|
352 void GetGprsCompressionL(TUint& aCompression) const; |
|
353 void GetGprsAAL(RPacketContext::TAnonymousAccess& aAnonymous) const; |
|
354 void GetGprsEdgeL(TBool& aUseEdge) const; |
|
355 TBool QueryIfGprsConfigAcceptable(const RPacketContext::TContextConfigGPRS& aNewConfig) const; |
|
356 private: |
|
357 CCommsDbAccess& iDbAccess; |
|
358 MPsdEnv::TNetworkMode iMode; |
|
359 TPacketDataConfigBase* iConfig; |
|
360 TPtr8* iPackedConfig; |
|
361 mutable TUint iStaticCaps; |
|
362 RPacketContext::TProtocolType iProtocolType; |
|
363 }; |
|
364 |
|
365 |
|
366 class CPsdContextQoSConfig : public CBase |
|
367 /** |
|
368 CPsdContextQoSConfig encapulates the QoS config parameters |
|
369 |
|
370 @internalComponent |
|
371 */ |
|
372 { |
|
373 public: |
|
374 static CPsdContextQoSConfig* NewL(CCommsDbAccess& aDbAccess, MPsdEnv::TNetworkMode aMode); |
|
375 ~CPsdContextQoSConfig(); |
|
376 public: // Access functions |
|
377 const TPacketDataConfigBase& QoSConfig() const; |
|
378 TDes8& PackedQoSConfig() const; |
|
379 TBool QueryIfQoSAcceptable(TDesC8& aNewQoS) const; |
|
380 private: // Creational functions |
|
381 CPsdContextQoSConfig(CCommsDbAccess& aDbAccess, MPsdEnv::TNetworkMode aMode); |
|
382 void ConstructL(); |
|
383 private: // internal functions |
|
384 void GprsQoSConfigConstructL(); |
|
385 TBool QueryIfGprsQoSAcceptable(const RPacketQoS::TQoSGPRSNegotiated& aNewQoS) const; |
|
386 private: |
|
387 CCommsDbAccess& iDbAccess; |
|
388 MPsdEnv::TNetworkMode iMode; |
|
389 TPacketDataConfigBase* iQoSConfig; |
|
390 TPtr8* iPackedQoSConfig; |
|
391 }; |
|
392 |
|
393 |
|
394 class CPsdContextConfigChangeWatcher : public CActive |
|
395 /** |
|
396 This class is responsible for being notified of changes in the context |
|
397 configuration parameters and notifying its observer when such a change |
|
398 occurs |
|
399 |
|
400 @internalComponent |
|
401 */ |
|
402 { |
|
403 public: |
|
404 class MObserver |
|
405 { |
|
406 public: |
|
407 virtual void ReportConfigChange()=0; |
|
408 virtual void ReportConfigWatcherError(TInt aError)=0; |
|
409 }; |
|
410 public: |
|
411 CPsdContextConfigChangeWatcher(const RPacketContext& aContext, MObserver& aObserver, TPtr8& aContextParams); |
|
412 void StartL(); |
|
413 ~CPsdContextConfigChangeWatcher(); |
|
414 protected: |
|
415 void RunL(); |
|
416 void DoCancel(); |
|
417 private: |
|
418 MObserver& iObserver; |
|
419 const RPacketContext& iContext; |
|
420 TPtr8& iContextParams; |
|
421 }; |
|
422 |
|
423 |
|
424 class CPsdQoSConfigChangeWatcher : public CActive |
|
425 /** |
|
426 This class is responsible for being notified of changes in the QoS |
|
427 configuration parameters and notifying its observer when such a change |
|
428 occurs |
|
429 |
|
430 @internalComponent |
|
431 */ |
|
432 { |
|
433 public: |
|
434 class MObserver |
|
435 { |
|
436 public: |
|
437 virtual void ReportQoSChange()=0; |
|
438 virtual void ReportQoSWatcherError(TInt aError)=0; |
|
439 }; |
|
440 public: |
|
441 CPsdQoSConfigChangeWatcher(const RPacketQoS& aQoS, MObserver& aObserver, TPtr8& aQoSParams); |
|
442 void StartL(); |
|
443 ~CPsdQoSConfigChangeWatcher(); |
|
444 protected: |
|
445 void RunL(); |
|
446 void DoCancel(); |
|
447 private: |
|
448 MObserver& iObserver; |
|
449 const RPacketQoS& iQoS; |
|
450 TPtr8& iQoSParams; |
|
451 }; |
|
452 |
|
453 |
|
454 class MPsdContextChangeObserver |
|
455 /** |
|
456 This class defines the callback functions that must be implemented by an |
|
457 observer of a CPsdContextChangeMonitor object |
|
458 |
|
459 @internalComponent |
|
460 */ |
|
461 { |
|
462 public: |
|
463 virtual void ReportContextBelowAcceptableQuality() = 0; |
|
464 virtual void ReportError(TInt aError)=0; |
|
465 }; |
|
466 |
|
467 class CPsdContextChangeMonitor : public CActive, public CPsdContextConfigChangeWatcher::MObserver, public CPsdQoSConfigChangeWatcher::MObserver |
|
468 /** |
|
469 This class is reponsible for notifying clients when the quality of the |
|
470 Context or QoS falls below the minimum required values |
|
471 |
|
472 @internalComponent |
|
473 */ |
|
474 { |
|
475 public: |
|
476 static CPsdContextChangeMonitor* NewL(MPsdEnv* aEnv, MPsdContextChangeObserver* aObserver); |
|
477 ~CPsdContextChangeMonitor(); |
|
478 // callbacks |
|
479 virtual void ReportConfigChange(); |
|
480 virtual void ReportConfigWatcherError(TInt aError); |
|
481 virtual void ReportQoSChange(); |
|
482 virtual void ReportQoSWatcherError(TInt aError); |
|
483 protected: |
|
484 void RunL(); |
|
485 void DoCancel(); |
|
486 private: |
|
487 CPsdContextChangeMonitor(MPsdEnv* aEnv, MPsdContextChangeObserver* aObserver); |
|
488 void ConstructL(); |
|
489 void StartTimeout(); |
|
490 void CancelTimeout(); |
|
491 private: |
|
492 enum TContextState |
|
493 { |
|
494 EContextQualityAcceptable = 0x0, |
|
495 EConfigQualityUnAcceptable = 0x1, |
|
496 EQoSQualityUnAcceptable = 0x2 |
|
497 }; |
|
498 private: |
|
499 CPsdContextConfigChangeWatcher* iConfigWatcher; |
|
500 CPsdQoSConfigChangeWatcher* iQoSWatcher; |
|
501 TPacketDataConfigBase* iActualConfig; |
|
502 TPtr8* iPackedActualConfig; |
|
503 TPacketDataConfigBase* iActualQoSConfig; |
|
504 TPtr8* iPackedActualQoSConfig; |
|
505 MPsdEnv* iSM; |
|
506 MPsdContextChangeObserver* iObserver; |
|
507 TUint iContextState; |
|
508 TTimeIntervalMicroSeconds32 iDebounceTimeout; |
|
509 RTimer iDebounceTimer; |
|
510 }; |
|
511 |
|
512 #endif |