cbsref/telephonyrefplugins/atltsy/atcommand/callcontrol/src/atwaitforcallhandler.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 // Wait for 2nd incoming call
       
    15 
       
    16 //system include
       
    17 
       
    18 //user include
       
    19 #include "atwaitforcallhandler.h"
       
    20 #include "atclcc.h"
       
    21 #include "atring.h"
       
    22 #include "atmanager.h"
       
    23 #include "activecommandstore.h"
       
    24 #include "ltsycallinformationmanager.h"
       
    25 #include "mslogger.h"
       
    26 
       
    27 CATWaitForCallHandler* CATWaitForCallHandler::NewL(CGlobalPhonemanager& aGloblePhone,
       
    28 		                                           CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    29 	{
       
    30 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATWaitForCallHandler::NewL()"));
       
    31 	
       
    32 	CATWaitForCallHandler* self = CATWaitForCallHandler::NewLC(aGloblePhone, aCtsyDispatcherCallback);
       
    33 	CleanupStack::Pop(self);
       
    34 	return self;
       
    35 	}
       
    36 
       
    37 CATWaitForCallHandler* CATWaitForCallHandler::NewLC(CGlobalPhonemanager& aGloblePhone,
       
    38 		                                            CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    39 	{
       
    40 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATWaitForCallHandler::NewLC()"));
       
    41 	
       
    42 	CATWaitForCallHandler* self = new (ELeave) CATWaitForCallHandler(aGloblePhone, aCtsyDispatcherCallback);
       
    43 	CleanupStack::PushL(self);
       
    44 	self->ConstructL();
       
    45 	return self;
       
    46 	}
       
    47 
       
    48 CATWaitForCallHandler::~CATWaitForCallHandler()
       
    49 	{
       
    50 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATWaitForCallHandler::~CATWaitForCallHandler()"));
       
    51 	
       
    52 	delete iAtRing;
       
    53 	iAtRing = NULL;
       
    54 	
       
    55 	delete iAtClcc;
       
    56 	iAtClcc = NULL;
       
    57 	}
       
    58 
       
    59 
       
    60 CATWaitForCallHandler::CATWaitForCallHandler(CGlobalPhonemanager& aGloblePhone,
       
    61 		                                     CCtsyDispatcherCallback& aCtsyDispatcherCallback)
       
    62 											 :CATCommandControlBase(aGloblePhone, aCtsyDispatcherCallback) 
       
    63 	{
       
    64 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATWaitForCallHandler::CATWaitForCallHandler()"));
       
    65 	
       
    66 	iPhoneGlobals.GetCallInfoManager().SetIncomingCallFlag(EFalse);
       
    67 	}
       
    68 
       
    69 void CATWaitForCallHandler::ConstructL()
       
    70 	{
       
    71 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATWaitForCallHandler::ConstructL()"));
       
    72 	
       
    73 	iAtClcc = CATClcc::NewL(iPhoneGlobals, iCtsyDispatcherCallback);
       
    74 	iAtRing = CATRing::NewL(iPhoneGlobals, iCtsyDispatcherCallback);
       
    75 	iAtRing->SetAtCommandObserver(this);
       
    76 	}
       
    77 
       
    78 
       
    79 void CATWaitForCallHandler::StartToWaitForCall()
       
    80 	{
       
    81 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATWaitForCallHandler::StartToWaitForCall()"));
       
    82 	
       
    83 	iPhoneGlobals.iAtManager->GetActiveCommandStore()->AddUnsolicitedAtCommand(iAtRing);
       
    84 	}
       
    85 
       
    86 TInt CATWaitForCallHandler::ProcessIncomingCallInfomation()
       
    87 	{
       
    88 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATWaitForCallHandler::ProcessIncomingCallInfomation()"));
       
    89 	
       
    90 	TInt nCallId = iPhoneGlobals.GetCallInfoManager().FindIncomingCallId();
       
    91 	
       
    92 	if (KErrNotFound == nCallId)
       
    93 		{
       
    94 		return KErrNotFound;
       
    95 		}
       
    96 	
       
    97 	//Incoming call information
       
    98 	TLtsyCallInformation& tIncomingCallInfo(iPhoneGlobals.GetCallInfoManager().GetCallInformationByCallId(nCallId));
       
    99 	
       
   100 	RMobileCall::TMobileCallInfoV1 tMobileCallInfo;
       
   101 	
       
   102 	//Call id
       
   103 	tMobileCallInfo.iCallId = tIncomingCallInfo.GetCallId();
       
   104 	
       
   105 	//Call service
       
   106 	TLtsyCallInformation::TCallMode tCallService(tIncomingCallInfo.GetCallMode());
       
   107 	if (TLtsyCallInformation::EVoiceCall == tCallService)
       
   108 		{
       
   109 		tMobileCallInfo.iService = RMobilePhone::EVoiceService;
       
   110 		}
       
   111 	else if (TLtsyCallInformation::EDataCall == tCallService)
       
   112 		{
       
   113 		tMobileCallInfo.iService = RMobilePhone::ECircuitDataService;
       
   114 		}
       
   115 	else if (TLtsyCallInformation::EFaxCall == tCallService)
       
   116 		{
       
   117 		tMobileCallInfo.iService = RMobilePhone::EFaxService;
       
   118 		}
       
   119 	else
       
   120 		{
       
   121 		tMobileCallInfo.iService = RMobilePhone::EServiceUnspecified;
       
   122 		}
       
   123 		
       
   124 	//Call back
       
   125 	iCtsyDispatcherCallback.CallbackCallControlNotifyIncomingCallInd(KErrNone, tMobileCallInfo);
       
   126 	
       
   127 	//Ring State
       
   128 	tMobileCallInfo.iStatus = RMobileCall::EStatusRinging;
       
   129 	
       
   130 	//Telephone number
       
   131 	tMobileCallInfo.iRemoteParty.iRemoteNumber.iTelNumber.Copy(tIncomingCallInfo.GetMobileTelNum());
       
   132 	
       
   133 	iCtsyDispatcherCallback.CallbackCallControlNotifyCallInfoChangeInd(KErrNone, tMobileCallInfo);
       
   134 	
       
   135 	return KErrNone;
       
   136 	}
       
   137 
       
   138 void CATWaitForCallHandler::AtCommandExecuteComplete(TAtEventSource /*aEventSource*/, TInt aStatus)
       
   139 	{
       
   140 	LOGTEXT(_L8("[Ltsy CallControl] Starting CATWaitForCallHandler::AtCommandExecuteComplete()"));
       
   141 	LOGTEXT2(_L8("[Ltsy CallControl] aEventSource = %d\taStatus = %d"),aStatus);
       
   142 		
       
   143 	//Process read or timeout error
       
   144 	if (aStatus != KErrNone)
       
   145 		{
       
   146 		//Reset Ring Count
       
   147 		iPhoneGlobals.GetCallInfoManager().SetIncomingCallFlag(EFalse);
       
   148 		
       
   149 		//Init ATCLCC Variable
       
   150 		iAtClcc->InitVariable();
       
   151 		
       
   152 		//Init InComing Call State
       
   153 		TInt nCall = iPhoneGlobals.GetCallInfoManager().FindIncomingCallId();
       
   154 		if (nCall != KErrNotFound)
       
   155 			{
       
   156 			iPhoneGlobals.GetCallInfoManager().ResetCallInformationByCallId(nCall);
       
   157 			}
       
   158 		return;
       
   159 		}
       
   160 	
       
   161 	//Clear Ring String
       
   162 	iAtRing->ClearCurrentLine();
       
   163 	
       
   164 	//CLCC find incoming information If first ring  coming
       
   165 	if (!iPhoneGlobals.GetCallInfoManager().GetIncomingCallFlag())
       
   166 		{
       
   167 		TInt nRet = iPhoneGlobals.CheckGlobalPhoneStatus();
       
   168 		if (nRet == KErrNone)
       
   169 			{
       
   170 			iPhoneGlobals.iEventSignalActive = ETrue;
       
   171 			iPhoneGlobals.GetCallInfoManager().SetIncomingCallFlag(ETrue);
       
   172 			iAtClcc->StartRequest();			
       
   173 			}
       
   174 		}	
       
   175 	
       
   176 	//Find At Clcc OK
       
   177 	if (iAtClcc->GetProcessStates() == CATClcc::EProcessOK)
       
   178 		{
       
   179 		TInt nRes = ProcessIncomingCallInfomation();
       
   180 		iAtClcc->InitVariable();
       
   181 		}	
       
   182 	
       
   183 	//Process AT CLCC error
       
   184 	if (iAtClcc->GetProcessStates() == CATClcc::EProcessError )
       
   185 		{
       
   186 		iAtClcc->InitVariable();
       
   187 		}
       
   188 	}
       
   189 
       
   190 //End of file