X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnntp%2Fnntpconnection.cpp;h=d7eaa7022adc13ebf662f0d0059dc53cf57b9453;hb=f208e33c29132aacaec448e74341edea1b925a2a;hp=ac75d4d310ffb0f931252a23b4f71ba3a950345a;hpb=868c533e84b3c81b6604b45b84efa32073aa20b4;p=fms.git diff --git a/src/nntp/nntpconnection.cpp b/src/nntp/nntpconnection.cpp index ac75d4d..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 @@ -26,7 +29,7 @@ NNTPConnection::NNTPConnection(SOCKET sock) m_status.m_messageid=-1; 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()); } } @@ -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,7 +870,7 @@ const bool NNTPConnection::HandleQuitCommand(const NNTPCommand &command) return true; } -void NNTPConnection::run() +void NNTPConnection::Run() { struct timeval tv; fd_set writefs,readfs; @@ -908,15 +916,16 @@ 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(Message &message) @@ -940,7 +949,7 @@ void NNTPConnection::SendArticleOverInfo(Message &message) { 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()); } } }