|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "t_rmobilecalldata.h" |
|
19 #include "t_rmobilelinedata.h" |
|
20 //System includes |
|
21 #include <e32property.h> |
|
22 |
|
23 |
|
24 _LIT( KCallName, "Call"); |
|
25 _LIT( KCapabilities, "Capabilities" ); |
|
26 _LIT( KPhoneNumber, "PhoneNumber" ); |
|
27 _LIT( KDefaultSection, "Default" ); |
|
28 _LIT( KMaxPhoneCalls, "MaxPhoneCalls"); |
|
29 |
|
30 // Call capabilities RMobileCall::GetCaps()) |
|
31 _LIT( KCapsVoiceCall, "VoiceCall" ); |
|
32 _LIT( KCapsHold, "Hold" ); |
|
33 _LIT( KCapsResume, "Resume" ); |
|
34 _LIT( KCapsSwap, "Swap" ); |
|
35 _LIT( KCapsDeflect, "Deflect" ); |
|
36 _LIT( KCapsTransfer, "Transfer" ); |
|
37 _LIT( KCapsJoin, "Join" ); // Conference |
|
38 _LIT( KCapsOneToOne, "OneToOne" ); // Conference |
|
39 |
|
40 _LIT(KMobileLineKey, "RMobileLine"); |
|
41 /*@}*/ |
|
42 // ini file Keys |
|
43 |
|
44 |
|
45 //Voice Call |
|
46 _LIT(KCmdAnswerIncomingCall, "AnswerIncomingCall"); |
|
47 _LIT(KCmdAnswerIncomingCallPost, "AnswerIncomingCallPost"); |
|
48 _LIT(KCmdGetCaps, "GetCaps"); |
|
49 _LIT(KCmdGetCallDuration, "GetCallDuration"); |
|
50 _LIT(KCmdHangUp, "HangUp"); |
|
51 _LIT(KCmdClose, "Close"); |
|
52 _LIT(KCmdOpenNewCall, "OpenNewCall"); |
|
53 _LIT(KCmdOpenExistingCall, "OpenExistingCall"); |
|
54 _LIT(KCmdDial, "Dial"); |
|
55 _LIT(KCmdDialCancel, "DialCancel"); |
|
56 _LIT(KCmdGetStatus, "GetStatus"); |
|
57 _LIT(KCmdHold, "Hold"); |
|
58 _LIT(KCmdResume, "Resume"); |
|
59 _LIT(KCmdSwap, "Swap"); |
|
60 _LIT(KCmdTransfer, "Transfer"); |
|
61 _LIT(KCmdUtilityCheckCaps, "CheckCaps"); |
|
62 /** |
|
63 * Two phase constructor |
|
64 * |
|
65 * @leave system wide error |
|
66 */ |
|
67 CT_RMobileCallData* CT_RMobileCallData::NewL() |
|
68 { |
|
69 CT_RMobileCallData* ret=new (ELeave) CT_RMobileCallData(); |
|
70 CleanupStack::PushL (ret); |
|
71 ret->ConstructL (); |
|
72 CleanupStack::Pop (ret); |
|
73 return ret; |
|
74 } |
|
75 |
|
76 /** |
|
77 * Protected constructor. First phase construction |
|
78 */ |
|
79 CT_RMobileCallData::CT_RMobileCallData() |
|
80 : iActiveCallback(NULL) |
|
81 { |
|
82 } |
|
83 |
|
84 /** |
|
85 * Second phase construction |
|
86 * |
|
87 * @internalComponent |
|
88 * |
|
89 * @return N/A |
|
90 * |
|
91 * @pre None |
|
92 * @post None |
|
93 * |
|
94 * @leave system wide error |
|
95 */ |
|
96 void CT_RMobileCallData::ConstructL() |
|
97 { |
|
98 iActiveCallback = CActiveCallback::NewL (*this); |
|
99 } |
|
100 |
|
101 /** |
|
102 * Third phase construction |
|
103 * |
|
104 * @internalComponent |
|
105 * |
|
106 * @return N/A |
|
107 * |
|
108 * @pre None |
|
109 * @post None |
|
110 * |
|
111 * @leave system wide error |
|
112 */ |
|
113 void CT_RMobileCallData::InitialiseL() |
|
114 { |
|
115 CDataWrapperBase::InitialiseL(); |
|
116 GetIntFromConfig(KDefaultSection, KMaxPhoneCalls, iMaxPhoneCalls ); |
|
117 |
|
118 RMobileCall* mobileCall= NULL; |
|
119 for (TInt i = 0; i < iMaxPhoneCalls; ++i) |
|
120 { |
|
121 // RMobileCalls |
|
122 mobileCall = new (ELeave) RMobileCall(); // We need a bunch of RMobileCall handles |
|
123 CleanupStack::PushL (mobileCall); |
|
124 iMobileCalls.AppendL (mobileCall); |
|
125 CleanupStack::Pop (mobileCall); |
|
126 } |
|
127 } |
|
128 |
|
129 /** |
|
130 * Public destructor |
|
131 */ |
|
132 CT_RMobileCallData::~CT_RMobileCallData() |
|
133 { |
|
134 delete iActiveCallback; |
|
135 iActiveCallback=NULL; |
|
136 |
|
137 // Empty arrays and also delete objects whose pointers are contained within |
|
138 iMobileCalls.ResetAndDestroy (); |
|
139 } |
|
140 |
|
141 /** |
|
142 * Return a pointer to the object that the data wraps |
|
143 * |
|
144 * @return pointer to the object that the data wraps |
|
145 */ |
|
146 TAny* CT_RMobileCallData::GetObject() |
|
147 { |
|
148 return &iMobileCall; |
|
149 } |
|
150 |
|
151 /** |
|
152 * Process a command read from the ini file |
|
153 * |
|
154 * @param aCommand The command to process |
|
155 * @param aSection The section in the ini containing data for the command |
|
156 * @param aAsyncErrorIndex Command index for async calls to return errors to |
|
157 * |
|
158 * @return ETrue if the command is processed |
|
159 * |
|
160 * @leave System wide error |
|
161 */ |
|
162 TBool CT_RMobileCallData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
163 { |
|
164 |
|
165 TBool ret = ETrue; |
|
166 |
|
167 if ( aCommand==KCmdGetCaps) |
|
168 { |
|
169 DoCmdGetCaps (aSection); |
|
170 } |
|
171 else if ( aCommand==KCmdUtilityCheckCaps) |
|
172 { |
|
173 DoCmdUtilityCheckCapability(aSection); |
|
174 } |
|
175 else if ( aCommand==KCmdGetCallDuration) |
|
176 { |
|
177 DoCmdGetCallDuration (aSection); |
|
178 } |
|
179 else if ( aCommand==KCmdHangUp) |
|
180 { |
|
181 DoCmdHangUp (aSection, aAsyncErrorIndex); |
|
182 } |
|
183 else if ( aCommand==KCmdClose) |
|
184 { |
|
185 DoCmdClose (aSection); |
|
186 } |
|
187 else if ( aCommand==KCmdOpenNewCall) |
|
188 { |
|
189 DoCmdOpenNewCall (aSection); |
|
190 } |
|
191 else if ( aCommand==KCmdOpenExistingCall) |
|
192 { |
|
193 DoCmdOpenExistingCall (aSection); |
|
194 } |
|
195 else if ( aCommand==KCmdDial) |
|
196 { |
|
197 DoCmdDial (aSection, aAsyncErrorIndex); |
|
198 } |
|
199 else if ( aCommand==KCmdDialCancel) |
|
200 { |
|
201 DoCmdDialCancel (aSection); |
|
202 } |
|
203 else if ( aCommand==KCmdAnswerIncomingCall) |
|
204 { |
|
205 DoCmdAnswerIncomingCall (aSection, aAsyncErrorIndex); |
|
206 } |
|
207 else if ( aCommand==KCmdAnswerIncomingCallPost) |
|
208 { |
|
209 DoCmdAnswerIncomingCallPost ( aSection, aAsyncErrorIndex); |
|
210 } |
|
211 else if ( aCommand==KCmdGetStatus) |
|
212 { |
|
213 DoCmdGetStatus (); |
|
214 } |
|
215 else if ( aCommand == KCmdHold) |
|
216 { |
|
217 DoCmdHold (aSection, aAsyncErrorIndex); |
|
218 } |
|
219 else if ( aCommand == KCmdSwap) |
|
220 { |
|
221 DoCmdSwap (aSection, aAsyncErrorIndex); |
|
222 } |
|
223 else if ( aCommand == KCmdResume) |
|
224 { |
|
225 DoCmdResume (aSection, aAsyncErrorIndex); |
|
226 } |
|
227 else if ( aCommand == KCmdTransfer) |
|
228 { |
|
229 DoCmdTransfer (aSection, aAsyncErrorIndex); |
|
230 } |
|
231 else |
|
232 { |
|
233 ERR_PRINTF1(_L("Unknown command")); |
|
234 ret = EFalse; |
|
235 } |
|
236 |
|
237 return ret; |
|
238 } |
|
239 |
|
240 void CT_RMobileCallData::DoCmdGetCaps(const TTEFFunction& aSection) |
|
241 { |
|
242 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdGetCaps")); |
|
243 TInt callNameParameter; |
|
244 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter )) |
|
245 { |
|
246 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
247 SetBlockResult(EFail); |
|
248 } |
|
249 else |
|
250 { |
|
251 INFO_PRINTF1(_L("Getting mobile call")); |
|
252 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
253 if(error != KErrNone) |
|
254 { |
|
255 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
256 SetBlockResult(EFail); |
|
257 } |
|
258 else |
|
259 { |
|
260 INFO_PRINTF1(_L("Getting call capabilities")); |
|
261 TRAP( error, iMobileCall->GetCaps(iCallCaps) ); |
|
262 if ( error != KErrNone) |
|
263 { |
|
264 ERR_PRINTF2(_L("Failed to get mobile call capabilities with error %d"), error); |
|
265 SetError(error); |
|
266 } |
|
267 } |
|
268 } |
|
269 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdGetCaps")); |
|
270 } |
|
271 |
|
272 void CT_RMobileCallData::DoCmdGetCallDuration(const TTEFFunction& aSection) |
|
273 { |
|
274 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdGetCallDuration")); |
|
275 TInt callNameParameter; |
|
276 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter )) |
|
277 { |
|
278 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
279 SetBlockResult(EFail); |
|
280 } |
|
281 else |
|
282 { |
|
283 INFO_PRINTF1(_L("Getting mobile call")); |
|
284 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
285 if(error != KErrNone) |
|
286 { |
|
287 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
288 SetBlockResult(EFail); |
|
289 } |
|
290 else |
|
291 { |
|
292 TTimeIntervalSeconds duration = 0; |
|
293 error = iMobileCall->GetCallDuration(duration); |
|
294 if(error != KErrNone) |
|
295 { |
|
296 ERR_PRINTF2(_L("Failed to get call duration with error %d"), error); |
|
297 SetError(error); |
|
298 } |
|
299 else |
|
300 { |
|
301 INFO_PRINTF3(_L("Call %d duration was %d seconds"), callNameParameter, duration.Int()); |
|
302 } |
|
303 } |
|
304 } |
|
305 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdGetCallDuration")); |
|
306 } |
|
307 |
|
308 void CT_RMobileCallData::DoCmdHangUp(const TTEFFunction& aSection, const TInt aAsyncErrorIndex) |
|
309 { |
|
310 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdHangUp")); |
|
311 TInt callNameParameter; |
|
312 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter )) |
|
313 { |
|
314 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
315 SetBlockResult(EFail); |
|
316 } |
|
317 else |
|
318 { |
|
319 INFO_PRINTF1(_L("Getting mobile call")); |
|
320 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
321 if(error != KErrNone) |
|
322 { |
|
323 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
324 SetBlockResult(EFail); |
|
325 } |
|
326 else |
|
327 { |
|
328 iMobileCall->HangUp(iActiveCallback->iStatus); |
|
329 iActiveCallback->Activate (aAsyncErrorIndex); |
|
330 IncOutstanding (); |
|
331 } |
|
332 } |
|
333 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdHangUp")); |
|
334 } |
|
335 |
|
336 void CT_RMobileCallData::DoCmdClose(const TTEFFunction& aSection) |
|
337 { |
|
338 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdCloseCall")); |
|
339 TInt callNameParameter; |
|
340 if ( !GetIntFromConfig( aSection, KCallName, callNameParameter )) |
|
341 { |
|
342 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
343 SetBlockResult(EFail); |
|
344 } |
|
345 else |
|
346 { |
|
347 INFO_PRINTF1(_L("Getting mobile call")); |
|
348 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
349 if(error != KErrNone) |
|
350 { |
|
351 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
352 SetBlockResult(EFail); |
|
353 } |
|
354 else |
|
355 { |
|
356 INFO_PRINTF1(_L("Close handle to RMobileCall")); |
|
357 iMobileCall->Close (); |
|
358 } |
|
359 } |
|
360 INFO_PRINTF1(_L("*END*CT_RMobileCallData::CloseCallL")); |
|
361 } |
|
362 |
|
363 void CT_RMobileCallData::RunL(CActive* aActive, TInt aIndex) |
|
364 { |
|
365 INFO_PRINTF1(_L("*START*CT_RMobileCallData::RunL")); |
|
366 DecOutstanding (); // One of the async calls has completed |
|
367 TInt err = aActive->iStatus.Int(); |
|
368 if ( err != KErrNone) |
|
369 { |
|
370 ERR_PRINTF2(_L("RunL Error %d"), err); |
|
371 SetAsyncError ( aIndex, err); |
|
372 } |
|
373 else |
|
374 { |
|
375 INFO_PRINTF1(_L("RunL completed successfully")); |
|
376 } |
|
377 INFO_PRINTF1(_L("*END*CT_RMobileCallData::RunL")); |
|
378 } |
|
379 |
|
380 |
|
381 void CT_RMobileCallData::DoCmdOpenNewCall(const TTEFFunction& aSection) |
|
382 { |
|
383 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdOpenNewCall")); |
|
384 TBool dataOk = ETrue; |
|
385 TInt callNameParameter; |
|
386 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter )) |
|
387 { |
|
388 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
389 SetBlockResult(EFail); |
|
390 dataOk = EFalse; |
|
391 } |
|
392 TPtrC mobileLineName; |
|
393 if ( !GetStringFromConfig (aSection, KMobileLineKey (), mobileLineName)) |
|
394 { |
|
395 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMobileLineKey ); |
|
396 SetBlockResult(EFail); |
|
397 dataOk = EFalse; |
|
398 } |
|
399 if ( dataOk ) |
|
400 { |
|
401 CT_RMobileLineData* mobileLineWrapper = static_cast<CT_RMobileLineData*>(GetDataWrapperL(mobileLineName)); |
|
402 TName* callName; |
|
403 TRAPD( error, callName = mobileLineWrapper->GetCallNameL (callNameParameter) ); |
|
404 if(error != KErrNone) |
|
405 { |
|
406 ERR_PRINTF2(_L("Left while getting call name with error %d"), error); |
|
407 SetError(error); |
|
408 } |
|
409 else |
|
410 { |
|
411 INFO_PRINTF1(_L("Open handle to RMobileCall which can be used to receive incoming or dial outgoing call.")); |
|
412 RMobileLine* mobileLineObject = static_cast<RMobileLine*>(GetDataObjectL(mobileLineName)); |
|
413 INFO_PRINTF1(_L("Getting mobile call")); |
|
414 TRAP(error, iMobileCall = GetMobileCallL(callNameParameter)); |
|
415 if(error != KErrNone) |
|
416 { |
|
417 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
418 SetBlockResult(EFail); |
|
419 } |
|
420 else |
|
421 { |
|
422 INFO_PRINTF1(_L("Opening new call")); |
|
423 error = iMobileCall->OpenNewCall(*mobileLineObject, *callName); |
|
424 if ( error != KErrNone) |
|
425 { |
|
426 ERR_PRINTF3(_L("OpenNewCall named: %S, failed with error [%d]"), &callName, error); |
|
427 SetError (error); |
|
428 } |
|
429 else |
|
430 { |
|
431 INFO_PRINTF1(_L("Open new call succeeded")); |
|
432 } |
|
433 } |
|
434 } |
|
435 } |
|
436 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdOpenNewCall")); |
|
437 } |
|
438 |
|
439 void CT_RMobileCallData::DoCmdOpenExistingCall(const TTEFFunction& aSection) |
|
440 { |
|
441 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdOpenExistingCall")); |
|
442 TInt callNameParameter; |
|
443 TBool dataOk = ETrue; |
|
444 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter )) |
|
445 { |
|
446 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
447 SetBlockResult(EFail); |
|
448 dataOk = EFalse; |
|
449 } |
|
450 TPtrC mobileLineName; |
|
451 if ( !GetStringFromConfig (aSection, KMobileLineKey (), mobileLineName)) |
|
452 { |
|
453 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMobileLineKey ); |
|
454 SetBlockResult(EFail); |
|
455 dataOk = EFalse; |
|
456 } |
|
457 if ( dataOk ) |
|
458 { |
|
459 CT_RMobileLineData* mobileLineWrapper = static_cast<CT_RMobileLineData*>(GetDataWrapperL(mobileLineName)); |
|
460 const TName* callName = NULL; |
|
461 TRAPD( error, callName = mobileLineWrapper->GetCallNameL (callNameParameter) ); |
|
462 if(error != KErrNone) |
|
463 { |
|
464 ERR_PRINTF2(_L("Left while getting call name with error %d"), error); |
|
465 SetError(error); |
|
466 } |
|
467 else |
|
468 { |
|
469 INFO_PRINTF1(_L("Open handle to RMobileCall which can be used to receive incoming or dial outgoing call.")); |
|
470 RMobileLine* mobileLineObject = static_cast<RMobileLine*>(GetDataObjectL(mobileLineName)); |
|
471 INFO_PRINTF1(_L("Getting mobile call")); |
|
472 TRAP( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
473 if(error != KErrNone) |
|
474 { |
|
475 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
476 SetBlockResult(EFail); |
|
477 } |
|
478 else |
|
479 { |
|
480 INFO_PRINTF1(_L("Opening existing call")); |
|
481 error = iMobileCall->OpenExistingCall(*mobileLineObject, *callName); |
|
482 if ( error != KErrNone) |
|
483 { |
|
484 ERR_PRINTF2(_L("OpenExistingCall failed with error [%d]"), error); |
|
485 SetError (error); |
|
486 } |
|
487 else |
|
488 { |
|
489 INFO_PRINTF1(_L("OpenExistingCall succeeded")); |
|
490 } |
|
491 } |
|
492 } |
|
493 } |
|
494 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdOpenExistingCall")); |
|
495 } |
|
496 |
|
497 /** |
|
498 Dial out to given phone number using previously opened RMobileCall |
|
499 @param aSection |
|
500 @param KCallName |
|
501 @param KPhoneNumber |
|
502 @param KCallTimeout |
|
503 @return error - Symbian error code. KErrNone if successful |
|
504 */ |
|
505 void CT_RMobileCallData::DoCmdDial(const TTEFFunction& aSection, const TInt aAsyncErrorIndex) |
|
506 { |
|
507 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdDial")); |
|
508 TBool dataOk = ETrue; |
|
509 if ( !GetStringFromConfig( aSection, KPhoneNumber, iPhoneNumber )) |
|
510 { |
|
511 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPhoneNumber); |
|
512 SetBlockResult(EFail); |
|
513 dataOk = EFalse; |
|
514 } |
|
515 TInt callNameParameter; |
|
516 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter )) |
|
517 { |
|
518 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
519 SetBlockResult(EFail); |
|
520 dataOk = EFalse; |
|
521 } |
|
522 if ( dataOk ) |
|
523 { |
|
524 INFO_PRINTF1(_L("Getting mobile call")); |
|
525 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
526 if(error != KErrNone) |
|
527 { |
|
528 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
529 SetBlockResult(EFail); |
|
530 } |
|
531 else |
|
532 { |
|
533 INFO_PRINTF2(_L("Dialing \"%S\""), &iPhoneNumber); |
|
534 iMobileCall->Dial (iActiveCallback->iStatus, iPhoneNumber); |
|
535 iActiveCallback->Activate(aAsyncErrorIndex); |
|
536 IncOutstanding (); |
|
537 } |
|
538 } |
|
539 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdDial")); |
|
540 } |
|
541 |
|
542 void CT_RMobileCallData::DoCmdAnswerIncomingCall(const TTEFFunction& aSection, const TInt aAsyncErrorIndex) |
|
543 { |
|
544 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdAnswerIncomingCallAsync")); |
|
545 |
|
546 TInt callNameParameter; |
|
547 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter)) |
|
548 { |
|
549 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
550 SetBlockResult(EFail); |
|
551 } |
|
552 else |
|
553 { |
|
554 TRequestStatus status; |
|
555 // Call status is read to a RCall:TStatus variable. |
|
556 RCall::TStatus callStatus; |
|
557 TBool callReady = EFalse; |
|
558 |
|
559 INFO_PRINTF1(_L("Getting mobile call")); |
|
560 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
561 if(error != KErrNone) |
|
562 { |
|
563 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
564 SetBlockResult(EFail); |
|
565 } |
|
566 else |
|
567 { |
|
568 while (callReady == EFalse) |
|
569 { |
|
570 INFO_PRINTF1(_L("Getting call status...")); |
|
571 error = iMobileCall->GetStatus (callStatus); |
|
572 if ( error != KErrNone) |
|
573 { |
|
574 ERR_PRINTF2(_L("Failed to read call status [%d]"), error); |
|
575 SetError(error); |
|
576 } |
|
577 else |
|
578 { |
|
579 switch(callStatus) |
|
580 { |
|
581 case RCall::EStatusRinging: |
|
582 // Mobile call is ringing, we can answer it now. |
|
583 INFO_PRINTF1(_L("Mobile call is ringing")); |
|
584 callReady = ETrue; |
|
585 break; |
|
586 case RCall::EStatusIdle: |
|
587 // Mobile call was terminated before we could answer it. |
|
588 INFO_PRINTF1(_L("Mobile call was terminated before it could be answered")); |
|
589 SetBlockResult(EFail); |
|
590 break; |
|
591 default: |
|
592 INFO_PRINTF1(_L("Mobile call is still waiting ring")); |
|
593 INFO_PRINTF1(_L("Waiting for the phone status change...")); |
|
594 TRequestStatus status; |
|
595 iMobileCall->NotifyStatusChange(status, callStatus); |
|
596 User::WaitForRequest(status); |
|
597 break; |
|
598 } |
|
599 } |
|
600 } |
|
601 // Answer the incoming phone call now. |
|
602 INFO_PRINTF1(_L("Mobile call is ready, answering")); |
|
603 iMobileCall->AnswerIncomingCall (iActiveCallback->iStatus); |
|
604 iActiveCallback->Activate (aAsyncErrorIndex); |
|
605 IncOutstanding (); |
|
606 } |
|
607 } |
|
608 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdAnswerIncomingCallAsync")); |
|
609 } |
|
610 |
|
611 void CT_RMobileCallData::DoCmdAnswerIncomingCallPost(const TTEFFunction& aSection, const TInt aAsyncErrorIndex) |
|
612 { |
|
613 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdAnswerIncomingCallPost")); |
|
614 |
|
615 TInt callNameParameter; |
|
616 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter)) |
|
617 { |
|
618 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
619 SetBlockResult(EFail); |
|
620 } |
|
621 else |
|
622 { |
|
623 INFO_PRINTF1(_L("Getting mobile call")); |
|
624 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
625 if(error != KErrNone) |
|
626 { |
|
627 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
628 SetBlockResult(EFail); |
|
629 } |
|
630 else |
|
631 { |
|
632 INFO_PRINTF1(_L("Read call status to check if the other party hanged up.")); |
|
633 RCall::TStatus callStatus; |
|
634 error = iMobileCall->GetStatus(callStatus); |
|
635 if ( error != KErrNone) |
|
636 { |
|
637 ERR_PRINTF2(_L("Failed to read mobile call's status [%d]"), error); |
|
638 SetError(error); |
|
639 } |
|
640 else |
|
641 { |
|
642 // Normal status of the connection is EStatusConnected. |
|
643 if ( callStatus == RCall::EStatusConnected) |
|
644 { |
|
645 INFO_PRINTF1(_L("Mobile call is connected.")); |
|
646 } |
|
647 else |
|
648 { |
|
649 INFO_PRINTF1(_L("Mobile call was disconnected, hanging up.")); |
|
650 iMobileCall->HangUp (iActiveCallback->iStatus); |
|
651 iActiveCallback->Activate (aAsyncErrorIndex); |
|
652 IncOutstanding (); |
|
653 } |
|
654 } |
|
655 } |
|
656 } |
|
657 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdAnswerIncomingCallPost")); |
|
658 } |
|
659 |
|
660 |
|
661 void CT_RMobileCallData::DoCmdGetStatus() |
|
662 { |
|
663 INFO_PRINTF1(_L( "*START*CT_RMobileCallData::DoCmdCheckStatusWasConnecting" )); |
|
664 |
|
665 TInt error(0); |
|
666 error = iMobileCall->GetStatus(iTimeoutedMOCallStatus); |
|
667 if( error != KErrNone ) |
|
668 { |
|
669 ERR_PRINTF2(_L("Failed to get call status with error %d"), error); |
|
670 SetError(error); |
|
671 } |
|
672 else |
|
673 { |
|
674 switch(iTimeoutedMOCallStatus) |
|
675 { |
|
676 case RCall::EStatusUnknown: |
|
677 INFO_PRINTF1(_L("The recieving device was in unknown status when the call was cancelled.")); |
|
678 break; |
|
679 case RCall::EStatusIdle: |
|
680 INFO_PRINTF1(_L("The recieving device was idle when the call was cancelled.")); |
|
681 break; |
|
682 case RCall::EStatusDialling: |
|
683 INFO_PRINTF1(_L("The recieving device was dialing when the call was cancelled.")); |
|
684 break; |
|
685 case RCall::EStatusRinging: |
|
686 INFO_PRINTF1(_L("The recieving device was ringing when the call was cancelled.")); |
|
687 break; |
|
688 case RCall::EStatusAnswering: |
|
689 INFO_PRINTF1(_L("The recieving device was answering when the call was cancelled.")); |
|
690 break; |
|
691 case RCall::EStatusConnecting: |
|
692 INFO_PRINTF1(_L("The recieving device was connecting when the call was cancelled.")); |
|
693 break; |
|
694 case RCall::EStatusConnected: |
|
695 INFO_PRINTF1(_L("The recieving device was connected when the call was cancelled.")); |
|
696 break; |
|
697 case RCall::EStatusHangingUp: |
|
698 INFO_PRINTF1(_L("The recieving device was hanging up when the call was cancelled.")); |
|
699 break; |
|
700 } |
|
701 } |
|
702 INFO_PRINTF1(_L( "*END*CT_RMobileCallData::DoCmdCheckStatusWasConnecting" )); |
|
703 } |
|
704 |
|
705 void CT_RMobileCallData::DoCmdDialCancel(const TTEFFunction& aSection) |
|
706 { |
|
707 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdDialCancel")); |
|
708 |
|
709 TInt callNameParameter; |
|
710 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter )) |
|
711 { |
|
712 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
713 SetBlockResult(EFail); |
|
714 } |
|
715 else |
|
716 { |
|
717 INFO_PRINTF1(_L("Getting mobile call")); |
|
718 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
719 if(error != KErrNone) |
|
720 { |
|
721 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
722 SetBlockResult(EFail); |
|
723 } |
|
724 else |
|
725 { |
|
726 INFO_PRINTF1(_L("Cancelling dial...")); |
|
727 iMobileCall->DialCancel(); |
|
728 } |
|
729 } |
|
730 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdDialCancel")); |
|
731 } |
|
732 |
|
733 void CT_RMobileCallData::DoCmdHold(const TTEFFunction& aSection, const TInt aAsyncErrorIndex) |
|
734 { |
|
735 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdHold")); |
|
736 |
|
737 TInt callNameParameter; |
|
738 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter )) |
|
739 { |
|
740 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
741 SetBlockResult(EFail); |
|
742 } |
|
743 else |
|
744 { |
|
745 INFO_PRINTF1(_L("Getting mobile call")); |
|
746 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
747 if(error != KErrNone) |
|
748 { |
|
749 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
750 SetBlockResult(EFail); |
|
751 } |
|
752 else |
|
753 { |
|
754 INFO_PRINTF1(_L("Holding call...")); |
|
755 iMobileCall->Hold(iActiveCallback->iStatus); |
|
756 iActiveCallback->Activate (aAsyncErrorIndex); |
|
757 IncOutstanding(); |
|
758 } |
|
759 } |
|
760 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdHold")); |
|
761 } |
|
762 |
|
763 void CT_RMobileCallData::DoCmdResume(const TTEFFunction& aSection, const TInt aAsyncErrorIndex) |
|
764 { |
|
765 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdResume")); |
|
766 |
|
767 TInt callNameParameter; |
|
768 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter )) |
|
769 { |
|
770 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
771 SetBlockResult(EFail); |
|
772 } |
|
773 else |
|
774 { |
|
775 INFO_PRINTF1(_L("Getting mobile call")); |
|
776 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
777 if(error != KErrNone) |
|
778 { |
|
779 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
780 SetBlockResult(EFail); |
|
781 } |
|
782 else |
|
783 { |
|
784 INFO_PRINTF1(_L("Resuming call...")); |
|
785 iMobileCall->Resume (iActiveCallback->iStatus); |
|
786 iActiveCallback->Activate (aAsyncErrorIndex); |
|
787 IncOutstanding (); |
|
788 } |
|
789 } |
|
790 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdResume")); |
|
791 } |
|
792 |
|
793 void CT_RMobileCallData::DoCmdSwap(const TTEFFunction& aSection, const TInt aAsyncErrorIndex) |
|
794 { |
|
795 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdSwap")); |
|
796 |
|
797 TInt callNameParameter; |
|
798 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter )) |
|
799 { |
|
800 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
801 SetBlockResult(EFail); |
|
802 } |
|
803 else |
|
804 { |
|
805 INFO_PRINTF1(_L("Getting mobile call")); |
|
806 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
807 if(error != KErrNone) |
|
808 { |
|
809 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
810 SetBlockResult(EFail); |
|
811 } |
|
812 else |
|
813 { |
|
814 INFO_PRINTF1(_L("Swapping call...")); |
|
815 iMobileCall->Swap(iActiveCallback->iStatus); |
|
816 iActiveCallback->Activate(aAsyncErrorIndex); |
|
817 IncOutstanding (); |
|
818 } |
|
819 } |
|
820 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdSwap")); |
|
821 } |
|
822 |
|
823 void CT_RMobileCallData::DoCmdTransfer(const TTEFFunction& aSection, const TInt aAsyncErrorIndex) |
|
824 { |
|
825 INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdTransfer")); |
|
826 |
|
827 TInt callNameParameter; |
|
828 if ( !GetIntFromConfig(aSection, KCallName, callNameParameter )) |
|
829 { |
|
830 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName); |
|
831 SetBlockResult(EFail); |
|
832 } |
|
833 else |
|
834 { |
|
835 INFO_PRINTF1(_L("Getting mobile call")); |
|
836 TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) ); |
|
837 if(error != KErrNone) |
|
838 { |
|
839 ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error); |
|
840 SetBlockResult(EFail); |
|
841 } |
|
842 else |
|
843 { |
|
844 INFO_PRINTF1(_L("Transferring call...")); |
|
845 iMobileCall->Transfer(iActiveCallback->iStatus); |
|
846 iActiveCallback->Activate(aAsyncErrorIndex); |
|
847 IncOutstanding (); |
|
848 } |
|
849 } |
|
850 INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdTransfer")); |
|
851 } |
|
852 |
|
853 RMobileCall* CT_RMobileCallData::GetMobileCallL(TInt aCall) |
|
854 { |
|
855 INFO_PRINTF1(_L("*START* CT_RMobileCallData::GetMobileCallL")); |
|
856 |
|
857 INFO_PRINTF2(_L("Get RMobileCall: %d"), aCall); |
|
858 |
|
859 // Check that over/under flow does not occur |
|
860 if ( aCall < 0 || aCall >= iMobileCalls.Count ()) |
|
861 { |
|
862 INFO_PRINTF2(_L("There is no such call as (%d)"), aCall); |
|
863 User::Leave (KErrArgument); |
|
864 } |
|
865 INFO_PRINTF1(_L("*END* CT_RMobileCallData::GetMobileCallL")); |
|
866 return iMobileCalls[aCall]; |
|
867 } |
|
868 |
|
869 |
|
870 void CT_RMobileCallData::DoCmdUtilityCheckCapability(const TTEFFunction& aSection) |
|
871 { |
|
872 INFO_PRINTF1(_L("*START* CT_RMobileCallData::DoCmdUtilityCheckCapability")); |
|
873 |
|
874 TPtrC capability; |
|
875 if ( !GetStringFromConfig( aSection, KCapabilities, capability )) |
|
876 { |
|
877 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCapabilities); |
|
878 SetBlockResult(EFail); |
|
879 } |
|
880 else |
|
881 { |
|
882 if (!(iCallCaps.iFlags)) |
|
883 { |
|
884 ERR_PRINTF1(_L("Call capabilities are not supported.")); |
|
885 SetBlockResult(EFail); |
|
886 } |
|
887 else |
|
888 { |
|
889 if (capability == KCapsVoiceCall) |
|
890 { |
|
891 INFO_PRINTF1(_L("Checking if Call has no voice call capabilities.")); |
|
892 if (!(RMobileCall::KCapsVoice)) |
|
893 { |
|
894 SetBlockResult(EFail); |
|
895 } |
|
896 } |
|
897 else if (capability == KCapsHold) |
|
898 { |
|
899 INFO_PRINTF1(_L("Checking if Call has no hold capabilities.")); |
|
900 if (!(RMobileCall::KCapsHold)) |
|
901 { |
|
902 SetBlockResult(EFail); |
|
903 } |
|
904 } |
|
905 else if (capability == KCapsResume) |
|
906 { |
|
907 INFO_PRINTF1(_L("Checking if Call has no resume capabilities.")); |
|
908 if (!(RMobileCall::KCapsResume)) |
|
909 { |
|
910 SetBlockResult(EFail); |
|
911 } |
|
912 } |
|
913 else if (capability == KCapsSwap) |
|
914 { |
|
915 INFO_PRINTF1(_L("Checking if Call has no swap capabilities.")); |
|
916 if (!(RMobileCall::KCapsSwap)) |
|
917 { |
|
918 SetBlockResult(EFail); |
|
919 } |
|
920 } |
|
921 else if (capability == KCapsDeflect) |
|
922 { |
|
923 INFO_PRINTF1(_L("Checking if Call has no deflect capabilities.")); |
|
924 if (!(RMobileCall::KCapsDeflect)) |
|
925 { |
|
926 SetBlockResult(EFail); |
|
927 } |
|
928 } |
|
929 else if (capability == KCapsTransfer) |
|
930 { |
|
931 INFO_PRINTF1(_L("Checking if Call has no transfer capabilities.")); |
|
932 if (!(RMobileCall::KCapsTransfer)) |
|
933 { |
|
934 SetBlockResult(EFail); |
|
935 } |
|
936 } |
|
937 else if (capability == KCapsJoin) |
|
938 { |
|
939 INFO_PRINTF1(_L("Checking if Call has no join (conference) capabilities.")); |
|
940 if (!(RMobileCall::KCapsJoin)) |
|
941 { |
|
942 SetBlockResult(EFail); |
|
943 } |
|
944 } |
|
945 else if (capability == KCapsOneToOne) |
|
946 { |
|
947 INFO_PRINTF1(_L("Checking if Call has no OneToOne (conference) capabilities.")); |
|
948 if (!(RMobileCall::KCapsOneToOne)) |
|
949 { |
|
950 SetBlockResult(EFail); |
|
951 } |
|
952 } |
|
953 else |
|
954 { |
|
955 ERR_PRINTF1(_L("Unknown capability.")); |
|
956 SetBlockResult(EFail); |
|
957 } |
|
958 } |
|
959 } |
|
960 INFO_PRINTF1(_L("*END* CT_RMobileCallData::DoCmdUtilityCheckCapability")); |
|
961 } |
|
962 |