cbsref/telephonyrefplugins/atltsy/atcommand/callcontrol/src/atanswer.cpp
branchRCL_3
changeset 20 07a122eea281
parent 19 630d2f34d719
child 21 4814c5a49428
equal deleted inserted replaced
19:630d2f34d719 20:07a122eea281
     1 // Copyright (c) 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 // @file atanswer.cpp
       
    15 // This contains CATAnswer which answering incomging call.
       
    16 // 
       
    17 
       
    18 //system include
       
    19 
       
    20 //user include
       
    21 #include "atanswer.h"
       
    22 #include "ltsycallinformationmanager.h"
       
    23 #include "mslogger.h"
       
    24 
       
    25 //const define
       
    26 const TInt KLtsyAnswerReadTimeOut = 20;
       
    27 _LIT8(KLtsyAnswerCallCommand, "ATA\r");
       
    28 
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // CATAnswer::NewL
       
    32 // other items were commented in a header
       
    33 // ---------------------------------------------------------------------------
       
    34 CATAnswer* CATAnswer::NewL(CGlobalPhonemanager& aGloblePhone,
       
    35 						   CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    36 	{
       
    37 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATAnswer::NewL()"));
       
    38 	
       
    39 	CATAnswer* self = CATAnswer::NewLC(aGloblePhone, aCtsyDispatcherCallback);
       
    40 	CleanupStack::Pop(self);
       
    41 	return self;
       
    42 	}
       
    43 
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // CATAnswer::NewLC
       
    47 // other items were commented in a header
       
    48 // ---------------------------------------------------------------------------
       
    49 CATAnswer* CATAnswer::NewLC(CGlobalPhonemanager& aGloblePhone,
       
    50 						    CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    51 	{
       
    52 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATAnswer::NewLC()"));
       
    53 	
       
    54 	CATAnswer* self = new (ELeave) CATAnswer(aGloblePhone, aCtsyDispatcherCallback);
       
    55 	CleanupStack::PushL(self);
       
    56 	self->ConstructL();
       
    57 	return self;
       
    58 	}
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CATAnswer::~CATAnswer
       
    62 // other items were commented in a header
       
    63 // ---------------------------------------------------------------------------
       
    64 CATAnswer::~CATAnswer()
       
    65 	{
       
    66 	}
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // CATAnswer::SetAnswerCallId
       
    70 // other items were commented in a header
       
    71 // ---------------------------------------------------------------------------
       
    72 void CATAnswer::SetAnswerCallId(TInt aCallId)
       
    73 	{
       
    74 	iCallId = aCallId;
       
    75 	}
       
    76 
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CATAnswer::SetIsIsvCall
       
    80 // other items were commented in a header
       
    81 // ---------------------------------------------------------------------------
       
    82 void CATAnswer::SetIsIsvCall(TBool aIsIsvCall)
       
    83 	{
       
    84 	iIsIsvCall = aIsIsvCall;
       
    85 	}
       
    86 
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CATAnswer::SetIsIsvCall
       
    90 // other items were commented in a header
       
    91 // ---------------------------------------------------------------------------
       
    92 CATAnswer::CATAnswer(CGlobalPhonemanager& aGloblePhone,
       
    93 		             CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    94 					 :CAtCommandBase(aGloblePhone, aCtsyDispatcherCallback)
       
    95 	{
       
    96 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATAnswer::CATAnswer()"));
       
    97 	
       
    98 	iIOStatus = KErrNone;
       
    99 	iATResult = KErrNone;
       
   100 	iAnswerStep = EATNotInProgress;
       
   101 	}
       
   102 
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CATAnswer::ConstructL
       
   106 // other items were commented in a header
       
   107 // ---------------------------------------------------------------------------
       
   108 void CATAnswer::ConstructL()
       
   109 	{
       
   110 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATAnswer::ConstructL()"));
       
   111 	
       
   112 	CAtCommandBase::ConstructL();
       
   113 	AddExpectStringL(KLtsyNoCarrierString);
       
   114 	
       
   115 	//Set read and write timeout
       
   116 	SetTimeOut(KLtsyDefaultWriteTimeOut, KLtsyAnswerReadTimeOut);	
       
   117 	}
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // CATAnswer::ExecuteCommand
       
   121 // other items were commented in a header
       
   122 // ---------------------------------------------------------------------------
       
   123 void CATAnswer::ExecuteCommand()
       
   124 	{
       
   125 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATAnswer::ExecuteCommand()"));
       
   126 	
       
   127 	//Write AT command
       
   128 	iTxBuffer.Copy(KLtsyAnswerCallCommand);
       
   129 	Write();
       
   130 	iAnswerStep = EATWaitForWriteComplete;
       
   131 	}
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // CATAnswer::StartRequest
       
   135 // other items were commented in a header
       
   136 // ---------------------------------------------------------------------------
       
   137 void CATAnswer::StartRequest()
       
   138 	{
       
   139 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATAnswer::StartRequest()"));
       
   140 	
       
   141 	ExecuteCommand();
       
   142 	}
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // CATAnswer::ParseResponseL
       
   146 // other items were commented in a header
       
   147 // ---------------------------------------------------------------------------
       
   148 void CATAnswer::ParseResponseL(const TDesC8& aResponseBuf)
       
   149 	{
       
   150 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATAnswer::ParseResponseL()"));
       
   151 	
       
   152 	if (aResponseBuf.Match(KLtsyOkString) == 0)
       
   153 		{
       
   154 		iATResult = KErrNone;
       
   155 		}
       
   156 	else if (aResponseBuf.Match(KLtsyErrorString) == 0)
       
   157 		{
       
   158 		iATResult = KErrArgument;
       
   159 		}
       
   160 	else if (aResponseBuf.Match(KLtsyNoCarrierString) == 0)
       
   161 		{
       
   162 		iATResult = KErrEtelNoCarrier;
       
   163 		}
       
   164 	}
       
   165 
       
   166 // ---------------------------------------------------------------------------
       
   167 // CATAnswer::HandleIOError
       
   168 // other items were commented in a header
       
   169 // ---------------------------------------------------------------------------
       
   170 void CATAnswer::HandleIOError()
       
   171 	{
       
   172 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATAnswer::HandleIOError()"));
       
   173 	
       
   174 	//Call back
       
   175 	iCtsyDispatcherCallback.CallbackCallControlAnswerComp(iIOStatus, iCallId);
       
   176 	}
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // CATAnswer::HandleResponseError
       
   180 // other items were commented in a header
       
   181 // ---------------------------------------------------------------------------
       
   182 void CATAnswer::HandleResponseError()
       
   183 	{
       
   184 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATAnswer::HandleResponseError()"));
       
   185 	
       
   186 	//Call back
       
   187 	iCtsyDispatcherCallback.CallbackCallControlAnswerComp(iATResult, iCallId);
       
   188 	}
       
   189 
       
   190 // ---------------------------------------------------------------------------
       
   191 // CATAnswer::HandleConnectedComplete
       
   192 // other items were commented in a header
       
   193 // ---------------------------------------------------------------------------
       
   194 void CATAnswer::HandleConnectedComplete()
       
   195 	{
       
   196 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATAnswer::HandleConnectedComplete()"));
       
   197 
       
   198 	//Setting call states
       
   199 	iCtsyDispatcherCallback.CallbackCallControlNotifyCallStatusChangeInd(KErrNone, 
       
   200 			                                                             iCallId, 
       
   201 			                                                             RMobileCall::EStatusAnswering);	
       
   202 		
       
   203 	iCtsyDispatcherCallback.CallbackCallControlNotifyCallStatusChangeInd(KErrNone, 
       
   204 			                                                             iCallId, 
       
   205 			                                                             RMobileCall::EStatusConnected);
       
   206 			                                                             
       
   207     //Call back
       
   208 	iCtsyDispatcherCallback.CallbackCallControlAnswerComp(KErrNone, iCallId);
       
   209 				                                                             						
       
   210 	//Change Call State to active
       
   211 	TLtsyCallInformation& tCallInfo(iPhoneGlobals.GetCallInfoManager().GetCallInformationByCallId(iCallId));
       
   212 	if (tCallInfo.GetCallIdIsUsedInfo() == TLtsyCallInformation::EUsed)
       
   213 		{
       
   214 		tCallInfo.SetCallState(TLtsyCallInformation::EActiveCall);
       
   215 		}
       
   216 	
       
   217 	//If exist other call , should set hold
       
   218 	for (TInt n = KLtsyMinCallId; n <= KLtsyMaxCallId; n++)
       
   219 		{
       
   220 		if (n != iCallId)
       
   221 			{
       
   222 			TLtsyCallInformation& tCallInfo(iPhoneGlobals.GetCallInfoManager().GetCallInformationByCallId(n));
       
   223 			if (tCallInfo.GetCallIdIsUsedInfo() == TLtsyCallInformation::EUsed &&
       
   224 				tCallInfo.GetCallState() != TLtsyCallInformation::EHeldCall )
       
   225 				{
       
   226 				tCallInfo.SetCallState(TLtsyCallInformation::EHeldCall);
       
   227 				
       
   228 				//Notify CTSY call state has changed
       
   229 				iCtsyDispatcherCallback.CallbackCallControlNotifyCallStatusChangeInd(KErrNone, 
       
   230 						                                                             n, 
       
   231 						                                                 RMobileCall::EStatusHold);				
       
   232 				}
       
   233 			}
       
   234 		}
       
   235 	}
       
   236 
       
   237 // ---------------------------------------------------------------------------
       
   238 // CATAnswer::Complete
       
   239 // other items were commented in a header
       
   240 // ---------------------------------------------------------------------------
       
   241 void CATAnswer::Complete()
       
   242 	{
       
   243 	//Invoke base class complete
       
   244 	CAtCommandBase::Complete();
       
   245 	
       
   246 	//Let other command can use I/O port
       
   247 	iPhoneGlobals.iEventSignalActive = EFalse;	
       
   248 	}
       
   249 
       
   250 // ---------------------------------------------------------------------------
       
   251 // CATAnswer::EventSignal
       
   252 // other items were commented in a header
       
   253 // ---------------------------------------------------------------------------
       
   254 void CATAnswer::EventSignal(TAtEventSource /*aEventSource*/, TInt aStatus)
       
   255 	{  
       
   256 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATAnswer::EventSignal()"));
       
   257 	LOGTEXT2(_L8("[Ltsy CallControl] aStatus = %d"),aStatus);
       
   258 	
       
   259 	iIOStatus = aStatus;
       
   260 	
       
   261 	//I/O error
       
   262 	if (iIOStatus != KErrNone)
       
   263 		{
       
   264 		HandleIOError();
       
   265 		Complete();
       
   266 		return;
       
   267 		}
       
   268 	
       
   269 	switch (iAnswerStep)
       
   270 		{
       
   271 		case EATWaitForWriteComplete:
       
   272 			iAnswerStep = EATReadComplete;
       
   273 			break;
       
   274 			
       
   275 		case EATReadComplete:
       
   276 			if (iATResult == KErrNone)
       
   277 				{
       
   278 				HandleConnectedComplete();
       
   279 				}
       
   280 			else
       
   281 				{
       
   282 				HandleResponseError();
       
   283 				}
       
   284 			Complete();
       
   285 			break;
       
   286 			
       
   287 		default:
       
   288 			break;
       
   289 		}
       
   290 	}
       
   291 
       
   292 //End of file