#ifndef _NNTP_NNTPCLIENT_HPP_ #define _NNTP_NNTPCLIENT_HPP_ #ifndef _COMMON_BLOCK_HPP_ #include #endif #ifndef _COMMON_STRING_HPP_ #include #endif #ifndef _SOCKET_INETSOCKETADDRESS_HPP_ #include #endif #ifndef _SOCKET_SOCKET_HPP_ #include #endif #ifndef _NNTP_MESSAGEID_HPP_ #include #endif #ifndef _NNTP_GROUPITERATOR_HPP_ #include #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 &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 &overview); bool article(DWORD articleNumber,Block &articleText,String &messageID); bool article(const MsgID &msgID,Block &articleText,String &messageID); bool body(DWORD articleNumber,Block &bodyText,String &messageID); bool body(const MsgID &msgID,Block &bodyText,String &messageID); bool head(DWORD articleNumber,Block &headText,String &messageID); bool head(const MsgID &msgID,Block &headText,String &messageID); bool stat(DWORD articleNumber,MsgID &msgID); bool stat(const MsgID &msgID,MsgID &msgFound); bool simulateNewNews(const String &newsGroup,Block &messageIDStrings,short pastDays); bool newNews(Block &newsGroups,Block &distributionGroups,Block &messageIDStrings,const SystemTime &systemTime,WORD isGMT); bool newNews(const String &newsGroup,Block &messageIDStrings,short pastDays=0); bool newGroups(ListItems &listItems,Block &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 &cmdLines); bool post(Block &articleLines); void cancel(void); protected: virtual void message(String messageString); virtual void message(Block &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 &receiveStrings); void daysPast(SystemTime &systemTime,short pastDays); void makeTimeDateString(String &timeDateString,const SystemTime &systemTime); bool retrieveBlock(const String &controlData,Block &stringBlock,Block &ackResponse,Block &nackResponse); bool retrieveBlock(const String &controlData,Block &stringBlock,String &extraInfo,Block &ackResponse,Block &nackResponse); bool isInResponse(const String &responseString,Block &responseStrings); bool putControlData(const String &stringData,bool waitForResponse=true); bool authenticate(const String &user,const String &pass); bool getControlData(void); Block mNNTPCmds; Block mAckArticleResponseStrings; Block mNackArticleResponseStrings; Block mAckSlaveResponseStrings; Block mAckGroupResponseStrings; Block mNackGroupResponseStrings; Block mAckListResponseStrings; Block mAckQuitResponseStrings; Block mAckNewNewsResponseStrings; Block mAckNewGroupsResponseStrings; Block mAckNextResponseStrings; Block mAckIHaveResponseStrings; Block mAckHelpResponseStrings; Block mAckPostResponseStrings; Block mAckAuthResponseStrings; Block mAckXOverResponseStrings; Block 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