{\r
DateTime now;\r
SQLite3DB::Statement st;\r
+ SQLite3DB::Statement trustst;\r
std::vector<std::string> idparts;\r
long datalength;\r
std::vector<char> data;\r
// parse file into xml and update the database\r
if(xml.ParseXML(std::string(data.begin(),data.end()))==true)\r
{\r
+\r
+ // drop all existing peer trust from this identity - we will rebuild it when we go through each trust in the xml file\r
+ st=m_db->Prepare("DELETE FROM tblPeerTrust WHERE IdentityID=?;");\r
+ st.Bind(0,identityid);\r
+ st.Step();\r
+ st.Finalize();\r
+\r
st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey=?;");\r
+ trustst=m_db->Prepare("INSERT INTO tblPeerTrust(IdentityID,TargetIdentityID,MessageTrust,TrustListTrust) VALUES(?,?,?,?);");\r
// loop through all trust entries in xml and add to database if we don't already know them\r
for(long i=0; i<xml.TrustCount(); i++)\r
{\r
+ int id;\r
std::string identity;\r
identity=xml.GetIdentity(i);\r
\r
- //TODO get the trust levels as well\r
-\r
st.Bind(0,identity);\r
st.Step();\r
if(st.RowReturned()==false)\r
{\r
- m_db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('"+identity+"','"+now.Format("%Y-%m-%d %H:%M:%S")+"');");\r
+ m_db->ExecuteInsert("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('"+identity+"','"+now.Format("%Y-%m-%d %H:%M:%S")+"');",(long &)id);\r
+ }\r
+ else\r
+ {\r
+ st.ResultInt(0,id);\r
}\r
st.Reset();\r
+\r
+ //insert trust for this identity\r
+ trustst.Bind(0,identityid);\r
+ trustst.Bind(1,id);\r
+ trustst.Bind(2,xml.GetMessageTrust(i));\r
+ trustst.Bind(3,xml.GetTrustListTrust(i));\r
+ trustst.Step();\r
+ trustst.Reset();\r
+\r
}\r
+ trustst.Finalize();\r
+ st.Finalize();\r
\r
st=m_db->Prepare("INSERT INTO tblTrustListRequests(IdentityID,Day,RequestIndex,Found) VALUES(?,?,?,'true');");\r
st.Bind(0,identityid);\r
st.Step();\r
st.Finalize();\r
\r
- m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" parsed Identity XML file : "+message["Identifier"]);\r
+ m_log->WriteLog(LogFile::LOGLEVEL_DEBUG,__FUNCTION__" parsed TrustList XML file : "+message["Identifier"]);\r
}\r
else\r
{\r