version 0.2.19
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Sat, 31 May 2008 07:37:00 +0000 (09:37 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Sat, 31 May 2008 07:37:00 +0000 (09:37 +0200)
include/global.h
include/nntp/extensiontrust.h
readme.txt
src/freenet/messagelistrequester.cpp
src/freenet/messagerequester.cpp
src/nntp/extensiontrust.cpp
src/nntp/nntpconnection.cpp

index 912021c..ad3e445 100644 (file)
@@ -5,7 +5,7 @@
 #include <vector>\r
 #include "pthreadwrapper/thread.h"\r
 \r
-#define FMS_VERSION    "0.2.18"\r
+#define FMS_VERSION    "0.2.19"\r
 \r
 // opens database and creates tables and initial inserts if necessary\r
 void SetupDB();\r
index 3ff45ef..b916fc7 100644 (file)
@@ -9,6 +9,18 @@ public:
        TrustExtension();\r
        TrustExtension(const int &localidentityid);\r
 \r
+       struct trust\r
+       {\r
+               trust() {}\r
+               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) {}\r
+               int m_localmessagetrust;\r
+               int m_peermessagetrust;\r
+               std::string m_messagetrustcomment;\r
+               int m_localtrustlisttrust;\r
+               int m_peertrustlisttrust;\r
+               std::string m_trustlisttrustcomment;\r
+       };\r
+\r
        void SetLocalIdentityID(const int id)   { m_localidentityid=id; }\r
 \r
        const bool GetMessageTrust(const std::string &nntpname, int &trust);\r
@@ -18,8 +30,10 @@ public:
 \r
        const bool SetMessageTrust(const std::string &nntpname, const int trust);\r
        const bool SetTrustListTrust(const std::string &nntpname, const int trust);\r
+       const bool SetMessageTrustComment(const std::string &nntpname, const std::string &comment);\r
+       const bool SetTrustListTrustComment(const std::string &nntpname, const std::string &comment);\r
 \r
-       const bool GetTrustList(std::map<std::string,std::pair<int,int> > &trustlist);\r
+       const bool GetTrustList(std::map<std::string,trust> &trustlist);\r
 \r
 private:\r
 \r
index 4874179..420fdf1 100644 (file)
@@ -20,9 +20,11 @@ noted.
 \r
 INSTALLATION\r
 ------------\r
-Place the binary and any templates in a directory of your choice.  On the first\r
-run, a database file will also be created in this directory.  Make sure the\r
-user that runs FMS has read/write access to this directory.\r
+Place the binary and any templates in a directory of your choice.  Windows\r
+users may need to download the runtime DLLs available from the fms Freesite and\r
+place in the fms directory if they are not already installed on the system.  On\r
+the first run, a database file will also be created in this directory.  Make\r
+sure the user that runs FMS has read/write access to this directory.\r
 \r
 RUNNING\r
 -------\r
@@ -112,10 +114,13 @@ identities with NULL local trust list trust.
 NNTP EXTENSIONS\r
 ---------------\r
 The following commands are available through the NNTP connection.  The client\r
-must have authenticated for the commands to work.\r
+must have authenticated for the commands to work.  Comments MUST be surrounded\r
+by ".\r
 \r
 XSETTRUST MESSAGE userid@keypart val\r
 XSETTRUST TRUSTLIST userid@keypart val\r
+XSETTRUST MESSAGECOMMENT userid@keypart "comment"\r
+XSETTRUST TRUSTLISTCOMMENT userid@keypart "comment"\r
 \r
 Responses:\r
 2xx Trust Set\r
@@ -133,11 +138,10 @@ Responses:
 5xx Syntax error\r
 \r
 XGETTRUSTLIST\r
-messagetrust and trustlisttrust will be 0 to 100 or can be the string "null"\r
-without quotes.\r
+trust values will be 0 to 100 or can be the string "null" without quotes.\r
 \r
 Responses:\r
 2xx Trust List Follows\r
-userid@keypart TAB messagetrust TAB trustlisttrust\r
+userid@keypart TAB messagetrust TAB trustlisttrust TAB peermessagetrust TAB peertrustlisttrust TAB messagecomment TAB trustlistcomment\r
 .\r
 4xx other error\r
