|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __GUQOSIFACE_H__ |
|
17 #define __GUQOSIFACE_H__ |
|
18 |
|
19 #include <comms-infras/nifif.h> |
|
20 #include <timeout.h> |
|
21 #include <networking/umtsnifcontrolif.h> |
|
22 |
|
23 class CPdpContext; |
|
24 class CRequestBase; |
|
25 class CFlowData; |
|
26 |
|
27 enum TNifStatus |
|
28 { |
|
29 EUnknown, |
|
30 EReady, |
|
31 EPending, |
|
32 EClosed |
|
33 }; |
|
34 |
|
35 const TUint KMaxEvaluationPrecedences = 256; |
|
36 |
|
37 class CModuleGuqos; |
|
38 |
|
39 // represents a Nif instance containing PDP contexts (there is one Nif instance per primary Pdp context) |
|
40 class CNif : public CBase, public MNifEvent |
|
41 { |
|
42 public: |
|
43 static CNif* NewL(CNifIfBase& aInterface, CModuleGuqos& aModule); |
|
44 ~CNif(); |
|
45 |
|
46 TInt NewPdpContext(); |
|
47 TInt PrimaryContextCreated(const TContextParameters& aParams); |
|
48 void SecondaryContextCreated(const TContextParameters& aParams); |
|
49 void DeletePdpContext(CPdpContext* aContext); |
|
50 |
|
51 CPdpContext* FindContext(TInt aContextId); |
|
52 CPdpContext* FindChannel(TInt aChannelId); |
|
53 |
|
54 void AddRequest(CRequestBase& aRequest); |
|
55 |
|
56 void CancelPendingRequest(CFlowData* aFlowData); |
|
57 void CancelPendingRequest(CPdpContext* aContext); |
|
58 TInt FindEvaluationPrecedence(); |
|
59 void RecomputeEvaluationPrecedences(); |
|
60 |
|
61 void CloseRequest(CRequestBase* aRequest); |
|
62 |
|
63 TInt Event(CProtocolBase* aProtocol, TUint aName, TDes8& aOption, TAny* aSource=0); |
|
64 TInt NetworkStatusEvent(const TNetworkParameters& aNetworkEvent); |
|
65 |
|
66 inline CPdpContext* PrimaryPdpContext() const; |
|
67 void IssueRequest(); |
|
68 inline void RemoveContext(CPdpContext& aContext); |
|
69 inline CNifIfBase& Interface() const; |
|
70 inline CModuleGuqos& Module() const; |
|
71 inline void SetStatus(const TNifStatus& aStatus); |
|
72 inline const TNifStatus& Status() const; |
|
73 inline CPdpContext* DefaultPdpContext(); |
|
74 inline TUint32 IapId() const; |
|
75 |
|
76 // Return a reference to initialized context parameters. |
|
77 TContextParameters& ContextParameters(); |
|
78 protected: |
|
79 CNif(CNifIfBase& aInterface, CModuleGuqos& aModule); |
|
80 void ConstructL(); |
|
81 TInt RegisterEventHandler(); |
|
82 TInt SetEvents(TBool aValue); |
|
83 void SetDefaultQoS(); |
|
84 |
|
85 private: |
|
86 void SelectNewDefaultContext(); |
|
87 void AddContext(CPdpContext& aContext); |
|
88 TInt CloseInterface(); |
|
89 |
|
90 CNifIfBase& iNif; // CNif always has a valid CNifIfBase |
|
91 CModuleGuqos& iModule; |
|
92 |
|
93 CPdpContext* iPrimary; // Primary PDP context (cannot be deleted while CNif exists) |
|
94 |
|
95 TSglQue<CPdpContext> iContexts; |
|
96 |
|
97 TUint32 iIapId; |
|
98 TSglQueLink iNext; |
|
99 TNifStatus iStatus; |
|
100 |
|
101 TSglQue<CRequestBase> iPending; |
|
102 CRequestBase* iCurrentRequest; |
|
103 TUint32 iPendingSequence; // Temporary hack to detect iPending modifications |
|
104 |
|
105 //?? This really should be a bitmap, and not waste even 8 bits where 1 would do... |
|
106 TUint8 iEvaluationPrecedenceMap[KMaxEvaluationPrecedences]; |
|
107 |
|
108 // Every NIF Control call requires use of this LARGE object. Include |
|
109 // it in here, so that it does not need to be constantly allocated |
|
110 // from heap or stack! Unfortunately, despite it being a T-class, it |
|
111 // actually contains C-class pointers and RArrays!!! A major goof |
|
112 // in specification!!! |
|
113 TContextParameters iParameters; |
|
114 |
|
115 friend class CNifManager; |
|
116 public: |
|
117 void RunPendingRequests(); |
|
118 RTimeout iTimeout; |
|
119 }; |
|
120 |
|
121 typedef TSglQueIter<CPdpContext> TContextIter; |
|
122 |
|
123 // Inline methods |
|
124 inline CPdpContext* CNif::PrimaryPdpContext() const |
|
125 { return iPrimary; } |
|
126 |
|
127 inline void CNif::RemoveContext(CPdpContext& aContext) |
|
128 { iContexts.Remove(aContext); } |
|
129 |
|
130 //lint -e{1763} would like return to be const (now 'indirectly modifies') |
|
131 inline CNifIfBase& CNif::Interface() const |
|
132 { return iNif; } |
|
133 |
|
134 inline CModuleGuqos& CNif::Module() const |
|
135 { return iModule; } |
|
136 |
|
137 inline void CNif::SetStatus(const TNifStatus& aStatus) |
|
138 { iStatus = aStatus; } |
|
139 |
|
140 inline const TNifStatus& CNif::Status() const |
|
141 { return iStatus; } |
|
142 |
|
143 |
|
144 inline CPdpContext* CNif::DefaultPdpContext() |
|
145 { return iPrimary; } |
|
146 |
|
147 inline TUint32 CNif::IapId() const |
|
148 { return iIapId; }; |
|
149 |
|
150 |
|
151 class CNifManager : public CBase |
|
152 { |
|
153 public: |
|
154 static CNifManager* NewL(); |
|
155 ~CNifManager(); |
|
156 |
|
157 CNif* CreateNifL(CNifIfBase& aInterface, CModuleGuqos& aModule); |
|
158 void DeleteNif(CNifIfBase* aInterface); |
|
159 void DeleteNif(CNif* aInterface); |
|
160 CNif* FindInterface(const CNifIfBase *aIface); |
|
161 CPdpContext* FindChannel(TInt aChannelId); |
|
162 void CancelPendingRequests(CFlowData* aFlowData); |
|
163 |
|
164 protected: |
|
165 CNifManager(); |
|
166 void ConstructL(); |
|
167 |
|
168 private: |
|
169 TSglQue<CNif> iNifs; |
|
170 }; |
|
171 |
|
172 #endif |