version 0.2.2
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Fri, 21 Mar 2008 13:13:00 +0000 (14:13 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 21 Mar 2008 13:13:00 +0000 (14:13 +0100)
13 files changed:
include/freenet/trustlistxml.h
include/global.h
readme.txt
src/freenet/captcha/simplecaptcha.cpp
src/freenet/identityintroductionrequester.cpp
src/freenet/identityrequester.cpp
src/freenet/trustlistinserter.cpp
src/freenet/trustlistrequester.cpp
src/freenet/trustlistxml.cpp
src/global.cpp
src/http/pages/peerdetailspage.cpp
src/http/pages/peertrustpage.cpp
src/main.cpp

index ac16d1f..7d08616 100644 (file)
@@ -12,10 +12,12 @@ class TrustListXML:public IFMSXMLDocument,public ILogger
 private:\r
        struct trust\r
        {\r
-               trust(const std::string &identity, const long messagetrust, const long trustlisttrust):m_identity(identity),m_messagetrust(messagetrust),m_trustlisttrust(trustlisttrust) {}\r
+               trust(const std::string &identity, const long messagetrust, const long trustlisttrust, const std::string &messagetrustcomment, const std::string &trustlisttrustcomment):m_identity(identity),m_messagetrust(messagetrust),m_trustlisttrust(trustlisttrust),m_messagetrustcomment(messagetrustcomment),m_trustlisttrustcomment(trustlisttrustcomment) {}\r
                std::string m_identity;\r
                long m_messagetrust;\r
                long m_trustlisttrust;\r
+               std::string m_messagetrustcomment;\r
+               std::string m_trustlisttrustcomment;\r
        };\r
 public:\r
        TrustListXML();\r
@@ -26,12 +28,14 @@ public:
 \r
        void ClearTrust()                       { m_trust.clear(); }\r
 \r
-       void AddTrust(const std::string &identity, const long messagetrust, const long trustlisttrust);\r
+       void AddTrust(const std::string &identity, const long messagetrust, const long trustlisttrust, const std::string &messagetrustcomment, const std::string &trustlisttrustcomment);\r
 \r
        const std::vector<trust>::size_type TrustCount()                { return m_trust.size(); }\r
        std::string GetIdentity(const long index);\r
        long GetMessageTrust(const long index);\r
        long GetTrustListTrust(const long index);\r
+       std::string GetMessageTrustComment(const long index);\r
+       std::string GetTrustListTrustComment(const long index);\r
 \r
 private:\r
        void Initialize();\r
index ddd6fa3..5240cc7 100644 (file)
@@ -5,13 +5,14 @@
 //#include <zthread/Thread.h>\r
 #include "pthreadwrapper/thread.h"\r
 \r
-#define FMS_VERSION    "0.2.1"\r
+#define FMS_VERSION    "0.2.2"\r
 \r
 // opens database and creates tables and initial inserts if necessary\r
 void SetupDB();\r
 void ConvertDB0100To0101();\r
 void ConvertDB0101To0103();\r
 void ConvertDB0103To0104();\r
+void ConvertDB0104To0105();\r
 // inserts default options into the database\r
 void SetupDefaultOptions();\r
 // opens logfile and sets it up\r
index 1c0fe8a..4cbc6d9 100644 (file)
@@ -68,7 +68,7 @@ TRUST
 -----\r
 Trust is the most important element of FMS.  It determines which identities you\r
 will download messages from and thus your overall experience.  Do not give\r
-trust to arbitrary identities.  Pick whom you trust wisely.  There settings for\r
+trust to arbitrary identities.  Pick whom you trust wisely.  The settings for\r
 minimum trust before downloading messages and trust lists can be changed on the\r
 web interface.\r
 \r
index 60e1d39..c84010f 100644 (file)
@@ -12,6 +12,7 @@ void SimpleCaptcha::Generate()
        BMP bmp;\r
        int bmpwidth=100;\r
        int bmpheight=50;\r
+       RGBApixel lettercols[5];\r
        std::string puzzlestring;\r
        std::string tempfilename=GenerateRandomString(10);\r
        tempfilename+=".bmp";\r
@@ -23,7 +24,7 @@ void SimpleCaptcha::Generate()
        bmp.SetSize(bmpwidth,bmpheight);\r
 \r
        // first draw some random lines around the bitmap\r
-       int numlines=(rand()%20)+10;\r
+       int numlines=(rand()%10)+10;\r
        for(int i=0; i<numlines; i++)\r
        {\r
                RGBApixel pixel;\r
@@ -38,15 +39,101 @@ void SimpleCaptcha::Generate()
                DrawAALine(bmp,x1,y1,x2,y2,pixel);\r
        }\r
 \r
-       // print puzzle onto bitmap\r
+       // draw some random arcs\r
+       int numarcs=(rand()%10)+10;\r
+       for(int i=0; i<numarcs; i++)\r
+       {\r
+               RGBApixel pixel;\r
+               int x1=rand()%bmpwidth;\r
+               int y1=rand()%bmpwidth;\r
+               int radius=rand()%(bmpheight/2);\r
+               double startangle=(double)(rand()%360)*(3.14159/180);\r
+               double endangle=(double)(rand()%360)*(3.14159/180);\r
+               pixel.Red=100+(rand()%150);\r
+               pixel.Green=100+(rand()%150);\r
+               DrawArc(bmp,x1,y1,radius,startangle,endangle,pixel);\r
+       }\r
+\r
        for(int i=0; i<5; i++)\r
        {\r
                // keep the colors dark\r
+               lettercols[i].Red=(rand()%200);\r
+               lettercols[i].Green=(rand()%200);\r
+               lettercols[i].Blue=(rand()%200);\r
+               // draw a line with the letter col\r
+               DrawAALine(bmp,rand()%bmpwidth,rand()%bmpheight,rand()%bmpwidth,rand()%bmpheight,lettercols[i]);\r
+       }\r
+\r
+       // print puzzle onto bitmap\r
+       for(int i=0; i<5; i++)\r
+       {\r
+               PrintLetter(bmp,puzzlestring[i],5+(i*20)+(rand()%11)-5,10+(rand()%10),20,lettercols[i]);\r
+       }\r
+\r
+       /* TOO dificult to solve with this\r
+       // skew image left/right\r
+       double skew=0;\r
+       for(int yy=0; yy<bmpheight; yy++)\r
+       {\r
                RGBApixel pixel;\r
-               pixel.Red=(rand()%200);\r
-               pixel.Green=(rand()%200);\r
-               pixel.Blue=(rand()%200);\r
-               PrintLetter(bmp,puzzlestring[i],5+(i*20),10+(rand()%10),20,pixel);\r
+               skew=skew+(double)((rand()%11)-5)/20.0;\r
+               int xx;\r
+               for(xx=0; xx<skew; xx++)\r
+               {\r
+                       pixel.Red=255;\r
+                       pixel.Green=255;\r
+                       pixel.Blue=255;\r
+                       bmp.SetPixel(xx,yy,pixel);\r
+               }\r
+               if(skew<0)\r
+               {\r
+                       for(xx=0; xx<bmpwidth+skew; xx++)\r
+                       {\r
+                               pixel=bmp.GetPixel(xx-skew,yy);\r
+                               bmp.SetPixel(xx,yy,pixel);\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       for(xx=bmpwidth-1; xx>skew; xx--)\r
+                       {\r
+                               pixel=bmp.GetPixel(xx-skew,yy);\r
+                               bmp.SetPixel(xx,yy,pixel);\r
+                       }\r
+               }\r
+               for(xx=bmpwidth+skew; xx<bmpwidth; xx++)\r
+               {\r
+                       pixel.Red=255;\r
+                       pixel.Green=255;\r
+                       pixel.Blue=255;\r
+                       bmp.SetPixel(xx,yy,pixel);\r
+               }\r
+       }\r
+       */\r
+\r
+       // generate noise for each pixel\r
+       for(int yy=0; yy<bmpheight; yy++)\r
+       {\r
+               for(int xx=0; xx<bmpwidth; xx++)\r
+               {\r
+                       RGBApixel pixel=bmp.GetPixel(xx,yy);\r
+                       int tempred=pixel.Red+(rand()%21)-10;\r
+                       int tempgreen=pixel.Green+(rand()%21)-10;\r
+                       int tempblue=pixel.Blue+(rand()%21)-10;\r
+\r
+                       tempred < 0 ? tempred=0 : false;\r
+                       tempred > 255 ? tempred=255 : false;\r
+                       tempgreen < 0 ? tempgreen=0 : false;\r
+                       tempgreen > 255 ? tempgreen=255 : false;\r
+                       tempblue < 0 ? tempblue=0 : false;\r
+                       tempblue > 255 ? tempblue=255 : false;\r
+\r
+                       pixel.Red=tempred;\r
+                       pixel.Green=tempgreen;\r
+                       pixel.Blue=tempblue;\r
+\r
+                       bmp.SetPixel(xx,yy,pixel);\r
+               }\r
        }\r
 \r
        bmp.WriteToFile(tempfilename.c_str());\r
index c408f48..0e5e3dd 100644 (file)
@@ -82,9 +82,10 @@ const bool IdentityIntroductionRequester::HandleAllData(FCPMessage &message)
                                // we don't already know about this id - add it\r
                                st.Finalize();\r
                                date.SetToGMTime();\r
-                               st=m_db->Prepare("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES(?,?);");\r
+                               st=m_db->Prepare("INSERT INTO tblIdentity(PublicKey,DateAdded,AddedMethod) VALUES(?,?,?);");\r
                                st.Bind(0,xml.GetIdentity());\r
                                st.Bind(1,date.Format("%Y-%m-%d %H:%M:%S"));\r
+                               st.Bind(2,"solved captcha");\r
                                st.Step();\r
                        }\r
                        st.Finalize();\r
