cellularsrvapitest/telephonydevsoundhaitest/etelmm/src/T_RMobileCallData.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     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 void CT_RMobileCallData::DoCmdOpenNewCall(const TTEFFunction& aSection)
       
   381 	{
       
   382 	INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdOpenNewCall"));
       
   383 	TBool dataOk = ETrue;
       
   384 	TInt callNameParameter;
       
   385 	if ( !GetIntFromConfig(aSection, KCallName, callNameParameter ))
       
   386 		{
       
   387 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
       
   388 		SetBlockResult(EFail);
       
   389 		dataOk = EFalse;
       
   390 		}
       
   391 	TPtrC mobileLineName;
       
   392 	if ( !GetStringFromConfig (aSection, KMobileLineKey (), mobileLineName))
       
   393 		{
       
   394 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMobileLineKey );
       
   395 		SetBlockResult(EFail);
       
   396 		dataOk = EFalse;
       
   397 		}
       
   398 	if ( dataOk )
       
   399 		{
       
   400 		CT_RMobileLineData* mobileLineWrapper = static_cast<CT_RMobileLineData*>(GetDataWrapperL(mobileLineName));
       
   401 		TName* callName;
       
   402 		TRAPD( error, callName = mobileLineWrapper->GetCallNameL (callNameParameter) );
       
   403 		if(error != KErrNone)
       
   404 			{
       
   405 			ERR_PRINTF2(_L("Left while getting call name with error %d"), error);
       
   406 			SetError(error);
       
   407 			}
       
   408 		else
       
   409 			{
       
   410 			INFO_PRINTF1(_L("Open handle to RMobileCall which can be used to receive incoming or dial outgoing call."));
       
   411 			RMobileLine* mobileLineObject = static_cast<RMobileLine*>(GetDataObjectL(mobileLineName));
       
   412 			INFO_PRINTF1(_L("Getting mobile call"));
       
   413 			TRAP(error, iMobileCall = GetMobileCallL(callNameParameter));
       
   414 			if(error != KErrNone)
       
   415 				{
       
   416 				ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error);
       
   417 				SetBlockResult(EFail);
       
   418 				}
       
   419 			else
       
   420 				{
       
   421 				INFO_PRINTF1(_L("Opening new call"));
       
   422 				error = iMobileCall->OpenNewCall(*mobileLineObject, *callName);
       
   423 				if ( error != KErrNone)
       
   424 					{
       
   425 					ERR_PRINTF3(_L("OpenNewCall named: %S, failed with error [%d]"), &callName, error);
       
   426 					SetError (error);
       
   427 					}
       
   428 				else
       
   429 					{
       
   430 					INFO_PRINTF1(_L("Open new call succeeded"));
       
   431 					}
       
   432 				}
       
   433 			}
       
   434 		}
       
   435 	INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdOpenNewCall"));
       
   436 	}
       
   437 
       
   438 void CT_RMobileCallData::DoCmdOpenExistingCall(const TTEFFunction& aSection)
       
   439 	{
       
   440 	INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdOpenExistingCall"));
       
   441 	TInt callNameParameter;
       
   442 	TBool dataOk = ETrue;
       
   443 	if ( !GetIntFromConfig(aSection, KCallName, callNameParameter ))
       
   444 		{
       
   445 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
       
   446 		SetBlockResult(EFail);
       
   447 		dataOk = EFalse;
       
   448 		}
       
   449 	TPtrC mobileLineName;
       
   450 	if ( !GetStringFromConfig (aSection, KMobileLineKey (), mobileLineName))
       
   451 		{
       
   452 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMobileLineKey );
       
   453 		SetBlockResult(EFail);
       
   454 		dataOk = EFalse;
       
   455 		}
       
   456 	if ( dataOk )
       
   457 		{
       
   458 		CT_RMobileLineData* mobileLineWrapper = static_cast<CT_RMobileLineData*>(GetDataWrapperL(mobileLineName));
       
   459 		const TName* callName = NULL;
       
   460 		TRAPD( error, callName = mobileLineWrapper->GetCallNameL (callNameParameter) );
       
   461 		if(error != KErrNone)
       
   462 			{
       
   463 			ERR_PRINTF2(_L("Left while getting call name with error %d"), error);
       
   464 			SetError(error);
       
   465 			}
       
   466 		else
       
   467 			{
       
   468 			INFO_PRINTF1(_L("Open handle to RMobileCall which can be used to receive incoming or dial outgoing call."));
       
   469 			RMobileLine* mobileLineObject = static_cast<RMobileLine*>(GetDataObjectL(mobileLineName));
       
   470 			INFO_PRINTF1(_L("Getting mobile call"));
       
   471 			TRAP( error, iMobileCall = GetMobileCallL(callNameParameter) );
       
   472 			if(error != KErrNone)
       
   473 				{
       
   474 				ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error);
       
   475 				SetBlockResult(EFail);
       
   476 				}
       
   477 			else
       
   478 				{
       
   479 				INFO_PRINTF1(_L("Opening existing call"));
       
   480 				error = iMobileCall->OpenExistingCall(*mobileLineObject, *callName);
       
   481 				if ( error != KErrNone)
       
   482 					{
       
   483 					ERR_PRINTF2(_L("OpenExistingCall failed with error [%d]"), error);
       
   484 					SetError (error);
       
   485 					}
       
   486 				else
       
   487 					{
       
   488 					INFO_PRINTF1(_L("OpenExistingCall succeeded"));
       
   489 					}
       
   490 				}
       
   491 			}
       
   492 		}
       
   493 	INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdOpenExistingCall"));
       
   494 	}
       
   495 
       
   496 /**
       
   497  Dial out to given phone number using previously opened RMobileCall
       
   498  @param aSection
       
   499  @param KCallName
       
   500  @param KPhoneNumber
       
   501  @param KCallTimeout
       
   502  @return error - Symbian error code. KErrNone if successful
       
   503  */
       
   504 void CT_RMobileCallData::DoCmdDial(const TTEFFunction& aSection, const TInt aAsyncErrorIndex)
       
   505 	{
       
   506 	INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdDial"));
       
   507 	TBool dataOk = ETrue;
       
   508 	if ( !GetStringFromConfig( aSection, KPhoneNumber, iPhoneNumber ))
       
   509 		{
       
   510 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPhoneNumber);
       
   511 		SetBlockResult(EFail);
       
   512 		dataOk = EFalse;
       
   513 		}
       
   514 	TInt callNameParameter;
       
   515 	if ( !GetIntFromConfig(aSection, KCallName, callNameParameter ))
       
   516 		{
       
   517 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
       
   518 		SetBlockResult(EFail);
       
   519 		dataOk = EFalse;
       
   520 		}
       
   521 	if ( dataOk )
       
   522 		{
       
   523 		INFO_PRINTF1(_L("Getting mobile call"));
       
   524 		TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) );
       
   525 		if(error != KErrNone)
       
   526 			{
       
   527 			ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error);
       
   528 			SetBlockResult(EFail);
       
   529 			}
       
   530 		else
       
   531 			{
       
   532 			INFO_PRINTF2(_L("Dialing \"%S\""), &iPhoneNumber);
       
   533 			iMobileCall->Dial (iActiveCallback->iStatus, iPhoneNumber);
       
   534 			iActiveCallback->Activate(aAsyncErrorIndex);
       
   535 			IncOutstanding ();
       
   536 			}
       
   537 		}
       
   538 	INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdDial"));
       
   539 	}
       
   540 
       
   541 void CT_RMobileCallData::DoCmdAnswerIncomingCall(const TTEFFunction& aSection, const TInt aAsyncErrorIndex)
       
   542 	{
       
   543 	INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdAnswerIncomingCallAsync"));
       
   544 
       
   545 	TInt callNameParameter;
       
   546 	if ( !GetIntFromConfig(aSection, KCallName, callNameParameter))
       
   547 		{
       
   548 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
       
   549 		SetBlockResult(EFail);
       
   550 		}
       
   551 	else
       
   552 		{
       
   553 		TRequestStatus status;
       
   554 		// Call status is read to a RCall:TStatus variable.
       
   555 		RCall::TStatus callStatus;
       
   556 		TBool callReady = EFalse;
       
   557 	
       
   558 		INFO_PRINTF1(_L("Getting mobile call"));
       
   559 		TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) );
       
   560 		if(error != KErrNone)
       
   561 			{
       
   562 			ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error);
       
   563 			SetBlockResult(EFail);
       
   564 			}
       
   565 		else
       
   566 			{
       
   567 			while (callReady == EFalse)
       
   568 				{
       
   569 				INFO_PRINTF1(_L("Getting call status..."));
       
   570 				error = iMobileCall->GetStatus (callStatus);
       
   571 				if ( error != KErrNone)
       
   572 					{
       
   573 					ERR_PRINTF2(_L("Failed to read call status [%d]"), error);
       
   574 					SetError(error);
       
   575 					}
       
   576 				else
       
   577 					{
       
   578 					switch(callStatus)
       
   579 						{
       
   580 						case RCall::EStatusRinging:
       
   581 							// Mobile call is ringing, we can answer it now.
       
   582 							INFO_PRINTF1(_L("Mobile call is ringing"));
       
   583 							callReady = ETrue;
       
   584 						break;
       
   585 						case RCall::EStatusIdle:
       
   586 							// Mobile call was terminated before we could answer it.
       
   587 							INFO_PRINTF1(_L("Mobile call was terminated before it could be answered"));
       
   588 							SetBlockResult(EFail);
       
   589 						break;
       
   590 						default:
       
   591 							INFO_PRINTF1(_L("Mobile call is still waiting ring"));
       
   592 							INFO_PRINTF1(_L("Waiting for the phone status change..."));
       
   593 							TRequestStatus status;
       
   594 							iMobileCall->NotifyStatusChange(status, callStatus);
       
   595 							User::WaitForRequest(status);
       
   596 						break;
       
   597 						}
       
   598 					}
       
   599 				}
       
   600 			// Answer the incoming phone call now.
       
   601 			INFO_PRINTF1(_L("Mobile call is ready, answering"));
       
   602 			iMobileCall->AnswerIncomingCall (iActiveCallback->iStatus);
       
   603 			iActiveCallback->Activate (aAsyncErrorIndex);
       
   604 			IncOutstanding ();
       
   605 			}
       
   606 		}
       
   607 	INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdAnswerIncomingCallAsync"));
       
   608 	}
       
   609 
       
   610 void CT_RMobileCallData::DoCmdAnswerIncomingCallPost(const TTEFFunction& aSection, const TInt aAsyncErrorIndex)
       
   611 	{
       
   612 	INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdAnswerIncomingCallPost"));
       
   613 
       
   614 	TInt callNameParameter;
       
   615 	if ( !GetIntFromConfig(aSection, KCallName, callNameParameter))
       
   616 		{
       
   617 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
       
   618 		SetBlockResult(EFail);
       
   619 		}
       
   620 	else
       
   621 		{
       
   622 		INFO_PRINTF1(_L("Getting mobile call"));
       
   623 		TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) );
       
   624 		if(error != KErrNone)
       
   625 			{
       
   626 			ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error);
       
   627 			SetBlockResult(EFail);
       
   628 			}
       
   629 		else
       
   630 			{
       
   631 			INFO_PRINTF1(_L("Read call status to check if the other party hanged up."));
       
   632 			RCall::TStatus callStatus;
       
   633 			error = iMobileCall->GetStatus(callStatus);
       
   634 			if ( error != KErrNone)
       
   635 				{
       
   636 				ERR_PRINTF2(_L("Failed to read mobile call's status [%d]"), error);
       
   637 				SetError(error);
       
   638 				}
       
   639 			else
       
   640 				{
       
   641 				// Normal status of the connection is EStatusConnected.
       
   642 				if ( callStatus == RCall::EStatusConnected)
       
   643 					{
       
   644 					INFO_PRINTF1(_L("Mobile call is connected."));
       
   645 					}
       
   646 				else
       
   647 					{
       
   648 					INFO_PRINTF1(_L("Mobile call was disconnected, hanging up."));
       
   649 					iMobileCall->HangUp (iActiveCallback->iStatus);
       
   650 					iActiveCallback->Activate (aAsyncErrorIndex);
       
   651 					IncOutstanding ();
       
   652 					}
       
   653 				}
       
   654 			}
       
   655 		}
       
   656 	INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdAnswerIncomingCallPost"));
       
   657 	}
       
   658 
       
   659 
       
   660 void CT_RMobileCallData::DoCmdGetStatus()
       
   661 	{
       
   662 	INFO_PRINTF1(_L( "*START*CT_RMobileCallData::DoCmdCheckStatusWasConnecting" ));
       
   663 
       
   664 	TRAPD( error, iMobileCall->GetStatus(iTimeoutedMOCallStatus) );
       
   665 	if( error != KErrNone )
       
   666 		{
       
   667 		ERR_PRINTF2(_L("Failed to get call status with error %d"), error);
       
   668 		SetError(error);
       
   669 		}
       
   670 	else
       
   671 		{
       
   672 		switch(iTimeoutedMOCallStatus)
       
   673 			{
       
   674 			case RCall::EStatusUnknown: 
       
   675 				INFO_PRINTF1(_L("The recieving device was in unknown status when the call was cancelled."));
       
   676 			break;
       
   677 			case RCall::EStatusIdle: 
       
   678 				INFO_PRINTF1(_L("The recieving device was idle when the call was cancelled."));
       
   679 			break;
       
   680 			case RCall::EStatusDialling: 
       
   681 				INFO_PRINTF1(_L("The recieving device was dialing when the call was cancelled."));
       
   682 			break;
       
   683 			case RCall::EStatusRinging: 
       
   684 				INFO_PRINTF1(_L("The recieving device was ringing when the call was cancelled."));
       
   685 			break;
       
   686 			case RCall::EStatusAnswering: 
       
   687 				INFO_PRINTF1(_L("The recieving device was answering when the call was cancelled."));
       
   688 			break;
       
   689 			case RCall::EStatusConnecting: 
       
   690 				INFO_PRINTF1(_L("The recieving device was connecting when the call was cancelled."));
       
   691 			break;
       
   692 			case RCall::EStatusConnected: 
       
   693 				INFO_PRINTF1(_L("The recieving device was connected when the call was cancelled."));
       
   694 			break;
       
   695 			case RCall::EStatusHangingUp: 
       
   696 				INFO_PRINTF1(_L("The recieving device was hanging up when the call was cancelled."));
       
   697 			break;
       
   698 			}
       
   699 		}
       
   700 	INFO_PRINTF1(_L( "*END*CT_RMobileCallData::DoCmdCheckStatusWasConnecting" ));
       
   701 	}
       
   702 
       
   703 void CT_RMobileCallData::DoCmdDialCancel(const TTEFFunction& aSection)
       
   704 	{
       
   705 	INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdDialCancel"));
       
   706 	
       
   707 	TInt callNameParameter;
       
   708 	if ( !GetIntFromConfig(aSection, KCallName, callNameParameter ))
       
   709 		{
       
   710 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
       
   711 		SetBlockResult(EFail);
       
   712 		}
       
   713 	else
       
   714 		{
       
   715 		INFO_PRINTF1(_L("Getting mobile call"));
       
   716 		TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) );
       
   717 		if(error != KErrNone)
       
   718 			{
       
   719 			ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error);
       
   720 			SetBlockResult(EFail);
       
   721 			}
       
   722 		else
       
   723 			{
       
   724 			INFO_PRINTF1(_L("Cancelling dial..."));
       
   725 			iMobileCall->DialCancel();
       
   726 			}
       
   727 		}
       
   728 	INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdDialCancel"));
       
   729 	}
       
   730 
       
   731 void CT_RMobileCallData::DoCmdHold(const TTEFFunction& aSection, const TInt aAsyncErrorIndex)
       
   732 	{
       
   733 	INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdHold"));
       
   734 
       
   735 	TInt callNameParameter;
       
   736 	if ( !GetIntFromConfig(aSection, KCallName, callNameParameter ))
       
   737 		{
       
   738 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
       
   739 		SetBlockResult(EFail);
       
   740 		}
       
   741 	else
       
   742 		{
       
   743 		INFO_PRINTF1(_L("Getting mobile call"));
       
   744 		TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) );
       
   745 		if(error != KErrNone)
       
   746 			{
       
   747 			ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error);
       
   748 			SetBlockResult(EFail);
       
   749 			}
       
   750 		else
       
   751 			{
       
   752 			INFO_PRINTF1(_L("Holding call..."));
       
   753 			iMobileCall->Hold(iActiveCallback->iStatus);
       
   754 			iActiveCallback->Activate (aAsyncErrorIndex);
       
   755 			IncOutstanding();
       
   756 			}
       
   757 		}
       
   758 	INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdHold"));
       
   759 	}
       
   760 
       
   761 void CT_RMobileCallData::DoCmdResume(const TTEFFunction& aSection, const TInt aAsyncErrorIndex)
       
   762 	{
       
   763 	INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdResume"));
       
   764 
       
   765 	TInt callNameParameter;
       
   766 	if ( !GetIntFromConfig(aSection, KCallName, callNameParameter ))
       
   767 		{
       
   768 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
       
   769 		SetBlockResult(EFail);
       
   770 		}
       
   771 	else
       
   772 		{
       
   773 		INFO_PRINTF1(_L("Getting mobile call"));
       
   774 		TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) );
       
   775 		if(error != KErrNone)
       
   776 			{
       
   777 			ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error);
       
   778 			SetBlockResult(EFail);
       
   779 			}
       
   780 		else
       
   781 			{
       
   782 			INFO_PRINTF1(_L("Resuming call..."));
       
   783 			iMobileCall->Resume (iActiveCallback->iStatus);
       
   784 			iActiveCallback->Activate (aAsyncErrorIndex);
       
   785 			IncOutstanding ();
       
   786 			}
       
   787 		}
       
   788 	INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdResume"));
       
   789 	}
       
   790 
       
   791 void CT_RMobileCallData::DoCmdSwap(const TTEFFunction& aSection, const TInt aAsyncErrorIndex)
       
   792 	{
       
   793 	INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdSwap"));
       
   794 
       
   795 	TInt callNameParameter;
       
   796 	if ( !GetIntFromConfig(aSection, KCallName, callNameParameter ))
       
   797 		{
       
   798 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
       
   799 		SetBlockResult(EFail);
       
   800 		}
       
   801 	else
       
   802 		{
       
   803 		INFO_PRINTF1(_L("Getting mobile call"));
       
   804 		TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) );
       
   805 		if(error != KErrNone)
       
   806 			{
       
   807 			ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error);
       
   808 			SetBlockResult(EFail);
       
   809 			}
       
   810 		else
       
   811 			{
       
   812 			INFO_PRINTF1(_L("Swapping call..."));
       
   813 			iMobileCall->Swap(iActiveCallback->iStatus);
       
   814 			iActiveCallback->Activate(aAsyncErrorIndex);
       
   815 			IncOutstanding ();
       
   816 			}
       
   817 		}
       
   818 	INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdSwap"));
       
   819 	}
       
   820 
       
   821 void CT_RMobileCallData::DoCmdTransfer(const TTEFFunction& aSection, const TInt aAsyncErrorIndex)
       
   822 	{
       
   823 	INFO_PRINTF1(_L("*START*CT_RMobileCallData::DoCmdTransfer"));
       
   824 
       
   825 	TInt callNameParameter;
       
   826 	if ( !GetIntFromConfig(aSection, KCallName, callNameParameter ))
       
   827 		{
       
   828 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCallName);
       
   829 		SetBlockResult(EFail);
       
   830 		}
       
   831 	else
       
   832 		{
       
   833 		INFO_PRINTF1(_L("Getting mobile call"));
       
   834 		TRAPD( error, iMobileCall = GetMobileCallL(callNameParameter) );
       
   835 		if(error != KErrNone)
       
   836 			{
       
   837 			ERR_PRINTF2(_L("GetMobileCallL left when trying to obtain the MobileCall with error %d"), error);
       
   838 			SetBlockResult(EFail);
       
   839 			}
       
   840 		else
       
   841 			{
       
   842 			INFO_PRINTF1(_L("Transferring call..."));
       
   843 			iMobileCall->Transfer(iActiveCallback->iStatus);
       
   844 			iActiveCallback->Activate(aAsyncErrorIndex);
       
   845 			IncOutstanding ();
       
   846 			}
       
   847 		}
       
   848 	INFO_PRINTF1(_L("*END*CT_RMobileCallData::DoCmdTransfer"));
       
   849 	}
       
   850 
       
   851 RMobileCall* CT_RMobileCallData::GetMobileCallL(TInt aCall)
       
   852 	{
       
   853 	INFO_PRINTF1(_L("*START* CT_RMobileCallData::GetMobileCallL"));
       
   854 	
       
   855 	INFO_PRINTF2(_L("Get RMobileCall: %d"), aCall);
       
   856 
       
   857 	// Check that over/under flow does not occur
       
   858 	if ( aCall < 0 || aCall >= iMobileCalls.Count ())
       
   859 		{
       
   860 		INFO_PRINTF2(_L("There is no such call as (%d)"), aCall);
       
   861 		User::Leave (KErrArgument);
       
   862 		}
       
   863 	INFO_PRINTF1(_L("*END* CT_RMobileCallData::GetMobileCallL"));
       
   864 	return iMobileCalls[aCall];
       
   865 	}
       
   866 
       
   867 
       
   868 void CT_RMobileCallData::DoCmdUtilityCheckCapability(const TTEFFunction& aSection)
       
   869     {
       
   870     INFO_PRINTF1(_L("*START* CT_RMobileCallData::DoCmdUtilityCheckCapability"));
       
   871 
       
   872     TPtrC capability;
       
   873 	if ( !GetStringFromConfig( aSection, KCapabilities, capability ))
       
   874 		{
       
   875 		ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCapabilities);
       
   876 		SetBlockResult(EFail);
       
   877 		}
       
   878 	else
       
   879 		{
       
   880 	    if (!(iCallCaps.iFlags))
       
   881 	        {
       
   882 	        ERR_PRINTF1(_L("Call capabilities are not supported."));
       
   883 	        SetBlockResult(EFail);
       
   884 	        }
       
   885 	    else
       
   886 	        {
       
   887 	        if (capability == KCapsVoiceCall)
       
   888 	            {
       
   889 	            INFO_PRINTF1(_L("Checking if Call has no voice call capabilities."));
       
   890 	            if (!(RMobileCall::KCapsVoice))
       
   891 	                {
       
   892 	                SetBlockResult(EFail);
       
   893 	                }
       
   894 	            }
       
   895 	        else if (capability == KCapsHold)
       
   896 	            {
       
   897 	            INFO_PRINTF1(_L("Checking if Call has no hold capabilities."));
       
   898 	            if (!(RMobileCall::KCapsHold))
       
   899 	                {
       
   900 	                SetBlockResult(EFail);
       
   901 	                }
       
   902 	            }
       
   903 	        else if (capability == KCapsResume)
       
   904 	            {
       
   905 	            INFO_PRINTF1(_L("Checking if Call has no resume capabilities."));
       
   906 	            if (!(RMobileCall::KCapsResume))
       
   907 	                {
       
   908 	                SetBlockResult(EFail);
       
   909 	                }
       
   910 	            }
       
   911 	        else if (capability == KCapsSwap)
       
   912 	            {
       
   913 	            INFO_PRINTF1(_L("Checking if Call has no swap capabilities."));
       
   914 	            if (!(RMobileCall::KCapsSwap))
       
   915 	                {
       
   916 	                SetBlockResult(EFail);
       
   917 	                }
       
   918 	            }
       
   919 	        else if (capability == KCapsDeflect)
       
   920 	            {
       
   921 	            INFO_PRINTF1(_L("Checking if Call has no deflect capabilities."));
       
   922 	            if (!(RMobileCall::KCapsDeflect))
       
   923 	                {
       
   924 	                SetBlockResult(EFail);
       
   925 	                }
       
   926 	            }
       
   927 	        else if (capability == KCapsTransfer)
       
   928 	            {
       
   929 	            INFO_PRINTF1(_L("Checking if Call has no transfer capabilities."));
       
   930 	            if (!(RMobileCall::KCapsTransfer))
       
   931 	                {
       
   932 	                SetBlockResult(EFail);
       
   933 	                }
       
   934 	            }
       
   935 	        else if (capability == KCapsJoin)
       
   936 	            {
       
   937 	            INFO_PRINTF1(_L("Checking if Call has no join (conference) capabilities."));
       
   938 	            if (!(RMobileCall::KCapsJoin))
       
   939 	                {
       
   940 	                SetBlockResult(EFail);
       
   941 	                }
       
   942 	            }
       
   943 	        else if (capability == KCapsOneToOne)
       
   944 	            {
       
   945 	            INFO_PRINTF1(_L("Checking if Call has no OneToOne (conference) capabilities."));
       
   946 	            if (!(RMobileCall::KCapsOneToOne))
       
   947 	                {
       
   948 	                SetBlockResult(EFail);
       
   949 	                }
       
   950 	            }
       
   951 	        else
       
   952 	        	{
       
   953 	        	ERR_PRINTF1(_L("Unknown capability."));
       
   954 	        	SetBlockResult(EFail);
       
   955 	        	}
       
   956 	        }
       
   957         }
       
   958 	INFO_PRINTF1(_L("*END* CT_RMobileCallData::DoCmdUtilityCheckCapability"));
       
   959     }
       
   960