added SignalProxy::isSecure() to determine if all connections are secure (ssl encrypt...
[quassel.git] / src / common / quassel.h
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
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  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef QUASSEL_H_
22 #define QUASSEL_H_
23
24 #include <QCoreApplication>
25 #include <QString>
26
27 #include "cliparser.h"
28
29 class Quassel {
30   Q_DECLARE_TR_FUNCTIONS(Quassel)
31
32 public:
33   enum RunMode {
34     Monolithic,
35     ClientOnly,
36     CoreOnly
37   };
38
39   struct BuildInfo {
40     QString fancyVersionString; // clickable rev
41     QString plainVersionString; // no <a> tag
42
43     QString baseVersion;
44     QString generatedVersion;
45     QString commitHash;
46     uint commitDate;
47     QString buildDate;
48     bool isSourceDirty;
49     uint protocolVersion;
50     uint clientNeedsProtocol;
51     uint coreNeedsProtocol;
52
53     QString applicationName;
54     QString coreApplicationName;
55     QString clientApplicationName;
56     QString organizationName;
57     QString organizationDomain;
58   };
59
60   void setupBuildInfo(const QString &generated);
61
62   virtual ~Quassel();
63
64   static inline const BuildInfo & buildInfo();
65   static inline RunMode runMode();
66
67   static inline CliParser *cliParser();
68   static inline QString optionValue(const QString &option);
69   static inline bool isOptionSet(const QString &option);
70
71   static const QString &coreDumpFileName();
72
73   static bool DEBUG;
74
75   static void logFatalMessage(const char *msg);
76
77 protected:
78   Quassel();
79   virtual bool init();
80
81   inline void setRunMode(RunMode mode);
82
83 private:
84   void registerMetaTypes();
85
86   static void handleSignal(int signal);
87   static void logBacktrace(const QString &filename);
88
89   static BuildInfo _buildInfo;
90   static CliParser *_cliParser;
91   static RunMode _runMode;
92   static bool _initialized;
93
94   static QString _coreDumpFileName;
95 };
96
97 const Quassel::BuildInfo & Quassel::buildInfo() { return _buildInfo; }
98 Quassel::RunMode Quassel::runMode() { return _runMode; }
99 void Quassel::setRunMode(Quassel::RunMode mode) { _runMode = mode; }
100
101 CliParser *Quassel::cliParser() { return _cliParser; }
102 QString Quassel::optionValue(const QString &key) { return cliParser()->value(key); }
103 bool Quassel::isOptionSet(const QString &key) { return cliParser()->isSet(key); }
104
105 #endif