version 0.3.0
[fms.git] / src / optionssetup.cpp
diff --git a/src/optionssetup.cpp b/src/optionssetup.cpp
new file mode 100644 (file)
index 0000000..2d646f0
--- /dev/null
@@ -0,0 +1,436 @@
+#include "../include/optionssetup.h"\r
+#include "../include/db/sqlite3db.h"\r
+\r
+#include <Poco/Message.h>\r
+\r
+#include <string>\r
+#include <sstream>\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
+\r
+       std::ostringstream tempstr;     // must set tempstr to "" between db inserts\r
+       SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
+       SQLite3DB::Statement st=db->Prepare("INSERT INTO tblOption(Option,OptionValue) VALUES(?,?);");\r
+       SQLite3DB::Statement upd=db->Prepare("UPDATE tblOption SET Section=?, SortOrder=?, ValidValues=?, OptionDescription=? WHERE Option=?;");\r
+       int order=0;\r
+\r
+       // LogLevel\r
+       tempstr.str("");\r
+       tempstr << Poco::Message::PRIO_DEBUG;\r
+       st.Bind(0,"LogLevel");\r
+       st.Bind(1,tempstr.str());\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Program");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2,"1|1 - Fatal Errors|2|2 - Critical Errors|3|3 - Errors|4|4 - Warnings|5|5 - Notices|6|6 - Informational Messages|7|7 - Debug Messages|8|8 - Trace Messages");\r
+       upd.Bind(3,"The maximum logging level that will be written to file.  Higher levels will include all messages from the previous levels.");\r
+       upd.Bind(4,"LogLevel");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"VacuumOnStartup");\r
+       st.Bind(1,"false");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Program");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2,"true|true|false|false");\r
+       upd.Bind(3,"VACUUM the database every time FMS starts.  This will defragment the free space in the database and create a smaller database file.  Vacuuming the database can be CPU and disk intensive.");\r
+       upd.Bind(4,"VacuumOnStartup");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MessageBase");\r
+       st.Bind(1,"fms");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Program");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"A unique string shared by all clients who want to communicate with each other.  This should not be changed unless you want to create your own separate communications network.");\r
+       upd.Bind(4,"MessageBase");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       // StartNNTP\r
+       st.Bind(0,"StartNNTP");\r
+       st.Bind(1,"true");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"NNTP Server");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2,"true|true|false|false");\r
+       upd.Bind(3,"Start NNTP server.");\r
+       upd.Bind(4,"StartNNTP");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       // NNTPListenPort\r
+       st.Bind(0,"NNTPListenPort");\r
+       st.Bind(1,"1119");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"NNTP Server");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"The port that the NNTP service will listen for incoming connections.");\r
+       upd.Bind(4,"NNTPListenPort");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       // NNTPBindAddresses\r
+       st.Bind(0,"NNTPBindAddresses");\r
+       st.Bind(1,"localhost");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"NNTP Server");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"A comma separated list of valid IPv4 or IPv6 addresses/hostnames that the NNTP service will try to bind to.");\r
+       upd.Bind(4,"NNTPBindAddresses");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"NNTPAllowPost");\r
+       st.Bind(1,"true");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"NNTP Server");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2,"true|true|false|false");\r
+       upd.Bind(3,"Allow posting messages from NNTP.  Setting to false will make the newsgroups read only.");\r
+       upd.Bind(4,"NNTPAllowPost");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"StartHTTP");\r
+       st.Bind(1,"true");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"HTTP Server");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2,"true|true|false|false");\r
+       upd.Bind(3,"Start HTTP server.  WARNING: If you turn this off, you won't be able to access the administration pages.");\r
+       upd.Bind(4,"StartHTTP");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"HTTPListenPort");\r
+       st.Bind(1,"8080");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"HTTP Server");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Port HTTP server will listen on.");\r
+       upd.Bind(4,"HTTPListenPort");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"HTTPAccessControl");\r
+       st.Bind(1,"-0.0.0.0/0,+127.0.0.1");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"HTTP Server");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Comma separated list of addresses and/or subnet masks that are allowed access to the administration pages.  Default is localhost only. + allows a host, - denies a host.");\r
+       upd.Bind(4,"HTTPAccessControl");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       // StartFreenetUpdater\r
+       st.Bind(0,"StartFreenetUpdater");\r
+       st.Bind(1,"true");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Freenet Connection");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2,"true|true|false|false");\r
+       upd.Bind(3,"Set to true to start the Freenet Updater thread and connect to Freenet.  Set to false to prevent communication with Freenet.");\r
+       upd.Bind(4,"StartFreenetUpdater");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       // FCPHost\r
+       st.Bind(0,"FCPHost");\r
+       st.Bind(1,"127.0.0.1");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Freenet Connection");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Host name or address of Freenet node.");\r
+       upd.Bind(4,"FCPHost");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       // FCPPort\r
+       st.Bind(0,"FCPPort");\r
+       st.Bind(1,"9481");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Freenet Connection");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"The port that Freenet is listening for FCP connections on.");\r
+       upd.Bind(4,"FCPPort");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"FProxyPort");\r
+       st.Bind(1,"8888");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Freenet Connection");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"The port that Freenet is listening for http connections on.");\r
+       upd.Bind(4,"FProxyPort");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MaxIdentityRequests");\r
+       st.Bind(1,"5");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Requests");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Maximum number of concurrent requests for new Identity xml files");\r
+       upd.Bind(4,"MaxIdentityRequests");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MaxIdentityIntroductionRequests");\r
+       st.Bind(1,"5");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Requests");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Maximum number of concurrent identities requesting IdentityIntroduction xml files.  Each identity may have multiple requests pending.");\r
+       upd.Bind(4,"MaxIdentityIntroductionRequests");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MaxIntroductionPuzzleRequests");\r
+       st.Bind(1,"5");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Requests");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Maximum number of concurrent requests for new IntroductionPuzzle xml files");\r
+       upd.Bind(4,"MaxIntroductionPuzzleRequests");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MaxTrustListRequests");\r
+       st.Bind(1,"5");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Requests");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Maximum number of concurrent requests for new Trust Lists");\r
+       upd.Bind(4,"MaxTrustListRequests");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MaxMessageListRequests");\r
+       st.Bind(1,"5");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Requests");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Maximum number of concurrent requests for new Message Lists");\r
+       upd.Bind(4,"MaxMessageListRequests");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MaxMessageRequests");\r
+       st.Bind(1,"20");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Requests");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Maximum number of concurrent requests for new Messages");\r
+       upd.Bind(4,"MaxMessageRequests");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MaxBoardListRequests");\r
+       st.Bind(1,"5");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Requests");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"The maximum number of concurrent requests for new Board Lists.  Set to 0 to disable.");\r
+       upd.Bind(4,"MaxBoardListRequests");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MinLocalMessageTrust");\r
+       st.Bind(1,"50");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Trust");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Specifies a local message trust level that a peer must have before its messages will be downloaded.");\r
+       upd.Bind(4,"MinLocalMessageTrust");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MinPeerMessageTrust");\r
+       st.Bind(1,"30");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Trust");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Specifies a peer message trust level that a peer must have before its messages will be downloaded.");\r
+       upd.Bind(4,"MinPeerMessageTrust");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MinLocalTrustListTrust");\r
+       st.Bind(1,"50");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Trust");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"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
+       upd.Bind(4,"MinLocalTrustListTrust");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MinPeerTrustListTrust");\r
+       st.Bind(1,"30");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Trust");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Specifies a peer 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
+       upd.Bind(4,"MinPeerTrustListTrust");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"LocalTrustOverridesPeerTrust");\r
+       st.Bind(1,"false");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Trust");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2,"true|true|false|false");\r
+       upd.Bind(3,"Set to true if you want your local trust levels to override the peer levels when determining which identities you will poll.");\r
+       upd.Bind(4,"LocalTrustOverridesPeerTrust");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MessageDownloadMaxDaysBackward");\r
+       st.Bind(1,"5");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Messages");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"The maximum number of days backward that messages will be downloaded from each identity");\r
+       upd.Bind(4,"MessageDownloadMaxDaysBackward");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MessageListDaysBackward");\r
+       st.Bind(1,"5");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Messages");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"The number of days backward that messages you have inserted will appear in your MessageLists");\r
+       upd.Bind(4,"MessageListDaysBackward");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MaxPeerMessagesPerDay");\r
+       st.Bind(1,"200");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Messages");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"The maximum number of messages you will download from each peer on a given day.");\r
+       upd.Bind(4,"MaxPeerMessagesPerDay");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"MaxBoardsPerMessage");\r
+       st.Bind(1,"8");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Messages");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"The maximum number of boards a received message may be sent to.  Boards over this limit will be ignored.");\r
+       upd.Bind(4,"MaxBoardsPerMessage");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"SaveMessagesFromNewBoards");\r
+       st.Bind(1,"true");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Messages");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2,"true|true|false|false");\r
+       upd.Bind(3,"Set to true to automatically save messages posted to new boards.  Set to false to ignore messages to new boards.");\r
+       upd.Bind(4,"SaveMessagesFromNewBoards");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"ChangeMessageTrustOnReply");\r
+       st.Bind(1,"0");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Messages");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"How much the local message trust level of an identity should change when you reply to one of their messages.");\r
+       upd.Bind(4,"ChangeMessageTrustOnReply");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"AddNewPostFromIdentities");\r
+       st.Bind(1,"false");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Messages");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2,"true|true|false|false");\r
+       upd.Bind(3,"Set to true to automatically create new identities when you send a message using a new name.  If you set this to false, posting messages will fail until you manually create the identity.");\r
+       upd.Bind(4,"AddNewPostFromIdentities");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+       st.Bind(0,"DeleteMessagesOlderThan");\r
+       st.Bind(1,"180");\r
+       st.Step();\r
+       st.Reset();\r
+       upd.Bind(0,"Messages");\r
+       upd.Bind(1,order++);\r
+       upd.Bind(2);\r
+       upd.Bind(3,"Automatically delete messages older than this many days.");\r
+       upd.Bind(4,"DeleteMessagesOlderThan");\r
+       upd.Step();\r
+       upd.Reset();\r
+\r
+}\r