|
1 /* |
|
2 * Copyright (c) 2006-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 "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 of CMccQosHandler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDES |
|
22 #include <networking/qos3gpp_subconparams.h> |
|
23 #include <es_enum.h> |
|
24 |
|
25 #include "mccqoshandler.h" |
|
26 #include "mccqossockethandler.h" |
|
27 #include "mccqoseventmonitor.h" |
|
28 #include "mccqoslogging.h" |
|
29 |
|
30 // Constants for QoS parameters |
|
31 const TUint KTransferDelay = 600; |
|
32 const TUint KMaxSduSize = 1024; |
|
33 const TUint KMaxBitrate = 66000; |
|
34 const TUint KMaxGuaBitrate = 15200; |
|
35 |
|
36 // ======== MEMBER FUNCTIONS ================================================= |
|
37 |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CMccQosHandler::CMccQosHandler |
|
41 // C++ default constructor can NOT contain any code, that |
|
42 // might leave. |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CMccQosHandler::CMccQosHandler( MMccQosEventObserver& aObserver ) : |
|
46 iObserver( aObserver ) |
|
47 { |
|
48 |
|
49 } |
|
50 |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CMccQosPluginImpl::NewL |
|
54 // Static constructor. |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CMccQosHandler* CMccQosHandler::NewL( MMccQosEventObserver& aObserver ) |
|
58 { |
|
59 __QOSLOG( "CMccQosHandler::NewL" ) |
|
60 |
|
61 CMccQosHandler* self = new ( ELeave ) CMccQosHandler( aObserver ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CMccQosHandler::~CMccQosHandler |
|
68 // Destructor. |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CMccQosHandler::~CMccQosHandler() |
|
72 { |
|
73 __QOSLOG( "CMccQosHandler::~CMccQosHandler" ) |
|
74 |
|
75 delete iEventMonitor; |
|
76 HandleSocketHandlerDeletion(); |
|
77 iSubConnection.Close(); |
|
78 } |
|
79 |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CMccQosHandler::EnableQosL |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 void CMccQosHandler::EnableQosL() |
|
86 { |
|
87 __QOSLOG("CMccQosHandler::DoEnableQoSL") |
|
88 |
|
89 __ASSERT_ALWAYS( iConnection, User::Leave( KErrNotReady ) ); |
|
90 __ASSERT_ALWAYS( iSocketServ, User::Leave( KErrNotReady ) ); |
|
91 __ASSERT_ALWAYS( iSocket, User::Leave( KErrNotReady ) ); |
|
92 |
|
93 // This makes sure that we have not created eventhandler nor |
|
94 // sockethandler. This way we stay in correct state. |
|
95 if ( QoSEnabled() ) |
|
96 { |
|
97 __QOSLOG( "CMccQosHandler::DoEnableQoSL KErrInUse" ) |
|
98 |
|
99 User::Leave( KErrInUse ); |
|
100 } |
|
101 |
|
102 // Qos functionality is broken in current environments and prevents |
|
103 // sending packets to network. Therefore, feature is disabled at the |
|
104 // moment. Only supported when unit testing. |
|
105 #ifndef TEST_EUNIT |
|
106 __QOSLOG( "CMccQosHandler::DoEnableQoSL FEATURE DISABLED!" ) |
|
107 User::Leave( KErrNotSupported ); |
|
108 #endif |
|
109 |
|
110 // Create a parameter bundle & container for QoS subconnection parameters |
|
111 RSubConParameterBundle subConparams; |
|
112 CleanupClosePushL( subConparams ); |
|
113 |
|
114 // Parambundle takes ownership |
|
115 CSubConParameterFamily* family = |
|
116 CSubConParameterFamily::NewL( subConparams, KSubConQoSFamily ); |
|
117 |
|
118 // Create a requested technology specific parameter set for QoS |
|
119 // (Qos family takes ownership). |
|
120 CSubConQosR99ParamSet* reqParams( CSubConQosR99ParamSet::NewL( *family, |
|
121 CSubConParameterFamily::ERequested ) ); |
|
122 |
|
123 // Create acceptable parameter set. (Qos family takes ownership). |
|
124 CSubConQosR99ParamSet* acpParams( CSubConQosR99ParamSet::NewL( *family, |
|
125 CSubConParameterFamily::EAcceptable ) ); |
|
126 |
|
127 // Set the requested params, request conversational class. |
|
128 reqParams->SetTrafficClass( |
|
129 RPacketQoS::ETrafficClassConversational ); |
|
130 |
|
131 reqParams->SetDeliveryOrder( |
|
132 RPacketQoS::EDeliveryOrderNotRequired ); |
|
133 |
|
134 reqParams->SetErroneousSDUDelivery( |
|
135 RPacketQoS::EErroneousSDUNoDetection ); |
|
136 |
|
137 reqParams->SetResidualBitErrorRatio( |
|
138 RPacketQoS::EBERUnspecified ); |
|
139 |
|
140 reqParams->SetSDUErrorRatio( |
|
141 RPacketQoS::ESDUErrorRatioUnspecified ); |
|
142 |
|
143 reqParams->SetTrafficHandlingPriority( |
|
144 RPacketQoS::ETrafficPriorityUnspecified ); |
|
145 |
|
146 // Accept streaming class |
|
147 acpParams->SetTrafficClass( |
|
148 RPacketQoS::ETrafficClassStreaming ); |
|
149 |
|
150 reqParams->SetTransferDelay( KTransferDelay ); |
|
151 reqParams->SetMaxSduSize( KMaxSduSize ); |
|
152 reqParams->SetMaxBitrateUplink( KMaxBitrate ); |
|
153 reqParams->SetMaxBitrateDownlink( KMaxBitrate ); |
|
154 reqParams->SetGuaBitrateUplink( KMaxGuaBitrate ); |
|
155 reqParams->SetGuaBitrateDownlink( KMaxGuaBitrate ); |
|
156 |
|
157 // Open the subconnection |
|
158 User::LeaveIfError( iSubConnection.Open( *iSocketServ, |
|
159 RSubConnection::ECreateNew, *iConnection ) ); |
|
160 |
|
161 // Set QoS properties of the subconnection |
|
162 User::LeaveIfError( iSubConnection.SetParameters( subConparams ) ); |
|
163 |
|
164 acpParams = NULL; |
|
165 reqParams = NULL; |
|
166 family = NULL; |
|
167 CleanupStack::PopAndDestroy(); // subConparams |
|
168 |
|
169 |
|
170 // Start the socket adding process to the subconnections |
|
171 CMccQosSocketHandler* sockHandler = CMccQosSocketHandler::NewLC( iObserver, |
|
172 iSubConnection, *iSocket ); |
|
173 |
|
174 // Start the eventmonitoring of the subconnection. |
|
175 CMccQosEventMonitor* evHandler = CMccQosEventMonitor::NewLC( iObserver, |
|
176 iSubConnection ); |
|
177 |
|
178 iEventMonitor = evHandler; |
|
179 CleanupStack::Pop( evHandler ); |
|
180 evHandler = NULL; |
|
181 |
|
182 iQosSocketHandler = sockHandler; |
|
183 CleanupStack::Pop( sockHandler ); |
|
184 sockHandler = NULL; |
|
185 |
|
186 __QOSLOG("CMccQosHandler::DoEnableQoSL exit") |
|
187 } |
|
188 |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CMccQosHandler::DisableQoSL |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 void CMccQosHandler::DisableQoS() |
|
195 { |
|
196 __QOSLOG( "CMccQosHandler::DisableQoS" ) |
|
197 |
|
198 HandleSocketHandlerDeletion(); |
|
199 delete iEventMonitor; |
|
200 iSubConnection.Close(); |
|
201 iQosSocketHandler = NULL; |
|
202 iEventMonitor = NULL; |
|
203 iConnection = NULL; |
|
204 iSocketServ = NULL; |
|
205 iSocket = NULL; |
|
206 } |
|
207 |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // CMccQosHandler::SetSubConnectionParams |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 void CMccQosHandler::SetSubConnectionParams( RConnection& aConnection, |
|
214 RSocketServ& aSocketServ, RSocket& aSocket ) |
|
215 { |
|
216 __QOSLOG( "CMccQosHandler::SetSubConnectionParams" ) |
|
217 |
|
218 iConnection = &aConnection; |
|
219 iSocketServ = &aSocketServ; |
|
220 iSocket = &aSocket; |
|
221 } |
|
222 |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CMccQosHandler::QoSEnabled |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 TBool CMccQosHandler::QoSEnabled() const |
|
229 { |
|
230 if ( iQosSocketHandler && iEventMonitor ) |
|
231 { |
|
232 __QOSLOG( "CMccQosHandler::QoSEnabled ETrue" ) |
|
233 |
|
234 return ETrue; |
|
235 } |
|
236 else |
|
237 { |
|
238 __QOSLOG( "CMccQosHandler::QoSEnabled EFalse" ) |
|
239 |
|
240 return EFalse; |
|
241 } |
|
242 } |
|
243 |
|
244 |
|
245 // --------------------------------------------------------------------------- |
|
246 // CMccQosHandler::HandleSocketHandlerDeletion |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 void CMccQosHandler::HandleSocketHandlerDeletion() |
|
250 { |
|
251 __QOSLOG("CMccQosHandler::HandleSocketHandlerDeletion" ) |
|
252 |
|
253 if ( iQosSocketHandler && iQosSocketHandler->IsActive() ) |
|
254 { |
|
255 iQosSocketHandler->AsyncDeleteNeeded( ETrue ); |
|
256 } |
|
257 else |
|
258 { |
|
259 delete iQosSocketHandler; |
|
260 iQosSocketHandler = NULL; |
|
261 } |
|
262 } |