index 93d65a8..b12fe08 100644 (file)
@@ -171,10 +171,12 @@ void IdentityRequester::PopulateIDList()
        int id;\r
 \r
        date.SetToGMTime();\r
-       date.Add(0,0,-1);\r
+       date.SetHour(0);\r
+       date.SetMinute(0);\r
+       date.SetSecond(0);\r
 \r
-       // select identities we want to query (haven't seen in last hour) - sort by their trust level (descending) with secondary sort on how long ago we saw them (ascending)\r
-       SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND (LastSeen IS NULL OR LastSeen<='"+date.Format("%Y-%m-%d %H:%M:%S")+"') ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");\r
+       // select identities we want to query (haven't seen yet today) - sort by their trust level (descending) with secondary sort on how long ago we saw them (ascending)\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND (LastSeen IS NULL OR LastSeen<'"+date.Format("%Y-%m-%d %H:%M:%S")+"') ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;");\r
        st.Step();\r
 \r
        m_ids.clear();\r
index 2d14f89..79745ee 100644 (file)
@@ -136,13 +136,15 @@ void TrustListInserter::StartInsert(const long localidentityid, const std::strin
        int index;\r
        std::string indexstr;\r
        std::string localidentityidstr;\r
+       std::string messagetrustcomment="";\r
+       std::string trustlisttrustcomment="";\r
 \r
        now.SetToGMTime();\r
        date.SetToGMTime();\r
 \r
        // build the xml file - we only want to add identities that we recently saw, otherwise we could be inserting a ton of identities\r
        date.Add(0,0,0,-20);    // identities seen in last 20 days\r
-       SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, LocalMessageTrust, LocalTrustListTrust FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LastSeen>=?;");\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT PublicKey, LocalMessageTrust, LocalTrustListTrust, MessageTrustComment, TrustListTrustComment FROM tblIdentity WHERE PublicKey IS NOT NULL AND PublicKey<>'' AND LastSeen>=?;");\r
        st.Bind(0,date.Format("%Y-%m-%d"));\r
        st.Step();\r
        while(st.RowReturned())\r
