/*************************************************************************\
* "$RCSfile: CSmtp.hpp,v $"                                               *
***************************************************************************
* Information by CVS or VSS:                                              *
*     Last check in on: $Date: 2010-06-16 10:21:39 $                      *
*     by                $Author: schluckebier $
*     Revision        : $Revision: 1.5 $                                  *
\*************************************************************************/
/*! \file CSmtp.hpp
*	\brief Header CSmtp Class
**************************************************************************/

/*************************************************************************/
/*! @brief SMTP class

	Implements the simple mail transfer protocol.
**************************************************************************/
class CSmtp
{
private:
	CSmtp();
	~CSmtp();
	static CSmtp *m_pThis;

public:
	static CSmtp *CreateInstance();
	//! Gets CSmtp instance.
	static CSmtp *GetInstance() { return m_pThis; }
	static void DisposeInstance();
	int Send(const char *pText, int Level = 10);
	void SetMailServer(const char *pAddress, int Port);
	void SetMailAddress(const char *pMailAddress);
	void SetRecepientAddress(const char *pMailAddress);
	//! Enables sending of mails.
	void SetEnable(int Ena) { m_StatusEmailLevel = Ena; }

protected:
	int SendData(SOCKET s, char *pBuffer);
	static void TaskSendMail();

	static SEM_Handle m_SendSem;
	struct sockaddr_in m_Socket_SMTP_Addr;
	char m_MailAddress[128];
	char m_Recepient[128];
	char m_Subject[128];
	char *m_Text;
	int m_StatusEmailLevel;
	bool m_bSendTaskActive;
};

/*************************************************************************/
