author | ivan.fildichev@opencode.com |
Tue, 19 Oct 2010 18:11:09 +0300 | |
branch | opencode |
changeset 81 | 7f379d8ed02d |
parent 77 | 930a53cdc2d3 |
child 85 | 96b4f933d69a |
permissions | -rw-r--r-- |
24 | 1 |
// Copyright (c) 1997-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 |
#include "ET_SSTD.H" |
|
17 |
#include "ETBUFFER.H" |
|
18 |
#include <f32file.h> |
|
19 |
#include "etsvr_slots.h" |
|
20 |
#include "et_phone_util.h" |
|
21 |
#include "et_patchdata.h" |
|
22 |
// |
|
23 |
// |
|
24 |
// CFaxBase |
|
25 |
// |
|
26 |
// |
|
27 |
EXPORT_C CFaxBase::CFaxBase() |
|
28 |
// |
|
29 |
// C'Tor |
|
30 |
// |
|
31 |
{ |
|
32 |
__DECLARE_NAME(_S("CFaxBase")); |
|
33 |
} |
|
34 |
||
35 |
EXPORT_C CFaxBase::~CFaxBase() |
|
36 |
// |
|
37 |
// D'Tor |
|
38 |
// |
|
39 |
{} |
|
40 |
||
41 |
EXPORT_C CTelObject* CFaxBase::OpenNewObjectByNameL(const TDesC&) |
|
42 |
// |
|
43 |
// Always return NULL not allow CFaxBase Tsy object to create new object |
|
44 |
// |
|
45 |
{ |
|
46 |
User::Leave(KErrNotSupported); |
|
47 |
return NULL; |
|
48 |
} |
|
49 |
||
50 |
EXPORT_C CTelObject* CFaxBase::OpenNewObjectL(TDes&) |
|
51 |
// |
|
52 |
// Always return NULL not allow CFaxBase Tsy object to create new object |
|
53 |
// |
|
54 |
{ |
|
55 |
User::Leave(KErrNotSupported); |
|
56 |
return NULL; |
|
57 |
} |
|
58 |
||
59 |
EXPORT_C void CFaxBase::OpenPostProcessing(CTelSession*,const TInt) |
|
60 |
// |
|
61 |
// Perform post-processing after object has been added to session's CObjectIx. |
|
62 |
// |
|
63 |
{} |
|
64 |
||
65 |
EXPORT_C void CFaxBase::CloseSubSessionPreProcessing(CTelSession* aSession,const TInt aSubSessionHandle) |
|
66 |
{ |
|
67 |
CreateDummySession(aSession,aSubSessionHandle); |
|
68 |
FlushReqs(aSession,aSubSessionHandle); |
|
69 |
} |
|
70 |
||
71 |
EXPORT_C TInt CFaxBase::CancelService(const TInt aIpc,const TTsyReqHandle /*aTsyReqHandle*/) |
|
72 |
// |
|
73 |
// Cancel Service for Fax |
|
74 |
// |
|
75 |
{ |
|
76 |
__ASSERT_ALWAYS((aIpc==EEtelFaxRead) || |
|
77 |
(aIpc==EEtelFaxWrite) || |
|
78 |
(aIpc==EEtelFaxWaitForEndOfPage) |
|
79 |
,Fault(EEtelFaultInvalidIpcForCancel)); |
|
80 |
||
81 |
switch (aIpc) |
|
82 |
{ |
|
83 |
// this is a special case for Fax session - |
|
84 |
// count already increment before calling susession |
|
85 |
// for those reqs below - server do expect Tsy to call ReqCompleted() |
|
86 |
// so the count should be decrement again ! |
|
87 |
case EEtelFaxRead: |
|
88 |
case EEtelFaxWrite: |
|
89 |
case EEtelFaxWaitForEndOfPage: |
|
90 |
return KErrNone; |
|
91 |
// There is no individual cancel associated with these requests |
|
92 |
default: |
|
93 |
return KErrGeneral; |
|
94 |
} |
|
95 |
} |
|
96 |
||
97 |
||
98 |
EXPORT_C TInt CFaxBase::Service(const RMessage2& /*aMessage*/,CReqEntry* aReqEntry) |
|
99 |
// |
|
100 |
// The ServiceL functionality for the fax |
|
101 |
// |
|
102 |
{ |
|
103 |
__ASSERT_ALWAYS(aReqEntry!=NULL,Fault(EEtelFaultCallTsyServiceWithoutReqPackage)); |
|
104 |
aReqEntry->iPlacedRequest=ETrue; |
|
105 |
TTsyReqHandle tsyReqHandle=aReqEntry->iTsyReqHandle; |
|
106 |
TDes8* des1 = BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
107 |
||
108 |
switch (aReqEntry->iFunction) |
|
109 |
{ |
|
110 |
case EEtelFaxRead: |
|
111 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
112 |
return Read(tsyReqHandle,des1); |
|
113 |
case EEtelFaxWrite: |
|
114 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
115 |
return Write(tsyReqHandle,des1); |
|
116 |
case EEtelFaxWaitForEndOfPage: |
|
117 |
return WaitForEndOfPage(tsyReqHandle); |
|
118 |
case EEtelFaxTerminateFaxSession: |
|
119 |
return TerminateFaxSession(tsyReqHandle); |
|
120 |
default: |
|
121 |
return KErrNotSupported; |
|
122 |
} |
|
123 |
} |
|
124 |
||
125 |
||
126 |
EXPORT_C void CFaxBase::Init() |
|
127 |
{} |
|
128 |
||
129 |
EXPORT_C CTelObject::TReqMode CFaxBase::ReqModeL(const TInt aIpc) |
|
130 |
// |
|
131 |
// Fax Request Inquiry Functions |
|
132 |
// |
|
133 |
{ |
|
134 |
CTelObject::TReqMode mode=0; |
|
135 |
switch (aIpc) |
|
136 |
{ |
|
137 |
case EEtelFaxTerminateFaxSession: |
|
138 |
// if two clients call this, only want the first to be acted upon |
|
139 |
mode=KReqModeMultipleCompletionEnabled; |
|
140 |
break; |
|
141 |
case EEtelFaxRead: |
|
142 |
case EEtelFaxWrite: |
|
143 |
case EEtelFaxWaitForEndOfPage: |
|
144 |
mode=KReqModeFlowControlObeyed; |
|
145 |
break; |
|
146 |
default: |
|
147 |
User::Leave(KErrNotSupported); |
|
148 |
break; |
|
149 |
} |
|
150 |
return mode; |
|
151 |
} |
|
152 |
||
153 |
EXPORT_C TInt CFaxBase::NumberOfSlotsL(const TInt /*aIpc*/) |
|
154 |
{ |
|
155 |
User::Leave(KErrNotSupported); // there are no repost immediately functions for fax |
|
156 |
return KSlotNumbersDefault; |
|
157 |
} |
|
158 |
||
159 |
// |
|
160 |
// |
|
161 |
// CCallBase |
|
162 |
// |
|
163 |
// |
|
164 |
EXPORT_C CCallBase::CCallBase() |
|
165 |
// |
|
166 |
// C'Tor |
|
167 |
// |
|
168 |
:iOwnershipStatus(EOwnedUnowned) |
|
169 |
,iOwnerSession(NULL) |
|
170 |
,iOwnerSubSessionHandle(0) |
|
171 |
,iLoanDataPort(EFalse) |
|
172 |
{ |
|
173 |
__DECLARE_NAME(_S("CCallBase")); |
|
174 |
} |
|
175 |
||
176 |
EXPORT_C CCallBase::~CCallBase() |
|
177 |
// |
|
178 |
// D'Tor |
|
179 |
// Attual closing of the owner is done in CSubSessionBase destructor |
|
180 |
// This is for all object inherit fron CSubSessionBase |
|
181 |
// |
|
182 |
{ |
|
183 |
LOGTEXT("~CCallBase"); |
|
184 |
} |
|
185 |
||
186 |
EXPORT_C TInt CCallBase::CancelService(const TInt aIpc,const TTsyReqHandle aTsyReqHandle) |
|
187 |
// |
|
188 |
// Cancel Service for Call |
|
189 |
// |
|
190 |
{ |
|
191 |
__ASSERT_ALWAYS((aIpc==EEtelCallNotifyHookChange) || |
|
192 |
(aIpc==EEtelCallNotifyStatusChange) || |
|
193 |
(aIpc==EEtelCallNotifyDurationChange) || |
|
194 |
(aIpc==EEtelCallCapsChangeNotification) || |
|
195 |
(aIpc==EEtelCallAcquireOwnership) || |
|
196 |
(aIpc==EEtelCallDial) || |
|
197 |
(aIpc==EEtelCallAnswer) || |
|
198 |
(aIpc==EEtelCallHangUp) || |
|
199 |
(aIpc==EEtelCallConnect)|| |
|
200 |
(aIpc==EEtelCallLoanDataPort) |
|
201 |
,Fault(EEtelFaultInvalidIpcForCancel)); |
|
202 |
switch (aIpc) |
|
203 |
{ |
|
204 |
case EEtelCallCapsChangeNotification: |
|
205 |
return NotifyCapsChangeCancel(aTsyReqHandle); |
|
206 |
case EEtelCallNotifyHookChange: |
|
207 |
return NotifyHookChangeCancel(aTsyReqHandle); |
|
208 |
case EEtelCallNotifyStatusChange: |
|
209 |
return NotifyStatusChangeCancel(aTsyReqHandle); |
|
210 |
case EEtelCallNotifyDurationChange: |
|
211 |
return NotifyDurationChangeCancel(aTsyReqHandle); |
|
212 |
case EEtelCallAcquireOwnership: |
|
213 |
return AcquireOwnershipCancel(aTsyReqHandle); |
|
214 |
case EEtelCallDial: |
|
215 |
return DialCancel(aTsyReqHandle); |
|
216 |
case EEtelCallConnect: |
|
217 |
return ConnectCancel(aTsyReqHandle); |
|
218 |
case EEtelCallAnswer: |
|
219 |
return AnswerIncomingCallCancel(aTsyReqHandle); |
|
220 |
case EEtelCallHangUp: |
|
221 |
return HangUpCancel(aTsyReqHandle); |
|
222 |
case EEtelCallLoanDataPort: |
|
223 |
return LoanDataPortCancel(aTsyReqHandle); |
|
224 |
default: |
|
225 |
return KErrGeneral; // should never reached here |
|
226 |
} |
|
227 |
} |
|
228 |
||
229 |
EXPORT_C void CCallBase::Init() |
|
230 |
{} |
|
231 |
||
232 |
EXPORT_C CCallBase::TCallOwnership CCallBase::CheckOwnership(const TTsyReqHandle aTsyReqHandle) const |
|
233 |
// |
|
234 |
// Tsy upcall function - return the call ownership status |
|
235 |
// |
|
236 |
{ |
|
237 |
CReqEntry* reqEntry=PhoneOwner()->FindByTsyHandle(aTsyReqHandle); |
|
238 |
__ASSERT_ALWAYS(reqEntry!=NULL,Fault(EEtelFaultNotRecognisedTsyHandle)); |
|
239 |
RCall::TOwnershipStatus owner=CheckOwnershipBySession(reqEntry->iSession,reqEntry->iMessage.Int3()); |
|
240 |
||
241 |
if (owner==RCall::EOwnershipUnowned) |
|
242 |
return EOwnedUnowned; |
|
243 |
||
244 |
if (owner==RCall::EOwnershipOwnedByThisClient) |
|
245 |
return EOwnedTrue; |
|
246 |
||
247 |
if (owner==RCall::EOwnershipThisIsPriorityClient) |
|
248 |
return EOwnedPriorityClient; |
|
249 |
||
250 |
return EOwnedFalse; |
|
251 |
} |
|
252 |
||
253 |
EXPORT_C RCall::TOwnershipStatus CCallBase::CheckOwnershipBySession(CTelSession* aSession,const TInt /*aSubSessionHandle*/) const |
|
254 |
// |
|
255 |
// Return true if the owner |
|
256 |
// |
|
257 |
{ |
|
258 |
if (iOwnershipStatus==EOwnedUnowned) |
|
259 |
return RCall::EOwnershipUnowned; |
|
260 |
||
261 |
if(iOwnershipStatus==EOwnedTrue && iOwnerSession==aSession /*&& iOwnerSubSessionHandle==aSubSessionHandle*/) // ownership is session based! |
|
262 |
return RCall::EOwnershipOwnedByThisClient; |
|
263 |
||
264 |
// Ann changed |
|
265 |
if (iOwnershipStatus==EOwnedTrue && aSession->TelServer()->IsPriorityClient(aSession)) |
|
266 |
return RCall::EOwnershipThisIsPriorityClient; |
|
267 |
// end |
|
268 |
||
269 |
return RCall::EOwnershipOwnedByAnotherClient; |
|
270 |
} |
|
271 |
||
272 |
EXPORT_C TInt CCallBase::SetUnowned() |
|
273 |
// |
|
274 |
// Return Owner ship status |
|
275 |
// |
|
276 |
{ |
|
277 |
iOwnershipStatus=EOwnedUnowned; |
|
278 |
iOwnerSession=NULL; // set to invalid value |
|
279 |
iOwnerSubSessionHandle=0; |
|
280 |
||
281 |
return KErrNone; |
|
282 |
} |
|
283 |
||
284 |
EXPORT_C TInt CCallBase::SetOwnership(const TTsyReqHandle aTsyReqHandle) |
|
285 |
// |
|
286 |
// If owner ship if not own |
|
287 |
// |
|
288 |
{ |
|
289 |
CReqEntry* reqEntry=PhoneOwner()->FindByTsyHandle(aTsyReqHandle); |
|
290 |
__ASSERT_ALWAYS(reqEntry!=NULL,Fault(EEtelFaultNotRecognisedTsyHandle)); |
|
291 |
||
292 |
iOwnershipStatus=EOwnedTrue; |
|
293 |
iOwnerSession=reqEntry->iSession; |
|
294 |
iOwnerSubSessionHandle=reqEntry->iMessage.Int3(); |
|
295 |
return KErrNone; |
|
296 |
} |
|
297 |
||
298 |
EXPORT_C TBool CCallBase::CheckPriorityClient(const TTsyReqHandle aTsyReqHandle) const |
|
299 |
{ |
|
300 |
CReqEntry* reqEntry=PhoneOwner()->FindByTsyHandle(aTsyReqHandle); |
|
301 |
__ASSERT_ALWAYS(reqEntry!=NULL,Fault(EEtelFaultNotRecognisedTsyHandle)); |
|
302 |
||
303 |
return reqEntry->iSession->TelServer()->IsPriorityClient(reqEntry->iSession); |
|
304 |
} |
|
305 |
||
306 |
EXPORT_C CCallBase* CCallBase::ResolveSubSessionHandle(const TTsyReqHandle aTsyReqHandle, |
|
307 |
const TInt aSubSessionHandle) |
|
308 |
// |
|
309 |
// expects the subsession handle of a call, which must have been opened by the same client session |
|
310 |
// which opened this call and called the current request (identified by aTsyReqHandle) |
|
311 |
// |
|
312 |
{ |
|
313 |
CReqEntry* reqEntry=PhoneOwner()->FindByTsyHandle(aTsyReqHandle); |
|
314 |
__ASSERT_ALWAYS(reqEntry!=NULL,Fault(EEtelFaultNotRecognisedTsyHandle)); |
|
315 |
return REINTERPRET_CAST(CCallBase*,reqEntry->iSession->CObjectFromHandle(aSubSessionHandle)); |
|
316 |
} |
|
317 |
||
318 |
EXPORT_C void CCallBase::OpenPostProcessing(CTelSession* ,const TInt) |
|
319 |
// |
|
320 |
// Perform post-processing after object has been added to session's CObjectIx. |
|
321 |
// |
|
322 |
{} |
|
323 |
||
324 |
EXPORT_C void CCallBase::CloseSubSessionPreProcessing(CTelSession* aSession,const TInt aSubSessionHandle) |
|
325 |
// |
|
326 |
// Perform close post-processing before object being close |
|
327 |
// if is owner then set to EUnOwned |
|
328 |
// |
|
329 |
{ |
|
330 |
LOGTEXT("CCallBase::CloseSubSessionPreProcessing() - about to create dummy session"); |
|
331 |
CreateDummySession(aSession,aSubSessionHandle); |
|
332 |
RCall::TOwnershipStatus owner=CheckOwnershipBySession(aSession,aSubSessionHandle); |
|
333 |
if (owner==RCall::EOwnershipOwnedByThisClient) |
|
334 |
{ |
|
335 |
CreateDummySession(aSession,aSubSessionHandle,ETrue); |
|
336 |
if (iLoanDataPort) // data port being on loan by this owner |
|
337 |
RecoverDataPortAndRelinquishOwnership(); // inform tsy about this |
|
338 |
else |
|
339 |
RelinquishOwnership(); |
|
340 |
} |
|
341 |
FlushReqs(aSession,aSubSessionHandle); |
|
342 |
} |
|
343 |
||
344 |
EXPORT_C void CCallBase::RelinquishOwnershipCompleted(const TInt aError) |
|
345 |
// |
|
346 |
// Server called Tsy with RelinquishOwnership() |
|
347 |
// TSY should do a Up call with this function |
|
348 |
// |
|
349 |
{ |
|
350 |
__ASSERT_ALWAYS(aError==KErrNone,Fault(EEtelFaultCanNotRelinquishOwnership)); |
|
351 |
CheckAndDestroyDummySubSession(); |
|
352 |
} |
|
353 |
||
354 |
EXPORT_C void CCallBase::RecoverDataPortAndRelinquishOwnershipCompleted(const TInt aError) |
|
355 |
// |
|
356 |
// Server called Tsy with RecoverDataPortAndRelinquishOwnership() |
|
357 |
// TSY should do a Up call with this function |
|
358 |
// |
|
359 |
{ |
|
360 |
__ASSERT_ALWAYS(aError==KErrNone,Fault(EEtelFaultCanNotRelinquishOwnership)); |
|
361 |
iLoanDataPort=EFalse; |
|
362 |
RelinquishOwnershipCompleted(aError); |
|
363 |
} |
|
364 |
||
365 |
EXPORT_C TInt CCallBase::Service(const RMessage2& aMessage,CReqEntry* aReqEntry) |
|
366 |
// |
|
367 |
// The ServiceL functionality for the call |
|
368 |
// |
|
369 |
{ |
|
370 |
__ASSERT_ALWAYS(aReqEntry!=NULL,Fault(EEtelFaultCallTsyServiceWithoutReqPackage)); |
|
371 |
aReqEntry->iPlacedRequest=ETrue; |
|
372 |
TTsyReqHandle tsyReqHandle=aReqEntry->iTsyReqHandle; |
|
373 |
TDes8* des1 = BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
374 |
TUint8* ptr1=Ptr1(des1); |
|
375 |
switch (aReqEntry->iFunction) |
|
376 |
{ |
|
377 |
||
378 |
// Asynchronous + Cancel |
|
379 |
case EEtelCallCapsChangeNotification: |
|
380 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
381 |
return NotifyCapsChange(tsyReqHandle,REINTERPRET_CAST(RCall::TCaps*,ptr1)); |
|
382 |
case EEtelCallCapsChangeNotificationCancel: |
|
383 |
return NotifyCapsChangeCancel(tsyReqHandle); |
|
384 |
case EEtelCallNotifyHookChange: |
|
385 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
386 |
return NotifyHookChange(tsyReqHandle,REINTERPRET_CAST(RCall::THookStatus*,ptr1)); |
|
387 |
case EEtelCallNotifyHookChangeCancel: |
|
388 |
return NotifyHookChangeCancel(tsyReqHandle); |
|
389 |
||
390 |
case EEtelCallNotifyStatusChange: |
|
391 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
392 |
return NotifyStatusChange(tsyReqHandle,REINTERPRET_CAST(RCall::TStatus*,ptr1)); |
|
393 |
case EEtelCallNotifyStatusChangeCancel: |
|
394 |
return NotifyStatusChangeCancel(tsyReqHandle); |
|
395 |
case EEtelCallNotifyDurationChange: |
|
396 |
return NotifyDurationChange(tsyReqHandle,REINTERPRET_CAST(TTimeIntervalSeconds*,ptr1)); |
|
397 |
case EEtelCallNotifyDurationChangeCancel: |
|
398 |
return NotifyDurationChangeCancel(tsyReqHandle); |
|
399 |
case EEtelCallDial: |
|
400 |
{ |
|
401 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
402 |
TDes* des2 = NULL; |
|
403 |
des2 = BufferDes2u(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
404 |
__ASSERT_ALWAYS(des2!=NULL,Fault(EEtelFaultDes2DoesNotExist)); |
|
405 |
return Dial(tsyReqHandle,des1,des2); |
|
406 |
} |
|
407 |
case EEtelCallDialCancel: |
|
408 |
return DialCancel(tsyReqHandle); |
|
409 |
||
410 |
case EEtelCallConnect: |
|
411 |
return Connect(tsyReqHandle,des1); |
|
412 |
case EEtelCallConnectCancel: |
|
413 |
return ConnectCancel(tsyReqHandle); |
|
414 |
||
415 |
case EEtelCallAnswer: |
|
416 |
return AnswerIncomingCall(tsyReqHandle,des1); |
|
417 |
case EEtelCallAnswerCancel: |
|
418 |
return AnswerIncomingCallCancel(tsyReqHandle); |
|
419 |
||
420 |
case EEtelCallHangUp: |
|
421 |
return HangUp(tsyReqHandle); |
|
422 |
case EEtelCallHangUpCancel: |
|
423 |
return HangUpCancel(tsyReqHandle); |
|
424 |
||
425 |
case EEtelCallAcquireOwnership: |
|
426 |
{ |
|
427 |
if (RCall::EOwnershipOwnedByThisClient== |
|
428 |
CheckOwnershipBySession(aReqEntry->iSession,aMessage.Int3())) |
|
429 |
return KErrEtelAlreadyCallOwner; |
|
430 |
else |
|
431 |
return AcquireOwnership(tsyReqHandle); |
|
432 |
} |
|
433 |
case EEtelCallAcquireOwnershipCancel: |
|
434 |
return AcquireOwnershipCancel(tsyReqHandle); |
|
435 |
||
436 |
// Synchronous |
|
437 |
case EEtelCallGetInfo: |
|
438 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
439 |
return GetInfo(tsyReqHandle,REINTERPRET_CAST(RCall::TCallInfo*,ptr1)); |
|
440 |
case EEtelCallGetStatus: |
|
441 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
442 |
return GetStatus(tsyReqHandle,REINTERPRET_CAST(RCall::TStatus*,ptr1)); |
|
443 |
case EEtelCallGetCaps: |
|
444 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
445 |
return GetCaps(tsyReqHandle,REINTERPRET_CAST(RCall::TCaps*,ptr1)); |
|
446 |
case EEtelCallLoanDataPort: |
|
447 |
{ |
|
448 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
449 |
TInt ret=LoanDataPort(tsyReqHandle,REINTERPRET_CAST(RCall::TCommPort*,ptr1)); |
|
450 |
if (ret==KErrNone) |
|
451 |
iLoanDataPort=ETrue; |
|
452 |
return ret; |
|
453 |
} |
|
454 |
case EEtelCallLoanDataPortCancel: |
|
455 |
return LoanDataPortCancel(tsyReqHandle); |
|
456 |
||
457 |
case EEtelCallRecoverDataPort: |
|
458 |
{ |
|
459 |
TInt ret=RecoverDataPort(tsyReqHandle); |
|
460 |
if (ret==KErrNone) |
|
461 |
iLoanDataPort=EFalse; |
|
462 |
return ret; |
|
463 |
} |
|
464 |
||
465 |
case EEtelCallTransferOwnership: |
|
466 |
return TransferOwnership(tsyReqHandle); |
|
467 |
case EEtelCallGetBearerServiceInfo: |
|
468 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
469 |
return GetBearerServiceInfo(tsyReqHandle,REINTERPRET_CAST(RCall::TBearerService*,ptr1)); |
|
470 |
||
471 |
case EEtelCallGetOwnershipStatus: |
|
472 |
{ |
|
473 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
474 |
||
475 |
RCall::TOwnershipStatus* owner=REINTERPRET_CAST(RCall::TOwnershipStatus*,ptr1); |
|
476 |
*owner=CheckOwnershipBySession(aReqEntry->iSession,aMessage.Int3()); |
|
477 |
ReqCompleted(tsyReqHandle,KErrNone); |
|
478 |
return KErrNone; |
|
479 |
} |
|
480 |
||
481 |
case EEtelCallGetCallParams: |
|
482 |
{ |
|
483 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
484 |
return GetCallParams(tsyReqHandle,des1); |
|
485 |
} |
|
486 |
case EEtelCallGetCallDuration: |
|
487 |
{ |
|
488 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
489 |
return GetCallDuration(tsyReqHandle,REINTERPRET_CAST(TTimeIntervalSeconds*,ptr1)); |
|
490 |
} |
|
491 |
case EEtelCallGetFaxSettings: |
|
492 |
{ |
|
493 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
494 |
return GetFaxSettings(tsyReqHandle,REINTERPRET_CAST(RCall::TFaxSessionSettings*,ptr1)); |
|
495 |
} |
|
496 |
||
497 |
case EEtelCallSetFaxSettings: |
|
498 |
{ |
|
499 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
500 |
return SetFaxSettings(tsyReqHandle,REINTERPRET_CAST(RCall::TFaxSessionSettings*,ptr1)); |
|
501 |
} |
|
502 |
case EEtelCallReferenceCount: |
|
503 |
{ |
|
504 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
505 |
||
506 |
TInt* count=REINTERPRET_CAST(TInt*,ptr1); |
|
507 |
*count=AccessCount(); |
|
508 |
ReqCompleted(tsyReqHandle,KErrNone); |
|
509 |
return KErrNone; |
|
510 |
} |
|
511 |
case EEtelAdoptFaxSharedHeaderFile: |
|
512 |
{ |
|
513 |
CFaxSharedFileHandles* fshare = NULL; |
|
514 |
TRAPD(err, fshare = CFaxSharedFileHandles::NewL(aMessage)); |
|
515 |
if(err != KErrNone) |
|
516 |
{ |
|
517 |
return err; |
|
518 |
} |
|
519 |
//Pass the CFaxSharedFileHandles object to the TSY. If call is successful then TSY assumes owenership of the object else we delete it. |
|
520 |
TInt ret = SetFaxSharedHeaderFile(tsyReqHandle, fshare); |
|
521 |
if(ret!= KErrNone) |
|
522 |
{ |
|
523 |
delete fshare; |
|
524 |
} |
|
525 |
return ret; |
|
526 |
} |
|
527 |
default: |
|
528 |
return ServiceExtFunc(aMessage,aReqEntry); |
|
529 |
} |
|
530 |
} |
|
531 |
||
532 |
EXPORT_C RHandleBase* CCallBase::GlobalKernelObjectHandle() |
|
533 |
{ |
|
534 |
if (iChunk.Handle() == KNullHandle) return NULL; |
|
535 |
return &iChunk; |
|
536 |
} |
|
537 |
||
538 |
||
539 |
EXPORT_C RFax::TProgress* CCallBase::CreateFaxProgressChunk() |
|
540 |
// |
|
541 |
// Even if already created, return pointer to it |
|
542 |
// |
|
543 |
{ |
|
544 |
if (iChunk.Handle() == KNullHandle) |
|
545 |
{ |
|
546 |
TInt r = iChunk.CreateGlobal(KNullDesC,sizeof (RFax::TProgress), sizeof (RFax::TProgress),EOwnerProcess); |
|
547 |
if (r == KErrNone) |
|
548 |
{ |
|
549 |
RFax::TProgress* progress = new(iChunk.Base()) RFax::TProgress; |
|
550 |
progress->iLastUpdateTime = 0; |
|
551 |
progress->iAnswerback.Zero (); |
|
552 |
progress->iPhase = ENotYetStarted; |
|
553 |
progress->iSpeed = 9600; |
|
554 |
progress->iResolution = EFaxNormal; |
|
555 |
progress->iCompression = EModifiedHuffman; |
|
556 |
progress->iECM = 0; |
|
557 |
progress->iPage = 0; |
|
558 |
progress->iLines = 0; |
|
559 |
return progress; |
|
560 |
} |
|
561 |
if (r != KErrNone) |
|
562 |
return NULL; |
|
563 |
||
564 |
} |
|
565 |
return (RFax::TProgress*)iChunk.Base(); |
|
566 |
} |
|
567 |
||
568 |
/** |
|
569 |
Base implementation for virtual API declared in MCallBaseTSY. This base implementation always returns KErrNotSupported and |
|
570 |
it is therefore necessary for TSYs who support this API to override this in their CCallBase derived class. |
|
571 |
||
572 |
This function passes through a pointer to a heap-based CFaxSharedFileHandles object. This object is instantiated by Etel but |
|
573 |
a successful return of this function will pass responsibility for deletion of aFaxSharedFileHandles from Etel server to the TSY. |
|
574 |
If an error code is returned from this function (e.g. KErrNotSupported) Etel maintains ownership of the aFaxSharedFileHandles and |
|
575 |
is responsible for its deletion. |
|
576 |
||
577 |
TSY overrides of this function must correctly handle the cleanup of the aFaxSharedFileHandles object if they take ownership of it |
|
578 |
which is implied when returning from this function with KErrNone. |
|
579 |
||
580 |
@publishedPartner |
|
581 |
@param aTsyReqHandle Handle to request. |
|
582 |
@param aFaxSharedFileHandles CFaxSharedFileHandles instance to be stored in TSY. |
|
583 |
@released Released v9.0 to allow a fax client to pass a file handle to the Fax server. |
|
584 |
*/ |
|
585 |
EXPORT_C TInt CCallBase::SetFaxSharedHeaderFile(const TTsyReqHandle /*aTsyReqHandle*/, CFaxSharedFileHandles* /*aFaxSharedFileHandles*/) |
|
586 |
{ |
|
587 |
return KErrNotSupported; |
|
588 |
} |
|
589 |
||
590 |
EXPORT_C void CCallBase::DeleteFaxProgressChunk() |
|
591 |
{ |
|
592 |
iChunk.Close(); |
|
593 |
} |
|
594 |
||
595 |
EXPORT_C CTelObject::TReqMode CCallBase::ReqModeL(const TInt aIpc) |
|
596 |
// |
|
597 |
// Basic Request Mode for Call |
|
598 |
// |
|
599 |
{ |
|
600 |
CTelObject::TReqMode mode=0; |
|
601 |
switch (aIpc) |
|
602 |
{ |
|
603 |
case EEtelCallNotifyHookChange: |
|
604 |
case EEtelCallNotifyStatusChange: |
|
605 |
case EEtelCallNotifyDurationChange: |
|
606 |
case EEtelCallCapsChangeNotification: |
|
607 |
mode=KReqModeMultipleCompletionEnabled | KReqModeRePostImmediately; |
|
608 |
break; |
|
609 |
case EEtelCallGetInfo: |
|
610 |
case EEtelCallRecoverDataPort: |
|
611 |
case EEtelCallGetStatus: |
|
612 |
case EEtelCallGetCaps: |
|
613 |
case EEtelCallTransferOwnership: |
|
614 |
case EEtelCallAcquireOwnership: |
|
615 |
case EEtelCallGetFaxSettings: |
|
616 |
case EEtelCallGetCallParams: |
|
617 |
case EEtelCallGetCallDuration: |
|
618 |
case EEtelCallAnswer: // no longer obeys flow control since it may be placed long before |
|
619 |
// a call arrives |
|
620 |
break; |
|
621 |
case EEtelCallGetOwnershipStatus: |
|
622 |
case EEtelCallGetBearerServiceInfo: |
|
623 |
case EEtelCallSetFaxSettings: |
|
624 |
case EEtelAdoptFaxSharedHeaderFile: |
|
625 |
case EEtelCallReferenceCount: |
|
626 |
break; |
|
627 |
case EEtelCallLoanDataPort: |
|
628 |
case EEtelCallDial: |
|
629 |
case EEtelCallConnect: |
|
630 |
case EEtelCallHangUp: |
|
631 |
||
632 |
mode=KReqModeFlowControlObeyed; |
|
633 |
break; |
|
634 |
||
635 |
default: |
|
636 |
User::Leave(KErrNotSupported); |
|
637 |
break; |
|
638 |
} |
|
639 |
return mode; |
|
640 |
} |
|
641 |
||
642 |
EXPORT_C TInt CCallBase::NumberOfSlotsL(const TInt aIpc) |
|
643 |
{ |
|
644 |
switch (aIpc) |
|
645 |
{ |
|
646 |
case EEtelCallNotifyHookChange: |
|
647 |
case EEtelCallNotifyDurationChange: |
|
648 |
break; |
|
649 |
case EEtelCallNotifyStatusChange: |
|
650 |
return KSlotNumbersCallStatusChange; |
|
651 |
case EEtelCallCapsChangeNotification: |
|
652 |
return KSlotNumbersCallCapsChange; |
|
653 |
default: |
|
654 |
User::Leave(KErrNotSupported); |
|
655 |
break; |
|
656 |
} |
|
657 |
return KSlotNumbersDefault; |
|
658 |
} |
|
659 |
||
660 |
// |
|
661 |
// |
|
662 |
// CLineBase |
|
663 |
// |
|
664 |
// |
|
665 |
EXPORT_C CLineBase::CLineBase() |
|
666 |
// |
|
667 |
// C'Tor |
|
668 |
// |
|
669 |
{ |
|
670 |
__DECLARE_NAME(_S("CLineBase")); |
|
671 |
} |
|
672 |
||
673 |
EXPORT_C CLineBase::~CLineBase() |
|
674 |
// |
|
675 |
// D'Tor |
|
676 |
// |
|
677 |
{ |
|
678 |
LOGTEXT("~CLineBase"); |
|
679 |
} |
|
680 |
||
681 |
EXPORT_C TInt CLineBase::CancelService(const TInt aIpc,const TTsyReqHandle aTsyReqHandle) |
|
682 |
// |
|
683 |
// Cancel Service for Line |
|
684 |
// |
|
685 |
{ |
|
686 |
__ASSERT_ALWAYS(( aIpc==EEtelLineNotifyIncomingCall || |
|
687 |
aIpc==EEtelLineNotifyHookChange || |
|
688 |
aIpc==EEtelLineNotifyStatusChange || |
|
689 |
aIpc==EEtelLineNotifyCallAdded || |
|
690 |
aIpc==EETelLineCapsChangeNotification) |
|
691 |
,Fault(EEtelFaultInvalidIpcForCancel)); |
|
692 |
switch (aIpc) |
|
693 |
{ |
|
694 |
case EEtelLineNotifyIncomingCall: |
|
695 |
return NotifyIncomingCallCancel(aTsyReqHandle); |
|
696 |
case EEtelLineNotifyHookChange: |
|
697 |
return NotifyHookChangeCancel(aTsyReqHandle); |
|
698 |
case EEtelLineNotifyStatusChange: |
|
699 |
return NotifyStatusChangeCancel(aTsyReqHandle); |
|
700 |
case EEtelLineNotifyCallAdded: |
|
701 |
return NotifyCallAddedCancel(aTsyReqHandle); |
|
702 |
case EETelLineCapsChangeNotification: |
|
703 |
return NotifyCapsChangeCancel(aTsyReqHandle); |
|
704 |
default: |
|
705 |
return KErrGeneral; // should never reaches here |
|
706 |
} |
|
707 |
} |
|
708 |
||
709 |
EXPORT_C TInt CLineBase::Service(const RMessage2& aMessage, CReqEntry* aReqEntry) |
|
710 |
// |
|
711 |
// The ServiceL Functionality for the Line |
|
712 |
// |
|
713 |
{ |
|
714 |
__ASSERT_ALWAYS(aReqEntry!=NULL,Fault(EEtelFaultCallTsyServiceWithoutReqPackage)); |
|
715 |
aReqEntry->iPlacedRequest=ETrue; |
|
716 |
TTsyReqHandle tsyReqHandle=aReqEntry->iTsyReqHandle; |
|
717 |
TDes8* des1 = BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
718 |
TUint8* ptr1=Ptr1(des1); |
|
719 |
||
720 |
switch (aReqEntry->iFunction) |
|
721 |
{ |
|
722 |
case EETelLineCapsChangeNotification: |
|
723 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
724 |
return NotifyCapsChange(tsyReqHandle,REINTERPRET_CAST(RLine::TCaps*,ptr1)); |
|
725 |
case EETelLineCapsChangeNotificationCancel: |
|
726 |
return NotifyCapsChangeCancel(tsyReqHandle); |
|
727 |
case EEtelLineNotifyIncomingCall: |
|
728 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
729 |
return NotifyIncomingCall(tsyReqHandle,REINTERPRET_CAST(TName*,ptr1)); |
|
730 |
case EEtelLineNotifyIncomingCallCancel: |
|
731 |
return NotifyIncomingCallCancel(tsyReqHandle); |
|
732 |
||
733 |
case EEtelLineNotifyHookChange: |
|
734 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
735 |
return NotifyHookChange(tsyReqHandle,REINTERPRET_CAST(RCall::THookStatus*,ptr1)); |
|
736 |
case EEtelLineNotifyHookChangeCancel: |
|
737 |
return NotifyHookChangeCancel(tsyReqHandle); |
|
738 |
case EEtelLineNotifyStatusChange: |
|
739 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
740 |
return NotifyStatusChange(tsyReqHandle,REINTERPRET_CAST(RCall::TStatus*,ptr1)); |
|
741 |
case EEtelLineNotifyStatusChangeCancel: |
|
742 |
return NotifyStatusChangeCancel(tsyReqHandle); |
|
743 |
case EEtelLineNotifyCallAdded: |
|
744 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
745 |
return NotifyCallAdded(tsyReqHandle,REINTERPRET_CAST(TName*,ptr1)); |
|
746 |
case EEtelLineNotifyCallAddedCancel: |
|
747 |
return NotifyCallAddedCancel(tsyReqHandle); |
|
748 |
||
749 |
case EEtelLineGetHookStatus: |
|
750 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
751 |
return GetHookStatus(tsyReqHandle,REINTERPRET_CAST(RCall::THookStatus*,ptr1)); |
|
752 |
||
753 |
case EEtelLineGetInfo: |
|
754 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
755 |
return GetInfo(tsyReqHandle,REINTERPRET_CAST(RLine::TLineInfo*,ptr1)); |
|
756 |
case EEtelLineGetCaps: |
|
757 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
758 |
return GetCaps(tsyReqHandle,REINTERPRET_CAST(RLine::TCaps*,ptr1)); |
|
759 |
case EEtelLineGetStatus: |
|
760 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
761 |
return GetStatus(tsyReqHandle,REINTERPRET_CAST(RCall::TStatus*,ptr1)); |
|
762 |
case EEtelLineEnumerateCall: |
|
763 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
764 |
return EnumerateCall(tsyReqHandle,REINTERPRET_CAST(TInt*,ptr1)); |
|
765 |
case EEtelLineGetCallInfo: |
|
766 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
767 |
return GetCallInfo(tsyReqHandle,REINTERPRET_CAST(TCallInfoIndex*,ptr1)); |
|
768 |
default: |
|
769 |
return ServiceExtFunc(aMessage,aReqEntry); |
|
770 |
} |
|
771 |
} |
|
772 |
||
773 |
EXPORT_C void CLineBase::Init() |
|
774 |
// |
|
775 |
// not used for Line |
|
776 |
// |
|
777 |
{} |
|
778 |
||
779 |
EXPORT_C void CLineBase::OpenPostProcessing(CTelSession*,const TInt) |
|
780 |
// |
|
781 |
// Perform post-processing after object has been added to session's CObjectIx. |
|
782 |
// |
|
783 |
{} |
|
784 |
||
785 |
EXPORT_C void CLineBase::CloseSubSessionPreProcessing(CTelSession* aSession,const TInt aSubSessionHandle) |
|
786 |
// |
|
787 |
// |
|
788 |
// |
|
789 |
{ |
|
790 |
LOGTEXT("CLineBase::CloseSubSessionPreProcessing() - about to create dummy session"); |
|
791 |
CreateDummySession(aSession,aSubSessionHandle); |
|
792 |
FlushReqs(aSession,aSubSessionHandle); |
|
793 |
} |
|
794 |
||
795 |
EXPORT_C CTelObject::TReqMode CLineBase::ReqModeL(const TInt aIpc) |
|
796 |
// |
|
797 |
// Mode Request Inquiry Functions |
|
798 |
// |
|
799 |
{ |
|
800 |
CTelObject::TReqMode mode=0; |
|
801 |
switch (aIpc) |
|
802 |
{ |
|
803 |
case EEtelLineGetCaps: |
|
804 |
case EEtelLineGetStatus: |
|
805 |
case EEtelLineGetHookStatus: |
|
806 |
case EEtelLineEnumerateCall: |
|
807 |
case EEtelLineGetCallInfo: |
|
808 |
case EEtelLineGetInfo: |
|
809 |
case EEtelLineNotifyIncomingCall: // 3/12/98 Removed Repost ability. |
|
810 |
mode=KReqModeMultipleCompletionEnabled; |
|
811 |
break; |
|
812 |
case EEtelLineNotifyHookChange: |
|
813 |
case EEtelLineNotifyStatusChange: |
|
814 |
case EEtelLineNotifyCallAdded: |
|
815 |
case EETelLineCapsChangeNotification: |
|
816 |
mode=KReqModeMultipleCompletionEnabled | KReqModeRePostImmediately; |
|
817 |
break; |
|
818 |
default: |
|
819 |
User::Leave(KErrNotSupported); |
|
820 |
break; |
|
821 |
} |
|
822 |
return mode; |
|
823 |
} |
|
824 |
||
825 |
EXPORT_C TInt CLineBase::NumberOfSlotsL(const TInt aIpc) |
|
826 |
{ |
|
827 |
switch (aIpc) |
|
828 |
{ |
|
829 |
case EEtelLineNotifyHookChange: |
|
830 |
case EETelLineCapsChangeNotification: |
|
831 |
break; |
|
832 |
case EEtelLineNotifyStatusChange: |
|
833 |
return KSlotNumbersLineStatusChange; |
|
834 |
case EEtelLineNotifyCallAdded: |
|
835 |
return KSlotNumbersLineCallAddedChange; |
|
836 |
default: |
|
837 |
User::Leave(KErrNotSupported); |
|
838 |
break; |
|
839 |
} |
|
840 |
return KSlotNumbersDefault; |
|
841 |
} |
|
842 |
||
843 |
// |
|
844 |
// |
|
845 |
// CPhoneBase |
|
846 |
// |
|
847 |
// |
|
848 |
EXPORT_C CPhoneBase::CPhoneBase() |
|
849 |
// |
|
850 |
// CPhoneBase constructor |
|
851 |
// |
|
852 |
{ |
|
853 |
__DECLARE_NAME(_S("CPhoneBase")); |
|
854 |
iReqWaitList.SetOffset(_FOFF(CReqEntry,iLink)); |
|
855 |
iReqActiveList.SetOffset(_FOFF(CReqEntry,iLink)); |
|
856 |
iTsyReqHandleCnt=TSY_HANDLE_INIT_VALUE; |
|
857 |
} |
|
858 |
||
859 |
EXPORT_C CPhoneBase::~CPhoneBase() |
|
860 |
// |
|
861 |
// CPhone destructor. |
|
862 |
// Attual closing of the owner is done in CSubSessionBase destructor |
|
863 |
// This is for all object inherit fron CSubSesissionBase |
|
864 |
// |
|
865 |
{ |
|
866 |
LOGTEXT("~CPhoneBase"); |
|
867 |
} |
|
868 |
||
869 |
// |
|
870 |
// Request List Manipulation Functions |
|
871 |
// |
|
872 |
CReqEntry* CPhoneBase::ActivateNextWaitingReq() |
|
873 |
// |
|
874 |
// Use: during completion to Activate the next waiting request |
|
875 |
// Action: Find next Waiting Req, move to active, and return. |
|
876 |
// |
|
877 |
{ |
|
878 |
if(iReqWaitList.IsEmpty()) |
|
879 |
return NULL; |
|
880 |
||
881 |
CReqEntry* reqEntry=iReqWaitList.First(); |
|
882 |
if(reqEntry==NULL) |
|
883 |
return NULL; |
|
884 |
reqEntry->iLink.Deque(); |
|
885 |
iReqActiveList.AddLast(*reqEntry); |
|
886 |
if (reqEntry->iReqMode & KReqModeMultipleCompletionEnabled | KReqModeMultipleCompletionWithInterestLevel) |
|
887 |
{ |
|
888 |
CReqEntry* otherClientsEntry; |
|
889 |
TDblQueIter<CReqEntry> iter(iReqWaitList); |
|
890 |
while(otherClientsEntry=iter++, otherClientsEntry!=NULL) |
|
891 |
{ |
|
892 |
if(otherClientsEntry->iTsyReqHandle==reqEntry->iTsyReqHandle) |
|
893 |
{ |
|
894 |
otherClientsEntry->iLink.Deque(); |
|
895 |
iReqActiveList.AddLast(*otherClientsEntry); |
|
896 |
} |
|
897 |
} |
|
898 |
} |
|
899 |
return reqEntry; |
|
900 |
} |
|
901 |
||
902 |
CReqEntry* CPhoneBase::FindByTsyHandleAndPlacedRequest(const TTsyReqHandle aTsyReqHandle) |
|
903 |
// |
|
904 |
// Use: to search active req list for a single req, remove and then return it. Can be called repeatedly for Notification |
|
905 |
// |
|
906 |
{ |
|
907 |
CReqEntry* reqEntry; |
|
908 |
TDblQueIter<CReqEntry> iter(iReqActiveList); |
|
909 |
while(reqEntry=iter++, reqEntry!=NULL) |
|
910 |
{ |
|
911 |
if(reqEntry->iTsyReqHandle==aTsyReqHandle && reqEntry->iPlacedRequest) |
|
912 |
return reqEntry; |
|
913 |
} |
|
914 |
return NULL; |
|
915 |
} |
|
916 |
||
917 |
CReqEntry* CPhoneBase::FindByTsyHandle(const TTsyReqHandle aTsyReqHandle) |
|
918 |
// |
|
919 |
// Use: to search active req list for a single req, remove and then return it. Can be called repeatedly for Notification |
|
920 |
// |
|
921 |
{ |
|
922 |
CReqEntry* reqEntry; |
|
923 |
TDblQueIter<CReqEntry> iter(iReqActiveList); |
|
924 |
while(reqEntry=iter++, reqEntry!=NULL) |
|
925 |
{ |
|
926 |
if(reqEntry->iTsyReqHandle==aTsyReqHandle) |
|
927 |
return reqEntry; |
|
928 |
} |
|
929 |
return NULL; |
|
930 |
} |
|
931 |
||
932 |
EXPORT_C TInt CPhoneBase::FindSessionByTsyHandle(const TTsyReqHandle aTsyReqHandle) |
|
933 |
{ |
|
934 |
CReqEntry* reqEntry = FindByTsyHandle(aTsyReqHandle); |
|
935 |
if (!reqEntry) |
|
936 |
{ |
|
937 |
// TODO we'd need to ensure the subsession handle was positive |
|
938 |
// to be able to return an error. Shifting the pointer >>1 |
|
939 |
// would ensure this. |
|
940 |
return KErrNotFound; |
|
941 |
} |
|
942 |
return reinterpret_cast<TInt>(reqEntry->iSession); |
|
943 |
} |
|
944 |
||
945 |
EXPORT_C TInt CPhoneBase::FindSubSessionByTsyHandle(const TTsyReqHandle aTsyReqHandle) |
|
946 |
{ |
|
947 |
CReqEntry* reqEntry = FindByTsyHandle(aTsyReqHandle); |
|
948 |
if (!reqEntry) |
|
949 |
{ |
|
950 |
return KErrNotFound; |
|
951 |
} |
|
952 |
return reqEntry->iMessage.Int3(); |
|
953 |
} |
|
77 | 954 |
|
24 | 955 |
void CPhoneBase::UpdateBuffer(CReqEntry* aUpdatedReqEntry,CReqEntry* aReqEntry) |
956 |
// |
|
957 |
// Is passed both the TSY-updated request entry (which may be multi-buffered or not) |
|
958 |
// and another request entry which is to have the data copied into it (which again may or may |
|
959 |
// not be multi-buffered) copies the latest data into the target request entry. |
|
960 |
// |
|
961 |
{ |
|
962 |
__ASSERT_ALWAYS(aUpdatedReqEntry->iFunction==aReqEntry->iFunction,Fault(EEtelFaultUpdatingBufferOfDifferentIpc)); |
|
963 |
TInt msgType = aReqEntry->iMessage.Int1(); |
|
964 |
if (msgType==EIsaNarrowAndUnicodeDoubleDesTobeRead) |
|
965 |
{ |
|
966 |
TDes8* targetDes1 = BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
967 |
TDes16* targetDes2 = BufferDes2u(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
968 |
TDes8* sourceDes1 = BufferDes1(aUpdatedReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
969 |
TDes16* sourceDes2 = BufferDes2u(aUpdatedReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
970 |
if (sourceDes1!=targetDes1) |
|
971 |
{ |
|
972 |
targetDes1->Copy(*sourceDes1); |
|
973 |
if (targetDes2) |
|
974 |
targetDes2->Copy(*sourceDes2); |
|
975 |
aReqEntry->iBuffer->IncWrite(); |
|
976 |
} |
|
977 |
return; |
|
978 |
} |
|
979 |
if (aUpdatedReqEntry->iSession->IsUnicodeReq(msgType)) |
|
980 |
{ |
|
981 |
TDes16* targetDes1 = BufferDes1u(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
982 |
TDes16* targetDes2 = BufferDes2u(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
983 |
TDes16* sourceDes1 = BufferDes1u(aUpdatedReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
984 |
TDes16* sourceDes2 = BufferDes2u(aUpdatedReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
985 |
if (sourceDes1!=targetDes1) |
|
986 |
{ |
|
987 |
targetDes1->Copy(*sourceDes1); |
|
988 |
if (targetDes2) |
|
989 |
targetDes2->Copy(*sourceDes2); |
|
990 |
aReqEntry->iBuffer->IncWrite(); |
|
991 |
} |
|
992 |
} |
|
993 |
else // this is narrow |
|
994 |
{ |
|
995 |
TDes8* targetDes1 = BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
996 |
TDes8* targetDes2 = BufferDes2(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
997 |
TDes8* sourceDes1 = BufferDes1(aUpdatedReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
998 |
TDes8* sourceDes2 = BufferDes2(aUpdatedReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
999 |
if (sourceDes1!=targetDes1) |
|
1000 |
{ |
|
1001 |
targetDes1->Copy(*sourceDes1); |
|
1002 |
if (targetDes2) |
|
1003 |
targetDes2->Copy(*sourceDes2); |
|
1004 |
aReqEntry->iBuffer->IncWrite(); |
|
1005 |
} |
|
1006 |
} |
|
1007 |
} |
|
1008 |
||
1009 |
CReqEntry* CPhoneBase::FindClientInWaiting(CTelSession* aSession,const TInt aSubSessionHandle,const TInt aIpc) |
|
1010 |
// |
|
1011 |
// Used to search waiting list for a req that's to be cancelled. |
|
1012 |
// If non-Null is returned it will have been removed by this function and can be completed by the caller. |
|
1013 |
// |
|
1014 |
{ |
|
1015 |
CReqEntry* reqEntry; |
|
1016 |
TDblQueIter<CReqEntry> iter(iReqWaitList); |
|
1017 |
while(reqEntry = iter++, reqEntry!=NULL) |
|
1018 |
{ |
|
1019 |
if((reqEntry->iSession==aSession)&&(reqEntry->iMessage.Int3()==aSubSessionHandle)&&(reqEntry->iFunction==aIpc)) |
|
1020 |
return reqEntry; |
|
1021 |
} |
|
1022 |
return NULL; |
|
1023 |
} |
|
1024 |
||
1025 |
CReqEntry* CPhoneBase::FindClientInActive(CTelSession* aSession,const TInt aSubSessionHandle,const TInt aIpc) |
|
1026 |
// |
|
1027 |
// Used to search the active req list for a req that's to be cancelled. |
|
1028 |
// The function will return any req entry found, by the caller does not know to pass the cancel down until a search has been done just on the aIpc |
|
1029 |
// |
|
1030 |
{ |
|
1031 |
CReqEntry* reqEntry; |
|
1032 |
TDblQueIter<CReqEntry> iter(iReqActiveList); |
|
1033 |
while(reqEntry = iter++, reqEntry!=NULL) |
|
1034 |
{ |
|
1035 |
if((reqEntry->iSession==aSession)&&(reqEntry->iMessage.Int3()==aSubSessionHandle)&&(reqEntry->iFunction==aIpc)) |
|
1036 |
return reqEntry; |
|
1037 |
} |
|
1038 |
return NULL; |
|
1039 |
} |
|
1040 |
||
1041 |
CReqEntry* CPhoneBase::FindByIpcAndTelObject(const TInt aIpc, const CTelObject* aTelObject, const TUint aBufSize) |
|
1042 |
// |
|
1043 |
// Finds an active request by both IPC and by the TelObject it was placed on |
|
1044 |
// |
|
1045 |
{ |
|
1046 |
CReqEntry* reqEntry; |
|
1047 |
TDblQueIter<CReqEntry> iter(iReqActiveList); |
|
1048 |
while(reqEntry = iter++, reqEntry!=NULL) |
|
1049 |
{ |
|
1050 |
if(reqEntry->iFunction==aIpc && reqEntry->iTelObject==aTelObject |
|
1051 |
&& reqEntry->iBuffer->Size() == aBufSize) |
|
1052 |
return reqEntry; |
|
1053 |
} |
|
1054 |
return NULL; |
|
1055 |
} |
|
1056 |
||
81
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1057 |
CReqEntry* CPhoneBase::FindByIpcAndSecureId(const TInt aIpc, const TSecureId aSid) |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1058 |
// |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1059 |
// Finds an active request by both IPC and by the TSecureId it was placed on |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1060 |
// |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1061 |
{ |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1062 |
CReqEntry* reqEntry; |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1063 |
TDblQueIter<CReqEntry> iter(iReqActiveList); |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1064 |
while(reqEntry = iter++, reqEntry!=NULL) |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1065 |
{ |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1066 |
if(reqEntry->iFunction==aIpc && reqEntry->iMessage.SecureId()==aSid |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1067 |
&& EFalse != reqEntry->iPlacedRequest) |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1068 |
return reqEntry; |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1069 |
} |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1070 |
return NULL; |
7f379d8ed02d
Implemented CTelObject::SetSessionOwnerByTsyHandleAndIpc() and CPhoneBase::FindByIpcAndSecureId()
ivan.fildichev@opencode.com
parents:
77
diff
changeset
|
1071 |
} |
24 | 1072 |
CReqEntry* CPhoneBase::FindByIpcAndTelObjectInWaiting(const TInt aIpc, const CTelObject* aTelObject, const TUint aBufSize) |
1073 |
// |
|
1074 |
// Finds a waiting request by both IPC and by the TelObject it was placed on |
|
1075 |
// |
|
1076 |
{ |
|
1077 |
CReqEntry* reqEntry; |
|
1078 |
TDblQueIter<CReqEntry> iter(iReqWaitList); |
|
1079 |
while(reqEntry = iter++, reqEntry!=NULL) |
|
1080 |
{ |
|
1081 |
if(reqEntry->iFunction==aIpc && reqEntry->iTelObject==aTelObject |
|
1082 |
&& reqEntry->iBuffer->Size() == aBufSize) |
|
1083 |
return reqEntry; |
|
1084 |
} |
|
1085 |
return NULL; |
|
1086 |
} |
|
1087 |
||
1088 |
void CPhoneBase::AddReqToActive(CReqEntry* aReqEntry) |
|
1089 |
// |
|
1090 |
// Add reqEntry to the 'active list' |
|
1091 |
// |
|
1092 |
{ |
|
1093 |
LOGTEXT2("CPhoneBase::AddReqToActive with TsyHandle of %d", aReqEntry->iTsyReqHandle); |
|
1094 |
iReqActiveList.AddLast(*aReqEntry); |
|
1095 |
} |
|
1096 |
||
1097 |
void CPhoneBase::AddReqToWaiting(CReqEntry* aReqEntry) |
|
1098 |
// |
|
1099 |
// Add entry to the 'wait list' |
|
1100 |
// |
|
1101 |
{ |
|
1102 |
LOGTEXT2("CPhoneBase::AddReqToWaiting with TsyHandle of %d", aReqEntry->iTsyReqHandle); |
|
1103 |
iReqWaitList.AddLast(*aReqEntry); |
|
1104 |
} |
|
1105 |
||
1106 |
TTsyReqHandle CPhoneBase::TsyReqHandle() |
|
1107 |
// |
|
1108 |
// Return the request handle if wrap round avoid assigned to TSY_HANDLE_INIT_VALUE |
|
1109 |
// |
|
1110 |
{ |
|
1111 |
iTsyReqHandleCnt++ ; |
|
1112 |
if (iTsyReqHandleCnt==TSY_HANDLE_INIT_VALUE) |
|
1113 |
iTsyReqHandleCnt=(TSY_HANDLE_INIT_VALUE+1); |
|
1114 |
return iTsyReqHandleCnt; |
|
1115 |
} |
|
1116 |
||
1117 |
CReqEntry* CPhoneBase::NewReqL(const RMessage2& aMessage, CTelSession* aSession,CBuffer* aBuffer, |
|
1118 |
const CTelObject* aTelObject,TInt aFunction) |
|
1119 |
// |
|
1120 |
// Create new req entry |
|
1121 |
// |
|
1122 |
{ |
|
1123 |
return CReqEntry::NewL(TsyReqHandle(),aMessage,aSession,aBuffer,aTelObject,aFunction,aSession->EmergencyClientHeap(aMessage.Int1())); |
|
1124 |
} |
|
1125 |
||
1126 |
CReqEntry* CPhoneBase::FindSameClientEntry(CTelSession* aSession,const TInt aSubSessionHandle,const TInt aIpc) |
|
1127 |
// |
|
1128 |
// Seaching for duplicate request and panic client is return not NULL |
|
1129 |
// |
|
1130 |
{ |
|
1131 |
CReqEntry* reqEntry=FindClientInWaiting(aSession,aSubSessionHandle,aIpc); |
|
1132 |
||
1133 |
if (reqEntry!=NULL) |
|
1134 |
return reqEntry; |
|
1135 |
else // not found in waiting |
|
1136 |
reqEntry=FindClientInActive(aSession,aSubSessionHandle,aIpc); |
|
1137 |
return reqEntry; |
|
1138 |
||
1139 |
} |
|
1140 |
||
1141 |
EXPORT_C void CPhoneBase::OpenPostProcessing(CTelSession*,const TInt) |
|
1142 |
// |
|
1143 |
// Perform post-processing after object has been added to session's CObjectIx. |
|
1144 |
// |
|
1145 |
{} |
|
1146 |
||
1147 |
EXPORT_C void CPhoneBase::CloseSubSessionPreProcessing(CTelSession* aSession,const TInt aSubSessionHandle) |
|
1148 |
// |
|
1149 |
// Find if any active request if so create a dummy session |
|
1150 |
// |
|
1151 |
{ |
|
1152 |
LOGTEXT("CPhoneBase::CloseSubSessionPreProcessing"); |
|
1153 |
CreateDummySession(aSession,aSubSessionHandle); |
|
1154 |
FlushReqs(aSession,aSubSessionHandle); |
|
1155 |
} |
|
1156 |
||
1157 |
EXPORT_C TInt CPhoneBase::Service(const RMessage2& aMessage, CReqEntry* aReqEntry) |
|
1158 |
// |
|
1159 |
// The ServiceL functionality for the phone |
|
1160 |
// |
|
1161 |
{ |
|
1162 |
__ASSERT_ALWAYS(aReqEntry!=NULL,Fault(EEtelFaultCallTsyServiceWithoutReqPackage)); |
|
1163 |
aReqEntry->iPlacedRequest=ETrue; |
|
1164 |
TTsyReqHandle tsyReqHandle=aReqEntry->iTsyReqHandle; |
|
1165 |
TDes8* des1 = BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
1166 |
TUint8* ptr1=Ptr1(des1); |
|
1167 |
switch (aReqEntry->iFunction) |
|
1168 |
{ |
|
1169 |
case EETelPhoneCapsChangeNotification: |
|
1170 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1171 |
return NotifyCapsChange(tsyReqHandle,REINTERPRET_CAST(RPhone::TCaps*,ptr1)); |
|
1172 |
case EETelPhoneCapsChangeNotificationCancel: |
|
1173 |
return NotifyCapsChangeCancel(tsyReqHandle); |
|
1174 |
case EEtelPhoneInitialise: |
|
1175 |
return ControlledInitialisation(tsyReqHandle); |
|
1176 |
case EEtelPhoneInitialiseCancel: |
|
1177 |
return ControlledInitialisationCancel(tsyReqHandle); |
|
1178 |
case EEtelPhoneNotifyModemDetected: |
|
1179 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1180 |
return NotifyModemDetected(tsyReqHandle,REINTERPRET_CAST(RPhone::TModemDetection*,ptr1) ); |
|
1181 |
case EEtelPhoneNotifyModemDetectedCancel: |
|
1182 |
return NotifyModemDetectedCancel(tsyReqHandle); |
|
1183 |
case EEtelPhoneGetInfo: |
|
1184 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1185 |
return GetInfo(tsyReqHandle,REINTERPRET_CAST(RPhone::TPhoneInfo*,ptr1)); |
|
1186 |
case EEtelPhoneGetCaps: |
|
1187 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1188 |
return GetCaps(tsyReqHandle,REINTERPRET_CAST(RPhone::TCaps*,ptr1)); |
|
1189 |
case EEtelPhoneGetStatus: |
|
1190 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1191 |
return GetStatus(tsyReqHandle,REINTERPRET_CAST(RPhone::TStatus*,ptr1)); |
|
1192 |
case EEtelPhoneEnumerateLines: |
|
1193 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1194 |
return EnumerateLines(tsyReqHandle,REINTERPRET_CAST(TInt*,ptr1)); |
|
1195 |
case EEtelPhoneGetLineInfo: |
|
1196 |
__ASSERT_ALWAYS(des1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1197 |
return GetLineInfo(tsyReqHandle,REINTERPRET_CAST(TLineInfoIndex*,ptr1)); |
|
1198 |
default: |
|
1199 |
return ServiceExtFunc(aMessage,aReqEntry); |
|
1200 |
} |
|
1201 |
} |
|
1202 |
||
1203 |
EXPORT_C TInt CPhoneBase::CancelService(const TInt aIpc,const TTsyReqHandle aTsyReqHandle) |
|
1204 |
// |
|
1205 |
// Cancel Outstanding service for the phone |
|
1206 |
// |
|
1207 |
{ |
|
1208 |
switch (aIpc) |
|
1209 |
{ |
|
1210 |
case EEtelPhoneNotifyModemDetected: |
|
1211 |
return NotifyModemDetectedCancel(aTsyReqHandle); |
|
1212 |
case EETelPhoneCapsChangeNotification: |
|
1213 |
return NotifyCapsChangeCancel(aTsyReqHandle); |
|
1214 |
case EEtelPhoneInitialise: |
|
1215 |
return ControlledInitialisationCancel(aTsyReqHandle); |
|
1216 |
default: |
|
1217 |
return KErrGeneral; |
|
1218 |
} |
|
1219 |
} |
|
1220 |
||
1221 |
CReqEntry* CPhoneBase::FindClientReqInWaitList(CTelSession* aSession,const TInt aSubSessionHandle) |
|
1222 |
// |
|
1223 |
// Find first entry already logged by this client - in wait list |
|
1224 |
// |
|
1225 |
{ |
|
1226 |
CReqEntry* reqEntry; |
|
1227 |
TDblQueIter<CReqEntry> iter(iReqWaitList); |
|
1228 |
while(reqEntry = iter++, reqEntry!=NULL) |
|
1229 |
{ |
|
1230 |
if(aSession==reqEntry->iSession && aSubSessionHandle==reqEntry->iMessage.Int3()) |
|
1231 |
return reqEntry; |
|
1232 |
} |
|
1233 |
return NULL; |
|
1234 |
} |
|
1235 |
||
1236 |
CReqEntry* CPhoneBase::FindThisReqByAnotherClient(CTelSession* aSession,const TInt aSubSessionHandle,const TInt aIpc,const TUint aBufSize,const CTelObject* aThisTelObject) |
|
1237 |
// |
|
1238 |
// Find this IPC in active list, placed by a different client |
|
1239 |
// |
|
1240 |
{ |
|
1241 |
CReqEntry* reqEntry; |
|
1242 |
TDblQueIter<CReqEntry> iter(iReqActiveList); |
|
1243 |
while(reqEntry=iter++,reqEntry!=NULL) |
|
1244 |
{ |
|
1245 |
if((aSession!=reqEntry->iSession || aSubSessionHandle!=reqEntry->iMessage.Int3()) |
|
1246 |
&& reqEntry->iFunction==aIpc && reqEntry->iTelObject==aThisTelObject |
|
1247 |
&& reqEntry->iBuffer->Size()==aBufSize) |
|
1248 |
{ |
|
1249 |
return reqEntry; |
|
1250 |
} |
|
1251 |
} |
|
1252 |
return NULL; |
|
1253 |
} |
|
1254 |
||
1255 |
CReqEntry* CPhoneBase::FindNonCancelledClientReq(CTelSession* aSession,const TInt aSubSessionHandle,const TInt aIpc) |
|
1256 |
// |
|
1257 |
// Find this IPC in active list, placed by this client but not the one which placed request on TSY |
|
1258 |
// |
|
1259 |
{ |
|
1260 |
CReqEntry* reqEntry; |
|
1261 |
TDblQueIter<CReqEntry> iter(iReqActiveList); |
|
1262 |
while(reqEntry=iter++,reqEntry!=NULL) |
|
1263 |
{ |
|
1264 |
if(aSession==reqEntry->iSession && aSubSessionHandle==reqEntry->iMessage.Int3() && reqEntry->iFunction==aIpc && reqEntry->iCancelFnCalled==EFalse) |
|
1265 |
{ |
|
1266 |
return reqEntry; |
|
1267 |
} |
|
1268 |
} |
|
1269 |
return NULL; |
|
1270 |
} |
|
1271 |
||
1272 |
void CPhoneBase::CheckAndCompleteAllActive(CReqEntry* aUpdatedReqEntry,const TReqMode aReqMode,const TInt aIpc,const TInt aError) |
|
1273 |
// |
|
1274 |
// Cycles through active list, checking for any requests with the same IPC value and if |
|
1275 |
// registered, copying the data from the buffer that the TSY filled in to this buffer. All those |
|
1276 |
// with the same IPC are completed up to the client (if the client is ready). |
|
1277 |
// |
|
1278 |
{ |
|
1279 |
CReqEntry* reqEntry; |
|
1280 |
TDblQueIter<CReqEntry> iter(iReqActiveList); |
|
1281 |
while(reqEntry = iter++, reqEntry!=NULL) |
|
1282 |
{ |
|
1283 |
if(reqEntry->iFunction==aIpc && reqEntry!=aUpdatedReqEntry |
|
1284 |
&& reqEntry->iTelObject==aUpdatedReqEntry->iTelObject |
|
1285 |
&& reqEntry->iBuffer->Size()==aUpdatedReqEntry->iBuffer->Size()) |
|
1286 |
{ |
|
1287 |
UpdateBuffer(aUpdatedReqEntry,reqEntry); |
|
1288 |
TInt error = ResolveError(reqEntry->iSession,aError); // set error as either low or high byte |
|
1289 |
if (aReqMode & KReqModeRePostImmediately) |
|
1290 |
UpdateAndCompleteIfNecessary(reqEntry,error); |
|
1291 |
else |
|
1292 |
WriteBackAndCompleteReq(reqEntry,error); |
|
1293 |
} |
|
1294 |
} |
|
1295 |
} |
|
1296 |
||
1297 |
||
1298 |
// The delivery object performs the task of delivering the request to the |
|
1299 |
// client. It loops through the clients in priority order and gives each |
|
1300 |
// client a fixed amount of time to either accept or reject. At the end |
|
1301 |
// the request will either be allocated or discarded (if no one wants it). |
|
1302 |
||
1303 |
CMmDeliveryObject* CMmDeliveryObject::NewL( CTelObject& aTelObject ) |
|
1304 |
{ |
|
1305 |
CMmDeliveryObject* self=new(ELeave) CMmDeliveryObject( aTelObject ); |
|
1306 |
CleanupStack::PushL( self ); |
|
1307 |
self->ConstructL(); |
|
1308 |
CleanupStack::Pop( self ); |
|
1309 |
return self; |
|
1310 |
} |
|
1311 |
||
1312 |
CMmDeliveryObject::CMmDeliveryObject( CTelObject& aTelObject ) : |
|
1313 |
CActive(EPriorityStandard), iTelObject(aTelObject) |
|
1314 |
{ |
|
1315 |
CActiveScheduler::Add( this ); |
|
1316 |
} |
|
1317 |
||
1318 |
void CMmDeliveryObject::ConstructL() |
|
1319 |
{ |
|
1320 |
User::LeaveIfError( iDeliveryTimer.CreateLocal() ); |
|
1321 |
} |
|
1322 |
||
1323 |
CMmDeliveryObject::~CMmDeliveryObject() |
|
1324 |
{ |
|
1325 |
Cancel(); |
|
1326 |
iDeliveryTimer.Close(); |
|
1327 |
iPendingReqs.Close(); |
|
1328 |
} |
|
1329 |
||
1330 |
void CMmDeliveryObject::DoCancel() |
|
1331 |
{ |
|
1332 |
iDeliveryTimer.Cancel(); |
|
1333 |
} |
|
1334 |
||
1335 |
// Called either when we need to attempt delivery of a request. |
|
1336 |
// Can be due to: |
|
1337 |
// 1) the start of the delivery process. |
|
1338 |
// 2) a client rejecting the request which makes us try the next one. |
|
1339 |
// 3) a client timing out which makes us try the next one. |
|
1340 |
void CMmDeliveryObject::RunL() |
|
1341 |
{ |
|
1342 |
||
1343 |
if ( iStatus == KErrNone && iUpdatedReqEntry) |
|
1344 |
{ |
|
1345 |
||
1346 |
TInterestCategory interestCategory; |
|
1347 |
iCurrentReq = NULL; |
|
1348 |
iCurrentReq = HighestPriorityReq(interestCategory); |
|
1349 |
||
1350 |
if ( iCurrentReq ) |
|
1351 |
{ |
|
1352 |
if (iUpdatedReqEntry!=iCurrentReq) |
|
1353 |
{ |
|
1354 |
iTelObject.PhoneOwner()->UpdateBuffer(iUpdatedReqEntry,iCurrentReq); |
|
1355 |
} |
|
1356 |
||
1357 |
// Offer incoming message to interested clients one at a time. |
|
1358 |
// Initially the priority client followed by Standard category clients. |
|
1359 |
OfferToClient( iCurrentReq ); |
|
1360 |
||
1361 |
// Client will have a certain time in which to accept/reject the message. |
|
1362 |
// After which it will be offered to the next client. |
|
1363 |
switch ( interestCategory ) |
|
1364 |
{ |
|
1365 |
case EInterestCategoryPriority: |
|
1366 |
iDeliveryTimer.After( iStatus, (KUssdOfferDialogueTimeout * KUssdPriorityTimeoutPercentage)/100 ); |
|
1367 |
SetActive(); |
|
1368 |
break; |
|
1369 |
case EInterestCategoryStandard: |
|
1370 |
iDeliveryTimer.After( iStatus, iTimeSlice ); |
|
1371 |
SetActive(); |
|
1372 |
break; |
|
1373 |
case EInterestCategoryDefault: |
|
77 | 1374 |
// wait on default client (no timeout) |
24 | 1375 |
break; |
1376 |
default: |
|
1377 |
// No more clients |
|
1378 |
Clear(); |
|
1379 |
} // end switch |
|
1380 |
} |
|
1381 |
else |
|
1382 |
{ |
|
1383 |
iTelObject.RepostRequest( iUpdatedReqEntry, KErrNone ); |
|
1384 |
||
1385 |
// No more clients left to check |
|
1386 |
Clear(); |
|
1387 |
} |
|
1388 |
} |
|
1389 |
else |
|
1390 |
{ |
|
1391 |
// Delivery has failed. |
|
1392 |
Clear(); |
|
1393 |
} |
|
1394 |
} |
|
1395 |
||
1396 |
TInt CMmDeliveryObject::DeliverReqL( TDblQue<CReqEntry>& aArray, CReqEntry* aUpdatedReqEntry, |
|
1397 |
const CTelObject::TReqMode aReqMode, const TInt aIpc, TInt aError) |
|
1398 |
{ |
|
1399 |
iPendingReqs.Reset(); |
|
1400 |
||
1401 |
ASSERT(aUpdatedReqEntry != NULL); |
|
1402 |
iUpdatedReqEntry = aUpdatedReqEntry; |
|
1403 |
iReqMode = aReqMode; |
|
1404 |
iError = aError; |
|
1405 |
||
1406 |
CReqEntry* reqEntry = NULL; |
|
1407 |
TDblQueIter<CReqEntry> iter(aArray); |
|
1408 |
while(reqEntry = iter++, reqEntry!=NULL) |
|
1409 |
{ |
|
1410 |
if(reqEntry->iFunction==aIpc |
|
1411 |
&& reqEntry->iTelObject==iUpdatedReqEntry->iTelObject |
|
1412 |
&& reqEntry->iBuffer->Size()==iUpdatedReqEntry->iBuffer->Size()) |
|
1413 |
{ |
|
1414 |
switch (reqEntry->iInterestCategory) |
|
1415 |
{ |
|
1416 |
case EInterestCategoryPriority: |
|
1417 |
{ |
|
1418 |
// If we don't already have a priority client registered, |
|
1419 |
// then add this one as the priority client. |
|
1420 |
if (iPriorityReq == NULL) |
|
1421 |
{ |
|
1422 |
iPriorityReq = reqEntry; |
|
1423 |
} |
|
1424 |
// Otherwise if there is already a registered priority client, |
|
1425 |
// add this to the list of standard clients to be treated as such. |
|
1426 |
else |
|
1427 |
{ |
|
1428 |
iPendingReqs.AppendL( reqEntry ); |
|
1429 |
} |
|
1430 |
break; |
|
1431 |
} |
|
1432 |
case EInterestCategoryDefault: |
|
1433 |
{ |
|
1434 |
// If we don't already have a default client registered, |
|
1435 |
// then add this one as the default client. |
|
1436 |
if (iDefaultReq == NULL) |
|
1437 |
{ |
|
1438 |
iDefaultReq = reqEntry; |
|
1439 |
} |
|
1440 |
// Otherwise if there is already a registered default client, |
|
1441 |
// add this to the list of standard clients to be treated as such. |
|
1442 |
else |
|
1443 |
{ |
|
1444 |
iPendingReqs.AppendL( reqEntry ); |
|
1445 |
} |
|
1446 |
break; |
|
1447 |
} |
|
1448 |
default: |
|
1449 |
{ |
|
1450 |
iPendingReqs.AppendL( reqEntry ); |
|
1451 |
} |
|
1452 |
} //end switch |
|
1453 |
} //end if |
|
1454 |
} |
|
1455 |
||
1456 |
// Calculate amount of time each client will get to accept the request |
|
1457 |
TInt count = iPendingReqs.Count(); |
|
1458 |
if (count) |
|
1459 |
{ |
|
1460 |
if (iPriorityReq) |
|
1461 |
{ |
|
1462 |
iTimeSlice = (KUssdOfferDialogueTimeout * (100 - KUssdPriorityTimeoutPercentage)/(100 * count) ); |
|
1463 |
} |
|
1464 |
else |
|
1465 |
{ |
|
1466 |
iTimeSlice = KUssdOfferDialogueTimeout / count ; |
|
1467 |
} |
|
1468 |
} |
|
1469 |
||
1470 |
// now start looping through clients... |
|
1471 |
DoStart(); |
|
1472 |
return KErrNone; |
|
1473 |
} |
|
1474 |
||
1475 |
TBool CMmDeliveryObject::DeliveryInProgress() const |
|
1476 |
{ |
|
1477 |
// In the case of delivery to the default client we won't be active when |
|
77 | 1478 |
// delivery is carried out as no timeout is used for the default client |
24 | 1479 |
return (IsActive() || iCurrentReq); |
1480 |
} |
|
77 | 1481 |
CTelObject::TReqMode CMmDeliveryObject::GetReqMode()const |
1482 |
{ |
|
1483 |
return iReqMode; |
|
1484 |
} |
|
24 | 1485 |
TInt CMmDeliveryObject::ClientsDecision( const RMessage2& aMessage, CTelSession* aSession, TBool aAccepted ) |
1486 |
{ |
|
1487 |
if (!DeliveryInProgress()) |
|
1488 |
{ |
|
1489 |
return KErrTimedOut; |
|
1490 |
} |
|
1491 |
||
1492 |
const TInt currentreqsession = reinterpret_cast<TInt>(iCurrentReq->iSession); |
|
1493 |
const TInt currentreqsubsession = iCurrentReq->iMessage.Int3(); |
|
1494 |
||
1495 |
const TInt clientsession = reinterpret_cast<TInt>(aSession); |
|
1496 |
const TInt clientsubsession = aMessage.Int3(); |
|
1497 |
||
1498 |
if (currentreqsession != clientsession || |
|
1499 |
currentreqsubsession != clientsubsession) |
|
1500 |
{ |
|
1501 |
// do nothing - client took too long to reply and we've moved |
|
1502 |
// onto another client now |
|
1503 |
return KErrTimedOut; |
|
1504 |
} |
|
1505 |
||
1506 |
if (aAccepted) |
|
1507 |
{ |
|
1508 |
Cancel(); |
|
1509 |
iTelObject.SetSessionOwner(clientsession, clientsubsession); |
|
1510 |
ASSERT(iUpdatedReqEntry != NULL); |
|
1511 |
// We repost the request so we don't miss the next message in the dialog |
|
1512 |
// in case the client is slow in calling ReceiveMessage again. |
|
1513 |
iTelObject.RepostRequest(iUpdatedReqEntry, KErrNone); |
|
1514 |
Clear(); |
|
1515 |
} |
|
1516 |
else |
|
1517 |
{ |
|
1518 |
Cancel(); |
|
1519 |
DoStart(); |
|
1520 |
} |
|
1521 |
return KErrNone; |
|
1522 |
} |
|
1523 |
||
1524 |
void CMmDeliveryObject::OfferToClient( CReqEntry* aReq ) |
|
1525 |
{ |
|
1526 |
iTelObject.OfferToClient(aReq, iUpdatedReqEntry, iReqMode, iError); |
|
1527 |
} |
|
1528 |
||
1529 |
||
1530 |
// CMmDeliveryObject is being notified that a client has called cancel. |
|
1531 |
// The relevant CReqEntry is being passed as a parameter. |
|
1532 |
// Need to remove it from our list of interested (in Receiving messages) clients. |
|
1533 |
||
1534 |
void CMmDeliveryObject::DeletedReqEntry( CReqEntry* aReqEntry ) |
|
1535 |
{ |
|
1536 |
if (iCurrentReq == aReqEntry) |
|
1537 |
{ |
|
1538 |
iCurrentReq = NULL; |
|
1539 |
} |
|
1540 |
||
1541 |
if (iPriorityReq == aReqEntry) |
|
1542 |
{ |
|
1543 |
iPriorityReq = NULL; |
|
1544 |
} |
|
1545 |
||
1546 |
if (iDefaultReq == aReqEntry) |
|
1547 |
{ |
|
1548 |
iDefaultReq = NULL; |
|
1549 |
} |
|
1550 |
||
1551 |
if ( iPendingReqs.Count() ) |
|
1552 |
{ |
|
1553 |
for (TInt i = iPendingReqs.Count()-1; i>=0; --i) |
|
1554 |
{ |
|
1555 |
if (aReqEntry == iPendingReqs[i]) |
|
1556 |
{ |
|
1557 |
iPendingReqs.Remove(i); |
|
1558 |
break; |
|
1559 |
} |
|
1560 |
} |
|
1561 |
} |
|
1562 |
||
1563 |
if (aReqEntry == iUpdatedReqEntry) |
|
1564 |
{ |
|
1565 |
// iUpdatedReqEntry is the client which cancelled. |
|
1566 |
// Copy data from the 'about to be destroyed' entry to |
|
1567 |
// one owned by the next client. |
|
1568 |
||
1569 |
CReqEntry* req = NewUpdatedReqEntry(); |
|
1570 |
if (req == NULL) |
|
1571 |
// No more clients left. |
|
1572 |
{ |
|
1573 |
Cancel(); |
|
1574 |
iPendingReqs.Close(); |
|
1575 |
} |
|
1576 |
else |
|
1577 |
{ |
|
1578 |
ASSERT(aReqEntry != req); |
|
1579 |
iTelObject.PhoneOwner()->UpdateBuffer(iUpdatedReqEntry,req); |
|
1580 |
iUpdatedReqEntry = req; |
|
1581 |
} |
|
1582 |
} |
|
1583 |
} |
|
1584 |
||
1585 |
CReqEntry* CMmDeliveryObject::NewUpdatedReqEntry() |
|
1586 |
{ |
|
1587 |
if (iCurrentReq) |
|
1588 |
return iCurrentReq; |
|
1589 |
||
1590 |
CReqEntry* req = NULL; |
|
1591 |
if (iPriorityReq) |
|
1592 |
{ |
|
1593 |
req = iPriorityReq; |
|
1594 |
} |
|
1595 |
else if ( iPendingReqs.Count() ) |
|
1596 |
{ |
|
1597 |
req = iPendingReqs[0]; |
|
1598 |
} |
|
1599 |
else if (iDefaultReq) |
|
1600 |
{ |
|
1601 |
req = iDefaultReq; |
|
1602 |
} |
|
1603 |
return req; |
|
1604 |
} |
|
1605 |
||
1606 |
||
1607 |
CReqEntry* CMmDeliveryObject::HighestPriorityReq( TInterestCategory& aInterestCategory ) |
|
1608 |
{ |
|
1609 |
aInterestCategory = EInterestCategoryStandard; |
|
1610 |
CReqEntry* req = NULL; |
|
1611 |
if (iPriorityReq) |
|
1612 |
{ |
|
1613 |
req = iPriorityReq; |
|
1614 |
iPriorityReq = NULL; |
|
1615 |
aInterestCategory = EInterestCategoryPriority; |
|
1616 |
} |
|
1617 |
else if ( iPendingReqs.Count() ) |
|
1618 |
{ |
|
1619 |
req = iPendingReqs[0]; |
|
1620 |
iPendingReqs.Remove(0); |
|
1621 |
aInterestCategory = EInterestCategoryStandard; |
|
1622 |
} |
|
1623 |
else if (iDefaultReq) |
|
1624 |
{ |
|
1625 |
req = iDefaultReq; |
|
1626 |
iDefaultReq = NULL; |
|
1627 |
aInterestCategory = EInterestCategoryDefault; |
|
1628 |
} |
|
1629 |
return req; |
|
1630 |
} |
|
1631 |
||
1632 |
void CMmDeliveryObject::DoStart() |
|
1633 |
{ |
|
1634 |
SetActive(); |
|
1635 |
TRequestStatus* status = &iStatus; |
|
1636 |
User::RequestComplete( status, KErrNone ); |
|
1637 |
} |
|
1638 |
||
1639 |
void CMmDeliveryObject::Clear() |
|
1640 |
{ |
|
1641 |
iPendingReqs.Reset(); |
|
1642 |
iCurrentReq = NULL; |
|
1643 |
iPriorityReq = NULL; |
|
1644 |
iDefaultReq = NULL; |
|
1645 |
||
1646 |
iUpdatedReqEntry = NULL; |
|
1647 |
iReqMode = 0; |
|
1648 |
iError = KErrNone; |
|
1649 |
} |
|
1650 |
||
1651 |
// |
|
1652 |
// CPhoneBase performs Flow Control |
|
1653 |
// |
|
1654 |
TInt CPhoneBase::FlowControl() const |
|
1655 |
// |
|
1656 |
// Return the value of iFlowControlCnt |
|
1657 |
// |
|
1658 |
{ |
|
1659 |
return iFlowControlCnt; |
|
1660 |
} |
|
1661 |
||
1662 |
void CPhoneBase::FlowControlInc() |
|
1663 |
// |
|
1664 |
// Increase iFlowControlCnt |
|
1665 |
// |
|
1666 |
{ |
|
1667 |
LOGTEXT3("Incrementing Flow Control from %d to %d", iFlowControlCnt, iFlowControlCnt+1); |
|
1668 |
iFlowControlCnt++; |
|
1669 |
} |
|
1670 |
||
1671 |
void CPhoneBase::FlowControlDec() |
|
1672 |
// |
|
1673 |
// Decrease iFlowControlCnt |
|
1674 |
// |
|
1675 |
{ |
|
1676 |
__ASSERT_ALWAYS((iFlowControlCnt>0),Fault(EEtelFaultNegativeFlowcontrolCount)); |
|
1677 |
LOGTEXT3("Decrementing Flow Control from %d to %d", iFlowControlCnt, iFlowControlCnt-1); |
|
1678 |
iFlowControlCnt--; |
|
1679 |
} |
|
1680 |
||
1681 |
EXPORT_C TBool CPhoneBase::CheckEmergencyClient(const TTsyReqHandle aTsyReqHandle) const |
|
1682 |
{ |
|
1683 |
CReqEntry* reqEntry=PhoneOwner()->FindByTsyHandle(aTsyReqHandle); |
|
1684 |
__ASSERT_ALWAYS(reqEntry!=NULL,Fault(EEtelFaultNotRecognisedTsyHandle)); |
|
1685 |
||
1686 |
return reqEntry->iSession->TelServer()->IsEmergencyClient(reqEntry->iSession); |
|
1687 |
} |
|
1688 |
||
1689 |
||
1690 |
EXPORT_C CTelObject::TReqMode CPhoneBase::ReqModeL(const TInt aIpc) |
|
1691 |
// |
|
1692 |
// Mode Request Inquiry Functions |
|
1693 |
// |
|
1694 |
{ |
|
1695 |
CTelObject::TReqMode mode=0; |
|
1696 |
switch (aIpc) |
|
1697 |
{ |
|
1698 |
case EEtelPhoneInitialise: //test |
|
1699 |
mode=KReqModeFlowControlObeyed | KReqModeMultipleCompletionEnabled; |
|
1700 |
break; |
|
1701 |
case EEtelPhoneGetCaps: |
|
1702 |
case EEtelPhoneGetStatus: |
|
1703 |
case EEtelPhoneEnumerateLines: |
|
1704 |
case EEtelPhoneGetLineInfo: |
|
1705 |
case EEtelPhoneGetInfo: |
|
1706 |
mode=KReqModeMultipleCompletionEnabled; |
|
1707 |
break; |
|
1708 |
case EETelPhoneSetEmergencyClient: |
|
1709 |
mode=KReqModeFlowControlObeyed; |
|
1710 |
break; |
|
1711 |
case EEtelPhoneNotifyModemDetected: |
|
1712 |
case EETelPhoneCapsChangeNotification: |
|
1713 |
mode=KReqModeMultipleCompletionEnabled | KReqModeRePostImmediately; |
|
1714 |
break; |
|
1715 |
default: |
|
1716 |
User::Leave(KErrNotSupported); |
|
1717 |
break; |
|
1718 |
} |
|
1719 |
return mode; |
|
1720 |
} |
|
1721 |
||
1722 |
EXPORT_C TInt CPhoneBase::NumberOfSlotsL(const TInt aIpc) |
|
1723 |
{ |
|
1724 |
switch (aIpc) |
|
1725 |
{ |
|
1726 |
case EEtelPhoneNotifyModemDetected: |
|
1727 |
case EETelPhoneCapsChangeNotification: |
|
1728 |
break; |
|
1729 |
default: |
|
1730 |
User::Leave(KErrNotSupported); |
|
1731 |
break; |
|
1732 |
} |
|
1733 |
return KSlotNumbersDefault; |
|
1734 |
} |
|
1735 |
||
1736 |
TDblQue<CReqEntry>& CPhoneBase::ReqActiveList() |
|
1737 |
{ |
|
1738 |
return iReqActiveList; |
|
1739 |
} |