linklayerprotocols/pppnif/te_ppp/inc/DummyAgtRef.h
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Defines the interface to a "dummy" Nifman Agent Ref.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #ifndef __DUMMYAGTREF_H__
       
    23 #define __DUMMYAGTREF_H__
       
    24 
       
    25 #include "nifagt.h"
       
    26 #include "nifif.h"
       
    27 #include "es_ini.h"
       
    28 #include <testexecutelog.h>
       
    29 #include <testexecutestepbase.h>
       
    30 #include "common.h"
       
    31 
       
    32 class CTestMgr;
       
    33 class CDummyProtocol;
       
    34 class CESockIniData;
       
    35 class CCommonData;
       
    36 
       
    37 class CDummyNifAgentRef : public CBase,
       
    38 								 public MNifAgentNotify,
       
    39 								 public MNifIfNotify
       
    40 {
       
    41 public:
       
    42 	static CDummyNifAgentRef* NewL(const TDesC& aName,CTestMgr& aTheMgr, CTestExecuteLogger& aLogger);
       
    43 	~CDummyNifAgentRef();
       
    44 	//
       
    45 	bool CreateIniReader();
       
    46 	void DestroyIniReader();
       
    47 	//
       
    48 	// MNifIfNotify overrides
       
    49     virtual void LinkLayerDown(TInt aReason, TAction aAction);
       
    50 	virtual void LinkLayerUp();
       
    51     virtual void NegotiationFailed(CNifIfBase* aIf, TInt aReason);
       
    52     virtual TInt Authenticate(TDes& aUsername, TDes& aPassword);
       
    53     virtual void CancelAuthenticate();
       
    54 	virtual TInt GetExcessData(TDes8& aBuffer);
       
    55     virtual void IfProgress(TInt aStage, TInt aError);
       
    56     virtual void IfProgress(TSubConnectionUniqueId aSubConnectionUniqueId, TInt aStage, TInt aError);
       
    57 	virtual void OpenRoute();
       
    58 	virtual void CloseRoute();
       
    59 	virtual TInt Notification(TNifToAgentEventType aEvent, void* aInfo);
       
    60 	virtual void BinderLayerDown(CNifIfBase* aBinderIf, TInt aReason, TAction aAction);
       
    61 	virtual TInt PacketActivity(TDataTransferDirection aDirection, TUint aBytes, TBool aResetTimer);
       
    62 	virtual void NotifyDataSent(TSubConnectionUniqueId aSubConnectionUniqueId, TUint aUplinkVolume);
       
    63 	virtual void NotifyDataReceived(TSubConnectionUniqueId aSubConnectionUniqueId, TUint aDownlinkVolume);
       
    64 	virtual void NifEvent(TNetworkAdaptorEventType aEventType, TUint aEvent, const TDesC8& aEventData, TAny* aSource=0);
       
    65 
       
    66 	//
       
    67 	// MNifAgentNotify overrides
       
    68 	virtual void ConnectComplete(TInt aStatus);
       
    69 	virtual void ReconnectComplete(TInt aStatus);
       
    70 	virtual void AuthenticateComplete(TInt aStatus);
       
    71 	virtual void ServiceStarted();
       
    72 	virtual void ServiceClosed();
       
    73 	virtual void DisconnectComplete();
       
    74 	virtual void AgentProgress(TInt aStage, TInt aError);
       
    75 	virtual	void AgentProgress(TSubConnectionUniqueId aSubConnectionUniqueId, TInt aStage, TInt aError);
       
    76 	virtual TInt Notification(TAgentToNifEventType aEvent, TAny* aInfo);
       
    77 	virtual TInt IncomingConnectionReceived();
       
    78 	virtual void AgentEvent(TNetworkAdaptorEventType aEventType, TUint aEvent, const TDesC8& aEventData, TAny* aSource=0);
       
    79     virtual TName Name() const;
       
    80 	virtual void Close();
       
    81 
       
    82 	void Stop();
       
    83 
       
    84 protected:
       
    85 	virtual TInt DoReadInt(const TDesC& aField, TUint32& aValue,const RMessagePtr2* aMessage);
       
    86     virtual TInt DoWriteInt( const TDesC& aField, TUint32 aValue,const RMessagePtr2* aMessage);
       
    87     virtual TInt DoReadDes(const TDesC& aField, TDes8& aValue,const RMessagePtr2* aMessage);
       
    88     virtual TInt DoWriteDes(const TDesC& aField, const TDesC8& aValue,const RMessagePtr2* aMessage);
       
    89     virtual TInt DoReadDes(const TDesC& aField, TDes16& aValue,const RMessagePtr2* aMessage);
       
    90     virtual TInt DoWriteDes(const TDesC& aField, const TDesC16& aValue,const RMessagePtr2* aMessage);
       
    91 	virtual TInt DoReadBool(const TDesC& aField, TBool& aValue,const RMessagePtr2* aMessage);
       
    92     virtual TInt DoWriteBool( const TDesC& aField, TBool aValue,const RMessagePtr2* aMessage);
       
    93 
       
    94 private:
       
    95 	/**
       
    96 	CNifAgentRef implements a state machine. 
       
    97 	Dummy NifAgentRef implements a simplified version of that state machine, sufficient for	testing with ANVL.  
       
    98 	This enum should be extended as necessary.	*/
       
    99 	enum TState
       
   100 		{
       
   101 		/** Link layer is up: NIF is Up. */
       
   102 		ELinkUp,
       
   103 		/** Link layer is in the process of being stopped: NIF is negotiating termination */
       
   104 		EStopping,
       
   105 		/** Link layer is down: NIF has terminated */
       
   106 		EStopped	
       
   107 		};
       
   108 private:
       
   109 	//
       
   110 	CDummyNifAgentRef(const TDesC& aName,CTestMgr& aTheMgr, CTestExecuteLogger& aLogger);
       
   111 	void ConstructL();
       
   112 	void ServiceStartedL();
       
   113 	//attributes
       
   114 	TDesC iName;
       
   115 	CNifIfLink* iInterface;
       
   116 	CNifIfBase* iInterfaceBound;
       
   117 	CTestMgr& iTheMgr;
       
   118 	CDummyProtocol* ipDummyPrt; //psydo protocol to bind with the ppp.
       
   119 	CESockIniData* ipIniFileReader;
       
   120 	CTestExecuteLogger iLogger;
       
   121 	CCommonData iData;
       
   122 	/** The state of the AgentRef (Reflects the state of the NIF associated with the AgentRef. */
       
   123 	TState iState;
       
   124 };
       
   125 
       
   126 //
       
   127 //inlines
       
   128 inline bool
       
   129 CDummyNifAgentRef::CreateIniReader()
       
   130 {
       
   131 		//if the it's imposible to open ppp.ini -> will use hardcoded info
       
   132 	TRAPD(result,ipIniFileReader=CESockIniData::NewL(iData.KPppIniFullPath));
       
   133 	if (result != KErrNone)
       
   134 	{
       
   135 		ipIniFileReader=0;
       
   136 	}
       
   137 	
       
   138 	return ipIniFileReader != 0 ;
       
   139 }
       
   140 
       
   141 inline void
       
   142 CDummyNifAgentRef::DestroyIniReader()
       
   143 {
       
   144 		delete ipIniFileReader;
       
   145 }
       
   146 
       
   147 #endif //__DUMMYAGTREF_H__