#include "../../include/freenet/messageinserter.h"\r
#include "../../include/freenet/messagexml.h"\r
\r
+#include <Poco/DateTime.h>\r
+#include <Poco/DateTimeFormatter.h>\r
+#include <Poco/Timestamp.h>\r
+\r
MessageInserter::MessageInserter()\r
{\r
Initialize();\r
\r
void MessageInserter::CheckForNeededInsert()\r
{\r
+ Poco::DateTime now;\r
bool didinsert=false;\r
// only do 1 insert at a time\r
if(m_inserting.size()==0)\r
{\r
- 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';");\r
+ 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<=?;");\r
+ st.Bind(0,Poco::DateTimeFormatter::format(now,"%Y-%m-%d %H:%M:%S"));\r
st.Step();\r
\r
while(st.RowReturned() && m_inserting.size()==0)\r
const bool MessageInserter::HandlePutSuccessful(FCPMessage &message)\r
{\r
MessageXML xml;\r
- DateTime date;\r
+ Poco::DateTime date;\r
int localidentityid;\r
int index;\r
std::vector<std::string> idparts;\r
st.Step();\r
\r
// insert record into temp table so MessageList will be inserted ASAP\r
- date.SetToGMTime();\r
+ date=Poco::Timestamp();\r
st=m_db->Prepare("INSERT INTO tmpMessageListInsert(LocalIdentityID,Date) VALUES(?,?);");\r
st.Bind(0,localidentityid);\r
- st.Bind(1,date.Format("%Y-%m-%d"));\r
+ st.Bind(1,Poco::DateTimeFormatter::format(date,"%Y-%m-%d"));\r
st.Step();\r
\r
// update the messageuuid to the real messageuuid\r
\r
RemoveFromInsertList(idparts[1]);\r
\r
- m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"MessageInserter::HandlePutSuccessful successfully inserted message "+message["Identifier"]);\r
+ m_log->debug("MessageInserter::HandlePutSuccessful successfully inserted message "+message["Identifier"]);\r
\r
return true;\r
}\r
m_fcpuniquename="MessageInserter";\r
}\r
\r
-void MessageInserter::StartInsert(const std::string &messageuuid)\r
+const bool MessageInserter::StartInsert(const std::string &messageuuid)\r
{\r
MessageXML xmlfile;\r
- DateTime now;\r
- now.SetToGMTime();\r
+ Poco::DateTime now;\r
SQLite3DB::Statement st=m_db->Prepare("SELECT MessageXML,PrivateKey,tblLocalIdentity.LocalIdentityID,PublicKey FROM tblMessageInserts INNER JOIN tblLocalIdentity ON tblMessageInserts.LocalIdentityID=tblLocalIdentity.LocalIdentityID WHERE MessageUUID=?;");\r
st.Bind(0,messageuuid);\r
st.Step();\r
StringFunctions::Convert(localidentityid,idstr);\r
\r
st=m_db->Prepare("SELECT MAX(InsertIndex) FROM tblMessageInserts WHERE Day=? AND LocalIdentityID=?;");\r
- st.Bind(0,now.Format("%Y-%m-%d"));\r
+ st.Bind(0,Poco::DateTimeFormatter::format(now,"%Y-%m-%d"));\r
st.Bind(1,localidentityid);\r
st.Step();\r
\r
StringFunctions::Convert(xml.size(),xmlsizestr);\r
\r
message.SetName("ClientPut");\r
- message["URI"]=privatekey+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|Message|"+indexstr+".xml";\r
+ message["URI"]=privatekey+m_messagebase+"|"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"|Message|"+indexstr+".xml";\r
message["Identifier"]=m_fcpuniquename+"|"+messageuuid+"|"+idstr+"|"+indexstr+"|"+xmlfile.GetMessageID()+"|"+message["URI"];\r
message["UploadFrom"]="direct";\r
message["DataLength"]=xmlsizestr;\r
\r
m_inserting.push_back(messageuuid);\r
\r
- m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"MessageInserter::StartInsert started message insert "+message["URI"]);\r
+ m_log->debug("MessageInserter::StartInsert started message insert "+message["URI"]);\r
+ \r
+ return true;\r
+ }\r
+ else\r
+ {\r
+ return false;\r
}\r
\r
}\r