@@ -164,7 +166,9 @@ void TrustListInserter::StartInsert(const long localidentityid, const std::strin
                {\r
                        trustlisttrust=-1;\r
                }\r
-               xml.AddTrust(publickey,messagetrust,trustlisttrust);\r
+               st.ResultText(3,messagetrustcomment);\r
+               st.ResultText(4,trustlisttrustcomment);\r
+               xml.AddTrust(publickey,messagetrust,trustlisttrust,messagetrustcomment,trustlisttrustcomment);\r
                st.Step();\r
        }\r
 \r
index 90606dd..89da83a 100644 (file)
@@ -54,6 +54,24 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message)
        // 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
@@ -62,19 +80,30 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message)
                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
@@ -101,6 +130,19 @@ const bool TrustListRequester::HandleAllData(FCPMessage &message)
                        {\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
index d732105..6b0329a 100644 (file)
@@ -12,9 +12,9 @@ TrustListXML::TrustListXML()
        Initialize();\r
 }\r
 \r
-void TrustListXML::AddTrust(const std::string &identity, const long messagetrust, const long trustlisttrust)\r
+void TrustListXML::AddTrust(const std::string &identity, const long messagetrust, const long trustlisttrust, const std::string &messagetrustcomment, const std::string &trustlisttrustcomment)\r
 {\r
-       m_trust.push_back(trust(identity,messagetrust,trustlisttrust));\r
+       m_trust.push_back(trust(identity,messagetrust,trustlisttrust,messagetrustcomment,trustlisttrustcomment));\r
 }\r
 \r
 std::string TrustListXML::GetIdentity(const long index)\r
@@ -41,6 +41,18 @@ long TrustListXML::GetMessageTrust(const long index)
        }       \r
 }\r
 \r
+std::string TrustListXML::GetMessageTrustComment(const long index)\r
+{\r
+       if(index>=0 && index<m_trust.size())\r
+       {\r
+               return m_trust[index].m_messagetrustcomment;\r
+       }\r
+       else\r
+       {\r
+               return "";\r
+       }       \r
+}\r
+\r
 long TrustListXML::GetTrustListTrust(const long index)\r
 {\r
        if(index>=0 && index<m_trust.size())\r
@@ -53,6 +65,18 @@ long TrustListXML::GetTrustListTrust(const long index)
        }\r
 }\r
 \r
