146 lines
4.9 KiB
C++
146 lines
4.9 KiB
C++
#ifndef _NNTP_NNTPCLIENT_HPP_
|
|
#define _NNTP_NNTPCLIENT_HPP_
|
|
#ifndef _COMMON_BLOCK_HPP_
|
|
#include <common/block.hpp>
|
|
#endif
|
|
#ifndef _COMMON_STRING_HPP_
|
|
#include <common/string.hpp>
|
|
#endif
|
|
#ifndef _SOCKET_INETSOCKETADDRESS_HPP_
|
|
#include <socket/intsaddr.hpp>
|
|
#endif
|
|
#ifndef _SOCKET_SOCKET_HPP_
|
|
#include <socket/socket.hpp>
|
|
#endif
|
|
#ifndef _NNTP_MESSAGEID_HPP_
|
|
#include <nntp/msgid.hpp>
|
|
#endif
|
|
#ifndef _NNTP_GROUPITERATOR_HPP_
|
|
#include <nntp/iterator.hpp>
|
|
#endif
|
|
|
|
class ListItems;
|
|
class GroupItem;
|
|
class SystemTime;
|
|
|
|
class NNTPClient : private INETSocketAddress
|
|
{
|
|
public:
|
|
NNTPClient(void);
|
|
virtual ~NNTPClient();
|
|
bool open(const String &hostName);
|
|
bool open(const String &hostName,const String &user,const String &password);
|
|
bool isConnected(void)const;
|
|
bool listGroup(const String &newsGroup,Block<String> &messageIDStrings);
|
|
bool list(void);
|
|
bool list(ListItems &listItems);
|
|
bool quit(void);
|
|
bool slave(void);
|
|
bool group(GroupItem &groupItem);
|
|
bool xover(DWORD first,DWORD last,Block<String> &overview);
|
|
bool article(DWORD articleNumber,Block<String> &articleText,String &messageID);
|
|
bool article(const MsgID &msgID,Block<String> &articleText,String &messageID);
|
|
bool body(DWORD articleNumber,Block<String> &bodyText,String &messageID);
|
|
bool body(const MsgID &msgID,Block<String> &bodyText,String &messageID);
|
|
bool head(DWORD articleNumber,Block<String> &headText,String &messageID);
|
|
bool head(const MsgID &msgID,Block<String> &headText,String &messageID);
|
|
bool stat(DWORD articleNumber,MsgID &msgID);
|
|
bool stat(const MsgID &msgID,MsgID &msgFound);
|
|
bool simulateNewNews(const String &newsGroup,Block<String> &messageIDStrings,short pastDays);
|
|
bool newNews(Block<String> &newsGroups,Block<String> &distributionGroups,Block<String> &messageIDStrings,const SystemTime &systemTime,WORD isGMT);
|
|
bool newNews(const String &newsGroup,Block<String> &messageIDStrings,short pastDays=0);
|
|
bool newGroups(ListItems &listItems,Block<String> &distributionGroups,const SystemTime &systemTime,bool isGMT);
|
|
bool newGroups(ListItems &listItems,short pastDays=0);
|
|
bool next(GroupIterator &groupIterator);
|
|
bool last(GroupIterator &groupIterator);
|
|
bool iHave(const MsgID &msgID);
|
|
bool help(Block<String> &cmdLines);
|
|
bool post(Block<String> &articleLines);
|
|
void cancel(void);
|
|
protected:
|
|
virtual void message(String messageString);
|
|
virtual void message(Block<String> &messageStrings);
|
|
private:
|
|
enum NNTPCmd{Article,Body,Group,Head,Help,IHave,Last,List,NewGroups,NewNews,Next,Post,Quit,Slave,Stat,ListGroup,AuthInfoUser,AuthInfoPass,XOver};
|
|
NNTPClient(const NNTPClient &someNNTPClient);
|
|
NNTPClient &operator=(const NNTPClient &someNNTPClient);
|
|
void createCmds(void);
|
|
void createResponseStrings(void);
|
|
void receiveStrings(WORD displayStrings=FALSE);
|
|
void receiveStrings(Block<String> &receiveStrings);
|
|
void daysPast(SystemTime &systemTime,short pastDays);
|
|
void makeTimeDateString(String &timeDateString,const SystemTime &systemTime);
|
|
bool retrieveBlock(const String &controlData,Block<String> &stringBlock,Block<String> &ackResponse,Block<String> &nackResponse);
|
|
bool retrieveBlock(const String &controlData,Block<String> &stringBlock,String &extraInfo,Block<String> &ackResponse,Block<String> &nackResponse);
|
|
bool isInResponse(const String &responseString,Block<String> &responseStrings);
|
|
bool putControlData(const String &stringData,bool waitForResponse=true);
|
|
bool authenticate(const String &user,const String &pass);
|
|
bool getControlData(void);
|
|
|
|
Block<String> mNNTPCmds;
|
|
Block<String> mAckArticleResponseStrings;
|
|
Block<String> mNackArticleResponseStrings;
|
|
Block<String> mAckSlaveResponseStrings;
|
|
Block<String> mAckGroupResponseStrings;
|
|
Block<String> mNackGroupResponseStrings;
|
|
Block<String> mAckListResponseStrings;
|
|
Block<String> mAckQuitResponseStrings;
|
|
Block<String> mAckNewNewsResponseStrings;
|
|
Block<String> mAckNewGroupsResponseStrings;
|
|
Block<String> mAckNextResponseStrings;
|
|
Block<String> mAckIHaveResponseStrings;
|
|
Block<String> mAckHelpResponseStrings;
|
|
Block<String> mAckPostResponseStrings;
|
|
Block<String> mAckAuthResponseStrings;
|
|
Block<String> mAckXOverResponseStrings;
|
|
Block<String> mNakConnectStrings;
|
|
String mPeriod;
|
|
String mSpace;
|
|
String mComma;
|
|
String mLeftAngle;
|
|
String mRightAngle;
|
|
Socket mNNTPControl;
|
|
WSASystem mWSASystem;
|
|
};
|
|
|
|
inline
|
|
NNTPClient::NNTPClient(void)
|
|
: mPeriod("."), mSpace(" "), mComma(","), mLeftAngle("<"), mRightAngle(">")
|
|
{
|
|
createCmds();
|
|
createResponseStrings();
|
|
}
|
|
|
|
inline
|
|
NNTPClient::NNTPClient(const NNTPClient &/*someNNTPClient*/)
|
|
: mPeriod("."), mSpace(" "), mComma(","), mLeftAngle("<"), mRightAngle(">")
|
|
{ // no implementation
|
|
}
|
|
|
|
inline
|
|
NNTPClient::~NNTPClient()
|
|
{
|
|
quit();
|
|
mNNTPControl.destroy();
|
|
}
|
|
|
|
inline
|
|
NNTPClient &NNTPClient::operator=(const NNTPClient &/*someNNTPClient*/)
|
|
{ // no implementation
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
bool NNTPClient::isConnected(void)const
|
|
{
|
|
return mNNTPControl.isConnected();
|
|
}
|
|
|
|
inline
|
|
void NNTPClient::cancel(void)
|
|
{
|
|
if(isConnected())quit();
|
|
mNNTPControl.destroy();
|
|
}
|
|
#endif
|