1f3562f10332068520894446d2703f4567a902b9
[fms.git] / src / optionssetup.cpp
1 #include "../include/optionssetup.h"\r
2 #include "../include/db/sqlite3db.h"\r
3 #include "../include/global.h"\r
4 \r
5 #include <Poco/Message.h>\r
6 \r
7 #include <string>\r
8 #include <sstream>\r
9 \r
10 void SetupDefaultOptions()\r
11 {\r
12         // 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
13 \r
14         std::ostringstream tempstr;     // must set tempstr to "" between db inserts\r
15         SQLite3DB::DB *db=SQLite3DB::DB::Instance();\r
16         SQLite3DB::Statement st=db->Prepare("INSERT INTO tblOption(Option,OptionValue) VALUES(?,?);");\r
17         SQLite3DB::Statement upd=db->Prepare("UPDATE tblOption SET Section=?, SortOrder=?, ValidValues=?, OptionDescription=? WHERE Option=?;");\r
18         int order=0;\r
19 \r
20         // LogLevel\r
21         tempstr.str("");\r
22         tempstr << Poco::Message::PRIO_DEBUG;\r
23         st.Bind(0,"LogLevel");\r
24         st.Bind(1,tempstr.str());\r
25         st.Step();\r
26         st.Reset();\r
27         upd.Bind(0,"Program");\r
28         upd.Bind(1,order++);\r
29         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
30         upd.Bind(3,"The maximum logging level that will be written to file.  Higher levels will include all messages from the previous levels.");\r
31         upd.Bind(4,"LogLevel");\r
32         upd.Step();\r
33         upd.Reset();\r
34 \r
35         st.Bind(0,"VacuumOnStartup");\r
36         st.Bind(1,"false");\r
37         st.Step();\r
38         st.Reset();\r
39         upd.Bind(0,"Program");\r
40         upd.Bind(1,order++);\r
41         upd.Bind(2,"true|true|false|false");\r
42         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
43         upd.Bind(4,"VacuumOnStartup");\r
44         upd.Step();\r
45         upd.Reset();\r
46 \r
47         st.Bind(0,"MessageBase");\r
48         st.Bind(1,"fms");\r
49         st.Step();\r
50         st.Reset();\r
51         upd.Bind(0,"Program");\r
52         upd.Bind(1,order++);\r
53         upd.Bind(2);\r
54         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
55         upd.Bind(4,"MessageBase");\r
56         upd.Step();\r
57         upd.Reset();\r
58 \r
59         st.Bind(0,"FMSVersionKey");\r
60         st.Bind(1,"USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fmsversion/");\r
61         st.Step();\r
62         st.Reset();\r
63         upd.Bind(0,"Program");\r
64         upd.Bind(1,order++);\r
65         upd.Bind(2);\r
66         upd.Bind(3,"The USK key which contains information about the latest version of FMS.");\r
67         upd.Bind(4,"FMSVersionKey");\r
68         upd.Step();\r
69         upd.Reset();\r
70 \r
71         st.Bind(0,"FMSVersionEdition");\r
72         st.Bind(1,FMS_VERSION_EDITION);\r
73         st.Step();\r
74         st.Reset();\r
75         upd.Bind(0,"Program");\r
76         upd.Bind(1,order++);\r
77         upd.Bind(2);\r
78         upd.Bind(3,"The latest found edition of the FMS version USK.");\r
79         upd.Bind(4,"FMSVersionEdition");\r
80         upd.Step();\r
81         upd.Reset();\r
82 \r
83         // StartNNTP\r
84         st.Bind(0,"StartNNTP");\r
85         st.Bind(1,"true");\r
86         st.Step();\r
87         st.Reset();\r
88         upd.Bind(0,"NNTP Server");\r
89         upd.Bind(1,order++);\r
90         upd.Bind(2,"true|true|false|false");\r
91         upd.Bind(3,"Start NNTP server.");\r
92         upd.Bind(4,"StartNNTP");\r
93         upd.Step();\r
94         upd.Reset();\r
95 \r
96         // NNTPListenPort\r
97         st.Bind(0,"NNTPListenPort");\r
98         st.Bind(1,"1119");\r
99         st.Step();\r
100         st.Reset();\r
101         upd.Bind(0,"NNTP Server");\r
102         upd.Bind(1,order++);\r
103         upd.Bind(2);\r
104         upd.Bind(3,"The port that the NNTP service will listen for incoming connections.");\r
105         upd.Bind(4,"NNTPListenPort");\r
106         upd.Step();\r
107         upd.Reset();\r
108 \r
109         // NNTPBindAddresses\r
110         st.Bind(0,"NNTPBindAddresses");\r
111         st.Bind(1,"localhost,127.0.0.1");\r
112         st.Step();\r
113         st.Reset();\r
114         upd.Bind(0,"NNTP Server");\r
115         upd.Bind(1,order++);\r
116         upd.Bind(2);\r
117         upd.Bind(3,"A comma separated list of valid IPv4 or IPv6 addresses/hostnames that the NNTP service will try to bind to.");\r
118         upd.Bind(4,"NNTPBindAddresses");\r
119         upd.Step();\r
120         upd.Reset();\r
121 \r
122         st.Bind(0,"NNTPAllowPost");\r
123         st.Bind(1,"true");\r
124         st.Step();\r
125         st.Reset();\r
126         upd.Bind(0,"NNTP Server");\r
127         upd.Bind(1,order++);\r
128         upd.Bind(2,"true|true|false|false");\r
129         upd.Bind(3,"Allow posting messages from NNTP.  Setting to false will make the newsgroups read only.");\r
130         upd.Bind(4,"NNTPAllowPost");\r
131         upd.Step();\r
132         upd.Reset();\r
133 \r
134         st.Bind(0,"StartHTTP");\r
135         st.Bind(1,"true");\r
136         st.Step();\r
137         st.Reset();\r
138         upd.Bind(0,"HTTP Server");\r
139         upd.Bind(1,order++);\r
140         upd.Bind(2,"true|true|false|false");\r
141         upd.Bind(3,"Start HTTP server.  WARNING: If you turn this off, you won't be able to access the administration pages.");\r
142         upd.Bind(4,"StartHTTP");\r
143         upd.Step();\r
144         upd.Reset();\r
145 \r
146         st.Bind(0,"HTTPListenPort");\r
147         st.Bind(1,"8080");\r
148         st.Step();\r
149         st.Reset();\r
150         upd.Bind(0,"HTTP Server");\r
151         upd.Bind(1,order++);\r
152         upd.Bind(2);\r
153         upd.Bind(3,"Port HTTP server will listen on.");\r
154         upd.Bind(4,"HTTPListenPort");\r
155         upd.Step();\r
156         upd.Reset();\r
157 \r
158         st.Bind(0,"HTTPAccessControl");\r
159         st.Bind(1,"-0.0.0.0/0,+127.0.0.1");\r
160         st.Step();\r
161         st.Reset();\r
162         upd.Bind(0,"HTTP Server");\r
163         upd.Bind(1,order++);\r
164         upd.Bind(2);\r
165         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
166         upd.Bind(4,"HTTPAccessControl");\r
167         upd.Step();\r
168         upd.Reset();\r
169 \r
170         // StartFreenetUpdater\r
171         st.Bind(0,"StartFreenetUpdater");\r
172         st.Bind(1,"true");\r
173         st.Step();\r
174         st.Reset();\r
175         upd.Bind(0,"Freenet Connection");\r
176         upd.Bind(1,order++);\r
177         upd.Bind(2,"true|true|false|false");\r
178         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
179         upd.Bind(4,"StartFreenetUpdater");\r
180         upd.Step();\r
181         upd.Reset();\r
182 \r
183         // FCPHost\r
184         st.Bind(0,"FCPHost");\r
185         st.Bind(1,"127.0.0.1");\r
186         st.Step();\r
187         st.Reset();\r
188         upd.Bind(0,"Freenet Connection");\r
189         upd.Bind(1,order++);\r
190         upd.Bind(2);\r
191         upd.Bind(3,"Host name or address of Freenet node.");\r
192         upd.Bind(4,"FCPHost");\r
193         upd.Step();\r
194         upd.Reset();\r
195 \r
196         // FCPPort\r
197         st.Bind(0,"FCPPort");\r
198         st.Bind(1,"9481");\r
199         st.Step();\r
200         st.Reset();\r
201         upd.Bind(0,"Freenet Connection");\r
202         upd.Bind(1,order++);\r
203         upd.Bind(2);\r
204         upd.Bind(3,"The port that Freenet is listening for FCP connections on.");\r
205         upd.Bind(4,"FCPPort");\r
206         upd.Step();\r
207         upd.Reset();\r
208 \r
209         st.Bind(0,"FProxyPort");\r
210         st.Bind(1,"8888");\r
211         st.Step();\r
212         st.Reset();\r
213         upd.Bind(0,"Freenet Connection");\r
214         upd.Bind(1,order++);\r
215         upd.Bind(2);\r
216         upd.Bind(3,"The port that Freenet is listening for http connections on.");\r
217         upd.Bind(4,"FProxyPort");\r
218         upd.Step();\r
219         upd.Reset();\r
220 \r
221         st.Bind(0,"MaxIdentityRequests");\r
222         st.Bind(1,"5");\r
223         st.Step();\r
224         st.Reset();\r
225         upd.Bind(0,"Requests");\r
226         upd.Bind(1,order++);\r
227         upd.Bind(2);\r
228         upd.Bind(3,"Maximum number of concurrent requests for new Identity xml files");\r
229         upd.Bind(4,"MaxIdentityRequests");\r
230         upd.Step();\r
231         upd.Reset();\r
232 \r
233         st.Bind(0,"MaxIdentityIntroductionRequests");\r
234         st.Bind(1,"5");\r
235         st.Step();\r
236         st.Reset();\r
237         upd.Bind(0,"Requests");\r
238         upd.Bind(1,order++);\r
239         upd.Bind(2);\r
240         upd.Bind(3,"Maximum number of concurrent identities requesting IdentityIntroduction xml files.  Each identity may have multiple requests pending.");\r
241         upd.Bind(4,"MaxIdentityIntroductionRequests");\r
242         upd.Step();\r
243         upd.Reset();\r
244 \r
245         st.Bind(0,"MaxIntroductionPuzzleRequests");\r
246         st.Bind(1,"5");\r
247         st.Step();\r
248         st.Reset();\r
249         upd.Bind(0,"Requests");\r
250         upd.Bind(1,order++);\r
251         upd.Bind(2);\r
252         upd.Bind(3,"Maximum number of concurrent requests for new IntroductionPuzzle xml files");\r
253         upd.Bind(4,"MaxIntroductionPuzzleRequests");\r
254         upd.Step();\r
255         upd.Reset();\r
256 \r
257         st.Bind(0,"MaxTrustListRequests");\r
258         st.Bind(1,"5");\r
259         st.Step();\r
260         st.Reset();\r
261         upd.Bind(0,"Requests");\r
262         upd.Bind(1,order++);\r
263         upd.Bind(2);\r
264         upd.Bind(3,"Maximum number of concurrent requests for new Trust Lists");\r
265         upd.Bind(4,"MaxTrustListRequests");\r
266         upd.Step();\r
267         upd.Reset();\r
268 \r
269         st.Bind(0,"MaxMessageListRequests");\r
270         st.Bind(1,"5");\r
271         st.Step();\r
272         st.Reset();\r
273         upd.Bind(0,"Requests");\r
274         upd.Bind(1,order++);\r
275         upd.Bind(2);\r
276         upd.Bind(3,"Maximum number of concurrent requests for new Message Lists");\r
277         upd.Bind(4,"MaxMessageListRequests");\r
278         upd.Step();\r
279         upd.Reset();\r
280 \r
281         st.Bind(0,"MaxMessageRequests");\r
282         st.Bind(1,"20");\r
283         st.Step();\r
284         st.Reset();\r
285         upd.Bind(0,"Requests");\r
286         upd.Bind(1,order++);\r
287         upd.Bind(2);\r
288         upd.Bind(3,"Maximum number of concurrent requests for new Messages");\r
289         upd.Bind(4,"MaxMessageRequests");\r
290         upd.Step();\r
291         upd.Reset();\r
292 \r
293         st.Bind(0,"MaxBoardListRequests");\r
294         st.Bind(1,"5");\r
295         st.Step();\r
296         st.Reset();\r
297         upd.Bind(0,"Requests");\r
298         upd.Bind(1,order++);\r
299         upd.Bind(2);\r
300         upd.Bind(3,"The maximum number of concurrent requests for new Board Lists.  Set to 0 to disable.");\r
301         upd.Bind(4,"MaxBoardListRequests");\r
302         upd.Step();\r
303         upd.Reset();\r
304 \r
305         st.Bind(0,"MinLocalMessageTrust");\r
306         st.Bind(1,"50");\r
307         st.Step();\r
308         st.Reset();\r
309         upd.Bind(0,"Trust");\r
310         upd.Bind(1,order++);\r
311         upd.Bind(2);\r
312         upd.Bind(3,"Specifies a local message trust level that a peer must have before its messages will be downloaded.");\r
313         upd.Bind(4,"MinLocalMessageTrust");\r
314         upd.Step();\r
315         upd.Reset();\r
316 \r
317         st.Bind(0,"MinPeerMessageTrust");\r
318         st.Bind(1,"30");\r
319         st.Step();\r
320         st.Reset();\r
321         upd.Bind(0,"Trust");\r
322         upd.Bind(1,order++);\r
323         upd.Bind(2);\r
324         upd.Bind(3,"Specifies a peer message trust level that a peer must have before its messages will be downloaded.");\r
325         upd.Bind(4,"MinPeerMessageTrust");\r
326         upd.Step();\r
327         upd.Reset();\r
328 \r
329         st.Bind(0,"MinLocalTrustListTrust");\r
330         st.Bind(1,"50");\r
331         st.Step();\r
332         st.Reset();\r
333         upd.Bind(0,"Trust");\r
334         upd.Bind(1,order++);\r
335         upd.Bind(2);\r
336         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
337         upd.Bind(4,"MinLocalTrustListTrust");\r
338         upd.Step();\r
339         upd.Reset();\r
340 \r
341         st.Bind(0,"MinPeerTrustListTrust");\r
342         st.Bind(1,"30");\r
343         st.Step();\r
344         st.Reset();\r
345         upd.Bind(0,"Trust");\r
346         upd.Bind(1,order++);\r
347         upd.Bind(2);\r
348         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
349         upd.Bind(4,"MinPeerTrustListTrust");\r
350         upd.Step();\r
351         upd.Reset();\r
352 \r
353         st.Bind(0,"LocalTrustOverridesPeerTrust");\r
354         st.Bind(1,"false");\r
355         st.Step();\r
356         st.Reset();\r
357         upd.Bind(0,"Trust");\r
358         upd.Bind(1,order++);\r
359         upd.Bind(2,"true|true|false|false");\r
360         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
361         upd.Bind(4,"LocalTrustOverridesPeerTrust");\r
362         upd.Step();\r
363         upd.Reset();\r
364 \r
365         st.Bind(0,"MessageDownloadMaxDaysBackward");\r
366         st.Bind(1,"5");\r
367         st.Step();\r
368         st.Reset();\r
369         upd.Bind(0,"Messages");\r
370         upd.Bind(1,order++);\r
371         upd.Bind(2);\r
372         upd.Bind(3,"The maximum number of days backward that messages will be downloaded from each identity");\r
373         upd.Bind(4,"MessageDownloadMaxDaysBackward");\r
374         upd.Step();\r
375         upd.Reset();\r
376 \r
377         st.Bind(0,"MessageListDaysBackward");\r
378         st.Bind(1,"5");\r
379         st.Step();\r
380         st.Reset();\r
381         upd.Bind(0,"Messages");\r
382         upd.Bind(1,order++);\r
383         upd.Bind(2);\r
384         upd.Bind(3,"The number of days backward that messages you have inserted will appear in your MessageLists");\r
385         upd.Bind(4,"MessageListDaysBackward");\r
386         upd.Step();\r
387         upd.Reset();\r
388 \r
389         st.Bind(0,"MaxPeerMessagesPerDay");\r
390         st.Bind(1,"200");\r
391         st.Step();\r
392         st.Reset();\r
393         upd.Bind(0,"Messages");\r
394         upd.Bind(1,order++);\r
395         upd.Bind(2);\r
396         upd.Bind(3,"The maximum number of messages you will download from each peer on a given day.");\r
397         upd.Bind(4,"MaxPeerMessagesPerDay");\r
398         upd.Step();\r
399         upd.Reset();\r
400 \r
401         st.Bind(0,"MaxBoardsPerMessage");\r
402         st.Bind(1,"8");\r
403         st.Step();\r
404         st.Reset();\r
405         upd.Bind(0,"Messages");\r
406         upd.Bind(1,order++);\r
407         upd.Bind(2);\r
408         upd.Bind(3,"The maximum number of boards a received message may be sent to.  Boards over this limit will be ignored.");\r
409         upd.Bind(4,"MaxBoardsPerMessage");\r
410         upd.Step();\r
411         upd.Reset();\r
412 \r
413         st.Bind(0,"SaveMessagesFromNewBoards");\r
414         st.Bind(1,"true");\r
415         st.Step();\r
416         st.Reset();\r
417         upd.Bind(0,"Messages");\r
418         upd.Bind(1,order++);\r
419         upd.Bind(2,"true|true|false|false");\r
420         upd.Bind(3,"Set to true to automatically save messages posted to new boards.  Set to false to ignore messages to new boards.");\r
421         upd.Bind(4,"SaveMessagesFromNewBoards");\r
422         upd.Step();\r
423         upd.Reset();\r
424 \r
425         st.Bind(0,"ChangeMessageTrustOnReply");\r
426         st.Bind(1,"0");\r
427         st.Step();\r
428         st.Reset();\r
429         upd.Bind(0,"Messages");\r
430         upd.Bind(1,order++);\r
431         upd.Bind(2);\r
432         upd.Bind(3,"How much the local message trust level of an identity should change when you reply to one of their messages.");\r
433         upd.Bind(4,"ChangeMessageTrustOnReply");\r
434         upd.Step();\r
435         upd.Reset();\r
436 \r
437         st.Bind(0,"AddNewPostFromIdentities");\r
438         st.Bind(1,"false");\r
439         st.Step();\r
440         st.Reset();\r
441         upd.Bind(0,"Messages");\r
442         upd.Bind(1,order++);\r
443         upd.Bind(2,"true|true|false|false");\r
444         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
445         upd.Bind(4,"AddNewPostFromIdentities");\r
446         upd.Step();\r
447         upd.Reset();\r
448 \r
449         st.Bind(0,"DeleteMessagesOlderThan");\r
450         st.Bind(1,"180");\r
451         st.Step();\r
452         st.Reset();\r
453         upd.Bind(0,"Messages");\r
454         upd.Bind(1,order++);\r
455         upd.Bind(2);\r
456         upd.Bind(3,"Automatically delete messages older than this many days.");\r
457         upd.Bind(4,"DeleteMessagesOlderThan");\r
458         upd.Step();\r
459         upd.Reset();\r
460 \r
461 }\r