telephonyprotocols/csdagt/src/ND_ETEL.CPP
changeset 0 3553901f7fa8
child 19 630d2f34d719
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2003-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 // ETel Processor
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file Nd_etel.cpp
       
    20 */
       
    21 
       
    22 #include "ND_DBACC.H"
       
    23 #include "ND_STD.H"
       
    24 #include "ND_ETEL.H"
       
    25 #include "SLOGGER.H"
       
    26 
       
    27 /**
       
    28 @internalComponent
       
    29 */
       
    30 _LIT(KDoubleColon,"::");
       
    31 _LIT(KTsyNameExtension,".tsy");
       
    32 
       
    33 /**
       
    34 @internalComponent
       
    35 */
       
    36 const TInt KDefaultMaxDialAttempts=0;
       
    37 
       
    38 // CTelServerProcessor definitions
       
    39 
       
    40 CTelServerProcessor* CTelServerProcessor::NewL(CCommsDbNetDialAccess* aDb,TInt aPriority)
       
    41 /**
       
    42 2 phased constructor for CTelServerProcessor, first phase.
       
    43 
       
    44 @param aDb a pointer to CommDB accessor.
       
    45 @param aPriority is priority for this object.
       
    46 @exception Leaves if ConstructL() leaves, or not enough memory is available.
       
    47 @return a new CTelServerProcessor object.
       
    48 */
       
    49 	{
       
    50 	CTelServerProcessor* r=new(ELeave) CTelServerProcessor(aDb,aPriority);
       
    51 	CleanupStack::PushL(r);
       
    52 	r->ConstructL();
       
    53 	CleanupStack::Pop();
       
    54 	return r;
       
    55 	}
       
    56 
       
    57 CTelServerProcessor::CTelServerProcessor(CCommsDbNetDialAccess* aDb,TInt aPriority) 
       
    58 	: CActive(aPriority), iDb(aDb), iCallParamsPckg(iCallParams), 
       
    59 	iMmCallParamsPckg(iMmCallParams), iMmDataCallParamsPckg(iMmDataCallParams),
       
    60 	iMmHscsdParamsPckg(iMmHscsdParams)
       
    61 /**
       
    62 Private constructor for CTelServerProcessor, used in the first phase of construction.
       
    63 
       
    64 @param aDb a pointer to CommDB accessor.
       
    65 @param aPriority is priority for this object.
       
    66 */
       
    67 	{}
       
    68 
       
    69 void CTelServerProcessor::ConstructL()
       
    70 /**
       
    71 Instantiate Member variable.
       
    72 Add this object into active scheduler.
       
    73 Connect to ETel server.
       
    74 
       
    75 @exception Leaves if ETel server Connect() returns error, or not enough memory is available.
       
    76 */
       
    77 	{
       
    78 	CActiveScheduler::Add(this);
       
    79 
       
    80 	__FLOG_STMT(_LIT8(logString,"NetDial:\tConnecting Etel Server");)
       
    81 	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
    82 	User::LeaveIfError(iTelServer.Connect());
       
    83 	iState=EIdle;
       
    84 	iCallType=EUnknown;
       
    85 	}
       
    86 
       
    87 CTelServerProcessor::~CTelServerProcessor()
       
    88 /**
       
    89 Destructor.
       
    90 Close active call.
       
    91 If TSY is loaded, call UnloadPhoneModule() to unload it.
       
    92 Close ETel server connection.
       
    93 */
       
    94 	{
       
    95 	__FLOG_STMT(_LIT8(logString1,"NetDial:\tClosing Call");)
       
    96 	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString1());
       
    97 	CloseCall();
       
    98 	__FLOG_STMT(_LIT8(logString2,"NetDial:\tClosing Etel Server");)
       
    99 	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString2());
       
   100 	if(iTsyLoaded)
       
   101 		{
       
   102 		iTelServer.UnloadPhoneModule(iTsyName);
       
   103 		iTsyLoaded=EFalse;
       
   104 		}
       
   105 	iTelServer.Close();
       
   106 	}
       
   107 
       
   108 void CTelServerProcessor::StartDialUpL(MNetDialEtelObserver& aObserver)
       
   109 /**
       
   110 Open call and set call parameters, resolve number and dial.
       
   111 Call OpenNewCallL() to open call object from ETel server.
       
   112 Call DoDiallingResolutionL() from CommDB accessor to get correct tel number.
       
   113 Call DialL() from call object to dial the call.
       
   114 
       
   115 @param aObserver a reference to observer.
       
   116 @exception Leaves if OpenNewCallL(), DoDiallingResolutionL() or DialL() leaves.
       
   117 */
       
   118 	{
       
   119 	Assertions();
       
   120 	iCurrentObserver=&aObserver;
       
   121 	OpenNewCallL();
       
   122 	iDb->DoDiallingResolutionL(iTelNum);
       
   123 	DialL();
       
   124 	}
       
   125 
       
   126 void CTelServerProcessor::DialL()
       
   127 /**
       
   128 Dial number and increment dial counter.
       
   129 Call GetRedialAttempts() from CommDB accessor to get max dial attempt count.
       
   130 Check call type (ECoreCallOnly, EMmDataCall or EMmHscsdCall), get corresponding call parameters
       
   131 and dial the call.
       
   132 
       
   133 @exception Leaves if GetCallParamsL() leaves.
       
   134 */
       
   135 	{
       
   136 	__FLOG_STMT(_LIT(logString,"NetDial:\tDialling %S");)
       
   137 	__FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(logString()),&iTelNum);
       
   138 
       
   139 	TInt ret=iDb->GetRedialAttempts(iMaxDialAttempts);
       
   140 	if (ret!=KErrNone)
       
   141 		{
       
   142 		iMaxDialAttempts=KDefaultMaxDialAttempts;
       
   143 		}
       
   144 	if (iCallType==ECoreCallOnly)
       
   145 		{
       
   146 		iDb->GetCallParamsL(iCallParams);
       
   147 		iCall.Dial(iStatus,iCallParamsPckg,iTelNum);
       
   148 		}
       
   149 	else if (iCallType==EMmDataCall)
       
   150 		{
       
   151 		iDb->GetCallParamsL(iMmDataCallParams);
       
   152 		iDb->GetMmCallParams(iMmDataCallParams); // ignore return value, contimue without if they are not there
       
   153 		iMmCall.Dial(iStatus,iMmDataCallParamsPckg, iTelNum);
       
   154 		}
       
   155 	else if (iCallType==EMmHscsdCall)
       
   156 		{
       
   157 		// When the call is opened, HSCSD parameters are already read when
       
   158 		// it is required and if phone supports it!
       
   159 		iDb->GetCallParamsL(iMmHscsdParams);
       
   160 		iDb->GetMmCallParams(iMmHscsdParams); // ignore return value, contimue without if they are not there
       
   161 		iMmCall.Dial(iStatus,iMmHscsdParamsPckg, iTelNum);
       
   162 		}
       
   163 	else
       
   164 		{
       
   165 		NetDialPanic(EUnknownCallType);
       
   166 		}
       
   167 		
       
   168 	SetActive();
       
   169 	iDialCounter++;
       
   170 	iState=EDialUp;
       
   171 	}
       
   172 
       
   173 void CTelServerProcessor::StartReconnectL(MNetDialEtelObserver& aObserver)
       
   174 /**
       
   175 Dial number and increment dial counter.
       
   176 If comm port is loaned, call ReturnCommPortL() to recover comm port to ETel.
       
   177 Start reconnection by calling DialL().
       
   178 
       
   179 @param aObserver a reference to observer.
       
   180 @exception Leaves if ReturnCommPortL() or DialL() leaves.
       
   181 */
       
   182 	{
       
   183 	if (iLoaned)
       
   184 		ReturnCommPortL();
       
   185 
       
   186 	Assertions();
       
   187 	__ASSERT_ALWAYS(iCallOpen, NetDialPanic(EEtelCallNotOpen));
       
   188 	iCurrentObserver=&aObserver;
       
   189 
       
   190 	DialL();
       
   191 	}
       
   192 
       
   193 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT	
       
   194 void CTelServerProcessor::ListenForStatusChange(MNetDialEtelObserver& aObserver)
       
   195 /**
       
   196 Enable listening for a baseband disconnect
       
   197 @param aObserver a reference to observer.
       
   198 */
       
   199 	{
       
   200 	__FLOG_STMT(_LIT8(logString,"NetDial:\tListening For Call Status Change");)
       
   201 	__FLOG_STATIC(KNetDialLogFolder(), KNetDialLogFile(), logString());
       
   202 	
       
   203 	__ASSERT_ALWAYS(EIdle == iState, NetDialPanic(EEtelServerNotIdle));
       
   204 	__ASSERT_ALWAYS(iCallOpen, NetDialPanic(EEtelCallNotOpen));
       
   205 	
       
   206 	iCurrentObserver = &aObserver;
       
   207 	ActiveCall().NotifyStatusChange(iStatus, iCallStatus);
       
   208 	SetActive();
       
   209 	iState = EListenForStatusChange;
       
   210 	}
       
   211 	
       
   212 void CTelServerProcessor::CancelListenForStatusChange()
       
   213 	{
       
   214 	__FLOG_STMT(_LIT8(logString,"NetDial:\tCancelListenForStatusChange. iState: [%d]. iStatus: [%d]");)
       
   215 	__FLOG_STATIC2(KNetDialLogFolder(), KNetDialLogFile(), logString(), iState, iStatus.Int());
       
   216 	
       
   217 	__ASSERT_ALWAYS(iCallOpen, NetDialPanic(EEtelCallNotOpen));	
       
   218 	
       
   219 	Cancel();
       
   220 	}
       
   221 
       
   222 void CTelServerProcessor::HandleStatusChange()
       
   223 /**
       
   224 Handle call status change.
       
   225 If the call dropped, notify the observer, otherwise re-issue status
       
   226 change notification
       
   227 */
       
   228 	{	
       
   229 	__FLOG_STMT(_LIT8(logString,"NetDial:\tCall Status Changed. CallStatus %d Error: %d");)
       
   230 	__FLOG_STATIC2(KNetDialLogFolder(), KNetDialLogFile(), logString(), iCallStatus, iStatus.Int());
       
   231 	
       
   232 	// Ignore if subscribing to status change notification failed.
       
   233 	// It can be that the TSY doesn't support the feature etc.
       
   234 	if (KErrNone != iStatus.Int()) 
       
   235 		{
       
   236 		iState = EIdle;
       
   237 		return;
       
   238 		}	
       
   239 	
       
   240 	__ASSERT_ALWAYS(iCallOpen, NetDialPanic(EEtelCallNotOpen));
       
   241 		
       
   242 	switch (iCallStatus)
       
   243 		{
       
   244 		case RCall::EStatusHangingUp:
       
   245 		case RCall::EStatusIdle:
       
   246 			{
       
   247 			iState = EIdle;
       
   248 			iCurrentObserver->TelFunctionComplete(iStatus.Int());
       
   249 			break;
       
   250 			}
       
   251 		default:
       
   252 			{
       
   253 			iState = EListenForStatusChange;
       
   254 			ActiveCall().NotifyStatusChange(iStatus, iCallStatus);
       
   255 			SetActive();
       
   256 			}
       
   257 		}
       
   258 	}
       
   259 #endif // SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT
       
   260 void CTelServerProcessor::WaitForIncomingCallL(MNetDialEtelObserver& aObserver)
       
   261 /**
       
   262 If comm port is loaned, call ReturnCommPortL() to recover comm port to ETel.for callback.
       
   263 Call GetPhoneInfoL().
       
   264 If call is not opened, call OpenNewCallL() to open call object from ETel.
       
   265 Check call type (ECoreCallOnly, EMmDataCall or EMmHscsdCall), get corresponding call parameters,
       
   266 call AnswerIncomingCall() and start to wait for incoming call.
       
   267 
       
   268 @param aObserver a reference to observer.
       
   269 @exception Leaves if GetPhoneInfoL() or GetCallParamsL()leaves.
       
   270 */
       
   271 	{
       
   272 	if (iLoaned)
       
   273 		ReturnCommPortL();
       
   274 
       
   275 	Assertions();
       
   276 	
       
   277 	iCurrentObserver=&aObserver;
       
   278 	RTelServer::TPhoneInfo info;
       
   279 	GetPhoneInfoL(info);
       
   280 
       
   281 	if (!iCallOpen)
       
   282 		OpenNewCallL();
       
   283 
       
   284 	__FLOG_STMT(_LIT8(logString2,"NetDial:\tWaiting For Incoming Call");)
       
   285 	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString2());
       
   286 
       
   287 	if (iCallType==ECoreCallOnly)
       
   288 		{
       
   289 		iDb->GetCallParamsL(iCallParams);
       
   290 		iCall.AnswerIncomingCall(iStatus,iCallParamsPckg);
       
   291 		}
       
   292 	else if (iCallType==EMmDataCall)
       
   293 		{
       
   294 		iDb->GetCallParamsL(iMmDataCallParams);
       
   295 		iDb->GetMmCallParams(iMmDataCallParams); // ignore return value, contimue without if they are not there
       
   296 		iMmCall.AnswerIncomingCall(iStatus,iMmDataCallParamsPckg);
       
   297 		}
       
   298 	else if (iCallType==EMmHscsdCall)
       
   299 		{
       
   300 		// When the call is opened, HSCSD parameters are already read when
       
   301 		// it is required and if phone supports it!
       
   302 		iDb->GetCallParamsL(iMmHscsdParams);
       
   303 		iDb->GetMmCallParams(iMmHscsdParams); // ignore return value, contimue without if they are not there
       
   304 		iMmCall.AnswerIncomingCall(iStatus,iMmHscsdParamsPckg);
       
   305 		}
       
   306 
       
   307 	else
       
   308 		NetDialPanic(EUnknownCallType);
       
   309 	
       
   310 	SetActive();
       
   311 	iState=EWait;
       
   312 	}
       
   313 
       
   314 void CTelServerProcessor::StartHangUpAfterDialOut(MNetDialEtelObserver& aObserver)
       
   315 /**
       
   316 Call StartHangUp() to end the dialled call.
       
   317 
       
   318 @param aObserver a reference to observer.
       
   319 */
       
   320 	{
       
   321 	iCurrentObserver=&aObserver;
       
   322 	StartHangUp();
       
   323 	iState=EHangUpDialOut;
       
   324 	}
       
   325 
       
   326 void CTelServerProcessor::StartHangUpAfterDialIn(MNetDialEtelObserver& aObserver)
       
   327 /**
       
   328 Call StartHangUp() to end the dialled call.
       
   329 
       
   330 @param aObserver a reference to observer.
       
   331 */
       
   332 	{
       
   333 	iCurrentObserver=&aObserver;
       
   334 	StartHangUp();
       
   335 	iState=EHangUpDialIn;
       
   336 	}
       
   337 
       
   338 void CTelServerProcessor::StartHangUp()
       
   339 /**
       
   340 Call HangUp() from active call object.
       
   341 Set object active to wait for completition of request.
       
   342 */
       
   343 	{
       
   344 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT
       
   345 	CancelListenForStatusChange();
       
   346 #endif	
       
   347 	Assertions();
       
   348 
       
   349 	__FLOG_STMT(_LIT8(logString,"NetDial:\tHanging Up Call");)
       
   350 	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
   351 	ActiveCall().HangUp(iStatus);
       
   352 	SetActive();
       
   353 	}
       
   354 
       
   355 void CTelServerProcessor::GetCommPortL(RCall::TCommPort& aCommPort)
       
   356 /**
       
   357 Call LoanDataPort() to loan comm port from ETel server.
       
   358 Call SetCommPortL() from CommDB accessor to set the comm port into CommDB.
       
   359 
       
   360 @param aCommPort returns reference to loaned comm port.
       
   361 @exception Leaves if LoanDataPort() returns error or SetCommPortL leaves.
       
   362 */
       
   363 	{
       
   364 	__FLOG_STMT(_LIT8(logString,"NetDial:\tLoaning Port From Etel");)
       
   365 	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
   366 	User::LeaveIfError(ActiveCall().LoanDataPort(aCommPort));
       
   367 	iDb->SetCommPortL(aCommPort);
       
   368 	iLoaned=ETrue;
       
   369 #ifndef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT
       
   370 	iState=EIdle;
       
   371 #endif
       
   372 	}	
       
   373 
       
   374 void CTelServerProcessor::ReturnCommPortL()
       
   375 /**
       
   376 Call RecoverDataPort() to return comm port to ETel server.
       
   377 
       
   378 @exception Leaves if RecoverDataPort() returns error.
       
   379 */
       
   380 	{
       
   381 	__FLOG_STMT(_LIT8(logString,"NetDial:\tRecovering Port To Etel");)
       
   382 	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
   383 	User::LeaveIfError(ActiveCall().RecoverDataPort());
       
   384 	iLoaned=EFalse;
       
   385 #ifndef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT
       
   386 	iState=EIdle;
       
   387 #endif
       
   388 	}
       
   389 	
       
   390 void CTelServerProcessor::CloseCall()
       
   391 /**
       
   392 If comm port is loaned, call ReturnCommPortL() and trap error.
       
   393 If call is open, call Close() from active call object.
       
   394 */
       
   395 	{
       
   396 	__FLOG_STMT(_LIT8(logString,"NetDial:\tClosing Call");)
       
   397 	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
   398 	if (iLoaned)
       
   399 		{
       
   400 		TRAPD(ret,ReturnCommPortL());		// can't do anything with the error, so just trap
       
   401 		if (KErrNone != ret)
       
   402 			{
       
   403 			__FLOG_STMT(_LIT8(logString2,"ReturnCommPort:\tError Occured");)
       
   404 			__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString2());
       
   405 			}
       
   406 		}
       
   407 
       
   408 	if (iCallOpen)
       
   409 		{
       
   410 		ActiveCall().Close();
       
   411 		iCallOpen=EFalse;
       
   412 		}
       
   413 
       
   414 	iCallType=EUnknown;
       
   415 	}
       
   416 
       
   417 void CTelServerProcessor::DoCancel()
       
   418 /**
       
   419 Cancels active requests.
       
   420 Ignore return value of cancels because we can't do anything with it!
       
   421 */
       
   422 	{
       
   423 	switch (iState)
       
   424 		{
       
   425 	case EDialUp:
       
   426 		ActiveCall().DialCancel();
       
   427 		break;
       
   428 	case EWait:
       
   429 		ActiveCall().AnswerIncomingCallCancel();
       
   430 		break;
       
   431 	case EHangUpDialOut:
       
   432 	case EHangUpDialIn:
       
   433 		ActiveCall().HangUpCancel();
       
   434 		break;
       
   435 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT		
       
   436 	case EListenForStatusChange:
       
   437 		ActiveCall().NotifyStatusChangeCancel();
       
   438 		break;
       
   439 #endif		
       
   440 	default:
       
   441 		break;
       
   442 		}
       
   443 
       
   444 	iDialCounter=0;
       
   445 	iState=EIdle;
       
   446 	}
       
   447 
       
   448 void CTelServerProcessor::RunL()
       
   449 /**
       
   450 Request completed.
       
   451 Match internal state and act accordingly.
       
   452 */
       
   453 	{
       
   454 	__ASSERT_ALWAYS(iCurrentObserver!=NULL, NetDialPanic(ENullCallBackContext));
       
   455 
       
   456 	switch (iState)
       
   457 		{
       
   458 	case EDialUp:
       
   459 			{
       
   460 			TBool ret=EFalse;
       
   461 			TRAPD(err,(ret=RepeatDialL()));
       
   462 			if (err!=KErrNone)
       
   463 				iStatus=err;
       
   464 			if (err!=KErrNone || !ret)
       
   465 				{
       
   466 				iState=EIdle;
       
   467 				iDialCounter=0;
       
   468 				iCurrentObserver->TelFunctionComplete(iStatus.Int());
       
   469 				}	
       
   470 			}
       
   471 		break;
       
   472 	case EWait:
       
   473 		iState=EIdle;
       
   474 		iCurrentObserver->TelFunctionComplete(iStatus.Int());
       
   475 		break;
       
   476 	case EHangUpDialOut:
       
   477 		iState=EIdle;
       
   478 		iCurrentObserver->TelFunctionComplete(iStatus.Int());
       
   479 		break;
       
   480 	case EHangUpDialIn:
       
   481 		iState=EIdle;
       
   482 		iCurrentObserver->TelFunctionComplete(iStatus.Int());
       
   483 		break;
       
   484 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT		
       
   485 	case EListenForStatusChange:
       
   486 		HandleStatusChange();
       
   487 		break;
       
   488 #endif
       
   489 	default:
       
   490 		User::Leave(KErrNotFound);
       
   491 		break;
       
   492 		}
       
   493 	}
       
   494 
       
   495 TBool CTelServerProcessor::RepeatDialL()
       
   496 /**
       
   497 If iStatus.Int() is KErrEtelBusyDetected or KErrEtelNoAnswer and max dial count
       
   498 is not exceeded, call DialL() to re-dial.
       
   499 
       
   500 @exception Leaves if DialL() leaves.
       
   501 @return ETrue if DialL() is called, otherwise EFalse.
       
   502 */
       
   503 	{
       
   504 	if ((iStatus.Int()==KErrEtelBusyDetected  || iStatus.Int()==KErrEtelNoAnswer ) && (iDialCounter<iMaxDialAttempts))
       
   505 		{
       
   506 		DialL();
       
   507 		return ETrue;	
       
   508 		}
       
   509 	return EFalse;
       
   510 	}
       
   511 
       
   512 void CTelServerProcessor::Assertions()
       
   513 /**
       
   514 These two assertions are needed for all the functions so they are in a separate function.
       
   515 */
       
   516 	{
       
   517 	__ASSERT_ALWAYS(!iLoaned, NetDialPanic(EEtelPortNotRecovered));
       
   518 	__ASSERT_ALWAYS(iState==EIdle, NetDialPanic(EEtelServerNotIdle));
       
   519 	}
       
   520 
       
   521 void CTelServerProcessor::OpenNewCallL()
       
   522 /**
       
   523 Load the TSY and open a new call from the ETEL server
       
   524 */
       
   525 	{
       
   526 	__ASSERT_ALWAYS(!iCallOpen, NetDialPanic(EEtelCallAlreadyOpen));
       
   527 	__ASSERT_ALWAYS(iCallType==EUnknown, NetDialPanic(EEtelCallAlreadyOpen));
       
   528 
       
   529 	TBuf<KCommsDbSvrMaxFieldLength> newTsyName;
       
   530 	iDb->GetTsyNameL(newTsyName);
       
   531 	// Remove unnecessary .TSY extension, if found
       
   532 	if (newTsyName.Right(4).CompareF(KTsyNameExtension) == 0)
       
   533 		newTsyName = newTsyName.Left(newTsyName.Length() - 4);
       
   534 
       
   535 	TBool loaded=EFalse;
       
   536 	if (iTsyName.Length()!=0)
       
   537 		{
       
   538 		if (iTsyName.CompareF(newTsyName)==KErrNone)	// the one we want is already loaded
       
   539 			loaded=ETrue;
       
   540 		else											// unload the one we were using
       
   541 			{
       
   542 			User::LeaveIfError(iTelServer.UnloadPhoneModule(iTsyName));
       
   543 			iTsyLoaded=EFalse;
       
   544 			}
       
   545 		}
       
   546 
       
   547 	if (!loaded)
       
   548 		{
       
   549 		User::LeaveIfError(iTelServer.LoadPhoneModule(newTsyName));
       
   550 		iTsyName=newTsyName;
       
   551 		iTsyLoaded=ETrue;
       
   552 		}
       
   553 	
       
   554 	if (iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended)!=KErrNone)
       
   555 		{
       
   556 		User::LeaveIfError(iTelServer.SetExtendedErrorGranularity(RTelServer::EErrorBasic));
       
   557 		}
       
   558 
       
   559 	RTelServer::TPhoneInfo info;
       
   560 	GetPhoneInfoL(info);
       
   561 	
       
   562 	TName callName;
       
   563 	callName.Zero();
       
   564 	callName.Copy(info.iName);		// phone name
       
   565 	callName.Append(KDoubleColon);
       
   566 
       
   567 	RPhone::TLineInfo lineInfo;
       
   568 	GetLineInfoL(lineInfo,info.iName,RLine::KCapsData);
       
   569 	callName.Append(lineInfo.iName);
       
   570 	
       
   571 	callName.Append(KDoubleColon);
       
   572 	__FLOG_STMT(_LIT8(logString,"NetDial:\tOpening Call");)
       
   573 	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
   574 
       
   575 	iDb->CopyIspInitStringToModemL();	// will not leave if the field is blank
       
   576 	// Only MultimodeV1 and greater supported!
       
   577 	if (info.iExtensions>=(TUint)KETelExtMultimodeV1)
       
   578 		{
       
   579 		User::LeaveIfError(iMmCall.OpenNewCall(iTelServer,callName));
       
   580 		iCallOpen=ETrue;
       
   581 		iCallType=EMmDataCall;
       
   582 		SetMmParametersL();	// may change call type to EMmHscsdCall
       
   583 		}
       
   584 	else
       
   585 		{
       
   586 		User::LeaveIfError(iCall.OpenNewCall(iTelServer,callName));
       
   587 		iCallOpen=ETrue;
       
   588 		iCallType=ECoreCallOnly;
       
   589 		}
       
   590 	}
       
   591 
       
   592 void CTelServerProcessor::GetPhoneInfoL(RTelServer::TPhoneInfo& aInfo)
       
   593 	{
       
   594 	TInt count;
       
   595 	User::LeaveIfError(iTelServer.EnumeratePhones(count));
       
   596 	if (count<=0)
       
   597 		{
       
   598     	__FLOG_STMT(_LIT(logString,"NetDial:\tGetPhoneInfoL(): no phones found - leaving with -1");)
       
   599     	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
   600 		User::Leave(KErrNotFound);
       
   601 		}
       
   602 	TInt i;
       
   603 	TBool found=EFalse;
       
   604 	for (i=0; i<count; i++)
       
   605 		{
       
   606 		TBuf<KCommsDbSvrMaxFieldLength> currentTsyName;
       
   607 		User::LeaveIfError(iTelServer.GetTsyName(i,currentTsyName));
       
   608 		// Remove unnecessary extension, if found
       
   609 		if (currentTsyName.Right(4).CompareF(KTsyNameExtension) == 0)
       
   610 			currentTsyName = currentTsyName.Left(currentTsyName.Length() - 4);
       
   611 		// Check for match in TSY names
       
   612 		if (currentTsyName.CompareF(iTsyName)==KErrNone)
       
   613 			{
       
   614 			User::LeaveIfError(iTelServer.GetPhoneInfo(i,aInfo));
       
   615 			found=ETrue;
       
   616 			break;
       
   617 			}	
       
   618 		}
       
   619 
       
   620 	if (!found)
       
   621 		{
       
   622 		__FLOG_STMT(_LIT(logString,"NetDial:\tGetPhoneInfoL(): required phone not found - leaving with -1");)
       
   623     	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
   624 		User::Leave(KErrNotFound);
       
   625 		}
       
   626 	}
       
   627 
       
   628 void CTelServerProcessor::GetLineInfoL(RPhone::TLineInfo& aInfo,const TDesC& aPhoneName, TUint aLineType)
       
   629         {
       
   630         RPhone phone;
       
   631         User::LeaveIfError(phone.Open(iTelServer,aPhoneName));
       
   632         CleanupClosePushL(phone);
       
   633         
       
   634         TInt count = 0;
       
   635         User::LeaveIfError(phone.EnumerateLines(count));
       
   636 	if (count <= 0)
       
   637 		{
       
   638     	__FLOG_STMT(_LIT(logString,"NetDial:\tGetLineInfoL(): no line info available - leaving with -1");)
       
   639     	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
   640 	        User::Leave(KErrNotFound);
       
   641 		}
       
   642         
       
   643         TBool found = EFalse;
       
   644 	for (TInt i=0; i<count && !found; ++i)
       
   645 		{
       
   646 		User::LeaveIfError(phone.GetLineInfo(i,aInfo));
       
   647 		/* if (aInfo.iLineCapsFlags & aLineType) // Required line found
       
   648 		        {
       
   649 		        found=ETrue;
       
   650 		        } */
       
   651 
       
   652 		RLine line;
       
   653 		User::LeaveIfError(line.Open(phone,aInfo.iName));
       
   654 		CleanupClosePushL(line);
       
   655 
       
   656 		RLine::TCaps caps;
       
   657 		User::LeaveIfError(line.GetCaps(caps));
       
   658 		if (caps.iFlags & aLineType) // Required line found
       
   659 		        {
       
   660 		        found=ETrue;
       
   661 		        }
       
   662                 CleanupStack::PopAndDestroy(&line);
       
   663 	
       
   664 		}
       
   665 
       
   666         CleanupStack::PopAndDestroy(&phone);
       
   667         if (!found)
       
   668         	{
       
   669         	__FLOG_STMT(_LIT(logString,"NetDial:\tGetLineInfoL(): required line not found - leaving with -1");)
       
   670         	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
   671 	        User::Leave(KErrNotFound);
       
   672         	}
       
   673         }
       
   674 
       
   675 void CTelServerProcessor::SetMmParametersL()
       
   676 /**
       
   677 Set the multimode call parameters.
       
   678 Call HscsdSettingsAvailableL() from CommDB accessor to check if HSCSD is supported.
       
   679 If available, check TSY's data call caps to find out if it supports HSCSD.
       
   680 If HSCSD is supported also by TSY, call GetMmHscsdParametersL() from CommDB accessor.
       
   681 
       
   682 @exception Leaves if HscsdSettingsAvailableL() and GetMmHscsdParametersL() leaves.
       
   683 */
       
   684 	{
       
   685 	__ASSERT_ALWAYS(iCallType==EMmDataCall, NetDialPanic(EAttemptHSCSDWhenNotMultimode));
       
   686 
       
   687 	if (iDb->HscsdSettingsAvailableL())
       
   688 		{
       
   689 		RMobileCall::TMobileCallDataCapsV1 mmDataCaps;
       
   690 		RMobileCall::TMobileCallDataCapsV1Pckg mmDataCapsPckg(mmDataCaps);
       
   691 		// Get the data caps from the phone
       
   692 		TInt ret = iMmCall.GetMobileDataCallCaps(mmDataCapsPckg);
       
   693 		if (KErrNone == ret)
       
   694 			{
       
   695 			// Check if the HSCSD is supported
       
   696 			if (mmDataCaps.iHscsdSupport != EFalse)
       
   697 				{
       
   698 				// Get the multimode HSCSD parameters and pass them in Dial.
       
   699 				iDb->GetMmHscsdParametersL(iMmHscsdParams);
       
   700 				iCallType=EMmHscsdCall;
       
   701 				}
       
   702 			}
       
   703 		else if (KErrNotSupported != ret)
       
   704 			User::Leave(ret);
       
   705 		}
       
   706 	}
       
   707 
       
   708 RCall& CTelServerProcessor::ActiveCall()
       
   709 /**
       
   710 If iCallType is ECoreCallOnly, return iCall.
       
   711 If iCallType is EMmDataCall or EMmHscsdCall, return iMmCall.
       
   712 Otherwise panic with EUnknownCallType.
       
   713 
       
   714 @return iCall or iMmCall.
       
   715 */
       
   716 	{
       
   717 	if (iCallType==ECoreCallOnly)
       
   718 		return iCall;
       
   719 
       
   720 	if (iCallType==EMmDataCall || iCallType==EMmHscsdCall)
       
   721 		return iMmCall;
       
   722 
       
   723 	NetDialPanic(EUnknownCallType);
       
   724 	return iCall;		// will never happen because of panic
       
   725 	}
       
   726 
       
   727 TBool CTelServerProcessor::CommPortLoaned() const
       
   728 /**
       
   729 @return iLoaned.
       
   730 */
       
   731 	{
       
   732 	return iLoaned;
       
   733 	}
       
   734 
       
   735 TBool CTelServerProcessor::CallActive() const
       
   736 /**
       
   737 @return iCallType.
       
   738 */
       
   739 	{
       
   740 	return (iCallType != EUnknown);
       
   741 	}
       
   742