X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffreenet%2Ftrustlistrequester.cpp;h=89da83a989ef62a05219b91c7e44c967cecd4d86;hb=175f098e7e712b839db433b93fe8649a402c6784;hp=90606dd7403821c9e2130e640665bb37251f2774;hpb=1dee4e3cd008a27789bbce05b0eb47b0eb5d121a;p=fms.git diff --git a/src/freenet/trustlistrequester.cpp b/src/freenet/trustlistrequester.cpp index 90606dd..89da83a 100644 --- a/src/freenet/trustlistrequester.cpp +++ b/src/freenet/trustlistrequester.cpp @@ -54,6 +54,24 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message) // parse file into xml and update the database if(xml.ParseXML(std::string(data.begin(),data.end()))==true) { + // find the identity name and public key of the identity publishing the trust list + std::string publisherid=""; + st=m_db->Prepare("SELECT Name,PublicKey FROM tblIdentity WHERE IdentityID=?;"); + st.Bind(0,identityid); + st.Step(); + if(st.RowReturned()) + { + std::string publishername=""; + std::string publisherpublickey=""; + st.ResultText(0,publishername); + st.ResultText(1,publisherpublickey); + publisherid=publishername; + if(publisherpublickey.size()>4) + { + publisherid+=publisherpublickey.substr(3,44); + } + } + st.Finalize(); // drop all existing peer trust from this identity - we will rebuild it when we go through each trust in the xml file st=m_db->Prepare("DELETE FROM tblPeerTrust WHERE IdentityID=?;"); @@ -62,19 +80,30 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message) st.Finalize(); st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey=?;"); - trustst=m_db->Prepare("INSERT INTO tblPeerTrust(IdentityID,TargetIdentityID,MessageTrust,TrustListTrust) VALUES(?,?,?,?);"); + trustst=m_db->Prepare("INSERT INTO tblPeerTrust(IdentityID,TargetIdentityID,MessageTrust,TrustListTrust,MessageTrustComment,TrustListTrustComment) VALUES(?,?,?,?,?,?);"); + + SQLite3DB::Statement idinsert=m_db->Prepare("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES(?,?,?);"); + // loop through all trust entries in xml and add to database if we don't already know them for(long i=0; iExecuteInsert("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('"+identity+"','"+now.Format("%Y-%m-%d %H:%M:%S")+"');",(long &)id); + idinsert.Bind(0,identity); + idinsert.Bind(1,now.Format("%Y-%m-%d %H:%M:%S")); + idinsert.Bind(2,"trust list of "+publisherid); + idinsert.Step(true); + id=idinsert.GetLastInsertRowID(); + idinsert.Reset(); + // m_db->ExecuteInsert("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('"+identity+"','"+now.Format("%Y-%m-%d %H:%M:%S")+"');",(long &)id); } else { @@ -101,6 +130,19 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message) { trustst.Bind(3,xml.GetTrustListTrust(i)); } + messagetrustcomment=xml.GetMessageTrustComment(i); + trustlisttrustcomment=xml.GetTrustListTrustComment(i); + // limit comments to 50 characters each + if(messagetrustcomment.size()>50) + { + messagetrustcomment.erase(50); + } + if(trustlisttrustcomment.size()>50) + { + trustlisttrustcomment.erase(50); + } + trustst.Bind(4,messagetrustcomment); + trustst.Bind(5,trustlisttrustcomment); trustst.Step(); trustst.Reset();