|
1 // Copyright (c) 2003-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 // qoslib_glob.h - Qoslib global (TLS) data |
|
15 // Qoslib global (TLS) data |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @internalComponent |
|
22 */ |
|
23 #ifndef __QOSLIB_GLOB_H__ |
|
24 #define __QOSLIB_GLOB_H__ |
|
25 |
|
26 #include "qoslib.h" |
|
27 #include "pfqosparser.h" |
|
28 #include "pfqos_stream.h" |
|
29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
30 #include <networking/qoslib_internal.h> |
|
31 #endif |
|
32 |
|
33 // |
|
34 const TInt KQoSSignaledOK = 0x0001; // Signaling ok |
|
35 const TInt KQoSSignaledFailed = 0x0002; // Signaling failed |
|
36 const TInt KQoSProvisionedOK = 0x0004; // Provisioning ok |
|
37 const TInt KQoSProvisionedFailed = 0x0008; // Provisioning failed |
|
38 const TInt KQoSOK = 0x0010; // A scheduler module should return this when ok |
|
39 const TInt KQoSFailed = 0x0020; // A scheduler module should return this when request fails |
|
40 const TInt KQoSRequestPending = 0x0040; // Request is pending and the result will be given using |
|
41 // Event-method (see below) |
|
42 |
|
43 const TInt KQoSDefaultBufSize = 8000; |
|
44 |
|
45 // Forward declaration |
|
46 class CQoSMan; |
|
47 // |
|
48 class CQoSRequestBase : public CBase |
|
49 { |
|
50 friend class CQoSMan; |
|
51 public: |
|
52 ~CQoSRequestBase(); |
|
53 |
|
54 virtual void ProcessEvent(TPfqosMessage& aMsg)=0; |
|
55 virtual void NotifyError(TInt aReason)=0; |
|
56 virtual TBool MatchReply(const TPfqosMessage& aMsg, TUint8 aMsgType)=0; |
|
57 virtual void ProcessReply(TPfqosMessage& aMsg)=0; |
|
58 TInt NotifyEvent(MQoSObserver& aObserver, TUint aMask); |
|
59 TInt CancelNotifyEvent(MQoSObserver& aObserver); |
|
60 |
|
61 protected: |
|
62 void ParseExtensions(TPfqosMessage& aMsg, CQoSParameters& aPolicy); |
|
63 TInt GetExtensionType(const TDesC8& aData, TInt& aType); |
|
64 |
|
65 protected: |
|
66 TSglQueLink iNext; |
|
67 TUint iEventMask; |
|
68 MQoSObserver* iObserver; |
|
69 CQoSParameters iPolicy; |
|
70 CQoSMan* iManager; |
|
71 }; |
|
72 |
|
73 class TSelectorItem : public TQoSSelector |
|
74 { |
|
75 public: |
|
76 TSglQueLink iNext; |
|
77 }; |
|
78 |
|
79 enum EQoSChannelStatus |
|
80 { |
|
81 EInit, |
|
82 EChannelCreated, |
|
83 EChannelReady |
|
84 }; |
|
85 |
|
86 |
|
87 class CChannel : public CQoSRequestBase |
|
88 { |
|
89 public: |
|
90 enum TPendingStatus |
|
91 { |
|
92 ENone, |
|
93 EPendingOpen, |
|
94 EPendingOpenExisting, |
|
95 EPendingOpenExistingSetQoS, |
|
96 EPendingSetPolicy, |
|
97 EPendingJoin, |
|
98 EPendingLeave, |
|
99 EPendingDelete |
|
100 }; |
|
101 |
|
102 static CChannel* NewL(CQoSMan* aManager, RSocket& aSocket, CQoSParameters* aSpec); |
|
103 ~CChannel(); |
|
104 void ProcessEvent(TPfqosMessage& aMsg); |
|
105 void ProcessReply(TPfqosMessage& aMsg); |
|
106 TBool Match(TInt aChannelId); |
|
107 TBool MatchReply(const TPfqosMessage& aMsg, TUint8 aMsgType); |
|
108 TInt OpenExisting(); |
|
109 TInt SetQoS(CQoSParameters& aPolicy); |
|
110 TInt Join(RSocket& aSocket); |
|
111 TInt Leave(RSocket& aSocket); |
|
112 TInt GetCapabilities(TUint& aCapabilities); |
|
113 void NotifyError(TInt aReason); |
|
114 |
|
115 inline CQoSParameters& GetPolicy(); |
|
116 inline TUint Capabilities() const; |
|
117 inline EQoSChannelStatus Status() const; |
|
118 inline TInt ChannelId() const; |
|
119 TInt Close(); |
|
120 |
|
121 private: |
|
122 CChannel(CQoSMan* aManager); |
|
123 // CChannel(CQoSMan* aManager, CQoSParameters* aSpec); |
|
124 void ConstructL(RSocket& aSocket, CQoSParameters* aSpec); |
|
125 // void ConstructL(RSocket& aSocket); |
|
126 void CreateSelector(TQoSSelector& aSelector, const TPfqosMessage& aMsg); |
|
127 |
|
128 private: |
|
129 EQoSChannelStatus iStatus; |
|
130 TInt iChannelId; |
|
131 TQoSSelector iRequestSelector; |
|
132 TQoSSelector iPendingRequestSelector; |
|
133 TPendingStatus iPending; |
|
134 TUint iCapabilities; |
|
135 }; |
|
136 |
|
137 class CPolicy : public CQoSRequestBase |
|
138 { |
|
139 public: |
|
140 enum TPendingStatus |
|
141 { |
|
142 ENone, |
|
143 EPendingAdd, |
|
144 EPendingUpdate, |
|
145 EPendingDelete, |
|
146 EPendingGet, |
|
147 EPendingLoadFile, |
|
148 EPendingUnloadFile |
|
149 }; |
|
150 |
|
151 static CPolicy* NewL(CQoSMan* aManager, const TQoSSelector& aSelector); |
|
152 ~CPolicy(); |
|
153 void SetQoSL(CQoSParameters& aPolicy); |
|
154 void GetQoSL(); |
|
155 void DeleteL(); |
|
156 void LoadFileL(const TDesC& aName); |
|
157 void UnloadFileL(const TDesC& aName); |
|
158 TBool Match(const TQoSSelector& aSelector); |
|
159 void ProcessReply(TPfqosMessage& aMsg); |
|
160 TBool MatchReply(const TPfqosMessage& aMsg, TUint8 aMsgType); |
|
161 void ProcessEvent(TPfqosMessage& aMsg); |
|
162 void NotifyError(TInt aReason); |
|
163 void Close(); |
|
164 |
|
165 protected: |
|
166 CPolicy(CQoSMan* aManager, const TQoSSelector& aSelector); |
|
167 |
|
168 private: |
|
169 TPendingStatus iPending; |
|
170 TBool iPolicyCreated; |
|
171 TQoSSelector iSelector; |
|
172 TUint iCapabilities; |
|
173 }; |
|
174 |
|
175 // |
|
176 class CRequest : public CBase |
|
177 { |
|
178 public: |
|
179 static CRequest* NewL(CQoSRequestBase* aOwner, TUint aBufSize); |
|
180 ~CRequest(); |
|
181 |
|
182 protected: |
|
183 CRequest(CQoSRequestBase* aOwner); |
|
184 void ConstructL(TUint aBufSize); |
|
185 |
|
186 public: |
|
187 CPfqosStream* iMsg; |
|
188 CQoSRequestBase* iOwner; |
|
189 TSglQueLink iLink; |
|
190 }; |
|
191 |
|
192 class CSender; |
|
193 class CQoSMan : public CActive |
|
194 { |
|
195 public: |
|
196 static CQoSMan* NewL(TInt aPriority=0); |
|
197 ~CQoSMan(); |
|
198 |
|
199 // qos channel methods |
|
200 CChannel* OpenQoSChannelL(RSocket& aSocket); |
|
201 void RemoveQoSChannel(CChannel* aChannel); |
|
202 void SetQoSL(CChannel& aChannel); |
|
203 void CreateL(CChannel& aChannel, const TQoSSelector& aSelector); |
|
204 void OpenExistingL(CChannel& aChannel, const TQoSSelector& aSelector); |
|
205 void JoinL(CChannel& aChannel, const TQoSSelector& aSelector); |
|
206 void LeaveL(CChannel& aChannel, const TQoSSelector& aSelector); |
|
207 |
|
208 // qos policy methods |
|
209 CPolicy* OpenQoSPolicyL(const TQoSSelector& aSelector); |
|
210 void RemoveQoSPolicy(CPolicy* aChannel); |
|
211 CPolicy* FindPolicy(const TQoSSelector& aSelector); |
|
212 |
|
213 void ClearPendingRequest(CQoSRequestBase* aRequest); |
|
214 void Send(CRequest* aRequest); |
|
215 inline RSocket& Socket(); |
|
216 inline const TCheckedUid& Uid() const; |
|
217 inline void Open(); |
|
218 void Close(); |
|
219 |
|
220 protected: |
|
221 CQoSMan(TInt aPriority=0); |
|
222 void ConstructL(); |
|
223 |
|
224 private: |
|
225 void Notify(TPfqosMessage& aMsg); |
|
226 void Flush(); |
|
227 CChannel* Match(TPfqosMessage& aMsg); |
|
228 CChannel* MatchChannelReply(TPfqosMessage& aMsg, TUint8 aMsgType); |
|
229 CPolicy* MatchPolicyReply(TPfqosMessage& aMsg, TUint8 aMsgType); |
|
230 void ExecEvent(TPfqosMessage& aMsg); |
|
231 void ExecReply(TPfqosMessage& aMsg); |
|
232 void RunL(); |
|
233 void DoCancel(); |
|
234 |
|
235 private: |
|
236 TInt iRefCount; |
|
237 TBool iNotifyPending; |
|
238 TBool iShutdown; |
|
239 TPtr8 iRecBuf; |
|
240 HBufC8* iBuf; |
|
241 RSocketServ iSocketServer; |
|
242 RSocket iSocket; |
|
243 CSender* iSender; |
|
244 TCheckedUid iUid; |
|
245 TSglQue<CChannel> iChannels; |
|
246 TSglQue<CPolicy> iStaticPolicies; |
|
247 }; |
|
248 |
|
249 // |
|
250 class QoSManGlobals |
|
251 { |
|
252 public: |
|
253 inline static CQoSMan* Get(); |
|
254 inline static void Set(CQoSMan* aGlobals); |
|
255 }; |
|
256 |
|
257 #include "qoslib_glob.inl" |
|
258 |
|
259 #endif |