/*
# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# pvs.cpp
# - main loop for pvsmgr GUI.
# -----------------------------------------------------------------------------
*/
#include <QtGui>
#include <QtGui/QDesktopServices>
#include <getopt.h>
#include "gui/mainWindow.h"
#include "util/consoleLogger.h"
#include "util/CertManager.h"
#include "src/input/i18n.h"
#include "version.h"
QApplication *qtApp;
void printHelp()
{
QTextStream qout(stdout);
qout << QObject::tr("Usage: pvsmgr/pvsmgrtouch [OPTIONS]...") << endl;
qout << QObject::tr("Start the Pool Video Switch Manager.") << endl;
qout << QObject::tr("Options:") << endl << endl;
qout << "-f or --fullscreen" << "\t" << QObject::tr("Start in fullscreen mode.") << endl;
qout << "-h or --help" << "\t\t" << QObject::tr("Show this help text and quit.") << endl;
qout << "-v or --version" << "\t\t" << QObject::tr("Show version and quit.") << endl;
qout << endl;
qout.flush();
exit(0);
}
void printVersion()
{
QTextStream qout(stdout);
qout << QObject::tr("Version: ") << VERSION_STRING << endl;
qout << endl;
qout.flush();
exit(0);
}
int main(int argc, char** argv)
{
bool fullscreen = false;
// parse command line arguments
int opt = 0;
int longIndex = 0;
static const char *optString = "hvf?";
static const struct option longOpts[] =
{
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'v' },
{ "fullscreen", no_argument, NULL, 'f' }
};
opt = getopt_long( argc, argv, optString, longOpts, &longIndex );
while( opt != -1 )
{
switch( opt )
{
case 'h':
printHelp();
break;
case 'v':
printVersion();
break;
case 'f':
fullscreen = true;
break;
case '?':
exit(1);
}
opt = getopt_long( argc, argv, optString, longOpts, &longIndex );
}
//system("openssl genrsa 1024 >~/.pvs/");
qtApp = new QApplication(argc, argv);
qtApp->setOrganizationName("openslx");
qtApp->setOrganizationDomain("openslx.org");
qtApp->setApplicationName("pvsmgr");
// use system locale as language to translate gui
QTranslator translator;
translator.load(":pvsmgr");
qtApp->installTranslator(&translator);
USE_PVSINPUT_TRANSLATIONS;
ConsoleLog setLogName(QString("log.server"));
ConsoleLog writeLine(QString("PVS-Server started."));
QSslKey k = CertManager::getPrivateKey("manager"); // preload key so the gui won't hang later
MainWindow *w;
if (fullscreen)
w = new MainWindow(0, Qt::FramelessWindowHint);
else
w = new MainWindow();
w->show();
return qtApp->exec();
}