telephonyserverplugins/multimodetsy/hayes/ATANSWER.CPP
changeset 0 3553901f7fa8
child 19 630d2f34d719
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "ATANSWER.H"
       
    17 #include "mSLOGGER.H"
       
    18 #include "PHONE.H"
       
    19 #include "LINE.H"
       
    20 #include "CALL.H"
       
    21 #include "ATNOCARR.H"
       
    22 #include "NOTIFY.H"
       
    23 #include "ATIO.H"
       
    24 
       
    25 const TInt KWaitForVoiceConnect=4000; 
       
    26 const TInt KWaitForTickleVoiceConnect=3000;
       
    27 _LIT8(KTickle,"AT+\r");		// To ensure off-line mode.
       
    28 
       
    29 //
       
    30 // CATAnswerVoice
       
    31 //
       
    32 CATAnswerVoice* CATAnswerVoice::NewL(CATIO* aIo, CTelObject* aTelObject,CATInit* aInit,CPhoneGlobals* aPhoneGlobals)	
       
    33 	{
       
    34 	CATAnswerVoice* answer=new(ELeave) CATAnswerVoice(aIo, aTelObject, aInit,aPhoneGlobals);
       
    35 	CleanupStack::PushL(answer);
       
    36 	answer->ConstructL();
       
    37 	CleanupStack::Pop();
       
    38 	return answer;
       
    39 	}
       
    40 
       
    41 CATAnswerVoice::CATAnswerVoice(CATIO* aIo, CTelObject* aTelObject,CATInit* aInit,CPhoneGlobals* aPhoneGlobals)
       
    42 											: CATVoiceCallConnectCommands(aIo,aTelObject,aInit,aPhoneGlobals)
       
    43 	{}
       
    44 
       
    45 CATAnswerVoice::~CATAnswerVoice()
       
    46 	{}
       
    47 
       
    48 void CATAnswerVoice::Start(TTsyReqHandle aTsyReqHandle, TAny* aParams)
       
    49 	{
       
    50 	LOGTEXT(_L8("Starting ATA Answer Voice Command"));
       
    51 	LOGTEXT2(_L8("Comm signals : %x"),iIo->Signals());
       
    52 	iState=EATInitialising;
       
    53 	CATVoiceCallConnectCommands::Start(aTsyReqHandle,aParams);
       
    54 	}
       
    55 
       
    56 void CATAnswerVoice::Stop(TTsyReqHandle aTsyReqHandle)
       
    57 //
       
    58 //	Attempts to halt the answering process by sending a carriage return.
       
    59 //
       
    60 	{
       
    61 	__ASSERT_ALWAYS(aTsyReqHandle == iReqHandle,Panic(EIllegalTsyReqHandle));		
       
    62 	__ASSERT_ALWAYS(iState!=EATNotInProgress,Panic(EATCommand_NotInProgress));		
       
    63 	LOGTEXT(_L8("Cancelling Answer Voice Command"));
       
    64 	iIo->WriteAndTimerCancel(this);
       
    65 	if (iState!=EATInitialising) // the ATA has been sent
       
    66 		{
       
    67 		Write(KCarriageReturn(),1);
       
    68 		iPreConnectState=CATCallConnectCommands::ENotInProgress;	
       
    69 		iState = EATCancellingWaitForWriteComplete;
       
    70 		}
       
    71 	else	// the pre-ATA sequence is still in progress
       
    72 		{
       
    73 		AddStdExpectStrings();
       
    74 		iPreConnectState=CATCallConnectCommands::ECancelling;
       
    75 		iState = EATNotInProgress;
       
    76 		}
       
    77 	}
       
    78 
       
    79 void CATAnswerVoice::CompleteWithIOError(TEventSource aSource,TInt aStatus)
       
    80 	{
       
    81 	if (iState!=EATNotInProgress)
       
    82 		{
       
    83 		iState = EATNotInProgress;
       
    84 		CATCallConnectCommands::CompleteWithIOError(aSource,aStatus);
       
    85 		}
       
    86 	}
       
    87 
       
    88 void CATAnswerVoice::EventSignal(TEventSource aSource)
       
    89 	{
       
    90 	// handle bug in Nokia 8210 which does not respond OK when answering
       
    91 	// incoming voice calls
       
    92 	// assume timeout here means that the call has connected
       
    93  	if((aSource==ETimeOutCompletion)
       
    94 		&&(iState!=EATCancellingReadCompleted)&&(iState!=EATNotInProgress)
       
    95 		&&(iPreConnectState!=EATWaitForATCheckOK))
       
    96 		{
       
    97 		LOGTEXT(_L8("Timeout Error during Answer"));
       
    98 		iState = EATNotInProgress;
       
    99 		Complete(KErrTimedOut,aSource);
       
   100 		return;
       
   101 		}
       
   102 	
       
   103 	if (iPreConnectState!=CATCallConnectCommands::EATInitCompleted
       
   104 		&& iPreConnectState!=CATCallConnectCommands::ENotInProgress)
       
   105 		{
       
   106 		CATCallConnectCommands::PreConnectEventSignal(aSource);
       
   107 		if (iPreConnectState==CATCallConnectCommands::ENotInProgress)	// cancelled
       
   108 			iState=EATNotInProgress;
       
   109 		if (iPreConnectState!=CATCallConnectCommands::EATInitCompleted)
       
   110 			return;
       
   111 		else
       
   112 			iState=EATSendAnswerCommand;
       
   113 		}
       
   114 
       
   115 	switch(iState)
       
   116 		{
       
   117 	case EATSendAnswerCommand:
       
   118 		{
       
   119 		ChangeLineStatus(RCall::EStatusAnswering);
       
   120 		// EStatusAnswering results in KErrNone return;
       
   121 		(void)ChangeCallStatus(RMobileCall::EStatusAnswering);
       
   122 		iPhoneGlobals->iNotificationStore->CheckNotification(REINTERPRET_CAST(CCallBase*,iTelObject),EBegunConnecting);
       
   123 		TPtrC8 answerCommand(KAnswerCommand);
       
   124 		WriteExpectingResults(answerCommand,3);
       
   125 		iState=EATAnswerWaitForWriteComplete;
       
   126 		break;
       
   127 		}
       
   128 
       
   129 	case EATAnswerWaitForWriteComplete:
       
   130 		{
       
   131 		__ASSERT_ALWAYS(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
       
   132 		LOGTEXT2(_L8("Comm signals : %x"),iIo->Signals());
       
   133 		CPhoneHayes* phone=STATIC_CAST(CPhoneHayes*,iTelObject->Owner()->Owner());
       
   134 		phone->StopRingCounter();	// RING should no longer come in		
       
   135 		AddStdExpectStrings();
       
   136 		iIo->SetTimeOut(this,KWaitForVoiceConnect);		// Wait for Answer
       
   137 		iState=EATAnswerReadCompleted;
       
   138 		}
       
   139 		break;
       
   140 
       
   141 	case EATAnswerReadCompleted:
       
   142 			{
       
   143 			if (aSource==ETimeOutCompletion)
       
   144 				{
       
   145 				Complete(KErrNone,EReadCompletion); 
       
   146 				return;
       
   147 				}
       
   148 			__ASSERT_ALWAYS(aSource==EReadCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
       
   149 			TInt ret(ValidateExpectString());
       
   150 			if (ret)
       
   151 				{
       
   152 				Complete(ret,aSource);
       
   153 				break;
       
   154 				}
       
   155 			iIo->WriteAndTimerCancel(this);
       
   156 			// handle bug in Ericsson SH888 which does not report "NO CARRIER" when the
       
   157 			// call is dropped unless the modem is prodded following the ATA command
       
   158 			LOGTEXT(_L8("handle bug in Ericsson SH888 which does not report NO CARRIER when the"));
       
   159 			LOGTEXT(_L8("call is dropped unless the modem is prodded following the ATA command"));
       
   160 			iIo->Write(this,KTickle);
       
   161 			iIo->SetTimeOut(this);
       
   162 			iState=EATTickleWaitForWriteComplete;
       
   163 			}
       
   164 		break;
       
   165 
       
   166 		
       
   167 	case EATTickleWaitForWriteComplete:
       
   168 		{
       
   169 		__ASSERT_ALWAYS(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
       
   170 		iIo->SetTimeOut(this,KWaitForTickleVoiceConnect);
       
   171 		iState=EATTickleReadCompleted;
       
   172 		}
       
   173 		break;
       
   174 
       
   175 	case EATTickleReadCompleted:
       
   176 		__ASSERT_ALWAYS(aSource==EReadCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
       
   177 		RemoveStdExpectStrings();
       
   178 		Complete(KErrNone,aSource);
       
   179 		break;
       
   180 
       
   181 		
       
   182 	case EATCancellingWaitForWriteComplete:
       
   183 		__ASSERT_ALWAYS(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
       
   184 		AddCommonExpectStrings();
       
   185 		iIo->SetTimeOut(this);
       
   186 		iState=EATCancellingReadCompleted;
       
   187 		break;
       
   188 
       
   189 	case EATCancellingReadCompleted:
       
   190 			{
       
   191 			iState = EATNotInProgress; 
       
   192 			RemoveCommonExpectStrings();
       
   193 			if (aSource==EReadCompletion)
       
   194 				{
       
   195 				TInt ret(ValidateExpectString());
       
   196 				if (ret==KErrNone)
       
   197 					{
       
   198 					iIo->DropDtr();		// Has connected despite sending CR
       
   199 					iIo->SetTimeOut(this,KDTRLowPeriod);
       
   200 					iState=EDTRDropped;
       
   201 					return;
       
   202 					}
       
   203 				}
       
   204 			Complete(KErrCancel,aSource);
       
   205 			}
       
   206 		break;
       
   207 
       
   208 	case EDTRDropped:
       
   209 		__ASSERT_ALWAYS(aSource==ETimeOutCompletion,Panic(EATCommand_IllegalCompletionWaitExpected));
       
   210 		iIo->Cancel();
       
   211 		iIo->RaiseDTR();
       
   212 		iIo->Read();
       
   213 		iIo->SetTimeOut(this,KDTRHighSettle);
       
   214 		iState=EWaitForDTRRaiseSettle;
       
   215 		break;
       
   216 
       
   217 	case EWaitForDTRRaiseSettle:
       
   218 		{
       
   219 		__ASSERT_ALWAYS(aSource==ETimeOutCompletion,Panic(EATCommand_IllegalCompletionWaitExpected));
       
   220 		TPtrC8 hangUpCommand(KHangUpCommand);
       
   221 		Write(hangUpCommand,1);
       
   222 		iState=EATHangupWaitForWriteComplete;
       
   223 		}
       
   224 		break;
       
   225 
       
   226 	case EATHangupWaitForWriteComplete:
       
   227 		__ASSERT_ALWAYS(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
       
   228 		if (!iNoCarrierExpectString)
       
   229 			iNoCarrierExpectString=iIo->AddExpectString(this,KNoCarrierString);
       
   230 		StandardWriteCompletionHandler(aSource,2);
       
   231 		iState=EATHangupReadCompleted;
       
   232 		break;
       
   233 	
       
   234 	case EATHangupReadCompleted:
       
   235 		__ASSERT_ALWAYS(aSource!=EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteNotExpected));
       
   236 		Complete(KErrCancel,aSource);
       
   237 		break;
       
   238 
       
   239 	case EATInitialising:
       
   240 	case EATNotInProgress:
       
   241 	default:
       
   242 		;
       
   243 		}
       
   244 	}
       
   245 
       
   246 void CATAnswerVoice::Complete(TInt aError,TEventSource aSource)
       
   247 	{
       
   248 	CATVoiceCallConnectCommands::Complete(aError,aSource);
       
   249 	}
       
   250 
       
   251 
       
   252 
       
   253 //
       
   254 // CATAnswerData
       
   255 //
       
   256 CATAnswerData* CATAnswerData::NewL(CATIO* aIo, CTelObject* aTelObject,CATInit* aInit,CPhoneGlobals* aPhoneGlobals)	{
       
   257 	CATAnswerData* answer=new(ELeave) CATAnswerData(aIo, aTelObject, aInit,aPhoneGlobals);
       
   258 	CleanupStack::PushL(answer);
       
   259 	answer->ConstructL();
       
   260 	CleanupStack::Pop();
       
   261 	return answer;
       
   262 	}
       
   263 
       
   264 CATAnswerData::CATAnswerData(CATIO* aIo, CTelObject* aTelObject,CATInit* aInit,CPhoneGlobals* aPhoneGlobals)
       
   265 											: CATDataCallConnectCommands(aIo,aTelObject,aInit,aPhoneGlobals)
       
   266 	{}
       
   267 
       
   268 CATAnswerData::~CATAnswerData()
       
   269 	{}
       
   270 
       
   271 void CATAnswerData::Start(TTsyReqHandle aTsyReqHandle, TAny* aParams)
       
   272 	{
       
   273 	LOGTEXT(_L8("Starting ATA Answer Command"));
       
   274 	LOGTEXT2(_L8("Comm signals : %x"),iIo->Signals());
       
   275 	iState=EATInitialising;
       
   276 	CATDataCallConnectCommands::Start(aTsyReqHandle,aParams);
       
   277 	}
       
   278 
       
   279 void CATAnswerData::Stop(TTsyReqHandle aTsyReqHandle)
       
   280 //
       
   281 //	Attempts to halt the answering process by sending a carriage return.
       
   282 //
       
   283 	{
       
   284 	__ASSERT_ALWAYS(aTsyReqHandle == iReqHandle,Panic(EIllegalTsyReqHandle));		
       
   285 	__ASSERT_ALWAYS(iState!=EATNotInProgress,Panic(EATCommand_NotInProgress));		
       
   286 	LOGTEXT(_L8("Cancelling Answer Command"));
       
   287 	iIo->WriteAndTimerCancel(this);
       
   288 	if (iState!=EATInitialising) // the ATA has been sent
       
   289 		{
       
   290 		Write(KCarriageReturn(),1);
       
   291 		iPreConnectState=CATCallConnectCommands::ENotInProgress;	
       
   292 		iState = EATCancellingWaitForWriteComplete;
       
   293 		}
       
   294 	else	// the pre-ATA sequence is still in progress
       
   295 		{
       
   296 		AddStdExpectStrings();
       
   297 		iPreConnectState=CATCallConnectCommands::ECancelling;
       
   298 		iState = EATNotInProgress;
       
   299 		}
       
   300 	}
       
   301 
       
   302 TInt CATAnswerData::ValidateAnswerExpectString()
       
   303 	{
       
   304 	TInt ret(KErrUnknown);
       
   305 	if(iIo->FoundChatString()==iConnectExpectString)
       
   306 		ret=KErrNone;
       
   307 	else if(iIo->FoundChatString()==iNoCarrierExpectString)
       
   308 		ret=KErrEtelNoCarrier;
       
   309 	return ret;
       
   310 	}
       
   311 
       
   312 void CATAnswerData::CompleteWithIOError(TEventSource aSource,TInt aStatus)
       
   313 	{
       
   314 	if (iState!=EATNotInProgress)
       
   315 		{
       
   316 		iState = EATNotInProgress;
       
   317 		CATCallConnectCommands::CompleteWithIOError(aSource,aStatus);
       
   318 		}
       
   319 	}
       
   320 
       
   321 void CATAnswerData::EventSignal(TEventSource aSource)
       
   322 	{
       
   323 	if((aSource==ETimeOutCompletion)&&(iState!=EATSpeedReadCompleted)
       
   324 		&&(iState!=EATCancellingReadCompleted)&&(iState!=EATNotInProgress)
       
   325 		&&(iPreConnectState!=EATWaitForATCheckOK))
       
   326 		{
       
   327 		LOGTEXT(_L8("Timeout Error during Answer"));
       
   328 		iState = EATNotInProgress;
       
   329 		Complete(KErrTimedOut,aSource);
       
   330 		return;
       
   331 		}
       
   332 	
       
   333 	if (iPreConnectState!=CATCallConnectCommands::EATInitCompleted
       
   334 		&& iPreConnectState!=CATCallConnectCommands::ENotInProgress)
       
   335 		{
       
   336 		CATCallConnectCommands::PreConnectEventSignal(aSource);
       
   337 		if (iPreConnectState==CATCallConnectCommands::ENotInProgress)	// cancelled
       
   338 			iState=EATNotInProgress;
       
   339 		if (iPreConnectState!=CATCallConnectCommands::EATInitCompleted)
       
   340 			return;
       
   341 		else
       
   342 			iState=EATSendAnswerCommand;
       
   343 		}
       
   344 
       
   345 	switch(iState)
       
   346 		{
       
   347 	case EATSendAnswerCommand:
       
   348 		{
       
   349 		ChangeLineStatus(RCall::EStatusAnswering);
       
   350 		// Don't bother checking return value. Setting to EStatusAnswering always returns KErrNone
       
   351 		(void)ChangeCallStatus(RMobileCall::EStatusAnswering);
       
   352 		iPhoneGlobals->iNotificationStore->CheckNotification(REINTERPRET_CAST(CCallBase*,iTelObject),EBegunConnecting);
       
   353 		TPtrC8 answerCommand(KAnswerCommand);
       
   354 		WriteExpectingResults(answerCommand,3);
       
   355 		iState=EATAnswerWaitForWriteComplete;
       
   356 		break;
       
   357 		}
       
   358 
       
   359 	case EATAnswerWaitForWriteComplete:
       
   360 		{
       
   361 		__ASSERT_ALWAYS(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
       
   362 		LOGTEXT2(_L8("Comm signals : %x"),iIo->Signals());
       
   363 		CPhoneHayes* phone=STATIC_CAST(CPhoneHayes*,iTelObject->Owner()->Owner());
       
   364 		phone->StopRingCounter();			// RING should no longer come in		
       
   365 		TInt ret=AddCommonExpectStrings();
       
   366 		if (ret!=KErrNone)
       
   367 			{
       
   368 			Complete(ret,aSource);
       
   369 			break;
       
   370 			}
       
   371 		iIo->SetTimeOut(this,(iPhoneGlobals->iPhoneStatus.iWaitForCarrierTime*1000)+KExtraWaitTime);
       
   372 		iState=EATAnswerReadCompleted;
       
   373 		}
       
   374 		break;
       
   375 
       
   376 	case EATAnswerReadCompleted:
       
   377 			{
       
   378 			__ASSERT_ALWAYS(aSource==EReadCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
       
   379 			TInt ret=ValidateAnswerExpectString();
       
   380 			RemoveCommonExpectStrings();
       
   381 			if (ret!=KErrNone)
       
   382 				{
       
   383 				iState = EATNotInProgress;
       
   384 				Complete(ret,aSource);
       
   385 				break;
       
   386 				}
       
   387 			iIo->SetTimeOut(this,KTimeForExtraRxData);
       
   388 			iState=EATSpeedReadCompleted;
       
   389 			}
       
   390 		break;
       
   391 
       
   392 	case EATSpeedReadCompleted:
       
   393 			{
       
   394 			__ASSERT_ALWAYS(aSource==ETimeOutCompletion,Panic(EATCommand_IllegalCompletionWaitExpected));
       
   395 			TInt ret=ParseForBearerCapsResponse();
       
   396 			iState = EATNotInProgress;
       
   397 			if (ret!=KErrNone)
       
   398 				{
       
   399 				Complete(ret,aSource);
       
   400 				break;
       
   401 				}
       
   402 			ret=ParseForBearerSpeedResponse();
       
   403 			Complete(ret,aSource);
       
   404 			}
       
   405 		break;
       
   406 		
       
   407 	case EATCancellingWaitForWriteComplete:
       
   408 		{
       
   409 		__ASSERT_ALWAYS(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
       
   410 		TInt ret=AddCommonExpectStrings();
       
   411 		if (ret)
       
   412 			{
       
   413 			Complete(ret,aSource);
       
   414 			break;
       
   415 			}
       
   416 		iIo->SetTimeOut(this);
       
   417 		iState=EATCancellingReadCompleted;
       
   418 		break;
       
   419 		}
       
   420 
       
   421 	case EATCancellingReadCompleted:
       
   422 			{
       
   423 			iState = EATNotInProgress;
       
   424 			if (aSource==EReadCompletion)
       
   425 				{
       
   426 				TInt ret=ValidateAnswerExpectString();
       
   427 				RemoveCommonExpectStrings();
       
   428 				if (ret==KErrNone)
       
   429 					{
       
   430 					iIo->DropDtr();		// Has connected despite sending CR
       
   431 					iIo->SetTimeOut(this,KDTRLowPeriod);
       
   432 					iState=EDTRDropped;
       
   433 					return;
       
   434 					}
       
   435 				}
       
   436 			RemoveCommonExpectStrings();
       
   437 			Complete(KErrCancel,aSource);
       
   438 			}
       
   439 		break;
       
   440 
       
   441 	case EDTRDropped:
       
   442 		__ASSERT_ALWAYS(aSource==ETimeOutCompletion,Panic(EATCommand_IllegalCompletionWaitExpected));
       
   443 		iIo->Cancel();
       
   444 		iIo->RaiseDTR();
       
   445 		iIo->Read();
       
   446 		iIo->SetTimeOut(this,KDTRHighSettle);
       
   447 		iState=EWaitForDTRRaiseSettle;
       
   448 		break;
       
   449 
       
   450 	case EWaitForDTRRaiseSettle:
       
   451 		{
       
   452 		__ASSERT_ALWAYS(aSource==ETimeOutCompletion,Panic(EATCommand_IllegalCompletionWaitExpected));
       
   453 		TPtrC8 hangUpCommand(KHangUpCommand);
       
   454 		Write(hangUpCommand,1);
       
   455 		iState=EATHangupWaitForWriteComplete;
       
   456 		}
       
   457 		break;
       
   458 
       
   459 	case EATHangupWaitForWriteComplete:
       
   460 		__ASSERT_ALWAYS(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected));
       
   461 		if (!iNoCarrierExpectString)
       
   462 			iNoCarrierExpectString=iIo->AddExpectString(this,KNoCarrierString);
       
   463 		StandardWriteCompletionHandler(aSource,2);
       
   464 		iState=EATHangupReadCompleted;
       
   465 		break;
       
   466 	
       
   467 	case EATHangupReadCompleted:
       
   468 		__ASSERT_ALWAYS(aSource!=EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteNotExpected));
       
   469 		Complete(KErrCancel,aSource);	// if ret!=KErrNone, perhaps don't complete but carry on
       
   470 		break;
       
   471 
       
   472 	case EATInitialising:
       
   473 	case EATNotInProgress:
       
   474 	default:
       
   475 		;
       
   476 		}
       
   477 	}
       
   478 
       
   479 void CATAnswerData::Complete(TInt aError,TEventSource aSource)
       
   480 	{
       
   481 	CATDataCallConnectCommands::Complete(aError,aSource);
       
   482 	}
       
   483 
       
   484 //
       
   485 //	CATAnswerFax
       
   486 //
       
   487 
       
   488 CATAnswerFax* CATAnswerFax::NewL(CATIO* aIo, CTelObject* aTelObject,CATInit* aInit,CPhoneGlobals* aPhoneGlobals)
       
   489 	{
       
   490 	CATAnswerFax* answer=new(ELeave) CATAnswerFax(aIo, aTelObject, aInit,aPhoneGlobals);
       
   491 	CleanupStack::PushL(answer);
       
   492 	answer->ConstructL();
       
   493 	CleanupStack::Pop();
       
   494 	return answer;
       
   495 	}
       
   496 
       
   497 CATAnswerFax::CATAnswerFax(CATIO* aIo, CTelObject* aTelObject,CATInit* aInit,CPhoneGlobals* aPhoneGlobals)
       
   498 											: CATFaxCallConnectCommands(aIo,aTelObject,aInit,aPhoneGlobals)
       
   499 	{}
       
   500 
       
   501 CATAnswerFax::~CATAnswerFax()
       
   502 	{}
       
   503 
       
   504 void CATAnswerFax::Start(TTsyReqHandle aTsyReqHandle, TAny* /*aParams*/)
       
   505 	{
       
   506 	LOGTEXT(_L8("Starting Answer fax call"));
       
   507 //	CATFaxCallConnectCommands::Start(aTsyReqHandle,aParams);	
       
   508 
       
   509 	//-- the change made by Dmitry Lyokhin. PIA-586KGE defect fix
       
   510 	//-- CATFaxCallConnectCommands::Start(); starts answering a fax call from sending 
       
   511 	//-- init strings to the modem that occassionally causes a collision with incoming "+CRING".
       
   512 	//-- now state machine starts with EATCallInitCompleted state that does nothing.
       
   513 
       
   514 	iReqHandle=aTsyReqHandle;
       
   515 	__ASSERT_ALWAYS(iIo->AddExpectString(this,KNotifyMeIfErrorString) != NULL, Panic(EGeneral));
       
   516 	
       
   517 	iPreConnectState=CATCallConnectCommands::EATCallInitCompleted; 
       
   518 
       
   519 	LOGTEXT2(_L8("-CATAnswerFax::Start, iPreConnectState=%d"), iPreConnectState);
       
   520 
       
   521 	EventSignal(EReadCompletion);	// EReadCompletion is a dummy enum here
       
   522 	}
       
   523 
       
   524 void CATAnswerFax::Stop(TTsyReqHandle aTsyReqHandle)
       
   525 //
       
   526 //	If still doing pre-answer command, cancel that, otherwise tell the fax server to cancel
       
   527 //
       
   528 	{
       
   529 	LOGTEXT(_L8("Cancelling Answer Fax Call Command"));
       
   530 	CATFaxCallConnectCommands::Stop(aTsyReqHandle);
       
   531 	}
       
   532 
       
   533 void CATAnswerFax::EventSignal(TEventSource aSource)
       
   534 	{
       
   535 	if((aSource==ETimeOutCompletion)
       
   536 		&&(iPreConnectState!=EATWaitForATCheckOK))
       
   537 		{
       
   538 		LOGTEXT(_L8("Timeout Error during Answer"));
       
   539 		Complete(KErrTimedOut,aSource);
       
   540 		return;
       
   541 		}
       
   542 	if (iPreConnectState!=CATCallConnectCommands::EATInitCompleted
       
   543 		&& iPreConnectState!=CATCallConnectCommands::ENotInProgress)
       
   544 		{
       
   545 		CATCallConnectCommands::PreConnectEventSignal(aSource);
       
   546 		}
       
   547 	}
       
   548 
       
   549 void CATAnswerFax::CompleteSuccessfully()
       
   550 	{
       
   551 	REINTERPRET_CAST(CCallMobileFax*,iTelObject)->FaxAnswer(iReqHandle);	
       
   552 	}