version 0.2.5
[fms.git] / src / global.cpp
index 251ea2a..035cdc3 100644 (file)
@@ -67,13 +67,19 @@ void SetupDB()
                        major=1;\r
                        minor=5;\r
                }\r
+               if(major==1 && minor==5)\r
+               {\r
+                       ConvertDB0105To0106();\r
+                       major=1;\r
+                       minor=6;\r
+               }\r
        }\r
        else\r
        {\r
-               db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,5);");\r
+               db->Execute("INSERT INTO tblDBVersion(Major,Minor) VALUES(1,6);");\r
        }\r
 \r
-       db->Execute("UPDATE tblDBVersion SET Major=1, Minor=4;");\r
+       db->Execute("UPDATE tblDBVersion SET Major=1, Minor=6;");\r
 \r
        db->Execute("CREATE TABLE IF NOT EXISTS tblOption(\\r
                                Option                          TEXT UNIQUE,\\r
@@ -89,6 +95,7 @@ void SetupDB()
                                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
+                               PublishFreesite                 BOOL CHECK(PublishFreesite IN('true','false')) DEFAULT 'false',\\r
                                InsertingIdentity               BOOL CHECK(InsertingIdentity IN('true','false')) DEFAULT 'false',\\r
                                LastInsertedIdentity    DATETIME,\\r
                                InsertingPuzzle                 BOOL CHECK(InsertingPuzzle IN('true','false')) DEFAULT 'false',\\r
@@ -99,6 +106,7 @@ void SetupDB()
                                LastInsertedBoardList   DATETIME,\\r
                                InsertingMessageList    BOOL CHECK(InsertingMessageList IN('true','false')) DEFAULT 'false',\\r
                                LastInsertedMessageList DATETIME,\\r
+                               LastInsertedFreesite    DATETIME,\\r
                                DateCreated                             DATETIME\\r
                                );");\r
 \r
@@ -186,6 +194,9 @@ void SetupDB()
                                TrustListTrustComment   TEXT\\r
                                );");\r
 \r
+       db->Execute("CREATE INDEX IF NOT EXISTS idxPeerTrust_IdentityID ON tblPeerTrust (IdentityID);");\r
+       db->Execute("CREATE INDEX IF NOT EXISTS idxPeerTrust_TargetIdentityID ON tblPeerTrust (TargetIdentityID);");\r
+\r
        db->Execute("CREATE TABLE IF NOT EXISTS tblBoard(\\r
                                BoardID                                 INTEGER PRIMARY KEY,\\r
                                BoardName                               TEXT UNIQUE,\\r
@@ -212,6 +223,8 @@ void SetupDB()
                                MessageIndex            INTEGER\\r
                                );");\r
 \r
+       db->Execute("CREATE INDEX IF NOT EXISTS idxMessage_IdentityID ON tblMessage (IdentityID);");\r
+\r
        db->Execute("CREATE TABLE IF NOT EXISTS tblMessageReplyTo(\\r
                                MessageID                       INTEGER,\\r
                                ReplyToMessageUUID      TEXT,\\r
@@ -223,6 +236,8 @@ void SetupDB()
                                BoardID                         INTEGER\\r
                                );");\r
 \r
