|
1 /* |
|
2 * Copyright (c) 2009 Sony Ericsson Mobile Communications AB |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Sony Ericsson Mobile Communications AB - initial contribution. |
|
11 * Nokia Corporation - additional changes. |
|
12 * |
|
13 * Contributors: |
|
14 * |
|
15 * Description: |
|
16 * TelephonyActPhone.cpp |
|
17 * Code for TelephonyActPhone class, used by CTelephonyFunctions class. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 */ |
|
25 |
|
26 #include "TelephonyFunctions.h" |
|
27 #include "TelephonyActCall.h" |
|
28 |
|
29 CDialNewCallAct* CDialNewCallAct::NewL(CTelephonyFunctions* aTelephonyFunctions) |
|
30 /** |
|
31 Public constructor which can Leave(). |
|
32 |
|
33 @param aTelephonyFunctions Object that constructs us. |
|
34 @leave Leaves if no memory. |
|
35 */ |
|
36 { |
|
37 CDialNewCallAct* self = new(ELeave) CDialNewCallAct(aTelephonyFunctions); |
|
38 CActiveScheduler::Add(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 CDialNewCallAct::~CDialNewCallAct() |
|
43 /** |
|
44 Destructor |
|
45 */ |
|
46 { |
|
47 Cancel(); |
|
48 Complete(); |
|
49 } |
|
50 |
|
51 void CDialNewCallAct::DialNewCall(TDes8& aCallParams,const CTelephony::TTelNumber& aTelNumber, CTelephony::TCallId& aCallId, |
|
52 CTelephony::TCallId& aTempCallId) |
|
53 /** |
|
54 Issue dial request |
|
55 */ |
|
56 { |
|
57 iISVcallParams = reinterpret_cast<CTelephony::TCallParamsV1*> ( const_cast<TUint8*> (aCallParams.Ptr()) ); |
|
58 iCallId=&aCallId; |
|
59 iTempCallId=aTempCallId; |
|
60 |
|
61 switch(iISVcallParams->iIdRestrict) |
|
62 { |
|
63 case CTelephony::ESendMyId: |
|
64 iMMcallParams.iIdRestrict = RMobileCall::ESendMyId; |
|
65 break; |
|
66 case CTelephony::EDontSendMyId: |
|
67 iMMcallParams.iIdRestrict = RMobileCall::EDontSendMyId; |
|
68 break; |
|
69 case CTelephony::EIdRestrictDefault: |
|
70 default: |
|
71 iMMcallParams.iIdRestrict = RMobileCall::EIdRestrictDefault; |
|
72 break; |
|
73 } |
|
74 iTelephonyFunctions->Call(iTempCallId)->DialISV(iStatus, iMMCallParamsPckg, aTelNumber); |
|
75 SetActive(); |
|
76 } |
|
77 |
|
78 |
|
79 void CDialNewCallAct::Complete() |
|
80 /** |
|
81 Service Completed request. |
|
82 |
|
83 @leave Leaves if System error. |
|
84 */ |
|
85 { |
|
86 if(iTelephonyFunctions->IsRequestPending(CTelephonyFunctions::EDialNewCall)) |
|
87 { |
|
88 if(iStatus == KErrNone) |
|
89 { |
|
90 *iCallId=iTempCallId; |
|
91 } |
|
92 else if(iStatus != KRequestPending && iStatus != KErrNone) |
|
93 { |
|
94 iTelephonyFunctions->CloseAndReset(iTempCallId); |
|
95 } |
|
96 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EDialNewCall, iStatus.Int()); |
|
97 } |
|
98 } |
|
99 |
|
100 |
|
101 TInt CDialNewCallAct::RunError(TInt aLeaveCode) |
|
102 /** |
|
103 Handle any Leave() from inside RunL(). |
|
104 |
|
105 @param aLeaveCode passed in if RunL Leaves. |
|
106 @return KErrNone. |
|
107 */ |
|
108 { |
|
109 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EDialNewCall, aLeaveCode); |
|
110 return KErrNone; |
|
111 } |
|
112 |
|
113 void CDialNewCallAct::DoCancel() |
|
114 /** |
|
115 Cancel request. |
|
116 |
|
117 Async request to dial is cancelled. |
|
118 */ |
|
119 { |
|
120 if(iTelephonyFunctions->Call(iTempCallId)) |
|
121 { |
|
122 iTelephonyFunctions->Call(iTempCallId)->CancelAsyncRequest(EMobileCallDialISV); |
|
123 } |
|
124 } |
|
125 |
|
126 |
|
127 CDialNewCallAct::CDialNewCallAct(CTelephonyFunctions* aTelephonyFunctions) |
|
128 : CAsyncRequestBaseAct(), |
|
129 iTelephonyFunctions(aTelephonyFunctions), |
|
130 iMMCallParamsPckg(iMMcallParams) |
|
131 /** |
|
132 First-phase constructor which cannot Leave(). |
|
133 |
|
134 @param aTelephonyFunctions Object that constructs us. |
|
135 */ |
|
136 { |
|
137 } |
|
138 |
|
139 CHoldAct* CHoldAct::NewL(CTelephonyFunctions* aTelephonyFunctions) |
|
140 /** |
|
141 Public constructor which can Leave(). |
|
142 |
|
143 @param aTelephonyFunctions Object that constructs us. |
|
144 @leave Leaves if no memory. |
|
145 */ |
|
146 { |
|
147 CHoldAct* self = new(ELeave) CHoldAct(aTelephonyFunctions); |
|
148 CActiveScheduler::Add(self); |
|
149 return self; |
|
150 } |
|
151 |
|
152 CHoldAct::~CHoldAct() |
|
153 /** |
|
154 Destructor |
|
155 */ |
|
156 { |
|
157 Cancel(); |
|
158 Complete(); |
|
159 } |
|
160 |
|
161 void CHoldAct::Hold(const CTelephony::TCallId& aCallId) |
|
162 /** |
|
163 Issue Request |
|
164 */ |
|
165 { |
|
166 iCallId = aCallId; |
|
167 iTelephonyFunctions->Call(aCallId)->Hold(iStatus); |
|
168 SetActive(); |
|
169 } |
|
170 |
|
171 |
|
172 void CHoldAct::Complete() |
|
173 /** |
|
174 Service Completed request. |
|
175 |
|
176 @leave Leaves if System error. |
|
177 */ |
|
178 { |
|
179 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EHold, iStatus.Int()); |
|
180 } |
|
181 |
|
182 |
|
183 TInt CHoldAct::RunError(TInt aLeaveCode) |
|
184 /** |
|
185 Handle any Leave() from inside RunL(). |
|
186 |
|
187 @param aLeaveCode passed in if RunL Leaves. |
|
188 @return KErrNone. |
|
189 */ |
|
190 { |
|
191 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EHold, aLeaveCode); |
|
192 return KErrNone; |
|
193 } |
|
194 |
|
195 void CHoldAct::DoCancel() |
|
196 /** |
|
197 Cancel request. |
|
198 |
|
199 Async request to dial is cancelled. |
|
200 */ |
|
201 { |
|
202 if(iTelephonyFunctions->Call(iCallId)) |
|
203 { |
|
204 iTelephonyFunctions->Call(iCallId)->CancelAsyncRequest(EMobileCallHold); |
|
205 } |
|
206 } |
|
207 |
|
208 |
|
209 CHoldAct::CHoldAct(CTelephonyFunctions* aTelephonyFunctions) |
|
210 : CAsyncRequestBaseAct(), |
|
211 iTelephonyFunctions(aTelephonyFunctions) |
|
212 /** |
|
213 First-phase constructor which cannot Leave(). |
|
214 |
|
215 @param aTelephonyFunctions Object that constructs us. |
|
216 */ |
|
217 { |
|
218 } |
|
219 |
|
220 |
|
221 CResumeAct* CResumeAct::NewL(CTelephonyFunctions* aTelephonyFunctions) |
|
222 /** |
|
223 Public constructor which can Leave(). |
|
224 |
|
225 @param aTelephonyFunctions Object that constructs us. |
|
226 @leave Leaves if no memory. |
|
227 */ |
|
228 { |
|
229 CResumeAct* self = new(ELeave) CResumeAct(aTelephonyFunctions); |
|
230 CActiveScheduler::Add(self); |
|
231 return self; |
|
232 } |
|
233 |
|
234 CResumeAct::~CResumeAct() |
|
235 /** |
|
236 Destructor |
|
237 */ |
|
238 { |
|
239 Cancel(); |
|
240 Complete(); |
|
241 } |
|
242 |
|
243 void CResumeAct::Resume(const CTelephony::TCallId& aCallId) |
|
244 /** |
|
245 Issue Request |
|
246 */ |
|
247 { |
|
248 iCallId = aCallId; |
|
249 iTelephonyFunctions->Call(aCallId)->Resume(iStatus); |
|
250 SetActive(); |
|
251 } |
|
252 |
|
253 |
|
254 void CResumeAct::Complete() |
|
255 /** |
|
256 Service Completed request. |
|
257 */ |
|
258 { |
|
259 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EResume, iStatus.Int()); |
|
260 } |
|
261 |
|
262 |
|
263 TInt CResumeAct::RunError(TInt aLeaveCode) |
|
264 /** |
|
265 Handle any Leave() from inside RunL(). |
|
266 |
|
267 @param aLeaveCode passed in if RunL Leaves. |
|
268 @return KErrNone. |
|
269 */ |
|
270 { |
|
271 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EResume, aLeaveCode); |
|
272 return KErrNone; |
|
273 } |
|
274 |
|
275 void CResumeAct::DoCancel() |
|
276 /** |
|
277 Cancel request. |
|
278 |
|
279 Async request to dial is cancelled. |
|
280 */ |
|
281 { |
|
282 if(iTelephonyFunctions->Call(iCallId)) |
|
283 { |
|
284 iTelephonyFunctions->Call(iCallId)->CancelAsyncRequest(EMobileCallResume); |
|
285 } |
|
286 } |
|
287 |
|
288 |
|
289 CResumeAct::CResumeAct(CTelephonyFunctions* aTelephonyFunctions) |
|
290 : CAsyncRequestBaseAct(), |
|
291 iTelephonyFunctions(aTelephonyFunctions) |
|
292 /** |
|
293 First-phase constructor which cannot Leave(). |
|
294 |
|
295 @param aTelephonyFunctions Object that constructs us. |
|
296 */ |
|
297 { |
|
298 } |
|
299 |
|
300 |
|
301 CSwapAct* CSwapAct::NewL(CTelephonyFunctions* aTelephonyFunctions) |
|
302 /** |
|
303 Public constructor which can Leave(). |
|
304 |
|
305 @param aTelephonyFunctions Object that constructs us. |
|
306 @leave Leaves if no memory. |
|
307 */ |
|
308 { |
|
309 CSwapAct* self = new(ELeave) CSwapAct(aTelephonyFunctions); |
|
310 CActiveScheduler::Add(self); |
|
311 return self; |
|
312 } |
|
313 |
|
314 CSwapAct::~CSwapAct() |
|
315 /** |
|
316 Destructor |
|
317 */ |
|
318 { |
|
319 Cancel(); |
|
320 Complete(); |
|
321 } |
|
322 |
|
323 void CSwapAct::Swap(const CTelephony::TCallId& aCallId) |
|
324 /** |
|
325 Issue Request |
|
326 */ |
|
327 { |
|
328 iCallId = aCallId; |
|
329 iTelephonyFunctions->Call(aCallId)->Swap(iStatus); |
|
330 SetActive(); |
|
331 } |
|
332 |
|
333 |
|
334 void CSwapAct::Complete() |
|
335 /** |
|
336 Service Completed request. |
|
337 */ |
|
338 { |
|
339 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::ESwap, iStatus.Int()); |
|
340 } |
|
341 |
|
342 |
|
343 TInt CSwapAct::RunError(TInt aLeaveCode) |
|
344 /** |
|
345 Handle any Leave() from inside RunL(). |
|
346 |
|
347 @param aLeaveCode passed in if RunL Leaves. |
|
348 @return KErrNone. |
|
349 */ |
|
350 { |
|
351 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::ESwap, aLeaveCode); |
|
352 return KErrNone; |
|
353 } |
|
354 |
|
355 void CSwapAct::DoCancel() |
|
356 /** |
|
357 Cancel request. |
|
358 |
|
359 Async request to dial is cancelled. |
|
360 */ |
|
361 { |
|
362 if(iTelephonyFunctions->Call(iCallId)) |
|
363 { |
|
364 iTelephonyFunctions->Call(iCallId)->CancelAsyncRequest(EMobileCallSwap); |
|
365 } |
|
366 } |
|
367 |
|
368 |
|
369 CSwapAct::CSwapAct(CTelephonyFunctions* aTelephonyFunctions) |
|
370 : CAsyncRequestBaseAct(), |
|
371 iTelephonyFunctions(aTelephonyFunctions) |
|
372 /** |
|
373 First-phase constructor which cannot Leave(). |
|
374 |
|
375 @param aTelephonyFunctions Object that constructs us. |
|
376 */ |
|
377 { |
|
378 } |
|
379 |
|
380 |
|
381 CHangupAct* CHangupAct::NewL(CTelephonyFunctions* aTelephonyFunctions) |
|
382 /** |
|
383 Public constructor which can Leave(). |
|
384 |
|
385 @param aTelephonyFunctions Object that constructs us. |
|
386 @leave Leaves if no memory. |
|
387 */ |
|
388 { |
|
389 CHangupAct* self = new(ELeave) CHangupAct(aTelephonyFunctions); |
|
390 CActiveScheduler::Add(self); |
|
391 return self; |
|
392 } |
|
393 |
|
394 CHangupAct::~CHangupAct() |
|
395 /** |
|
396 Destructor |
|
397 */ |
|
398 { |
|
399 Cancel(); |
|
400 Complete(); |
|
401 } |
|
402 |
|
403 void CHangupAct::Hangup(const CTelephony::TCallId& aCallId) |
|
404 /** |
|
405 Issue Request |
|
406 */ |
|
407 { |
|
408 iCallId = aCallId; |
|
409 iTelephonyFunctions->Call(aCallId)->HangUp(iStatus); |
|
410 SetActive(); |
|
411 } |
|
412 |
|
413 |
|
414 void CHangupAct::Complete() |
|
415 /** |
|
416 Service Completed request. |
|
417 */ |
|
418 { |
|
419 if(iTelephonyFunctions->IsRequestPending(CTelephonyFunctions::EHangup)) |
|
420 { |
|
421 if(iStatus == KErrNone) //close the call handle if hangup was successful |
|
422 { |
|
423 //close and reset call handle |
|
424 iTelephonyFunctions->CloseAndReset(iCallId); |
|
425 } |
|
426 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EHangup, iStatus.Int()); |
|
427 } |
|
428 } |
|
429 |
|
430 |
|
431 TInt CHangupAct::RunError(TInt aLeaveCode) |
|
432 /** |
|
433 Handle any Leave() from inside RunL(). |
|
434 |
|
435 @param aLeaveCode passed in if RunL Leaves. |
|
436 @return KErrNone. |
|
437 */ |
|
438 { |
|
439 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EHangup, aLeaveCode); |
|
440 return KErrNone; |
|
441 } |
|
442 |
|
443 void CHangupAct::DoCancel() |
|
444 /** |
|
445 Cancel request. |
|
446 |
|
447 Async request to dial is cancelled. |
|
448 */ |
|
449 { |
|
450 if(iTelephonyFunctions->Call(iCallId)) |
|
451 { |
|
452 iTelephonyFunctions->Call(iCallId)->CancelAsyncRequest(EEtelCallHangUp); |
|
453 } |
|
454 } |
|
455 |
|
456 |
|
457 CHangupAct::CHangupAct(CTelephonyFunctions* aTelephonyFunctions) |
|
458 : CAsyncRequestBaseAct(), |
|
459 iTelephonyFunctions(aTelephonyFunctions) |
|
460 /** |
|
461 First-phase constructor which cannot Leave(). |
|
462 |
|
463 @param aTelephonyFunctions Object that constructs us. |
|
464 */ |
|
465 { |
|
466 } |
|
467 |
|
468 /** |
|
469 Public constructor which can Leave(). |
|
470 |
|
471 @param aTelephonyFunctions Object that constructs this object. |
|
472 @param aIncomingCallNameSubject Reference to an active object owned by iTelephonyFunctions. Used to retrieve the call name of the new incoming call. |
|
473 @param aCallPool Reference to the call pool array owned by aTelephonyFunctions |
|
474 @param aCallPoolStatus Reference to the call pool status array owned by aTelephonyFunction |
|
475 |
|
476 @leave Leaves if no memory. |
|
477 @return A pointer to the created CAnswerIncomingCallAct object. |
|
478 */ |
|
479 CAnswerIncomingCallAct* CAnswerIncomingCallAct::NewL(CTelephonyFunctions* aTelephonyFunctions, MIncomingCallNameSubject& aIncomingCallNameSubject, RArray<RMobileCall>& aCallPool, RArray<CTelephonyFunctions::TCallPoolOperation>& aCallPoolStatus) |
|
480 { |
|
481 CAnswerIncomingCallAct* self = new(ELeave) CAnswerIncomingCallAct(aTelephonyFunctions, aIncomingCallNameSubject, aCallPool, aCallPoolStatus); |
|
482 CleanupStack::PushL(self); |
|
483 self->ConstructL(); |
|
484 CleanupStack::Pop(self); |
|
485 return self; |
|
486 } |
|
487 |
|
488 /** |
|
489 Second phase constructor. |
|
490 */ |
|
491 void CAnswerIncomingCallAct::ConstructL() |
|
492 { |
|
493 // Create timer for use later if needed. |
|
494 User::LeaveIfError(iTimer.CreateLocal()); |
|
495 // Register interest in receiving notification when a |
|
496 // new incoming call is received. |
|
497 iIncomingCallNameSubject.RegisterObserver(this); |
|
498 CActiveScheduler::Add(this); |
|
499 } |
|
500 |
|
501 /** |
|
502 Default destructor. |
|
503 */ |
|
504 CAnswerIncomingCallAct::~CAnswerIncomingCallAct() |
|
505 { |
|
506 iIncomingCallNameSubject.DeregisterObserver(this); |
|
507 Cancel(); |
|
508 Complete(); |
|
509 iTimer.Close(); |
|
510 } |
|
511 |
|
512 /** |
|
513 Issue Request. |
|
514 |
|
515 This AO starts off in the EAnswerIncomingCallStateIdle state. |
|
516 In order to answer the incoming call, the line must be ringing and |
|
517 the CNotifyIncomingCallAct AO must have completed. When this |
|
518 function is called, it checks if CNotifyIncomingCallAct |
|
519 has a valid call name available. This means that the notify incoming |
|
520 call event has completed and the call object has been created. |
|
521 When this happens, the call can be answered. This AO then moves into |
|
522 the EAnswerIncomingCallStateAnswering state and proceeds to answer |
|
523 the call. If CNotifyIncomingCallAct does not have a valid |
|
524 call name available, then there is no guarantee that the call object |
|
525 exists and hence the call cannot be answered yet. If this happens, |
|
526 this AO will move into the EAnswerIncomingCallStateWaiting |
|
527 state and will wait for up to 1 second for CNotifyIncomingCallAct |
|
528 AO to complete. If it does complete during or when this one second |
|
529 interval is up, an attempt to answer the call will be made, otherwise |
|
530 KErrTimedOut will be returned back to the client. |
|
531 |
|
532 @param aCallId Stores the call ID which will be returned to the client. |
|
533 @param aTempCallId Stores free call ID. |
|
534 */ |
|
535 void CAnswerIncomingCallAct::AnswerIncomingCall(CTelephony::TCallId& aCallId, CTelephony::TCallId& aTempCallId) |
|
536 { |
|
537 iCallId=&aCallId; |
|
538 iTempCallId=aTempCallId; |
|
539 |
|
540 switch (iState) |
|
541 { |
|
542 case EAnswerIncomingCallStateIdle: |
|
543 case EAnswerIncomingCallStateAnswering: |
|
544 { |
|
545 TName callName; |
|
546 if (iIncomingCallNameSubject.CallName(callName) == KErrNone) |
|
547 { |
|
548 // A valid call name is available, therefore there |
|
549 // is a new incoming call. The notify incoming call |
|
550 // event has completed, therefore it is possible to |
|
551 // answer the call. |
|
552 iState = EAnswerIncomingCallStateAnswering; |
|
553 |
|
554 // Create subsession with ringing call object. |
|
555 // Open a call using the voice line and the call name |
|
556 // of the incoming call. |
|
557 TInt ret = iCallPool[iTempCallId].OpenExistingCall(*(iTelephonyFunctions->Line(CTelephony::EVoiceLine)), callName); |
|
558 if (ret != KErrNone) |
|
559 { |
|
560 // Call could not be opened, close and complete |
|
561 // request back to the client. |
|
562 iTelephonyFunctions->CloseAndReset(iTempCallId); |
|
563 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EAnswerIncomingCall, KErrAccessDenied); |
|
564 iState = EAnswerIncomingCallStateIdle; |
|
565 return; |
|
566 } |
|
567 // Post the request to answer the incoming call. |
|
568 iCallPoolStatus[iTempCallId]=CTelephonyFunctions::EAnswer; |
|
569 iTelephonyFunctions->Call(iTempCallId)->AnswerIncomingCallISV(iStatus, iMMCallParamsPckg); |
|
570 } |
|
571 else |
|
572 { |
|
573 // Call name is not available, NotifyIncomingCallAct AO has |
|
574 // not yet completed. Start the timer for 1 second. |
|
575 iState = EAnswerIncomingCallStateWaiting; |
|
576 iTimer.After(iStatus,KOneSecond); |
|
577 } |
|
578 SetActive(); |
|
579 break; |
|
580 } |
|
581 case EAnswerIncomingCallStateWaiting: |
|
582 default: |
|
583 // This AO shouldn't be in any other state when this function |
|
584 // is called, therefore, complete the CTelephonyFunctions |
|
585 // request with an error. |
|
586 iStatus = KErrTimedOut; |
|
587 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EAnswerIncomingCall, iStatus.Int()); |
|
588 //iState = EAnswerIncomingCallStateIdle; // Should iState be set to idle? |
|
589 break; |
|
590 } // End switch(iState) |
|
591 } |
|
592 |
|
593 /** |
|
594 Service completed request. |
|
595 |
|
596 Two different requests could have been issued by AnswerIncomingCall() |
|
597 depending on the state of this AO. |
|
598 If it is in the EAnswerIncomingCallStateAnswering state, then it has |
|
599 just finished answering the incoming call. |
|
600 If it is in the EAnswerIncomingCallStateWaiting state, then it was |
|
601 waiting for the CNotifyIncomingCallAct AO to complete and the 1 |
|
602 second timeout has finished. When this happens, it checks to see if |
|
603 CNotifyIncomingCallAct contains a valid call name. If so, it has |
|
604 completed, and this AO will post a request to answer the incoming call. |
|
605 If not, then there is a problem and the KErrAccessDenied |
|
606 error is returned via the iStatus status variable. |
|
607 */ |
|
608 void CAnswerIncomingCallAct::Complete() |
|
609 { |
|
610 if (iTelephonyFunctions->IsRequestPending(CTelephonyFunctions::EAnswerIncomingCall)) |
|
611 { |
|
612 switch (iState) |
|
613 { |
|
614 case EAnswerIncomingCallStateAnswering: |
|
615 // Normal situation. |
|
616 if(iStatus == KErrNone) |
|
617 { |
|
618 *iCallId=iTempCallId; |
|
619 } |
|
620 else if((iStatus != KRequestPending) && |
|
621 (iStatus != KErrNone)) |
|
622 { |
|
623 iTelephonyFunctions->CloseAndReset(iTempCallId); |
|
624 } |
|
625 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EAnswerIncomingCall, iStatus.Int()); |
|
626 iState = EAnswerIncomingCallStateIdle; |
|
627 break; |
|
628 case EAnswerIncomingCallStateWaiting: |
|
629 { |
|
630 TName callName; |
|
631 if (iIncomingCallNameSubject.CallName(callName) == KErrNone) |
|
632 { |
|
633 iState = EAnswerIncomingCallStateAnswering; |
|
634 AnswerIncomingCall(*iCallId, iTempCallId); |
|
635 } |
|
636 else |
|
637 { |
|
638 // Timer has finished and there is still no call name, |
|
639 // complete with an error. |
|
640 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EAnswerIncomingCall, KErrTimedOut); |
|
641 iState = EAnswerIncomingCallStateIdle; |
|
642 } |
|
643 break; |
|
644 } |
|
645 // This AO can complete in the idle state on object destruction. |
|
646 // It should not reach this code in any other situation. |
|
647 case EAnswerIncomingCallStateIdle: |
|
648 default: |
|
649 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EAnswerIncomingCall, KErrAccessDenied); |
|
650 iState = EAnswerIncomingCallStateIdle; |
|
651 break; |
|
652 } // switch (iState) |
|
653 } |
|
654 |
|
655 } |
|
656 |
|
657 /** |
|
658 Handle any Leave() from inside RunL(). |
|
659 |
|
660 @param aLeaveCode passed in if RunL Leaves. |
|
661 @return KErrNone. |
|
662 */ |
|
663 TInt CAnswerIncomingCallAct::RunError(TInt aLeaveCode) |
|
664 { |
|
665 iTelephonyFunctions->CompleteRequest(CTelephonyFunctions::EAnswerIncomingCall, aLeaveCode); |
|
666 iState = EAnswerIncomingCallStateIdle; |
|
667 return KErrNone; |
|
668 } |
|
669 |
|
670 /** |
|
671 Cancel request. |
|
672 |
|
673 Async request to answer the call and timer are cancelled. |
|
674 */ |
|
675 void CAnswerIncomingCallAct::DoCancel() |
|
676 { |
|
677 if(iTelephonyFunctions->Call(iTempCallId)) |
|
678 { |
|
679 iTelephonyFunctions->Call(iTempCallId)->CancelAsyncRequest(EMobileCallAnswerISV); |
|
680 } |
|
681 iTimer.Cancel(); |
|
682 } |
|
683 |
|
684 |
|
685 /** |
|
686 First-phase constructor which cannot Leave(). |
|
687 |
|
688 @param aTelephonyFunctions Pointer to the CTelephonyFunctions object that constructs this object. |
|
689 @param aIncomingCallNameSubject Reference to an AO owned by iTelephonyFunctions which implements the MIncomingCallNameSubject interface. Used by this object to retrieve the call name of the incoming call. |
|
690 @param aCallPool Reference to the call pool array owned by iTelephonyFunctions. |
|
691 @param aCallPoolStatus Reference to the call pool status array owned by iTelephonyFunctions. |
|
692 */ |
|
693 CAnswerIncomingCallAct::CAnswerIncomingCallAct(CTelephonyFunctions* aTelephonyFunctions, MIncomingCallNameSubject& aIncomingCallNameSubject, RArray<RMobileCall>& aCallPool, RArray<CTelephonyFunctions::TCallPoolOperation>& aCallPoolStatus) |
|
694 : CAsyncRequestBaseAct(), |
|
695 iTelephonyFunctions(aTelephonyFunctions), |
|
696 iMMCallParamsPckg(iMMcallParams), |
|
697 iState(EAnswerIncomingCallStateIdle), |
|
698 iIncomingCallNameSubject(aIncomingCallNameSubject), |
|
699 iCallPool(aCallPool), |
|
700 iCallPoolStatus(aCallPoolStatus) |
|
701 { |
|
702 } |
|
703 |
|
704 /** |
|
705 Implementation of the MEventObserver interface. |
|
706 If this object is in the EAnswerIncomingCallStateWaiting state, it |
|
707 is waiting for up to 1 second for CNotifyIncomingCallAct to complete |
|
708 so that it can answer the incoming call. When |
|
709 CNotifyIncomingCallAct completes during this 1 second period, |
|
710 this function is called to stop the timer and proceed to answer |
|
711 the call. After the timer is cancelled, the Active Scheduler will |
|
712 automatically complete this AO. |
|
713 */ |
|
714 void CAnswerIncomingCallAct::EventCompleted() |
|
715 { |
|
716 if (iState == EAnswerIncomingCallStateWaiting) |
|
717 { |
|
718 iTimer.Cancel(); |
|
719 } |
|
720 } |
|
721 |
|
722 CNotifyCallStatusAct* CNotifyCallStatusAct::NewL(CTelephonyFunctions* aTelephonyFunctions, CTelephonyFunctions::TOperations aPendingOperation) |
|
723 /** |
|
724 Public constructor which can Leave(). |
|
725 |
|
726 @param aTelephonyFunctions Object that constructs us. |
|
727 @leave Leaves if no memory. |
|
728 */ |
|
729 { |
|
730 CNotifyCallStatusAct* self = new(ELeave) CNotifyCallStatusAct(aTelephonyFunctions, aPendingOperation); |
|
731 CActiveScheduler::Add(self); |
|
732 return self; |
|
733 } |
|
734 |
|
735 CNotifyCallStatusAct::~CNotifyCallStatusAct() |
|
736 /** |
|
737 Destructor |
|
738 */ |
|
739 { |
|
740 Cancel(); |
|
741 Complete(); |
|
742 } |
|
743 |
|
744 void CNotifyCallStatusAct::NotifyCallStatus(TDes8& aId, const CTelephony::TCallId& aCallId) |
|
745 /** |
|
746 Issue Request |
|
747 */ |
|
748 { |
|
749 iISVCallStatus = reinterpret_cast<CTelephony::TCallStatusV1*> ( const_cast<TUint8*> (aId.Ptr()) ); |
|
750 iCallId = aCallId; |
|
751 iTelephonyFunctions->Call(aCallId)->NotifyMobileCallStatusChange(iStatus,iMMCallStatus); |
|
752 SetActive(); |
|
753 } |
|
754 |
|
755 |
|
756 void CNotifyCallStatusAct::Complete() |
|
757 /** |
|
758 Service Completed request. |
|
759 */ |
|
760 { |
|
761 if(iTelephonyFunctions->IsRequestPending(iPendingOperation)) |
|
762 { |
|
763 if(iStatus==KErrNone) |
|
764 { |
|
765 CTelephonyFunctions::GetCallStatus(iMMCallStatus, iISVCallStatus->iStatus); |
|
766 } |
|
767 iTelephonyFunctions->CompleteRequest(iPendingOperation, iStatus.Int()); |
|
768 } |
|
769 } |
|
770 |
|
771 |
|
772 TInt CNotifyCallStatusAct::RunError(TInt aLeaveCode) |
|
773 /** |
|
774 Handle any Leave() from inside RunL(). |
|
775 |
|
776 @param aLeaveCode passed in if RunL Leaves. |
|
777 @return KErrNone. |
|
778 */ |
|
779 { |
|
780 iTelephonyFunctions->CompleteRequest(iPendingOperation, aLeaveCode); |
|
781 return KErrNone; |
|
782 } |
|
783 |
|
784 void CNotifyCallStatusAct::DoCancel() |
|
785 /** |
|
786 Cancel request. |
|
787 |
|
788 Async request to dial is cancelled. |
|
789 */ |
|
790 { |
|
791 if(iTelephonyFunctions->Call(iCallId)!=NULL) |
|
792 { |
|
793 iTelephonyFunctions->Call(iCallId)->CancelAsyncRequest(EMobileCallNotifyMobileCallStatusChange); |
|
794 } |
|
795 } |
|
796 |
|
797 |
|
798 CNotifyCallStatusAct::CNotifyCallStatusAct(CTelephonyFunctions* aTelephonyFunctions, CTelephonyFunctions::TOperations aPendingOperation) |
|
799 : CAsyncRequestBaseAct(), |
|
800 iTelephonyFunctions(aTelephonyFunctions), |
|
801 iPendingOperation(aPendingOperation) |
|
802 /** |
|
803 First-phase constructor which cannot Leave(). |
|
804 |
|
805 @param aTelephonyFunctions Object that constructs us. |
|
806 */ |
|
807 { |
|
808 } |
|
809 |
|
810 |
|
811 CNotifyRemotePartyInfoAct* CNotifyRemotePartyInfoAct::NewL(CTelephonyFunctions* aTelephonyFunctions, CTelephonyFunctions::TOperations aPendingOperation) |
|
812 /** |
|
813 Public constructor which can Leave(). |
|
814 |
|
815 @param aTelephonyFunctions Object that constructs us. |
|
816 @leave Leaves if no memory. |
|
817 */ |
|
818 { |
|
819 CNotifyRemotePartyInfoAct* self = new(ELeave) CNotifyRemotePartyInfoAct(aTelephonyFunctions, aPendingOperation); |
|
820 CActiveScheduler::Add(self); |
|
821 return self; |
|
822 } |
|
823 |
|
824 CNotifyRemotePartyInfoAct::~CNotifyRemotePartyInfoAct() |
|
825 /** |
|
826 Destructor |
|
827 */ |
|
828 { |
|
829 Cancel(); |
|
830 Complete(); |
|
831 } |
|
832 |
|
833 void CNotifyRemotePartyInfoAct::NotifyRemotePartyInfo(TDes8& aId, const CTelephony::TCallId& aCallId) |
|
834 /** |
|
835 Issue Request |
|
836 */ |
|
837 { |
|
838 iISVRemotePartyInfo = reinterpret_cast<CTelephony::TRemotePartyInfoV1*> ( const_cast<TUint8*> (aId.Ptr()) ); |
|
839 iCallId = aCallId; |
|
840 iTelephonyFunctions->Call(aCallId)->NotifyRemotePartyInfoChange(iStatus,iMMRemotePartyInfoPckg); |
|
841 SetActive(); |
|
842 } |
|
843 |
|
844 |
|
845 void CNotifyRemotePartyInfoAct::Complete() |
|
846 /** |
|
847 Service Completed request. |
|
848 */ |
|
849 { |
|
850 if(iTelephonyFunctions->IsRequestPending(iPendingOperation)) |
|
851 { |
|
852 if(iStatus==KErrNone) |
|
853 { |
|
854 switch(iMMRemotePartyInfo.iRemoteIdStatus) |
|
855 { |
|
856 case RMobileCall::ERemoteIdentityAvailable: |
|
857 iISVRemotePartyInfo->iRemoteIdStatus = CTelephony::ERemoteIdentityAvailable; |
|
858 break; |
|
859 case RMobileCall::ERemoteIdentitySuppressed: |
|
860 iISVRemotePartyInfo->iRemoteIdStatus = CTelephony::ERemoteIdentitySuppressed; |
|
861 break; |
|
862 case RMobileCall::ERemoteIdentityUnknown: |
|
863 default: |
|
864 iISVRemotePartyInfo->iRemoteIdStatus = CTelephony::ERemoteIdentityUnknown; |
|
865 break; |
|
866 } |
|
867 |
|
868 iISVRemotePartyInfo->iCallingName.Copy(iMMRemotePartyInfo.iCallingName); |
|
869 CTelephonyFunctions::CopyTelAddress(iMMRemotePartyInfo.iRemoteNumber, iISVRemotePartyInfo->iRemoteNumber); |
|
870 |
|
871 switch(iMMRemotePartyInfo.iDirection) |
|
872 { |
|
873 case RMobileCall::EMobileOriginated: |
|
874 iISVRemotePartyInfo->iDirection = CTelephony::EMobileOriginated; |
|
875 break; |
|
876 case RMobileCall::EMobileTerminated: |
|
877 iISVRemotePartyInfo->iDirection = CTelephony::EMobileTerminated; |
|
878 break; |
|
879 case RMobileCall::EDirectionUnknown: |
|
880 default: |
|
881 iISVRemotePartyInfo->iDirection = CTelephony::EDirectionUnknown; |
|
882 break; |
|
883 } |
|
884 } |
|
885 iTelephonyFunctions->CompleteRequest(iPendingOperation, iStatus.Int()); |
|
886 } |
|
887 } |
|
888 |
|
889 |
|
890 TInt CNotifyRemotePartyInfoAct::RunError(TInt aLeaveCode) |
|
891 /** |
|
892 Handle any Leave() from inside RunL(). |
|
893 |
|
894 @param aLeaveCode passed in if RunL Leaves. |
|
895 @return KErrNone. |
|
896 */ |
|
897 { |
|
898 iTelephonyFunctions->CompleteRequest(iPendingOperation, aLeaveCode); |
|
899 return KErrNone; |
|
900 } |
|
901 |
|
902 void CNotifyRemotePartyInfoAct::DoCancel() |
|
903 /** |
|
904 Cancel request. |
|
905 |
|
906 Async request to dial is cancelled. |
|
907 */ |
|
908 { |
|
909 if(iTelephonyFunctions->Call(iCallId)!=NULL) |
|
910 { |
|
911 iTelephonyFunctions->Call(iCallId)->CancelAsyncRequest(EMobileCallNotifyRemotePartyInfoChange); |
|
912 } |
|
913 } |
|
914 |
|
915 /** |
|
916 First-phase constructor which cannot Leave(). |
|
917 |
|
918 @param aTelephonyFunctions Object that constructs us. |
|
919 */ |
|
920 CNotifyRemotePartyInfoAct::CNotifyRemotePartyInfoAct(CTelephonyFunctions* aTelephonyFunctions, CTelephonyFunctions::TOperations aPendingOperation) |
|
921 : CAsyncRequestBaseAct(), |
|
922 iTelephonyFunctions(aTelephonyFunctions), |
|
923 iMMRemotePartyInfoPckg(iMMRemotePartyInfo), |
|
924 iPendingOperation(aPendingOperation) |
|
925 { |
|
926 } |
|
927 |
|
928 /** |
|
929 Public constructor which can Leave(). |
|
930 |
|
931 @param aTelephonyFunctions Object that constructs the returned object. |
|
932 @param aPendingOperation The pending operation. |
|
933 @leave Leaves if no memory. |
|
934 @return Pointer to the created CNotifyIncomingCallAct object. |
|
935 */ |
|
936 CNotifyIncomingCallAct* CNotifyIncomingCallAct::NewL(CTelephonyFunctions* aTelephonyFunctions) |
|
937 { |
|
938 CNotifyIncomingCallAct* self = new (ELeave) CNotifyIncomingCallAct(aTelephonyFunctions); |
|
939 CActiveScheduler::Add(self); |
|
940 return self; |
|
941 } |
|
942 |
|
943 /** |
|
944 Default destructor. |
|
945 */ |
|
946 CNotifyIncomingCallAct::~CNotifyIncomingCallAct() |
|
947 { |
|
948 iState = ENotifyIncomingCallActStateCleanUp; |
|
949 Cancel(); |
|
950 Complete(); |
|
951 iIncomingCallCompletionObservers.Close(); |
|
952 } |
|
953 |
|
954 /** |
|
955 Issue request to be notified of an incoming call so that the call name can be retrieved. |
|
956 */ |
|
957 void CNotifyIncomingCallAct::NotifyIncomingCall() |
|
958 { |
|
959 // Only voice lines are supported |
|
960 iTelephonyFunctions->Line(CTelephony::EVoiceLine)->NotifyIncomingCall(iStatus, iCallName); |
|
961 SetActive(); |
|
962 } |
|
963 |
|
964 /** |
|
965 Registers an observer with this object. Observers of this AO are AOs |
|
966 owned by CTelephonyFunctions which want to be notified when this |
|
967 AO completes (i.e. of the arrival of an incomingcall). |
|
968 |
|
969 @param aOperation The operation that the aObserver active object performs. |
|
970 @param aObserver Pointer to the observer object. |
|
971 */ |
|
972 void CNotifyIncomingCallAct::RegisterObserver(MEventObserver* aObserver) |
|
973 { |
|
974 iIncomingCallCompletionObservers.Append(aObserver); |
|
975 } |
|
976 |
|
977 /** |
|
978 Deregisters an observer with this object. The deregistered observer |
|
979 will no longer be notified when this active object completes. If the |
|
980 observer was registered more than once with this AO, this method will |
|
981 only deregister one of those registrations. |
|
982 |
|
983 @param aOperation The operation that the aObserver active object performs. |
|
984 */ |
|
985 void CNotifyIncomingCallAct::DeregisterObserver(MEventObserver* aObserver) |
|
986 { |
|
987 TInt pos = iIncomingCallCompletionObservers.Find(aObserver); |
|
988 if (pos != KErrNotFound) |
|
989 { |
|
990 iIncomingCallCompletionObservers.Remove(pos); |
|
991 } |
|
992 } |
|
993 |
|
994 /** |
|
995 Deletes the contents of iCallName. |
|
996 */ |
|
997 void CNotifyIncomingCallAct::ResetCallName() |
|
998 { |
|
999 iCallName.FillZ(); |
|
1000 iCallName.Zero(); |
|
1001 } |
|
1002 |
|
1003 /** |
|
1004 Checks if there is a valid call name available and stores it in |
|
1005 aCallName if there is. |
|
1006 |
|
1007 @param aCallName Stores the call name of the new incoming call if there is one available. |
|
1008 |
|
1009 @return KErrNone if there is a valid call name available, KErrNotFound if there is not. |
|
1010 */ |
|
1011 TInt CNotifyIncomingCallAct::CallName(TName& aCallName) const |
|
1012 { |
|
1013 if (iCallName.Length() == 0) |
|
1014 { |
|
1015 return KErrNotFound; |
|
1016 } |
|
1017 else |
|
1018 { |
|
1019 aCallName = iCallName; |
|
1020 return KErrNone; |
|
1021 } |
|
1022 } |
|
1023 |
|
1024 /** |
|
1025 Service completed request. |
|
1026 */ |
|
1027 void CNotifyIncomingCallAct::Complete() |
|
1028 { |
|
1029 if (iStatus == KErrNone) |
|
1030 { |
|
1031 // Let all the observers interested in being notified of an |
|
1032 // incoming call that an incoming call has been received. |
|
1033 TInt numObservers = iIncomingCallCompletionObservers.Count(); |
|
1034 for (TInt i = 0; i < numObservers; i++) |
|
1035 { |
|
1036 if (iIncomingCallCompletionObservers[i] != NULL) |
|
1037 { |
|
1038 iIncomingCallCompletionObservers[i]->EventCompleted(); |
|
1039 } |
|
1040 } |
|
1041 } |
|
1042 |
|
1043 // Listen again for an incoming call. |
|
1044 // This AO continuously listens for incoming calls, the request |
|
1045 // will only be cancelled when the object is being destroyed, |
|
1046 // in this case do not repost. |
|
1047 if ((iStatus != KRequestPending) && (iStatus != KErrCancel) && (iState != ENotifyIncomingCallActStateCleanUp)) |
|
1048 { |
|
1049 NotifyIncomingCall(); |
|
1050 } |
|
1051 } |
|
1052 |
|
1053 /** |
|
1054 Handle any Leave() from inside RunL(). |
|
1055 |
|
1056 @param aLeaveCode passed in if RunL Leaves. |
|
1057 @return KErrNone. |
|
1058 */ |
|
1059 TInt CNotifyIncomingCallAct::RunError(/*TInt aLeaveCode*/) |
|
1060 { |
|
1061 // ENotifyIncomingCall is not a supported client request, therefore, |
|
1062 // don't need to complete back to the client. |
|
1063 return KErrNone; |
|
1064 } |
|
1065 |
|
1066 /** |
|
1067 Cancel NotifyIncomingCall request. |
|
1068 */ |
|
1069 void CNotifyIncomingCallAct::DoCancel() |
|
1070 { |
|
1071 iTelephonyFunctions->Line(CTelephony::EVoiceLine)->NotifyIncomingCallCancel(); |
|
1072 } |
|
1073 |
|
1074 /** |
|
1075 First-phase constructor which cannot Leave(). |
|
1076 |
|
1077 @param aTelephonyFunctions Pointer to the CTelephonyFunctions object that created this object. |
|
1078 @param aPendingOperation The pending operation. |
|
1079 */ |
|
1080 CNotifyIncomingCallAct::CNotifyIncomingCallAct(CTelephonyFunctions* aTelephonyFunctions) |
|
1081 : CAsyncRequestBaseAct(), |
|
1082 iTelephonyFunctions(aTelephonyFunctions), |
|
1083 iState(ENotifyIncomingCallActStateOperating) |
|
1084 { |
|
1085 } |