telephonyutils/etel3rdpartyapi/ExampleApps/OutgoingCalls/CMainMenu.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "CMainMenu.h"
       
    17 #include <simtsy.h>
       
    18 
       
    19 /**
       
    20 Factory constructor.
       
    21 
       
    22 @param  aConsole Console to which output is printed
       
    23 @return          Instance of CMainMenu class
       
    24 */
       
    25 CMainMenu* CMainMenu::NewLC(CConsoleBase& aConsole)
       
    26 	{
       
    27 	CMainMenu* self = new(ELeave) CMainMenu(aConsole);
       
    28 	CleanupStack::PushL(self);
       
    29 	self->ConstructL();
       
    30 	return self;
       
    31 	}
       
    32 
       
    33 /**
       
    34 Constructor called by the factory constructor CMainMenu::NewLC().
       
    35 
       
    36 @param Console to which output is printed
       
    37 */
       
    38 CMainMenu::CMainMenu(CConsoleBase& aConsole)
       
    39 	: CBaseMenuAsync(aConsole)
       
    40 	{
       
    41 	iCallWaitingOn = EFalse;
       
    42 	iRinging = EFalse;
       
    43 	iThenAnswer = EFalse;
       
    44 	}
       
    45 
       
    46 /**
       
    47 Second phase constructor.
       
    48 */
       
    49 void CMainMenu::ConstructL()
       
    50 	{
       
    51 	CBaseMenuAsync::ConstructL();
       
    52 	iPhoneId = CPhoneId::NewL(this);
       
    53 	iNetworkName = CCurrentNetworkName::NewL(this);
       
    54 	iOperatorName = COperatorName::NewL(this);
       
    55   	iNetworkInfo = CCurrentNetworkInfo::NewL(this);
       
    56 
       
    57 	iFlightModeInfo = CFlightModeInfo::NewL(this);
       
    58 	iNetworkRegInfo = CNetworkRegInfo::NewL(this);
       
    59 	iDialCall = CDialCall::NewL(this);
       
    60 	iLineStatus = CLineStatus::NewL(this);
       
    61 
       
    62 	iHangup = CHangup::NewL(this);
       
    63 	iHold = CHold::NewL(this);
       
    64 	iResume = CResume::NewL(this);
       
    65 
       
    66 	iSwap = CSwap::NewL(this);
       
    67 
       
    68 	iGetLockInfo = CGetLockInfo::NewL(this);
       
    69 	iCallWaiting = CCallWaitingStatus::NewL(this);
       
    70 	iAnswerIncomingCall = CAnswerIncomingCall::NewL(this);
       
    71 	}
       
    72 
       
    73 /**
       
    74 Destructor.
       
    75 */
       
    76 CMainMenu::~CMainMenu()
       
    77 	{
       
    78 	delete iTelephony;
       
    79 	delete iPhoneId;
       
    80 
       
    81 	delete iNetworkName;
       
    82 	delete iNetworkInfo;
       
    83 	delete iOperatorName;
       
    84 
       
    85 	delete iDialCall;
       
    86 	delete iHangup;
       
    87 	delete iHold;
       
    88 	delete iSwap;
       
    89 	delete iResume;
       
    90 
       
    91 	delete iFlightModeInfo;
       
    92 	delete iNetworkRegInfo;
       
    93 
       
    94 	delete iGetLockInfo;
       
    95 	delete iCallWaiting;
       
    96 	delete iAnswerIncomingCall;
       
    97 
       
    98 	delete iLineStatus;
       
    99 	delete iCallStatus;
       
   100 	delete iCallStatus2;
       
   101 	}
       
   102 
       
   103 /**
       
   104 Provides functionality for member objects to notify the Menu object (their 
       
   105 owner) that they have completed their request.
       
   106 
       
   107 @param aDerivedType Type of class derived from CISVAPIBase
       
   108 */
       
   109 void CMainMenu::ExecComplete(TTelISVExampleType aDerivedType)
       
   110 	{
       
   111 	if (IsActive())
       
   112 		{
       
   113 		Cancel();
       
   114 		}
       
   115    if (	iState==ESetNotifier
       
   116 			||  aDerivedType == KLineStatus
       
   117 			||  aDerivedType == KHold)
       
   118 		{
       
   119 		switch(aDerivedType)
       
   120 			{
       
   121 		case KLineStatus:
       
   122 			iLastOperation = iLineStatus;
       
   123 			break;
       
   124 		case KFlightModeInfo:
       
   125 			iLastOperation = iFlightModeInfo;
       
   126 			break;
       
   127 		case KNetworkRegInfo:
       
   128 			iLastOperation = iNetworkRegInfo;
       
   129 			break;
       
   130 		case KDialCall:
       
   131 			iLastOperation = iDialCall;
       
   132 			break;
       
   133 		case KHold:
       
   134 			iLastOperation = iHold;
       
   135 			break;
       
   136 		case KResume:
       
   137 			iLastOperation = iResume;
       
   138 			break;
       
   139 		case KSwap:
       
   140 			iLastOperation = iSwap;
       
   141 			break;
       
   142 		case KHangup:
       
   143 			iLastOperation = iHangup;
       
   144 			break;
       
   145 		case KNetworkInfo:
       
   146 			iLastOperation = iNetworkInfo;
       
   147 			break;
       
   148 		case KNetworkName:
       
   149 			iLastOperation = iNetworkName;
       
   150 			break;
       
   151 		case KOperatorName:
       
   152 			iLastOperation = iOperatorName;
       
   153 			break;
       
   154 		case KLockInfo:
       
   155 			iLastOperation = iGetLockInfo;
       
   156 			break;
       
   157 		case KCallWaitingStatus:
       
   158 			iLastOperation = iCallWaiting;
       
   159 			break;
       
   160 		case KAnswerIncomingCall:
       
   161 			iLastOperation = iAnswerIncomingCall;
       
   162 			break;
       
   163 			}
       
   164 		TRAPD(errNotify, iLastOperation->RequestNotificationL());
       
   165 		if (errNotify != KErrNone)
       
   166 			{
       
   167 			iConsole->Printf(_L("Notification Request for TTelISVExampleType"));
       
   168 			iConsole->Printf(_L("%d left with error code "), aDerivedType);
       
   169 			iConsole->Printf(_L("%d\n"), errNotify);
       
   170 			return;
       
   171 			};
       
   172 		// Check the type of iLastOperation to see what it has been cast to
       
   173 		switch(iLastOperation->GetExampleType())
       
   174 			{
       
   175 		case KFlightModeInfo:
       
   176 			iState = EGetNetworkRegStatus;
       
   177 			iLastOperation = iNetworkRegInfo;
       
   178 			SetActive();
       
   179 			CompleteOwnRequest(KErrNone);
       
   180 			break;
       
   181 		case KLineStatus:
       
   182 			iRinging = ETrue;
       
   183 			PrintCorrectMenu(GetCurrentDynamicCaps());
       
   184 			GetInput();
       
   185 			break;
       
   186 		case KAnswerIncomingCall:
       
   187 			if (iCallStatus == NULL)
       
   188 				{
       
   189 				iCallId = reinterpret_cast<CAnswerIncomingCall*>
       
   190 						  (iAnswerIncomingCall)->iCallId;
       
   191 				TRAPD(err, 	iCallStatus = CCallStatus::NewL(this, iCallId));
       
   192 				if (err != KErrNone)
       
   193 					{
       
   194 					iConsole->Printf(_L("CallStatus1 construction left "));
       
   195 					iConsole->Printf(_L("with error code %d\n"), err);
       
   196 					return;
       
   197 					}
       
   198 				iLastCallStatus = iCallStatus;
       
   199 				}
       
   200 			else
       
   201 				{
       
   202 				iCallId2 = reinterpret_cast<CAnswerIncomingCall*>
       
   203 				           (iAnswerIncomingCall)->iCallId;
       
   204 				TRAPD(err, 	iCallStatus2 = CCallStatus::NewL(this, iCallId2));
       
   205 				if (err != KErrNone)
       
   206 					{
       
   207 					iConsole->Printf(_L("CallStatus2 construction left "));
       
   208 					iConsole->Printf(_L("with error code %d\n"), err);
       
   209 					return;
       
   210 					}
       
   211 				iLastCallStatus =  iCallStatus2;
       
   212 				}
       
   213 			iState = EGetCallStatus;
       
   214 			iLastOperation = iLastCallStatus;
       
   215 			SetActive();
       
   216 			CompleteOwnRequest(KErrNone);
       
   217 			break;
       
   218 		case KDialCall:
       
   219 			if (iCallStatus == NULL)
       
   220 				{
       
   221 				iCallId = reinterpret_cast<CDialCall*>
       
   222 				          (iDialCall)->iCallId;
       
   223 				TRAPD(err, 	iCallStatus = CCallStatus::NewL(this, iCallId));
       
   224 				if (err != KErrNone)
       
   225 					{
       
   226 					iConsole->Printf(_L("CallStatus1 construction left "));
       
   227 					iConsole->Printf(_L("with error code %d\n"), err);
       
   228 					return;
       
   229 					}
       
   230 
       
   231 				iLastCallStatus = iCallStatus;
       
   232 				}
       
   233 			else
       
   234 				{
       
   235 				iCallId2 = reinterpret_cast<CDialCall*>
       
   236 				           (iDialCall)->iCallId;
       
   237 				TRAPD(err, 	iCallStatus2 = CCallStatus::NewL(this, iCallId2));
       
   238 				if (err != KErrNone)
       
   239 					{
       
   240 					iConsole->Printf(_L("CallStatus2 construction left "));
       
   241 					iConsole->Printf(_L("with error code %d\n"), err);
       
   242 					return;
       
   243 					}
       
   244 				iLastCallStatus =  iCallStatus2;
       
   245 				}
       
   246 			iState = EGetCallStatus;
       
   247 			iLastOperation = iLastCallStatus;
       
   248 			SetActive();
       
   249 			CompleteOwnRequest(KErrNone);
       
   250 			break;
       
   251 		case KCallStatus:
       
   252 		case KResume:
       
   253 			PrintCorrectMenu(GetCurrentDynamicCaps());
       
   254 			GetInput();
       
   255 			break;
       
   256 		case KSwap:
       
   257 			if (iLastCallStatus == iCallStatus)
       
   258 				{
       
   259 				iLastCallStatus =  iCallStatus2;
       
   260 				}
       
   261 			else
       
   262 				{
       
   263 				iLastCallStatus =  iCallStatus;
       
   264 				}
       
   265 			PrintCorrectMenu(GetCurrentDynamicCaps());
       
   266 			GetInput();
       
   267 			break;
       
   268 		case KHangup:
       
   269 			// Do nothing; all operations on hangup event are handled by the
       
   270 			// call status notification. In this way remote party hangups can be
       
   271 			// detected.
       
   272 			break;
       
   273 		case KHold:
       
   274 			if (iThenAnswer)
       
   275 				{
       
   276 				iThenAnswer = EFalse;
       
   277 				iState = EAnswerIncomingCall;
       
   278 				iLastOperation = iAnswerIncomingCall;
       
   279 				SetActive();
       
   280 				CompleteOwnRequest(KErrNone);
       
   281 				}
       
   282 			else
       
   283 				{
       
   284 				PrintCorrectMenu(GetCurrentDynamicCaps());
       
   285 				GetInput();
       
   286 				}
       
   287 			break;
       
   288 		case KNetworkInfo:
       
   289 			iState = EGetNetworkName;
       
   290 			iLastOperation = iNetworkName;
       
   291 			SetActive();
       
   292 			CompleteOwnRequest(KErrNone);
       
   293 			break;
       
   294 		case KNetworkName:
       
   295 			iState = EGetOperatorName;
       
   296 			iLastOperation = iOperatorName;
       
   297 			SetActive();
       
   298 			CompleteOwnRequest(KErrNone);
       
   299 			break;
       
   300 		case KOperatorName:
       
   301 			iState = ECallWaiting;
       
   302 			iLastOperation = iCallWaiting;
       
   303 			SetActive();
       
   304 			CompleteOwnRequest(KErrNone);
       
   305 			break;
       
   306 		case KLockInfo:
       
   307 			iState = EGetLineStatus;
       
   308 			iLastOperation = iLineStatus;
       
   309 			SetActive();
       
   310 			CompleteOwnRequest(KErrNone);
       
   311 			break;
       
   312 		case KCallWaitingStatus:
       
   313 			iCallWaitingOn = ETrue;
       
   314 			iState = EGetLockInfo;
       
   315 			iLastOperation = iGetLockInfo;
       
   316 			SetActive();
       
   317 			CompleteOwnRequest(KErrNone);
       
   318 			break;
       
   319 		default:
       
   320 
       
   321 			break;
       
   322 			}
       
   323 		}
       
   324 	else if(aDerivedType == KPhoneId)
       
   325 		{
       
   326 		iLastOperation = iFlightModeInfo;
       
   327 		SetActive();
       
   328 		CompleteOwnRequest(KErrNone);
       
   329 		}
       
   330 	}
       
   331 
       
   332 /**
       
   333 Provides functionality for member objects to notify the Menu object (their 
       
   334 owner) that they have been notified of a change.
       
   335 
       
   336 @param aDerivedType Type of class derived from CISVAPIBase
       
   337 */
       
   338 void CMainMenu::ExecNotify(TTelISVExampleType aDerivedType)
       
   339 	{
       
   340 	if (IsActive())
       
   341 		{
       
   342 		Cancel();
       
   343 		}
       
   344 	switch(aDerivedType)
       
   345 		{
       
   346 	case KNetworkRegInfo:
       
   347 		{
       
   348 		TRAPD(err, iNetworkRegInfo->RequestNotificationL());
       
   349 		if (err != KErrNone)
       
   350 			{
       
   351 			iConsole->Printf(_L("%d\n"),err);
       
   352 			return;
       
   353 			}
       
   354 		iState = EGetNetworkInfo;
       
   355 		iLastOperation = iNetworkInfo;
       
   356 		SetActive();
       
   357 		CompleteOwnRequest(KErrNone);
       
   358 		break;
       
   359 		}
       
   360 	case KLineStatus:
       
   361 		{
       
   362 		TRAPD(err, iLineStatus->RequestNotificationL());
       
   363 		if (err != KErrNone)
       
   364 			{
       
   365 			iConsole->Printf(_L("Request left with error code "));
       
   366 			iConsole->Printf(_L("%d\n"),err);
       
   367 			return;
       
   368 			}		PrintCorrectMenu(GetCurrentDynamicCaps());
       
   369 		GetInput();
       
   370 		break;
       
   371 		}
       
   372 	case KCallStatus:
       
   373 		if (iLastCallStatus == iCallStatus)
       
   374 			{
       
   375 			// Delete the previous object call status object which has now been
       
   376 			// hung up.
       
   377 			delete iLastCallStatus;
       
   378 			iCallStatus = NULL;
       
   379 			iLastCallStatus = iCallStatus2;
       
   380 			}
       
   381 		else
       
   382 			{
       
   383 			delete iLastCallStatus;
       
   384 			iCallStatus2 = NULL;
       
   385 			iLastCallStatus = iCallStatus;
       
   386 			}
       
   387 		if (iLineStatus->IsActive())
       
   388 			{
       
   389 			iLineStatus->Cancel();
       
   390 			}
       
   391 		iState = EGetLineStatus;
       
   392 		iLastOperation = iLineStatus;
       
   393 		SetActive();
       
   394 		CompleteOwnRequest(KErrNone);
       
   395 		break;
       
   396 	case KCallWaitingStatus:
       
   397 		iCallWaitingOn = EFalse;
       
   398 		iState = EGetLockInfo;
       
   399 		iLastOperation = iGetLockInfo;
       
   400 		SetActive();
       
   401 		CompleteOwnRequest(KErrNone);
       
   402 		break;
       
   403 		}
       
   404 	}
       
   405 
       
   406 /**
       
   407 Handles key presses.
       
   408 */
       
   409 void CMainMenu::RunL()
       
   410 	{
       
   411 	switch(iState)
       
   412 		{
       
   413 	case EStart:
       
   414 		iState = EGetFlightModeInfo;
       
   415 		iLastOperation = iPhoneId;
       
   416 		TRAPD(errPhone, iLastOperation->StartRequestL());
       
   417 		if (errPhone != KErrNone)
       
   418 			{
       
   419 			iConsole->Printf(_L("Request left with error code "));
       
   420 			iConsole->Printf(_L("%d\n"), errPhone);
       
   421 			return;
       
   422 			};
       
   423 		break;
       
   424 	case EEnd:
       
   425 		if (iLineStatus->IsActive())
       
   426 			{
       
   427 			iLineStatus->Cancel();
       
   428 			}
       
   429 		if (iNetworkRegInfo->IsActive())
       
   430 			{
       
   431 			iNetworkRegInfo->Cancel();
       
   432 			}
       
   433 		if (iNetworkInfo->IsActive())
       
   434 			{
       
   435 			iNetworkInfo->Cancel();
       
   436 			}
       
   437 		if (iFlightModeInfo->IsActive())
       
   438 			{
       
   439 			iFlightModeInfo->Cancel();
       
   440 			}
       
   441 		CActiveScheduler::Stop();
       
   442 		break;
       
   443 	case EAnswerIncomingCall:
       
   444 	case ECallWaiting:
       
   445 	case EGetLockInfo:
       
   446 	case EGetNetworkInfo:
       
   447 	case EGetNetworkName:
       
   448 	case EGetOperatorName:
       
   449 	case EGetFlightModeInfo:
       
   450 	case EGetNetworkRegStatus:
       
   451 	case EGetLineStatus:
       
   452 	case EGetCallStatus:
       
   453 		iState = ESetNotifier;
       
   454 		TRAPD(err, iLastOperation->StartRequestL());
       
   455 		if (err != KErrNone)
       
   456 			{
       
   457 			iConsole->Printf(_L("Request left with error code "));
       
   458 			iConsole->Printf(_L("%d\n"), err);
       
   459 			return;
       
   460 			}
       
   461 		break;
       
   462 	case EHold:
       
   463 	case EResume:
       
   464 	case EHangup:
       
   465 		CTelephony::TCallId temp;
       
   466 		if (iLastCallStatus == iCallStatus)
       
   467 			{
       
   468 			temp = iCallId;
       
   469 			}
       
   470 		else
       
   471 			{
       
   472 			temp = iCallId2;
       
   473 			}
       
   474 		iState = ESetNotifier;
       
   475 		TRAPD(errArg, iLastOperation->StartRequestL(temp));
       
   476 		if (errArg != KErrNone)
       
   477 			{
       
   478 			iConsole->Printf(_L("Request left with error code "));
       
   479 			iConsole->Printf(_L("%d\n"), errArg);
       
   480 			return;
       
   481 			}
       
   482 		break;
       
   483 	case ESwap:
       
   484 		iState = ESetNotifier;
       
   485 		TRAPD(errSwap, iLastOperation->StartRequestL(iCallId, iCallId2));
       
   486 		if (errSwap != KErrNone)
       
   487 			{
       
   488 			iConsole->Printf(_L("Request left with error code "));
       
   489 			iConsole->Printf(_L("%d\n"), errSwap);
       
   490 			return;
       
   491 			}
       
   492 		break;
       
   493 	case EDialCall:
       
   494 		iState = ESetNotifier;
       
   495 		TRAPD(errNum, iLastOperation->StartRequestL(KTheNumber));
       
   496 		if (errNum != KErrNone)
       
   497 			{
       
   498 			iConsole->Printf(_L("Request left with error code "));
       
   499 			iConsole->Printf(_L("%d\n"), errNum);
       
   500 			return;
       
   501 			}
       
   502 		break;
       
   503 	case EWaitingForKeyPress:
       
   504 		{
       
   505 		CTelephony::TCallCapsV1 CallCapsV1 = GetCurrentDynamicCaps();
       
   506 		TUint32 crtlCaps = CallCapsV1.iControlCaps;
       
   507 		TInt c = iConsole->KeyCode();
       
   508 		switch(c)
       
   509 			{
       
   510 		// Exit
       
   511 		case 'E':
       
   512 		case 'e':
       
   513 		// cancel notifications
       
   514 			if (iCallStatus != NULL)
       
   515 				{
       
   516 				iCallStatus->Cancel();
       
   517 				}
       
   518 			if (iCallStatus2 != NULL)
       
   519 				{
       
   520 				iCallStatus2->Cancel();
       
   521 				}
       
   522 			iLineStatus->Cancel();
       
   523 			iFlightModeInfo->Cancel();
       
   524 			iNetworkRegInfo->Cancel();
       
   525 			iNetworkInfo->Cancel();
       
   526 			iGetLockInfo->Cancel();
       
   527 			CActiveScheduler::Stop();
       
   528 			break;
       
   529 		// Hangup active call
       
   530 		case EKeyEscape:
       
   531 			if (iLastCallStatus != NULL)
       
   532 				{
       
   533 				iState = EHangup;
       
   534 				iLastOperation = iHangup;
       
   535 				SetActive();
       
   536 				CompleteOwnRequest(KErrNone);
       
   537 				}
       
   538 			else
       
   539 				{
       
   540 				GetInput();
       
   541 				}
       
   542 			break;
       
   543 		// Swap active and on hold calls
       
   544 		case 'S':
       
   545 		case 's':
       
   546 			if (crtlCaps & CTelephony::KCapsSwap
       
   547 			&&  iCallStatus != NULL
       
   548 			&&  iCallStatus2 !=NULL)
       
   549 				{
       
   550 				iState = ESwap;
       
   551 				iLastOperation = iSwap;
       
   552 				SetActive();
       
   553 				CompleteOwnRequest(KErrNone);
       
   554 				}
       
   555 			else
       
   556 				{
       
   557 				GetInput();
       
   558 				}
       
   559 			break;
       
   560 		// Make another call
       
   561 		case 'D':
       
   562 		case 'd':
       
   563 			if (iLastCallStatus == NULL
       
   564 			||  crtlCaps & CTelephony::KCapsResume
       
   565 			&& !iRinging)
       
   566 				{
       
   567 				iConsole->ClearScreen();
       
   568 				iConsole->Printf(_L("Dialling Call\n"));
       
   569 				iState = EDialCall;
       
   570 				iLastOperation = iDialCall;
       
   571 				SetActive();
       
   572 				CompleteOwnRequest(KErrNone);
       
   573 				}
       
   574 			else
       
   575 				{
       
   576 				GetInput();
       
   577 				}
       
   578 			break;
       
   579 		// Put call on hold
       
   580 		case 'H':
       
   581 		case 'h':
       
   582 			if (crtlCaps & CTelephony::KCapsHold)
       
   583 				{
       
   584 				iState = EHold;
       
   585 				iLastOperation = iHold;
       
   586 				SetActive();
       
   587 				CompleteOwnRequest(KErrNone);
       
   588 				}
       
   589 			else
       
   590 				{
       
   591 				GetInput();
       
   592 				}
       
   593 			break;
       
   594 		// Resume on hold call
       
   595 		case 'R':
       
   596 		case 'r':
       
   597 			if (crtlCaps & CTelephony::KCapsResume
       
   598 			&&  iLastCallStatus != NULL )
       
   599 				{
       
   600 				iState = EResume;
       
   601 				iLastOperation = iResume;
       
   602 				SetActive();
       
   603 				CompleteOwnRequest(KErrNone);
       
   604 				}
       
   605 			else
       
   606 				{
       
   607 				GetInput();
       
   608 				}
       
   609 			break;
       
   610 		// Answer incoming call
       
   611 		case 'a':
       
   612 		case 'A':
       
   613 			if (iCallWaiting && iLastCallStatus != NULL
       
   614 			&&  crtlCaps & CTelephony::KCapsResume)
       
   615 				{
       
   616 				iRinging = EFalse;
       
   617 				iState = EAnswerIncomingCall;
       
   618 				iLastOperation = iAnswerIncomingCall;
       
   619 				SetActive();
       
   620 				CompleteOwnRequest(KErrNone);
       
   621 				break;
       
   622 				}
       
   623 			else if(iCallWaiting
       
   624 			     && iLastCallStatus != NULL
       
   625 			     && crtlCaps & CTelephony::KCapsHold)
       
   626 				{
       
   627 				iRinging = EFalse;
       
   628 				iThenAnswer = ETrue;
       
   629 				iState = EHold;
       
   630 				iLastOperation = iHold;
       
   631 				SetActive();
       
   632 				CompleteOwnRequest(KErrNone);
       
   633 				}
       
   634 			else
       
   635 				{
       
   636 				GetInput();
       
   637 				}
       
   638 			break;
       
   639 		// Simulate incoming call
       
   640 		case 'i':
       
   641 		case 'I':
       
   642 			if(iCallWaiting
       
   643 			&& iLastCallStatus != NULL
       
   644 			&& (crtlCaps & CTelephony::KCapsResume ||
       
   645 			    crtlCaps & CTelephony::KCapsHold))
       
   646 				{
       
   647 				TInt ret = RProperty::Set(KUidPSSimTsyCategory,
       
   648 										  KPSSimTsyIncomingVoiceCall,
       
   649 										  0);
       
   650 				break;
       
   651 				}
       
   652 		default:
       
   653 			GetInput();
       
   654 			}
       
   655 		}
       
   656 		break;
       
   657 	default:
       
   658 		break;
       
   659 		}
       
   660 	}
       
   661 
       
   662 /**
       
   663 Gets dynamic call capabilities.
       
   664 */
       
   665 CTelephony::TCallCapsV1 CMainMenu::GetCurrentDynamicCaps()
       
   666 	{
       
   667 	CTelephony::TCallId temp;
       
   668 	CTelephony::TCallCapsV1 callCapsV1;
       
   669 	CTelephony::TCallCapsV1Pckg callCapsV1Pckg(callCapsV1);
       
   670 	if (iLastCallStatus == iCallStatus)
       
   671 		{
       
   672 		temp = iCallId;
       
   673 		}
       
   674 	else
       
   675 		{
       
   676 		temp = iCallId2;
       
   677 		}
       
   678 	// Retrieves the dynamic call capabilities for calls you dialled or answered with CTelephony
       
   679 	iTelephony->GetCallDynamicCaps(temp, callCapsV1Pckg);
       
   680 	return callCapsV1;
       
   681 	}
       
   682 
       
   683 /**
       
   684 Prints options menu to the console.
       
   685 
       
   686 @param aCallCapsV1 Stores the call capabilities
       
   687 */
       
   688 void CMainMenu::PrintCorrectMenu(CTelephony::TCallCapsV1 aCallCapsV1)
       
   689 	{
       
   690 	iConsole->ClearScreen();
       
   691 	iConsole->Printf(KMenuMsg);
       
   692 	if (iRinging)
       
   693 		{
       
   694 		iConsole->Printf(_L("There is an incoming call\n"));
       
   695 		iConsole->Printf(_L("How would you like to proceed?\n"));
       
   696 		if (aCallCapsV1.iControlCaps & CTelephony::KCapsHold)
       
   697 			{
       
   698 			iConsole->Printf(KHoldMsg);
       
   699 			iConsole->Printf(KAnswerMsg);
       
   700 			iConsole->Printf(KHangupMsg);
       
   701 			}
       
   702 		else
       
   703 			{
       
   704 			iConsole->Printf(KResumeMsg);
       
   705 			iConsole->Printf(KAnswerMsg);
       
   706 			iConsole->Printf(KHangupMsg);
       
   707 			}
       
   708 		}
       
   709 	else
       
   710 		{
       
   711 		if (iLastCallStatus == NULL)
       
   712 			{
       
   713 			iConsole->Printf(KDialMsg);
       
   714 			}
       
   715 		else if (aCallCapsV1.iControlCaps & CTelephony::KCapsSwap
       
   716 		     &&  iCallStatus != NULL
       
   717 		     &&  iCallStatus2 != NULL)
       
   718 			{
       
   719 			iConsole->Printf(KSwapMsg);
       
   720 			iConsole->Printf(KHangupMsg);
       
   721 			}
       
   722 		else if (aCallCapsV1.iControlCaps & CTelephony::KCapsHold)
       
   723 			{
       
   724 			iConsole->Printf(KHoldMsg);
       
   725 			iConsole->Printf(KIncomingMsg);
       
   726 			iConsole->Printf(KHangupMsg);
       
   727 			}
       
   728 		else if (aCallCapsV1.iControlCaps & CTelephony::KCapsResume)
       
   729 			{
       
   730 			iConsole->Printf(KResumeMsg);
       
   731 			iConsole->Printf(KDialMsg);
       
   732 			iConsole->Printf(KIncomingMsg);
       
   733 			iConsole->Printf(KHangupMsg);
       
   734 			}
       
   735 		}
       
   736 	}
       
   737 
       
   738 /**
       
   739 Waits for console input.
       
   740 */
       
   741 void CMainMenu::GetInput()
       
   742 	{
       
   743 	iConsole->Read(iStatus);
       
   744 	iState = EWaitingForKeyPress;
       
   745 	SetActive();
       
   746 	}
       
   747 
       
   748 /**
       
   749 Cancels outstanding asynchronous request.
       
   750 */
       
   751 void CMainMenu::DoCancel()
       
   752 	{
       
   753 	if(iState == EStart)
       
   754 		{
       
   755 		CompleteOwnRequest(KErrCancel);
       
   756 		}
       
   757 	else
       
   758 		{
       
   759 		iConsole->ReadCancel();
       
   760 		}
       
   761 	}