2011-02-19 03:53:06 +00:00
|
|
|
#include "Server.h"
|
2013-01-08 03:38:43 +00:00
|
|
|
#include <QApplication>
|
2011-02-19 03:53:06 +00:00
|
|
|
#include <iostream>
|
2011-08-22 07:32:08 +00:00
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2011-02-19 03:53:06 +00:00
|
|
|
|
2013-11-07 23:07:09 +00:00
|
|
|
void ignoreDebugOutput(QtMsgType type, const char *msg);
|
|
|
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
|
|
void ignoreDebugOutputQt5(QtMsgType type, const QMessageLogContext &context, const QString &message);
|
|
|
|
#endif
|
|
|
|
|
2011-02-19 03:53:06 +00:00
|
|
|
int main(int argc, char **argv) {
|
2011-08-22 07:32:08 +00:00
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
if (setpgid(0, 0) < 0) {
|
|
|
|
std::cerr << "Unable to set new process group." << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-19 03:53:06 +00:00
|
|
|
QApplication app(argc, argv);
|
2011-02-26 20:53:03 +00:00
|
|
|
app.setApplicationName("capybara-webkit");
|
2011-02-19 03:53:06 +00:00
|
|
|
app.setOrganizationName("thoughtbot, inc");
|
|
|
|
app.setOrganizationDomain("thoughtbot.com");
|
|
|
|
|
2013-11-07 23:07:09 +00:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
|
|
qInstallMessageHandler(ignoreDebugOutputQt5);
|
|
|
|
#else
|
|
|
|
qInstallMsgHandler(ignoreDebugOutput);
|
|
|
|
#endif
|
|
|
|
|
2012-05-04 17:56:21 +00:00
|
|
|
Server server(0);
|
2011-02-19 03:53:06 +00:00
|
|
|
|
|
|
|
if (server.start()) {
|
2011-06-30 01:29:36 +00:00
|
|
|
std::cout << "Capybara-webkit server started, listening on port: " << server.server_port() << std::endl;
|
2011-02-19 03:53:06 +00:00
|
|
|
return app.exec();
|
|
|
|
} else {
|
2011-05-30 04:36:03 +00:00
|
|
|
std::cerr << "Couldn't start capybara-webkit server" << std::endl;
|
2011-02-19 03:53:06 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-07 23:07:09 +00:00
|
|
|
void ignoreDebugOutput(QtMsgType type, const char *msg) {
|
|
|
|
switch (type) {
|
|
|
|
case QtDebugMsg:
|
|
|
|
case QtWarningMsg:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "%s\n", msg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
|
|
void ignoreDebugOutputQt5(QtMsgType type, const QMessageLogContext &context, const QString &message) {
|
|
|
|
Q_UNUSED(context);
|
|
|
|
ignoreDebugOutput(type, message.toLocal8Bit().data());
|
|
|
|
}
|
|
|
|
#endif
|