Huggle  build:^490^dce1e5c
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
configuration.hpp
1 //This program is free software: you can redistribute it and/or modify
2 //it under the terms of the GNU General Public License as published by
3 //the Free Software Foundation, either version 3 of the License, or
4 //(at your option) any later version.
5 
6 //This program is distributed in the hope that it will be useful,
7 //but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 //GNU General Public License for more details.
10 
11 // comment this if you want to disable python support
12 //#define PYTHONENGINE
13 
14 #ifndef CONFIGURATION_H
15 #define CONFIGURATION_H
16 #define PRODUCTION_BUILD 0
17 //! Minimal score the edit can have
18 #define MINIMAL_SCORE -999999
19 #define HUGGLE_VERSION "3.0.0.0"
20 #define HUGGLE_BYTE_VERSION 0x3000
21 //! Path where the extensions are located
22 #define EXTENSION_PATH "extensions"
23 #define MEDIAWIKI_DEFAULT_NS_MAIN ""
24 #define MEDIAWIKI_DEFAULT_NS_TALK "Talk:"
25 #define MEDIAWIKI_DEFAULT_NS_USER "User:"
26 #define MEDIAWIKI_DEFAULT_NS_USERTALK "User talk:"
27 #define MEDIAWIKI_DEFAULT_NS_PROJECT "Project:"
28 #define MEDIAWIKI_DEFAULT_NS_PROJECTTALK "Project talk:"
29 #define MEDIAWIKI_DEFAULT_NS_FILE "File:"
30 #define MEDIAWIKI_DEFAULT_NS_FILETALK "File talk:"
31 #define MEDIAWIKI_DEFAULT_NS_MEDIAWIKI "Mediawiki:"
32 #define MEDIAWIKI_DEFAULT_NS_MEDIAWIKITALK "Mediawiki talk:"
33 #define MEDIAWIKI_DEFAULT_NS_TEMPLATE "Template:"
34 #define MEDIAWIKI_DEFAULT_NS_TEMPLATETALK "Template talk:"
35 #define MEDIAWIKI_DEFAULT_NS_HELP "Help:"
36 #define MEDIAWIKI_DEFAULT_NS_HELPTALK "Help talk:"
37 #define MEDIAWIKI_DEFAULT_NS_CATEGORY "Category:"
38 #define MEDIAWIKI_DEFAULT_NS_CATEGORYTALK "Category talk:"
39 #define MEDIAWIKI_DEFAULT_NS_PORTAL "Portal:"
40 #define MEDIAWIKI_DEFAULT_NS_PORTALTALK "Portal talk:"
41 #define MEDIAWIKI_NSID_MAIN 0
42 #define MEDIAWIKI_NSID_TALK 1
43 #define MEDIAWIKI_NSID_USER 2
44 #define MEDIAWIKI_NSID_USERTALK 3
45 #define MEDIAWIKI_NSID_PROJECT 4
46 #define MEDIAWIKI_NSID_PROJECTTALK 5
47 #define MEDIAWIKI_NSID_FILE 6
48 #define MEDIAWIKI_NSID_FILETALK 7
49 #define MEDIAWIKI_NSID_MEDIAWIKI 8
50 #define MEDIAWIKI_NSID_MEDIAWIKITALK 9
51 #define MEDIAWIKI_NSID_TEMPLATE 10
52 #define MEDIAWIKI_NSID_TEMPLATETALK 11
53 #define MEDIAWIKI_NSID_HELP 12
54 #define MEDIAWIKI_NSID_HELPTALK 13
55 #define MEDIAWIKI_NSID_CATEGORY 14
56 #define MEDIAWIKI_NSID_CATEGORYTALK 15
57 #define MEDIAWIKI_NSID_PORTAL 100
58 
59 #include <QList>
60 #include <QStringList>
61 #include <QDir>
62 #include <QtXml>
63 #include <QString>
64 #include "core.hpp"
65 #include "wikisite.hpp"
66 
67 //! Huggle namespace contains all objects that belongs to huggle only so that they don't colide with other objects
68 namespace Huggle
69 {
70  class Core;
71  /*!
72  * \brief The ScoreWord class
73  *
74  * Every score word is represented by this class, a score word is a pattern
75  * that has some score and score of edit is incremented by sum of all scores
76  * of all score words matched in edit
77  */
78  class ScoreWord
79  {
80  public:
81  ScoreWord(QString Word, int Score);
82  ScoreWord(ScoreWord *word);
83  ScoreWord(const ScoreWord &word);
84  QString word;
85  int score;
86  };
87 
88  //! Run time configuration of huggle
90  {
91  public:
92  ////////////////////////////////////////////
93  // System
94  ////////////////////////////////////////////
95 
96  //! Verbosity for debugging to terminal etc, can be switched with parameter --verbosity
97  static unsigned int Verbosity;
98  //! Version
99  static QString HuggleVersion;
100  //! currently selected project
102  //! List of projects
103  static QList<WikiSite *> ProjectList;
104  //! When this is true most of functions will not work
105  static bool Restricted;
106  //! Return a prefix for url
107  static QString GetURLProtocolPrefix();
108  //! Where the welcome message is stored
109  static QString WelcomeMP;
110  //! Size of info cache
111  static int Cache_InfoSize;
112  //! Whether python is available
113  static bool PythonEngine;
114  //! Size of feed
115  static int ProviderCache;
116  //! Maximum size of ringlog
117  static int RingLogMaxSize;
118  //! Path where huggle contains its data
119  static QString HomePath;
120  //! Path to a file where information about wikis are stored
121  static QString WikiDB;
122  //! Return a configuration path
123  static QString GetConfigurationPath();
124  //! Data of wl
125  static QStringList WhiteList;
126  //! URL of wiki that contains a global config
128  //! Number of seconds for which the processed queries remain in list of processes
129  static int QueryListTimeLimit;
130  //! Number of edits to keep in history stack
131  static int HistorySize;
132  //! Language selected by user this is only a language of interface
133  static QString Language;
134  //! Number of edits made since you logged in
135  static double EditCounter;
136  //! Number of reverts made since you logged in
137  static double RvCounter;
138  //! Ask user if they really want to report someone
139  static bool AskUserBeforeReport;
140  //! This is experimental feature that removes the old templates from talk pages when they are being read
141  static bool TrimOldWarnings;
142  static QStringList Rights;
143  //! Whether new edits go to top or bottom
144  static bool QueueNewEditsUp;
145  //! If this is true some functionalities will be disabled
146  static bool _SafeMode;
147  //! Resolve edit conflict without asking user
149  //! Size of fonts in diff
150  static int FontSize;
151  //! Timeout for queries
152  static int ReadTimeout;
153  //! Timeout for write / update queries
154  static int WriteTimeout;
155  //! Whitelist is not useable
156  static bool WhitelistDisabled;
157 
158  //! If this is true huggle will always use software rollback even if user has the rollback privileges
160 
161  //////////////////////////////////////////////
162  // Local config
163  //////////////////////////////////////////////
164 
165  //! Minimal version of huggle required to use it
167  static bool LocalConfig_UseIrc;
168  static bool LocalConfig_RequireRollback;
169  static bool LocalConfig_RequireAdmin;
170  static bool LocalConfig_EnableAll;
171  static int LocalConfig_RequireEdits;
172 
173  static bool LocalConfig_AIV;
174  static bool LocalConfig_AIVExtend;
175  static QString LocalConfig_ReportPath;
176  //! Section of report page to append template to
178  //! IP vandals
180  //! Regular users
182  static QString LocalConfig_WelcomeSummary;
183  static QString LocalConfig_NSTalk;
184  static QString LocalConfig_NSUserTalk;
185  static QString LocalConfig_NSProject;
186  static QString LocalConfig_NSUser;
187  static QString LocalConfig_NSProjectTalk;
188  static QString LocalConfig_NSFile;
189  static QString LocalConfig_NSFileTalk;
190  static QString LocalConfig_NSMediaWiki;
191  static QString LocalConfig_NSMediaWikiTalk;
192  static QString LocalConfig_NSTemplate;
193  static QString LocalConfig_NSTemplateTalk;
194  static QString LocalConfig_NSHelp;
195  static QString LocalConfig_NSHelpTalk;
196  static QString LocalConfig_NSCategory;
197  static QString LocalConfig_NSCategoryTalk;
198  static QString LocalConfig_NSPortal;
199  static QString LocalConfig_NSPortalTalk;
200  static int LocalConfig_TemplateAge;
201  static bool LocalConfig_ConfirmMultipleEdits;
202  static bool LocalConfig_ConfirmRange;
203  static bool LocalConfig_ConfirmPage;
204  static bool LocalConfig_ConfirmSame;
205  static bool LocalConfig_ConfirmWarned;
206 
207  // Reverting
208 
209  static QString LocalConfig_MultipleRevertSummary;
210  static QStringList LocalConfig_RevertSummaries;
211  static QString LocalConfig_SoftwareRevertDefaultSummary;
212  static QString LocalConfig_RollbackSummary;
213  static QString LocalConfig_DefaultSummary;
214  static QString LocalConfig_SingleRevert;
215  static QString LocalConfig_UndoSummary;
216  static QString LocalConfig_ClearTalkPageTemp;
217  static QString LocalConfig_WelcomeAnon;
218  static QString LocalConfig_WelcomeTitle;
219 
220  // Warnings
221 
222  static QString LocalConfig_AgfRevert;
223  static QString LocalConfig_WarnSummary;
224  static QString LocalConfig_WarnSummary2;
225  static QString LocalConfig_WarnSummary3;
226  static QString LocalConfig_WarnSummary4;
227  static QStringList LocalConfig_WarningTemplates;
228  static QStringList LocalConfig_WarningDefs;
229  static QString LocalConfig_ReportSummary;
230  static bool LocalConfig_WelcomeGood;
231 
232  // Blocking users
233  static QStringList LocalConfig_BlockExpiryOptions;
234  static QString LocalConfig_BlockTime;
235  static QString LocalConfig_BlockTimeAnon;
236  static QString LocalConfig_BlockMessage;
237  static QString LocalConfig_BlockMessageIndef;
238  static QString LocalConfig_BlockReason;
239  static QString LocalConfig_BlockSummary;
240 
241  // Protecting pages
242  static QString LocalConfig_ProtectReason;
243 
244  // Definitions
245 
246  static QList<ScoreWord> LocalConfig_ScoreParts;
247  static QList<ScoreWord> LocalConfig_ScoreWords;
248  static int LocalConfig_ScoreFlag;
249  //! Score that is added for every edit that has really big size
251  static QStringList LocalConfig_Ignores;
252  static QStringList LocalConfig_RevertPatterns;
253  static QStringList LocalConfig_Assisted;
254  static QStringList LocalConfig_Templates;
255  static QStringList LocalConfig_IgnorePatterns;
256  static int LocalConfig_TalkPageWarningScore;
257  static bool LocalConfig_GlobalRequired;
258 
259  static int LocalConfig_BotScore;
260  static int LocalConfig_IPScore;
261  static int LocalConfig_WarningScore;
262  static QStringList LocalConfig_WarningTypes;
263  static QStringList LocalConfig_DeletionTemplates;
264  static QStringList LocalConfig_WelcomeTypes;
265  static int LocalConfig_WhitelistScore;
266 
267  // UAA
268  static QString LocalConfig_UAAPath;
269  static bool LocalConfig_UAAavailable;
270  static QString LocalConfig_UAATemplate;
271 
272 
273  //////////////////////////////////////////////
274  // Global config
275  //////////////////////////////////////////////
276 
277  static bool GlobalConfig_EnableAll;
278  static QString GlobalConfig_MinVersion;
279  static QString GlobalConfig_LocalConfigWikiPath;
280  static QString GlobalConfig_DocumentationPath;
281  static QString GlobalConfig_FeedbackPath;
282  static QString GlobalConfig_UserConf;
283  static bool GlobalConfigWasLoaded;
284 
285  //////////////////////////////////////////////
286  // Login
287  //////////////////////////////////////////////
288 
289  //! User name
290  static QString UserName;
291  //! If SSL is being used
292  static bool UsingSSL;
293  //! Consumer key
294  static QString WmfOAuthConsumerKey;
295  //! Password
296  static QString Password;
297 
298  //////////////////////////////////////////////
299  // IRC
300  //////////////////////////////////////////////
301 
302  //! Whether IRC is being used
303  static bool UsingIRC;
304  //! Server
305  static QString IRCServer;
306  //! Nick
307  static QString IRCNick;
308  //! Ident
309  static QString IRCIdent;
310  //! Port
311  static quint16 IRCPort;
312 
313  //////////////////////////////////////////////
314  // Friends
315  //////////////////////////////////////////////
316 
317  //! Suffix used by huggle
318  static QString EditSuffixOfHuggle;
319  //! Regexes that other tools can be identified with
320  static QStringList EditRegexOfTools;
321 
322  //////////////////////////////////////////////
323  // Reverting
324  //////////////////////////////////////////////
325 
326  static QString DefaultRevertSummary;
327  /*!
328  * \brief GetDefaultRevertSummary Retrieve default summary
329  * \param source User who should be replaced instead of $1
330  * \return Default revert summary
331  */
332  static QString GetDefaultRevertSummary(QString source);
333  //! Warn you in case you want to revert a user page
334  static bool WarnUserSpaceRoll;
335  static bool NextOnRv;
336  //! Send a message to user on good edit
337  static bool WelcomeEmpty;
338 
339  static QString VandalNw_Server;
340  static QString VandalNw_Ident;
341  static bool VandalNw_Login;
342 
343 
344  /*!
345  * \brief Bool2String Convert a bool to string
346  * \param b bool
347  * \return string
348  */
349  static QString Bool2String(bool b);
350 
351  //! Save the local configuration to file
352  static void SaveConfig();
353  //! Load the local configuration from disk
354  static void LoadConfig();
355  static void NormalizeConf();
356  //! This function creates a user configuration that is stored on wiki
357  static QString MakeLocalUserConfig();
358  /*!
359  * \brief InsertConfig
360  * \param key Configuration key
361  * \param value Value of key
362  * \param s Stream writer
363  */
364  static void InsertConfig(QString key, QString value, QXmlStreamWriter *s);
365  static bool SafeBool(QString value, bool defaultvalue = false);
366  //! Parse all information from global config on meta
367  static bool ParseGlobalConfig(QString config);
368  //! Parse all information from local config, this function is used in login
369  static bool ParseLocalConfig(QString config);
370  static bool ParseUserConfig(QString config);
371  //! Parse a string from configuration which has format used by huggle 2x
372  /*!
373  * \param key Key
374  * \param content Text to parse from
375  * \param missing Default value in case this key is missing in text
376  * \return Value of key
377  */
378  static QString ConfigurationParse(QString key, QString content, QString missing = "");
379  /*!
380  * \brief ConfigurationParse_QL Parses a QStringList of values for a given key
381  * \param key Key
382  * \param content Text to parse key from
383  * \param CS Whether the values are separated by comma
384  * \return List of values from text or empty list
385  */
386  static QStringList ConfigurationParse_QL(QString key, QString content, bool CS = false);
387  static QStringList ConfigurationParse_QL(QString key, QString content, QStringList list, bool CS = false);
388  };
389 }
390 
391 #endif // CONFIGURATION_H
static QString HuggleVersion
Version.
static QStringList ConfigurationParse_QL(QString key, QString content, bool CS=false)
ConfigurationParse_QL Parses a QStringList of values for a given key.
static QString WikiDB
Path to a file where information about wikis are stored.
The ScoreWord class.
static bool QueueNewEditsUp
Whether new edits go to top or bottom.
static double RvCounter
Number of reverts made since you logged in.
static QString HomePath
Path where huggle contains its data.
static QString UserName
User name.
static int QueryListTimeLimit
Number of seconds for which the processed queries remain in list of processes.
static QString GetConfigurationPath()
Return a configuration path.
static bool Restricted
When this is true most of functions will not work.
static bool WelcomeEmpty
Send a message to user on good edit.
static int ReadTimeout
Timeout for queries.
static QString Bool2String(bool b)
Bool2String Convert a bool to string.
static QString GetURLProtocolPrefix()
Return a prefix for url.
static double EditCounter
Number of edits made since you logged in.
static bool TrimOldWarnings
This is experimental feature that removes the old templates from talk pages when they are being read...
static QString LocalConfig_RUTemplateReport
Regular users.
static QString WmfOAuthConsumerKey
Consumer key.
static void LoadConfig()
Load the local configuration from disk.
static bool WarnUserSpaceRoll
Warn you in case you want to revert a user page.
static QString IRCIdent
Ident.
static QString IRCServer
Server.
static bool UsingIRC
Whether IRC is being used.
static void InsertConfig(QString key, QString value, QXmlStreamWriter *s)
InsertConfig.
static QString Language
Language selected by user this is only a language of interface.
static int ProviderCache
Size of feed.
static QStringList EditRegexOfTools
Regexes that other tools can be identified with.
static QString Password
Password.
static QStringList WhiteList
Data of wl.
static int LocalConfig_ReportSt
Section of report page to append template to.
static int Cache_InfoSize
Size of info cache.
static QString IRCNick
Nick.
static int HistorySize
Number of edits to keep in history stack.
static QString MakeLocalUserConfig()
This function creates a user configuration that is stored on wiki.
static bool ParseUserConfig(QString config)
static quint16 IRCPort
Port.
static unsigned int Verbosity
Verbosity for debugging to terminal etc, can be switched with parameter –verbosity.
static int WriteTimeout
Timeout for write / update queries.
static QString LocalConfig_MinimalVersion
Minimal version of huggle required to use it.
static WikiSite Project
currently selected project
static int LocalConfig_ScoreChange
Score that is added for every edit that has really big size.
static QString EditSuffixOfHuggle
Suffix used by huggle.
static int RingLogMaxSize
Maximum size of ringlog.
static int FontSize
Size of fonts in diff.
static bool AutomaticallyResolveConflicts
Resolve edit conflict without asking user.
static bool ParseGlobalConfig(QString config)
Parse all information from global config on meta.
static bool PythonEngine
Whether python is available.
static QString ConfigurationParse(QString key, QString content, QString missing="")
Parse a string from configuration which has format used by huggle 2x.
static bool WhitelistDisabled
Whitelist is not useable.
static QString LocalConfig_IPVTemplateReport
IP vandals.
static bool UsingSSL
If SSL is being used.
static bool ParseLocalConfig(QString config)
Parse all information from local config, this function is used in login.
static QList< WikiSite * > ProjectList
List of projects.
static QString GlobalConfigurationWikiAddress
URL of wiki that contains a global config.
Run time configuration of huggle.
static bool _SafeMode
If this is true some functionalities will be disabled.
static QString WelcomeMP
Where the welcome message is stored.
static void SaveConfig()
Save the local configuration to file.
static QString GetDefaultRevertSummary(QString source)
GetDefaultRevertSummary Retrieve default summary.
static bool AskUserBeforeReport
Ask user if they really want to report someone.
static bool EnforceManualSoftwareRollback
If this is true huggle will always use software rollback even if user has the rollback privileges...