Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
quassel.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 by the Quassel Project *
3  * devel@quassel-irc.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) version 3. *
9  * *
10  * This program 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 *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef QUASSEL_H_
22 #define QUASSEL_H_
23 
24 #include <QCoreApplication>
25 #include <QLocale>
26 #include <QString>
27 
28 #include "abstractcliparser.h"
29 
30 class QFile;
31 
32 class Quassel
33 {
35 
36 public:
37  enum RunMode {
38  Monolithic,
39  ClientOnly,
40  CoreOnly
41  };
42 
43  struct BuildInfo {
44  QString fancyVersionString; // clickable rev
45  QString plainVersionString; // no <a> tag
46 
47  QString baseVersion;
49  QString commitHash;
50  uint commitDate;
51  QString buildDate;
52 
53  uint protocolVersion; // deprecated
54 
55  QString applicationName;
60  };
61 
63 
69  enum Feature {
72  SaslExternal = 0x0004,
74  PasswordChange = 0x0010,
75 
76  NumFeatures = 0x0010
77  };
78  Q_DECLARE_FLAGS(Features, Feature);
79 
81 
83  static Features features();
84 
85  virtual ~Quassel();
86 
87  static void setupBuildInfo();
88  static inline const BuildInfo &buildInfo();
89  static inline RunMode runMode();
90 
91  static QString configDirPath();
92 
94 
99  static QStringList dataDirPaths();
100 
102 
107  static QString findDataFilePath(const QString &filename);
108 
109  static QString translationDirPath();
110 
112 
115  static QStringList scriptDirPaths();
116 
117  static void loadTranslation(const QLocale &locale);
118 
119  static inline void setCliParser(AbstractCliParser *cliParser);
120  static inline AbstractCliParser *cliParser();
121  static inline QString optionValue(const QString &option);
122  static inline bool isOptionSet(const QString &option);
123 
124  static const QString &coreDumpFileName();
125 
126  static bool DEBUG;
127 
128  enum LogLevel {
133  };
134 
135  static inline LogLevel logLevel();
136  static inline QFile *logFile();
137  static inline bool logToSyslog();
138 
139  static void logFatalMessage(const char *msg);
140 
141 protected:
142  Quassel();
143  virtual bool init();
144  virtual void quit();
145 
146  inline void setRunMode(RunMode mode);
147  inline void setDataDirPaths(const QStringList &paths);
148  QStringList findDataDirPaths() const;
149  inline void disableCrashhandler();
150 
151 private:
152  void setupEnvironment();
153  void registerMetaTypes();
154 
155  static void handleSignal(int signal);
156  static void logBacktrace(const QString &filename);
157 
161  static RunMode _runMode;
162  static bool _initialized;
163  static bool _handleCrashes;
164 
165  static QString _coreDumpFileName;
166  static QString _configDirPath;
167  static QStringList _dataDirPaths;
168  static QString _translationDirPath;
169 
171  static QFile *_logFile;
172  static bool _logToSyslog;
173 };
174 
175 
176 Q_DECLARE_OPERATORS_FOR_FLAGS(Quassel::Features);
177 
179 Quassel::RunMode Quassel::runMode() { return _runMode; }
180 void Quassel::setRunMode(Quassel::RunMode mode) { _runMode = mode; }
181 void Quassel::setDataDirPaths(const QStringList &paths) { _dataDirPaths = paths; }
183 
186 QString Quassel::optionValue(const QString &key) { return cliParser()->value(key); }
187 bool Quassel::isOptionSet(const QString &key) { return cliParser()->isSet(key); }
188 
190 QFile *Quassel::logFile() { return _logFile; }
192 
193 #endif