1 /***************************************************************************
2 * Copyright (C) 2005-2014 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
24 #include <QCoreApplication>
28 #include "abstractcliparser.h"
34 Q_DECLARE_TR_FUNCTIONS(Quassel)
44 QString fancyVersionString; // clickable rev
45 QString plainVersionString; // no <a> tag
48 QString generatedVersion;
54 uint clientNeedsProtocol;
55 uint coreNeedsProtocol;
57 QString applicationName;
58 QString coreApplicationName;
59 QString clientApplicationName;
60 QString organizationName;
61 QString organizationDomain;
64 //! A list of features that are optional in core and/or client, but need runtime checking
65 /** Some features require an uptodate counterpart, but don't justify a protocol break.
66 * This is what we use this enum for. Add such features to it and check at runtime on the other
67 * side for their existence.
69 * This list should be cleaned up after every protocol break, as we can assume them to be present then.
72 SynchronizedMarkerLine = 0x0001,
73 SaslAuthentication = 0x0002,
74 SaslExternal = 0x0004,
75 HideInactiveNetworks = 0x0008,
79 Q_DECLARE_FLAGS(Features, Feature);
81 //! The features the current version of Quassel supports (\sa Feature)
82 /** \return An ORed list of all enum values in Feature
84 static Features features();
88 static void setupBuildInfo(const QString &generated);
89 static inline const BuildInfo &buildInfo();
90 static inline RunMode runMode();
92 static QString configDirPath();
94 //! Returns a list of data directory paths
95 /** There are several locations for applications to install their data files in. On Unix,
96 * a common location is /usr/share; others include $PREFIX/share and additional directories
97 * specified in the env variable XDG_DATA_DIRS.
98 * \return A list of directory paths to look for data files in
100 static QStringList dataDirPaths();
102 //! Searches for a data file in the possible data directories
103 /** Data files can reside in $DATA_DIR/apps/quassel, where $DATA_DIR is one of the directories
104 * returned by \sa dataDirPaths().
105 * \Note With KDE integration enabled, files are searched (only) in KDE's appdata dirs.
106 * \return The full path to the data file if found; a null QString else
108 static QString findDataFilePath(const QString &filename);
110 static QString translationDirPath();
112 //! Returns a list of directories we look for scripts in
113 /** We look for a subdirectory named "scripts" in the configdir and in all datadir paths.
114 * \return A list of directory paths containing executable scripts for /exec
116 static QStringList scriptDirPaths();
118 static void loadTranslation(const QLocale &locale);
120 static inline void setCliParser(AbstractCliParser *cliParser);
121 static inline AbstractCliParser *cliParser();
122 static inline QString optionValue(const QString &option);
123 static inline bool isOptionSet(const QString &option);
125 static const QString &coreDumpFileName();
136 static inline LogLevel logLevel();
137 static inline QFile *logFile();
138 static inline bool logToSyslog();
140 static void logFatalMessage(const char *msg);
147 inline void setRunMode(RunMode mode);
148 inline void setDataDirPaths(const QStringList &paths);
149 QStringList findDataDirPaths() const;
150 inline void disableCrashhandler();
153 void registerMetaTypes();
155 static void handleSignal(int signal);
156 static void logBacktrace(const QString &filename);
158 static Quassel *_instance;
159 static BuildInfo _buildInfo;
160 static AbstractCliParser *_cliParser;
161 static RunMode _runMode;
162 static bool _initialized;
163 static bool _handleCrashes;
165 static QString _coreDumpFileName;
166 static QString _configDirPath;
167 static QStringList _dataDirPaths;
168 static QString _translationDirPath;
170 static LogLevel _logLevel;
171 static QFile *_logFile;
172 static bool _logToSyslog;
176 Q_DECLARE_OPERATORS_FOR_FLAGS(Quassel::Features);
178 const Quassel::BuildInfo &Quassel::buildInfo() { return _buildInfo; }
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; }
182 void Quassel::disableCrashhandler() { _handleCrashes = false; }
184 void Quassel::setCliParser(AbstractCliParser *parser) { _cliParser = parser; }
185 AbstractCliParser *Quassel::cliParser() { return _cliParser; }
186 QString Quassel::optionValue(const QString &key) { return cliParser()->value(key); }
187 bool Quassel::isOptionSet(const QString &key) { return cliParser()->isSet(key); }
189 Quassel::LogLevel Quassel::logLevel() { return _logLevel; }
190 QFile *Quassel::logFile() { return _logFile; }
191 bool Quassel::logToSyslog() { return _logToSyslog; }