X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Fmessageinserter.cpp;h=0c032048e8bca8461db99b07ee26fcefaf48d94f;hp=e1a52114bde16fe09ec6e2353da12d55ace4d485;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hpb=9b22dd53fe62e312c1647310b7ec43aa127090af diff --git a/src/freenet/messageinserter.cpp b/src/freenet/messageinserter.cpp index e1a5211..0c03204 100644 --- a/src/freenet/messageinserter.cpp +++ b/src/freenet/messageinserter.cpp @@ -1,6 +1,10 @@ #include "../../include/freenet/messageinserter.h" #include "../../include/freenet/messagexml.h" +#include +#include +#include + MessageInserter::MessageInserter() { Initialize(); @@ -13,14 +17,13 @@ MessageInserter::MessageInserter(FCPv2 *fcp):IIndexInserter(fcp) void MessageInserter::CheckForNeededInsert() { - DateTime now; - now.SetToGMTime(); + Poco::DateTime now; bool didinsert=false; // only do 1 insert at a time if(m_inserting.size()==0) { SQLite3DB::Statement st=m_db->Prepare("SELECT MessageUUID FROM tblMessageInserts INNER JOIN tblLocalIdentity ON tblMessageInserts.LocalIdentityID=tblLocalIdentity.LocalIdentityID WHERE tblLocalIdentity.PrivateKey IS NOT NULL AND tblLocalIdentity.PrivateKey <> '' AND tblMessageInserts.Inserted='false' AND tblMessageInserts.SendDate<=?;"); - 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.Step(); while(st.RowReturned() && m_inserting.size()==0) @@ -70,7 +73,7 @@ const bool MessageInserter::HandlePutFailed(FCPMessage &message) const bool MessageInserter::HandlePutSuccessful(FCPMessage &message) { MessageXML xml; - DateTime date; + Poco::DateTime date; int localidentityid; int index; std::vector idparts; @@ -86,10 +89,10 @@ const bool MessageInserter::HandlePutSuccessful(FCPMessage &message) st.Step(); // insert record into temp table so MessageList will be inserted ASAP - date.SetToGMTime(); + date=Poco::Timestamp(); st=m_db->Prepare("INSERT INTO tmpMessageListInsert(LocalIdentityID,Date) VALUES(?,?);"); st.Bind(0,localidentityid); - st.Bind(1,date.Format("%Y-%m-%d")); + st.Bind(1,Poco::DateTimeFormatter::format(date,"%Y-%m-%d")); st.Step(); // update the messageuuid to the real messageuuid @@ -118,7 +121,7 @@ const bool MessageInserter::HandlePutSuccessful(FCPMessage &message) RemoveFromInsertList(idparts[1]); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"MessageInserter::HandlePutSuccessful successfully inserted message "+message["Identifier"]); + m_log->debug("MessageInserter::HandlePutSuccessful successfully inserted message "+message["Identifier"]); return true; } @@ -131,8 +134,7 @@ void MessageInserter::Initialize() const bool MessageInserter::StartInsert(const std::string &messageuuid) { MessageXML xmlfile; - DateTime now; - now.SetToGMTime(); + Poco::DateTime now; SQLite3DB::Statement st=m_db->Prepare("SELECT MessageXML,PrivateKey,tblLocalIdentity.LocalIdentityID,PublicKey FROM tblMessageInserts INNER JOIN tblLocalIdentity ON tblMessageInserts.LocalIdentityID=tblLocalIdentity.LocalIdentityID WHERE MessageUUID=?;"); st.Bind(0,messageuuid); st.Step(); @@ -156,7 +158,7 @@ const bool MessageInserter::StartInsert(const std::string &messageuuid) StringFunctions::Convert(localidentityid,idstr); st=m_db->Prepare("SELECT MAX(InsertIndex) FROM tblMessageInserts WHERE Day=? AND LocalIdentityID=?;"); - st.Bind(0,now.Format("%Y-%m-%d")); + st.Bind(0,Poco::DateTimeFormatter::format(now,"%Y-%m-%d")); st.Bind(1,localidentityid); st.Step(); @@ -200,7 +202,7 @@ const bool MessageInserter::StartInsert(const std::string &messageuuid) StringFunctions::Convert(xml.size(),xmlsizestr); message.SetName("ClientPut"); - message["URI"]=privatekey+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|Message|"+indexstr+".xml"; + message["URI"]=privatekey+m_messagebase+"|"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"|Message|"+indexstr+".xml"; message["Identifier"]=m_fcpuniquename+"|"+messageuuid+"|"+idstr+"|"+indexstr+"|"+xmlfile.GetMessageID()+"|"+message["URI"]; message["UploadFrom"]="direct"; message["DataLength"]=xmlsizestr; @@ -209,7 +211,7 @@ const bool MessageInserter::StartInsert(const std::string &messageuuid) m_inserting.push_back(messageuuid); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"MessageInserter::StartInsert started message insert "+message["URI"]); + m_log->debug("MessageInserter::StartInsert started message insert "+message["URI"]); return true; }