Initial working baulkTerm-daemon
[baulk.git] / src / Widgets / BaulkTerm / wrapper / main.cpp
blobc0b8d4f209dbfe9888fae502eccbee9bc5c6ea69
1 // BaulkTerm - Standalone Binary
2 //
3 // Baulk - Copyright (C) 2008 Jacob Alexander
4 //
5 // Baulk 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 // any later version, including version 3 of the License.
9 //
10 // Baulk 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, see <http://www.gnu.org/licenses/>.
18 #include <QApplication>
19 #include <QTest>
21 #include <client.h>
22 #include <server.h>
24 #include "baulkterm.h"
26 /// Baulk Declaration for use in handler.h
27 BaulkTerm *baulk;
29 #include <handler.h>
30 #include <compositing.h>
32 /**
33 * @author Jacob Alexander (HaaTa)
35 * First point of entry, which passes to baulk.h.
36 * Captures all debug output for this instance of Baulk.
38 int main( int argc, char *argv[] ) {
39 // Message Handler
40 qInstallMsgHandler( handler );
42 // Compositing Information
43 Display* display = 0;
44 Visual* visual = 0;
45 Colormap colormap = 0;
46 getDisplayInformation( display, visual, colormap );
48 // Daemon
49 InformationClient *client;
51 // Qt GUI Application start with compositing information
52 QApplication *app = new QApplication( display, argc, argv, (Qt::HANDLE)visual, (Qt::HANDLE)colormap );
53 baulk = new BaulkTerm( 0 );
54 if ( baulk->processCommandArgs() ) {
55 if ( baulk->useDaemon() ) {
56 QString serverListenName = "BaulkTermServ"; // TODO Put in config
58 // Daemon Quit Event Connection
59 InformationServer *serv = new InformationServer( serverListenName );
60 //QObject::connect( serv, SIGNAL( destroyed() ), app, SLOT( quit() ));
61 QObject::connect( serv, SIGNAL( startNewHostInstance() ), baulk, SLOT( newTerminal() ) );
63 // Connect to Daemon
64 QTest::qSleep( 200 );
65 client = new InformationClient( serverListenName );
66 client->requestId();
68 // Start Terminal through generic pathway (via the connection above)
69 client->requestStartNewHostInstance();
72 if ( !baulk->useDaemon() ) {
73 baulk->startShellProgram();
74 baulk->setStyleSheet("QWidget {"
75 "background: black;"
76 "}");
77 baulk->show();
80 else {
81 delete baulk;
82 delete app;
83 return 0;
86 // Event-Loop
87 int reTurn = app->exec();
89 // Post-Quit Events
90 delete client;
91 delete baulk;
92 delete app;
94 return reTurn;