|
1 // Copyright (c) 2001-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 |
|
17 #include "mSLOGGER.H" |
|
18 #include <pcktcs.h> |
|
19 #include "gprsqos.h" |
|
20 #include "ATIO.H" |
|
21 #include "NOTIFY.H" |
|
22 #include "ATSTD.H" |
|
23 #include "atgprsqosprofile.h" |
|
24 |
|
25 /** |
|
26 * @file |
|
27 * This file implements the CGprsQoS class. Used to implement the RPacketQoS API. |
|
28 */ |
|
29 |
|
30 |
|
31 CGprsQoS* CGprsQoS::NewL(CGprsContext* aParent, TInt aCid, CATIO* aIo, CATInit* aInit, CPhoneGlobals* aPhoneGlobals, TDes& aName) |
|
32 /** |
|
33 * Standard 2 phase constructor. |
|
34 * |
|
35 * @param aTelObject pointer to parent. |
|
36 * @param aIo pointer to communication object. |
|
37 * @param aInit pointer to AT phone init object. |
|
38 * @param aPhoneGlobals pointer to phone global wide states. |
|
39 */ |
|
40 { |
|
41 CGprsQoS* gprs=new(ELeave) CGprsQoS(aParent, aCid, aIo, aInit, aPhoneGlobals); |
|
42 CleanupStack::PushL(gprs); |
|
43 gprs->ConstructL(aName); |
|
44 CleanupStack::Pop(); |
|
45 return gprs; |
|
46 } |
|
47 |
|
48 |
|
49 CGprsQoS::CGprsQoS(CGprsContext* aParent, TInt aCid, CATIO* aIo, CATInit* aInit, CPhoneGlobals* aPhoneGlobals) |
|
50 : CSubSessionExtBase(), |
|
51 iCid(aCid), |
|
52 iParent(aParent), |
|
53 iIo(aIo), |
|
54 iInit(aInit), |
|
55 iPhoneGlobals(aPhoneGlobals) |
|
56 /** |
|
57 * Constructor |
|
58 * |
|
59 * @param aParent pointer to parent. |
|
60 * @param aIo pointer to communication object. |
|
61 * @param aInit pointer to AT phone init object. |
|
62 * @param aPhoneGlobals pointer to phone global wide states. |
|
63 */ |
|
64 { |
|
65 } |
|
66 |
|
67 |
|
68 void CGprsQoS::ConstructL(TDes& aName) |
|
69 /** |
|
70 * This function creates all objects on the heap that can leave. |
|
71 * @param aName Name of QoS profile |
|
72 */ |
|
73 { |
|
74 LOGTEXT(_L8("CGprsQoS: Entered ConstructL")); |
|
75 iQoSName.Copy(aName); |
|
76 iATGprsSetProfile = CATGprsSetProfile::NewL(iCid, iIo, this, iInit, iPhoneGlobals); |
|
77 iATGprsGetProfile = CATGprsGetProfile::NewL(iCid, iIo, this, iInit, iPhoneGlobals); |
|
78 // iATGprsGetCapsProfile= CATGprsGetCapsProfile::NewL(iCid, iIo, this, iInit, iPhoneGlobals); |
|
79 } |
|
80 //TODO fix above! |
|
81 |
|
82 CGprsQoS::~CGprsQoS() |
|
83 /** |
|
84 * Destructor |
|
85 */ |
|
86 { |
|
87 LOGTEXT(_L8("CGprsQoS: Entered destructor")); |
|
88 iParent->RemoveQoSProfileIfFound(this); |
|
89 iPhoneGlobals->iNotificationStore->RemoveClientFromLastEvents(this); |
|
90 delete iATGprsSetProfile; |
|
91 delete iATGprsGetProfile; |
|
92 } |
|
93 |
|
94 |
|
95 void CGprsQoS::Init() |
|
96 /** |
|
97 * This is not used. Init is done from the CPhone class. |
|
98 */ |
|
99 { |
|
100 LOGTEXT(_L8("CGprsQoS: init()")); |
|
101 } |
|
102 |
|
103 |
|
104 CTelObject* CGprsQoS::OpenNewObjectByNameL(const TDesC& /*aName*/) |
|
105 /** |
|
106 * This function is not used. |
|
107 */ |
|
108 { |
|
109 LOGTEXT(_L8("CGprsQoS::OpenNewObjectByNameL called")); |
|
110 User::Leave(KErrNotSupported); |
|
111 return NULL; |
|
112 } |
|
113 |
|
114 |
|
115 CTelObject* CGprsQoS::OpenNewObjectL(TDes& /*aNewName*/) |
|
116 /** |
|
117 * This function is not used. |
|
118 */ |
|
119 { |
|
120 User::Leave(KErrNotSupported); |
|
121 return NULL; |
|
122 } |
|
123 |
|
124 |
|
125 CTelObject::TReqMode CGprsQoS::ReqModeL(const TInt aIpc) |
|
126 /** |
|
127 * This function is called from the framework and checks the flow control for a IPC call. |
|
128 * @param aIpc IPC call from client. |
|
129 */ |
|
130 { |
|
131 CTelObject::TReqMode ret=0; |
|
132 switch (aIpc) |
|
133 { |
|
134 case EPacketQoSGetProfileParams: |
|
135 case EPacketQoSSetProfileParams: |
|
136 ret = KReqModeFlowControlObeyed; |
|
137 break; |
|
138 |
|
139 case EPacketQoSGetProfileCaps: |
|
140 ret = KReqModeMultipleCompletionEnabled; |
|
141 break; |
|
142 |
|
143 case EPacketQoSNotifyProfileChanged: |
|
144 ret = KReqModeMultipleCompletionEnabled | KReqModeRePostImmediately; |
|
145 break; |
|
146 |
|
147 default: |
|
148 User::Leave(KErrNotSupported); |
|
149 break; |
|
150 } |
|
151 |
|
152 // Check if the data port is currently loaned. If it is and the requested IPC |
|
153 // is flow controlled then block Etel calling the IPC by leaving with KErrInUse |
|
154 if((ret&KReqModeFlowControlObeyed) && iPhoneGlobals->iPhoneStatus.iDataPortLoaned) |
|
155 { |
|
156 LOGTEXT2(_L8("ReqModeL Leaving with KErrInUse as data port is loaned (aIpc=%d)"),aIpc); |
|
157 User::Leave(KErrInUse); |
|
158 } |
|
159 |
|
160 return ret; |
|
161 } |
|
162 |
|
163 |
|
164 TInt CGprsQoS::RegisterNotification(const TInt aIpc) |
|
165 /** |
|
166 * This function is called from the framework. |
|
167 * @param aIpc IPC call from client. |
|
168 */ |
|
169 { |
|
170 switch (aIpc) |
|
171 { |
|
172 case EPacketQoSNotifyProfileChanged: |
|
173 LOGTEXT(_L8("CGprsQoS: RegisterNotification - Config Changed")); |
|
174 return KErrNone; |
|
175 |
|
176 default: |
|
177 // Unknown or invalid IPC |
|
178 LOGTEXT(_L8("CGprsQoS: Register error, unknown IPC")); |
|
179 return KErrNotSupported; |
|
180 } |
|
181 } |
|
182 |
|
183 |
|
184 TInt CGprsQoS::DeregisterNotification(const TInt aIpc) |
|
185 /** |
|
186 * This function is called when the there is no client listening to a notification anymore. |
|
187 * |
|
188 * @param aIpc IPC call from client. |
|
189 */ |
|
190 { |
|
191 switch (aIpc) |
|
192 { |
|
193 case EPacketQoSNotifyProfileChanged: |
|
194 LOGTEXT(_L8("CGprsQoS: DeregisterNotification - Config Changed")); |
|
195 return KErrNone; |
|
196 |
|
197 default: |
|
198 // Unknown or invalid IPC |
|
199 LOGTEXT(_L8("CGprsQoS: Deregister error, unknown IPC")); |
|
200 return KErrNotSupported; |
|
201 } |
|
202 } |
|
203 |
|
204 |
|
205 TInt CGprsQoS::NumberOfSlotsL(const TInt aIpc) |
|
206 { |
|
207 TInt numberOfSlots=0; |
|
208 switch (aIpc) |
|
209 { |
|
210 case EPacketQoSNotifyProfileChanged: |
|
211 LOGTEXT(_L8("CGprsQoS: Registered with 5 slots")); |
|
212 numberOfSlots=5; |
|
213 break; |
|
214 |
|
215 default: |
|
216 // Unknown or invalid IPC |
|
217 LOGTEXT(_L8("CGprsQoS: Number of Slots error, unknown IPC")); |
|
218 User::Leave(KErrNotSupported); |
|
219 break; |
|
220 } |
|
221 return numberOfSlots; |
|
222 |
|
223 } |
|
224 |
|
225 |
|
226 TInt CGprsQoS::ExtFunc(const TTsyReqHandle aTsyReqHandle,const TInt aIpc,const TDataPackage& aPackage) |
|
227 /** |
|
228 * This function is called from the framework. |
|
229 * @param aTsyReqHandle handle to client. |
|
230 * @param aIpc IPC call from client. |
|
231 * @param aPackage agruments with the IPC call. |
|
232 */ |
|
233 { |
|
234 |
|
235 if(ShouldNotProcessIpcCall(aIpc)) |
|
236 {// If the context is in state deleted these calls should not be processed. |
|
237 |
|
238 ReqCompleted(aTsyReqHandle, KErrGeneral); |
|
239 return KErrNone; |
|
240 } |
|
241 if(ShouldNotProcessIpcCallWhenComportIsLoaned(aIpc)) |
|
242 {// If the comport is loaned out ipcs that generate an AT-command shall be returned with KErrAccesssDenied |
|
243 ReqCompleted(aTsyReqHandle, KErrAccessDenied); |
|
244 return KErrNone; |
|
245 } |
|
246 |
|
247 switch (aIpc) |
|
248 { |
|
249 case EPacketQoSSetProfileParams: |
|
250 return SetProfile(aTsyReqHandle, aPackage.Des1n()); |
|
251 |
|
252 case EPacketQoSGetProfileParams: |
|
253 return GetProfile(aTsyReqHandle, aPackage.Des1n()); |
|
254 |
|
255 case EPacketQoSGetProfileCaps: |
|
256 return GetProfileCaps(aTsyReqHandle, aPackage.Des1n()); |
|
257 |
|
258 case EPacketQoSNotifyProfileChanged: |
|
259 return NotifyProfileChanged(aTsyReqHandle, aPackage.Des1n()); |
|
260 |
|
261 default: |
|
262 return KErrNotSupported; |
|
263 } |
|
264 } |
|
265 |
|
266 |
|
267 TDes* CGprsQoS::GetProfileName() |
|
268 /** |
|
269 * This function returns the context name. |
|
270 * |
|
271 */ |
|
272 { |
|
273 return &iQoSName; |
|
274 } |
|
275 |
|
276 |
|
277 RPacketQoS::TQoSGPRSRequested* CGprsQoS::GetReqQoSProfile() |
|
278 /** |
|
279 * This function returns the requested QoS profile |
|
280 * |
|
281 */ |
|
282 { |
|
283 return &iQoSRequested; |
|
284 } |
|
285 |
|
286 |
|
287 void CGprsQoS::SetReqQoSProfile(const RPacketQoS::TQoSGPRSRequested* aQoSRequested) |
|
288 /** |
|
289 * This function sets the context configuration. |
|
290 * @param iContextConfigV10 Configuration to set. |
|
291 */ |
|
292 |
|
293 { |
|
294 iQoSRequested = *aQoSRequested; |
|
295 } |
|
296 |
|
297 void CGprsQoS::SetNegQoSProfile(const RPacketQoS::TQoSGPRSNegotiated* aQoSNegotiated) |
|
298 /** |
|
299 * This function sets the context configuration. |
|
300 * @param iContextConfigV10 Configuration to set. |
|
301 */ |
|
302 |
|
303 { |
|
304 iQoSNegotiated = *aQoSNegotiated; |
|
305 } |
|
306 |
|
307 TInt CGprsQoS::CancelService(const TInt aIpc, const TTsyReqHandle aTsyReqHandle) |
|
308 /** |
|
309 * This function is called from the framework and cancels a outstanding request. |
|
310 * @param aIpc The IPC to cancel. |
|
311 * @param aTsyReqHandle the client handle to cancel. |
|
312 */ |
|
313 { |
|
314 LOGTEXT(_L8("CGprsATContextTsy: - CancelService called")); |
|
315 switch (aIpc) |
|
316 { |
|
317 case EPacketQoSSetProfileParams: |
|
318 return SetProfileCancel(aTsyReqHandle); |
|
319 |
|
320 case EPacketQoSGetProfileParams: |
|
321 return GetProfileCancel(aTsyReqHandle); |
|
322 |
|
323 case EPacketQoSGetProfileCaps: |
|
324 return GetProfileCapsCancel(aTsyReqHandle); |
|
325 |
|
326 case EPacketQoSNotifyProfileChanged: |
|
327 return NotifyProfileChangedCancel(aTsyReqHandle); |
|
328 |
|
329 default: |
|
330 return KErrNotSupported; |
|
331 } |
|
332 } |
|
333 |
|
334 |
|
335 |
|
336 TInt CGprsQoS::SetProfile(const TTsyReqHandle aTsyReqHandle,const TDesC8* aReqProfile) |
|
337 /** |
|
338 * Called from a client via ExtFunc. |
|
339 * This function will start a chain of AT commands to the phone(AT+CGQMIN and AT+CGQREQ). |
|
340 * |
|
341 * @param aTsyReqHandle request handle that is completed when done with request. |
|
342 * @param aConfig Pointer to a RPacketContext::TContextConfigPckg. |
|
343 */ |
|
344 { |
|
345 LOGTEXT(_L8("CGprsQoS::SetProfile called")); |
|
346 |
|
347 // check the client's passed me a GPRS pckg & not a CDMA package |
|
348 TPacketDataConfigBase& aCheck = (*(TPckg<TPacketDataConfigBase>*)aReqProfile)(); |
|
349 if (aCheck.ExtensionId() == TPacketDataConfigBase::KConfigGPRS) |
|
350 iATGprsSetProfile->ExecuteCommand(aTsyReqHandle, (TAny*)aReqProfile); |
|
351 else |
|
352 ReqCompleted(aTsyReqHandle, KErrNotSupported); // I don't do CDMA |
|
353 return KErrNone; |
|
354 } |
|
355 |
|
356 |
|
357 TInt CGprsQoS::SetProfileCancel(const TTsyReqHandle aTsyReqHandle) |
|
358 /** |
|
359 * Cancels a outstanding request. Called via CancelService. |
|
360 * |
|
361 * @param aTsyReqHandle The handle to cancel |
|
362 */ |
|
363 { |
|
364 LOGTEXT(_L8("CGprsQoS::SetProfileCancel called")); |
|
365 iATGprsSetProfile->CancelCommand(aTsyReqHandle); |
|
366 return KErrNone; |
|
367 } |
|
368 |
|
369 |
|
370 TInt CGprsQoS::GetProfile(const TTsyReqHandle aTsyReqHandle, TDes8* aNegProfile) |
|
371 /** |
|
372 * Called from a client via ExtFunc. |
|
373 * This function will start a chain of AT commands to the phone(AT+CGQREQ?, AT+CGQMIN?) |
|
374 * and query the settings in the phone. |
|
375 * |
|
376 * @param aTsyReqHandle request handle that is completed when done with request. |
|
377 * @param aConfig Pointer to a RPacketContext::TContextConfigPckg. |
|
378 */ |
|
379 { |
|
380 LOGTEXT(_L8("CGprsQoS::GetProfile called")); |
|
381 |
|
382 // check the client's passed me a GPRS pckg & not a CDMA package |
|
383 TPacketDataConfigBase& aCheck = (*(TPckg<TPacketDataConfigBase>*)aNegProfile)(); |
|
384 if (aCheck.ExtensionId() == TPacketDataConfigBase::KConfigGPRS) |
|
385 iATGprsGetProfile->ExecuteCommand(aTsyReqHandle, (TAny*)aNegProfile); |
|
386 else |
|
387 ReqCompleted(aTsyReqHandle, KErrNotSupported); // I don't do CDMA |
|
388 return KErrNone; |
|
389 } |
|
390 |
|
391 |
|
392 TInt CGprsQoS::GetProfileCancel(const TTsyReqHandle aTsyReqHandle) |
|
393 /** |
|
394 * Cancels a outstanding request. Called via CancelService. |
|
395 * |
|
396 * @param aTsyReqHandle The handle to cancel |
|
397 */ |
|
398 { |
|
399 LOGTEXT(_L8("CGprsQoS::GetProfileCancel called")); |
|
400 iATGprsGetProfile->CancelCommand(aTsyReqHandle); |
|
401 return KErrNone; |
|
402 } |
|
403 |
|
404 |
|
405 TInt CGprsQoS::NotifyProfileChanged(const TTsyReqHandle aTsyReqHandle, TDes8* aNegConfig) |
|
406 /** |
|
407 * Called from a client via ExtFunc. |
|
408 * This function will complete when EPacketQoSProfileChange event is triggered. |
|
409 * |
|
410 * @param aTsyReqHandle request handle that is completed. |
|
411 * @param aConfig Pointer to a RPacketContext::TContextConfigPckg |
|
412 */ |
|
413 { |
|
414 LOGTEXT(_L8("CGprsQoS::NotifyProfileChanged called")); |
|
415 iPhoneGlobals->iNotificationStore->RegisterNotification(EPacketQoSProfileChange, aTsyReqHandle, this, aNegConfig); |
|
416 return KErrNone; |
|
417 } |
|
418 |
|
419 |
|
420 TInt CGprsQoS::NotifyProfileChangedCancel(const TTsyReqHandle aTsyReqHandle) |
|
421 /** |
|
422 * Cancels a outstanding request. Called via CancelService. |
|
423 * |
|
424 * @param aTsyReqHandle The handle to cancel |
|
425 */ |
|
426 { |
|
427 LOGTEXT(_L8("CGprsQoS::NotifyProfileChangedCancel called")); |
|
428 iPhoneGlobals->iNotificationStore->RemoveNotification(aTsyReqHandle); |
|
429 return KErrNone; |
|
430 } |
|
431 |
|
432 TInt CGprsQoS::GetProfileCaps(const TTsyReqHandle aTsyReqHandle, TDes8* aCapsProfile) |
|
433 /** |
|
434 * @param aTsyReqHandle request handle that is completed. |
|
435 */ |
|
436 { |
|
437 LOGTEXT(_L8("CGprsQoS::GetProfileCaps called")); |
|
438 |
|
439 // check that the client has passed us a GPRS package & not a CDMA package |
|
440 TPacketDataConfigBase& aCheck = (*(TPckg<TPacketDataConfigBase>*)aCapsProfile)(); |
|
441 if (aCheck.ExtensionId() == TPacketDataConfigBase::KConfigGPRS) |
|
442 { |
|
443 TPckg<RPacketQoS::TQoSCapsGPRS>* qosCapsGPRSPckg = (TPckg<RPacketQoS::TQoSCapsGPRS>*)aCapsProfile; |
|
444 RPacketQoS::TQoSCapsGPRS& qosCaps = (*qosCapsGPRSPckg)(); |
|
445 |
|
446 qosCaps.iDelay = iPhoneGlobals->iStaticQoSCaps.iDelay; |
|
447 qosCaps.iMean = iPhoneGlobals->iStaticQoSCaps.iMean; |
|
448 qosCaps.iPeak = iPhoneGlobals->iStaticQoSCaps.iPeak; |
|
449 qosCaps.iPrecedence = iPhoneGlobals->iStaticQoSCaps.iPrecedence; |
|
450 qosCaps.iReliability = iPhoneGlobals->iStaticQoSCaps.iReliability; |
|
451 |
|
452 ReqCompleted(aTsyReqHandle, KErrNone); |
|
453 } |
|
454 else |
|
455 ReqCompleted(aTsyReqHandle,KErrNotSupported); // CDMA not supported here |
|
456 return KErrNone; |
|
457 } |
|
458 |
|
459 TInt CGprsQoS::GetProfileCapsCancel(const TTsyReqHandle aTsyReqHandle) |
|
460 /** |
|
461 * @param aTsyReqHandle request handle that is completed. |
|
462 */ |
|
463 { |
|
464 LOGTEXT(_L8("CGprsQoS::GetProfileCapsCancel called")); |
|
465 ReqCompleted(aTsyReqHandle,KErrNotSupported); |
|
466 return KErrNone; |
|
467 } |
|
468 |
|
469 TBool CGprsQoS::ShouldNotProcessIpcCall(TInt aIpc) |
|
470 /** |
|
471 * This function indicates if a IPC should not be handled. |
|
472 * @param aIPC A IPC call number. |
|
473 */ |
|
474 { |
|
475 switch(aIpc) |
|
476 { |
|
477 case EPacketContextSetConfig: |
|
478 case EPacketContextGetConfig: |
|
479 case EPacketContextNotifyConfigChanged: |
|
480 case EPacketContextActivate: |
|
481 case EPacketContextDeactivate: |
|
482 case EPacketContextDelete: |
|
483 case EPacketContextLoanCommPort: |
|
484 case EPacketContextRecoverCommPort: |
|
485 LOGTEXT(_L8("CGprsQoS::ShouldNotProcessIpcCall, context deleted. This ipc is not legal")); |
|
486 return ETrue; |
|
487 default: |
|
488 return EFalse; |
|
489 } |
|
490 } |
|
491 |
|
492 |
|
493 TBool CGprsQoS::ShouldNotProcessIpcCallWhenComportIsLoaned(TInt aIpc) |
|
494 /** |
|
495 * This function indicates if a IPC should not be handled when comport is loaned. |
|
496 * @param aIPC A IPC call number. |
|
497 */ |
|
498 { |
|
499 if(iPhoneGlobals->iPhoneStatus.iDataPortLoaned == EFalse) |
|
500 return EFalse; |
|
501 switch(aIpc) |
|
502 { |
|
503 case EPacketContextSetConfig: |
|
504 case EPacketContextGetConfig: |
|
505 case EPacketContextNotifyConfigChanged: |
|
506 case EPacketContextActivate: |
|
507 case EPacketContextDeactivate: |
|
508 case EPacketContextDelete: |
|
509 case EPacketContextLoanCommPort: |
|
510 LOGTEXT(_L8("CGprsQoS::ShouldNotProcessIpcCallWhenComportIsLoaned, comport loaned out. This ipc is not legal")); |
|
511 return ETrue; |
|
512 default: |
|
513 return EFalse; |
|
514 |
|
515 } |
|
516 } |