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