index 75f2e02..12ed511 100644 (file)
@@ -288,7 +288,8 @@ void MessageListRequester::StartRequest(const long &id)
                        if(st2.ResultNull(0)==false)\r
                        {\r
                                st2.ResultInt(0,index);\r
-                               index++;\r
+                               // don't increment index here - the node will let us know if there is a new edition\r
+                               //index++;\r
                        }\r
                }\r
                st2.Finalize();\r
index 70a5dba..f13d04d 100644 (file)
@@ -494,7 +494,7 @@ void MessageRequester::StartRequest(const std::string &requestid)
                message["Identifier"]=m_fcpuniquename+"|"+requestid+"|"+parts[0]+"|"+parts[1]+"|"+parts[2]+"|"+message["URI"];\r
                message["ReturnType"]="direct";\r
                message["MaxSize"]="1000000";           // 1 MB\r
-               message["MaxRetries"]="-1";                     // use new ULPR since we are fairly sure message exists since the author says it does\r
+               message["MaxRetries"]="-1";                     // use ULPR since we are fairly sure message exists since the author says it does\r
 \r
                m_fcp->SendMessage(message);\r
 \r
index 8a50beb..eb0a765 100644 (file)
@@ -161,17 +161,21 @@ const bool TrustExtension::GetPeerTrustListTrust(const std::string &nntpname, in
        }\r
 }\r
 \r
