telephonyprotocols/csdagt/src/Nd_dlupStates.cpp
changeset 42 3adadc800673
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
31:8ab6687fb94c 42:3adadc800673
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 /**
    18 /**
    19  @file Nd_dlupstates.cpp 
    19  @file Nd_dlupstates.cpp 
    20 */
    20 */
    21 
    21 
    22 
    22 
       
    23 
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "Nd_dlupStatesTraces.h"
       
    27 #endif
       
    28 
    23 #include "Nd_dlupStates.h"
    29 #include "Nd_dlupStates.h"
    24 #include "SLOGGER.H"
       
    25 #include <comms-infras/eventlogger.h>
    30 #include <comms-infras/eventlogger.h>
    26 #include <csdprog.h>
    31 #include <csdprog.h>
    27 #include "ND_DBACC.H"
    32 #include "ND_DBACC.H"
    28 
    33 
    29 
    34 
   271 Dialling is always asynchronous, so should not complete if cancelled.
   276 Dialling is always asynchronous, so should not complete if cancelled.
   272 */
   277 */
   273 	{
   278 	{
   274 	if(iStatus!=KErrNone)
   279 	if(iStatus!=KErrNone)
   275 		{
   280 		{
   276 		__FLOG_STMT(_LIT(logString3,"Dialling");)
   281 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPDIALLING_RUNL_1, "NetDial:\tCompleted Phase 'Dialling' with Error %d" ,iStatus.Int());
   277 		__FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3() ,iStatus.Int());
       
   278 		if (iNdEnv->Script()!=NULL)
   282 		if (iNdEnv->Script()!=NULL)
   279 			iNdEnv->Script()->CloseScript();
   283 			iNdEnv->Script()->CloseScript();
   280 		iSMObserver->ConnectionComplete(ECsdFinishedDialling,iStatus.Int());
   284 		iSMObserver->ConnectionComplete(ECsdFinishedDialling,iStatus.Int());
   281 		return;
   285 		return;
   282 		}
   286 		}
   427 Call CompleteState() with KErrNone.
   431 Call CompleteState() with KErrNone.
   428 */
   432 */
   429 	{
   433 	{
   430 	if(iStatus!=KErrNone)
   434 	if(iStatus!=KErrNone)
   431 		{
   435 		{
   432 		__FLOG_STMT(_LIT(logString3,"Scan Script");)
   436 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPSCANSCRIPT_RUNL_1, "NetDial:\tCompleted Phase 'Scan Script' with Error %d", iStatus.Int());
   433 		__FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int());
       
   434 		if (iNdEnv->Script()!=NULL)
   437 		if (iNdEnv->Script()!=NULL)
   435 			iNdEnv->Script()->CloseScript();
   438 			iNdEnv->Script()->CloseScript();
   436 		iSMObserver->ConnectionComplete(ECsdScannedScript,iStatus.Int());
   439 		iSMObserver->ConnectionComplete(ECsdScannedScript,iStatus.Int());
   437 		return;
   440 		return;
   438 		}
   441 		}
   501 @return a new CDlUpCloseDataPort (BCA) / CDlUpHangUp (non-BCA) or CDlUpLogin object.
   504 @return a new CDlUpCloseDataPort (BCA) / CDlUpHangUp (non-BCA) or CDlUpLogin object.
   502 */
   505 */
   503 	{ 
   506 	{ 
   504 	if((!aContinue)||(iStatus!=KErrNone))
   507 	if((!aContinue)||(iStatus!=KErrNone))
   505 		{
   508 		{
   506 		__FLOG_STMT(_LIT(logString,"NetDial:\tGetLoginInfo state cancelling (aContinue %d, iStatus %d)");)
   509 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPGETLOGININFO_NEXTSTATEL_1, "NetDial:\tGetLoginInfo state cancelling (aContinue %d, iStatus %d)",aContinue, iStatus.Int());
   507 		__FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(logString()), aContinue, iStatus.Int());
       
   508 
   510 
   509 		TInt err = iStatus.Int();
   511 		TInt err = iStatus.Int();
   510 		if (!aContinue && err == KErrNone)
   512 		if (!aContinue && err == KErrNone)
   511 			{
   513 			{
   512 			// Ensure that CDlUpCloseDataPort receives an error in the case where aContinue==EFalse and iStatus==KErrNone.
   514 			// Ensure that CDlUpCloseDataPort receives an error in the case where aContinue==EFalse and iStatus==KErrNone.
   643 Call CompleteState() with KErrNone.
   645 Call CompleteState() with KErrNone.
   644 */
   646 */
   645 	{
   647 	{
   646 	if(iStatus!=KErrNone)
   648 	if(iStatus!=KErrNone)
   647 		{
   649 		{
   648 		__FLOG_STMT(_LIT(logString3,"Login");)
   650 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPLOGIN_RUNL_1, _ "NetDial:\tCompleted Phase 'Login' with Error %d", iStatus.Int());
   649 		__FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int());
       
   650 		if (iNdEnv->Script()!=NULL)
   651 		if (iNdEnv->Script()!=NULL)
   651 			iNdEnv->Script()->CloseScript();
   652 			iNdEnv->Script()->CloseScript();
   652 		iSMObserver->ConnectionComplete(ECsdFinishedLogIn,iStatus.Int());
   653 		iSMObserver->ConnectionComplete(ECsdFinishedLogIn,iStatus.Int());
   653 		return;
   654 		return;
   654 		}
   655 		}
   778 		return;
   779 		return;
   779 		}	
   780 		}	
   780 #endif					
   781 #endif					
   781 	__ASSERT_DEBUG(iStatus==KErrNone,User::Invariant());
   782 	__ASSERT_DEBUG(iStatus==KErrNone,User::Invariant());
   782 	iSMObserver->UpdateProgress(ECsdConnectionOpen,KErrNone);
   783 	iSMObserver->UpdateProgress(ECsdConnectionOpen,KErrNone);
   783 	__FLOG_STMT(_LIT8(logString,"NetDial:\tConnection Open");)
   784 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPOPEN_RUNL_1, "NetDial:\tConnection Open");
   784 	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
   785 	if (iNdEnv->Script()!=NULL)
   785 	if (iNdEnv->Script()!=NULL)
   786 		iNdEnv->Script()->CloseScript();
   786 		iNdEnv->Script()->CloseScript();
   787 	iSMObserver->ConnectionComplete(ECsdConnectionOpen,KErrNone);
   787 	iSMObserver->ConnectionComplete(ECsdConnectionOpen,KErrNone);
   788 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT
   788 #ifdef SYMBIAN_NETWORKING_CSDAGENT_BCA_SUPPORT
   789 	iNdEnv->TelServPrc()->ListenForStatusChange(*this);
   789 	iNdEnv->TelServPrc()->ListenForStatusChange(*this);
   918 	{	
   918 	{	
   919 	//update the log object
   919 	//update the log object
   920 	iNdEnv->Logger()->LogDataUpdateEvent(R_LOG_CON_DISCONNECTED, KLogDataEventTypeUid);
   920 	iNdEnv->Logger()->LogDataUpdateEvent(R_LOG_CON_DISCONNECTED, KLogDataEventTypeUid);
   921 	if(iStatus!=KErrNone)
   921 	if(iStatus!=KErrNone)
   922 		{
   922 		{
   923 #ifdef __FLOG_ACTIVE
   923 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPHANGUP_RUNL_1,"NetDial:\tCompleted Phase 'Hang Up' with Error %d", iStatus.Int());
   924 		_LIT(logString3,"Hang Up");
   924 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPHANGUP_RUNL_2, "NetDial:\tDisconnection Error %d", iStatus.Int());
   925 		_LIT8(logString2,"NetDial:\tDisconnection Error %d");
       
   926 #endif
       
   927 		__FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int());
       
   928 		__FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC8>(logString2()), iStatus.Int());
       
   929 		}
   925 		}
   930 	else
   926 	else
   931 		{
   927 		{
   932 		iSMObserver->UpdateProgress(ECsdFinishedHangUp,KErrNone);
   928 		iSMObserver->UpdateProgress(ECsdFinishedHangUp,KErrNone);
   933 		}
   929 		}
  1022 /**
  1018 /**
  1023 Disconnect completed.
  1019 Disconnect completed.
  1024 Call DisconnectComplete().
  1020 Call DisconnectComplete().
  1025 */
  1021 */
  1026 	{
  1022 	{
  1027 	__FLOG_STMT(_LIT8(logString,"NetDial:\tDisconnect Complete");)
  1023 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPDISCONNECT_RUNL_1, _"NetDial:\tDisconnect Complete");
  1028 	__FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString());
       
  1029 
  1024 
  1030 	iSMObserver->DisconnectComplete();
  1025 	iSMObserver->DisconnectComplete();
  1031 	}
  1026 	}
  1032 
  1027 
  1033 CDlUpOpenDataPort* CDlUpOpenDataPort::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv)
  1028 CDlUpOpenDataPort* CDlUpOpenDataPort::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv)
  1077 Set up script and initiate creation of channel.
  1072 Set up script and initiate creation of channel.
  1078 Call JumpToRunl() with KErrNone.
  1073 Call JumpToRunl() with KErrNone.
  1079 */
  1074 */
  1080 	{
  1075 	{
  1081 	ASSERT(iNdEnv);
  1076 	ASSERT(iNdEnv);
  1082 	__FLOG_STMT(_LIT8(logString,"NetDial:\tOpening Data Port"));
  1077 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPOPENDATAPORT_STARTSTATE_1,"NetDial:\tOpening Data Port");
  1083 	__FLOG_STATIC(KNetDialLogFolder(), KNetDialLogFile(), logString());
       
  1084 
  1078 
  1085 	iSMObserver->UpdateProgress(ECsdScanningScript,KErrNone);
  1079 	iSMObserver->UpdateProgress(ECsdScanningScript,KErrNone);
  1086 	TRAPD(ret,iNdEnv->SetUpScriptL());
  1080 	TRAPD(ret,iNdEnv->SetUpScriptL());
  1087 	if (ret!=KErrNone)
  1081 	if (ret!=KErrNone)
  1088 		{
  1082 		{
  1128 Call CompleteState() with KErrNone.
  1122 Call CompleteState() with KErrNone.
  1129 */
  1123 */
  1130 	{
  1124 	{
  1131 	if (iStatus!=KErrNone)
  1125 	if (iStatus!=KErrNone)
  1132 		{
  1126 		{
  1133 #ifdef __FLOG_ACTIVE
  1127 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPOPENDATAPORT_RUNL_1, "NetDial:\tCompleted Phase 'Open Data Port' with Error %d", iStatus.Int());
  1134 		_LIT(logString3,"Open Data Port");
       
  1135 #endif
       
  1136 		__FLOG_STATIC2(KNetDialLogFolder(), KNetDialLogFile(), TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int());
       
  1137 		if (iNdEnv->Script()!=NULL)
  1128 		if (iNdEnv->Script()!=NULL)
  1138 			iNdEnv->Script()->CloseScript();
  1129 			iNdEnv->Script()->CloseScript();
  1139 		iSMObserver->ConnectionComplete(ECsdScannedScript,iStatus.Int());
  1130 		iSMObserver->ConnectionComplete(ECsdScannedScript,iStatus.Int());
  1140 		return;
  1131 		return;
  1141 		}
  1132 		}
  1191 */
  1182 */
  1192 	{
  1183 	{
  1193 	ASSERT(iNdEnv);
  1184 	ASSERT(iNdEnv);
  1194 	ASSERT (iNdEnv->Script());
  1185 	ASSERT (iNdEnv->Script());
  1195 
  1186 
  1196 	__FLOG_STMT(_LIT8(logString,"NetDial:\tClosing Data Port"));
  1187 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPCLOSEDATAPORT_STARTSTATE_1, "NetDial:\tClosing Data Port");
  1197 	__FLOG_STATIC(KNetDialLogFolder(), KNetDialLogFile(), logString());
       
  1198 
  1188 
  1199 	iNdEnv->Script()->ShutdownChannel(iStatus);
  1189 	iNdEnv->Script()->ShutdownChannel(iStatus);
  1200 	iStatus = KRequestPending;
  1190 	iStatus = KRequestPending;
  1201 	SetActive();
  1191 	SetActive();
  1202 	}
  1192 	}
  1209 @return a new CDlUpCloseDataPort object.
  1199 @return a new CDlUpCloseDataPort object.
  1210 */
  1200 */
  1211 	{
  1201 	{
  1212 	if((!aContinue) || (iError != KErrNone) || (iStatus.Int() != KErrNone))
  1202 	if((!aContinue) || (iError != KErrNone) || (iStatus.Int() != KErrNone))
  1213 		{
  1203 		{
  1214 		__FLOG_STMT(_LIT(logString,"NetDial:\tCloseDataPort state cancelling (iError %d, aContinue %d, iStatus %d)");)
  1204 		OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPCLOSEDATAPORT_NEXTSTATEL_1, "NetDial:\tCloseDataPort state cancelling (iError %d, aContinue %d, iStatus %d)", iError, aContinue, iStatus.Int());
  1215 		__FLOG_STATIC3(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(logString()), iError, aContinue, iStatus.Int());
       
  1216 
       
  1217 		return CDlUpHangUp::NewL(*iSMObserver,*iNdEnv);
  1205 		return CDlUpHangUp::NewL(*iSMObserver,*iNdEnv);
  1218 		}
  1206 		}
  1219 	else
  1207 	else
  1220 		{
  1208 		{
  1221 		return CDlUpOpen::NewL(*iSMObserver, *iNdEnv);
  1209 		return CDlUpOpen::NewL(*iSMObserver, *iNdEnv);
  1238 	// Note: we assume that if iError != KErrNone then ConnectionComplete() has already been called by
  1226 	// Note: we assume that if iError != KErrNone then ConnectionComplete() has already been called by
  1239 	// the failing state (otherwise NIFMAN will panic due to the lack of a ConnectComplete() in response
  1227 	// the failing state (otherwise NIFMAN will panic due to the lack of a ConnectComplete() in response
  1240 	// to its earlier Connect()).
  1228 	// to its earlier Connect()).
  1241 	if (iStatus!=KErrNone)
  1229 	if (iStatus!=KErrNone)
  1242 		{
  1230 		{
  1243 #ifdef __FLOG_ACTIVE
  1231 
  1244 		_LIT(logString3,"Close Data Port");
  1232 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPCLOSEDATAPORT_RUNL_1, "NetDial:\tCompleted Phase 'Close Data Port' with Error %d", iStatus.Int());
  1245 		_LIT8(logstring2,"Saved error = %d");
       
  1246 #endif
       
  1247 		__FLOG_STATIC2(KNetDialLogFolder(), KNetDialLogFile(), TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int());
       
  1248 		if (iError != KErrNone)
  1233 		if (iError != KErrNone)
  1249 			{
  1234 			{
  1250 			__FLOG_STATIC1(KNetDialLogFolder(), KNetDialLogFile(), TRefByValue<const TDesC8>(logstring2()), iError);
  1235 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDLUPCLOSEDATAPORT_RUNL_2, "Saved error = %d", iError);
  1251 			}
  1236 			}
  1252 		else
  1237 		else
  1253 			{
  1238 			{
  1254 			// Only do the ConnectionComplete() due to errors in this state if a previous state has not already done
  1239 			// Only do the ConnectionComplete() due to errors in this state if a previous state has not already done
  1255 			// so (i.e. iError == KErrNone) otherwise NIFMAN will panic.
  1240 			// so (i.e. iError == KErrNone) otherwise NIFMAN will panic.