main.h
1 //------------------------------------------------------------------------------
2 // main.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2009 Braden "Blzut3" Obrzut <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 
24 #ifndef __MAIN_H__
25 #define __MAIN_H__
26 
27 #include <QApplication>
28 #include <QObject>
29 #include <QStringList>
30 #include <QUrl>
31 
32 class LocalizationInfo;
33 
37 class Main : public QObject
38 {
39  Q_OBJECT
40 
41 public:
52  static QString argDataDir;
53 
54  Main(int argc, char *argv[]);
55  ~Main() override;
56 
62  void finalize();
63 
67  int run();
68 
69 private:
70  enum LogVerbosity
71  {
72  LV_Default,
73  LV_Verbose,
74  LV_Quiet
75  };
76 
77  void applyLogVerbosity();
78  int connectToServerByURL();
79  void convertOldIniToQSettingsIni();
80 
81  void createMainWindow();
82 
83  int runTestMode();
84  int runVersionDump();
85 
86  void initCaCerts();
87 
93  bool initDataDirectories();
94 
100  int initIP2C();
101  void initIRCConfig();
102  void initLocalizationsDefinitions();
103  void initMainConfig();
104  void initPasswordsConfig();
105  void initPluginConfig();
106  int installPendingUpdates();
107 
112  bool interpretCommandLineParameters();
113  void setupRefreshingThread();
114  bool shouldLogToStderr() const;
115 
116  char **arguments;
117  int argumentsCount;
118  bool bIsFirstRun;
119  bool bTestMode;
120  bool bVersionDump;
121  QString versionDumpFile;
122  QStringList dataDirectories;
123  LogVerbosity logVerbosity;
124  QString rconPluginName;
125  QString rconAddress;
126  unsigned short rconPort;
127  bool startCreateGame;
128  bool startRcon;
129  int updateFailedCode;
130  QUrl connectUrl;
131  bool bPortableMode;
132 
133 private slots:
134  void runCreateGame();
135  void runRemoteConsole();
136 };
137 
138 #endif /* __MAIN_H__ */