+std::string TrustListXML::GetTrustListTrustComment(const long index)\r
+{\r
+       if(index>=0 && index<m_trust.size())\r
+       {\r
+               return m_trust[index].m_trustlisttrustcomment;\r
+       }\r
+       else\r
+       {\r
+               return "";\r
+       }\r
+}\r
+\r
 std::string TrustListXML::GetXML()\r
 {\r
        TiXmlDocument td;\r
@@ -81,6 +105,14 @@ std::string TrustListXML::GetXML()
                {\r
                        tr->LinkEndChild(XMLCreateTextElement("TrustListTrustLevel",trustlisttrust));\r
                }\r
+               if((*i).m_messagetrustcomment!="")\r
+               {\r
+                       tr->LinkEndChild(XMLCreateCDATAElement("MessageTrustComment",(*i).m_messagetrustcomment));\r
+               }\r
+               if((*i).m_trustlisttrustcomment!="")\r
+               {\r
+                       tr->LinkEndChild(XMLCreateCDATAElement("TrustListTrustComment",(*i).m_trustlisttrustcomment));\r
+               }\r
        }\r
 \r
        td.Accept(&tp);\r
@@ -102,6 +134,8 @@ const bool TrustListXML::ParseXML(const std::string &xml)
                std::string identity;\r
                std::string messagetruststr;\r
                std::string trustlisttruststr;\r
+               std::string messagetrustcomment="";\r
+               std::string trustlisttrustcomment="";\r
                long messagetrust;\r
                long trustlisttrust;\r
                TiXmlText *txt;\r
@@ -142,6 +176,16 @@ const bool TrustListXML::ParseXML(const std::string &xml)
                                        StringFunctions::Convert(trustlisttruststr,trustlisttrust);\r
                                }\r
                        }\r
+                       txt=hnd2.FirstChild("MessageTrustComment").FirstChild().ToText();\r
+                       if(txt)\r
+                       {\r
+                               messagetrustcomment=txt->ValueStr();\r
+                       }\r
+                       txt=hnd2.FirstChild("TrustListTrustComment").FirstChild().ToText();\r
+                       if(txt)\r
+                       {\r
+                               trustlisttrustcomment=txt->ValueStr();\r
+                       }\r
 \r
                        if(identity!="" && messagetrust>=-1 && messagetrust<=100 && trustlisttrust>=-1 && trustlisttrust<=100)\r
                        {\r
@@ -149,7 +193,7 @@ const bool TrustListXML::ParseXML(const std::string &xml)
                                if(std::find(m_foundkeys.begin(),m_foundkeys.end(),identity)==m_foundkeys.end())\r
                                {\r
                                        m_foundkeys.push_back(identity);\r
-                                       m_trust.push_back(trust(identity,messagetrust,trustlisttrust));\r
+                                       m_trust.push_back(trust(identity,messagetrust,trustlisttrust,messagetrustcomment,trustlisttrustcomment));\r
                                }\r
                        }\r
                        else\r
index 0698703..087ce1c 100644 (file)
@@ -28,9 +28,6 @@ void SetupDB()
        db->Open("fms.db3");\r
        db->SetBusyTimeout(10000);              // set timeout to 10 seconds\r
        db->Execute("VACUUM;");\r
-       \r
-       // TODO remove this - temp fix for problem in 0.1.8\r
-       db->Execute("DELETE FROM tblMessageBoard WHERE MessageID NOT IN (SELECT MessageID FROM tblMessage);");\r
 \r
        db->Execute("CREATE TABLE IF NOT EXISTS tblDBVersion(\\r
                                Major                           INTEGER,\\r
@@ -64,10 +61,16 @@ void SetupDB()
                        major=1;\r
                        minor=4;\r
                }\r
+               if(major==1 && minor==4)\r
+               {\r
+                       ConvertDB0104To0105();\r
+                       major=1;\r
+                       minor=5;\r
+               }\r
        }\r
        else\r
        {\r
-               db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,4);");\r
+               db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,5);");\r
        }\r
 \r
        db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;");\r
