X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnntp%2Fnntpconnection.cpp;h=d7eaa7022adc13ebf662f0d0059dc53cf57b9453;hb=f208e33c29132aacaec448e74341edea1b925a2a;hp=5ee97767d2bdddb262c2707dd6442231be05fdb1;hpb=6b896a9e1dc143bba86795be1e9336549db9b85f;p=fms.git diff --git a/src/nntp/nntpconnection.cpp b/src/nntp/nntpconnection.cpp index 5ee9776..d7eaa70 100644 --- a/src/nntp/nntpconnection.cpp +++ b/src/nntp/nntpconnection.cpp @@ -7,7 +7,10 @@ #include "../../include/messagelist.h" #include "../../include/option.h" -#include +#include + +//#include +#include "../../include/pthreadwrapper/thread.h" #ifdef XMEM #include @@ -24,9 +27,9 @@ NNTPConnection::NNTPConnection(SOCKET sock) m_status.m_allowpost=false; m_status.m_boardid=-1; m_status.m_messageid=-1; - m_status.m_mode=ClientMode::MODE_NONE; + m_status.m_mode=MODE_NONE; - Option::instance()->Get("NNTPAllowPost",tempval); + Option::Instance()->Get("NNTPAllowPost",tempval); if(tempval=="true") { m_status.m_allowpost=true; @@ -230,7 +233,7 @@ const bool NNTPConnection::HandleLastCommand(const NNTPCommand &command) { Message mess; - if(mess.Load(m_status.m_messageid,m_status.m_boardid)) + if(mess.LoadPrevious(m_status.m_messageid,m_status.m_boardid)) { std::ostringstream tempstr; @@ -316,7 +319,7 @@ const bool NNTPConnection::HandleListCommand(const NNTPCommand &command) if(show==true) { - tempstr << (*i).GetBoardName() << "\t" << (*i).GetHighMessageID() << "\t" << (*i).GetLowMessageID() << "\t" << (m_status.m_allowpost ? "y" : "n"); + tempstr << (*i).GetBoardName() << " " << (*i).GetHighMessageID() << " " << (*i).GetLowMessageID() << " " << (m_status.m_allowpost ? "y" : "n"); SendBufferedLine(tempstr.str()); } } @@ -479,7 +482,7 @@ const bool NNTPConnection::HandleModeCommand(const NNTPCommand &command) StringFunctions::UpperCase(arg,arg); if(arg=="READER") { - m_status.m_mode=ClientMode::MODE_READER; + m_status.m_mode=MODE_READER; if(m_status.m_allowpost==true) { SendBufferedLine("200 Posting allowed"); @@ -583,7 +586,7 @@ const bool NNTPConnection::HandleNextCommand(const NNTPCommand &command) { Message mess; - if(mess.Load(m_status.m_messageid,m_status.m_boardid)) + if(mess.LoadNext(m_status.m_messageid,m_status.m_boardid)) { std::ostringstream tempstr; @@ -633,6 +636,11 @@ const bool NNTPConnection::HandleOverCommand(const NNTPCommand &command) messageuuid=command.m_arguments[0]; messageuuid=StringFunctions::Replace(messageuuid,"<",""); messageuuid=StringFunctions::Replace(messageuuid,">",""); + // get rid of @ and everything after + if(messageuuid.find("@")!=std::string::npos) + { + messageuuid.erase(messageuuid.find("@")); + } } // single article or range else @@ -862,10 +870,10 @@ const bool NNTPConnection::HandleQuitCommand(const NNTPCommand &command) return true; } -void NNTPConnection::run() +void NNTPConnection::Run() { struct timeval tv; - FD_SET writefs,readfs; + fd_set writefs,readfs; int rval; // seed random number generater for this thread @@ -908,18 +916,19 @@ void NNTPConnection::run() SocketSend(); } } - else if(rval==-1) + else if(rval==SOCKET_ERROR) { m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::run select returned -1 : "+GetSocketErrorMessage()); } - }while(!Disconnected() && !ZThread::Thread::interrupted()); - +// }while(!Disconnected() && !ZThread::Thread::interrupted()); + }while(!Disconnected() && !IsCancelled()); + Disconnect(); - + } -void NNTPConnection::SendArticleOverInfo(const Message &message) +void NNTPConnection::SendArticleOverInfo(Message &message) { std::string tempval; std::string line; @@ -934,13 +943,13 @@ void NNTPConnection::SendArticleOverInfo(const Message &message) references=message.GetInReplyTo(); if(references.size()>0) { - for(std::map::const_reverse_iterator i=references.rbegin(); i!=references.rend(); i++) + for(std::map::reverse_iterator i=references.rbegin(); i!=references.rend(); i++) { if(i!=references.rbegin()) { line+=" "; } - line+="<"+(*i).second+">"; + line+="<"+(*i).second+"@freenetproject.org>"; } line+="\t"; } @@ -1163,9 +1172,11 @@ void NNTPConnection::SocketReceive() } else if(rval==-1) { + std::string errnostr; + StringFunctions::Convert(GetSocketErrorNumber(),errnostr); // error on receive - close the connection Disconnect(); - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::SocketReceive recv returned -1 : "+GetSocketErrorMessage()); + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::SocketReceive recv returned -1 : "+errnostr+" - "+GetSocketErrorMessage()); } } @@ -1180,7 +1191,9 @@ void NNTPConnection::SocketSend() } else if(rval==-1) { - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::SocketSend returned -1 : "+GetSocketErrorMessage()); + std::string errnostr; + StringFunctions::Convert(GetSocketErrorNumber(),errnostr); + m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"NNTPConnection::SocketSend returned -1 : "+errnostr+" - "+GetSocketErrorMessage()); } } }