// parse file into xml and update the database\r
if(xml.ParseXML(std::string(data.begin(),data.end()))==true)\r
{\r
+ // find the identity name and public key of the identity publishing the trust list\r
+ std::string publisherid="";\r
+ st=m_db->Prepare("SELECT Name,PublicKey FROM tblIdentity WHERE IdentityID=?;");\r
+ st.Bind(0,identityid);\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ std::string publishername="";\r
+ std::string publisherpublickey="";\r
+ st.ResultText(0,publishername);\r
+ st.ResultText(1,publisherpublickey);\r
+ publisherid=publishername;\r
+ if(publisherpublickey.size()>4)\r
+ {\r
+ publisherid+=publisherpublickey.substr(3,44);\r
+ }\r
+ }\r
+ st.Finalize();\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.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
+ trustst=m_db->Prepare("INSERT INTO tblPeerTrust(IdentityID,TargetIdentityID,MessageTrust,TrustListTrust,MessageTrustComment,TrustListTrustComment) VALUES(?,?,?,?,?,?);");\r
+ \r
+ SQLite3DB::Statement idinsert=m_db->Prepare("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES(?,?,?);");\r
+ \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
+ std::string messagetrustcomment="";\r
+ std::string trustlisttrustcomment="";\r
identity=xml.GetIdentity(i);\r
\r
st.Bind(0,identity);\r
st.Step();\r
if(st.RowReturned()==false)\r
{\r
- m_db->ExecuteInsert("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('"+identity+"','"+now.Format("%Y-%m-%d %H:%M:%S")+"');",(long &)id);\r
+ idinsert.Bind(0,identity);\r
+ idinsert.Bind(1,now.Format("%Y-%m-%d %H:%M:%S"));\r
+ idinsert.Bind(2,"trust list of "+publisherid);\r
+ idinsert.Step(true);\r
+ id=idinsert.GetLastInsertRowID();\r
+ idinsert.Reset();\r
+ // m_db->ExecuteInsert("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES('"+identity+"','"+now.Format("%Y-%m-%d %H:%M:%S")+"');",(long &)id);\r
}\r
else\r
{\r
{\r
trustst.Bind(3,xml.GetTrustListTrust(i));\r
}\r
+ messagetrustcomment=xml.GetMessageTrustComment(i);\r
+ trustlisttrustcomment=xml.GetTrustListTrustComment(i);\r
+ // limit comments to 50 characters each\r
+ if(messagetrustcomment.size()>50)\r
+ {\r
+ messagetrustcomment.erase(50);\r
+ }\r
+ if(trustlisttrustcomment.size()>50)\r
+ {\r
+ trustlisttrustcomment.erase(50);\r
+ }\r
+ trustst.Bind(4,messagetrustcomment);\r
+ trustst.Bind(5,trustlisttrustcomment);\r
trustst.Step();\r
trustst.Reset();\r
\r