telephonyprotocols/psdagt/src/psdstates.cpp
branchRCL_3
changeset 20 07a122eea281
parent 19 630d2f34d719
equal deleted inserted replaced
19:630d2f34d719 20:07a122eea281
     1 // Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2003-2009 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".
    15 
    15 
    16 /**
    16 /**
    17  @file PsdStates.cpp
    17  @file PsdStates.cpp
    18 */
    18 */
    19 
    19 
    20 
       
    21 #include "OstTraceDefinitions.h"
       
    22 #ifdef OST_TRACE_COMPILER_IN_USE
       
    23 #include "psdstatesTraces.h"
       
    24 #endif
       
    25 
       
    26 #include <comms-infras/cagentsmbase.h>
    20 #include <comms-infras/cagentsmbase.h>
    27 #include <etelpckt.h>
    21 #include <etelpckt.h>
    28 #include <connectprog.h>  // for circuit-switched progress enums
    22 #include <connectprog.h>  // for circuit-switched progress enums
    29 #include <netconerror.h>
    23 #include <netconerror.h>
    30 #include "psdlogger.h"
    24 #include "psdlogger.h"
    31 
    25 
    32 #include "psdstates.h"
    26 #include "psdstates.h"
    33 #include "psdagt.h"
    27 #include "psdagt.h"
    34 #include "psdprog.h"
    28 #include "psdprog.h"
    35 
    29 
       
    30 #include "debuglogger.h"
    36 #include <logengevents.h>
    31 #include <logengevents.h>
    37 
    32 
    38 CPsdOutInit::CPsdOutInit(MAgentStateMachineEnv* aObserver,MPsdEnv* aPsdSM, MPsdCommDbAccess* aDb)
    33 CPsdOutInit::CPsdOutInit(MAgentStateMachineEnv* aObserver,MPsdEnv* aPsdSM, MPsdCommDbAccess* aDb)
    39 : CPsdInitBase(aObserver,aPsdSM,aDb)
    34 : CPsdInitBase(aObserver,aPsdSM,aDb)
    40 /**
    35 /**
   189 Internal function that performs all the initialisation of the common resources
   184 Internal function that performs all the initialisation of the common resources
   190 held by the state machine for use by subsequent states
   185 held by the state machine for use by subsequent states
   191 */
   186 */
   192 	{
   187 	{
   193 	__ASSERT_DEBUG(iSM,User::Invariant());
   188 	__ASSERT_DEBUG(iSM,User::Invariant());
   194 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDINITBASE_DOSTARTSTATEL_1, "Packet Data:\tInitialising");
   189 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tInitialising");)
   195 	
   190 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1());
       
   191 
   196 	iSMObserver->PreventConnectionRetries();
   192 	iSMObserver->PreventConnectionRetries();
   197 	//
   193 	//
   198 	//	PSD AGX does not allow any more connection retries. It assumes that GenConn has
   194 	//	PSD AGX does not allow any more connection retries. It assumes that GenConn has
   199 	//  already done the packet network availability check, so we would only get to this stage
   195 	//  already done the packet network availability check, so we would only get to this stage
   200 	//	should there be packet network (or if it was unknown).
   196 	//	should there be packet network (or if it was unknown).
   276 void CPsdInitBase::RunL()
   272 void CPsdInitBase::RunL()
   277 /**
   273 /**
   278 Complete state for the initialisation state for both incomming and outgoing connections.
   274 Complete state for the initialisation state for both incomming and outgoing connections.
   279 */
   275 */
   280 	{
   276 	{
   281 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDINITBASE_RUNL_1, "Packet Data:\tInitialised");
   277 	__FLOG_STMT(_LIT8(logString2,"Packet Data:\tInitialised");)
       
   278 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString2());
   282 	if (iStatus!=KErrNone)
   279 	if (iStatus!=KErrNone)
   283 		iSMObserver->ConnectionComplete(EPsdStartingConfiguration,iStatus.Int()); // correct progress?
   280 		iSMObserver->ConnectionComplete(EPsdStartingConfiguration,iStatus.Int()); // correct progress?
   284 	else
   281 	else
   285 		iSM->BaseEnv().CompleteState(KErrNone);	// this tells the SM to move onto the next state
   282 		iSM->BaseEnv().CompleteState(KErrNone);	// this tells the SM to move onto the next state
   286 	}
   283 	}
   325 	const CPsdContextConfig& config = iSM->Config();
   322 	const CPsdContextConfig& config = iSM->Config();
   326 	if(!config.IsConfigSupportedL(packetNetwork,iSM->Direction()) )
   323 	if(!config.IsConfigSupportedL(packetNetwork,iSM->Direction()) )
   327 		{
   324 		{
   328 		User::Leave(KErrNotSupported);
   325 		User::Leave(KErrNotSupported);
   329 		}
   326 		}
   330 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDCHECKCONFIG_DOINITL_1,"Packet Data:\tChecked Config");
   327 	__FLOG_STMT(_LIT8(logString2,"Packet Data:\tChecked Config");)
       
   328 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString2());
   331 	}
   329 	}
   332 
   330 
   333 void CPsdCheckConfig::RunL()
   331 void CPsdCheckConfig::RunL()
   334 /**
   332 /**
   335 Complete state for the config checking state for both incomming and outgoing connections.
   333 Complete state for the config checking state for both incomming and outgoing connections.
   372 */
   370 */
   373 	{
   371 	{
   374 	__ASSERT_DEBUG(iSM,User::Invariant());
   372 	__ASSERT_DEBUG(iSM,User::Invariant());
   375 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   373 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   376 
   374 
   377 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDNETWORKCHECK_STARTSTATE_1,"Packet Data:\tChecking network availability");
   375 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tChecking network availability");)
       
   376 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1());
   378 
   377 
   379 	iSubState = EGettingInitialStatus;
   378 	iSubState = EGettingInitialStatus;
   380 	iSM->PacketNetwork().GetNtwkRegStatus(iStatus,iRegStatus);
   379 	iSM->PacketNetwork().GetNtwkRegStatus(iStatus,iRegStatus);
   381 	SetActive();
   380 	SetActive();
   382 	}
   381 	}
   391 
   390 
   392 	if (iRegStatus==RPacketService::ERegistrationDenied || 
   391 	if (iRegStatus==RPacketService::ERegistrationDenied || 
   393 		iRegStatus==RPacketService::ENotRegisteredNotSearching || 
   392 		iRegStatus==RPacketService::ENotRegisteredNotSearching || 
   394 		iRegStatus==RPacketService::ENotRegisteredAndNotAvailable)
   393 		iRegStatus==RPacketService::ENotRegisteredAndNotAvailable)
   395 		{
   394 		{
   396 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDNETWORKCHECK_DONETWORKCHECK_1, "Packet Data:\tNo network");
   395 		__FLOG_STMT(_LIT8(logString1,"Packet Data:\tNo network");)
       
   396 		__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1());
   397 		JumpToRunl(KErrNetConNoGPRSNetwork);
   397 		JumpToRunl(KErrNetConNoGPRSNetwork);
   398 		return;
   398 		return;
   399 		}
   399 		}
   400 	if (iRegStatus==RPacketService::ERegisteredOnHomeNetwork || 
   400 	if (iRegStatus==RPacketService::ERegisteredOnHomeNetwork || 
   401 		iRegStatus==RPacketService::ERegisteredRoaming ||
   401 		iRegStatus==RPacketService::ERegisteredRoaming ||
   402 		iRegStatus==RPacketService::ENotRegisteredButAvailable ||
   402 		iRegStatus==RPacketService::ENotRegisteredButAvailable ||
   403 		iRegStatus==RPacketService::EUnknown)
   403 		iRegStatus==RPacketService::EUnknown)
   404 		{
   404 		{
   405 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDNETWORKCHECK_DONETWORKCHECK_2,"Packet Data:\tReg status %d. Proceeding",iRegStatus);
   405 		__FLOG_STMT(_LIT8(logString1,"Packet Data:\tReg status %d. Proceeding");)
       
   406 		__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),iRegStatus);
   406 
   407 
   407 		iSM->BaseEnv().CompleteState(KErrNone);
   408 		iSM->BaseEnv().CompleteState(KErrNone);
   408 		return;
   409 		return;
   409 		}
   410 		}
   410 
   411 
   485 Function called by the genconn state machine framework to start the state
   486 Function called by the genconn state machine framework to start the state
   486 */
   487 */
   487 	{
   488 	{
   488 	__ASSERT_DEBUG(iSM,User::Invariant());
   489 	__ASSERT_DEBUG(iSM,User::Invariant());
   489 
   490 
   490 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDWAITFORINCOMING_STARTSTATE_1,"Packet Data:\tWaiting for incoming Packet request");
   491 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tWaiting for incoming Packet request");)
       
   492 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1);
   491 
   493 
   492 	iSM->PacketNetwork().NotifyContextActivationRequested(iStatus,iPdpTypeRequested,iAddressRequested);
   494 	iSM->PacketNetwork().NotifyContextActivationRequested(iStatus,iPdpTypeRequested,iAddressRequested);
   493 	SetActive();
   495 	SetActive();
   494 	}
   496 	}
   495 
   497 
   503 	__ASSERT_DEBUG(iSM,User::Invariant());
   505 	__ASSERT_DEBUG(iSM,User::Invariant());
   504 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   506 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   505 
   507 
   506 	if (iStatus==KErrNone)
   508 	if (iStatus==KErrNone)
   507 		{
   509 		{
   508 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDWAITFORINCOMING_RUNL_1, "Packet Data:\tReceived network context activation request");
   510 		__FLOG_STMT(_LIT8(logString1,"Packet Data:\tReceived network context activation request");)
       
   511 		__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1);
   509 		
   512 		
   510 		if(iSM->Config().QueryIfIncommingConnectionAcceptable(iPdpTypeRequested,iAddressRequested) )
   513 		if(iSM->Config().QueryIfIncommingConnectionAcceptable(iPdpTypeRequested,iAddressRequested) )
   511 			{
   514 			{
   512 			iSMObserver->UpdateProgress(EPsdAnsweringIncoming,KErrNone);
   515 			iSMObserver->UpdateProgress(EPsdAnsweringIncoming,KErrNone);
   513 			TInt ret = iSMObserver->IncomingConnectionReceived();	// to switch NIFMAN to connecting
   516 			TInt ret = iSMObserver->IncomingConnectionReceived();	// to switch NIFMAN to connecting
   584 */
   587 */
   585 	{
   588 	{
   586 	__ASSERT_DEBUG(iSM,User::Invariant());
   589 	__ASSERT_DEBUG(iSM,User::Invariant());
   587 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   590 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   588 
   591 
   589 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDCREATECONTEXT_STARTSTATE_1, "Packet Data:\tCreating context");
   592 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tCreating context");)
       
   593 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1);
   590 
   594 
   591 	RPacketService& packetNetwork = iSM->PacketNetwork();
   595 	RPacketService& packetNetwork = iSM->PacketNetwork();
   592 	RPacketContext& context = iSM->Context();
   596 	RPacketContext& context = iSM->Context();
   593 
   597 
   594 	TName name;
   598 	TName name;
   611 */
   615 */
   612 	{
   616 	{
   613 	__ASSERT_DEBUG(iSM,User::Invariant());
   617 	__ASSERT_DEBUG(iSM,User::Invariant());
   614 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   618 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   615 
   619 
   616 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDCREATECONTEXT_RUNL_1, "Packet Data:\tCompleted with error %d",iStatus.Int());
   620 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tCompleted with error %d");)
       
   621 	__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),iStatus.Int());
   617 
   622 
   618 	if (iStatus==KErrNone)
   623 	if (iStatus==KErrNone)
   619 		{
   624 		{
   620 		// Have added new configure qos state that follows this one
   625 		// Have added new configure qos state that follows this one
   621 		// therefore don't report config completion until that state has finished
   626 		// therefore don't report config completion until that state has finished
   680 */
   685 */
   681 	{
   686 	{
   682 	__ASSERT_DEBUG(iSM,User::Invariant());
   687 	__ASSERT_DEBUG(iSM,User::Invariant());
   683 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   688 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   684 
   689 
   685 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDCREATEQOS_STARTSTATE_1, "Packet Data:\tCreating QoS");
   690 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tCreating QoS");)
       
   691 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1);
   686 
   692 
   687 	RPacketContext& context = iSM->Context();
   693 	RPacketContext& context = iSM->Context();
   688 	RPacketQoS& qoS = iSM->QoS();
   694 	RPacketQoS& qoS = iSM->QoS();
   689 
   695 
   690 	TName name;
   696 	TName name;
   711 */
   717 */
   712 	{
   718 	{
   713 	__ASSERT_DEBUG(iSM,User::Invariant());
   719 	__ASSERT_DEBUG(iSM,User::Invariant());
   714 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   720 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   715 
   721 
   716 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDCREATEQOS_RUNL_1,"Packet Data:\tCompleted with error %d",iStatus.Int());
   722 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tCompleted with error %d");)
       
   723 	__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),iStatus.Int());
   717 
   724 
   718 	if (iStatus==KErrNone)
   725 	if (iStatus==KErrNone)
   719 		{
   726 		{
   720 		iSMObserver->UpdateProgress(EPsdFinishedConfiguration,KErrNone);
   727 		iSMObserver->UpdateProgress(EPsdFinishedConfiguration,KErrNone);
   721 		iSM->BaseEnv().CompleteState(KErrNone);
   728 		iSM->BaseEnv().CompleteState(KErrNone);
   776 */
   783 */
   777 	{
   784 	{
   778 	__ASSERT_DEBUG(iSM,User::Invariant());
   785 	__ASSERT_DEBUG(iSM,User::Invariant());
   779 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   786 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   780 
   787 
   781 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDACTIVATECONTEXT_STARTSTATE_1, "Packet Data:\tActivating context");
   788 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tActivating context");)
   782 	
   789 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1);
   783 
   790 
   784 	iSMObserver->UpdateProgress(EPsdStartingActivation,KErrNone);
   791 	iSMObserver->UpdateProgress(EPsdStartingActivation,KErrNone);
   785 	// Check if the context is already active since in the reconnect case it may be
   792 	// Check if the context is already active since in the reconnect case it may be
   786 	RPacketContext::TContextStatus contextStatus;
   793 	RPacketContext::TContextStatus contextStatus;
   787 	iSM->Context().GetStatus(contextStatus);
   794 	iSM->Context().GetStatus(contextStatus);
   808 */
   815 */
   809 	{
   816 	{
   810 	__ASSERT_DEBUG(iSM,User::Invariant());
   817 	__ASSERT_DEBUG(iSM,User::Invariant());
   811 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   818 	__ASSERT_DEBUG(iSMObserver,User::Invariant());
   812 
   819 
   813 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDACTIVATECONTEXT_RUNL_1, "Packet Data:\tCompleted with error %d",iStatus.Int());
   820 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tCompleted with error %d");)
       
   821 	__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),iStatus.Int());
   814 
   822 
   815 	if( (iSubState==EActivatingContext&&(iStatus==KErrNone || iStatus==KErrNotSupported) )
   823 	if( (iSubState==EActivatingContext&&(iStatus==KErrNone || iStatus==KErrNotSupported) )
   816 		||(iSubState==ELoaningCommPort&&iStatus==KErrNone) ) 
   824 		||(iSubState==ELoaningCommPort&&iStatus==KErrNone) ) 
   817 		{
   825 		{
   818 		if(iSubState==EActivatingContext)
   826 		if(iSubState==EActivatingContext)
   832 				}
   840 				}
   833 			else
   841 			else
   834 				{
   842 				{
   835 				iSMObserver->UpdateProgress(EPsdFinishedActivation,KErrNone);// may want to do this when it really
   843 				iSMObserver->UpdateProgress(EPsdFinishedActivation,KErrNone);// may want to do this when it really
   836 																// activates
   844 																// activates
   837 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDACTIVATECONTEXT_RUNL_2,"Packet Data:\tHanding control to PPP");
   845 				__FLOG_STMT(_LIT8(logString1,"Packet Data:\tHanding control to PPP");)
       
   846 				__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1);
   838 
   847 
   839 				iSMObserver->ServiceStarted();	
   848 				iSMObserver->ServiceStarted();	
   840 				iSM->BaseEnv().CompleteState(KErrNone);
   849 				iSM->BaseEnv().CompleteState(KErrNone);
   841 				}
   850 				}
   842 			}
   851 			}
   931 	//wait for TSY to tell us it has become active. This is because calling Activate()
   940 	//wait for TSY to tell us it has become active. This is because calling Activate()
   932 	//doesn't necessarily mean it's activated in the network - have to wait for PPP to do its
   941 	//doesn't necessarily mean it's activated in the network - have to wait for PPP to do its
   933 	//stuff.
   942 	//stuff.
   934 	RequestStatusChange();
   943 	RequestStatusChange();
   935  
   944  
   936 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDOPEN_STARTSTATE_1, "Packet Data:\tCalling ConnectionComplete");
   945 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tCalling ConnectionComplete");)
   937 
   946 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1());
   938 
   947 
   939 	iSMObserver->Notification(EAgentToNifEventTypeModifyInitialTimer,NULL);
   948 	iSMObserver->Notification(EAgentToNifEventTypeModifyInitialTimer,NULL);
   940 	iSMObserver->UpdateProgress(KConnectionOpen,KErrNone); // I think NIFMAN just swallows this after
   949 	iSMObserver->UpdateProgress(KConnectionOpen,KErrNone); // I think NIFMAN just swallows this after
   941 												// a ConnectComplete(Open)
   950 												// a ConnectComplete(Open)
   942 	iSMObserver->ConnectionComplete(KConnectionOpen,KErrNone);	
   951 	iSMObserver->ConnectionComplete(KConnectionOpen,KErrNone);	
   958 		TRAPD(err, iDbPsd->GetRemotePartyL(remoteParty));
   967 		TRAPD(err, iDbPsd->GetRemotePartyL(remoteParty));
   959 		// logg err
   968 		// logg err
   960 		if(err != KErrNone)
   969 		if(err != KErrNone)
   961 			{
   970 			{
   962 #ifdef __FLOG_ACTIVE
   971 #ifdef __FLOG_ACTIVE
   963 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDOPEN_LOGACTIVE_1, "CPsdOpen:\t Error in getting remote party %d.",err);
   972 			_LIT8(logString1,"CPsdOpen:\t Error in getting remote party %d.");
       
   973 			__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),err);	
   964 #endif
   974 #endif
   965 			}
   975 			}
   966 		iEventLoggerStarted = ETrue;
   976 		iEventLoggerStarted = ETrue;
   967 		if (!iSM->BaseEnv().IsReconnect())
   977 		if (!iSM->BaseEnv().IsReconnect())
   968 			{
   978 			{
  1014 Update progress for open state.
  1024 Update progress for open state.
  1015 */
  1025 */
  1016 	{
  1026 	{
  1017 	__ASSERT_DEBUG(iSM && iSMObserver,User::Invariant());
  1027 	__ASSERT_DEBUG(iSM && iSMObserver,User::Invariant());
  1018 
  1028 
       
  1029 	__FLOG_STMT(_LIT8(logString1,"PacketData:\tStatus change to %s\0");)
       
  1030 
  1019 	if (iStatus==KErrNone)
  1031 	if (iStatus==KErrNone)
  1020 		{
  1032 		{
  1021 		switch (iContextStatus)
  1033 		switch (iContextStatus)
  1022 			{
  1034 			{
  1023 		case RPacketContext::EStatusSuspended:
  1035 		case RPacketContext::EStatusSuspended:
  1024 			{
  1036 			{
  1025 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDOPEN_RUNL_1, "PacketData:\tStatus change to suspended");
  1037 			__FLOG_STMT(const TText8 value[] = "suspended";)
  1026 			
  1038 			__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),&value);
  1027 			iSMObserver->Notification(EAgentToNifEventTypeDisableTimers,NULL);	
  1039 			iSMObserver->Notification(EAgentToNifEventTypeDisableTimers,NULL);	
  1028 			iSMObserver->UpdateProgress(EPsdSuspended,KErrNone);
  1040 			iSMObserver->UpdateProgress(EPsdSuspended,KErrNone);
  1029 			iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_SUSPENDED, KLogPacketDataEventTypeUid);
  1041 			iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_SUSPENDED, KLogPacketDataEventTypeUid);
  1030 			RequestStatusChange();
  1042 			RequestStatusChange();
  1031 			}
  1043 			}
  1033 		case RPacketContext::EStatusActive:
  1045 		case RPacketContext::EStatusActive:
  1034 			{
  1046 			{
  1035 			// if reconnect happened then the logger is allready started and we just do an update
  1047 			// if reconnect happened then the logger is allready started and we just do an update
  1036 			if (!iEventLoggerStarted)
  1048 			if (!iEventLoggerStarted)
  1037 				{
  1049 				{
  1038                 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDOPEN_RUNL_2, "PacketData:\tStatus change to log active");
  1050 				__FLOG_STMT(const TText8 value[] = "log active";)
       
  1051 				__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),&value);
  1039 				WatchForConfigChangesL();	//those 2 functions should have been called in start state but
  1052 				WatchForConfigChangesL();	//those 2 functions should have been called in start state but
  1040 				LogActive();				//RPacketContext was not EStatusActive at that time
  1053 				LogActive();				//RPacketContext was not EStatusActive at that time
  1041 				}
  1054 				}
  1042 			else	// the LogCallStart() has completed 
  1055 			else	// the LogCallStart() has completed 
  1043 				{
  1056 				{
  1044 				iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_CONNECTED, KLogPacketDataEventTypeUid);
  1057 				iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_CONNECTED, KLogPacketDataEventTypeUid);
  1045 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDOPEN_RUNL_3, "PacketData:\tStatus change to active");
  1058 				__FLOG_STMT(const TText8 value[] = "active";)
  1046 				
  1059 				__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),&value);
  1047 				}
  1060 				}
  1048 			iSMObserver->Notification(EAgentToNifEventTypeEnableTimers,NULL);	
  1061 			iSMObserver->Notification(EAgentToNifEventTypeEnableTimers,NULL);	
  1049 			iSMObserver->UpdateProgress(KConnectionOpen,KErrNone);
  1062 			iSMObserver->UpdateProgress(KConnectionOpen,KErrNone);
  1050 			RequestStatusChange();
  1063 			RequestStatusChange();
  1051 			}
  1064 			}
  1052 			break;
  1065 			break;
  1053 		case RPacketContext::EStatusDeactivating:
  1066 		case RPacketContext::EStatusDeactivating:
  1054 			{
  1067 			{
  1055 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDOPEN_RUNL_4, "PacketData:\tStatus change to deactivating");
  1068 			__FLOG_STMT(const TText8 value[] = "deactivating";)
       
  1069 			__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),&value);
  1056 			iSMObserver->UpdateProgress(EPsdStartingDeactivation,KErrNone);
  1070 			iSMObserver->UpdateProgress(EPsdStartingDeactivation,KErrNone);
  1057 			iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_DISCONNECTING, KLogPacketDataEventTypeUid);
  1071 			iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_DISCONNECTING, KLogPacketDataEventTypeUid);
  1058 			RequestStatusChange();			
  1072 			RequestStatusChange();			
  1059 			}
  1073 			}
  1060 			break;
  1074 			break;
  1061 		case RPacketContext::EStatusInactive:
  1075 		case RPacketContext::EStatusInactive:
  1062 			{
  1076 			{
  1063 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDOPEN_RUNL_5, "PacketData:\tStatus change to inactive");
  1077 			__FLOG_STMT(const TText8 value[] = "inactive";)
       
  1078 			__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),&value);
  1064 			iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_DISCONNECTED, KLogPacketDataEventTypeUid);
  1079 			iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_DISCONNECTED, KLogPacketDataEventTypeUid);
  1065 			}
  1080 			}
  1066 			break;
  1081 			break;
  1067 		case RPacketContext::EStatusDeleted:
  1082 		case RPacketContext::EStatusDeleted:
  1068 			{ 
  1083 			{ 
  1069 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDOPEN_RUNL_6, "PacketData:\tStatus change to deleted");
  1084 			__FLOG_STMT(const TText8 value[] = "deleted";)
       
  1085 			__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),&value);
  1070 			iSMObserver->UpdateProgress(EPsdFinishedDeactivation,KErrNone);
  1086 			iSMObserver->UpdateProgress(EPsdFinishedDeactivation,KErrNone);
  1071 			iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_DISCONNECTED, KLogPacketDataEventTypeUid);
  1087 			iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_DISCONNECTED, KLogPacketDataEventTypeUid);
  1072 			}
  1088 			}
  1073 			break;
  1089 			break;
  1074 		case RPacketContext::EStatusActivating:
  1090 		case RPacketContext::EStatusActivating:
  1075 			{
  1091 			{
  1076 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDOPEN_RUNL_7, "PacketData:\tStatus change to activating");
  1092 			__FLOG_STMT(const TText8 value[] = "activating";)
       
  1093 			__FLOG_STATIC1(KPsdAgxLogFolder(),KPsdAgxLogFile(),TRefByValue<const TDesC8>(logString1()),&value);
  1077 			iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_CONNECTING, KLogPacketDataEventTypeUid);
  1094 			iSM->Logger()->LogDataUpdateEvent(R_LOG_CON_CONNECTING, KLogPacketDataEventTypeUid);
  1078 			RequestStatusChange();
  1095 			RequestStatusChange();
  1079 			}
  1096 			}
  1080 			break;
  1097 			break;
  1081 		default:
  1098 		default:
  1176 Function called by the genconn state machine framework to start the state
  1193 Function called by the genconn state machine framework to start the state
  1177 */
  1194 */
  1178 	{
  1195 	{
  1179 	__ASSERT_DEBUG(iSM && iSMObserver,User::Invariant());
  1196 	__ASSERT_DEBUG(iSM && iSMObserver,User::Invariant());
  1180 
  1197 
  1181 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDRECOVERCOMMPORT_STARTSTATE_1, "Packet Data:\tRecovering Comm Port to ETel");
  1198 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tRecovering Comm Port to ETel");)
       
  1199 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1);
  1182 
  1200 
  1183 	iSMObserver->UpdateProgress(EPsdStartingDeactivation,KErrNone);
  1201 	iSMObserver->UpdateProgress(EPsdStartingDeactivation,KErrNone);
  1184 	iSM->Context().RecoverCommPort(iStatus);
  1202 	iSM->Context().RecoverCommPort(iStatus);
  1185 	SetActive();
  1203 	SetActive();
  1186 	}
  1204 	}
  1190 Complete state for Recover comm port state.
  1208 Complete state for Recover comm port state.
  1191 */
  1209 */
  1192 	{
  1210 	{
  1193 	__ASSERT_DEBUG(iSM,User::Invariant());
  1211 	__ASSERT_DEBUG(iSM,User::Invariant());
  1194 	// what can we do with errors at this stage in the game?
  1212 	// what can we do with errors at this stage in the game?
  1195 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDRECOVERCOMMPORT_RUNL_1, "Packet Data:\tRecovered Comm Port");
  1213 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tRecovered Comm Port");)
       
  1214 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1);
  1196 
  1215 
  1197 	iSM->BaseEnv().CompleteState(KErrNone);
  1216 	iSM->BaseEnv().CompleteState(KErrNone);
  1198 	}
  1217 	}
  1199 
  1218 
  1200 void CPsdRecoverCommPort::DoCancel()
  1219 void CPsdRecoverCommPort::DoCancel()
  1258 void CPsdCloseLog::StartState()
  1277 void CPsdCloseLog::StartState()
  1259 /**
  1278 /**
  1260 Function called by the genconn state machine framework to start the state
  1279 Function called by the genconn state machine framework to start the state
  1261 */
  1280 */
  1262 	{
  1281 	{
  1263 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDCLOSELOG_STARTSTATE_1, "Packet Data:\tClosing Log");
  1282 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tClosing Log");)
       
  1283 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1());
  1264 	// We need to make sure that logging is finished before closing everything.
  1284 	// We need to make sure that logging is finished before closing everything.
  1265 	// forward iStatus to the logger, which will be responsible to complete iStatus when it is finished.
  1285 	// forward iStatus to the logger, which will be responsible to complete iStatus when it is finished.
  1266 			iStatus = KRequestPending;
  1286 			iStatus = KRequestPending;
  1267 			SetActive();
  1287 			SetActive();
  1268 	iSM->Logger()->LogDataNotifyLastEventUpdate(&iStatus);
  1288 	iSM->Logger()->LogDataNotifyLastEventUpdate(&iStatus);
  1327 Function called by the genconn state machine framework to start the state
  1347 Function called by the genconn state machine framework to start the state
  1328 */
  1348 */
  1329 	{
  1349 	{
  1330 	__ASSERT_DEBUG(iSM,User::Invariant());
  1350 	__ASSERT_DEBUG(iSM,User::Invariant());
  1331 
  1351 
  1332 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDDEACTIVATION_STARTSTATE_1, "Packet Data:\tDeactivating Context");
  1352 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tDeactivating Context");)
       
  1353 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1);
  1333 
  1354 
  1334 	iSM->Context().Deactivate(iStatus);
  1355 	iSM->Context().Deactivate(iStatus);
  1335 	SetActive();
  1356 	SetActive();
  1336 	}
  1357 	}
  1337 
  1358 
  1340 Complete state for deactivation state.
  1361 Complete state for deactivation state.
  1341 */
  1362 */
  1342 	{
  1363 	{
  1343 	__ASSERT_DEBUG(iSM && iSMObserver,User::Invariant());
  1364 	__ASSERT_DEBUG(iSM && iSMObserver,User::Invariant());
  1344 
  1365 
  1345 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDDEACTIVATION_RUNL_1,"Packet Data:\tDeactivated Context");
  1366 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tDeactivated Context");)
  1346 		
  1367 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1);
       
  1368 	
  1347 	iSMObserver->UpdateProgress(EPsdFinishedDeactivation,KErrNone);
  1369 	iSMObserver->UpdateProgress(EPsdFinishedDeactivation,KErrNone);
  1348 	iSM->BaseEnv().CompleteState(KErrNone);
  1370 	iSM->BaseEnv().CompleteState(KErrNone);
  1349 
  1371 
  1350 	}
  1372 	}
  1351 
  1373 
  1405 Complete Disconnection for closure state.
  1427 Complete Disconnection for closure state.
  1406 */
  1428 */
  1407 	{
  1429 	{
  1408 	__ASSERT_DEBUG(iSM && iSMObserver,User::Invariant());
  1430 	__ASSERT_DEBUG(iSM && iSMObserver,User::Invariant());
  1409 
  1431 
  1410 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPSDCLOSURE_RUNL_1,"Packet Data:\tClosing down");
  1432 	__FLOG_STMT(_LIT8(logString1,"Packet Data:\tClosing down");)
       
  1433 	__FLOG_STATIC(KPsdAgxLogFolder(),KPsdAgxLogFile(),logString1);
  1411 
  1434 
  1412 	RTelServer& etel = iSM->TelServer();
  1435 	RTelServer& etel = iSM->TelServer();
  1413 	RPhone& phone = iSM->Phone();
  1436 	RPhone& phone = iSM->Phone();
  1414 	RPacketService& packetNetwork = iSM->PacketNetwork();
  1437 	RPacketService& packetNetwork = iSM->PacketNetwork();
  1415 	RPacketContext& context = iSM->Context();
  1438 	RPacketContext& context = iSM->Context();