X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fintroductionpuzzleinserter.cpp;h=000d973fd49b0f5754659a921402b8dbda7d5c14;hb=59a5414ec47a2932a7802fcd1d98c4d80166564f;hp=defa0cb392ba56ad0038a27ac432601fbe40f639;hpb=c0ebc7b53a977885ebc2d3a679c586ae20c0bc4a;p=fms.git diff --git a/src/freenet/introductionpuzzleinserter.cpp b/src/freenet/introductionpuzzleinserter.cpp index defa0cb..000d973 100644 --- a/src/freenet/introductionpuzzleinserter.cpp +++ b/src/freenet/introductionpuzzleinserter.cpp @@ -17,12 +17,12 @@ #include #endif -IntroductionPuzzleInserter::IntroductionPuzzleInserter():IIndexInserter() +IntroductionPuzzleInserter::IntroductionPuzzleInserter(SQLite3DB::DB *db):IIndexInserter(db) { Initialize(); } -IntroductionPuzzleInserter::IntroductionPuzzleInserter(FCPv2 *fcp):IIndexInserter(fcp) +IntroductionPuzzleInserter::IntroductionPuzzleInserter(SQLite3DB::DB *db, FCPv2::Connection *fcp):IIndexInserter(db,fcp) { Initialize(); } @@ -59,6 +59,7 @@ void IntroductionPuzzleInserter::CheckForNeededInsert() // make sure we are on the next day or the appropriate amount of time has elapsed since the last insert if(m_lastinserted.find(rs.GetInt(0))==m_lastinserted.end() || m_lastinserted[rs.GetInt(0)]<=lastinsert || m_lastinserted[rs.GetInt(0)].day()!=now.day()) { + StartInsert(rs.GetInt(0)); m_lastinserted[rs.GetInt(0)]=now; } else @@ -105,7 +106,7 @@ void IntroductionPuzzleInserter::GenerateCaptcha(std::string &encodeddata, std:: } -const bool IntroductionPuzzleInserter::HandlePutFailed(FCPMessage &message) +const bool IntroductionPuzzleInserter::HandlePutFailed(FCPv2::Message &message) { SQLite3DB::Statement st; std::vector idparts; @@ -131,7 +132,7 @@ const bool IntroductionPuzzleInserter::HandlePutFailed(FCPMessage &message) return true; } -const bool IntroductionPuzzleInserter::HandlePutSuccessful(FCPMessage &message) +const bool IntroductionPuzzleInserter::HandlePutSuccessful(FCPv2::Message &message) { Poco::DateTime now; SQLite3DB::Statement st; @@ -186,7 +187,7 @@ const bool IntroductionPuzzleInserter::StartInsert(const long &localidentityid) IntroductionPuzzleXML xml; std::string encodedpuzzle=""; std::string solutionstring=""; - FCPMessage message; + FCPv2::Message message; std::string xmldata=""; std::string xmldatasizestr=""; std::string privatekey=""; @@ -223,7 +224,8 @@ const bool IntroductionPuzzleInserter::StartInsert(const long &localidentityid) } } - Option::Instance()->Get("MessageBase",messagebase); + Option option(m_db); + option.Get("MessageBase",messagebase); GenerateCaptcha(encodedpuzzle,solutionstring); if(encodedpuzzle.size()==0) @@ -256,11 +258,11 @@ const bool IntroductionPuzzleInserter::StartInsert(const long &localidentityid) message["Identifier"]=m_fcpuniquename+"|"+idstring+"|"+indexstr+"|"+xml.GetUUID()+"|"+message["URI"]; message["UploadFrom"]="direct"; message["DataLength"]=xmldatasizestr; - m_fcp->SendMessage(message); - m_fcp->SendRaw(xmldata.c_str(),xmldata.size()); + m_fcp->Send(message); + m_fcp->Send(std::vector(xmldata.begin(),xmldata.end())); // insert to USK - message.Reset(); + message.Clear(); message.SetName("ClientPutComplexDir"); message["URI"]="USK"+privatekey.substr(3)+messagebase+"|"+Poco::DateTimeFormatter::format(now,"%Y.%m.%d")+"|IntroductionPuzzle/0/"; message["Identifier"]=m_fcpuniquename+"USK|"+message["URI"]; @@ -268,8 +270,8 @@ const bool IntroductionPuzzleInserter::StartInsert(const long &localidentityid) message["Files.0.Name"]="IntroductionPuzzle.xml"; message["Files.0.UplaodFrom"]="direct"; message["Files.0.DataLength"]=xmldatasizestr; - m_fcp->SendMessage(message); - m_fcp->SendRaw(xmldata.c_str(),xmldata.size()); + m_fcp->Send(message); + m_fcp->Send(std::vector(xmldata.begin(),xmldata.end())); m_db->Execute("INSERT INTO tblIntroductionPuzzleInserts(UUID,Type,MimeType,LocalIdentityID,PuzzleData,PuzzleSolution) VALUES('"+xml.GetUUID()+"','captcha','image/bmp',"+idstring+",'"+encodedpuzzle+"','"+solutionstring+"');");