#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
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
\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
\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
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
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
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
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
}\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
}\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
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
}\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
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
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
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
{\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
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