From: SomeDude Date: Sat, 31 May 2008 07:37:00 +0000 (+0200) Subject: version 0.2.19 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=3f6f19146f015fa8d2c89f1e72cd467dbc4115aa;p=fms.git version 0.2.19 --- diff --git a/include/global.h b/include/global.h index 912021c..ad3e445 100644 --- a/include/global.h +++ b/include/global.h @@ -5,7 +5,7 @@ #include #include "pthreadwrapper/thread.h" -#define FMS_VERSION "0.2.18" +#define FMS_VERSION "0.2.19" // opens database and creates tables and initial inserts if necessary void SetupDB(); diff --git a/include/nntp/extensiontrust.h b/include/nntp/extensiontrust.h index 3ff45ef..b916fc7 100644 --- a/include/nntp/extensiontrust.h +++ b/include/nntp/extensiontrust.h @@ -9,6 +9,18 @@ public: TrustExtension(); TrustExtension(const int &localidentityid); + struct trust + { + trust() {} + trust(const int localmessagetrust, const int peermessagetrust, const std::string &messagetrustcomment, const int localtrustlisttrust, const int peertrustlisttrust, const std::string &trustlisttrustcomment):m_localmessagetrust(localmessagetrust),m_peermessagetrust(peermessagetrust),m_messagetrustcomment(messagetrustcomment),m_localtrustlisttrust(localtrustlisttrust),m_peertrustlisttrust(peertrustlisttrust),m_trustlisttrustcomment(trustlisttrustcomment) {} + int m_localmessagetrust; + int m_peermessagetrust; + std::string m_messagetrustcomment; + int m_localtrustlisttrust; + int m_peertrustlisttrust; + std::string m_trustlisttrustcomment; + }; + void SetLocalIdentityID(const int id) { m_localidentityid=id; } const bool GetMessageTrust(const std::string &nntpname, int &trust); @@ -18,8 +30,10 @@ public: const bool SetMessageTrust(const std::string &nntpname, const int trust); const bool SetTrustListTrust(const std::string &nntpname, const int trust); + const bool SetMessageTrustComment(const std::string &nntpname, const std::string &comment); + const bool SetTrustListTrustComment(const std::string &nntpname, const std::string &comment); - const bool GetTrustList(std::map > &trustlist); + const bool GetTrustList(std::map &trustlist); private: diff --git a/readme.txt b/readme.txt index 4874179..420fdf1 100644 --- a/readme.txt +++ b/readme.txt @@ -20,9 +20,11 @@ noted. INSTALLATION ------------ -Place the binary and any templates in a directory of your choice. On the first -run, a database file will also be created in this directory. Make sure the -user that runs FMS has read/write access to this directory. +Place the binary and any templates in a directory of your choice. Windows +users may need to download the runtime DLLs available from the fms Freesite and +place in the fms directory if they are not already installed on the system. On +the first run, a database file will also be created in this directory. Make +sure the user that runs FMS has read/write access to this directory. RUNNING ------- @@ -112,10 +114,13 @@ identities with NULL local trust list trust. NNTP EXTENSIONS --------------- The following commands are available through the NNTP connection. The client -must have authenticated for the commands to work. +must have authenticated for the commands to work. Comments MUST be surrounded +by ". XSETTRUST MESSAGE userid@keypart val XSETTRUST TRUSTLIST userid@keypart val +XSETTRUST MESSAGECOMMENT userid@keypart "comment" +XSETTRUST TRUSTLISTCOMMENT userid@keypart "comment" Responses: 2xx Trust Set @@ -133,11 +138,10 @@ Responses: 5xx Syntax error XGETTRUSTLIST -messagetrust and trustlisttrust will be 0 to 100 or can be the string "null" -without quotes. +trust values will be 0 to 100 or can be the string "null" without quotes. Responses: 2xx Trust List Follows -userid@keypart TAB messagetrust TAB trustlisttrust +userid@keypart TAB messagetrust TAB trustlisttrust TAB peermessagetrust TAB peertrustlisttrust TAB messagecomment TAB trustlistcomment . 4xx other error diff --git a/src/freenet/messagelistrequester.cpp b/src/freenet/messagelistrequester.cpp index 75f2e02..12ed511 100644 --- a/src/freenet/messagelistrequester.cpp +++ b/src/freenet/messagelistrequester.cpp @@ -288,7 +288,8 @@ void MessageListRequester::StartRequest(const long &id) if(st2.ResultNull(0)==false) { st2.ResultInt(0,index); - index++; + // don't increment index here - the node will let us know if there is a new edition + //index++; } } st2.Finalize(); diff --git a/src/freenet/messagerequester.cpp b/src/freenet/messagerequester.cpp index 70a5dba..f13d04d 100644 --- a/src/freenet/messagerequester.cpp +++ b/src/freenet/messagerequester.cpp @@ -494,7 +494,7 @@ void MessageRequester::StartRequest(const std::string &requestid) message["Identifier"]=m_fcpuniquename+"|"+requestid+"|"+parts[0]+"|"+parts[1]+"|"+parts[2]+"|"+message["URI"]; message["ReturnType"]="direct"; message["MaxSize"]="1000000"; // 1 MB - message["MaxRetries"]="-1"; // use new ULPR since we are fairly sure message exists since the author says it does + message["MaxRetries"]="-1"; // use ULPR since we are fairly sure message exists since the author says it does m_fcp->SendMessage(message); 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; + } +} diff --git a/src/nntp/nntpconnection.cpp b/src/nntp/nntpconnection.cpp index 99914cd..eecbec6 100644 --- a/src/nntp/nntpconnection.cpp +++ b/src/nntp/nntpconnection.cpp @@ -268,6 +268,10 @@ const bool NNTPConnection::HandleGetTrustCommand(const NNTPCommand &command) std::string nntpname=""; for(int i=1; i > trustlist; + std::map trustlist; if(tr.GetTrustList(trustlist)) { SendBufferedLine("280 Trust list follows"); - for(std::map >::iterator i=trustlist.begin(); i!=trustlist.end(); i++) + for(std::map::iterator i=trustlist.begin(); i!=trustlist.end(); i++) { std::ostringstream tempstr; tempstr << (*i).first << "\t"; - if((*i).second.first>-1) + if((*i).second.m_localmessagetrust>-1) { - tempstr << (*i).second.first; + tempstr << (*i).second.m_localmessagetrust; } else { tempstr << "null"; } tempstr << "\t"; - if((*i).second.second>-1) + if((*i).second.m_localtrustlisttrust>-1) + { + tempstr << (*i).second.m_localtrustlisttrust; + } + else + { + tempstr << "null"; + } + tempstr << "\t"; + if((*i).second.m_peermessagetrust>-1) + { + tempstr << (*i).second.m_peermessagetrust; + } + else + { + tempstr << "null"; + } + tempstr << "\t"; + if((*i).second.m_peertrustlisttrust>-1) { - tempstr << (*i).second.second; + tempstr << (*i).second.m_peertrustlisttrust; } else { tempstr << "null"; } + tempstr << "\t"; + tempstr << (*i).second.m_messagetrustcomment; + tempstr << "\t"; + tempstr << (*i).second.m_trustlisttrustcomment; + SendBufferedLine(tempstr.str()); } SendBufferedLine("."); @@ -1086,26 +1113,76 @@ const bool NNTPConnection::HandleSetTrustCommand(const NNTPCommand &command) { std::string type=command.m_arguments[0]; StringFunctions::UpperCase(type,type); - if(type=="MESSAGE" || type=="TRUSTLIST") + if(type=="MESSAGE" || type=="TRUSTLIST" || type=="MESSAGECOMMENT" || type=="TRUSTLISTCOMMENT") { if(m_status.m_authenticated) { bool found=false; bool valid=false; int trust=-1; + std::string comment=""; std::string nntpname=""; - for(int i=1; i=-1 && trust<=100) + if(trust>=-1 && trust<=100) + { + valid=true; + } + } + else { + int startpos=-1; + // get nntpname + for(int i=1; i0 && command.m_arguments[i][0]!='\"') + { + if(i!=1) + { + nntpname+=" "; + } + nntpname+=command.m_arguments[i]; + } + else + { + startpos=i; + } + } + + // get comment + for(int i=startpos; i0 && comment[0]=='\"') + { + comment.erase(0,1); + } + if(comment.size()>0 && comment[comment.size()-1]=='\"') + { + comment.erase(comment.size()-1); + } + valid=true; } @@ -1125,6 +1202,20 @@ const bool NNTPConnection::HandleSetTrustCommand(const NNTPCommand &command) found=true; } } + if(type=="MESSAGECOMMENT") + { + if(tr.SetMessageTrustComment(nntpname,comment)) + { + found=true; + } + } + if(type=="TRUSTLISTCOMMENT") + { + if(tr.SetTrustListTrustComment(nntpname,comment)) + { + found=true; + } + } if(found && valid) {