1 /*
2 * This file is part of signon-ui
3 *
4 * Copyright (C) 2013 Canonical Ltd.
5 *
6 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "browser-process.h"
22
23 #include "debug.h"
24
25 #include <QGuiApplication>
26 #include <fcntl.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <unistd.h>
30
31 using namespace SignOnUi;
32
stderrMessage(QtMsgType type,const QMessageLogContext & context,const QString & msg)33 void stderrMessage(QtMsgType type, const QMessageLogContext &context,
34 const QString &msg)
35 {
36 Q_UNUSED(context);
37 QByteArray localMsg = msg.toLocal8Bit();
38 switch (type) {
39 case QtDebugMsg:
40 fprintf(stderr, "Debug: %s\n", localMsg.constData());
41 break;
42 case QtWarningMsg:
43 fprintf(stderr, "Warning: %s\n", localMsg.constData());
44 break;
45 case QtCriticalMsg:
46 fprintf(stderr, "Critical: %s\n", localMsg.constData());
47 break;
48 case QtFatalMsg:
49 fprintf(stderr, "Fatal: %s\n", localMsg.constData());
50 abort();
51 }
52 }
53
main(int argc,char ** argv)54 int main(int argc, char **argv)
55 {
56 qInstallMessageHandler(stderrMessage);
57 TRACE() << "started";
58 QGuiApplication app(argc, argv);
59 app.setQuitOnLastWindowClosed(false);
60 fcntl(fileno(stdin), F_SETFL, fcntl(fileno(stdin), F_GETFL, 0) | O_NONBLOCK);
61 BrowserProcess browserProcess;
62
63 QObject::connect(&browserProcess, SIGNAL(finished()),
64 &app, SLOT(quit()));
65 browserProcess.processClientRequest();
66 return app.exec();
67 }
68
69