author | ivan.fildichev@opencode.com |
Thu, 07 Oct 2010 19:32:01 +0300 | |
branch | opencode |
changeset 77 | 930a53cdc2d3 |
parent 32 | 58332560b319 |
child 81 | 7f379d8ed02d |
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 |
/** |
|
17 |
@file |
|
18 |
*/ |
|
19 |
||
20 |
#include "ET_SSTD.H" |
|
21 |
#include "et_record.h" |
|
22 |
#include "et_phone_util.h" |
|
23 |
#include "et_patchdata.h" |
|
24 |
// |
|
25 |
// CReqEntry class definitions |
|
26 |
// |
|
27 |
||
28 |
CReqEntry* CReqEntry::NewL(TTsyReqHandle aTsyReqHandle, const RMessage2& aMessage, CTelSession* aSession, CBuffer* aBuffer, const CTelObject* aTelObject, TInt aFunction, RHeap* aHeap) |
|
29 |
// |
|
30 |
// Create new request entry. aHeap should be NULL unless this is to be allocated on the |
|
31 |
// priority client heap. |
|
32 |
// |
|
33 |
{ |
|
34 |
if (aHeap != NULL) |
|
35 |
{ |
|
36 |
return new(aHeap) CReqEntry(aTsyReqHandle,aMessage,aSession,aBuffer,aTelObject,aFunction,aHeap); |
|
37 |
} |
|
38 |
||
39 |
return new(ELeave) CReqEntry(aTsyReqHandle,aMessage,aSession,aBuffer,aTelObject,aFunction,NULL); |
|
40 |
} |
|
41 |
||
42 |
||
43 |
CReqEntry::CReqEntry(TTsyReqHandle aTsyReqHandle,const RMessage2& aMessage,CTelSession* aSession,CBuffer* aBuffer,const CTelObject* aTelObject,TInt aFunction,RHeap* aHeap) |
|
44 |
// |
|
45 |
// CReqEntry constructor |
|
46 |
// |
|
47 |
: iTsyReqHandle(aTsyReqHandle), iMessage(aMessage), iSession(aSession), iTelObject(aTelObject), |
|
48 |
iClientInterested(ETrue), iCancelFnCalled(EFalse), iFunction(aFunction), iBuffer(aBuffer), |
|
49 |
iReadByClient(ETrue), iMessageNulled(EFalse), iHeap(aHeap) |
|
50 |
{} |
|
51 |
||
52 |
CReqEntry::~CReqEntry() |
|
53 |
// |
|
54 |
// CReqEntry destructor |
|
55 |
// |
|
56 |
{ |
|
57 |
delete iBuffer; |
|
58 |
} |
|
59 |
||
60 |
void CReqEntry::Deque() |
|
61 |
// |
|
62 |
// Deque CReqEntry list |
|
63 |
// |
|
64 |
{ |
|
65 |
iLink.Deque(); |
|
66 |
iLink.iPrev=iLink.iNext=NULL; |
|
67 |
} |
|
68 |
||
69 |
void CReqEntry::CompleteAndDeque(TInt aError) |
|
70 |
{ |
|
71 |
LOGTEXT("CReqEntry::CompleteAndDeque"); |
|
72 |
// if client does not interested in this request do not completed |
|
73 |
if (iClientInterested) |
|
74 |
{ |
|
75 |
RECORD_COMPLETE_SUB(iMessage.Session(), iTelObject, iMessage.Int3(), iMessage.Function(), aError); |
|
76 |
iMessage.Complete(aError); |
|
77 |
} |
|
78 |
||
79 |
iLink.Deque(); |
|
80 |
} |
|
81 |
||
82 |
TAny* CReqEntry::operator new(TUint aSize,RHeap* aHeap) __NO_THROW |
|
83 |
// |
|
84 |
// overloaded new using the priority client heap - can leave |
|
85 |
// |
|
86 |
{ |
|
87 |
TAny *pM=NULL; |
|
88 |
TRAPD(err, pM=aHeap->AllocL(aSize) ); |
|
89 |
||
90 |
if(err!=KErrNone) |
|
91 |
pM = NULL; |
|
92 |
else |
|
93 |
Mem::FillZ(pM,aSize); |
|
94 |
return(pM); |
|
95 |
} |
|
96 |
||
97 |
TAny* CReqEntry::operator new(TUint aSize) __NO_THROW |
|
98 |
{ |
|
99 |
return CBase::operator new(aSize); |
|
100 |
} |
|
101 |
||
102 |
TAny* CReqEntry::operator new(TUint aSize,TLeave aLeave) |
|
103 |
{ |
|
104 |
return CBase::operator new(aSize,aLeave); |
|
105 |
} |
|
106 |
||
107 |
TAny* CReqEntry::operator new(TUint aSize,TUint aExtraSize) __NO_THROW |
|
108 |
{ |
|
109 |
return CBase::operator new(aSize,aExtraSize); |
|
110 |
} |
|
111 |
||
112 |
void CReqEntry::operator delete(TAny* aPtr) |
|
113 |
// |
|
114 |
// overloaded delete - deletes from priority client heap if iHeap is not NULL |
|
115 |
// |
|
116 |
{ |
|
117 |
if (((CReqEntry*)aPtr)->iHeap!=NULL) |
|
118 |
((CReqEntry*)aPtr)->iHeap->Free(aPtr); |
|
119 |
else |
|
120 |
User::Free(aPtr); |
|
121 |
} |
|
122 |
||
123 |
// |
|
124 |
// CBuffer class definitions |
|
125 |
// |
|
126 |
CBuffer* CBuffer::NewL(HEtelBufC8* aBuf8,HEtelBufC16* aBuf16,RHeap* aHeap,TInt aSizeOfData1,TInt aSizeOfData2,TInt aNoOfSlots) |
|
127 |
{ |
|
128 |
if (aHeap!=NULL) |
|
129 |
return new(aHeap) CBuffer(aBuf8,aBuf16,aHeap,aSizeOfData1,aSizeOfData2,aNoOfSlots); |
|
130 |
||
131 |
return new(ELeave) CBuffer(aBuf8,aBuf16,NULL,aSizeOfData1,aSizeOfData2,aNoOfSlots); |
|
132 |
} |
|
133 |
||
134 |
CBuffer::CBuffer(HEtelBufC8* aBuf8,HEtelBufC16* aBuf16,RHeap* aHeap,TInt aSizeOfData1,TInt aSizeOfData2,TInt aNoOfSlots) |
|
135 |
: iBuf8(aBuf8),iBuf16(aBuf16),iHeap(aHeap),iRead(0),iWrite(0),iNoOfSlots(aNoOfSlots), |
|
136 |
iSizeOfData1(aSizeOfData1),iSizeOfData2(aSizeOfData2), |
|
137 |
iOverFlow(EFalse),iBufferFull(EFalse) |
|
138 |
{} |
|
139 |
||
140 |
CBuffer::~CBuffer() |
|
141 |
{ |
|
142 |
delete iBuf8; |
|
143 |
delete iBuf16; |
|
144 |
} |
|
145 |
||
146 |
TAny* CBuffer::operator new(TUint aSize,RHeap* aHeap) __NO_THROW |
|
147 |
// |
|
148 |
// overloaded new using the priority client heap - can leave |
|
149 |
// |
|
150 |
{ |
|
151 |
TAny *pM=NULL; |
|
152 |
TRAPD(err, pM=aHeap->AllocL(aSize) ); |
|
153 |
||
154 |
if(err!=KErrNone) |
|
155 |
pM = NULL; |
|
156 |
else |
|
157 |
Mem::FillZ(pM,aSize); |
|
158 |
return(pM); |
|
159 |
} |
|
160 |
||
161 |
TAny* CBuffer::operator new(TUint aSize) __NO_THROW |
|
162 |
{ |
|
163 |
return CBase::operator new(aSize); |
|
164 |
} |
|
165 |
||
166 |
TAny* CBuffer::operator new(TUint aSize,TLeave aLeave) |
|
167 |
{ |
|
168 |
return CBase::operator new(aSize,aLeave); |
|
169 |
} |
|
170 |
||
171 |
TAny* CBuffer::operator new(TUint aSize,TUint aExtraSize) __NO_THROW |
|
172 |
{ |
|
173 |
return CBase::operator new(aSize,aExtraSize); |
|
174 |
} |
|
175 |
||
176 |
void CBuffer::operator delete(TAny* aPtr) |
|
177 |
// |
|
178 |
// overloaded delete - deletes from priority client heap if iHeap not NULL |
|
179 |
// |
|
180 |
{ |
|
181 |
if (((CBuffer*)aPtr)->iHeap!=NULL) |
|
182 |
((CBuffer*)aPtr)->iHeap->Free(aPtr); |
|
183 |
else |
|
184 |
User::Free(aPtr); |
|
185 |
} |
|
186 |
||
187 |
TUint CBuffer::Size() const |
|
188 |
{ |
|
189 |
return iSizeOfData1 + iSizeOfData2; |
|
190 |
} |
|
191 |
||
192 |
void CBuffer::IncRead() |
|
193 |
{ |
|
194 |
if(++iRead==iNoOfSlots) |
|
195 |
iRead=0; |
|
196 |
iOverFlow=EFalse; |
|
197 |
iBufferFull=EFalse; |
|
198 |
LOGTEXT2("ETel:\tiRead incremented to %d", iRead); |
|
199 |
} |
|
200 |
||
201 |
void CBuffer::IncWrite() |
|
202 |
{ |
|
203 |
if(++iWrite==iNoOfSlots) |
|
204 |
iWrite=0; |
|
205 |
if (iOverFlow) |
|
206 |
iRead=iWrite; |
|
207 |
else |
|
208 |
{ |
|
209 |
if (!iBufferFull) |
|
210 |
{ |
|
211 |
if (iWrite==iRead) |
|
212 |
iBufferFull=ETrue; |
|
213 |
} |
|
214 |
else |
|
215 |
{ |
|
216 |
iRead=iWrite; |
|
217 |
iOverFlow=ETrue; |
|
218 |
} |
|
219 |
} |
|
220 |
LOGTEXT2("ETel:\tiWrite incremented to %d", iWrite); |
|
221 |
} |
|
222 |
||
223 |
TUint8* CBuffer::CurrentSlotData1(TWhichSlot aWhichSlot) const |
|
224 |
// |
|
225 |
// iSizeOfData1 and iSizeOfData2 include the sizes of the TPtr's |
|
226 |
// |
|
227 |
{ |
|
228 |
TInt pos=((aWhichSlot==ESlotRead) ? iRead : iWrite); |
|
229 |
||
230 |
if (iBuf8==NULL) |
|
231 |
{ |
|
232 |
return NULL; |
|
233 |
} |
|
234 |
else if (iBuf16==NULL) |
|
235 |
{ |
|
236 |
TInt slotSize = iSizeOfData1 + iSizeOfData2; |
|
237 |
return (const_cast<TUint8*> (iBuf8->Des().Mid(pos*(slotSize),iSizeOfData1-sizeof(TPtr8)).Ptr())); |
|
238 |
} |
|
239 |
else |
|
240 |
{ |
|
241 |
// we have a narrow and a unicode parameter. Data1 is always narrow |
|
242 |
return (const_cast<TUint8*> (iBuf8->Des().Mid(pos*iSizeOfData1,iSizeOfData1-sizeof(TPtr8)).Ptr())); |
|
243 |
} |
|
244 |
} |
|
245 |
||
246 |
TUint8* CBuffer::CurrentSlotData2(TWhichSlot aWhichSlot) const |
|
247 |
{ |
|
248 |
if (iSizeOfData2==0) |
|
249 |
return NULL; |
|
250 |
TInt pos=((aWhichSlot==ESlotRead) ? iRead : iWrite); |
|
251 |
||
252 |
if (iBuf8!=NULL && iBuf16==NULL) |
|
253 |
{ |
|
254 |
TInt slotSize = iSizeOfData1 + iSizeOfData2; |
|
255 |
return (const_cast<TUint8*> (iBuf8->Des().Mid(pos*(slotSize)+iSizeOfData1,iSizeOfData2-sizeof(TPtr8)).Ptr())); |
|
256 |
} |
|
257 |
||
258 |
return NULL; |
|
259 |
} |
|
260 |
||
261 |
TUint16* CBuffer::CurrentSlotData1u(TWhichSlot aWhichSlot) const |
|
262 |
// |
|
263 |
// Unicode version |
|
264 |
// |
|
265 |
{ |
|
266 |
TInt pos=((aWhichSlot==ESlotRead) ? iRead : iWrite); |
|
267 |
||
268 |
if (iBuf8==NULL && iBuf16!=NULL) |
|
269 |
{ |
|
270 |
TInt slotSize = iSizeOfData1 + iSizeOfData2; |
|
271 |
return (const_cast<TUint16*> (iBuf16->Des().Mid(pos*(slotSize),iSizeOfData1-sizeof(TPtr16)).Ptr())); |
|
272 |
} |
|
273 |
||
274 |
return NULL; // Data1 will be narrow if we have a mixture of both 8 and 16 bit |
|
275 |
} |
|
276 |
||
277 |
TUint16* CBuffer::CurrentSlotData2u(TWhichSlot aWhichSlot) const |
|
278 |
// |
|
279 |
// Unicode version |
|
280 |
// |
|
281 |
{ |
|
282 |
if (iSizeOfData2==0) |
|
283 |
return NULL; |
|
284 |
TInt pos=((aWhichSlot==ESlotRead) ? iRead : iWrite); |
|
285 |
||
286 |
if (iBuf16==NULL) |
|
287 |
{ |
|
288 |
return NULL; |
|
289 |
} |
|
290 |
else if (iBuf8==NULL) |
|
291 |
{ |
|
292 |
TInt slotSize = iSizeOfData1 + iSizeOfData2; |
|
293 |
return (const_cast<TUint16*> (iBuf16->Des().Mid(pos*(slotSize)+iSizeOfData1,iSizeOfData2-sizeof(TPtr16)).Ptr())); |
|
294 |
} |
|
295 |
else |
|
296 |
{ |
|
297 |
// we have a narrow and a unicode parameter. Data2 is always unicode |
|
298 |
return (const_cast<TUint16*> (iBuf16->Des().Mid(pos*iSizeOfData2,iSizeOfData2-sizeof(TPtr16)).Ptr())); |
|
299 |
} |
|
300 |
} |
|
301 |
||
302 |
TBool CBuffer::EqualSizes(TInt aSize1, TInt aSize2) const |
|
303 |
{ |
|
304 |
if(iSizeOfData1 != aSize1) |
|
305 |
{ |
|
306 |
return EFalse; |
|
307 |
} |
|
308 |
if(iSizeOfData2 != aSize2) |
|
309 |
{ |
|
310 |
return EFalse; |
|
311 |
} |
|
312 |
return ETrue; |
|
313 |
} |
|
314 |
||
315 |
TInt CBuffer::CompareRWPtrs() const |
|
316 |
{ |
|
317 |
return (iRead-iWrite); |
|
318 |
} |
|
319 |
||
320 |
// |
|
321 |
// |
|
322 |
// CTelObject class definitions |
|
323 |
// |
|
324 |
||
325 |
EXPORT_C CTelObject::CTelObject() |
|
326 |
// |
|
327 |
// CTelObject constructor |
|
328 |
// |
|
329 |
:iActiveReqCount(0), iTelServer(NULL), iDestroyDummySubSession(NULL), iCreateDummy(EFalse) |
|
330 |
{ |
|
331 |
__DECLARE_NAME(_S("CTelObject")); |
|
332 |
} |
|
333 |
||
334 |
EXPORT_C CTelObject::~CTelObject() |
|
335 |
// |
|
336 |
// Destructor |
|
337 |
// |
|
338 |
{ |
|
339 |
delete iDeliveryObject; |
|
340 |
delete iDestroyDummySubSession; |
|
341 |
} |
|
342 |
||
343 |
EXPORT_C void CTelObject::CTelObject_Reserved1() |
|
344 |
// |
|
345 |
// Reserved virtual function |
|
346 |
// |
|
347 |
{} |
|
348 |
||
349 |
void CTelObject::CreateDummySessionObjectL(CTelSession* aTelSession) |
|
350 |
{ |
|
351 |
if (iDestroyDummySubSession==NULL) |
|
352 |
{ |
|
353 |
LOGTEXT("CDestroyDummySubSession object does not already exist and will be created."); |
|
354 |
iDestroyDummySubSession = CDestroyDummySubSession::NewL(aTelSession->TelServer(),this); |
|
355 |
} |
|
356 |
else |
|
357 |
{ |
|
358 |
LOGTEXT("CDestroyDummySubSession object already exists and will not be created"); |
|
359 |
} |
|
360 |
||
361 |
} |
|
362 |
||
363 |
void CTelObject::CreateDummySession(CTelSession* aSession, const TInt aSubSessionHandle, TBool aCreateDummy) |
|
364 |
// |
|
365 |
// So the server has to create a dummy session just to keep session alive until completed |
|
366 |
// function is called. |
|
367 |
// |
|
368 |
{ |
|
369 |
LOGTEXT2("CreateDummySession() with iDestroyDummySubSession = %x", iDestroyDummySubSession); |
|
370 |
iCreateDummy=aCreateDummy; |
|
371 |
||
372 |
if (iDestroyDummySubSession->iOpen == EFalse) |
|
373 |
{ |
|
374 |
if ( IsActiveReq(aSession,aSubSessionHandle) || aCreateDummy) |
|
375 |
{ |
|
376 |
LOGTEXT("About to create dummy session"); |
|
377 |
__ASSERT_ALWAYS(aSession!=NULL,Fault(EEtelFaultBadTelSessionPointer)); |
|
378 |
CObject* theObj=this; |
|
379 |
while(theObj->Owner()) |
|
380 |
{ |
|
381 |
theObj->Open(); |
|
382 |
theObj=theObj->Owner(); |
|
383 |
} |
|
384 |
theObj->Open(); |
|
385 |
iTelServer=aSession->TelServer(); |
|
386 |
||
387 |
// incrementing the server's session count to include the dummy session, which |
|
388 |
// has been previously allocated upon the CTelObject creation (by calling |
|
389 |
// CreateDummySessionObjectL() ) |
|
390 |
iTelServer->Inc(); |
|
391 |
LOGTEXT2("Added a Dummy Session, producing server's session count of %d", iTelServer->Count()); |
|
392 |
||
393 |
iDestroyDummySubSession->iTelServer = iTelServer; |
|
394 |
iDestroyDummySubSession->iTelObject = this; |
|
395 |
iDestroyDummySubSession->iOpen = ETrue; |
|
396 |
} |
|
397 |
} |
|
398 |
} |
|
399 |
||
400 |
void CTelObject::TelObjectClose() |
|
401 |
// |
|
402 |
// Perform an iterative close of Tel Objects |
|
403 |
// |
|
404 |
{ |
|
405 |
CTelObject* owner = reinterpret_cast<CTelObject*> (Owner()); |
|
406 |
Close(); |
|
407 |
if(owner) |
|
408 |
owner->TelObjectClose(); |
|
409 |
} |
|
410 |
||
411 |
void CTelObject::CompleteAndDestroyReq(CReqEntry* aReqEntry,const TInt aStatus) const |
|
412 |
// |
|
413 |
// complete the entry and remove from entry list and associate heap |
|
414 |
// |
|
415 |
{ |
|
416 |
if (!aReqEntry->iMessageNulled) |
|
417 |
{ |
|
418 |
RECORD_COMPLETE_SUB(aReqEntry->iMessage.Session(), this, aReqEntry->iMessage.Int3(), aReqEntry->iMessage.Function(), aStatus); |
|
419 |
aReqEntry->iMessage.Complete(aStatus); |
|
420 |
} |
|
421 |
DestroyReq(aReqEntry); |
|
422 |
} |
|
423 |
||
424 |
void CTelObject::DestroyReq(CReqEntry* aReqEntry) const |
|
425 |
// |
|
426 |
// remove from entry list and associate heap |
|
427 |
// |
|
428 |
{ |
|
429 |
aReqEntry->Deque(); |
|
430 |
delete aReqEntry; |
|
431 |
} |
|
432 |
||
433 |
TBool CTelObject::IsActiveReq(CTelSession* aSession,const TInt aSubSessionHandle) |
|
434 |
// |
|
435 |
// Return True if found the active req still out standing |
|
436 |
// going through and counting the total of active req |
|
437 |
// |
|
438 |
{ |
|
439 |
TBool ret=EFalse; |
|
440 |
CReqEntry* reqEntry=NULL; |
|
441 |
TDblQueIter<CReqEntry> iter(PhoneOwner()->ReqActiveList()); |
|
442 |
while(reqEntry=iter++,reqEntry!=NULL) // go through the list from begin to end |
|
443 |
{ |
|
444 |
if (aSession==reqEntry->iSession && aSubSessionHandle==reqEntry->iMessage.Int3() && reqEntry->iClientInterested ) |
|
445 |
{ |
|
446 |
iActiveReqCount++; |
|
447 |
ret=ETrue; |
|
448 |
} |
|
449 |
} |
|
450 |
LOGTEXT2("IsActiveReq found %d active reqs", iActiveReqCount); |
|
451 |
return ret; |
|
452 |
} |
|
453 |
||
454 |
void CTelObject::CancelActiveReq(CTelSession* aSession,const TInt aSubSessionHandle) |
|
455 |
// |
|
456 |
// active list - must inform tsy by calling CancelService |
|
457 |
// this request will be destroyed when Tsy do an up call ReqCompleted with KErrCancel |
|
458 |
// Only go through the list once set the count to zero at start to count number of requests |
|
459 |
// |
|
460 |
{ |
|
461 |
LOGTEXT("Entered CancelActiveReq"); |
|
462 |
CReqEntry* reqEntry=NULL; |
|
463 |
TDblQueIter<CReqEntry> iter(PhoneOwner()->ReqActiveList()); |
|
464 |
while(reqEntry=iter++,reqEntry!=NULL) // go through the list from begin to end |
|
465 |
{ |
|
466 |
if (aSession==reqEntry->iSession && aSubSessionHandle==reqEntry->iMessage.Int3() && reqEntry->iClientInterested ) |
|
467 |
{ |
|
468 |
reqEntry->iClientInterested=EFalse; |
|
469 |
__ASSERT_ALWAYS(iActiveReqCount>=0,Fault(EEtelFaultNegativeActiveReqCount)); |
|
470 |
if (reqEntry->iCancelFnCalled==FALSE) |
|
471 |
{ |
|
472 |
TReqMode reqMode = reqEntry->iReqMode; |
|
473 |
||
474 |
if (reqEntry->iPlacedRequest) |
|
475 |
{ |
|
476 |
LOGTEXT2("Calling Cancel Service ActiveReq TsyReq=%d", reqEntry->iTsyReqHandle); |
|
477 |
reqEntry->iCancelFnCalled=ETrue; |
|
478 |
CancelService(reqEntry->iFunction,reqEntry->iTsyReqHandle); |
|
479 |
||
480 |
// |
|
481 |
// In calling CancelService() it is possible that a second |
|
482 |
// handle has performed the same request (e.g. a notify) and |
|
483 |
// that ETel will re-post the notify using that handle. In |
|
484 |
// some cases it could happen that the re-posted notify is |
|
485 |
// invalid and fails, thereby completing that next request. |
|
486 |
// Finally, if that request is the next one after this one, |
|
487 |
// then the iterator is going to be invalid. So reset it now |
|
488 |
// and start at the beginning of the list! |
|
489 |
// |
|
490 |
if (PhoneOwner()->ReqActiveList().IsEmpty() == EFalse) |
|
491 |
{ |
|
492 |
iter.Set(*PhoneOwner()->ReqActiveList().First()); |
|
493 |
} |
|
494 |
else |
|
495 |
{ |
|
496 |
break; |
|
497 |
} |
|
498 |
} |
|
499 |
else |
|
500 |
{ |
|
501 |
if (reqMode&KReqModeMultipleCompletionWithInterestLevel && iDeliveryObject) |
|
502 |
{ |
|
503 |
iDeliveryObject->DeletedReqEntry(reqEntry); |
|
504 |
} |
|
505 |
||
506 |
LOGTEXT("Destroying request"); |
|
507 |
DestroyReq(reqEntry); |
|
508 |
CheckAndDestroyDummySubSession(); |
|
509 |
} |
|
510 |
} |
|
511 |
} |
|
512 |
} |
|
513 |
} |
|
514 |
||
515 |
void CTelObject::CancelSubSession(CTelSession* aSession,const TInt aSubSessionHandle) |
|
516 |
// |
|
517 |
// Flush outstanding requests from the queue for this client only |
|
518 |
// Cancel the service if request already passed to Tsy |
|
519 |
// |
|
520 |
{ |
|
521 |
CReqEntry* reqEntry=NULL; |
|
522 |
while (reqEntry=PhoneOwner()->FindClientReqInWaitList(aSession,aSubSessionHandle),reqEntry) |
|
523 |
CompleteAndDestroyReq(reqEntry,KErrCancel); |
|
524 |
||
525 |
CancelActiveReq(aSession,aSubSessionHandle); |
|
526 |
} |
|
527 |
||
528 |
void CTelObject::FlushReqs(CTelSession* aSession,const TInt aSubSessionHandle) |
|
529 |
// |
|
530 |
// Flush outstanding requests from the queue for this client only |
|
531 |
// Cancel the service if request already passed to Tsy |
|
532 |
// Return ETrue if it have to create a dummy session |
|
533 |
// |
|
534 |
{ |
|
535 |
CReqEntry* reqEntry=NULL; |
|
536 |
// wait list |
|
537 |
while (reqEntry=PhoneOwner()->FindClientReqInWaitList(aSession,aSubSessionHandle),reqEntry) |
|
538 |
DestroyReq(reqEntry); |
|
539 |
||
540 |
CancelActiveReq(aSession,aSubSessionHandle); |
|
541 |
||
542 |
} |
|
543 |
||
544 |
CPhoneBase* CTelObject::PhoneOwner() const |
|
545 |
// |
|
546 |
// Get the owner handle |
|
547 |
// |
|
548 |
{ |
|
549 |
return iPhoneOwner; |
|
550 |
} |
|
551 |
||
552 |
void CTelObject::SetPhoneOwner(CPhoneBase* aPhoneOwner) |
|
553 |
// |
|
554 |
// Set the owner of phone |
|
555 |
// |
|
556 |
{ |
|
557 |
iPhoneOwner=aPhoneOwner; |
|
558 |
} |
|
559 |
||
560 |
void CTelObject::GetMessageDescriptorSizes(const RMessage2& aMessage,TInt &aSize1, TInt &aSize2) const |
|
561 |
{ |
|
562 |
TInt messageType=aMessage.Int1(); |
|
563 |
aSize1=0; |
|
564 |
aSize2=0; |
|
565 |
||
566 |
if (messageType!=EIsaNull && |
|
567 |
messageType!=EIsaCancelMessage && |
|
568 |
messageType!=EIsPriorityClientReqWithNull) |
|
569 |
{ // we're going to create server-side buffer |
|
570 |
TInt basicMsgType = messageType&(~(KUnicodeReq|KPriorityClientReq)); |
|
571 |
||
572 |
if (messageType==EIsaNarrowAndUnicodeDoubleDesTobeSet) |
|
573 |
basicMsgType=EIsaDoubleDesTobeSet; |
|
574 |
if (messageType==EIsaNarrowAndUnicodeDoubleDesTobeRead) |
|
575 |
basicMsgType=EIsaDoubleDesTobeRead; |
|
576 |
||
577 |
switch (basicMsgType) |
|
578 |
{ |
|
579 |
case EIsaDoubleDesTobeSet:// if we're setting data, get length |
|
580 |
aSize2=aMessage.GetDesLength(2); // no break |
|
581 |
case EIsaDesTobeSet: |
|
582 |
aSize1=aMessage.GetDesLength(0); |
|
583 |
break; |
|
584 |
case EIsaDoubleDesTobeRead:// if we're reading data, get max length |
|
585 |
aSize2=aMessage.GetDesMaxLength(2); // no break |
|
586 |
case EIsaDesTobeRead: |
|
587 |
aSize1=aMessage.GetDesMaxLength(0); |
|
588 |
break; |
|
589 |
case EIsaNarrowDesToSetAndGet: |
|
590 |
aSize1=aMessage.GetDesLength(0); // set data |
|
591 |
aSize2=aMessage.GetDesMaxLength(2); // get data |
|
592 |
break; |
|
593 |
case EIsaNarrowDesToGetUnicodeDesToSet: |
|
594 |
aSize1=aMessage.GetDesMaxLength(0); // get data |
|
595 |
aSize2=aMessage.GetDesLength(2); // set data |
|
596 |
break; |
|
597 |
case EIsaUnicodeDesToSetAndGet: |
|
598 |
aSize1=aMessage.GetDesLength(0); // set data |
|
599 |
aSize2=aMessage.GetDesMaxLength(2); // get data |
|
600 |
break; |
|
601 |
case EIsaUnicodeDesToGetNarrowDesToSet: |
|
602 |
aSize1=aMessage.GetDesLength(0); // set data |
|
603 |
aSize2=aMessage.GetDesMaxLength(2); // get data |
|
604 |
break; |
|
605 |
default: |
|
606 |
PanicClient(EEtelPanicInvalidRequestType,aMessage); |
|
607 |
break; |
|
608 |
} |
|
609 |
} |
|
610 |
} |
|
611 |
||
612 |
TBool CTelObject::IsSameMessageType(const RMessage2& aMessage,CReqEntry* aReqEntry) const |
|
613 |
{ |
|
614 |
TInt size1; |
|
615 |
TInt size2; |
|
616 |
TInt ptrSize=sizeof(TPtr8); |
|
617 |
GetMessageDescriptorSizes(aMessage, size1, size2); |
|
618 |
||
619 |
if(size1) |
|
620 |
{ |
|
621 |
CheckAndResize(size1,aMessage); |
|
622 |
size1+=ptrSize; |
|
623 |
} |
|
624 |
if (size2) |
|
625 |
{ |
|
626 |
CheckAndResize(size2,aMessage); |
|
627 |
size2+=ptrSize; |
|
628 |
} |
|
629 |
if(aReqEntry->iBuffer->EqualSizes(size1,size2)) |
|
630 |
{ |
|
631 |
return ETrue; |
|
632 |
} |
|
633 |
return EFalse; |
|
634 |
} |
|
635 |
||
636 |
void CTelObject::CompleteOrBufferRead(const RMessage2& aMessage, CReqEntry* aReqEntry) |
|
637 |
// |
|
638 |
// Check and complete if possible this notification/multislot command from |
|
639 |
// this subsession in the ReqActive list |
|
640 |
// aMessage is the message just received from the client |
|
641 |
// aReqEntry is the Entry previously created when the same client called the same function |
|
642 |
// |
|
643 |
{ |
|
644 |
if(aReqEntry->iMessageNulled==FALSE) // same client already posted this notification |
|
645 |
{ |
|
646 |
PanicClient(EEtelPanicRequestAsyncTwice,aMessage); |
|
647 |
return; |
|
648 |
} |
|
649 |
TInt slots=0; |
|
650 |
TRAP_IGNORE(slots = NumberOfSlotsL(aReqEntry->iFunction)); |
|
651 |
TBool sameMessageType = IsSameMessageType(aMessage, aReqEntry); |
|
652 |
||
653 |
if (slots>1) |
|
654 |
{ |
|
655 |
TInt comparison = aReqEntry->iBuffer->CompareRWPtrs(); |
|
656 |
if (comparison==0 && aReqEntry->iBuffer->BufferFull()==FALSE) |
|
657 |
{ // if the client has already read value,the automatic server-TSY |
|
658 |
// notify request becomes the "true" request |
|
659 |
if(sameMessageType) |
|
660 |
{ |
|
661 |
aReqEntry->iMessage=aMessage; |
|
662 |
aReqEntry->iMessageNulled=EFalse; |
|
663 |
} |
|
664 |
else |
|
665 |
{ |
|
666 |
// cancel in ctsy |
|
667 |
aReqEntry->iCancelFnCalled = ETrue; |
|
668 |
CancelService(aReqEntry->iFunction, aReqEntry->iTsyReqHandle); |
|
669 |
aReqEntry->iCancelFnCalled = EFalse; |
|
670 |
GeneralReq(aMessage,aReqEntry->iSession,NULL); |
|
671 |
} |
|
672 |
} |
|
673 |
else |
|
674 |
{ |
|
675 |
if (aReqEntry->iBuffer->OverFlow()) |
|
676 |
WriteBackAndCompleteBufferedReq(aMessage,aReqEntry,KErrOverflow); |
|
677 |
else |
|
678 |
{ |
|
679 |
if(sameMessageType) |
|
680 |
{ |
|
681 |
WriteBackAndCompleteBufferedReq(aMessage,aReqEntry,KErrNone); |
|
682 |
} |
|
683 |
else |
|
684 |
{ |
|
685 |
WriteBackAndCompleteBufferedReq(aMessage,aReqEntry,KErrOverflow); |
|
686 |
} |
|
687 |
} |
|
688 |
} |
|
689 |
} |
|
690 |
else // this is a non-registered notification (ie single-slot) |
|
691 |
{ |
|
692 |
if(aReqEntry->iReadByClient) |
|
693 |
{ |
|
694 |
if(sameMessageType) |
|
695 |
{ |
|
696 |
aReqEntry->iMessage=aMessage; |
|
697 |
aReqEntry->iMessageNulled=EFalse; |
|
698 |
} |
|
699 |
else |
|
700 |
{ |
|
701 |
CancelService(aReqEntry->iFunction, aReqEntry->iTsyReqHandle); |
|
702 |
GeneralReq(aMessage,aReqEntry->iSession,NULL); |
|
703 |
} |
|
704 |
} |
|
705 |
else // Client has not read this new value yet |
|
706 |
{ |
|
707 |
if(sameMessageType) |
|
708 |
{ |
|
709 |
WriteBackAndCompleteBufferedReq(aMessage,aReqEntry,KErrNone); |
|
710 |
} |
|
711 |
else |
|
712 |
{ |
|
713 |
WriteBackAndCompleteBufferedReq(aMessage,aReqEntry,KErrOverflow); |
|
714 |
} |
|
715 |
} |
|
716 |
} |
|
717 |
} |
|
718 |
||
719 |
void CTelObject::CheckAndResize(TInt& aSizeOfData,const RMessage2& aMessage) const |
|
720 |
// |
|
721 |
// Checks that size of data is non-zero - if not, panic client. |
|
722 |
// Also checks that size of data is word-aligned, ie a multiple of 4 bytes. |
|
723 |
// If not, ensure that in the space in buffer for data is word-aligned. |
|
724 |
// |
|
725 |
{ |
|
726 |
if(aSizeOfData<0) |
|
727 |
PanicClient(EEtelPanicDesLengthNegative,aMessage); |
|
728 |
aSizeOfData=(aSizeOfData+3)&~3; |
|
729 |
} |
|
730 |
||
731 |
HEtelBufC8* CTelObject::CreateNarrowBufferLC(RHeap* aHeap,const RMessage2& aMessage,TUint aIndexOfClientPtr1,TUint aIndexOfClientPtr2,TInt& aSize1,TInt& aSize2,TInt aNoOfSlots) const |
|
732 |
// |
|
733 |
// aSize1 = size of 1st descriptor buffer |
|
734 |
// aSize2 = size of 2nd descriptor buffer (default=0) |
|
735 |
// aHeap may be NULL if the priority heap is not to be used |
|
736 |
// aNoOfSlots will usually be 1. Only if this request is a notification that requires |
|
737 |
// registering, ie increasing the number of events the server will buffer, will it be greater than 1 |
|
738 |
// |
|
739 |
{ |
|
740 |
TInt desSize1=aSize1; |
|
741 |
TInt desSize2=aSize2; |
|
742 |
CheckAndResize(aSize1,aMessage); |
|
743 |
||
744 |
TInt ptrSize=sizeof(TPtr8); |
|
745 |
TInt allocSize=aSize1+ptrSize; |
|
746 |
if (aSize2) |
|
747 |
{ |
|
748 |
CheckAndResize(aSize2,aMessage); |
|
749 |
allocSize += aSize2+ptrSize; |
|
750 |
} |
|
751 |
HEtelBufC8* buf = HEtelBufC8::NewMaxLC(allocSize*aNoOfSlots,aHeap); // allocate a buffer for the Des and Data |
|
752 |
||
753 |
TPtr8 firstptrDes1(const_cast<TUint8*> (buf->Des().Left(ptrSize).Ptr()),ptrSize,ptrSize); // carve the thing up |
|
754 |
TPtr8 firstdataDes1(const_cast<TUint8*> (buf->Des().Mid(ptrSize,aSize1).Ptr()),desSize1,desSize1); |
|
755 |
TPtr8 firstdataDes2(NULL,0,0); |
|
756 |
aMessage.ReadL(aIndexOfClientPtr1,firstdataDes1);// Read the Data. If it leaves, buf will be cleaned up |
|
757 |
firstptrDes1.Copy(reinterpret_cast<TUint8*> (&firstdataDes1),ptrSize); // Copy the new Des |
|
758 |
if (aSize2) |
|
759 |
// Construct Second descriptor |
|
760 |
{ |
|
761 |
TPtr8 firstptrDes2(const_cast<TUint8*> (buf->Des().Mid(ptrSize+aSize1,ptrSize).Ptr()),ptrSize,ptrSize); |
|
762 |
firstdataDes2.Set(const_cast<TUint8*> (buf->Des().Mid((ptrSize*2)+aSize1,aSize2).Ptr()),desSize2,desSize2); |
|
763 |
aMessage.ReadL(aIndexOfClientPtr2,firstdataDes2); |
|
764 |
firstptrDes2.Copy(reinterpret_cast<TUint8*> (&firstdataDes2),ptrSize); |
|
765 |
} |
|
766 |
for (TInt i=1; i<aNoOfSlots;i++) |
|
767 |
{// Copy descriptors into each slot |
|
768 |
TPtr8 ptrDes1(const_cast<TUint8*> (buf->Des().Mid(i*allocSize,ptrSize).Ptr()),ptrSize,ptrSize); |
|
769 |
TPtr8 dataDes1(const_cast<TUint8*> (buf->Des().Mid(i*allocSize+ptrSize,aSize1).Ptr()),desSize1,desSize1); |
|
770 |
dataDes1.Copy(firstdataDes1); |
|
771 |
ptrDes1.Copy(reinterpret_cast<TUint8*> (&dataDes1),ptrSize); |
|
772 |
if (aSize2) |
|
773 |
{ |
|
774 |
TPtr8 ptrDes2(const_cast<TUint8*> (buf->Des().Mid(i*allocSize+ptrSize+aSize1,ptrSize).Ptr()),ptrSize,ptrSize); |
|
775 |
TPtr8 dataDes2(const_cast<TUint8*> (buf->Des().Mid(i*allocSize+(ptrSize*2)+aSize1).Ptr()),desSize2,desSize2); |
|
776 |
dataDes2.Copy(firstdataDes2); |
|
777 |
ptrDes2.Copy(reinterpret_cast<TUint8*> (&dataDes2),ptrSize); |
|
778 |
} |
|
779 |
} |
|
780 |
return buf; |
|
781 |
} |
|
782 |
||
783 |
HEtelBufC16* CTelObject::CreateUnicodeBufferLC(RHeap* aHeap,const RMessage2& aMessage,TUint aIndexOfClientPtr1,TUint aIndexOfClientPtr2,TInt& aSize1,TInt& aSize2,TInt aNoOfSlots) const |
|
784 |
// |
|
785 |
// We place both parameters in the same buffer which is either narrow or unicode (unicode in this case) |
|
786 |
// Should a function ever require one parameter to be narrow and the other unicode, |
|
787 |
// will need to review. |
|
788 |
// |
|
789 |
{ |
|
790 |
TInt desSize1=aSize1; |
|
791 |
TInt desSize2=aSize2; |
|
792 |
CheckAndResize(aSize1,aMessage); |
|
793 |
TInt ptrSize=sizeof(TPtr16); |
|
794 |
TInt allocSize=aSize1+ptrSize; |
|
795 |
if (aSize2) |
|
796 |
{ |
|
797 |
CheckAndResize(aSize2,aMessage); |
|
798 |
allocSize += aSize2+ptrSize; |
|
799 |
} |
|
800 |
HEtelBufC16* buf = HEtelBufC16::NewMaxLC(allocSize*aNoOfSlots,aHeap); // allocate a buffer for the Des and Data |
|
801 |
||
802 |
TPtr16 firstptrDes1(const_cast<TUint16*> (buf->Des().Left(ptrSize).Ptr()),ptrSize,ptrSize); // carve the thing up |
|
803 |
TPtr16 firstdataDes1(const_cast<TUint16*> (buf->Des().Mid(ptrSize,aSize1).Ptr()),desSize1,desSize1); |
|
804 |
TPtr16 firstdataDes2(NULL,0,0); |
|
805 |
aMessage.ReadL(aIndexOfClientPtr1,firstdataDes1);// Read the Data. If it leaves, buf will be cleaned up |
|
806 |
firstptrDes1.Copy(reinterpret_cast<TUint16*> (&firstdataDes1),ptrSize); // Copy the new Des |
|
807 |
if (aSize2) |
|
808 |
// Construct Second descriptor |
|
809 |
{ |
|
810 |
TPtr16 firstptrDes2(const_cast<TUint16*> (buf->Des().Mid(ptrSize+aSize1,ptrSize).Ptr()),ptrSize,ptrSize); |
|
811 |
firstdataDes2.Set(const_cast<TUint16*> (buf->Des().Mid((ptrSize*2)+aSize1,aSize2).Ptr()),desSize2,desSize2); |
|
812 |
aMessage.ReadL(aIndexOfClientPtr2,firstdataDes2); |
|
813 |
firstptrDes2.Copy(reinterpret_cast<TUint16*> (&firstdataDes2),ptrSize); |
|
814 |
} |
|
815 |
for (TInt i=1; i<aNoOfSlots;i++) |
|
816 |
{// Copy descriptors into each slot |
|
817 |
TPtr16 ptrDes1(const_cast<TUint16*> (buf->Des().Mid(i*allocSize,ptrSize).Ptr()),ptrSize,ptrSize); |
|
818 |
TPtr16 dataDes1(const_cast<TUint16*> (buf->Des().Mid(i*allocSize+ptrSize,aSize1).Ptr()),desSize1,desSize1); |
|
819 |
dataDes1.Copy(firstdataDes1); |
|
820 |
ptrDes1.Copy(reinterpret_cast<TUint16*> (&dataDes1),ptrSize); |
|
821 |
if (aSize2) |
|
822 |
{ |
|
823 |
TPtr16 ptrDes2(const_cast<TUint16*> (buf->Des().Mid(i*allocSize+ptrSize+aSize1,ptrSize).Ptr()),ptrSize,ptrSize); |
|
824 |
TPtr16 dataDes2(const_cast<TUint16*> (buf->Des().Mid(i*allocSize+(ptrSize*2)+aSize1).Ptr()),desSize2,desSize2); |
|
825 |
dataDes2.Copy(firstdataDes2); |
|
826 |
ptrDes2.Copy(reinterpret_cast<TUint16*> (&dataDes2),ptrSize); |
|
827 |
} |
|
828 |
} |
|
829 |
return buf; |
|
830 |
} |
|
831 |
||
832 |
CReqEntry* CTelObject::ReqAnalyserL(const RMessage2& aMessage,CTelSession* aSession,TReqMode& aReqMode) |
|
833 |
// |
|
834 |
// Analyse the request. First search for an entry from the same client for the same request, |
|
835 |
// and if found either panic if this is a non-buffered request(ie the request is already |
|
836 |
// pending) or look at the buffer to see if there is any unread data to complete with. |
|
837 |
// If the identical entry was not found and this is a request of type multiple completion, search |
|
838 |
// for a similar one by a different client (on this TelObject) and if found simply create a new |
|
839 |
// entry with the same request handle that will be completed at the same time as the current |
|
840 |
// posted notification. |
|
841 |
// If this request has not been found in the active or wait lists, create the necessary |
|
842 |
// address space on server side |
|
843 |
// |
|
844 |
{ |
|
845 |
HEtelBufC8* buf8=NULL; |
|
846 |
HEtelBufC16* buf16=NULL; |
|
847 |
CReqEntry* reqEntry=NULL; |
|
848 |
||
849 |
reqEntry = PhoneOwner()->FindSameClientEntry(aSession,aMessage.Int3(),aMessage.Function()); |
|
850 |
if (reqEntry) |
|
851 |
{ |
|
852 |
if (aReqMode&KReqModeRePostImmediately) |
|
853 |
{ |
|
854 |
// same notification/buffered command has been found |
|
855 |
// and either the read has completed or it has been stored in |
|
856 |
// the request entry waiting for the completion from the TSY. |
|
857 |
CompleteOrBufferRead(aMessage,reqEntry); |
|
858 |
} |
|
859 |
else // found an outstanding async req - panic |
|
860 |
{ |
|
861 |
PanicClient(EEtelPanicRequestAsyncTwice,aMessage); |
|
862 |
} |
|
863 |
return NULL; |
|
864 |
} |
|
865 |
TInt messageType=aMessage.Int1(); |
|
866 |
TInt noOfSlots = 1; |
|
867 |
if (aReqMode&KReqModeRePostImmediately) |
|
868 |
noOfSlots = NumberOfSlotsL(aMessage.Function()); |
|
869 |
TInt size1; |
|
870 |
TInt size2; |
|
871 |
if (messageType!=EIsaNull && |
|
872 |
messageType!=EIsaCancelMessage && |
|
873 |
messageType!=EIsPriorityClientReqWithNull) |
|
874 |
{ // we're going to create server-side buffer |
|
875 |
GetMessageDescriptorSizes(aMessage, size1, size2); |
|
876 |
if (size1<0 || size2<0) |
|
877 |
{ |
|
878 |
PanicClient(EEtelPanicBadDescriptor,aMessage); |
|
879 |
return NULL; |
|
880 |
} |
|
881 |
if (messageType==EIsaNarrowAndUnicodeDoubleDesTobeSet || |
|
882 |
messageType==EIsaNarrowAndUnicodeDoubleDesTobeRead || |
|
883 |
messageType==EIsaNarrowDesToGetUnicodeDesToSet || |
|
884 |
messageType==EIsaUnicodeDesToGetNarrowDesToSet) |
|
885 |
{ |
|
886 |
TInt zeroSize=0; |
|
887 |
||
888 |
buf8 = CreateNarrowBufferLC(aSession->EmergencyClientHeap(messageType),aMessage,0,2,size1,zeroSize,noOfSlots); |
|
889 |
buf16 = CreateUnicodeBufferLC(aSession->EmergencyClientHeap(messageType),aMessage,2,NULL,size2,zeroSize,noOfSlots); // the second client parameter pointer is passed as the first, so that the second parameter will be copied as the first |
|
890 |
} |
|
891 |
else |
|
892 |
if (messageType==EIsaUnicodeDesToSetAndGet) |
|
893 |
buf16 = CreateUnicodeBufferLC(aSession->EmergencyClientHeap(messageType),aMessage,0,2,size1,size2,noOfSlots); |
|
894 |
||
895 |
else |
|
896 |
if (!(aSession->IsUnicodeReq(messageType))) |
|
897 |
buf8 = CreateNarrowBufferLC(aSession->EmergencyClientHeap(messageType),aMessage,0,2,size1,size2,noOfSlots); |
|
898 |
||
899 |
else |
|
900 |
buf16 = CreateUnicodeBufferLC(aSession->EmergencyClientHeap(messageType),aMessage,0,2,size1,size2,noOfSlots); |
|
901 |
size1+=sizeof(TPtr); // passed into CBuffer::NewL() later as these sizes |
|
902 |
if (size2!=0) // remain zero otherwise |
|
903 |
size2+=sizeof(TPtr); //sizeof(TPtr)==sizeof(TPtr8)==sizeof(TPtr16) |
|
904 |
} |
|
905 |
else |
|
906 |
{ |
|
907 |
size1 = 0; |
|
908 |
size2 = 0; |
|
909 |
} |
|
910 |
// |
|
911 |
// Now create the wrapper class, which manages the circular buffer. |
|
912 |
// |
|
913 |
CBuffer* buffer = CBuffer::NewL(buf8,buf16,aSession->EmergencyClientHeap(messageType),size1,size2,noOfSlots); |
|
914 |
if (buf8) |
|
915 |
CleanupStack::Pop(); // pops HEtelBufC8 off cleanup stack |
|
916 |
if (buf16) |
|
917 |
CleanupStack::Pop(); // pops HEtelBufC16 off cleanup stack |
|
918 |
CleanupStack::PushL(buffer); // since buffer is still not owned by anything |
|
919 |
// |
|
920 |
// Now create the request entry for this client request - even if it's not to be passed |
|
921 |
// down to the TSY in the case of MultipleCompletion. |
|
922 |
// |
|
923 |
reqEntry=PhoneOwner()->NewReqL(aMessage,aSession,buffer,this,aMessage.Function()); |
|
924 |
CleanupStack::Pop(); |
|
925 |
||
926 |
reqEntry->iInterestCategory = FindInterestCategory(aMessage.SecureId()); |
|
927 |
||
928 |
if ( aReqMode & (KReqModeMultipleCompletionEnabled | KReqModeMultipleCompletionWithInterestLevel) ) |
|
929 |
// this client has not currently got this request outstanding but another client may have |
|
930 |
{ |
|
931 |
CReqEntry* previousReq=NULL; |
|
932 |
previousReq=PhoneOwner()->FindByIpcAndTelObject(aMessage.Function(),this, buffer->Size()); // search in active list |
|
933 |
if (previousReq) |
|
934 |
{ |
|
935 |
reqEntry->iTsyReqHandle=previousReq->iTsyReqHandle; |
|
936 |
reqEntry->iReqMode=aReqMode; |
|
937 |
PhoneOwner()->AddReqToActive(reqEntry); |
|
938 |
reqEntry=NULL; |
|
939 |
} |
|
940 |
else if (aReqMode&KReqModeFlowControlObeyed) |
|
941 |
{ |
|
942 |
previousReq=PhoneOwner()->FindByIpcAndTelObjectInWaiting(aMessage.Function(),this, buffer->Size()); |
|
943 |
if (previousReq) |
|
944 |
{ |
|
945 |
reqEntry->iTsyReqHandle=previousReq->iTsyReqHandle; |
|
946 |
reqEntry->iReqMode=aReqMode; |
|
947 |
PhoneOwner()->AddReqToWaiting(reqEntry); |
|
948 |
reqEntry=NULL; |
|
949 |
} |
|
950 |
} |
|
951 |
} |
|
952 |
return reqEntry; |
|
953 |
} |
|
954 |
||
955 |
void CTelObject::GeneralReq(const RMessage2& aMessage,CTelSession* aSession,CReqEntry* aNewReqEntry, TBool aFromFlowControlResume) |
|
956 |
// |
|
957 |
// On any CTelObject based class, do the general processing around sequential and parallel |
|
958 |
// request modes for the server, before calling the pure virtual Service in the class to do |
|
959 |
// the actual command. |
|
960 |
// |
|
961 |
{ |
|
962 |
||
963 |
LOGTEXT2("CTelObject::GeneralReq - IPC=%d", aMessage.Function()); |
|
964 |
RECORD_IPC(aMessage,aSession,this,aFromFlowControlResume); |
|
965 |
if (aFromFlowControlResume && !aFromFlowControlResume){ ; } // avoid compiler warning when ETEL_RECORDER is not defined |
|
966 |
||
967 |
TInt type=aMessage.Int1(); |
|
968 |
CReqEntry* reqEntry=NULL; |
|
969 |
TInt basicMsgType = type&(~(KUnicodeReq|KPriorityClientReq)); |
|
970 |
switch(basicMsgType) |
|
971 |
{ |
|
972 |
case EIsaNull: |
|
973 |
case EIsaDesTobeSet: |
|
974 |
case EIsaDesTobeRead: |
|
975 |
case EIsaDoubleDesTobeSet: |
|
976 |
case EIsaDoubleDesTobeRead: |
|
977 |
case EIsaNarrowAndUnicodeDoubleDesTobeSet: |
|
978 |
case EIsaNarrowAndUnicodeDoubleDesTobeRead: |
|
979 |
case EIsaNarrowDesToSetAndGet: |
|
980 |
case EIsaNarrowDesToGetUnicodeDesToSet: |
|
981 |
case EIsaUnicodeDesToSetAndGet: |
|
982 |
case EIsaUnicodeDesToGetNarrowDesToSet: |
|
983 |
{ |
|
984 |
TInt ipc=aMessage.Function(); |
|
985 |
||
986 |
TReqMode reqMode=0; |
|
987 |
TRAPD(res,(reqMode=ReqModeL(ipc))); |
|
988 |
if (res) |
|
989 |
{ |
|
990 |
RECORD_COMPLETE_SUB(aMessage.Session(), this, aMessage.Int3(), aMessage.Function(), res); |
|
991 |
aMessage.Complete(res); |
|
992 |
return; |
|
993 |
} |
|
994 |
||
995 |
// If a call is session based then it can only be used |
|
996 |
// when the client is the session owner. |
|
77 | 997 |
if ( (reqMode&KReqModeSessionBased && IsSessionInProgress()) |
998 |
&& (aMessage.Int3() != iDeliveryObject->iSessionOwner.iSubSessionId) ) |
|
24 | 999 |
{ |
1000 |
// Each type of session only allowed to have one ongoing 'session/dialogue'. |
|
1001 |
RECORD_COMPLETE_SUB(aMessage.Session(), this, aMessage.Int3(), aMessage.Function(), res); |
|
1002 |
aMessage.Complete(KErrServerBusy); |
|
1003 |
return; |
|
1004 |
} |
|
1005 |
||
1006 |
if (aNewReqEntry==NULL) |
|
1007 |
{ |
|
1008 |
TRAP(res,reqEntry=ReqAnalyserL(aMessage,aSession,reqMode)); |
|
1009 |
if (res) |
|
1010 |
{ |
|
1011 |
RECORD_COMPLETE_SUB(aMessage.Session(), this, aMessage.Int3(), aMessage.Function(), res); |
|
1012 |
aMessage.Complete(res); |
|
1013 |
return; |
|
1014 |
} |
|
1015 |
else |
|
1016 |
if (reqEntry==NULL) // there was no need to construct another reqEntry, |
|
1017 |
// or another reqEntry with identical IPC for a different client |
|
1018 |
// has been added inside ReqAnalyserL() |
|
1019 |
||
1020 |
return; |
|
1021 |
reqEntry->iReqMode = reqMode; // so ReqCompleted() needn't ask for it again |
|
1022 |
} |
|
1023 |
else |
|
1024 |
reqEntry=aNewReqEntry; // aNewReqEntry has just come from the waiting list |
|
1025 |
||
1026 |
if (reqMode&KReqModeFlowControlObeyed) // flow control obeyed |
|
1027 |
{ |
|
1028 |
if (PhoneOwner()->FlowControl()) |
|
1029 |
PhoneOwner()->AddReqToWaiting(reqEntry); |
|
1030 |
else |
|
1031 |
{ |
|
1032 |
PhoneOwner()->FlowControlInc(); |
|
1033 |
if (aNewReqEntry==NULL) |
|
1034 |
PhoneOwner()->AddReqToActive(reqEntry); |
|
1035 |
res=Service(aMessage,reqEntry); |
|
1036 |
if (res!=KErrNone) // can not do the service to tsy properly |
|
1037 |
{ |
|
1038 |
CompleteAndDestroyReq(reqEntry,res); |
|
1039 |
PhoneOwner()->FlowControlDec(); // Dec() as service is being abandoned |
|
1040 |
} |
|
1041 |
} |
|
1042 |
} |
|
1043 |
else // Ignored |
|
1044 |
{ |
|
1045 |
PhoneOwner()->AddReqToActive(reqEntry); |
|
1046 |
if (reqMode&KReqModeRePostImmediately) |
|
1047 |
res=RegisterNotification(ipc); // this tells the TSY the first time any client |
|
1048 |
// calls a particular notification. |
|
1049 |
if (res!=KErrNone) |
|
1050 |
CompleteAndDestroyReq(reqEntry,res); |
|
1051 |
else |
|
1052 |
{ |
|
1053 |
res=Service(aMessage,reqEntry); // down to the TSY |
|
1054 |
if (res!=KErrNone) |
|
1055 |
CompleteAndDestroyReq(reqEntry,res); |
|
1056 |
} |
|
1057 |
} |
|
1058 |
break; |
|
1059 |
} |
|
1060 |
case EIsaCancelMessage: |
|
1061 |
// This is for Cancel Req - Int0 contains the original IPC |
|
1062 |
{ |
|
1063 |
TInt cancelIpc=aMessage.Int0(); |
|
1064 |
reqEntry=PhoneOwner()->FindClientInWaiting(aSession,aMessage.Int3(),cancelIpc); |
|
1065 |
if(reqEntry!=NULL) // Is it Waiting to be passed to the TSY? |
|
1066 |
{ |
|
1067 |
CompleteAndDestroyReq(reqEntry,KErrCancel); // If yes then complete it. |
|
1068 |
RECORD_COMPLETE_SUB(aMessage.Session(), this, aMessage.Int3(), aMessage.Function(), KErrNone); |
|
1069 |
aMessage.Complete(KErrNone); |
|
1070 |
return; |
|
1071 |
} |
|
1072 |
reqEntry=PhoneOwner()->FindClientInActive(aSession,aMessage.Int3(),cancelIpc); |
|
1073 |
if(reqEntry) // found in active list |
|
1074 |
{ |
|
1075 |
TReqMode reqMode=0; |
|
1076 |
TRAPD(res,(reqMode=ReqModeL(reqEntry->iFunction))); |
|
1077 |
if (res) |
|
1078 |
{ |
|
1079 |
// client cannot check return value of Cancel() |
|
1080 |
// so use return value of original function call |
|
1081 |
RECORD_COMPLETE_SUB(reqEntry->iMessage.Session(), this, reqEntry->iMessage.Int3(), reqEntry->iMessage.Function(), res); |
|
1082 |
reqEntry->iMessage.Complete(res); |
|
1083 |
return; |
|
1084 |
} |
|
1085 |
if (reqMode&KReqModeRePostImmediately && reqEntry->iMessageNulled) |
|
1086 |
{ |
|
1087 |
// client has called Cancel on a notification |
|
1088 |
// after it had completed to the client |
|
1089 |
RECORD_COMPLETE_SUB(aMessage.Session(), this, aMessage.Int3(), aMessage.Function(), KErrNone); |
|
1090 |
aMessage.Complete(KErrNone); |
|
1091 |
return; |
|
1092 |
} |
|
1093 |
// so now we know the client must have the request outstanding |
|
1094 |
if ((reqMode&KReqModeMultipleCompletionEnabled || reqMode&KReqModeMultipleCompletionWithInterestLevel) && !(reqEntry->iPlacedRequest)) |
|
1095 |
{ |
|
1096 |
if (iDeliveryObject) |
|
1097 |
{ |
|
1098 |
iDeliveryObject->DeletedReqEntry(reqEntry); |
|
1099 |
} |
|
1100 |
||
1101 |
CompleteAndDestroyReq(reqEntry,KErrCancel); // the request hadn't been passed to the TSY |
|
1102 |
RECORD_COMPLETE_SUB(aMessage.Session(), this, aMessage.Int3(), aMessage.Function(), KErrNone); |
|
1103 |
aMessage.Complete(KErrNone); |
|
1104 |
return; |
|
1105 |
} |
|
1106 |
// so the request is outstanding on the TSY |
|
1107 |
if (reqEntry->iCancelFnCalled==FALSE) |
|
1108 |
{ |
|
1109 |
reqEntry->iCancelFnCalled=ETrue; |
|
1110 |
TInt status=CancelService(aMessage.Int0(),reqEntry->iTsyReqHandle); |
|
1111 |
if(status!=KErrNone) |
|
1112 |
CompleteAndDestroyReq(reqEntry,status); |
|
1113 |
} |
|
1114 |
} |
|
1115 |
RECORD_COMPLETE_SUB(aMessage.Session(), this, aMessage.Int3(), aMessage.Function(), KErrNone); |
|
1116 |
aMessage.Complete(KErrNone); |
|
1117 |
} |
|
1118 |
break; |
|
1119 |
||
1120 |
case EIsaCancelSubSession: |
|
1121 |
// This is a special case for cancelling all asynchronous requests for this subsession |
|
1122 |
{ |
|
1123 |
CancelSubSession(aSession,aMessage.Int3()); |
|
1124 |
RECORD_COMPLETE_SUB(aMessage.Session(), this, aMessage.Int3(), aMessage.Function(), KErrNone); |
|
1125 |
aMessage.Complete(KErrNone); |
|
1126 |
} |
|
1127 |
break; |
|
1128 |
||
1129 |
default: |
|
1130 |
PanicClient(EEtelPanicInvalidRequestType,aMessage); |
|
1131 |
break; |
|
1132 |
} |
|
1133 |
} |
|
1134 |
||
1135 |
void CTelObject::AcceptIncoming(const RMessage2& aMessage,CTelSession* aSession) |
|
1136 |
{ |
|
1137 |
TInt status = KErrNotReady; |
|
1138 |
if (iDeliveryObject) |
|
1139 |
{ |
|
1140 |
status = iDeliveryObject->ClientsDecision(aMessage, aSession, ETrue); |
|
1141 |
} |
|
1142 |
aMessage.Complete(status); |
|
1143 |
} |
|
1144 |
||
1145 |
void CTelObject::RejectIncoming(const RMessage2& aMessage,CTelSession* aSession) |
|
1146 |
{ |
|
1147 |
TInt status = KErrNotReady; |
|
1148 |
if (iDeliveryObject) |
|
1149 |
{ |
|
1150 |
if (iDeliveryObject->DeliveryInProgress()) |
|
1151 |
{ |
|
1152 |
status = iDeliveryObject->ClientsDecision(aMessage, aSession, EFalse); |
|
1153 |
} |
|
1154 |
else |
|
1155 |
{ |
|
1156 |
// Rejecting when the time out has occurred will lead to a KErrNone |
|
1157 |
// error rather than KErrTimedOut. |
|
1158 |
status = KErrNone; |
|
1159 |
} |
|
1160 |
} |
|
1161 |
aMessage.Complete(status); |
|
1162 |
} |
|
1163 |
||
1164 |
EXPORT_C void CTelObject::ReqCompleted(const TTsyReqHandle aTsyReqHandle,const TInt aError) |
|
1165 |
// |
|
1166 |
// General complete function for all CTelObject derived classes |
|
1167 |
// |
|
1168 |
{ |
|
1169 |
__ASSERT_ALWAYS(aTsyReqHandle!=TSY_HANDLE_INIT_VALUE,Fault(EEtelFaultNotRecognisedTsyHandle)); |
|
1170 |
TInt ipc=0; |
|
1171 |
CReqEntry* updatedReqEntry = NULL; |
|
1172 |
CReqEntry* nextPostedReqEntry = NULL; |
|
1173 |
updatedReqEntry=PhoneOwner()->FindByTsyHandleAndPlacedRequest(aTsyReqHandle); |
|
1174 |
__ASSERT_ALWAYS(updatedReqEntry!=NULL, Fault(EEtelFaultCompletionReceivedWithNoReqPackage)); |
|
1175 |
||
1176 |
TInt error = ResolveError(updatedReqEntry->iSession,aError); // set error as either low or high byte |
|
1177 |
||
1178 |
ipc=updatedReqEntry->iFunction; |
|
1179 |
LOGTEXT4("CTelObject::ReqCompleted, IPC=%d, TsyHandle=%d, Error=%d", ipc, aTsyReqHandle, aError); |
|
1180 |
||
1181 |
TReqMode reqMode = updatedReqEntry->iReqMode; |
|
1182 |
TBool ret=EFalse; |
|
1183 |
if (error!=KErrCancel) |
|
1184 |
{ |
|
1185 |
// Multiple-completion malarky. |
|
1186 |
// Don't copy data across to other buffers and complete their reqs if TSY knows about |
|
1187 |
// each client that has called it. In that case, |
|
1188 |
// TSY will fill in the appropriate client's buffer and complete each separately. |
|
1189 |
if (reqMode&KReqModeMultipleCompletionEnabled) |
|
1190 |
{ |
|
1191 |
||
1192 |
PhoneOwner()->CheckAndCompleteAllActive(updatedReqEntry,reqMode,ipc,aError); |
|
1193 |
} |
|
1194 |
else if (reqMode&KReqModeMultipleCompletionWithInterestLevel && error ==KErrNone) |
|
1195 |
{ |
|
1196 |
// TODO if delivery is active for this req then return |
|
1197 |
// KErrInUse / KErrServerBusy? |
|
1198 |
// TODO what if one CTelObject has multiple requests which are |
|
1199 |
// KReqModeMultipleCompletionWithInterestLevel. Would we need multiple |
|
1200 |
// delivery managers? |
|
1201 |
if (!IsSessionInProgress()) |
|
1202 |
{ |
|
1203 |
// Find an owner for the new session by offering it to the |
|
1204 |
// interested clients one by one. |
|
1205 |
DeliverReqL(updatedReqEntry,reqMode, ipc, aError); |
|
1206 |
} |
|
1207 |
else |
|
1208 |
{ |
|
1209 |
// Route response direct to session owner |
|
1210 |
FindReq(updatedReqEntry, reqMode, ipc, aError); |
|
1211 |
} |
|
1212 |
||
1213 |
} |
|
1214 |
||
1215 |
if (reqMode&KReqModeRePostImmediately && error==KErrNone) |
|
1216 |
nextPostedReqEntry = updatedReqEntry; |
|
1217 |
updatedReqEntry->iBuffer->IncWrite(); |
|
1218 |
} |
|
1219 |
else // if a cancel comes from the TSY, then if it is a notification |
|
1220 |
// there may be other clients who have also called the notification and who |
|
1221 |
// have entries in active list, so one of these must be re-posted. |
|
1222 |
{ |
|
1223 |
||
1224 |
if ( reqMode&KReqModeMultipleCompletionEnabled || reqMode&KReqModeMultipleCompletionWithInterestLevel) |
|
1225 |
{ |
|
1226 |
nextPostedReqEntry = PhoneOwner()->FindThisReqByAnotherClient(updatedReqEntry->iSession, |
|
1227 |
updatedReqEntry->iMessage.Int3(),ipc,updatedReqEntry->iBuffer->Size(),this); |
|
1228 |
} |
|
1229 |
||
1230 |
if (!nextPostedReqEntry) |
|
1231 |
// then we don't want to post any other client's requests in place of this one |
|
1232 |
{ |
|
1233 |
nextPostedReqEntry = PhoneOwner()->FindNonCancelledClientReq(updatedReqEntry->iSession,updatedReqEntry->iMessage.Int3(),ipc); |
|
1234 |
__ASSERT_DEBUG(updatedReqEntry!=nextPostedReqEntry, Fault(EEtelFaultCancelErrorWithoutCancelled)); |
|
1235 |
if (nextPostedReqEntry==NULL && reqMode&KReqModeRePostImmediately) |
|
1236 |
{ |
|
1237 |
TInt ret = DeregisterNotification(ipc); // no more clients are interested so |
|
1238 |
// tell TSY to stop looking at notifies |
|
1239 |
if (ret!=KErrNone) |
|
1240 |
error=ret; // so the KErrCancel wouldn't reach the client |
|
1241 |
} |
|
1242 |
} |
|
1243 |
} |
|
1244 |
||
1245 |
if (error && reqMode&KReqModeMultipleCompletionWithInterestLevel && iDeliveryObject) |
|
1246 |
{ |
|
1247 |
// We need to do this before the updatedReqEntry is destroyed |
|
1248 |
iDeliveryObject->DeletedReqEntry(updatedReqEntry); |
|
1249 |
} |
|
1250 |
||
1251 |
if (reqMode & KReqModeRePostImmediately) |
|
1252 |
{ |
|
1253 |
// this will destroy the reqEntry if an error occurred. |
|
1254 |
UpdateAndCompleteIfNecessary(updatedReqEntry,error); |
|
1255 |
} |
|
1256 |
else |
|
1257 |
{ |
|
1258 |
WriteBackAndCompleteReq(updatedReqEntry,error); |
|
1259 |
} |
|
1260 |
||
1261 |
if (nextPostedReqEntry) // will be NULL if no following request for TSY |
|
1262 |
{ |
|
1263 |
if(nextPostedReqEntry->iReqMode&KReqModeFlowControlObeyed && |
|
1264 |
!(nextPostedReqEntry->iReqMode&KReqModeMultipleCompletionWithInterestLevel)) |
|
1265 |
{ // since the request mode is flow control obeyed, increment the flow control counter |
|
1266 |
FlowControlSuspend(); |
|
1267 |
} |
|
1268 |
Service(nextPostedReqEntry->iMessage,nextPostedReqEntry); |
|
1269 |
} |
|
1270 |
||
1271 |
||
1272 |
if (!(reqMode&KReqModeFlowControlObeyed)) // If flow control not enabled, go home |
|
1273 |
{ |
|
1274 |
ret=ETrue; |
|
1275 |
} |
|
1276 |
||
1277 |
// So everything below assumes it obeyed flow control |
|
1278 |
// Resume Flow control ... |
|
1279 |
if (!ret) |
|
1280 |
{ |
|
1281 |
FlowControlResume(); |
|
1282 |
} |
|
1283 |
// |
|
1284 |
// Check and destroying the dummy session |
|
1285 |
// |
|
1286 |
CheckAndDestroyDummySubSession(); |
|
1287 |
} |
|
1288 |
||
1289 |
TInt CTelObject::DeliverReqL(CReqEntry* aUpdatedReqEntry,const TReqMode aReqMode,const TInt aIpc, const TInt aError) |
|
1290 |
{ |
|
1291 |
// There is no active session therefore we have to work out who to deliver it to. |
|
1292 |
if (!iDeliveryObject) |
|
1293 |
{ |
|
1294 |
iDeliveryObject = CMmDeliveryObject::NewL(*this); |
|
1295 |
} |
|
1296 |
||
1297 |
if (iDeliveryObject->DeliveryInProgress()) |
|
1298 |
{ |
|
1299 |
// Session in progress. |
|
1300 |
return KErrPermissionDenied; |
|
1301 |
} |
|
1302 |
||
1303 |
return iDeliveryObject->DeliverReqL(PhoneOwner()->ReqActiveList(), aUpdatedReqEntry, aReqMode, aIpc, aError); |
|
1304 |
} |
|
1305 |
||
1306 |
void CTelObject::FindReq(CReqEntry* aUpdatedReqEntry,const TReqMode aReqMode,const TInt aIpc,const TInt aError) |
|
1307 |
{ |
|
1308 |
CReqEntry* reqEntry; |
|
1309 |
TDblQueIter<CReqEntry> iter(PhoneOwner()->ReqActiveList()); |
|
1310 |
while(reqEntry = iter++, reqEntry!=NULL) |
|
1311 |
{ |
|
1312 |
if(reqEntry->iFunction==aIpc |
|
1313 |
&& reqEntry->iTelObject==aUpdatedReqEntry->iTelObject |
|
1314 |
&& reqEntry->iBuffer->Size()==aUpdatedReqEntry->iBuffer->Size() |
|
1315 |
/*&& IsSessionOwner(reqEntry)*/) |
|
1316 |
{ |
|
1317 |
if (aUpdatedReqEntry != reqEntry) |
|
1318 |
{ |
|
1319 |
// Copy data from the 'placed' request to the one |
|
1320 |
// that is owned by the client. |
|
1321 |
PhoneOwner()->UpdateBuffer(aUpdatedReqEntry,reqEntry); |
|
1322 |
} |
|
1323 |
OfferToClient(reqEntry, aUpdatedReqEntry, aReqMode, aError); |
|
1324 |
RepostRequest(aUpdatedReqEntry, aError); |
|
1325 |
} |
|
1326 |
} |
|
1327 |
} |
|
1328 |
||
1329 |
void CTelObject::OfferToClient(CReqEntry* aReqEntry,CReqEntry* aUpdatedReqEntry,const TReqMode aReqMode,const TInt aError) |
|
1330 |
{ |
|
1331 |
if (aReqEntry == aUpdatedReqEntry) |
|
1332 |
{ |
|
1333 |
aUpdatedReqEntry->iBuffer->IncWrite(); |
|
1334 |
if (aReqMode&KReqModeRePostImmediately) |
|
1335 |
{ |
|
1336 |
// this will destroy the reqEntry if an error occurred. |
|
1337 |
UpdateAndCompleteIfNecessary(aUpdatedReqEntry,aError); |
|
1338 |
} |
|
1339 |
else |
|
1340 |
{ |
|
1341 |
WriteBackAndCompleteReq(aUpdatedReqEntry,aError); |
|
1342 |
} |
|
1343 |
} |
|
1344 |
else |
|
1345 |
{ |
|
1346 |
TInt error = ResolveError(aReqEntry->iSession,aError); // set error as either low or high byte |
|
1347 |
if (aReqMode&KReqModeRePostImmediately) |
|
1348 |
{ |
|
1349 |
UpdateAndCompleteIfNecessary(aReqEntry,error); |
|
1350 |
} |
|
1351 |
else |
|
1352 |
{ |
|
1353 |
WriteBackAndCompleteReq(aReqEntry,error); |
|
1354 |
} |
|
1355 |
} |
|
1356 |
||
77 | 1357 |
CheckAndDestroyDummySubSession(); |
24 | 1358 |
} |
1359 |
||
1360 |
void CTelObject::RepostRequest(CReqEntry* aUpdatedReqEntry, const TInt aError) |
|
1361 |
{ |
|
1362 |
TReqMode reqMode = aUpdatedReqEntry->iReqMode; |
|
1363 |
TBool ret=EFalse; |
|
1364 |
||
1365 |
CReqEntry* nextPostedReqEntry = NULL; |
|
1366 |
if (reqMode&KReqModeRePostImmediately && aError==KErrNone) |
|
1367 |
{ |
|
1368 |
nextPostedReqEntry = aUpdatedReqEntry; |
|
1369 |
} |
|
1370 |
||
1371 |
if (nextPostedReqEntry) // will be NULL if no following request for TSY |
|
1372 |
{ |
|
1373 |
if(nextPostedReqEntry->iReqMode&KReqModeFlowControlObeyed) |
|
1374 |
{ // since the request mode is flow control obeyed, increment the flow control counter |
|
1375 |
FlowControlSuspend(); |
|
1376 |
} |
|
1377 |
Service(nextPostedReqEntry->iMessage,nextPostedReqEntry); |
|
1378 |
} |
|
1379 |
||
1380 |
if (!(reqMode&KReqModeFlowControlObeyed && aError == KErrNone)) // If flow control not enabled, go home |
|
1381 |
ret=ETrue; |
|
1382 |
||
1383 |
// So everything below assumes it obeyed flow control |
|
1384 |
// Resume Flow control ... |
|
1385 |
if (!ret) |
|
1386 |
FlowControlResume(); |
|
1387 |
} |
|
1388 |
||
1389 |
void CTelObject::SetSessionOwner(TInt aSessionHandle, TInt aSubSessionHandle) |
|
1390 |
{ |
|
1391 |
iDeliveryObject->iSessionOwner = TPhoneClientId(aSessionHandle, aSubSessionHandle); |
|
1392 |
} |
|
1393 |
||
77 | 1394 |
// Can be used by the TSY to set the session owner to the current request. |
24 | 1395 |
// For each request the CTSY is given a TsyReqHandle so this is a sensible thing |
1396 |
// for it to be dealing with. |
|
77 | 1397 |
// Note that once a session has an owner the reserved state is irrelevant. |
24 | 1398 |
|
1399 |
EXPORT_C void CTelObject::SetSessionOwnerByTsyHandle(const TTsyReqHandle aTsyReqHandle) |
|
1400 |
{ |
|
1401 |
||
77 | 1402 |
const TInt owningsession = PhoneOwner()->FindSessionByTsyHandle( aTsyReqHandle ); |
1403 |
const TInt owningsubsession = PhoneOwner()->FindSubSessionByTsyHandle( aTsyReqHandle ); |
|
1404 |
||
1405 |
||
1406 |
if(iDeliveryObject->GetReqMode() == (KReqModeSessionBased | KReqModeTransferToDefaultHandler)) // transfer to default handler |
|
1407 |
{ |
|
1408 |
iDeliveryObject->iSessionOwner = TPhoneClientId(KUssdDefaultClientSid, owningsubsession); |
|
1409 |
} |
|
1410 |
else //not default handler |
|
1411 |
{ |
|
1412 |
iDeliveryObject->iSessionOwner = TPhoneClientId(owningsession, owningsubsession); |
|
1413 |
} |
|
24 | 1414 |
} |
1415 |
||
1416 |
||
1417 |
TBool CTelObject::IsSessionOwner(CReqEntry* aReqEntry) const |
|
1418 |
{ |
|
1419 |
TPhoneClientId clientId(reinterpret_cast<TInt>(aReqEntry->iSession),aReqEntry->iMessage.Int3()); |
|
1420 |
return (clientId == iDeliveryObject->iSessionOwner); |
|
1421 |
} |
|
1422 |
||
1423 |
TInterestCategory CTelObject::FindInterestCategory( const TSecureId aSid) |
|
1424 |
{ |
|
1425 |
if (aSid == KUssdPriorityClientSid) |
|
1426 |
{ |
|
1427 |
return EInterestCategoryPriority; |
|
1428 |
} |
|
1429 |
else if(aSid == KUssdDefaultClientSid) |
|
1430 |
{ |
|
1431 |
return EInterestCategoryDefault; |
|
1432 |
} |
|
1433 |
else |
|
1434 |
return EInterestCategoryStandard; |
|
1435 |
} |
|
1436 |
||
1437 |
EXPORT_C TBool CTelObject::IsSessionInProgress() const |
|
1438 |
{ |
|
77 | 1439 |
//Indicates if there is an ongoing USSD dialogue. |
24 | 1440 |
if (iDeliveryObject) |
1441 |
{ |
|
1442 |
return iDeliveryObject->iSessionOwner != TPhoneClientId(); |
|
1443 |
} |
|
1444 |
return EFalse; |
|
1445 |
} |
|
1446 |
||
1447 |
EXPORT_C TInt CTelObject::ReserveSession() |
|
1448 |
{ |
|
77 | 1449 |
// There is no active session so we have to work out who to deliver it to. |
1450 |
if (NULL == iDeliveryObject) |
|
1451 |
{ |
|
1452 |
iDeliveryObject = CMmDeliveryObject::NewL(*this); |
|
1453 |
} |
|
1454 |
//Reserve the session if it is not already reserved |
|
24 | 1455 |
if (iDeliveryObject->iSessionReserved) |
1456 |
{ |
|
1457 |
return KErrInUse; |
|
1458 |
} |
|
1459 |
iDeliveryObject->iSessionReserved = ETrue; |
|
1460 |
return KErrNone; |
|
1461 |
} |
|
1462 |
||
1463 |
EXPORT_C TBool CTelObject::IsSessionReserved() const |
|
1464 |
{ |
|
77 | 1465 |
//Check if the USSD session has been reserved |
1466 |
if (NULL != iDeliveryObject) |
|
1467 |
{ |
|
1468 |
return iDeliveryObject->iSessionReserved; |
|
1469 |
} |
|
1470 |
else |
|
1471 |
{ |
|
1472 |
return EFalse; |
|
1473 |
} |
|
24 | 1474 |
} |
1475 |
||
1476 |
EXPORT_C void CTelObject::CancelReserveSession() |
|
1477 |
{ |
|
77 | 1478 |
if (iDeliveryObject) |
1479 |
{ |
|
1480 |
iDeliveryObject->iSessionReserved = EFalse; |
|
1481 |
} |
|
24 | 1482 |
} |
1483 |
||
1484 |
EXPORT_C void CTelObject::EndSession() |
|
1485 |
{ |
|
77 | 1486 |
if (iDeliveryObject) |
1487 |
{ |
|
1488 |
iDeliveryObject->iSessionOwner = TPhoneClientId(); |
|
1489 |
iDeliveryObject->iSessionReserved = EFalse; |
|
1490 |
} |
|
24 | 1491 |
} |
1492 |
||
1493 |
TInt CTelObject::ResolveError(CTelSession* aSession, const TInt aError) const |
|
1494 |
/** |
|
1495 |
* Converts a coded error into the correct error to return. The coded error value |
|
1496 |
* allows an extended error code to be present allong with a basic error code. If |
|
1497 |
* the client has specified awareness of the extended codes, then they are returned. |
|
1498 |
* Otherwise the basic error code will be returned. The advanced error codes do not |
|
1499 |
* overlap the basic ones. |
|
1500 |
* |
|
1501 |
* In the case of no extended error code available, then the core error code will |
|
1502 |
* be returned regardless of the client's extended error granularity. |
|
1503 |
* |
|
1504 |
* @return Either the basic error code or the advanced error coded if available and |
|
1505 |
* requested. |
|
1506 |
* @param aSession The CTelSession of the client. |
|
1507 |
* @param aError The coded error. |
|
1508 |
*/ |
|
1509 |
{ |
|
1510 |
// |
|
1511 |
// Handle the common cases to make the code more efficent.... |
|
1512 |
// |
|
1513 |
if ((aError==KErrNone) || (aError==KErrCancel)) |
|
1514 |
{ |
|
1515 |
return aError; |
|
1516 |
} |
|
1517 |
||
1518 |
// |
|
1519 |
// 'aError' is coded into two halves (eXtended and baSic): 0xXXXXSSSS. Take the |
|
1520 |
// top 16 bits for the eXtended code, and the bottom 16 bit for the baSic code. |
|
1521 |
// |
|
1522 |
// So, basicError becomes 0xffffSSSS and extendedError becomes 0xffffXXXX. |
|
1523 |
// |
|
1524 |
// A special case exists if the 16 bits were 0x0000 as this is KErrNone, and we must |
|
1525 |
// treat this as a positive int and not a negative one (e.g. clear the top 16 bits). |
|
1526 |
// |
|
1527 |
TInt basicError = (aError | 0xFFFF0000); |
|
1528 |
TInt extendedError = ((aError >> 16) | 0xFFFF0000); |
|
1529 |
||
1530 |
if (basicError == (TInt)(0xffff0000)) |
|
1531 |
{ |
|
1532 |
basicError = KErrNone; |
|
1533 |
} |
|
1534 |
||
1535 |
if (extendedError == (TInt)(0xffff0000)) |
|
1536 |
{ |
|
1537 |
extendedError = KErrNone; |
|
1538 |
} |
|
1539 |
||
1540 |
// |
|
1541 |
// If the an extended error code is available and if client wants extended errors |
|
1542 |
// then return the extended error. Otherwise return the basic error code. |
|
1543 |
// |
|
1544 |
// The extended error is not available if 'extendedError' is KErrNotFound (e.g. |
|
1545 |
// the top 16 bits were 0xffff. |
|
1546 |
// |
|
1547 |
if (extendedError != KErrNotFound && aSession->IsExpectingExtendedError()) |
|
1548 |
{ |
|
1549 |
return extendedError; |
|
1550 |
} |
|
1551 |
else |
|
1552 |
{ |
|
1553 |
return basicError; |
|
1554 |
} |
|
1555 |
} |
|
1556 |
||
1557 |
void CTelObject::UpdateAndCompleteIfNecessary(CReqEntry* aReqEntry,TInt aError) const |
|
1558 |
// |
|
1559 |
// If client has this request outstanding on the server, complete it, otherwise set Read |
|
1560 |
// flag to false. Destroy the request if an error has occurred. |
|
1561 |
// |
|
1562 |
{ |
|
1563 |
if (aReqEntry->iMessageNulled) |
|
1564 |
aReqEntry->iReadByClient=EFalse; |
|
1565 |
else |
|
1566 |
WriteBackAndCompleteBufferedReq(aReqEntry->iMessage,aReqEntry,aError); |
|
1567 |
if (aError) |
|
1568 |
DestroyReq(aReqEntry); |
|
1569 |
} |
|
1570 |
||
1571 |
void CTelObject::CheckAndDestroyDummySubSession() |
|
1572 |
{ |
|
1573 |
if (iActiveReqCount) |
|
1574 |
{ |
|
1575 |
iActiveReqCount--; |
|
1576 |
LOGTEXT2("In CheckAndDestroyDummySubSession(), iActiveReqCount down to %d", iActiveReqCount); |
|
1577 |
if ((iActiveReqCount==0) && (iCreateDummy==FALSE)) |
|
1578 |
{ |
|
1579 |
__ASSERT_ALWAYS(iDestroyDummySubSession!=NULL,Fault(EEtelFaultBadTelSessionPointer)); |
|
1580 |
if (!(iDestroyDummySubSession->IsActive())) // only set going if not already active! |
|
1581 |
{ |
|
1582 |
iDestroyDummySubSession->Call(); |
|
1583 |
iTelServer->Dec(); |
|
1584 |
} |
|
1585 |
} |
|
1586 |
} |
|
1587 |
else if (iCreateDummy) |
|
1588 |
{ |
|
1589 |
__ASSERT_ALWAYS(iDestroyDummySubSession!=NULL,Fault(EEtelFaultBadTelSessionPointer)); |
|
1590 |
if (!(iDestroyDummySubSession->IsActive())) // only set going if not already active! |
|
1591 |
{ |
|
1592 |
iDestroyDummySubSession->Call(); |
|
1593 |
iTelServer->Dec(); |
|
1594 |
} |
|
1595 |
iCreateDummy=EFalse; |
|
1596 |
} |
|
1597 |
} |
|
1598 |
||
1599 |
void CTelObject::WriteBackAndCompleteBufferedReq(const RMessage2& aNewMessage,CReqEntry* aReqEntry,TInt aError) const |
|
1600 |
{ |
|
1601 |
TInt basicMessageType =0; |
|
1602 |
basicMessageType = (aNewMessage.Int1() & ~(KPriorityClientReq)); |
|
1603 |
switch (basicMessageType) |
|
1604 |
{ |
|
1605 |
case EIsaNull: |
|
1606 |
if (aReqEntry->iClientInterested) |
|
1607 |
{ |
|
1608 |
RECORD_COMPLETE_SUB(aNewMessage.Session(), this, aNewMessage.Int3(), aNewMessage.Function(), aError); |
|
1609 |
aNewMessage.Complete(aError); |
|
1610 |
} |
|
1611 |
break; |
|
1612 |
case EIsaDesTobeRead: |
|
1613 |
case EIsaDoubleDesTobeRead: |
|
1614 |
if (aReqEntry->iClientInterested) |
|
1615 |
{ |
|
1616 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf8!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1617 |
TDes8* dataDes1=BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1618 |
__ASSERT_ALWAYS(dataDes1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1619 |
||
1620 |
TRAPD(ret,aNewMessage.WriteL(0,*dataDes1)); // if this fails, panic the client |
|
1621 |
if(ret!=KErrNone) |
|
1622 |
{ |
|
1623 |
PanicClient(EEtelPanicBadDescriptor,aNewMessage); |
|
1624 |
break; |
|
1625 |
} |
|
1626 |
||
1627 |
if (basicMessageType==EIsaDoubleDesTobeRead) |
|
1628 |
{ |
|
1629 |
TDes8* dataDes2=BufferDes2(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1630 |
__ASSERT_ALWAYS(dataDes2!=NULL,Fault(EEtelFaultDes2DoesNotExist)); |
|
1631 |
||
1632 |
TRAP(ret,aNewMessage.WriteL(2,*dataDes2)); |
|
1633 |
if(ret!=KErrNone) |
|
1634 |
{ |
|
1635 |
PanicClient(EEtelPanicBadDescriptor,aNewMessage); |
|
1636 |
break; |
|
1637 |
} |
|
1638 |
} |
|
1639 |
RECORD_COMPLETE_SUB(aNewMessage.Session(), this, aNewMessage.Int3(), aNewMessage.Function(), aError); |
|
1640 |
aNewMessage.Complete(aError); |
|
1641 |
} |
|
1642 |
break; |
|
1643 |
case EIsaUnicodeDesTobeRead: |
|
1644 |
case EIsaUnicodeDoubleDesTobeRead: |
|
1645 |
{ |
|
1646 |
if (aReqEntry->iClientInterested) |
|
1647 |
{ |
|
1648 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf16!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1649 |
// The TDes16 will be at the start of the HBufC buffer |
|
1650 |
TDes16* unicodeDataDes1=BufferDes1u(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1651 |
__ASSERT_ALWAYS(unicodeDataDes1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1652 |
||
1653 |
TRAPD(ret,aNewMessage.WriteL(0,*unicodeDataDes1)); |
|
1654 |
if(ret!=KErrNone) |
|
1655 |
{ |
|
1656 |
PanicClient(EEtelPanicBadDescriptor,aNewMessage); |
|
1657 |
break; |
|
1658 |
} |
|
1659 |
||
1660 |
if (basicMessageType==EIsaUnicodeDoubleDesTobeRead) |
|
1661 |
{ |
|
1662 |
TDes16* unicodeDataDes2=BufferDes2u(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1663 |
__ASSERT_ALWAYS(unicodeDataDes2!=NULL,Fault(EEtelFaultDes2DoesNotExist)); |
|
1664 |
||
1665 |
TRAP(ret,aNewMessage.WriteL(2,*unicodeDataDes2)); |
|
1666 |
if(ret!=KErrNone) |
|
1667 |
{ |
|
1668 |
PanicClient(EEtelPanicBadDescriptor,aNewMessage); |
|
1669 |
break; |
|
1670 |
} |
|
1671 |
} |
|
1672 |
RECORD_COMPLETE_SUB(aNewMessage.Session(), this, aNewMessage.Int3(), aNewMessage.Function(), aError); |
|
1673 |
aNewMessage.Complete(aError); |
|
1674 |
} |
|
1675 |
} |
|
1676 |
break; |
|
1677 |
||
1678 |
case EIsaNarrowAndUnicodeDoubleDesTobeRead: |
|
1679 |
{ |
|
1680 |
if (aReqEntry->iClientInterested) |
|
1681 |
{ |
|
1682 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf16!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1683 |
TDes8* dataDes1=BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1684 |
__ASSERT_ALWAYS(dataDes1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1685 |
||
1686 |
TRAPD(ret,aNewMessage.WriteL(0,*dataDes1)); |
|
1687 |
if(ret!=KErrNone) |
|
1688 |
{ |
|
1689 |
PanicClient(EEtelPanicBadDescriptor,aNewMessage); |
|
1690 |
break; |
|
1691 |
} |
|
1692 |
||
1693 |
TDes16* unicodeDataDes2=BufferDes2u(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1694 |
__ASSERT_ALWAYS(unicodeDataDes2!=NULL,Fault(EEtelFaultDes2DoesNotExist)); |
|
1695 |
||
1696 |
TRAP(ret,aNewMessage.WriteL(2,*unicodeDataDes2)); |
|
1697 |
if(ret!=KErrNone) |
|
1698 |
{ |
|
1699 |
PanicClient(EEtelPanicBadDescriptor,aNewMessage); |
|
1700 |
break; |
|
1701 |
} |
|
1702 |
RECORD_COMPLETE_SUB(aNewMessage.Session(), this, aNewMessage.Int3(), aNewMessage.Function(), aError); |
|
1703 |
aNewMessage.Complete(aError); |
|
1704 |
} |
|
1705 |
} |
|
1706 |
break; |
|
1707 |
||
1708 |
case EIsaNarrowDesToSetAndGet: |
|
1709 |
{ |
|
1710 |
if (aReqEntry->iClientInterested) |
|
1711 |
{ |
|
1712 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf8!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1713 |
TDes8* dataDes2=BufferDes2(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1714 |
__ASSERT_ALWAYS(dataDes2!=NULL,Fault(EEtelFaultDes2DoesNotExist)); |
|
1715 |
||
1716 |
TRAPD(ret,aNewMessage.WriteL(2,*dataDes2)); |
|
1717 |
if(ret!=KErrNone) |
|
1718 |
{ |
|
1719 |
PanicClient(EEtelPanicBadDescriptor,aNewMessage); |
|
1720 |
break; |
|
1721 |
} |
|
1722 |
RECORD_COMPLETE_SUB(aNewMessage.Session(), this, aNewMessage.Int3(), aNewMessage.Function(), aError); |
|
1723 |
aNewMessage.Complete(aError); |
|
1724 |
} |
|
1725 |
} |
|
1726 |
break; |
|
1727 |
||
1728 |
case EIsaUnicodeDesToGetNarrowDesToSet: |
|
1729 |
case EIsaUnicodeDesToSetAndGet: |
|
1730 |
if (aReqEntry->iClientInterested) |
|
1731 |
{ |
|
1732 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf16!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1733 |
TDes16* dataDes2=BufferDes2u(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1734 |
__ASSERT_ALWAYS(dataDes2!=NULL,Fault(EEtelFaultDes2DoesNotExist)); |
|
1735 |
||
1736 |
TRAPD(ret,aNewMessage.WriteL(2,*dataDes2)); |
|
1737 |
if(ret!=KErrNone) |
|
1738 |
{ |
|
1739 |
PanicClient(EEtelPanicBadDescriptor,aNewMessage); |
|
1740 |
break; |
|
1741 |
} |
|
1742 |
RECORD_COMPLETE_SUB(aNewMessage.Session(), this, aNewMessage.Int3(), aNewMessage.Function(), aError); |
|
1743 |
aNewMessage.Complete(aError); |
|
1744 |
} |
|
1745 |
break; |
|
1746 |
||
1747 |
case EIsaNarrowDesToGetUnicodeDesToSet: |
|
1748 |
{ |
|
1749 |
if (aReqEntry->iClientInterested) |
|
1750 |
{ |
|
1751 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf8!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1752 |
TDes8* dataDes1=BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1753 |
__ASSERT_ALWAYS(dataDes1!=NULL,Fault(EEtelFaultDes1DoesNotExist)); |
|
1754 |
||
1755 |
TRAPD(ret,aNewMessage.WriteL(0,*dataDes1)); |
|
1756 |
if(ret!=KErrNone) |
|
1757 |
{ |
|
1758 |
PanicClient(EEtelPanicBadDescriptor,aNewMessage); |
|
1759 |
break; |
|
1760 |
} |
|
1761 |
RECORD_COMPLETE_SUB(aNewMessage.Session(), this, aNewMessage.Int3(), aNewMessage.Function(), aError); |
|
1762 |
aNewMessage.Complete(aError); |
|
1763 |
} |
|
1764 |
} |
|
1765 |
break; |
|
1766 |
||
1767 |
case EIsaDesTobeSet: |
|
1768 |
case EIsaDoubleDesTobeSet: |
|
1769 |
case EIsaUnicodeDesTobeSet: |
|
1770 |
case EIsaUnicodeDoubleDesTobeSet: |
|
1771 |
case EIsaNarrowAndUnicodeDoubleDesTobeSet: |
|
1772 |
case EIsaCancelMessage: |
|
1773 |
case EIsaCancelSubSession: |
|
1774 |
||
1775 |
default: |
|
1776 |
Fault(EEtelFaultBadMessageType); |
|
1777 |
break; |
|
1778 |
} |
|
1779 |
if (aError==KErrNone || aError==KErrOverflow) |
|
1780 |
{ |
|
1781 |
aReqEntry->iReadByClient=ETrue; |
|
1782 |
aReqEntry->iMessageNulled=ETrue; |
|
1783 |
aReqEntry->iBuffer->IncRead(); |
|
1784 |
} |
|
1785 |
} |
|
1786 |
||
1787 |
void CTelObject::WriteBackAndCompleteReq(CReqEntry* aReqEntry,const TInt aError) const |
|
1788 |
// |
|
1789 |
// Complete a request entry and write data back to client |
|
1790 |
// |
|
1791 |
{ |
|
1792 |
__ASSERT_ALWAYS(aReqEntry!=NULL,Fault(EEtelFaultCompleteReqWithoutReqEntry)); |
|
1793 |
LOGTEXT("CTelObject::WriteBackAndCompleteReq"); |
|
1794 |
TInt basicMessageType = (aReqEntry->iMessage.Int1() & ~KPriorityClientReq); |
|
1795 |
||
1796 |
switch (basicMessageType) |
|
1797 |
{ |
|
1798 |
case EIsaNull: |
|
1799 |
aReqEntry->CompleteAndDeque(aError); |
|
1800 |
break; |
|
1801 |
case EIsaDesTobeSet: |
|
1802 |
case EIsaDoubleDesTobeSet: |
|
1803 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf8!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1804 |
aReqEntry->CompleteAndDeque(aError); |
|
1805 |
break; |
|
1806 |
case EIsaUnicodeDesTobeSet: |
|
1807 |
case EIsaUnicodeDoubleDesTobeSet: |
|
1808 |
case EIsaNarrowAndUnicodeDoubleDesTobeSet: |
|
1809 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf16!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1810 |
aReqEntry->CompleteAndDeque(aError); |
|
1811 |
break; |
|
1812 |
case EIsaDesTobeRead: |
|
1813 |
case EIsaDoubleDesTobeRead: |
|
1814 |
{ |
|
1815 |
if (aReqEntry->iClientInterested) |
|
1816 |
{ |
|
1817 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf8!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1818 |
// The TPtr8 will be at the start of the HBufC buffer |
|
1819 |
TDes8* dataDes1=BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1820 |
__ASSERT_ALWAYS(dataDes1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1821 |
||
1822 |
TRAPD(ret,aReqEntry->iMessage.WriteL(0,*dataDes1)); |
|
1823 |
if(ret!=KErrNone) |
|
1824 |
{ |
|
1825 |
PanicClient(EEtelPanicBadDescriptor,aReqEntry->iMessage); |
|
1826 |
break; |
|
1827 |
} |
|
1828 |
||
1829 |
if (basicMessageType==EIsaDoubleDesTobeRead) |
|
1830 |
{ |
|
1831 |
TDes8* dataDes2=BufferDes2(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1832 |
||
1833 |
TRAP(ret,aReqEntry->iMessage.WriteL(2,*dataDes2)); |
|
1834 |
if(ret!=KErrNone) |
|
1835 |
{ |
|
1836 |
PanicClient(EEtelPanicBadDescriptor,aReqEntry->iMessage); |
|
1837 |
break; |
|
1838 |
} |
|
1839 |
} |
|
1840 |
} |
|
1841 |
aReqEntry->CompleteAndDeque(aError); |
|
1842 |
} |
|
1843 |
break; |
|
1844 |
case EIsaUnicodeDesTobeRead: |
|
1845 |
case EIsaUnicodeDoubleDesTobeRead: |
|
1846 |
{ |
|
1847 |
if (aReqEntry->iClientInterested) |
|
1848 |
{ |
|
1849 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf16!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1850 |
TDes16* dataDes1=BufferDes1u(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1851 |
||
1852 |
TRAPD(ret,aReqEntry->iMessage.WriteL(0,*dataDes1)); |
|
1853 |
if(ret!=KErrNone) |
|
1854 |
{ |
|
1855 |
PanicClient(EEtelPanicBadDescriptor,aReqEntry->iMessage); |
|
1856 |
break; |
|
1857 |
} |
|
1858 |
||
1859 |
if (basicMessageType==EIsaUnicodeDoubleDesTobeRead) |
|
1860 |
{ |
|
1861 |
TDes16* dataDes2=BufferDes2u(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
32
58332560b319
Bring opencode branch up-to-date with latest cellularsrv changes
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
24
diff
changeset
|
1862 |
__ASSERT_ALWAYS(dataDes2!=NULL,Fault(EEtelFaultDes2DoesNotExist)); |
24 | 1863 |
|
1864 |
TRAP(ret,aReqEntry->iMessage.WriteL(2,*dataDes2)); |
|
1865 |
if(ret!=KErrNone) |
|
1866 |
{ |
|
1867 |
PanicClient(EEtelPanicBadDescriptor,aReqEntry->iMessage); |
|
1868 |
break; |
|
1869 |
} |
|
1870 |
} |
|
1871 |
} |
|
1872 |
aReqEntry->CompleteAndDeque(aError); |
|
1873 |
} |
|
1874 |
break; |
|
1875 |
case EIsaNarrowAndUnicodeDoubleDesTobeRead: |
|
1876 |
{ |
|
1877 |
if (aReqEntry->iClientInterested) |
|
1878 |
{ |
|
1879 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf16!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1880 |
TDes8* dataDes1=BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1881 |
__ASSERT_ALWAYS(dataDes1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1882 |
||
1883 |
TRAPD(ret,aReqEntry->iMessage.WriteL(0,*dataDes1)); |
|
1884 |
if(ret!=KErrNone) |
|
1885 |
{ |
|
1886 |
PanicClient(EEtelPanicBadDescriptor,aReqEntry->iMessage); |
|
1887 |
break; |
|
1888 |
} |
|
1889 |
||
1890 |
TDes16* unicodeDataDes2=BufferDes2u(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1891 |
__ASSERT_ALWAYS(unicodeDataDes2!=NULL,Fault(EEtelFaultDes2DoesNotExist)); |
|
1892 |
||
1893 |
TRAP(ret,aReqEntry->iMessage.WriteL(2,*unicodeDataDes2)); |
|
1894 |
if(ret!=KErrNone) |
|
1895 |
{ |
|
1896 |
PanicClient(EEtelPanicBadDescriptor,aReqEntry->iMessage); |
|
1897 |
break; |
|
1898 |
} |
|
1899 |
} |
|
1900 |
aReqEntry->CompleteAndDeque(aError); |
|
1901 |
} |
|
1902 |
break; |
|
1903 |
||
1904 |
case EIsaNarrowDesToSetAndGet: |
|
1905 |
{ |
|
1906 |
if (aReqEntry->iClientInterested) |
|
1907 |
{ |
|
1908 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf8!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1909 |
// only write back the second parameter |
|
1910 |
TDes8* dataDes2=BufferDes2(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1911 |
__ASSERT_ALWAYS(dataDes2!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1912 |
||
1913 |
TRAPD(ret,aReqEntry->iMessage.WriteL(2,*dataDes2)); |
|
1914 |
if(ret!=KErrNone) |
|
1915 |
{ |
|
1916 |
PanicClient(EEtelPanicBadDescriptor,aReqEntry->iMessage); |
|
1917 |
break; |
|
1918 |
} |
|
1919 |
} |
|
1920 |
aReqEntry->CompleteAndDeque(aError); |
|
1921 |
} |
|
1922 |
break; |
|
1923 |
||
1924 |
case EIsaNarrowDesToGetUnicodeDesToSet: |
|
1925 |
{ |
|
1926 |
if (aReqEntry->iClientInterested) |
|
1927 |
{ |
|
1928 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf8!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1929 |
// only write back the first parameter |
|
1930 |
TDes8* dataDes1=BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1931 |
__ASSERT_ALWAYS(dataDes1!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1932 |
||
1933 |
TRAPD(ret,aReqEntry->iMessage.WriteL(0,*dataDes1)); |
|
1934 |
if(ret!=KErrNone) |
|
1935 |
{ |
|
1936 |
PanicClient(EEtelPanicBadDescriptor,aReqEntry->iMessage); |
|
1937 |
break; |
|
1938 |
} |
|
1939 |
} |
|
1940 |
aReqEntry->CompleteAndDeque(aError); |
|
1941 |
} |
|
1942 |
break; |
|
1943 |
||
1944 |
case EIsaUnicodeDesToSetAndGet: |
|
1945 |
case EIsaUnicodeDesToGetNarrowDesToSet: |
|
1946 |
{ |
|
1947 |
if (aReqEntry->iClientInterested) |
|
1948 |
{ |
|
1949 |
__ASSERT_ALWAYS(aReqEntry->iBuffer->iBuf16!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1950 |
// only write back the second parameter |
|
1951 |
TDes16* dataDes2=BufferDes2u(aReqEntry->iBuffer,CBuffer::ESlotRead); |
|
1952 |
__ASSERT_ALWAYS(dataDes2!=NULL,Fault(EETelFaultRequestWithoutBuffer)); |
|
1953 |
||
1954 |
TRAPD(ret,aReqEntry->iMessage.WriteL(2,*dataDes2)); |
|
1955 |
if(ret!=KErrNone) |
|
1956 |
{ |
|
1957 |
PanicClient(EEtelPanicBadDescriptor,aReqEntry->iMessage); |
|
1958 |
break; |
|
1959 |
} |
|
1960 |
} |
|
1961 |
aReqEntry->CompleteAndDeque(aError); |
|
1962 |
} |
|
1963 |
break; |
|
1964 |
||
1965 |
default: |
|
1966 |
Fault(EEtelFaultBadMessageType); |
|
1967 |
break; |
|
1968 |
} |
|
1969 |
aReqEntry->Deque(); |
|
1970 |
delete aReqEntry; |
|
1971 |
} |
|
1972 |
||
1973 |
EXPORT_C void CTelObject::FlowControlSuspend() |
|
1974 |
// |
|
1975 |
// Suspend the Request Flow |
|
1976 |
// |
|
1977 |
{ |
|
1978 |
PhoneOwner()->FlowControlInc(); |
|
1979 |
} |
|
1980 |
||
1981 |
||
1982 |
EXPORT_C void CTelObject::FlowControlResume() |
|
1983 |
||
1984 |
// |
|
1985 |
// Resume the Request Flow |
|
1986 |
// |
|
1987 |
{ |
|
1988 |
PhoneOwner()->FlowControlDec(); |
|
1989 |
if(PhoneOwner()->FlowControl()>0) // check for outstanding request |
|
1990 |
return; |
|
1991 |
||
1992 |
CReqEntry* reqEntry=PhoneOwner()->ActivateNextWaitingReq(); |
|
1993 |
if (reqEntry==NULL) |
|
1994 |
return; |
|
1995 |
||
1996 |
RMessage2& message=reqEntry->iMessage; |
|
1997 |
||
1998 |
CTelObject* theObj=reqEntry->iSession->CObjectFromHandle(message.Int3()); |
|
1999 |
__ASSERT_ALWAYS(theObj!=NULL, Fault(EEtelFaultWaitingReqLostCObject)); |
|
2000 |
theObj->GeneralReq(message,reqEntry->iSession,reqEntry, ETrue); |
|
2001 |
} |
|
2002 |
||
2003 |
// |
|
2004 |
// Future proofing in server |
|
2005 |
// |
|
2006 |
EXPORT_C TInt CTelObject::DownCallOption(TInt /*aOptionNumber*/, TAny* /*aData*/) |
|
2007 |
{ |
|
2008 |
return KErrNotSupported; |
|
2009 |
} |
|
2010 |
||
2011 |
EXPORT_C TInt CTelObject::UpCallOption(TInt /*aOptionNumber*/, TAny* /*aData*/) |
|
2012 |
{ |
|
2013 |
return KErrNotSupported; |
|
2014 |
} |
|
2015 |
||
2016 |
EXPORT_C TInt CTelObject::ServerVersion() const |
|
2017 |
// |
|
2018 |
// Lets TSY know which version of server this is, ie which extra options the server will support. |
|
2019 |
// |
|
2020 |
{ |
|
2021 |
return KETelServerVersion; |
|
2022 |
} |
|
2023 |
||
2024 |
EXPORT_C TSecurityPolicy CTelObject::GetRequiredPlatSecCaps(const TInt /*aIpc*/) |
|
2025 |
/** |
|
2026 |
* Default implementation of TSY side of the Etel capability policy checking delegation. |
|
2027 |
* If the TSY does not support CustomAPIs or the TSY does not implement it's own version |
|
2028 |
* of this virtual function, then this default implementation will get used and shall always |
|
2029 |
* return a policy that fails the capability check. |
|
2030 |
* |
|
2031 |
* @return This base implementation always returns a TSecurityPolicy::EAlwaysFail. |
|
2032 |
* @param aIpc This parameter is not used in the base implementation of this virtual function. |
|
2033 |
*/ |
|
2034 |
{ |
|
2035 |
return TSecurityPolicy(TSecurityPolicy::EAlwaysFail); |
|
2036 |
} |
|
2037 |
||
2038 |
||
2039 |
TDes8* CTelObject::BufferDes1(const CBuffer* aBuffer,CBuffer::TWhichSlot aWhichSlot) const |
|
2040 |
// |
|
2041 |
// Returns pointer to first descriptor in current slot. More specifically, a pointer to the |
|
2042 |
// TPtr which is stored just before the data that it points to. |
|
2043 |
||
2044 |
// The buffer is circular, and there are |
|
2045 |
// two "current" slots - one slot for where the next data should be written to by the TSY, |
|
2046 |
// the other from which the client should next read from. aWhichSlot specifies which of these |
|
2047 |
// should be returned. |
|
2048 |
// |
|
2049 |
{ |
|
2050 |
TDes8* des1=NULL; |
|
2051 |
if (aBuffer->iBuf8) |
|
2052 |
{ |
|
2053 |
TUint8* pos = aBuffer->CurrentSlotData1(aWhichSlot); |
|
2054 |
if (pos) |
|
2055 |
des1=reinterpret_cast<TDes8*> (pos); |
|
2056 |
} |
|
2057 |
return des1; |
|
2058 |
} |
|
2059 |
||
2060 |
TDes8* CTelObject::BufferDes2(const CBuffer* aBuffer,CBuffer::TWhichSlot aWhichSlot) const |
|
2061 |
{ |
|
2062 |
TDes8* des2=NULL; |
|
2063 |
if (aBuffer->iBuf8) |
|
2064 |
{ |
|
2065 |
TUint8* pos = aBuffer->CurrentSlotData2(aWhichSlot); |
|
2066 |
if (pos) |
|
2067 |
des2=reinterpret_cast<TDes8*> (pos); |
|
2068 |
} |
|
2069 |
return des2; |
|
2070 |
} |
|
2071 |
||
2072 |
TDes16* CTelObject::BufferDes1u(const CBuffer* aBuffer,CBuffer::TWhichSlot aWhichSlot) const |
|
2073 |
{ |
|
2074 |
TDes16* des1=NULL; |
|
2075 |
if (aBuffer->iBuf16) |
|
2076 |
{ |
|
2077 |
TUint16* pos = aBuffer->CurrentSlotData1u(aWhichSlot); |
|
2078 |
if (pos) |
|
2079 |
des1=reinterpret_cast<TDes16*> (pos); |
|
2080 |
} |
|
2081 |
return des1; |
|
2082 |
} |
|
2083 |
||
2084 |
TDes16* CTelObject::BufferDes2u(const CBuffer* aBuffer,CBuffer::TWhichSlot aWhichSlot) const |
|
2085 |
{ |
|
2086 |
TDes16* des2=NULL; |
|
2087 |
if (aBuffer->iBuf16) |
|
2088 |
{ |
|
2089 |
TUint16* pos = aBuffer->CurrentSlotData2u(aWhichSlot); |
|
2090 |
if (pos) |
|
2091 |
des2=reinterpret_cast<TDes16*> (pos); |
|
2092 |
} |
|
2093 |
return des2; |
|
2094 |
} |
|
2095 |
||
2096 |
TUint8* CTelObject::Ptr1(const TDes8* aDes1) const |
|
2097 |
// |
|
2098 |
// return the pointer to the data of the first descriptor |
|
2099 |
// return NULL if does not exist |
|
2100 |
// |
|
2101 |
{ |
|
2102 |
TUint8* ptr1=NULL; |
|
2103 |
if (aDes1) |
|
2104 |
ptr1=const_cast<TUint8*> (aDes1->Ptr()); |
|
2105 |
return ptr1; |
|
2106 |
} |
|
2107 |
||
2108 |
void CTelObject::RemoveDummySubSessionDestroyer() |
|
2109 |
{ |
|
2110 |
iDestroyDummySubSession = NULL; |
|
2111 |
} |
|
2112 |
||
2113 |
// |
|
2114 |
// |
|
2115 |
// CSubSessionExtBase |
|
2116 |
// |
|
2117 |
// |
|
2118 |
EXPORT_C CSubSessionExtBase::CSubSessionExtBase() |
|
2119 |
// |
|
2120 |
// C'Tor |
|
2121 |
// |
|
2122 |
{ |
|
2123 |
__DECLARE_NAME(_S("CSubSessionExtBase")); |
|
2124 |
} |
|
2125 |
||
2126 |
EXPORT_C CSubSessionExtBase::~CSubSessionExtBase() |
|
2127 |
// |
|
2128 |
// D'Tor |
|
2129 |
// |
|
2130 |
{} |
|
2131 |
||
2132 |
TInt CSubSessionExtBase::ServiceExtFunc(const RMessage2& aMessage,CReqEntry* aReqEntry) |
|
2133 |
// |
|
2134 |
// Sort out Des1 and Des2 before calling ExtFunc() |
|
2135 |
// |
|
2136 |
{ |
|
2137 |
__ASSERT_ALWAYS(aReqEntry!=NULL,Fault(EEtelFaultCallTsyServiceWithoutReqPackage)); |
|
2138 |
TTsyReqHandle tsyReqHandle=aReqEntry->iTsyReqHandle; |
|
2139 |
||
2140 |
LOGTEXT2("Entered ServiceExtFunc with TSY handle %d", tsyReqHandle); |
|
2141 |
TInt ret=KErrNone; |
|
2142 |
||
2143 |
TInt basicMessageType = aMessage.Int1() & ~(KPriorityClientReq); |
|
2144 |
switch (basicMessageType) |
|
2145 |
{ |
|
2146 |
case EIsaNull: |
|
2147 |
case EIsaCancelMessage: |
|
2148 |
{ |
|
2149 |
TDataPackage package; // a package with all data pointers nulled |
|
2150 |
ret=ExtFunc(tsyReqHandle,aMessage.Function(),package); |
|
2151 |
} |
|
2152 |
break; |
|
2153 |
case EIsaDesTobeSet: |
|
2154 |
case EIsaDesTobeRead: |
|
2155 |
case EIsaDoubleDesTobeSet: |
|
2156 |
case EIsaDoubleDesTobeRead: // may have been multi-slot registered |
|
2157 |
case EIsaNarrowDesToSetAndGet: |
|
2158 |
{ |
|
2159 |
TDes8* des1 = BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
2160 |
if (!des1) |
|
2161 |
{ |
|
2162 |
return KErrArgument; |
|
2163 |
} |
|
2164 |
TDes8* des2=NULL; |
|
2165 |
if (basicMessageType==EIsaDoubleDesTobeSet || |
|
2166 |
basicMessageType==EIsaDoubleDesTobeRead || |
|
2167 |
basicMessageType==EIsaNarrowDesToSetAndGet) |
|
2168 |
{ |
|
2169 |
des2=BufferDes2(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
2170 |
if (!des2) |
|
2171 |
{ |
|
2172 |
return KErrArgument; |
|
2173 |
} |
|
2174 |
} |
|
2175 |
TDataPackage package(des1,des2); |
|
2176 |
ret=ExtFunc(tsyReqHandle,aReqEntry->iFunction,package); |
|
2177 |
} |
|
2178 |
break; |
|
2179 |
case EIsaUnicodeDesTobeSet: |
|
2180 |
case EIsaUnicodeDesTobeRead: |
|
2181 |
case EIsaUnicodeDoubleDesTobeSet: |
|
2182 |
case EIsaUnicodeDoubleDesTobeRead: |
|
2183 |
case EIsaUnicodeDesToSetAndGet: |
|
2184 |
{ |
|
2185 |
TDes16* des1 = BufferDes1u(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
2186 |
if (!des1) |
|
2187 |
{ |
|
2188 |
return KErrArgument; |
|
2189 |
} |
|
2190 |
TDes16* des2=NULL; |
|
2191 |
if (basicMessageType==EIsaUnicodeDoubleDesTobeSet || |
|
2192 |
basicMessageType==EIsaUnicodeDoubleDesTobeRead || |
|
2193 |
basicMessageType==EIsaUnicodeDesToSetAndGet) |
|
2194 |
{ |
|
2195 |
des2 = BufferDes2u(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
2196 |
if (!des2) |
|
2197 |
{ |
|
2198 |
return KErrArgument; |
|
2199 |
} |
|
2200 |
} |
|
2201 |
TDataPackage package(des1,des2); |
|
2202 |
ret=ExtFunc(tsyReqHandle,aReqEntry->iFunction,package); |
|
2203 |
} |
|
2204 |
break; |
|
2205 |
case EIsaNarrowAndUnicodeDoubleDesTobeSet: |
|
2206 |
case EIsaNarrowAndUnicodeDoubleDesTobeRead: |
|
2207 |
case EIsaNarrowDesToGetUnicodeDesToSet: |
|
2208 |
case EIsaUnicodeDesToGetNarrowDesToSet: |
|
2209 |
{ |
|
2210 |
TDes8* des1 = BufferDes1(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
2211 |
if (!des1) |
|
2212 |
{ |
|
2213 |
return KErrArgument; |
|
2214 |
} |
|
2215 |
TDes16* des2=NULL; |
|
2216 |
des2=BufferDes2u(aReqEntry->iBuffer,CBuffer::ESlotWrite); |
|
2217 |
if (!des2) |
|
2218 |
{ |
|
2219 |
return KErrArgument; |
|
2220 |
} |
|
2221 |
TDataPackage package(des1,des2); |
|
2222 |
ret=ExtFunc(tsyReqHandle,aReqEntry->iFunction,package); |
|
2223 |
} |
|
2224 |
break; |
|
2225 |
||
2226 |
default: |
|
2227 |
Fault(EEtelFaultMessageTypeCorrupted); |
|
2228 |
break; |
|
2229 |
} |
|
2230 |
return ret; |
|
2231 |
} |
|
2232 |
||
2233 |
EXPORT_C TInt CSubSessionExtBase::Service(const RMessage2& aMessage, CReqEntry* aReqEntry) |
|
2234 |
// |
|
2235 |
// The ServiceL functionality for the ext base |
|
2236 |
// |
|
2237 |
{ |
|
2238 |
aReqEntry->iPlacedRequest=ETrue; |
|
2239 |
return ServiceExtFunc(aMessage,aReqEntry); |
|
2240 |
} |
|
2241 |
||
2242 |
EXPORT_C void CSubSessionExtBase::CloseSubSessionPreProcessing(CTelSession* aSession,const TInt aSubSessionHandle) |
|
2243 |
{ |
|
2244 |
CreateDummySession(aSession,aSubSessionHandle); |
|
2245 |
FlushReqs(aSession,aSubSessionHandle); |
|
2246 |
} |
|
2247 |
||
2248 |
EXPORT_C void CSubSessionExtBase::OpenPostProcessing(CTelSession* /*aSession*/,const TInt) |
|
2249 |
// |
|
2250 |
// Perform post-processing after object has been added to session's CObjectIx. |
|
2251 |
// |
|
2252 |
{ |
|
2253 |
} |
|
2254 |
||
2255 |
EXPORT_C RHandleBase* CSubSessionExtBase::GlobalKernelObjectHandle() |
|
2256 |
{ |
|
2257 |
return NULL; |
|
2258 |
} |
|
2259 |
||
2260 |
EXPORT_C void CSubSessionExtBase::NullMethod1() |
|
2261 |
{} |
|
2262 |
||
2263 |
EXPORT_C void CFaxBase::NullMethod2() |
|
2264 |
{} |
|
2265 |
||
2266 |
// |
|
2267 |
// |
|
2268 |
// CLibUnloader |
|
2269 |
// |
|
2270 |
// |
|
2271 |
CLibUnloader::CLibUnloader() |
|
2272 |
// |
|
2273 |
// C'tor |
|
2274 |
// |
|
2275 |
:CAsyncOneShot(CActive::EPriorityHigh) |
|
2276 |
{ |
|
2277 |
__DECLARE_NAME(_S("CLibUnloader")); |
|
2278 |
} |
|
2279 |
||
2280 |
CLibUnloader* CLibUnloader::NewL(RLibrary &aLib) |
|
2281 |
// |
|
2282 |
// New Library Unloader |
|
2283 |
// |
|
2284 |
{ |
|
2285 |
CLibUnloader *s=new(ELeave)CLibUnloader; |
|
2286 |
s->iLib=aLib; |
|
2287 |
return s; |
|
2288 |
} |
|
2289 |
||
2290 |
CLibUnloader::~CLibUnloader() |
|
2291 |
{ |
|
2292 |
Cancel(); |
|
2293 |
iLib.Close(); |
|
2294 |
} |
|
2295 |
||
2296 |
void CLibUnloader::RunL() |
|
2297 |
// |
|
2298 |
// Unload TSY module |
|
2299 |
// |
|
2300 |
{ |
|
2301 |
delete this; |
|
2302 |
} |
|
2303 |
||
2304 |
// |
|
2305 |
// |
|
2306 |
// CPhoneFactoryBase definition |
|
2307 |
// |
|
2308 |
// |
|
2309 |
EXPORT_C TBool CPhoneFactoryBase::QueryVersionSupported( TVersion const & aVersion )const |
|
2310 |
// |
|
2311 |
// Pass through to default QVS |
|
2312 |
// |
|
2313 |
{ |
|
2314 |
return(User::QueryVersionSupported(iVersion,aVersion)); |
|
2315 |
} |
|
2316 |
||
2317 |
EXPORT_C CPhoneFactoryBase::CPhoneFactoryBase() |
|
2318 |
// |
|
2319 |
// C'Tor |
|
2320 |
// |
|
2321 |
{ |
|
2322 |
__DECLARE_NAME(_S("CPhoneFactoryBase")); |
|
2323 |
} |
|
2324 |
||
2325 |
void CPhoneFactoryBase::ConstructL(RLibrary& aLib) |
|
2326 |
// |
|
2327 |
// Allocate a CLibrary Unloader |
|
2328 |
// |
|
2329 |
{ |
|
2330 |
iLibUnloader=CLibUnloader::NewL(aLib); |
|
2331 |
} |
|
2332 |
||
2333 |
EXPORT_C CPhoneFactoryBase::~CPhoneFactoryBase() |
|
2334 |
// |
|
2335 |
// D'Tor |
|
2336 |
// |
|
2337 |
{ |
|
2338 |
if (iLibUnloader) |
|
2339 |
{ |
|
2340 |
LOGTEXT("About to call iLibUnloader"); |
|
2341 |
iLibUnloader->Call(); |
|
2342 |
} |
|
2343 |
} |
|
2344 |
||
2345 |
EXPORT_C void CPhoneFactoryBase::CPhoneFactoryBase_Reserved1() |
|
2346 |
// |
|
2347 |
// Reserved virtual function |
|
2348 |
// |
|
2349 |
{} |
|
2350 |
||
2351 |
// |
|
2352 |
// HEtelBufC definitions |
|
2353 |
// |
|
2354 |
||
2355 |
||
2356 |
// |
|
2357 |
// HEtelBufC8 |
|
2358 |
// |
|
2359 |
HEtelBufC8* HEtelBufC8::NewMaxLC(TInt aMaxLength,RHeap* aHeap) |
|
2360 |
{ |
|
2361 |
__ASSERT_ALWAYS(aMaxLength>=0,Fault(EEtelFaultMaxDesLengthNegative)); |
|
2362 |
||
2363 |
HEtelBufC8* pH=NULL; |
|
2364 |
TInt size=sizeof(HEtelBufC8)+(aMaxLength*sizeof(TUint8)); |
|
2365 |
if (aHeap!=NULL) |
|
2366 |
pH=(HEtelBufC8*)aHeap->AllocLC(size); |
|
2367 |
else |
|
2368 |
pH=(HEtelBufC8*)User::AllocLC(size); |
|
2369 |
pH->iLength=aMaxLength; |
|
2370 |
pH->iHeap=aHeap; |
|
2371 |
pH->Des().SetLength(aMaxLength); |
|
2372 |
return(pH); |
|
2373 |
} |
|
2374 |
||
2375 |
TPtr8 HEtelBufC8::Des() |
|
2376 |
{ |
|
2377 |
TUint8* ptr = reinterpret_cast<TUint8*> (((reinterpret_cast<TInt> (this)) + |
|
2378 |
sizeof(HEtelBufC8)) |
|
2379 |
); |
|
2380 |
return TPtr8(ptr,iLength,iLength); |
|
2381 |
} |
|
2382 |
||
2383 |
const TUint8* HEtelBufC8::Ptr() const |
|
2384 |
{ |
|
2385 |
return reinterpret_cast<const TUint8*> (((reinterpret_cast<TInt> (this)) + |
|
2386 |
sizeof(HEtelBufC8)) |
|
2387 |
); |
|
2388 |
} |
|
2389 |
||
2390 |
void HEtelBufC8::operator delete(TAny* aPtr) |
|
2391 |
// |
|
2392 |
// overloaded delete - deletes from priority client heap if iHeap is not NULL |
|
2393 |
// |
|
2394 |
{ |
|
2395 |
RHeap* heap=NULL; |
|
2396 |
if (aPtr!=NULL) |
|
2397 |
{ |
|
2398 |
heap = (reinterpret_cast<HEtelBufC8*> (aPtr))->iHeap; |
|
2399 |
} |
|
2400 |
||
2401 |
if (heap!=NULL) |
|
2402 |
{ |
|
2403 |
reinterpret_cast<HEtelBufC8*> (aPtr)->iHeap->Free(aPtr); |
|
2404 |
} |
|
2405 |
else |
|
2406 |
{ |
|
2407 |
User::Free(aPtr); |
|
2408 |
} |
|
2409 |
} |
|
2410 |
||
2411 |
// |
|
2412 |
// HEtelBufC16 |
|
2413 |
// |
|
2414 |
HEtelBufC16* HEtelBufC16::NewMaxLC(TInt aMaxLength,RHeap* aHeap) |
|
2415 |
{ |
|
2416 |
__ASSERT_ALWAYS(aMaxLength>=0,Fault(EEtelFaultMaxDesLengthNegative)); |
|
2417 |
||
2418 |
HEtelBufC16* pH=NULL; |
|
2419 |
TInt size=sizeof(HEtelBufC16)+(aMaxLength*sizeof(TUint16)); |
|
2420 |
if (aHeap!=NULL) |
|
2421 |
pH=(HEtelBufC16*)aHeap->AllocLC(size); |
|
2422 |
else |
|
2423 |
pH=(HEtelBufC16*)User::AllocLC(size); |
|
2424 |
pH->iLength=aMaxLength; |
|
2425 |
pH->iHeap=aHeap; |
|
2426 |
pH->Des().SetLength(aMaxLength); |
|
2427 |
return(pH); |
|
2428 |
} |
|
2429 |
||
2430 |
TPtr16 HEtelBufC16::Des() |
|
2431 |
{ |
|
2432 |
TUint16* ptr=reinterpret_cast<TUint16*> ((reinterpret_cast<TInt> (this)+sizeof(HEtelBufC16))); |
|
2433 |
return TPtr16(ptr,iLength,iLength); |
|
2434 |
} |
|
2435 |
||
2436 |
const TUint16* HEtelBufC16::Ptr() const |
|
2437 |
{ |
|
2438 |
return reinterpret_cast<const TUint16*> ((reinterpret_cast<TInt> (this)+sizeof(HEtelBufC16))); |
|
2439 |
} |
|
2440 |
||
2441 |
void HEtelBufC16::operator delete(TAny* aPtr) |
|
2442 |
// |
|
2443 |
// overloaded delete - deletes from priority client heap if iHeap is not NULL |
|
2444 |
// |
|
2445 |
{ |
|
2446 |
RHeap* heap=NULL; |
|
2447 |
if (aPtr!=NULL) |
|
2448 |
heap=reinterpret_cast<HEtelBufC16*> (aPtr)->iHeap; |
|
2449 |
||
2450 |
if (heap!=NULL) |
|
2451 |
reinterpret_cast<HEtelBufC16*> (aPtr)->iHeap->Free(aPtr); |
|
2452 |
else |
|
2453 |
User::Free(aPtr); |
|
2454 |
} |
|
2455 |
||
2456 |
// |
|
2457 |
// TDataPackage class contains the data pointers to be passed down to the TSY in ExtFunc() |
|
2458 |
// |
|
2459 |
TDataPackage::TDataPackage() |
|
2460 |
: iDes1(NULL),iDes2(NULL),iDes1u(NULL),iDes2u(NULL) |
|
2461 |
{} |
|
2462 |
TDataPackage::TDataPackage(TDes8* aDes1, TDes8* aDes2) |
|
2463 |
: iDes1(aDes1),iDes2(aDes2),iDes1u(NULL),iDes2u(NULL) |
|
2464 |
{} |
|
2465 |
||
2466 |
TDataPackage::TDataPackage(TDes16* aDes1, TDes16* aDes2) |
|
2467 |
: iDes1(NULL),iDes2(NULL),iDes1u(aDes1),iDes2u(aDes2) |
|
2468 |
{} |
|
2469 |
TDataPackage::TDataPackage(TDes8* aDes1, TDes16* aDes2) |
|
2470 |
: iDes1(aDes1),iDes2(NULL),iDes1u(NULL),iDes2u(aDes2) |
|
2471 |
{} |
|
2472 |
||
2473 |
EXPORT_C TDes8* TDataPackage::Des1n() const |
|
2474 |
{ |
|
2475 |
__ASSERT_ALWAYS(iDes1,Fault(EEtelFaultDes1DoesNotExist)); |
|
2476 |
return iDes1; |
|
2477 |
} |
|
2478 |
EXPORT_C TDes8* TDataPackage::Des2n() const |
|
2479 |
{ |
|
2480 |
__ASSERT_ALWAYS(iDes2,Fault(EEtelFaultDes2DoesNotExist)); |
|
2481 |
return iDes2; |
|
2482 |
} |
|
2483 |
EXPORT_C TDes16* TDataPackage::Des1u() const |
|
2484 |
{ |
|
2485 |
__ASSERT_ALWAYS(iDes1u,Fault(EEtelFaultDes1DoesNotExist)); |
|
2486 |
return iDes1u; |
|
2487 |
} |
|
2488 |
EXPORT_C TDes16* TDataPackage::Des2u() const |
|
2489 |
{ |
|
2490 |
__ASSERT_ALWAYS(iDes2u,Fault(EEtelFaultDes2DoesNotExist)); |
|
2491 |
return iDes2u; |
|
2492 |
} |
|
2493 |
||
2494 |
EXPORT_C TAny* TDataPackage::Ptr1() const |
|
2495 |
{ |
|
2496 |
if (iDes1u) |
|
2497 |
return reinterpret_cast<TAny*> (const_cast<TUint16*> (iDes1u->Ptr())); |
|
2498 |
if (iDes1) |
|
2499 |
return reinterpret_cast<TAny*> (const_cast<TUint8*> (iDes1->Ptr())); |
|
2500 |
return NULL; |
|
2501 |
} |
|
2502 |
||
2503 |
EXPORT_C TAny* TDataPackage::Ptr2() const |
|
2504 |
{ |
|
2505 |
if (iDes2u) |
|
2506 |
return reinterpret_cast<TAny*> (const_cast<TUint16*> (iDes2u->Ptr())); |
|
2507 |
if (iDes2) |
|
2508 |
return reinterpret_cast<TAny*> (const_cast<TUint8*> (iDes2->Ptr())); |
|
2509 |
return NULL; |
|
2510 |
} |
|
2511 |
||
2512 |
/** |
|
2513 |
* This helper utility returns the type of a packaged data structure. |
|
2514 |
* It is very useful to know which type of variables (unicode or narrow) a package contains |
|
2515 |
* before passing it to any functions. It could also help to provide more generic implementation |
|
2516 |
* on the TSY, that currently assumes knowledge of the way the data are packaged. |
|
2517 |
* |
|
2518 |
*/ |
|
2519 |
||
2520 |
EXPORT_C TDataPackage::TDataPackageType TDataPackage::Type() const |
|
2521 |
{ |
|
2522 |
if(iDes1 && iDes2) |
|
2523 |
return EPackage1n2n; |
|
2524 |
else if (iDes1u && iDes2u) |
|
2525 |
return EPackage1u2u; |
|
2526 |
else if (iDes1 && iDes2u) |
|
2527 |
return EPackage1n2u; |
|
2528 |
else if (iDes1 && !iDes2) |
|
2529 |
return EPackage1n; |
|
2530 |
else if (iDes1u && !iDes2u) |
|
2531 |
return EPackage1u; |
|
2532 |
else |
|
2533 |
return EPackageUnknown; |
|
2534 |
} |
|
2535 |
||
2536 |
/** |
|
2537 |
Non-exported static factory constructor. This class should only be instantiated by Etel server. |
|
2538 |
*/ |
|
2539 |
CFaxSharedFileHandles* CFaxSharedFileHandles::NewL(const RMessage2& aMsg) |
|
2540 |
{ |
|
2541 |
CFaxSharedFileHandles* obj = new(ELeave) CFaxSharedFileHandles(); |
|
2542 |
CleanupStack::PushL(obj); |
|
2543 |
obj->ConstructL(aMsg); |
|
2544 |
CleanupStack::Pop(obj); |
|
2545 |
return obj; |
|
2546 |
} |
|
2547 |
||
2548 |
/** |
|
2549 |
Destructor. |
|
2550 |
||
2551 |
@publishedPartner |
|
2552 |
@released |
|
2553 |
*/ |
|
2554 |
EXPORT_C CFaxSharedFileHandles::~CFaxSharedFileHandles() |
|
2555 |
{ |
|
2556 |
iFile.Close(); |
|
2557 |
} |
|
2558 |
||
2559 |
/** |
|
2560 |
Default constructor. |
|
2561 |
*/ |
|
2562 |
CFaxSharedFileHandles::CFaxSharedFileHandles() |
|
2563 |
{ |
|
2564 |
//empty |
|
2565 |
} |
|
2566 |
||
2567 |
/** |
|
2568 |
Reference to an adopted file. |
|
2569 |
||
2570 |
@return RFile& Reference to an open file handle. |
|
2571 |
@publishedPartner |
|
2572 |
@released |
|
2573 |
*/ |
|
2574 |
EXPORT_C RFile& CFaxSharedFileHandles::File() |
|
2575 |
{ |
|
2576 |
return iFile; |
|
2577 |
}; |
|
2578 |
||
2579 |
/** |
|
2580 |
Adopt the file during construction. |
|
2581 |
*/ |
|
2582 |
void CFaxSharedFileHandles::ConstructL(const RMessage2& aMsg) |
|
2583 |
{ |
|
2584 |
//Use the RMessage2 and EKA2 adopt functions to adopt the file. Slots 0 & 2 contain relevant session handles. |
|
2585 |
User::LeaveIfError(iFile.AdoptFromClient(aMsg, 0, 2)); |
|
2586 |
} |