1 /***************************************************************************
2 * Copyright (C) 2005-2018 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 ***************************************************************************/
25 # include <sys/types.h>
26 # include <sys/stat.h>
27 #endif /* HAVE_UMASK */
29 #include <QCoreApplication>
33 # include "coreapplication.h"
34 #elif defined BUILD_QTUI
35 # include "aboutdata.h"
36 # include "qtuiapplication.h"
37 #elif defined BUILD_MONO
38 # include "aboutdata.h"
39 # include "monoapplication.h"
42 #error "Something is wrong - you need to #define a build mode!"
45 // We don't want quasselcore to depend on KDE
46 #if defined HAVE_KF5 && defined BUILD_CORE
51 # include <KCoreAddons/KAboutData>
52 # include <KCoreAddons/Kdelibs4ConfigMigrator>
55 #if !defined(BUILD_CORE) && defined(STATIC)
57 Q_IMPORT_PLUGIN(qjpeg)
61 #include "qt5cliparser.h"
65 int main(int argc, char **argv)
68 umask(S_IRWXG | S_IRWXO);
71 // Instantiate early, so log messages are handled
74 Quassel::setupBuildInfo();
75 QCoreApplication::setApplicationName(Quassel::buildInfo().applicationName);
76 QCoreApplication::setApplicationVersion(Quassel::buildInfo().plainVersionString);
77 QCoreApplication::setOrganizationName(Quassel::buildInfo().organizationName);
78 QCoreApplication::setOrganizationDomain(Quassel::buildInfo().organizationDomain);
80 //Setup the High-DPI settings
81 # if QT_VERSION >= 0x050600 && defined(Q_OS_WIN)
82 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); //Added in Qt 5.6
84 QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
86 // We need to explicitly initialize the required resources when linking statically
91 Q_INIT_RESOURCE(pics);
92 Q_INIT_RESOURCE(hicolor_icons);
96 Q_INIT_RESOURCE(i18n);
98 Q_INIT_RESOURCE(data);
99 Q_INIT_RESOURCE(breeze_icons);
100 Q_INIT_RESOURCE(breeze_dark_icons);
101 # ifdef WITH_OXYGEN_ICONS
102 Q_INIT_RESOURCE(oxygen_icons);
104 # ifdef WITH_BUNDLED_ICONS
105 Q_INIT_RESOURCE(breeze_icon_theme);
106 Q_INIT_RESOURCE(breeze_dark_icon_theme);
107 # ifdef WITH_OXYGEN_ICONS
108 Q_INIT_RESOURCE(oxygen_icon_theme);
114 std::shared_ptr<AbstractCliParser> cliParser = std::make_shared<Qt5CliParser>();
115 Quassel::setCliParser(cliParser);
117 // Initialize CLI arguments
118 // NOTE: We can't use tr() at this point, since app is not yet created
119 // TODO: Change this once we get rid of KDE4 and can initialize the parser after creating the app
121 // put shared client&core arguments here
122 cliParser->addSwitch("debug", 'd', "Enable debug output");
123 cliParser->addSwitch("help", 'h', "Display this help and exit");
124 cliParser->addSwitch("version", 'v', "Display version information");
126 cliParser->addOption("configdir", 'c', "Specify the directory holding the client configuration", "path");
128 cliParser->addOption("configdir", 'c', "Specify the directory holding configuration files, the SQlite database and the SSL certificate", "path");
130 cliParser->addOption("datadir", 0, "DEPRECATED - Use --configdir instead", "path");
131 cliParser->addOption("loglevel", 'L', "Loglevel Debug|Info|Warning|Error", "level", "Info");
133 cliParser->addSwitch("syslog", 0, "Log to syslog");
135 cliParser->addOption("logfile", 'l', "Log to a file", "path");
138 // put client-only arguments here
139 cliParser->addOption("icontheme", 0, "Override the system icon theme ('breeze' is recommended)", "theme");
140 cliParser->addOption("qss", 0, "Load a custom application stylesheet", "file.qss");
141 cliParser->addSwitch("debugbufferswitches", 0, "Enables debugging for bufferswitches");
142 cliParser->addSwitch("debugmodel", 0, "Enables debugging for models");
143 cliParser->addSwitch("hidewindow", 0, "Start the client minimized to the system tray");
146 // put core-only arguments here
147 cliParser->addOption("listen", 0, "The address(es) quasselcore will listen on", "<address>[,<address>[,...]]", "::,0.0.0.0");
148 cliParser->addOption("port", 'p', "The port quasselcore will listen at", "port", "4242");
149 cliParser->addSwitch("norestore", 'n', "Don't restore last core's state");
150 cliParser->addSwitch("config-from-environment", 0, "Load configuration from environment variables");
151 cliParser->addOption("select-backend", 0, "Switch storage backend (migrating data if possible)", "backendidentifier");
152 cliParser->addOption("select-authenticator", 0, "Select authentication backend", "authidentifier");
153 cliParser->addSwitch("add-user", 0, "Starts an interactive session to add a new core user");
154 cliParser->addOption("change-userpass", 0, "Starts an interactive session to change the password of the user identified by <username>", "username");
155 cliParser->addSwitch("oidentd", 0, "Enable oidentd integration. In most cases you should also enable --strict-ident");
156 cliParser->addOption("oidentd-conffile", 0, "Set path to oidentd configuration file", "file");
157 cliParser->addSwitch("strict-ident", 0, "Use users' quasselcore username as ident reply. Ignores each user's configured ident setting.");
158 cliParser->addSwitch("ident-daemon", 0, "Enable internal ident daemon");
159 cliParser->addOption("ident-port", 0, "The port quasselcore will listen at for ident requests. Only meaningful with --ident-daemon", "port", "10113");
161 cliParser->addSwitch("require-ssl", 0, "Require SSL for remote (non-loopback) client connections");
162 cliParser->addOption("ssl-cert", 0, "Specify the path to the SSL Certificate", "path", "configdir/quasselCert.pem");
163 cliParser->addOption("ssl-key", 0, "Specify the path to the SSL key", "path", "ssl-cert-path");
165 cliParser->addSwitch("debug-irc", 0,
166 "Enable logging of all raw IRC messages to debug log, including "
167 "passwords! In most cases you should also set --loglevel Debug");
168 cliParser->addOption("debug-irc-id", 0,
169 "Limit raw IRC logging to this network ID. Implies --debug-irc",
170 "database network ID", "-1");
171 cliParser->addSwitch("enable-experimental-dcc", 0, "Enable highly experimental and unfinished support for CTCP DCC (DANGEROUS)");
174 #if defined BUILD_CORE
175 CoreApplication app(argc, argv);
176 #elif defined BUILD_QTUI
177 QtUiApplication app(argc, argv);
178 #elif defined BUILD_MONO
179 MonolithicApplication app(argc, argv);
182 if (!cliParser->init(app.arguments())) {
187 // Migrate settings from KDE4 to KF5 if appropriate
189 Kdelibs4ConfigMigrator migrator(QCoreApplication::applicationName());
190 migrator.setConfigFiles(QStringList() << "quasselrc" << "quassel.notifyrc");
195 // FIXME: This should be done after loading the translation catalogue, but still in main()
197 AboutData::setQuasselPersons(&aboutData);
198 KAboutData::setApplicationData(aboutData.kAboutData());
203 catch (ExitException e) {
204 if (!e.errorString.isEmpty()) {
205 qCritical() << e.errorString;