1 /***************************************************************************
2 * Copyright (C) 2005-07 by The Quassel IRC Development Team *
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) any later version. *
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 #if defined BUILD_CORE
25 #include <QCoreApplication>
30 #elif defined BUILD_QTGUI
31 #include <QApplication>
33 //#include "clientproxy.h"
37 #elif defined BUILD_MONO
38 #include <QApplication>
40 //#include "clientproxy.h"
42 #include "coresession.h"
47 #error "Something is wrong - you need to #define a build mode!"
52 //! Signal handler for graceful shutdown.
53 void handle_signal(int sig) {
54 qWarning(QString("Caught signal %1 - exiting.").arg(sig).toAscii());
55 QCoreApplication::quit();
58 int main(int argc, char **argv) {
59 // We catch SIGTERM and SIGINT (caused by Ctrl+C) to graceful shutdown Quassel.
60 signal(SIGTERM, handle_signal);
61 signal(SIGINT, handle_signal);
63 qRegisterMetaType<QVariant>("QVariant");
64 qRegisterMetaType<Message>("Message");
65 qRegisterMetaType<BufferId>("BufferId");
66 qRegisterMetaTypeStreamOperators<QVariant>("QVariant");
67 qRegisterMetaTypeStreamOperators<Message>("Message");
68 qRegisterMetaTypeStreamOperators<BufferId>("BufferId");
70 #if defined BUILD_CORE
71 Global::runMode = Global::CoreOnly;
72 QCoreApplication app(argc, argv);
73 #elif defined BUILD_QTGUI
74 Global::runMode = Global::ClientOnly;
75 QApplication app(argc, argv);
77 Global::runMode = Global::Monolithic;
78 QApplication app(argc, argv);
80 QCoreApplication::setOrganizationDomain("quassel-irc.org");
81 QCoreApplication::setApplicationName("Quassel IRC");
82 QCoreApplication::setOrganizationName("Quassel IRC Development Team");
84 Global::quasselDir = QDir::homePath() + "/.quassel";
86 Core::instance(); // create and init the core
93 QtGui *gui = new QtGui();
98 int exitCode = app.exec();
101 // the mainWin has to be deleted before the Core
102 // if not Quassel will crash on exit under certain conditions since the gui
103 // still wants to access clientdata
115 QVariant Client::connectToLocalCore(QString, QString) { return QVariant(); }
116 void Client::disconnectFromLocalCore() {}
118 #elif defined BUILD_MONO
119 QVariant Client::connectToLocalCore(QString user, QString passwd) {
120 // TODO catch exceptions
122 QVariant reply = Core::connectLocalClient(user, passwd);
123 QObject::connect(Core::localSession(), SIGNAL(proxySignal(CoreSignal, QVariant, QVariant, QVariant)), ClientProxy::instance(), SLOT(recv(CoreSignal, QVariant, QVariant, QVariant)));
124 QObject::connect(ClientProxy::instance(), SIGNAL(send(ClientSignal, QVariant, QVariant, QVariant)), Core::localSession(), SLOT(processSignal(ClientSignal, QVariant, QVariant, QVariant)));
130 void Client::disconnectFromLocalCore() {
132 disconnect(Core::localSession(), 0, ClientProxy::instance(), 0);
133 disconnect(ClientProxy::instance(), 0, Core::localSession(), 0);
134 Core::disconnectLocalClient();