#include "../../include/freenet/boardlistinserter.h"\r
#include "../../include/freenet/boardlistxml.h"\r
\r
+#include <Poco/DateTime.h>\r
+#include <Poco/Timespan.h>\r
+#include <Poco/DateTimeFormatter.h>\r
+\r
#ifdef XMEM\r
#include <xmem.h>\r
#endif\r
Initialize();\r
}\r
\r
-BoardListInserter::BoardListInserter(FCPv2 *fcp):IIndexInserter<long>(fcp)\r
+BoardListInserter::BoardListInserter(FCPv2::Connection *fcp):IIndexInserter<long>(fcp)\r
{\r
Initialize();\r
}\r
// only do 1 insert at a time\r
if(m_inserting.size()==0)\r
{\r
- DateTime today;\r
- DateTime daysback;\r
- \r
- today.SetToGMTime();\r
- daysback.SetToGMTime();\r
+ Poco::DateTime today;\r
+ Poco::DateTime daysback;\r
\r
- // 20 days\r
- daysback.Add(0,0,0,-20);\r
+ // 20 days back\r
+ daysback-=Poco::Timespan(20,0,0,0,0);\r
\r
// get identities who posted messages to boards in the past 20 days\r
SQLite3DB::Statement st=m_db->Prepare("SELECT tblLocalIdentity.LocalIdentityID FROM tblLocalIdentity INNER JOIN tblMessageInserts ON tblLocalIdentity.LocalIdentityID=tblMessageInserts.LocalIdentityID WHERE tblLocalIdentity.PublishBoardList='true' AND (tblLocalIdentity.LastInsertedBoardList<? OR tblLocalIdentity.LastInsertedBoardList IS NULL) AND tblMessageInserts.Day>=? GROUP BY tblLocalIdentity.LocalIdentityID;");\r
- st.Bind(0,today.Format("%Y-%m-%d"));\r
- st.Bind(1,daysback.Format("%Y-%m-%d"));\r
+ st.Bind(0,Poco::DateTimeFormatter::format(today,"%Y-%m-%d"));\r
+ st.Bind(1,Poco::DateTimeFormatter::format(daysback,"%Y-%m-%d"));\r
st.Step();\r
\r
if(st.RowReturned())\r
}\r
}\r
\r
-const bool BoardListInserter::HandlePutFailed(FCPMessage &message)\r
+const bool BoardListInserter::HandlePutFailed(FCPv2::Message &message)\r
{\r
std::vector<std::string> idparts;\r
long localidentityid;\r
return true;\r
}\r
\r
-const bool BoardListInserter::HandlePutSuccessful(FCPMessage &message)\r
+const bool BoardListInserter::HandlePutSuccessful(FCPv2::Message &message)\r
{\r
- DateTime now;\r
+ Poco::DateTime now;\r
std::vector<std::string> idparts;\r
long localidentityid;\r
long index;\r
st.Bind(2,index);\r
st.Step();\r
\r
- now.SetToGMTime();\r
st=m_db->Prepare("UPDATE tblLocalIdentity SET LastInsertedBoardList=? WHERE LocalIdentityID=?;");\r
- st.Bind(0,now.Format("%Y-%m-%d %H:%M:%S"));\r
+ st.Bind(0,Poco::DateTimeFormatter::format(now,"%Y-%m-%d %H:%M:%S"));\r
st.Bind(1,localidentityid);\r
st.Step();\r
\r
RemoveFromInsertList(localidentityid);\r
\r
- m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"BoardListInserter::HandlePutSuccessful successfully inserted BoardList.");\r
+ m_log->debug("BoardListInserter::HandlePutSuccessful successfully inserted BoardList.");\r
\r
return true;\r
}\r
\r
const bool BoardListInserter::StartInsert(const long &localidentityid)\r
{\r
- DateTime daysback;\r
- DateTime now;\r
+ Poco::DateTime daysback;\r
+ Poco::DateTime now;\r
BoardListXML xml;\r
- FCPMessage message;\r
+ FCPv2::Message message;\r
std::string data;\r
std::string datasizestr;\r
std::string privatekey="";\r
std::string indexstr="";\r
std::string localidentityidstr;\r
\r
- now.SetToGMTime();\r
- daysback.SetToGMTime();\r
- daysback.Add(0,0,0,-20);\r
+ // 20 days back\r
+ daysback-=Poco::Timespan(20,0,0,0,0);\r
\r
// get boards\r
SQLite3DB::Statement st=m_db->Prepare("SELECT BoardName,BoardDescription FROM tblBoard INNER JOIN tblMessageBoard ON tblBoard.BoardID=tblMessageBoard.BoardID INNER JOIN tblMessage ON tblMessageBoard.MessageID=tblMessage.MessageID INNER JOIN tblMessageInserts ON tblMessage.MessageUUID=tblMessageInserts.MessageUUID WHERE tblMessageInserts.LocalIdentityID=? AND tblMessageInserts.Day>=? GROUP BY tblBoard.BoardID;");\r
st.Bind(0,localidentityid);\r
- st.Bind(1,daysback.Format("%Y-%m-%d"));\r
+ st.Bind(1,Poco::DateTimeFormatter::format(daysback,"%Y-%m-%d"));\r
st.Step();\r
\r
while(st.RowReturned())\r
index=0;\r
st=m_db->Prepare("SELECT MAX(InsertIndex) FROM tblBoardListInserts WHERE LocalIdentityID=? AND Day=?;");\r
st.Bind(0,localidentityid);\r
- st.Bind(1,now.Format("%Y-%m-%d"));\r
+ st.Bind(1,Poco::DateTimeFormatter::format(now,"%Y-%m-%d"));\r
st.Step();\r
if(st.RowReturned())\r
{\r
StringFunctions::Convert(localidentityid,localidentityidstr);\r
\r
message.SetName("ClientPut");\r
- message["URI"]=privatekey+m_messagebase+"|"+now.Format("%Y-%m-%d")+"|BoardList|"+indexstr+".xml";\r
+ message["URI"]=privatekey+m_messagebase+"|"+Poco::DateTimeFormatter::format(now,"%Y-%m-%d")+"|BoardList|"+indexstr+".xml";\r
message["Identifier"]=m_fcpuniquename+"|"+localidentityidstr+"|"+indexstr+"|"+message["URI"];\r
message["UploadFrom"]="direct";\r
message["DataLength"]=datasizestr;\r
- m_fcp->SendMessage(message);\r
- m_fcp->SendRaw(data.c_str(),data.size());\r
+ m_fcp->Send(message);\r
+ m_fcp->Send(std::vector<char>(data.begin(),data.end()));\r
\r
m_inserting.push_back(localidentityid);\r
\r