X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fidentityinserter.cpp;h=571546a7c5d3b1c1fabd5d47bf4becd9d0a71ad8;hb=8adfd604a97d385869b0ce763b35d014d7aa2cca;hp=33a80854c820e037d8bb1834ba56e79f10826606;hpb=d8f51eac91f86a1e00a05a5058a8fa9eb8732464;p=fms.git diff --git a/src/freenet/identityinserter.cpp b/src/freenet/identityinserter.cpp index 33a8085..571546a 100644 --- a/src/freenet/identityinserter.cpp +++ b/src/freenet/identityinserter.cpp @@ -17,18 +17,24 @@ IdentityInserter::IdentityInserter(FCPv2 *fcp):IFCPConnected(fcp) Initialize(); } -void IdentityInserter::FCPConnected() -{ - m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false';"); -} - void IdentityInserter::CheckForNeededInsert() { + DateTime now; DateTime date; + now.SetToGMTime(); date.SetToGMTime(); // set date to 1 hour back date.Add(0,0,-1); + // Because of importance of Identity.xml, if we are now at the next day we immediately want to insert identities so change the date back to 12:00 AM so we find all identities not inserted yet today + if(date.GetDay()!=now.GetDay()) + { + date=now; + date.SetHour(0); + date.SetMinute(0); + date.SetSecond(0); + } + SQLite3DB::Recordset rs=m_db->Query("SELECT LocalIdentityID FROM tblLocalIdentity WHERE PrivateKey IS NOT NULL AND PrivateKey <> '' AND InsertingIdentity='false' AND (LastInsertedIdentity<'"+date.Format("%Y-%m-%d %H:%M:%S")+"' OR LastInsertedIdentity IS NULL) ORDER BY LastInsertedIdentity;"); if(rs.Empty()==false) @@ -38,6 +44,12 @@ void IdentityInserter::CheckForNeededInsert() } +void IdentityInserter::FCPConnected() +{ + m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false';"); +} + + void IdentityInserter::FCPDisconnected() { @@ -70,14 +82,14 @@ const bool IdentityInserter::HandleMessage(FCPMessage &message) { m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false', LastInsertedIdentity='"+now.Format("%Y-%m-%d %H:%M:%S")+"' WHERE LocalIdentityID="+idparts[1]+";"); m_db->Execute("INSERT INTO tblLocalIdentityInserts(LocalIdentityID,Day,InsertIndex) VALUES("+idparts[1]+",'"+idparts[4]+"',"+idparts[2]+");"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" inserted identity xml"); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IdentityInserter::HandleMessage inserted Identity xml"); return true; } if(message.GetName()=="PutFailed") { m_db->Execute("UPDATE tblLocalIdentity SET InsertingIdentity='false' WHERE LocalIdentityID="+idparts[1]+";"); - m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" failure inserting identity xml. Code="+message["Code"]+" Description="+message["CodeDescription"]); + m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,"IdentityInserter::HandleMessage failure inserting Identity xml. Code="+message["Code"]+" Description="+message["CodeDescription"]); // if code 9 (collision), then insert index into inserted table if(message["Code"]=="9") @@ -127,7 +139,7 @@ void IdentityInserter::StartInsert(const long localidentityid) StringFunctions::Convert(localidentityid,idstring); date.SetToGMTime(); - SQLite3DB::Recordset rs=m_db->Query("SELECT Name,PrivateKey,SingleUse FROM tblLocalIdentity WHERE LocalIdentityID="+idstring+";"); + SQLite3DB::Recordset rs=m_db->Query("SELECT Name,PrivateKey,SingleUse,PublishTrustList,PublishBoardList FROM tblLocalIdentity WHERE LocalIdentityID="+idstring+";"); if(rs.Empty()==false) { @@ -141,6 +153,8 @@ void IdentityInserter::StartInsert(const long localidentityid) long index=0; std::string indexstr; std::string singleuse="false"; + std::string publishtrustlist="false"; + std::string publishboardlist="false"; now.SetToGMTime(); @@ -176,6 +190,18 @@ void IdentityInserter::StartInsert(const long localidentityid) } singleuse=="true" ? idxml.SetSingleUse(true) : idxml.SetSingleUse(false); + if(rs.GetField(3)) + { + publishtrustlist=rs.GetField(3); + } + publishtrustlist=="true" ? idxml.SetPublishTrustList(true) : idxml.SetPublishTrustList(false); + + if(rs.GetField(4)) + { + publishboardlist=rs.GetField(4); + } + publishboardlist=="true" ? idxml.SetPublishBoardList(true) : idxml.SetPublishBoardList(false); + data=idxml.GetXML(); StringFunctions::Convert(data.size(),datasizestr);