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 "coreapplication.h"
25 #elif defined BUILD_QTUI
26 # include "qtuiapplication.h"
27 #elif defined BUILD_MONO
28 # include "monoapplication.h"
31 #error "Something is wrong - you need to #define a build mode!"
34 // We don't want quasselcore to depend on KDE
35 #if defined HAVE_KDE && defined BUILD_CORE
40 # include <KAboutData>
41 # include "kcmdlinewrapper.h"
44 #if !defined(BUILD_CORE) && defined(STATIC)
46 Q_IMPORT_PLUGIN(qjpeg)
50 #include "cliparser.h"
53 int main(int argc, char **argv) {
55 // Setup build information and version string
56 # include "version.gen"
57 buildinfo.append(QString(",%1,%2").arg(__DATE__, __TIME__));
58 Quassel::setupBuildInfo(buildinfo);
59 QCoreApplication::setApplicationName(Quassel::buildInfo().applicationName);
60 QCoreApplication::setOrganizationName(Quassel::buildInfo().organizationName);
61 QCoreApplication::setOrganizationDomain(Quassel::buildInfo().organizationDomain);
63 AbstractCliParser *cliParser;
66 // We need to init KCmdLineArgs first
67 // TODO: build an AboutData compat class to replace our aboutDlg strings
68 KAboutData aboutData("quassel", "kdelibs4", ki18n("Quassel IRC"), Quassel::buildInfo().plainVersionString.toUtf8(),
69 ki18n("A modern, distributed IRC client"));
70 aboutData.addLicense(KAboutData::License_GPL_V2);
71 aboutData.addLicense(KAboutData::License_GPL_V3);
72 aboutData.setOrganizationDomain(Quassel::buildInfo().organizationDomain.toUtf8());
73 KCmdLineArgs::init(argc, argv, &aboutData);
75 cliParser = new KCmdLineWrapper();
77 cliParser = new CliParser();
79 Quassel::setCliParser(cliParser);
81 // Initialize CLI arguments
82 // NOTE: We can't use tr() at this point, since app is not yet created
84 // put shared client&core arguments here
85 cliParser->addSwitch("debug",'d', "Enable debug output");
86 cliParser->addSwitch("help",'h', "Display this help and exit");
87 cliParser->addSwitch("version", 'v', "Display version information");
89 cliParser->addOption("configdir <path>", 'c', "Specify the directory holding the client configuration");
91 cliParser->addOption("configdir <path>", 'c', "Specify the directory holding configuration files, the SQlite database and the SSL certificate");
93 cliParser->addOption("datadir <path>", 0, "DEPRECATED - Use --configdir instead");
96 // put client-only arguments here
97 cliParser->addSwitch("debugbufferswitches", 0, "Enables debugging for bufferswitches");
98 cliParser->addSwitch("debugmodel", 0, "Enables debugging for models");
101 // put core-only arguments here
102 cliParser->addOption("listen <address>[,<address[,...]]>", 0, "The address(es) quasselcore will listen on", "0.0.0.0,::");
103 cliParser->addOption("port <port>",'p', "The port quasselcore will listen at", QString("4242"));
104 cliParser->addSwitch("norestore", 'n', "Don't restore last core's state");
105 cliParser->addOption("logfile <path>", 'l', "Path to logfile");
106 cliParser->addOption("loglevel <level>", 'L', "Loglevel Debug|Info|Warning|Error", "Info");
107 cliParser->addOption("select-backend <backendidentifier>", 0, "Starts an interactive session and switches your current storage backend to the new one. Attempts a merge if the new backend is uninitialized and the old backend supports migration. Otherwise prompts for new user credentials!");
108 cliParser->addSwitch("add-user", 0, "Starts an interactive session to add a new core user");
109 cliParser->addOption("change-userpass <username>", 0, "Starts an interactive session to change the password of the user identified by username");
113 // the KDE version needs this extra call to parse argc/argv before app is instantiated
114 if(!cliParser->init()) {
120 # if defined BUILD_CORE
121 CoreApplication app(argc, argv);
122 # elif defined BUILD_QTUI
123 QtUiApplication app(argc, argv);
124 # elif defined BUILD_MONO
125 MonolithicApplication app(argc, argv);
129 // the non-KDE version parses after app has been instantiated
130 if(!cliParser->init(app.arguments())) {
136 if(!app.init()) return EXIT_FAILURE;