-const bool TrustExtension::GetTrustList(std::map<std::string,std::pair<int,int> > &trustlist)\r
+const bool TrustExtension::GetTrustList(std::map<std::string,trust> &trustlist)\r
 {\r
        if(m_localidentityid>=0)\r
        {\r
-               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 <> '' ;");\r
+               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 <> '' ;");\r
                st.Bind(0,m_localidentityid);\r
                st.Step();\r
                while(st.RowReturned())\r
                {\r
                        int messagetrust=-1;\r
                        int trustlisttrust=-1;\r
+                       int peermessagetrust=-1;\r
+                       int peertrustlisttrust=-1;\r
+                       std::string messagetrustcomment="";\r
+                       std::string trustlisttrustcomment="";\r
                        std::string name="";\r
                        std::string publickey="";\r
                        std::vector<std::string> keyparts;\r
@@ -187,6 +191,16 @@ const bool TrustExtension::GetTrustList(std::map<std::string,std::pair<int,int>
                        }\r
                        st.ResultText(2,name);\r
                        st.ResultText(3,publickey);\r
+                       st.ResultText(4,messagetrustcomment);\r
+                       st.ResultText(5,trustlisttrustcomment);\r
+                       if(st.ResultNull(6)==false)\r
+                       {\r
+                               st.ResultInt(6,peermessagetrust);\r
+                       }\r
+                       if(st.ResultNull(7)==false)\r
+                       {\r
+                               st.ResultInt(7,peertrustlisttrust);\r
+                       }\r
 \r
                        StringFunctions::SplitMultiple(publickey,"@,",keyparts);\r
                        if(keyparts.size()>1)\r
@@ -194,7 +208,7 @@ const bool TrustExtension::GetTrustList(std::map<std::string,std::pair<int,int>
                                nntpname=name+"@"+keyparts[1];\r
                        }\r
 \r
-                       trustlist[nntpname]=std::pair<int,int>(messagetrust,trustlisttrust);\r
+                       trustlist[nntpname]=trust(messagetrust,peermessagetrust,messagetrustcomment,trustlisttrust,peertrustlisttrust,trustlisttrustcomment);\r
 \r
                        st.Step();\r
                }\r
@@ -277,6 +291,39 @@ const bool TrustExtension::SetMessageTrust(const std::string &nntpname, const in
        }\r
 }\r
 \r
+const bool TrustExtension::SetMessageTrustComment(const std::string &nntpname, const std::string &comment)\r
+{\r
+       if(m_localidentityid>=0)\r
+       {\r
+               int id=GetIdentityID(nntpname);\r
+               if(id>=0)\r
+               {\r
+                       SQLite3DB::Statement st=m_db->Prepare("UPDATE tblIdentityTrust SET MessageTrustComment=? WHERE LocalIdentityID=? AND IdentityID=?;");\r
+                       if(comment=="")\r
+                       {\r
+                               st.Bind(0);\r
+                       }\r
+                       else\r
+                       {\r
+                               st.Bind(0,comment);\r
+                       }\r
+                       st.Bind(1,m_localidentityid);\r
+                       st.Bind(2,id);\r
+                       st.Step();\r
+\r
+                       return true;\r
+               }\r
+               else\r
+               {\r
+                       return false;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r
+\r
 const bool TrustExtension::SetTrustListTrust(const std::string &nntpname, const int trust)\r
 {\r
        if(m_localidentityid>=0 && trust>=-1 && trust<=100)\r
@@ -309,3 +356,36 @@ const bool TrustExtension::SetTrustListTrust(const std::string &nntpname, const
                return false;\r
        }\r
 }\r
+\r
+const bool TrustExtension::SetTrustListTrustComment(const std::string &nntpname, const std::string &comment)\r
+{\r
+       if(m_localidentityid>=0)\r
+       {\r
+               int id=GetIdentityID(nntpname);\r
+               if(id>=0)\r
+               {\r
+                       SQLite3DB::Statement st=m_db->Prepare("UPDATE tblIdentityTrust SET TrustListTrustComment=? WHERE LocalIdentityID=? AND IdentityID=?;");\r
+                       if(comment=="")\r
+                       {\r
+                               st.Bind(0);\r
+                       }\r
+                       else\r
+                       {\r
+                               st.Bind(0,comment);\r
+                       }\r
+                       st.Bind(1,m_localidentityid);\r
+                       st.Bind(2,id);\r
+                       st.Step();\r
+\r
+                       return true;\r
+               }\r
+               else\r
+               {\r
+                       return false;\r
+               }\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r
index 99914cd..eecbec6 100644 (file)
@@ -268,6 +268,10 @@ const bool NNTPConnection::HandleGetTrustCommand(const NNTPCommand &command)
                                std::string nntpname="";\r
                                for(int i=1; i<command.m_arguments.size(); i++)\r
                                {\r
+                                       if(i!=1)\r
+                                       {\r
+                                               nntpname+=" ";\r
+                                       }\r
                                        nntpname+=command.m_arguments[i];\r
                                }\r
 \r
@@ -340,31 +344,54 @@ const bool NNTPConnection::HandleGetTrustListCommand(const NNTPCommand &command)
        if(m_status.m_authenticated)\r
        {\r
                TrustExtension tr(m_status.m_authuser.GetID());\r
-               std::map<std::string,std::pair<int,int> > trustlist;\r
+               std::map<std::string,TrustExtension::trust> trustlist;\r
                if(tr.GetTrustList(trustlist))\r
                {\r
                        SendBufferedLine("280 Trust list follows");\r
-                       for(std::map<std::string,std::pair<int,int> >::iterator i=trustlist.begin(); i!=trustlist.end(); i++)\r
+                       for(std::map<std::string,TrustExtension::trust>::iterator i=trustlist.begin(); i!=trustlist.end(); i++)\r
                        {\r
                                std::ostringstream tempstr;\r
                                tempstr << (*i).first << "\t";\r
-                               if((*i).second.first>-1)\r
+                               if((*i).second.m_localmessagetrust>-1)\r
                                {\r
-                                       tempstr << (*i).second.first;\r
+                                       tempstr << (*i).second.m_localmessagetrust;\r
                                } \r
                                else\r
                                {\r
                                        tempstr << "null";\r
                                }\r
                                tempstr << "\t";\r
-                               if((*i).second.second>-1)\r
+                               if((*i).second.m_localtrustlisttrust>-1)\r
+                               {\r
+                                       tempstr << (*i).second.m_localtrustlisttrust;\r
+                               }\r
+                               else\r
+                               {\r
+                                       tempstr << "null";\r
+                               }\r
+                               tempstr << "\t";\r
+                               if((*i).second.m_peermessagetrust>-1)\r
+                               {\r
+                                       tempstr << (*i).second.m_peermessagetrust;\r
+                               }\r
+                               else\r
+                               {\r
+                                       tempstr << "null";\r
+                               }\r
+                               tempstr << "\t";\r
+                               if((*i).second.m_peertrustlisttrust>-1)\r
                                {\r
-                                       tempstr << (*i).second.second;\r
+                                       tempstr << (*i).second.m_peertrustlisttrust;\r
                                }\r
                                else\r
                                {\r
                                        tempstr << "null";\r
                                }\r
+                               tempstr << "\t";\r
+                               tempstr << (*i).second.m_messagetrustcomment;\r
+                               tempstr << "\t";\r
+                               tempstr << (*i).second.m_trustlisttrustcomment;\r
+\r
                                SendBufferedLine(tempstr.str());\r
                        }\r
                        SendBufferedLine(".");\r
@@ -1086,26 +1113,76 @@ const bool NNTPConnection::HandleSetTrustCommand(const NNTPCommand &command)
        {\r
                std::string type=command.m_arguments[0];\r
                StringFunctions::UpperCase(type,type);\r
-               if(type=="MESSAGE" || type=="TRUSTLIST")\r
+               if(type=="MESSAGE" || type=="TRUSTLIST" || type=="MESSAGECOMMENT" || type=="TRUSTLISTCOMMENT")\r
                {\r
                        if(m_status.m_authenticated)\r
                        {\r
                                bool found=false;\r
                                bool valid=false;\r
                                int trust=-1;\r
+                               std::string comment="";\r
                                std::string nntpname="";\r
-                               for(int i=1; i<command.m_arguments.size()-1; i++)\r
-                               {\r
-                                       nntpname+=command.m_arguments[i];\r
-                               }\r
 \r
-                               if(command.m_arguments[command.m_arguments.size()-1]!="null")\r
+                               if(type=="MESSAGE" || type=="TRUSTLIST")\r
                                {\r
-                                       StringFunctions::Convert(command.m_arguments[command.m_arguments.size()-1],trust);\r
-                               }\r
+                                       for(int i=1; i<command.m_arguments.size()-1; i++)\r
+                                       {\r
+                                               if(i!=1)\r
+                                               {\r
+                                                       nntpname+=" ";\r
+                                               }\r
+                                               nntpname+=command.m_arguments[i];\r
+                                       }\r
+\r
+                                       if(command.m_arguments[command.m_arguments.size()-1]!="null")\r
+                                       {\r
+                                               StringFunctions::Convert(command.m_arguments[command.m_arguments.size()-1],trust);\r
+                                       }\r
 \r
-                               if(trust>=-1 && trust<=100)\r
+                                       if(trust>=-1 && trust<=100)\r
+                                       {\r
+                                               valid=true;\r
+                                       }\r
+                               }\r
+                               else\r
                                {\r
+                                       int startpos=-1;\r
+                                       // get nntpname\r
+                                       for(int i=1; i<command.m_arguments.size() && startpos==-1; i++)\r
+                                       {\r
+                                               if(command.m_arguments[i].size()>0 && command.m_arguments[i][0]!='\"')\r
+                                               {\r
+                                                       if(i!=1)\r
+                                                       {\r
+                                                               nntpname+=" ";\r
+                                                       }\r
+                                                       nntpname+=command.m_arguments[i];\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       startpos=i;\r
+                                               }\r
+                                       }\r
+\r
+                                       // get comment\r
+                                       for(int i=startpos; i<command.m_arguments.size(); i++)\r
+                                       {\r
+                                               if(i!=startpos)\r
+                                               {\r
+                                                       comment+=" ";\r
+                                               }\r
+                                               comment+=command.m_arguments[i];\r
+                                       }\r
+                                       // strip " from comment beginning and end\r
+                                       if(comment.size()>0 && comment[0]=='\"')\r
+                                       {\r
+                                               comment.erase(0,1);\r
+                                       }\r
+                                       if(comment.size()>0 && comment[comment.size()-1]=='\"')\r
+                                       {\r
+                                               comment.erase(comment.size()-1);\r
+                                       }\r
+\r
                                        valid=true;\r
                                }\r
 \r
@@ -1125,6 +1202,20 @@ const bool NNTPConnection::HandleSetTrustCommand(const NNTPCommand &command)
                                                found=true;\r
                                        }\r
                                }\r
+                               if(type=="MESSAGECOMMENT")\r
+                               {\r
+                                       if(tr.SetMessageTrustComment(nntpname,comment))\r
+                                       {\r
+                                               found=true;\r
+                                       }\r
+                               }\r
+                               if(type=="TRUSTLISTCOMMENT")\r
+                               {\r
+                                       if(tr.SetTrustListTrustComment(nntpname,comment))\r
+                                       {\r
+                                               found=true;\r
+                                       }\r
+                               }\r
 \r
                                if(found && valid)\r
                                {\r