X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Fidentityrequester.cpp;h=3375f1d0ef7edc759c8056394a03f47cb0daf697;hp=c0f6c8a74cddfafea36b4ecb73e46ba1ffc0afb3;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hpb=9b22dd53fe62e312c1647310b7ec43aa127090af diff --git a/src/freenet/identityrequester.cpp b/src/freenet/identityrequester.cpp index c0f6c8a..3375f1d 100644 --- a/src/freenet/identityrequester.cpp +++ b/src/freenet/identityrequester.cpp @@ -2,7 +2,11 @@ #include "../../include/freenet/identityxml.h" #include "../../include/stringfunctions.h" #include "../../include/option.h" -#include "../../include/datetime.h" + +#include +#include +#include +#include #ifdef XMEM #include @@ -20,7 +24,7 @@ IdentityRequester::IdentityRequester(FCPv2 *fcp):IIndexRequester(fcp) const bool IdentityRequester::HandleAllData(FCPMessage &message) { - DateTime now; + Poco::DateTime now; SQLite3DB::Statement st; std::vector idparts; long datalength; @@ -30,7 +34,7 @@ const bool IdentityRequester::HandleAllData(FCPMessage &message) long index; std::string name=""; - now.SetToGMTime(); + now=Poco::Timestamp(); StringFunctions::Split(message["Identifier"],"|",idparts); StringFunctions::Convert(message["DataLength"],datalength); StringFunctions::Convert(idparts[1],identityid); @@ -71,7 +75,7 @@ const bool IdentityRequester::HandleAllData(FCPMessage &message) { st.Bind(1,"false"); } - st.Bind(2,now.Format("%Y-%m-%d %H:%M:%S")); + st.Bind(2,Poco::DateTimeFormatter::format(now,"%Y-%m-%d %H:%M:%S")); if(xml.GetPublishTrustList()==true) { st.Bind(3,"true"); @@ -107,7 +111,7 @@ const bool IdentityRequester::HandleAllData(FCPMessage &message) st.Step(); st.Finalize(); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IdentityRequester::HandleAllData parsed Identity XML file : "+message["Identifier"]); + m_log->debug("IdentityRequester::HandleAllData parsed Identity XML file : "+message["Identifier"]); } else { @@ -119,7 +123,7 @@ const bool IdentityRequester::HandleAllData(FCPMessage &message) st.Step(); st.Finalize(); - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IdentityRequester::HandleAllData error parsing Identity XML file : "+message["Identifier"]); + m_log->error("IdentityRequester::HandleAllData error parsing Identity XML file : "+message["Identifier"]); } // remove this identityid from request list @@ -131,13 +135,11 @@ const bool IdentityRequester::HandleAllData(FCPMessage &message) const bool IdentityRequester::HandleGetFailed(FCPMessage &message) { - DateTime now; SQLite3DB::Statement st; std::vector idparts; long identityid; long index; - now.SetToGMTime(); StringFunctions::Split(message["Identifier"],"|",idparts); StringFunctions::Convert(idparts[1],identityid); StringFunctions::Convert(idparts[2],index); @@ -152,7 +154,7 @@ const bool IdentityRequester::HandleGetFailed(FCPMessage &message) st.Step(); st.Finalize(); - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"IdentityRequester::HandleGetFailed fatal error requesting "+message["Identifier"]); + m_log->error("IdentityRequester::HandleGetFailed fatal error requesting "+message["Identifier"]); } // remove this identityid from request list @@ -171,26 +173,23 @@ void IdentityRequester::Initialize() if(m_maxrequests<1) { m_maxrequests=1; - m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"Option MaxIdentityRequests is currently set at "+tempval+". It must be 1 or greater."); + m_log->error("Option MaxIdentityRequests is currently set at "+tempval+". It must be 1 or greater."); } if(m_maxrequests>100) { - m_log->WriteLog(LogFile::LOGLEVEL_WARNING,"Option MaxIdentityRequests is currently set at "+tempval+". This value might be incorrectly configured."); + m_log->warning("Option MaxIdentityRequests is currently set at "+tempval+". This value might be incorrectly configured."); } } void IdentityRequester::PopulateIDList() { - DateTime date; + Poco::DateTime date; int id; - date.SetToGMTime(); - date.SetHour(0); - date.SetMinute(0); - date.SetSecond(0); + date.assign(date.year(),date.month(),date.day(),0,0,0); // select identities we want to query (haven't seen yet today) - sort by their trust level (descending) with secondary sort on how long ago we saw them (ascending) - SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND (LastSeen IS NULL OR LastSeen<'"+date.Format("%Y-%m-%d %H:%M:%S")+"') ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;"); + SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND (LastSeen IS NULL OR LastSeen<'"+Poco::DateTimeFormatter::format(date,"%Y-%m-%d %H:%M:%S")+"') ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;"); st.Step(); m_ids.clear(); @@ -205,7 +204,7 @@ void IdentityRequester::PopulateIDList() void IdentityRequester::StartRequest(const long &identityid) { - DateTime now; + Poco::DateTime now; FCPMessage message; std::string publickey; int index; @@ -220,10 +219,10 @@ void IdentityRequester::StartRequest(const long &identityid) { st.ResultText(0,publickey); - now.SetToGMTime(); + now=Poco::Timestamp(); SQLite3DB::Statement st2=m_db->Prepare("SELECT MAX(RequestIndex) FROM tblIdentityRequests WHERE Day=? AND IdentityID=?;"); - st2.Bind(0,now.Format("%Y-%m-%d")); + st2.Bind(0,Poco::DateTimeFormatter::format(now,"%Y-%m-%d")); st2.Bind(1,identityid); st2.Step(); @@ -242,7 +241,7 @@ void IdentityRequester::StartRequest(const long &identityid) StringFunctions::Convert(identityid,identityidstr); message.SetName("ClientGet"); - message["URI"]=publickey+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|Identity|"+indexstr+".xml"; + message["URI"]=publickey+m_messagebase+"|"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"|Identity|"+indexstr+".xml"; message["Identifier"]=m_fcpuniquename+"|"+identityidstr+"|"+indexstr+"|"+message["URI"]; message["ReturnType"]="direct"; message["MaxSize"]="10000"; // 10 KB