/*************************************************************************\
* "$RCSfile: CNetwork.hpp,v $"                                            *
***************************************************************************
* Information by CVS or VSS:                                              *
*     Last check in on: $Date: 2010-10-04 14:03:08 $                      *
*     by                $Author: schluckebier $
*     Revision        : $Revision: 1.1 $                                 *
\*************************************************************************/
/*! \file CNetwork.hpp
*	\brief Interface for the CNetwork class
*	\addtogroup Ethernet
*	\{
**************************************************************************/

#ifndef _CNETWORK_H_
#define _CNETWORK_H_

#include "Config.h"
#include "FTP.h"

#define TCP_DISPLAY_PORT 2001	//!< Port for TCP display
#define UDP_PORT_IN 49152		//!< Port for UDP broadcast
#define UDP_PORT_OUT 49153		//!< Port for UDP broadcast

/*************************************************************************/
class CNetwork
/*************************************************************************/
/*! @brief Network class

	Initializes Ethernet and creates DVI-/TCP-display.
	@par Example:
	@code
int bDviDisplay, bGBitDisplay;
CIMAGE DisplayPic;
CNetwork cNet;

cNet.InitDisplay(&DisplayPic, &bDviDisplay, &bGBitDisplay);
{...}
if (bGBitDisplay)
	cNet.Stop();
	@endcode
**************************************************************************/
{
public:
	CNetwork();

	void InitDisplay(CIMAGE *pImage, int *pDviDisplay, int *pGBitDisplay, int DefaultWidth=800, int DefaultHeight=600);
	int Init(CIMAGE *pDisplayPic);
	void Stop();

	//! Get IP-Address.
	char *GetIpAdr() { return m_IPAdr; }
	//! Get Serial number.
	char *GetSerial() { return m_SerialNumber; }
	//! Get Display device.
	VIB_DISPLAYDEVICE *GetDisplayDevice() { return &m_DisplayA; }

protected:
	static void TaskDisplay(VIB_DISPLAYDEVICE *pTcpDisplay, CIMAGE *pDisplayPic);
	static void TaskUDPBroadcast(CNetwork *pThis);

	int AddWebFolder(const char *Folder, const char *DstFolder, bool IsTopDir);
	int AddWebFile(const char *SrcFileName, const char *DstFileName);
	void AddIndexHtml(int DisplayWidth, int DisplayHeight, int DisplayPort);
	int ChangeIpAddr(const char *pIpAddr);

	Ftp *m_pFtp;				//!< FTP server
	char m_IPAdr[32];			//!< IP address
	char m_SerialNumber[64];	//!< Serial number of VisionBox
	int m_NetShowLinks;			//!< Show links to FTP and socket information
	int m_NetAutoRedraw;		//!< Create TaskDisplay()
	Config *m_EthernetIni;		//!< .ini file to control the Ethernet interface
	GUI_DISPLAY m_GuiDisplay;	//!< GUI display
	VIB_DISPLAYDEVICE m_DisplayA;	//!< Display A
	VIB_DISPLAYDEVICE m_DisplayB;	//!< Display B
	VIB_DISPLAYDEVICE m_TcpDisplay;	//!< TCP Display
};
// \}
/*************************************************************************/
#endif
