X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Fmessagelistinserter.cpp;h=9307b19272ca6c198cccdc7e20fe1fcf1d997be0;hp=eb102a13bfe7e78cdf0d36dac8c348de0b442368;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hpb=9b22dd53fe62e312c1647310b7ec43aa127090af diff --git a/src/freenet/messagelistinserter.cpp b/src/freenet/messagelistinserter.cpp index eb102a1..9307b19 100644 --- a/src/freenet/messagelistinserter.cpp +++ b/src/freenet/messagelistinserter.cpp @@ -2,6 +2,10 @@ #include "../../include/freenet/messagexml.h" #include "../../include/freenet/messagelistxml.h" +#include +#include +#include + #ifdef XMEM #include #endif @@ -22,20 +26,17 @@ void MessageListInserter::CheckForNeededInsert() if(m_inserting.size()==0) { std::string sql; - DateTime now; - DateTime previous; + Poco::DateTime now; + Poco::DateTime previous; bool startedinsert=false; - now.SetToGMTime(); - previous.SetToGMTime(); - // reset the last inserted xml doc to nothing if the day has changed - if(m_lastchecked.GetDay()!=now.GetDay()) + if(m_lastchecked.day()!=now.day()) { m_lastinsertedxml.clear(); } - previous.Add(0,0,0,-m_daysbackward); + previous-=Poco::Timespan(m_daysbackward,0,0,0,0); // query for identities that have messages in the past X days and (we haven't inserted lists for in the past 30 minutes OR identity has a record in tmpMessageListInsert) sql="SELECT tblLocalIdentity.LocalIdentityID "; @@ -44,8 +45,8 @@ void MessageListInserter::CheckForNeededInsert() sql+="GROUP BY tblLocalIdentity.LocalIdentityID;"; SQLite3DB::Statement st=m_db->Prepare(sql); - st.Bind(0,previous.Format("%Y-%m-%d")); - st.Bind(1,(now-(1.0/48.0)).Format("%Y-%m-%d %H:%M:%S")); + st.Bind(0,Poco::DateTimeFormatter::format(previous,"%Y-%m-%d")); + st.Bind(1,Poco::DateTimeFormatter::format((now-Poco::Timespan(0,0,30,0,0)),"%Y-%m-%d %H:%M:%S")); st.Step(); while(st.RowReturned() && startedinsert==false) @@ -89,7 +90,7 @@ const bool MessageListInserter::HandlePutFailed(FCPMessage &message) } else { - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"MessageListInserter::HandlePutFailed "+message["Identifier"]); + m_log->debug("MessageListInserter::HandlePutFailed "+message["Identifier"]); } return true; @@ -98,7 +99,7 @@ const bool MessageListInserter::HandlePutFailed(FCPMessage &message) const bool MessageListInserter::HandlePutSuccessful(FCPMessage &message) { - DateTime now; + Poco::DateTime now; std::vector idparts; long localidentityid; long index; @@ -117,9 +118,9 @@ const bool MessageListInserter::HandlePutSuccessful(FCPMessage &message) st.Bind(2,index); st.Step(); - now.SetToGMTime(); + now=Poco::Timestamp(); st=m_db->Prepare("UPDATE tblLocalIdentity SET LastInsertedMessageList=? WHERE LocalIdentityID=?;"); - st.Bind(0,now.Format("%Y-%m-%d %H:%M:%S")); + st.Bind(0,Poco::DateTimeFormatter::format(now,"%Y-%m-%d %H:%M:%S")); st.Bind(1,localidentityid); st.Step(); @@ -130,11 +131,11 @@ const bool MessageListInserter::HandlePutSuccessful(FCPMessage &message) RemoveFromInsertList(localidentityid); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"MessageListInserter::HandlePutSuccessful successfully inserted MessageList."); + m_log->debug("MessageListInserter::HandlePutSuccessful successfully inserted MessageList."); } else { - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"MessageListInserter::HandlePutSuccessful inserted USK MessageList "+message["Identifier"]); + m_log->debug("MessageListInserter::HandlePutSuccessful inserted USK MessageList "+message["Identifier"]); } return true; @@ -153,8 +154,8 @@ void MessageListInserter::Initialize() const bool MessageListInserter::StartInsert(const long &localidentityid) { FCPMessage message; - DateTime date; - DateTime now; + Poco::DateTime date; + Poco::DateTime now; std::string privatekey; std::string localidentityidstr; MessageListXML mlxml; @@ -164,14 +165,12 @@ const bool MessageListInserter::StartInsert(const long &localidentityid) int index; std::string indexstr; - now.SetToGMTime(); - date.SetToGMTime(); - date.Add(0,0,0,-m_daysbackward); + date-=Poco::Timespan(m_daysbackward,0,0,0,0); StringFunctions::Convert(localidentityid,localidentityidstr); SQLite3DB::Statement st=m_db->Prepare("SELECT Day, InsertIndex, MessageXML, PrivateKey FROM tblMessageInserts INNER JOIN tblLocalIdentity ON tblMessageInserts.LocalIdentityID=tblLocalIdentity.LocalIdentityID WHERE tblLocalIdentity.LocalIdentityID=? AND Day>=?;"); st.Bind(0,localidentityid); - st.Bind(1,date.Format("%Y-%m-%d")); + st.Bind(1,Poco::DateTimeFormatter::format(date,"%Y-%m-%d")); st.Step(); while(st.RowReturned()) @@ -232,7 +231,7 @@ const bool MessageListInserter::StartInsert(const long &localidentityid) index=0; st=m_db->Prepare("SELECT MAX(InsertIndex) FROM tblMessageListInserts WHERE LocalIdentityID=? AND Day=?;"); st.Bind(0,localidentityid); - st.Bind(1,now.Format("%Y-%m-%d")); + st.Bind(1,Poco::DateTimeFormatter::format(now,"%Y-%m-%d")); st.Step(); if(st.ResultNull(0)==false) { @@ -250,7 +249,7 @@ const bool MessageListInserter::StartInsert(const long &localidentityid) StringFunctions::Convert(xmlstr.size(),xmlsizestr); message.SetName("ClientPut"); - message["URI"]=privatekey+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|MessageList|"+indexstr+".xml"; + message["URI"]=privatekey+m_messagebase+"|"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"|MessageList|"+indexstr+".xml"; message["Identifier"]=m_fcpuniquename+"|"+localidentityidstr+"|"+indexstr+"|"+message["URI"]; message["UploadFrom"]="direct"; message["DataLength"]=xmlsizestr; @@ -259,7 +258,7 @@ const bool MessageListInserter::StartInsert(const long &localidentityid) message.Reset(); message.SetName("ClientPutComplexDir"); - message["URI"]="USK"+privatekey.substr(3)+m_messagebase+"|"+now.Format("%Y.%m.%d")+"|MessageList/0/"; + message["URI"]="USK"+privatekey.substr(3)+m_messagebase+"|"+Poco::DateTimeFormatter::format(now,"%Y.%m.%d")+"|MessageList/0/"; message["Identifier"]=m_fcpuniquename+"USK|"+message["URI"]; message["DefaultName"]="MessageList.xml"; message["Files.0.Name"]="MessageList.xml";