/******************************************************************************
 GPOPRetriever.h

	Interface for the GPOPRetriever class

	Copyright © 1998 by Glenn W. Bach.  All rights reserved.
	
	Base code generated by Codemill v0.1.0

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

#ifndef _H_GPOPRetriever
#define _H_GPOPRetriever

#include <JBroadcaster.h>
#include <JMessageProtocol.h>	

#include <JString.h>	
#include <JPtrArray.h>	
#include <JProcess.h>	

#include <jTypes.h>

#include <ace/INET_Addr.h>
#include <ace/UNIX_Addr.h>

#include <ace/SOCK_Connector.h>
#include <ace/SOCK_Stream.h>

class JXGetPasswordDialog;
class JXTimerTask;

class GPOPRetriever : virtual public JBroadcaster
{
public:

	GPOPRetriever();
	virtual ~GPOPRetriever();

	void	CheckMail();
	
protected:

	virtual void	Receive(JBroadcaster* sender,
								const JBroadcaster::Message& message);

private:

	typedef JMessageProtocol<ACE_SOCK_STREAM>	InetLink;

private:

	InetLink*				itsLink;
	JXGetPasswordDialog* 	itsDialog;
	JString 				itsPasswd;
	JString					itsTimeStamp;
	JIndex					itsCurrentIndex;
	JIndex					itsCurrentMode;
	JCoordinate				itsMessageCount;
	JBoolean				itsMessageFinished;
	JBoolean				itsMessageStarting;
	JString*				itsMessageBuffer;
	JPtrArray<JString>*		itsBuffers;
	JBoolean				itsListStarting;
	JIndex					itsListLinesCount;
	JPtrArray<JString>*		itsReadUIDList;
	JPtrArray<JString>*		itsUIDList;
	JArray<JIndex>*			itsNewUIDIndexes;
	JXTimerTask*			itsTimerTask;
	JXTimerTask*			itsDeleteTask;
	JProcess*				itsProcmailProcess;

private:

	void		SendLine(const JCharacter* line);
	void		SendLine(const JString& line);

	void		HandleUIDL();
	JString		EncryptedTimeAndPass();

	void		ConnectToServer();
	void		ReadReturnValue();
	void		SendNextData();
	JBoolean	SaveMessage();

	// not allowed

	GPOPRetriever(const GPOPRetriever& source);
	const GPOPRetriever& operator=(const GPOPRetriever& source);

public:

};


#endif
