/*****************************************************************************
* Copyright (c) 1990-98 Digi International Inc., All Rights Reserved
* 
* This software contains proprietary and confidential information of Digi
* International Inc.  By accepting transfer of this copy, Recipient agrees
* to retain this software in confidence, to prevent disclosure to others,
* and to make no use of this software other than that for which it was
* delivered.  This is an unpublished copyrighted work of Digi International
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
* prohibited.
* 
* Restricted Rights Legend
*
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
* Technical Data and Computer Software clause at DFARS 252.227-7031 or
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -
* Restricted Rights at 48 CFR 52.227-19, as applicable.
*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
*
*****************************************************************************/
// ProtocolX25.h: interface for the CProtocolX25 class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PROTOCOLX25_H__BA2DE9F1_2BB0_11D2_BFB9_00401C6095EC__INCLUDED_)
#define AFX_PROTOCOLX25_H__BA2DE9F1_2BB0_11D2_BFB9_00401C6095EC__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "protocol.h"
#include "defs.h"
#include "utils.h"
#include "WizPageComboBox.h"
#include "WizPageRadioButtons.h"
#include "TreeNode.h"
#include "x25cfg.h"
#include "router.h"
class SERVICE_EXPORTED_CLASS CProtocolX25 : public CProtocol  
{
	DECLARE_DYNAMIC(CProtocolX25)
public:
	CProtocolX25(HKEY const hKeyRoot, CString const strRegPath, CConfigObject const * const pParent);
	virtual ~CProtocolX25();
	virtual BOOL GetParameters(void);
	virtual BOOL SetParameters(void);
	virtual BOOL RemoveParameters(BOOL fRemoveKey = FALSE);

	virtual BOOL AddWizardPages(CConfigWizSheet * const pSheet);
	virtual BOOL NextWizardPage(int const nState);

	virtual BOOL AddChild(void){ASSERT(FALSE);return FALSE;}
	virtual BOOL DoProperties(void);
	virtual CString GetInformationText(void);
	virtual BOOL BuildDisplayTree(CTreeNode * const pNode);

	virtual void ObjectToTrash(void);
	virtual void ObjectFromTrash(void);
	virtual INT_PTR GetConfiguredPorts(void);

	BOOL AllocPVC();
	void DeAllocPVC();
	DWORD GetLineSpeed() const;
	DWORD GetWindowSize() const;
	void GetPVCChannelData(DWORD& start,DWORD& count) const;
	void GetPacketandWindowData(int& RemWindow,int& RemPacket,int& LocWindow,int& LocPacket) const;
	int GetPVCStartChannel() const {return m_X25.LPC;}

	int GetTotalSVCs(void) { return CountChannels(SVC); }
	INT_PTR GetConfiguredPVCs(void) { return PVCCount; }

private:
	enum CHANNELTYPE { BOTH,SVC,PVC};

	BOOL ReadWriteLapbParams(REGMODE emode);
	BOOL ReadWriteX25Params(REGMODE emode);
	BOOL AddWizLapbPage();
	BOOL AddWizGeneralPage();
	BOOL AddWizChannelPage();
	void GetInfoFromWizLapbPage();
	void GetInfoFromWizGeneralPage();
	void GetInfoFromWizChannelPage();
	void CreateRouter();
	int  CountChannels(CHANNELTYPE ctype);
	int GetPortLimit();

// attributes
private:
   void SetX25LAPBConfig();
   void GetX25LAPBConfig();
	LAPB m_WorkingLAPB;     // Used in place of global data, passed in to all prop pages
	X25  m_WorkingX25;      // Used in place of global data, passed in to all prop pages
	LAPB m_LAPB;            // Current settings, used as a base for the working copies
	X25  m_X25;             // Current settings, used as a base for the working copies

#if defined NT5
	// For NT5, the channel limit is only related to the line, not the adapter/router
	INT_PTR PVCCount;
#else // #if defined NT5
	static int PVCCount;
#endif // #if defined NT5
	static int m_nReferenceCount;
	static CX25Router* m_pRouter;
	static CConfigObject* m_pInstance;

	DWORD m_dwLineSpeed;
    CConfigWizSheet * m_pwsSheet;
	CWizPageRadioButtons* m_pwpLapbPage;
	CX25General* m_pwpGeneralPage;
	CX25Channel* m_pwpChannelPage;
	enum
	{WP_LAPBSEQUENCE,WP_X25GENERAL,WP_X25CHANNELS};
	CString m_strDeviceName;

};

#endif // !defined(AFX_PROTOCOLX25_H__BA2DE9F1_2BB0_11D2_BFB9_00401C6095EC__INCLUDED_)
