X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Fnntp%2Fextensiontrust.cpp;h=eb0a765ba560e21d34fdc090abd6e9470ceed394;hp=8a50bebc348217fed230a61b41c74fc1f40a9239;hb=3f6f19146f015fa8d2c89f1e72cd467dbc4115aa;hpb=1230cc420c955e75051d011d964bc68f061ba08c diff --git a/src/nntp/extensiontrust.cpp b/src/nntp/extensiontrust.cpp index 8a50beb..eb0a765 100644 --- a/src/nntp/extensiontrust.cpp +++ b/src/nntp/extensiontrust.cpp @@ -161,17 +161,21 @@ const bool TrustExtension::GetPeerTrustListTrust(const std::string &nntpname, in } } -const bool TrustExtension::GetTrustList(std::map > &trustlist) +const bool TrustExtension::GetTrustList(std::map &trustlist) { if(m_localidentityid>=0) { - SQLite3DB::Statement st=m_db->Prepare("SELECT tblIdentityTrust.LocalMessageTrust,tblIdentityTrust.LocalTrustListTrust,tblIdentity.Name,tblIdentity.PublicKey FROM tblIdentityTrust INNER JOIN tblIdentity ON tblIdentityTrust.IdentityID=tblIdentity.IdentityID WHERE tblIdentityTrust.LocalIdentityID=? AND tblIdentity.Name IS NOT NULL AND tblIdentity.PublicKey IS NOT NULL AND tblIdentity.PublicKey <> '' ;"); + SQLite3DB::Statement st=m_db->Prepare("SELECT tblIdentityTrust.LocalMessageTrust,tblIdentityTrust.LocalTrustListTrust,tblIdentity.Name,tblIdentity.PublicKey,tblIdentityTrust.MessageTrustComment,tblIdentityTrust.TrustListTrustComment,tblIdentity.PeerMessageTrust,tblIdentity.PeerTrustListTrust FROM tblIdentityTrust INNER JOIN tblIdentity ON tblIdentityTrust.IdentityID=tblIdentity.IdentityID WHERE tblIdentityTrust.LocalIdentityID=? AND tblIdentity.Name IS NOT NULL AND tblIdentity.PublicKey IS NOT NULL AND tblIdentity.PublicKey <> '' ;"); st.Bind(0,m_localidentityid); st.Step(); while(st.RowReturned()) { int messagetrust=-1; int trustlisttrust=-1; + int peermessagetrust=-1; + int peertrustlisttrust=-1; + std::string messagetrustcomment=""; + std::string trustlisttrustcomment=""; std::string name=""; std::string publickey=""; std::vector keyparts; @@ -187,6 +191,16 @@ const bool TrustExtension::GetTrustList(std::map } st.ResultText(2,name); st.ResultText(3,publickey); + st.ResultText(4,messagetrustcomment); + st.ResultText(5,trustlisttrustcomment); + if(st.ResultNull(6)==false) + { + st.ResultInt(6,peermessagetrust); + } + if(st.ResultNull(7)==false) + { + st.ResultInt(7,peertrustlisttrust); + } StringFunctions::SplitMultiple(publickey,"@,",keyparts); if(keyparts.size()>1) @@ -194,7 +208,7 @@ const bool TrustExtension::GetTrustList(std::map nntpname=name+"@"+keyparts[1]; } - trustlist[nntpname]=std::pair(messagetrust,trustlisttrust); + trustlist[nntpname]=trust(messagetrust,peermessagetrust,messagetrustcomment,trustlisttrust,peertrustlisttrust,trustlisttrustcomment); st.Step(); } @@ -277,6 +291,39 @@ const bool TrustExtension::SetMessageTrust(const std::string &nntpname, const in } } +const bool TrustExtension::SetMessageTrustComment(const std::string &nntpname, const std::string &comment) +{ + if(m_localidentityid>=0) + { + int id=GetIdentityID(nntpname); + if(id>=0) + { + SQLite3DB::Statement st=m_db->Prepare("UPDATE tblIdentityTrust SET MessageTrustComment=? WHERE LocalIdentityID=? AND IdentityID=?;"); + if(comment=="") + { + st.Bind(0); + } + else + { + st.Bind(0,comment); + } + st.Bind(1,m_localidentityid); + st.Bind(2,id); + st.Step(); + + return true; + } + else + { + return false; + } + } + else + { + return false; + } +} + const bool TrustExtension::SetTrustListTrust(const std::string &nntpname, const int trust) { if(m_localidentityid>=0 && trust>=-1 && trust<=100) @@ -309,3 +356,36 @@ const bool TrustExtension::SetTrustListTrust(const std::string &nntpname, const return false; } } + +const bool TrustExtension::SetTrustListTrustComment(const std::string &nntpname, const std::string &comment) +{ + if(m_localidentityid>=0) + { + int id=GetIdentityID(nntpname); + if(id>=0) + { + SQLite3DB::Statement st=m_db->Prepare("UPDATE tblIdentityTrust SET TrustListTrustComment=? WHERE LocalIdentityID=? AND IdentityID=?;"); + if(comment=="") + { + st.Bind(0); + } + else + { + st.Bind(0,comment); + } + st.Bind(1,m_localidentityid); + st.Bind(2,id); + st.Step(); + + return true; + } + else + { + return false; + } + } + else + { + return false; + } +}