+       db->Execute("CREATE INDEX IF NOT EXISTS idxMessageBoard_BoardID ON tblMessageBoard (BoardID);");\r
+\r
        db->Execute("CREATE TABLE IF NOT EXISTS tblMessageListRequests(\\r
                                IdentityID                      INTEGER,\\r
                                Day                                     DATE,\\r
@@ -290,7 +305,7 @@ void SetupDB()
                                GROUP BY tblBoard.BoardID;");\r
 \r
        // calculates peer trust\r
-       // do the (MessageTrust+1)*LocalTrustListTrust/(MessageTrust+1)/100.0 - so it MessageTrust or TrustListTrust is NULL, the calc will be NULL and it won't be included at all in the average\r
+       // do the (MessageTrust+1)*LocalTrustListTrust/(MessageTrust+1)/100.0 - so if MessageTrust or TrustListTrust is NULL, the calc will be NULL and it won't be included at all in the average\r
        // need the +1 so that when the values are 0 the result is not 0\r
        db->Execute("DROP VIEW IF EXISTS vwCalculatedPeerTrust;");\r
        db->Execute("CREATE VIEW IF NOT EXISTS vwCalculatedPeerTrust AS \\r
@@ -388,7 +403,7 @@ void SetupDB()
 \r
        date.SetToGMTime();\r
        // insert SomeDude's public key\r
-       db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,LocalTrustListTrust) VALUES('SSK@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw,iXez4j3qCpd596TxXiJgZyTq9o-CElEuJxm~jNNZAuA,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"',51);");\r
+       db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded,LocalTrustListTrust) VALUES('SSK@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw,iXez4j3qCpd596TxXiJgZyTq9o-CElEuJxm~jNNZAuA,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"',50);");\r
        // insert Shadow Panther's public key\r
        db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('SSK@~mimyB1kmH4f7Cgsd2wM2Qv2NxrZHRMM6IY8~7EWRVQ,fxTKkR0TYhgMYb-vEGAv55sMOxCGD2xhE4ZxWHxdPz4,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"');");\r
        // insert garfield's public key\r
@@ -484,6 +499,15 @@ void ConvertDB0104To0105()
        db->Execute("UPDATE tblDBVersion SET Major=1, Minor=5;");\r
 }\r
 \r
+void ConvertDB0105To0106()\r
+{\r
+       // add Publish Freesite\r
+       SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+       db->Execute("ALTER TABLE tblLocalIdentity ADD COLUMN PublishFreesite BOOL CHECK(PublishFreesite IN('true','false')) DEFAULT 'false';");\r
+       db->Execute("ALTER TABLE tblLocalIdentity ADD COLUMN LastInsertedFreesite DATETIME;");\r
+       db->Execute("UPDATE tblDBVersion SET Major=1, Minor=6;");\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
@@ -530,7 +554,7 @@ void SetupDefaultOptions()
 \r
        st.Bind(0,"StartHTTP");\r
        st.Bind(1,"true");\r
-       st.Bind(2,"Start HTTP server.");\r
+       st.Bind(2,"Start HTTP server.  WARNING: If you turn this off, you won't be able to access the administration pages.");\r
        st.Step();\r
        st.Reset();\r
 \r
@@ -549,7 +573,7 @@ void SetupDefaultOptions()
        // StartFreenetUpdater\r
        st.Bind(0,"StartFreenetUpdater");\r
        st.Bind(1,"true");\r
-       st.Bind(2,"Start Freenet Updater thread.");\r
+       st.Bind(2,"Set to true to start the Freenet Updater thread and connect to Freenet.  Set to false to prevent communication with Freenet.");\r
        st.Step();\r
        st.Reset();\r
 \r
@@ -622,7 +646,7 @@ void SetupDefaultOptions()
        st.Reset();\r
 \r
        st.Bind(0,"MinLocalTrustListTrust");\r
-       st.Bind(1,"51");\r
+       st.Bind(1,"50");\r
        st.Bind(2,"Specifies a local trust list trust level that a peer must have before its trust list will be included in the weighted average.  Any peers below this number will be excluded from the results.");\r
        st.Step();\r
        st.Reset();\r
@@ -663,6 +687,12 @@ void SetupDefaultOptions()
        st.Step();\r
        st.Reset();\r
 \r
+       st.Bind(0,"SaveMessagesFromNewBoards");\r
+       st.Bind(1,"true");\r
+       st.Bind(2,"Set to true to automatically save messages posted to new boards.  Set to false to ignore messages to new boards.");\r
+       st.Step();\r
+       st.Reset();\r
+\r
        st.Bind(0,"ChangeMessageTrustOnReply");\r
        st.Bind(1,"0");\r
        st.Bind(2,"How much the local message trust level of an identity should change when you reply to one of their messages.");\r