Finished logical separation of core and GUI. Monolithic build should work as expected.
[quassel.git] / main / main_mono.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005 by The Quassel 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 <iostream>
22
23 #include <QApplication>
24
25 #include "core.h"
26 #include "quassel.h"
27 #include "guiproxy.h"
28 #include "coreproxy.h"
29
30 #include "mainwin.h"
31
32 int main(int argc, char **argv) {
33   QApplication app(argc, argv);
34   QApplication::setOrganizationDomain("quassel-irc.org");
35   QApplication::setApplicationName("Quassel IRC");
36   QApplication::setOrganizationName("The Quassel Team");
37
38   Quassel::runMode = Quassel::Monolithic;
39   quassel = new Quassel();
40   guiProxy = new GUIProxy();
41   coreProxy = new CoreProxy();
42   core = new Core();
43
44   core->init();
45
46   MainWin mainWin;
47   mainWin.show();
48   int exitCode = app.exec();
49   delete core;
50   delete guiProxy;
51   delete coreProxy;
52   delete quassel;
53   return exitCode;
54 }
55
56 void GUIProxy::send(GUISignal sig, QVariant arg1, QVariant arg2, QVariant arg3) {
57   coreProxy->recv(sig, arg1, arg2, arg3);
58 }
59
60 void CoreProxy::recv(GUISignal sig, QVariant arg1, QVariant arg2, QVariant arg3) {
61   switch(sig) {
62     case GS_USER_INPUT: emit gsUserInput(arg1.toString()); break;
63     case GS_REQUEST_CONNECT: emit gsRequestConnect(arg1.toString(), arg2.toUInt()); break;
64     default: qWarning() << "Unknown signal in CoreProxy::recv: " << sig;
65   }
66 }
67
68 void CoreProxy::send(CoreSignal sig, QVariant arg1, QVariant arg2, QVariant arg3) {
69   guiProxy->recv(sig, arg1, arg2, arg3);
70 }
71
72 void GUIProxy::recv(CoreSignal sig, QVariant arg1, QVariant arg2, QVariant arg3) {
73   switch(sig) {
74     case CS_CORE_MESSAGE: emit csCoreMessage(arg1.toString()); break;
75     default: qWarning() << "Unknown signal in GUIProxy::recv: " << sig;
76   }
77 }