telephonyprotocols/csdagt/script/SSCREXEC.H
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 /**
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Script Executor Header.
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file Sscrexec.h
       
    24  @internalComponent
       
    25 */
       
    26 
       
    27 #ifndef __SSCREXEC_H__
       
    28 #define __SSCREXEC_H__
       
    29 
       
    30 #include <d32comm.h>
       
    31 #include <etel.h>
       
    32 #include <comms-infras/dialogprocessor.h>
       
    33 #include "ND_STD.H"
       
    34 #include "SCOMMAND.H"
       
    35 
       
    36 const TInt KMaxReadBufferLength=100;
       
    37 const TInt KNumCommands=9;	///< number of derived command classes in SCommand.h
       
    38 
       
    39 struct SErrorVariable
       
    40 	{
       
    41 	const TText* iString;
       
    42 	TInt iValue;
       
    43 	};
       
    44 
       
    45 // Forward declarations
       
    46 
       
    47 class CScriptIO;
       
    48 class CScriptCharacterConverter;
       
    49 class CNetDialScript;
       
    50 class CGotoCommand;
       
    51 class CWaitCommand;
       
    52 class CLoopCommand;
       
    53 class CReadPCTCommand;
       
    54 class CScriptCommandBase;
       
    55 class CScriptReader;
       
    56 class CScriptVarMan;
       
    57 class CScriptLabelMan;
       
    58 class CScriptCharacterConverter;
       
    59 
       
    60 
       
    61 class CScriptExecutor : public CActive
       
    62 /**
       
    63 One per CNetDialScript object.  Has one of all script commands and label and variable managers.
       
    64 Controls execution of the scripts.
       
    65 
       
    66 @internalComponent
       
    67 */
       
    68 	{
       
    69 public:
       
    70 	static CScriptExecutor* NewL(CNetDialScript* aScript,const TDesC& aCommChannel, TInt aScriptLength);
       
    71 	CScriptExecutor(CNetDialScript* aScript);
       
    72 	~CScriptExecutor();
       
    73 	//
       
    74 	void SetLoginParams(const TDesC& aLoginName,const TDesC& aLoginPass);
       
    75 	void SetScript(const TDesC& aScript);
       
    76 	void ScanScriptL();
       
    77 	void RunScript();
       
    78 	
       
    79 	static TInt StartScript(TAny* aPtr);
       
    80 	void ProcessScript();
       
    81 	void CompletedWrite(TInt aStatus);
       
    82 	void CompletedReadL(TInt aStatus,TInt aIndex =0);
       
    83 	void Disconnect();
       
    84 	void CreateChannel(TRequestStatus& aStatus);
       
    85 	void CancelCreateChannel();
       
    86 	void ShutdownChannel(TRequestStatus& aStatus);
       
    87 	void ReConfigureAndCancelCommPort(TRequestStatus& aStatus);
       
    88 	void DropSignals(TRequestStatus& aStatus);
       
    89 	void CloseScript();
       
    90 	void Close();
       
    91 	inline TBool IsScriptSet() const;
       
    92 	//
       
    93 	TInt WritePct(const TDesC8& aBuffer);
       
    94 	void ReadPct();
       
    95 	void ReadPctComplete(TInt aStatus);
       
    96 	void DestroyPctNotificationReceived(TInt aStatus);
       
    97 	void PctCancelAndClose();
       
    98 	void SetReadFromPctPending(TBool aPending);
       
    99 	inline TBool ReadFound() const;
       
   100 	inline TBool ReadPctPending() const;
       
   101 	inline TBool RequestUsePct() const;
       
   102 	//
       
   103 	void SetVariableL(const TDesC& aName, const TDesC& aContent);
       
   104 	void ConfigureCommPort(TRequestStatus& aStatus, const TCommConfig& aConfiguration);
       
   105 	void CancelConfigureCommPort();
       
   106 	void DropDTR(TRequestStatus* aStatusPtr);
       
   107 
       
   108 	inline const TDesC& BcaStack() const;
       
   109 	inline TInt IapId() const;
       
   110 	TInt GetExcessData(TDes8& aBuffer);
       
   111 
       
   112 	void SetRetransmittedLoginTimeout(TReal& aRetransmitLoginTimeOut);
       
   113 protected:
       
   114 	// derived from CActive
       
   115 	void RunL();
       
   116 	void DoCancel();
       
   117 private:
       
   118 	void ConstructL(const TDesC& aCommChannel, TInt aScriptLength);
       
   119 	void ProcessNextLinesL();
       
   120 	void SetReadPctBuffer();
       
   121 	void CompletedScript(TInt aStatus);
       
   122 	void CleanupLastCommand();
       
   123 	void ConvertScriptError(TInt& aError) const;
       
   124 private:
       
   125 	CScriptIO* iScriptIO;
       
   126 	CGotoCommand* iGotoCommand;
       
   127 	CWaitCommand* iWaitCommand;
       
   128 	CLoopCommand* iLoopCommand;
       
   129 	CReadPCTCommand* iReadCommand;
       
   130 	CScriptCommandBase* iCommands[KNumCommands];
       
   131 	CScriptCommandBase* iLastCommand;
       
   132 	CScriptReader* iScriptReader;
       
   133 	CScriptVarMan* iVarMan;
       
   134 	CScriptLabelMan* iLabelMan;
       
   135 	CScriptCharacterConverter* iCharConv;
       
   136 	CNetDialScript* iScript;
       
   137 	TBool iInitializationFlag;
       
   138 	enum {
       
   139 		EFirstWaitCommand,
       
   140 		ESendingCR,
       
   141 		ESecondWaitCommand,
       
   142 		EDeactivated
       
   143 		} iServerRetransmitLoginPromptStatus;
       
   144 	CLabelSearchArray* iDummySearchArray;
       
   145 	TReal iRetransmitLoginTimeOut;
       
   146 	enum {
       
   147 		EIdle,
       
   148 		ERunning
       
   149 		} iScriptStatus;
       
   150 	TBool iReadFound;
       
   151 	TInt iReadReq;
       
   152 	TBool iReadFromPctPending;
       
   153 	TBuf<KMaxReadBufferLength> iReadBuffer;		///< This is a straight ASCII or UNICODE buffer - no fancy character sets!
       
   154 	TBuf8<KTxBufferSize> iDataToWrite;			///< This is an 8 bit buffer with characters converted appropriately
       
   155 //	Need for test dialog server only
       
   156 	TBuf<KCommsDbSvrMaxUserIdPassLength> iLoginName;
       
   157 	TBuf<KCommsDbSvrMaxUserIdPassLength> iLoginPass;
       
   158 	};
       
   159 
       
   160 #include "SSCREXEC.INL"
       
   161 
       
   162 #endif