summaryrefslogtreecommitdiffstats
path: root/src/pvsmgr.cpp
blob: b9e53f36be4b8fdd460a18d2d96a33891cafcca0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 # 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();
}