1 /***************************************************************************
2 * Copyright (C) 2005-09 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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
24 #include <QCoreApplication>
28 #include "abstractcliparser.h"
33 Q_DECLARE_TR_FUNCTIONS(Quassel)
43 QString fancyVersionString; // clickable rev
44 QString plainVersionString; // no <a> tag
47 QString generatedVersion;
53 uint clientNeedsProtocol;
54 uint coreNeedsProtocol;
56 QString applicationName;
57 QString coreApplicationName;
58 QString clientApplicationName;
59 QString organizationName;
60 QString organizationDomain;
63 //! A list of features that are optional in core and/or client, but need runtime checking
64 /** Some features require an uptodate counterpart, but don't justify a protocol break.
65 * This is what we use this enum for. Add such features to it and check at runtime on the other
66 * side for their existence.
68 * This list should be cleaned up after every protocol break, as we can assume them to be present then.
71 SynchronizedMarkerLine = 0x0001,
72 SaslAuthentication = 0x0002,
76 Q_DECLARE_FLAGS(Features, Feature);
78 //! The features the current version of Quassel supports (\sa Feature)
79 /** \return An ORed list of all enum values in Feature
81 static Features features();
85 static void setupBuildInfo(const QString &generated);
86 static inline const BuildInfo & buildInfo();
87 static inline RunMode runMode();
89 static QString configDirPath();
91 //! Returns a list of data directory paths
92 /** There are several locations for applications to install their data files in. On Unix,
93 * a common location is /usr/share; others include $PREFIX/share and additional directories
94 * specified in the env variable XDG_DATA_DIRS.
95 * \return A list of directory paths to look for data files in
97 static QStringList dataDirPaths();
99 //! Searches for a data file in the possible data directories
100 /** Data files can reside in $DATA_DIR/apps/quassel, where $DATA_DIR is one of the directories
101 * returned by \sa dataDirPaths().
102 * \Note With KDE integration enabled, files are searched (only) in KDE's appdata dirs.
103 * \return The full path to the data file if found; a null QString else
105 static QString findDataFilePath(const QString &filename);
107 static QString translationDirPath();
109 //! Returns a list of directories we look for scripts in
110 /** We look for a subdirectory named "scripts" in the configdir and in all datadir paths.
111 * \return A list of directory paths containing executable scripts for /exec
113 static QStringList scriptDirPaths();
115 static void loadTranslation(const QLocale &locale);
117 static inline void setCliParser(AbstractCliParser *cliParser);
118 static inline AbstractCliParser *cliParser();
119 static inline QString optionValue(const QString &option);
120 static inline bool isOptionSet(const QString &option);
122 static const QString &coreDumpFileName();
133 static inline LogLevel logLevel();
134 static inline QFile *logFile();
135 static inline bool logToSyslog();
137 static void logFatalMessage(const char *msg);
144 inline void setRunMode(RunMode mode);
145 inline void setDataDirPaths(const QStringList &paths);
146 QStringList findDataDirPaths() const;
147 inline void disableCrashhandler();
150 void registerMetaTypes();
152 static void handleSignal(int signal);
153 static void logBacktrace(const QString &filename);
155 static Quassel *_instance;
156 static BuildInfo _buildInfo;
157 static AbstractCliParser *_cliParser;
158 static RunMode _runMode;
159 static bool _initialized;
160 static bool _handleCrashes;
162 static QString _coreDumpFileName;
163 static QString _configDirPath;
164 static QStringList _dataDirPaths;
165 static QString _translationDirPath;
167 static LogLevel _logLevel;
168 static QFile *_logFile;
169 static bool _logToSyslog;
172 Q_DECLARE_OPERATORS_FOR_FLAGS(Quassel::Features);
174 const Quassel::BuildInfo & Quassel::buildInfo() { return _buildInfo; }
175 Quassel::RunMode Quassel::runMode() { return _runMode; }
176 void Quassel::setRunMode(Quassel::RunMode mode) { _runMode = mode; }
177 void Quassel::setDataDirPaths(const QStringList &paths) { _dataDirPaths = paths; }
178 void Quassel::disableCrashhandler() { _handleCrashes = false; }
180 void Quassel::setCliParser(AbstractCliParser *parser) { _cliParser = parser; }
181 AbstractCliParser *Quassel::cliParser() { return _cliParser; }
182 QString Quassel::optionValue(const QString &key) { return cliParser()->value(key); }
183 bool Quassel::isOptionSet(const QString &key) { return cliParser()->isSet(key); }
185 Quassel::LogLevel Quassel::logLevel() { return _logLevel; }
186 QFile *Quassel::logFile() { return _logFile; }
187 bool Quassel::logToSyslog() { return _logToSyslog; }