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". |
17 |
17 |
18 /** |
18 /** |
19 @file Nd_directstates.cpp |
19 @file Nd_directstates.cpp |
20 */ |
20 */ |
21 |
21 |
|
22 |
|
23 |
|
24 #include "OstTraceDefinitions.h" |
|
25 #ifdef OST_TRACE_COMPILER_IN_USE |
|
26 #include "ND_DIRECTSTATESTraces.h" |
|
27 #endif |
|
28 |
22 #include "ND_DIRCT.H" |
29 #include "ND_DIRCT.H" |
23 #include "ND_SCR.H" |
30 #include "ND_SCR.H" |
24 #include "ND_DBACC.H" |
31 #include "ND_DBACC.H" |
25 #include "ND_STD.H" |
32 #include "ND_STD.H" |
26 #include "SLOGGER.H" |
|
27 #include "ND_DIRECTSTATES.H" |
33 #include "ND_DIRECTSTATES.H" |
28 |
34 |
29 CDirCtInit* CDirCtInit::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
35 CDirCtInit* CDirCtInit::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
30 /** |
36 /** |
31 Direct Connection Initial State |
37 Direct Connection Initial State |
234 Call ServiceStarted() if not a reconnect. |
240 Call ServiceStarted() if not a reconnect. |
235 */ |
241 */ |
236 { |
242 { |
237 if(iStatus!=KErrNone) |
243 if(iStatus!=KErrNone) |
238 { |
244 { |
239 __FLOG_STMT(_LIT(logString3,"Scan Script");) |
245 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTSCANSCRIPT_RUNL_1,"NetDial:\tCompleted Phase Scan Script with Error %d", iStatus.Int()); |
240 __FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),KCompletedPhaseLogString(), &logString3(), iStatus.Int()); |
|
241 if (iNdEnv->Script()!=NULL) |
246 if (iNdEnv->Script()!=NULL) |
242 iNdEnv->Script()->CloseScript(); |
247 iNdEnv->Script()->CloseScript(); |
243 iSMObserver->ConnectionComplete(ECsdScannedScript,iStatus.Int()); |
248 iSMObserver->ConnectionComplete(ECsdScannedScript,iStatus.Int()); |
244 return; |
249 return; |
245 } |
250 } |
246 |
251 |
247 iSMObserver->UpdateProgress(ECsdScannedScript,iStatus.Int()); |
252 iSMObserver->UpdateProgress(ECsdScannedScript,iStatus.Int()); |
248 if (!(iNdEnv->BaseEnv())->IsReconnect()) |
253 if (!(iNdEnv->BaseEnv())->IsReconnect()) |
249 { |
254 { |
250 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),KServiceStartedLogString()); |
255 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTSCANSCRIPT_RUNL_2, "NetDial:\tService Started"); |
251 } |
256 } |
252 else |
257 else |
253 { |
258 { |
254 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),KServiceStartedReconnLogString()); |
259 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTSCANSCRIPT_RUNL_3,"NetDial:\tService Started On Reconnection"); |
255 } |
260 } |
256 //iSMObserver->ServiceStarted(); |
261 //iSMObserver->ServiceStarted(); |
257 (iNdEnv->BaseEnv())->CompleteState(KErrNone); |
262 (iNdEnv->BaseEnv())->CompleteState(KErrNone); |
258 } |
263 } |
259 |
264 |
429 Complete connect state with KErrNone. |
434 Complete connect state with KErrNone. |
430 */ |
435 */ |
431 { |
436 { |
432 if(iStatus!=KErrNone) |
437 if(iStatus!=KErrNone) |
433 { |
438 { |
434 __FLOG_STMT(_LIT(logString3,"Execute Script");) |
439 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTCONNECT_RUNL_1, "NetDial:\tCompleted Phase Execute Script with Error %d", iStatus.Int()); |
435 __FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),KCompletedPhaseLogString(), &logString3(), iStatus.Int()); |
|
436 if (iNdEnv->Script()!=NULL) |
440 if (iNdEnv->Script()!=NULL) |
437 iNdEnv->Script()->CloseScript(); |
441 iNdEnv->Script()->CloseScript(); |
438 iSMObserver->ConnectionComplete(ECsdFinishedConnect,iStatus.Int()); |
442 iSMObserver->ConnectionComplete(ECsdFinishedConnect,iStatus.Int()); |
439 return; |
443 return; |
440 } |
444 } |
462 @exception Leaves if ExecuteL() leaves. |
466 @exception Leaves if ExecuteL() leaves. |
463 */ |
467 */ |
464 { |
468 { |
465 if (iNdEnv->UseScript()) |
469 if (iNdEnv->UseScript()) |
466 { |
470 { |
467 __FLOG_STMT(_LIT8(logString,"NetDial:\tExecuting Script");) |
471 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTCONNECT_DOSTARTSTATEL_1, "NetDial:\tExecuting Script"); |
468 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString()); |
|
469 |
472 |
470 (iNdEnv->Script())->ExecuteL(*this); |
473 (iNdEnv->Script())->ExecuteL(*this); |
471 iStatus=KRequestPending; |
474 iStatus=KRequestPending; |
472 SetActive(); |
475 SetActive(); |
473 } |
476 } |
565 If script is used, close script. |
568 If script is used, close script. |
566 */ |
569 */ |
567 { |
570 { |
568 __ASSERT_DEBUG(iStatus==KErrNone,User::Invariant()); |
571 __ASSERT_DEBUG(iStatus==KErrNone,User::Invariant()); |
569 iSMObserver->UpdateProgress(ECsdConnectionOpen,KErrNone); |
572 iSMObserver->UpdateProgress(ECsdConnectionOpen,KErrNone); |
570 __FLOG_STMT(_LIT8(logString,"NetDial:\tConnection Open");) |
573 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTOPEN_RUNL_1, "NetDial:\tConnection Open"); |
571 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString()); |
|
572 if (iNdEnv->Script()!=NULL) |
574 if (iNdEnv->Script()!=NULL) |
573 iNdEnv->Script()->CloseScript(); |
575 iNdEnv->Script()->CloseScript(); |
574 iSMObserver->ConnectionComplete(ECsdConnectionOpen,KErrNone); |
576 iSMObserver->ConnectionComplete(ECsdConnectionOpen,KErrNone); |
575 } |
577 } |
576 |
578 |
656 Direct connection hangup completed. |
658 Direct connection hangup completed. |
657 Call UpdateProgress() with ECsdFinishedHangUp and KErrNone. |
659 Call UpdateProgress() with ECsdFinishedHangUp and KErrNone. |
658 Complete hangup state. |
660 Complete hangup state. |
659 */ |
661 */ |
660 { |
662 { |
661 __FLOG_STMT(_LIT(logString3,"Hang Up");) |
|
662 if(iStatus!=KErrNone) |
663 if(iStatus!=KErrNone) |
663 { |
664 { |
664 __FLOG_STMT(_LIT8(logString2,"NetDial:\tDisconnection Error %d");) |
665 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTHANGUP_RUNL_1,"NetDial:\tCompleted Phase Hang Up with Error %d", iStatus.Int()); |
665 __FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int()); |
666 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTHANGUP_RUNL_2, "NetDial:\tDisconnection Error %d", iStatus.Int()); |
666 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC8>(logString2()), iStatus.Int()); |
667 } |
667 } |
668 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTHANGUP_RUNL_3,"Hang Up"); |
668 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString3()); |
|
669 iSMObserver->UpdateProgress(ECsdFinishedHangUp,iStatus.Int()); |
669 iSMObserver->UpdateProgress(ECsdFinishedHangUp,iStatus.Int()); |
670 (iNdEnv->BaseEnv())->CompleteState(iStatus.Int()); |
670 (iNdEnv->BaseEnv())->CompleteState(iStatus.Int()); |
671 } |
671 } |
672 |
672 |
673 CDirCtDisconnect* CDirCtDisconnect::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
673 CDirCtDisconnect* CDirCtDisconnect::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
749 Direct connection disconnect completed. |
749 Direct connection disconnect completed. |
750 If script is used, call ReConfigureAndCancelCommPort(). |
750 If script is used, call ReConfigureAndCancelCommPort(). |
751 Call DisconnectComplete(). |
751 Call DisconnectComplete(). |
752 */ |
752 */ |
753 { |
753 { |
754 __FLOG_STMT(_LIT8(logString,"NetDial:\tDisconnect Complete");) |
754 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTDISCONNECT_RUNL_1, "NetDial:\tDisconnect Complete"); |
755 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString()); |
|
756 |
755 |
757 iSMObserver->DisconnectComplete(); |
756 iSMObserver->DisconnectComplete(); |
758 } |
757 } |
759 |
758 |
760 CDirCtOpenDataPort* CDirCtOpenDataPort::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
759 CDirCtOpenDataPort* CDirCtOpenDataPort::NewL(MAgentStateMachineEnv& aSMObserver, MNetdialEnv& aNdEnv) |
921 { |
920 { |
922 iSMObserver->UpdateProgress(ECsdStartingConnect,KErrNone); |
921 iSMObserver->UpdateProgress(ECsdStartingConnect,KErrNone); |
923 TRAPD(ret,DoStartStateL()); |
922 TRAPD(ret,DoStartStateL()); |
924 if (ret!=KErrNone) |
923 if (ret!=KErrNone) |
925 { |
924 { |
926 __FLOG_STMT(_LIT8(logString, "NetDial:\tError %d Configuring Comm Port");) |
925 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTCONFIGURECOMMPORT_STARTSTATE_1, "NetDial:\tError %d Configuring Comm Port", ret); |
927 __FLOG_STATIC1(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC8>(logString()), ret); |
|
928 JumpToRunl(ret); |
926 JumpToRunl(ret); |
929 } |
927 } |
930 } |
928 } |
931 |
929 |
932 CAgentStateBase* CDirCtConfigureCommPort::NextStateL(TBool aContinue) |
930 CAgentStateBase* CDirCtConfigureCommPort::NextStateL(TBool aContinue) |
953 void CDirCtConfigureCommPort::DoCancel() |
951 void CDirCtConfigureCommPort::DoCancel() |
954 /** |
952 /** |
955 Cancels active requests |
953 Cancels active requests |
956 */ |
954 */ |
957 { |
955 { |
958 __FLOG_STMT(_LIT8(logString, "NetDial:\tCancel Configure Comm Port");) |
956 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTCONFIGURECOMMPORT_DOCANCEL_1,"NetDial:\tCancel Configure Comm Port"); |
959 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),TRefByValue<const TDesC8>(logString())); |
957 |
960 |
958 |
961 (iNdEnv->Script())->CancelConfigureCommPort(); |
959 (iNdEnv->Script())->CancelConfigureCommPort(); |
962 } |
960 } |
963 |
961 |
964 void CDirCtConfigureCommPort::RunL() |
962 void CDirCtConfigureCommPort::RunL() |
968 Complete configure comm port state with KErrNone. |
966 Complete configure comm port state with KErrNone. |
969 */ |
967 */ |
970 { |
968 { |
971 if(iStatus!=KErrNone) |
969 if(iStatus!=KErrNone) |
972 { |
970 { |
973 __FLOG_STMT(_LIT(logString3,"Configuring Comm Port");) |
971 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTCONFIGURECOMMPORT_RUNL_1, "NetDial:\tCompleted Phase Configuring Comm Port with Error %d", iStatus.Int()); |
974 __FLOG_STATIC2(KNetDialLogFolder(),KNetDialLogFile(),KCompletedPhaseLogString(), &logString3(), iStatus.Int()); |
|
975 if (iNdEnv->Script()!=NULL) |
972 if (iNdEnv->Script()!=NULL) |
976 iNdEnv->Script()->CloseScript(); |
973 iNdEnv->Script()->CloseScript(); |
977 iSMObserver->ConnectionComplete(ECsdFinishedConnect,iStatus.Int()); |
974 iSMObserver->ConnectionComplete(ECsdFinishedConnect,iStatus.Int()); |
978 return; |
975 return; |
979 } |
976 } |
986 Retrieves Comm Port configuration parameters from CommsDat and initiates configuration. |
983 Retrieves Comm Port configuration parameters from CommsDat and initiates configuration. |
987 |
984 |
988 @exception Leaves if GetCommConfigForDirectConnectL() leaves. |
985 @exception Leaves if GetCommConfigForDirectConnectL() leaves. |
989 */ |
986 */ |
990 { |
987 { |
991 __FLOG_STMT(_LIT8(logString1,"NetDial:\tConfiguring Comm Port");) |
988 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTCONFIGURECOMMPORT_DOSTARTSTATEL_1,"NetDial:\tConfiguring Comm Port"); |
992 __FLOG_STATIC(KNetDialLogFolder(),KNetDialLogFile(),logString1()); |
989 |
993 (iNdEnv->NetDialDb())->GetCommConfigForDirectConnectL(iConfigPckg); |
990 (iNdEnv->NetDialDb())->GetCommConfigForDirectConnectL(iConfigPckg); |
994 |
991 |
995 iStatus = KRequestPending; |
992 iStatus = KRequestPending; |
996 SetActive(); |
993 SetActive(); |
997 (iNdEnv->Script())->ConfigureCommPort(iStatus, iConfigPckg); |
994 (iNdEnv->Script())->ConfigureCommPort(iStatus, iConfigPckg); |
1048 /** |
1045 /** |
1049 Starts direct connection reconfigure comm port state. |
1046 Starts direct connection reconfigure comm port state. |
1050 Reconfigure port to allow signals to be dropped. |
1047 Reconfigure port to allow signals to be dropped. |
1051 */ |
1048 */ |
1052 { |
1049 { |
1053 __FLOG_STMT(_LIT8(logString, "NetDial:\tReconfiguring Comm Port");) |
1050 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTRECONFIGURECOMMPORT_STARTSTATE_1, "NetDial:\tReconfiguring Comm Port"); |
1054 __FLOG_STATIC(KNetDialLogFolder(), KNetDialLogFile(), logString()); |
|
1055 iStatus = KRequestPending; |
1051 iStatus = KRequestPending; |
1056 SetActive(); |
1052 SetActive(); |
1057 // Reconfigure the Comm Port to allow the signals to be set. |
1053 // Reconfigure the Comm Port to allow the signals to be set. |
1058 (iNdEnv->Script())->ReConfigureAndCancelCommPort(iStatus); |
1054 (iNdEnv->Script())->ReConfigureAndCancelCommPort(iStatus); |
1059 } |
1055 } |
1112 // to drop, not to set up the final Comm Port properly. The final Comm Port configuration will take |
1108 // to drop, not to set up the final Comm Port properly. The final Comm Port configuration will take |
1113 // place in CDirCtConfigureCommPort. |
1109 // place in CDirCtConfigureCommPort. |
1114 if (!iDropping) |
1110 if (!iDropping) |
1115 { |
1111 { |
1116 // ReConfigureAndCancelCommPort() has completed to allow us to drop the Comm Port signals. |
1112 // ReConfigureAndCancelCommPort() has completed to allow us to drop the Comm Port signals. |
1117 __FLOG_STMT(_LIT8(logString, "NetDial:\tDropping Signals");) |
1113 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTRECONFIGURECOMMPORT_RUNL_1, "NetDial:\tDropping Signals"); |
1118 __FLOG_STATIC(KNetDialLogFolder(), KNetDialLogFile(), logString()); |
|
1119 |
1114 |
1120 iDropping = ETrue; |
1115 iDropping = ETrue; |
1121 iStatus = KRequestPending; |
1116 iStatus = KRequestPending; |
1122 SetActive(); |
1117 SetActive(); |
1123 (iNdEnv->Script())->DropSignals(iStatus); |
1118 (iNdEnv->Script())->DropSignals(iStatus); |
1221 // Note: we assume that if iError != KErrNone then ConnectionComplete(error) or CompleteState(error) has |
1216 // Note: we assume that if iError != KErrNone then ConnectionComplete(error) or CompleteState(error) has |
1222 // already been called by the failing state (otherwise NIFMAN will panic due to the lack of a ConnectComplete() |
1217 // already been called by the failing state (otherwise NIFMAN will panic due to the lack of a ConnectComplete() |
1223 // in response to its earlier Connect()). Consequently, we can't call either method with an error argument |
1218 // in response to its earlier Connect()). Consequently, we can't call either method with an error argument |
1224 // for a second time (otherwise NIFMAN will panic due to too many ConnectComplete() responses). |
1219 // for a second time (otherwise NIFMAN will panic due to too many ConnectComplete() responses). |
1225 if (iStatus!=KErrNone) |
1220 if (iStatus!=KErrNone) |
1226 { |
1221 { |
1227 #ifdef __FLOG_ACTIVE |
1222 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTCLOSEDATAPORT_RUNL_1, "NetDial:\tCompleted Phase Close Data Port with Error %d", iStatus.Int()); |
1228 _LIT(logString3,"Close Data Port"); |
|
1229 _LIT8(logstring2,"Saved error = %d"); |
|
1230 #endif |
|
1231 __FLOG_STATIC2(KNetDialLogFolder(), KNetDialLogFile(), TRefByValue<const TDesC>(KCompletedPhaseLogString()), &logString3(), iStatus.Int()); |
|
1232 if (iError != KErrNone) |
1223 if (iError != KErrNone) |
1233 { |
1224 { |
1234 __FLOG_STATIC1(KNetDialLogFolder(), KNetDialLogFile(), TRefByValue<const TDesC8>(logstring2()), iError); |
1225 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CDIRCTCLOSEDATAPORT_RUNL_2,"Saved error = %d", iError); |
1235 } |
1226 } |
1236 else |
1227 else |
1237 { |
1228 { |
1238 // Only do the ConnectionComplete() due to errors in this state if a previous state has not already done |
1229 // Only do the ConnectionComplete() due to errors in this state if a previous state has not already done |
1239 // so (i.e. iError == KErrNone) otherwise NIFMAN will panic. |
1230 // so (i.e. iError == KErrNone) otherwise NIFMAN will panic. |