Fixed linker error caused by not running MOC on ircuser.h.
[quassel.git] / src / common / main.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-07 by The Quassel IRC Development 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) any later version.                                   *
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 #include "settings.h"
22
23 #if defined BUILD_CORE
24 #include <QCoreApplication>
25 #include "core.h"
26
27 #elif defined BUILD_QTGUI
28 #include <QApplication>
29 #include "client.h"
30 #include "clientproxy.h"
31 #include "qtgui.h"
32 #include "style.h"
33
34 #elif defined BUILD_MONO
35 #include <QApplication>
36 #include "client.h"
37 #include "clientproxy.h"
38 #include "core.h"
39 #include "coresession.h"
40 #include "qtgui.h"
41 #include "style.h"
42
43 #else
44 #error "Something is wrong - you need to #define a build mode!"
45 #endif
46
47 int main(int argc, char **argv) {
48 #if defined BUILD_CORE
49   Global::runMode = Global::CoreOnly;
50   QCoreApplication app(argc, argv);
51 #elif defined BUILD_QTGUI
52   Global::runMode = Global::ClientOnly;
53   QApplication app(argc, argv);
54 #else
55   Global::runMode = Global::Monolithic;
56   QApplication app(argc, argv);
57 #endif
58   QCoreApplication::setOrganizationDomain("quassel-irc.org");
59   QCoreApplication::setApplicationName("Quassel IRC");
60   QCoreApplication::setOrganizationName("Quassel IRC Development Team");
61
62   Global::quasselDir = QDir::homePath() + "/.quassel";
63 #ifndef BUILD_QTGUI
64   Core::instance();  // create and init the core
65 #endif
66
67   Settings::init();
68
69 #ifndef BUILD_CORE
70   Style::init();
71   QtGui *gui = new QtGui();
72   Client::init(gui);
73   gui->init();
74 #endif
75
76   int exitCode = app.exec();
77
78 #ifndef BUILD_CORE
79   // the mainWin has to be deleted before the Core
80   // if not Quassel will crash on exit under certain conditions since the gui
81   // still wants to access clientdata
82   delete gui;
83   Client::destroy();
84 #endif
85 #ifndef BUILD_QTGUI
86   Core::destroy();
87 #endif
88
89   return exitCode;
90 }
91
92 #ifdef BUILD_QTGUI
93 QVariant Client::connectToLocalCore(QString, QString) { return QVariant(); }
94 void Client::disconnectFromLocalCore() {}
95
96 #elif defined BUILD_MONO
97 QVariant Client::connectToLocalCore(QString user, QString passwd) {
98   // TODO catch exceptions
99   QVariant reply = Core::connectLocalClient(user, passwd);
100   QObject::connect(Core::localSession(), SIGNAL(proxySignal(CoreSignal, QVariant, QVariant, QVariant)), ClientProxy::instance(), SLOT(recv(CoreSignal, QVariant, QVariant, QVariant)));
101   QObject::connect(ClientProxy::instance(), SIGNAL(send(ClientSignal, QVariant, QVariant, QVariant)), Core::localSession(), SLOT(processSignal(ClientSignal, QVariant, QVariant, QVariant)));
102   return reply;
103 }
104
105 void Client::disconnectFromLocalCore() {
106   disconnect(Core::localSession(), 0, ClientProxy::instance(), 0);
107   disconnect(ClientProxy::instance(), 0, Core::localSession(), 0);
108   Core::disconnectLocalClient();
109 }
110
111 #endif