@@ -131,18 +134,21 @@ void SetupDB()
                                );");\r
 \r
        db->Execute("CREATE TABLE IF NOT EXISTS tblIdentity(\\r
-                               IdentityID                      INTEGER PRIMARY KEY,\\r
-                               PublicKey                       TEXT UNIQUE,\\r
-                               Name                            TEXT,\\r
-                               SingleUse                       BOOL CHECK(SingleUse IN('true','false')) DEFAULT 'false',\\r
-                               PublishTrustList        BOOL CHECK(PublishTrustList IN('true','false')) DEFAULT 'false',\\r
-                               PublishBoardList        BOOL CHECK(PublishBoardList IN('true','false')) DEFAULT 'false',\\r
-                               DateAdded                       DATETIME,\\r
-                               LastSeen                        DATETIME,\\r
-                               LocalMessageTrust       INTEGER CHECK(LocalMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
-                               PeerMessageTrust        INTEGER CHECK(PeerMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
-                               LocalTrustListTrust     INTEGER CHECK(LocalTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
-                               PeerTrustListTrust      INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL\\r
+                               IdentityID                              INTEGER PRIMARY KEY,\\r
+                               PublicKey                               TEXT UNIQUE,\\r
+                               Name                                    TEXT,\\r
+                               SingleUse                               BOOL CHECK(SingleUse IN('true','false')) DEFAULT 'false',\\r
+                               PublishTrustList                BOOL CHECK(PublishTrustList IN('true','false')) DEFAULT 'false',\\r
+                               PublishBoardList                BOOL CHECK(PublishBoardList IN('true','false')) DEFAULT 'false',\\r
+                               DateAdded                               DATETIME,\\r
+                               LastSeen                                DATETIME,\\r
+                               LocalMessageTrust               INTEGER CHECK(LocalMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
+                               PeerMessageTrust                INTEGER CHECK(PeerMessageTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
+                               LocalTrustListTrust             INTEGER CHECK(LocalTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
+                               PeerTrustListTrust              INTEGER CHECK(PeerTrustListTrust BETWEEN 0 AND 100) DEFAULT NULL,\\r
+                               AddedMethod                             TEXT,\\r
+                               MessageTrustComment             TEXT,\\r
+                               TrustListTrustComment   TEXT\\r
                                );");\r
 \r
        db->Execute("CREATE TABLE IF NOT EXISTS tblIdentityRequests(\\r
@@ -172,10 +178,12 @@ void SetupDB()
                                );");\r
 \r
        db->Execute("CREATE TABLE IF NOT EXISTS tblPeerTrust(\\r
-                               IdentityID                      INTEGER,\\r
-                               TargetIdentityID        INTEGER,\\r
-                               MessageTrust            INTEGER CHECK(MessageTrust BETWEEN 0 AND 100),\\r
-                               TrustListTrust          INTEGER CHECK(TrustListTrust BETWEEN 0 AND 100)\\r
+                               IdentityID                              INTEGER,\\r
+                               TargetIdentityID                INTEGER,\\r
+                               MessageTrust                    INTEGER CHECK(MessageTrust BETWEEN 0 AND 100),\\r
+                               TrustListTrust                  INTEGER CHECK(TrustListTrust BETWEEN 0 AND 100),\\r
+                               MessageTrustComment             TEXT,\\r
+                               TrustListTrustComment   TEXT\\r
                                );");\r
 \r
        db->Execute("CREATE TABLE IF NOT EXISTS tblBoard(\\r
@@ -463,6 +471,19 @@ void ConvertDB0103To0104()
        db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;");\r
 }\r
 \r
+void ConvertDB0104To0105()\r
+{\r
+       // add AddedMethod, MessageTrustComment, TrustListTrustComment to tblIdentity\r
+       // add MessageTrustComment,TrustListTrustComment to tblPeerTrust\r
+       SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+       db->Execute("ALTER TABLE tblIdentity ADD COLUMN AddedMethod TEXT;");\r
+       db->Execute("ALTER TABLE tblIdentity ADD COLUMN MessageTrustComment TEXT;");\r
+       db->Execute("ALTER TABLE tblIdentity ADD COLUMN TrustListTrustComment TEXT;");\r
+       db->Execute("ALTER TABLE tblPeerTrust ADD COLUMN MessageTrustComment TEXT;");\r
+       db->Execute("ALTER TABLE tblPeerTrust ADD COLUMN TrustListTrustComment TEXT;");\r
+       db->Execute("UPDATE tblDBVersion SET Major=1, Minor=5;");\r
+}\r
+\r
 void SetupDefaultOptions()\r
 {\r
        // OptionValue should always be inserted as a string, even if the option really isn't a string - just to keep the field data type consistent\r
index 7f06fd2..1ff0493 100644 (file)
@@ -17,6 +17,7 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const
        std::string keypart="";\r
        std::string lastseen="";\r
        std::string dateadded="";\r
+       std::string addedmethod="";\r
 \r
        if(queryvars.find("identityid")!=queryvars.end() && (*queryvars.find("identityid")).second!="")\r
        {\r
@@ -31,7 +32,7 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const
                del.Step();\r
        }\r
 \r
-       SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen FROM tblIdentity WHERE IdentityID=?;");\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT Name,PublicKey,DateAdded,LastSeen,AddedMethod FROM tblIdentity WHERE IdentityID=?;");\r
        st.Bind(0,identityid);\r
        st.Step();\r
 \r
@@ -42,11 +43,13 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const
                st.ResultText(1,publickey);\r
                st.ResultText(2,dateadded);\r
                st.ResultText(3,lastseen);\r
+               st.ResultText(4,addedmethod);\r
 \r
                content+="<tr><td>Name</td><td>"+SanitizeOutput(name)+"</td></tr>";\r
                content+="<tr><td>Public Key</td><td class=\"smaller\">"+SanitizeOutput(publickey)+"</td></tr>";\r
                content+="<tr><td>Date Added</td><td>"+dateadded+"</td></tr>";\r
                content+="<tr><td>Last Seen</td><td>"+lastseen+"</td></tr>";\r
+               content+="<tr><td>Added Method</td><td class=\"smaller\">"+SanitizeOutput(addedmethod)+"</td></tr>";\r
        }\r
 \r
        // get message count posted by this identity\r
@@ -73,7 +76,7 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const
        content+="</table>";\r
 \r
 \r
-       st=m_db->Prepare("SELECT Name,PublicKey,MessageTrust,TrustListTrust,tblIdentity.IdentityID FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.TargetIdentityID=tblIdentity.IdentityID WHERE tblPeerTrust.IdentityID=? ORDER BY Name COLLATE NOCASE;");\r
+       st=m_db->Prepare("SELECT Name,PublicKey,MessageTrust,TrustListTrust,tblIdentity.IdentityID,tblPeerTrust.MessageTrustComment,tblPeerTrust.TrustListTrustComment FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.TargetIdentityID=tblIdentity.IdentityID WHERE tblPeerTrust.IdentityID=? ORDER BY Name COLLATE NOCASE;");\r
        st.Bind(0,identityid);\r
        st.Step();\r
 \r
@@ -81,16 +84,20 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const
        content+="<tr><th colspan=\"3\">";\r
        content+="Trust List of this identity";\r
        content+="</th></tr>";\r
-       content+="<tr><td></td><th>Message Trust</th><th>Trust List Trust</th></tr>";\r
+       content+="<tr><td></td><th>Message Trust</th><th>Message Comment</th><th>Trust List Trust</th><th>Trust Comment</th></tr>";\r
        while(st.RowReturned())\r
        {\r
                std::string thisid="";\r
+               std::string messagetrustcomment="";\r
+               std::string trustlisttrustcomment="";\r
 \r
                st.ResultText(0,name);\r
                st.ResultText(1,publickey);\r
                st.ResultText(2,messagetrust);\r
                st.ResultText(3,trustlisttrust);\r
                st.ResultText(4,thisid);\r
+               st.ResultText(5,messagetrustcomment);\r
+               st.ResultText(6,trustlisttrustcomment);\r
 \r
                if(publickey.size()>8)\r
                {\r
@@ -100,29 +107,35 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const
                content+="<tr>";\r
                content+="<td><a href=\"peerdetails.htm?identityid="+thisid+"\">"+SanitizeOutput(name+keypart)+"...</a></td>";\r
                content+="<td "+GetClassString(messagetrust)+">"+messagetrust+"</td>";\r
+               content+="<td>"+SanitizeOutput(messagetrustcomment)+"</td>";\r
                content+="<td "+GetClassString(trustlisttrust)+">"+trustlisttrust+"</td>";\r
+               content+="<td>"+SanitizeOutput(trustlisttrustcomment)+"</td>";\r
                content+="</tr>\r\n";\r
 \r
                st.Step();\r
        }\r
 \r
-       st=m_db->Prepare("SELECT Name,PublicKey,MessageTrust,TrustListTrust,tblIdentity.IdentityID FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.IdentityID=tblIdentity.IdentityID WHERE tblPeerTrust.TargetIdentityID=? ORDER BY Name COLLATE NOCASE;");\r
+       st=m_db->Prepare("SELECT Name,PublicKey,MessageTrust,TrustListTrust,tblIdentity.IdentityID,tblPeerTrust.MessageTrustComment,tblPeerTrust.TrustListTrustComment FROM tblPeerTrust INNER JOIN tblIdentity ON tblPeerTrust.IdentityID=tblIdentity.IdentityID WHERE tblPeerTrust.TargetIdentityID=? ORDER BY Name COLLATE NOCASE;");\r
        st.Bind(0,identityid);\r
        st.Step();\r
 \r
        content+="<tr><th colspan=\"3\">";\r
        content+="Trust of this identity from other identities";\r
        content+="</th></tr>";\r
-       content+="<tr><td></td><th>Message Trust</th><th>Trust List Trust</th></tr>";\r
+       content+="<tr><td></td><th>Message Trust</th><th>Message Comment</th><th>Trust List Trust</th><th>Trust Comment</th></tr>";\r
        while(st.RowReturned())\r
        {\r
                std::string thisid="";\r
+               std::string messagetrustcomment="";\r
+               std::string trustlisttrustcomment="";\r
 \r
                st.ResultText(0,name);\r
                st.ResultText(1,publickey);\r
                st.ResultText(2,messagetrust);\r
                st.ResultText(3,trustlisttrust);\r
                st.ResultText(4,thisid);\r
+               st.ResultText(5,messagetrustcomment);\r
+               st.ResultText(6,trustlisttrustcomment);\r
                \r
                if(publickey.size()>8)\r
                {\r
@@ -132,7 +145,9 @@ const std::string PeerDetailsPage::GeneratePage(const std::string &method, const
                content+="<tr>";\r
                content+="<td><a href=\"peerdetails.htm?identityid="+thisid+"\">"+SanitizeOutput(name+keypart)+"...</a></td>";\r
                content+="<td "+GetClassString(messagetrust)+">"+messagetrust+"</td>";\r
+               content+="<td>"+SanitizeOutput(messagetrustcomment)+"</td>";\r
                content+="<td "+GetClassString(trustlisttrust)+">"+trustlisttrust+"</td>";\r
+               content+="<td>"+SanitizeOutput(trustlisttrustcomment)+"</td>";\r
                content+="</tr>";\r
 \r
                st.Step();\r
index ee087f3..0cb0d42 100644 (file)
@@ -71,6 +71,10 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                std::vector<std::string> lmt;\r
                std::vector<std::string> oldltlt;\r
                std::vector<std::string> ltlt;\r
+               std::vector<std::string> oldmtc;\r
+               std::vector<std::string> mtc;\r
+               std::vector<std::string> oldtltc;\r
+               std::vector<std::string> tltc;\r
                int localmessagetrust=0;\r
                int localtrustlisttrust=0;\r
                int identityid;\r
@@ -80,12 +84,16 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                CreateArgArray(queryvars,"localmessagetrust",lmt);\r
                CreateArgArray(queryvars,"oldlocaltrustlisttrust",oldltlt);\r
                CreateArgArray(queryvars,"localtrustlisttrust",ltlt);\r
+               CreateArgArray(queryvars,"oldmessagetrustcomment",oldmtc);\r
+               CreateArgArray(queryvars,"messagetrustcomment",mtc);\r
+               CreateArgArray(queryvars,"oldtrustlisttrustcomment",oldtltc);\r
+               CreateArgArray(queryvars,"trustlisttrustcomment",tltc);\r
                \r
-               SQLite3DB::Statement update=m_db->Prepare("UPDATE tblIdentity SET LocalMessageTrust=?, LocalTrustListTrust=? WHERE IdentityID=?;");\r
+               SQLite3DB::Statement update=m_db->Prepare("UPDATE tblIdentity SET LocalMessageTrust=?, LocalTrustListTrust=?, MessageTrustComment=?, TrustListTrustComment=? WHERE IdentityID=?;");\r
 \r
                for(int i=0; i<identityids.size(); i++)\r
                {\r
-                       if(oldlmt[i]!=lmt[i] || oldltlt[i]!=ltlt[i])\r
+                       if(oldlmt[i]!=lmt[i] || oldltlt[i]!=ltlt[i] || oldmtc[i]!=mtc[i] || oldtltc[i]!=tltc[i])\r
                        {\r
                                StringFunctions::Convert(lmt[i],localmessagetrust);\r
                                StringFunctions::Convert(ltlt[i],localtrustlisttrust);\r
@@ -107,7 +115,9 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                                {\r
                                        update.Bind(1);\r
                                }\r
-                               update.Bind(2,identityid);\r
+                               update.Bind(2,mtc[i]);\r
+                               update.Bind(3,tltc[i]);\r
+                               update.Bind(4,identityid);\r
                                update.Step();\r
                                update.Reset();\r
                        }\r
@@ -172,8 +182,10 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
        content+="<table>";\r
        content+="<tr><th><a href=\"peertrust.htm?"+BuildQueryString(startrow,namesearch,"Name",ReverseSort("Name",sortby,sortorder))+"\">Name</a></th>";\r
        content+="<th><a href=\"peertrust.htm?"+BuildQueryString(startrow,namesearch,"LocalMessageTrust",ReverseSort("LocalMessageTrust",sortby,sortorder))+"\">Local Message Trust</a></th>";\r
+       content+="<th>Message Comment</th>";\r
        content+="<th><a href=\"peertrust.htm?"+BuildQueryString(startrow,namesearch,"PeerMessageTrust",ReverseSort("PeerMessageTrust",sortby,sortorder))+"\">Peer Message Trust</a></th>";\r
        content+="<th><a href=\"peertrust.htm?"+BuildQueryString(startrow,namesearch,"LocalTrustListTrust",ReverseSort("LocalTrustListTrust",sortby,sortorder))+"\">Local Trust List Trust</a></th>";\r
+       content+="<th>Trust Comment</th>";\r
        content+="<th><a href=\"peertrust.htm?"+BuildQueryString(startrow,namesearch,"PeerTrustListTrust",ReverseSort("PeerTrustListTrust",sortby,sortorder))+"\">Peer Trust List Trust</a></th></tr>";\r
        \r
        // get count of identities we are showing\r
@@ -192,7 +204,7 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
        st.ResultInt(0,identitycount);\r
        st.Finalize();\r
 \r
-       sql="SELECT IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey FROM tblIdentity";\r
+       sql="SELECT IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey,MessageTrustComment,TrustListTrustComment FROM tblIdentity";\r
        if(namesearch!="")\r
        {\r
                sql+=" WHERE Name LIKE  '%' || ? || '%'";\r
@@ -228,6 +240,8 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                std::string peertrustlisttrust;\r
                std::string publickey;\r
                std::string keypart="";\r
+               std::string messagetrustcomment="";\r
+               std::string trustlisttrustcomment="";\r
 \r
                StringFunctions::Convert(count,countstr);\r
 \r
@@ -238,6 +252,8 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                st.ResultText(4,localtrustlisttrust);\r
                st.ResultText(5,peertrustlisttrust);\r
                st.ResultText(6,publickey);\r
+               st.ResultText(7,messagetrustcomment);\r
+               st.ResultText(8,trustlisttrustcomment);\r
 \r
                if(publickey.size()>8)\r
                {\r
@@ -261,11 +277,19 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                content+="<td "+GetClassString(localmessagetrust)+">";\r
                content+="<input type=\"hidden\" name=\"oldlocalmessagetrust["+countstr+"]\" value=\""+localmessagetrust+"\">";\r
                content+="<input type=\"text\" name=\"localmessagetrust["+countstr+"]\" value=\""+localmessagetrust+"\" size=\"2\" maxlength=\"3\"></td>";\r
+               content+="<td "+GetClassString(localmessagetrust)+">";\r
+               content+="<input type=\"hidden\" name=\"oldmessagetrustcomment["+countstr+"]\" value=\""+SanitizeOutput(messagetrustcomment)+"\">";\r
+               content+="<input type=\"text\" name=\"messagetrustcomment["+countstr+"]\" value=\""+SanitizeOutput(messagetrustcomment)+"\" maxlength=\"50\">";\r
+               content+="</td>";               \r
                content+="<td "+GetClassString(peermessagetrust)+">";\r
                content+=peermessagetrust+"</td>";\r
                content+="<td "+GetClassString(localtrustlisttrust)+">";\r
                content+="<input type=\"hidden\" name=\"oldlocaltrustlisttrust["+countstr+"]\" value=\""+localtrustlisttrust+"\">";\r
                content+="<input type=\"text\" name=\"localtrustlisttrust["+countstr+"]\" value=\""+localtrustlisttrust+"\" size=\"2\" maxlength=\"3\"></td>";\r
+               content+="<td "+GetClassString(localtrustlisttrust)+">";\r
+               content+="<input type=\"hidden\" name=\"oldtrustlisttrustcomment["+countstr+"]\" value=\""+SanitizeOutput(trustlisttrustcomment)+"\">";\r
+               content+="<input type=\"text\" name=\"trustlisttrustcomment["+countstr+"]\" value=\""+SanitizeOutput(trustlisttrustcomment)+"\" maxlength=\"50\">";\r
+               content+="</td>";\r
                content+="<td "+GetClassString(peertrustlisttrust)+">";\r
                content+=peertrustlisttrust+"</td>";\r
                content+="</tr>";\r
@@ -282,17 +306,17 @@ const std::string PeerTrustPage::GeneratePage(const std::string &method, const s
                if(startrow>0)\r
                {\r
                        StringFunctions::Convert(startrow-rowsperpage,tempstr);\r
-                       content+="<td colspan=\"2\" align=\"left\"><a href=\"peertrust.htm?"+BuildQueryString(startrow-rowsperpage,namesearch,sortby,sortorder)+"\"><-- Previous Page</a></td>";\r
-                       cols+=2;\r
+                       content+="<td colspan=\"3\" align=\"left\"><a href=\"peertrust.htm?"+BuildQueryString(startrow-rowsperpage,namesearch,sortby,sortorder)+"\"><-- Previous Page</a></td>";\r
+                       cols+=3;\r
                }\r
                if(startrow+rowsperpage<identitycount)\r
                {\r
-                       while(cols<3)\r
+                       while(cols<4)\r
                        {\r
                                content+="<td></td>";\r
                                cols++;\r
                        }\r
-                       content+="<td colspan=\"2\" align=\"right\"><a href=\"peertrust.htm?"+BuildQueryString(startrow+rowsperpage,namesearch,sortby,sortorder)+"\">Next Page --></a></td>";\r
+                       content+="<td colspan=\"3\" align=\"right\"><a href=\"peertrust.htm?"+BuildQueryString(startrow+rowsperpage,namesearch,sortby,sortorder)+"\">Next Page --></a></td>";\r
                }\r
                content+="</tr>";\r
        }\r
index 9fefa8f..8b33355 100644 (file)
@@ -18,6 +18,7 @@
 \r
 int main(int argc, char *argv[])\r
 {\r
+\r
        bool daemon=false;\r
 \r
        #ifdef XMEM\r