source: src-qt4/pc-servicemanager/main.cpp @ 62a794c

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since 62a794c was 62a794c, checked in by Ken Moore <ken@…>, 9 months ago

Fix compilation of pc-servicemanager on 10.x

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#include <qapplication.h>
2#include <qtranslator.h>
3#include <qtextcodec.h>
4#include <qstylefactory.h>
5#include <qdesktopwidget.h>
6#include <QDebug>
7#include <unistd.h>
8#include <sys/types.h>
9#include "servicemanager.h"
10#include "../config.h"
11
12int main( int argc, char ** argv )
13{
14   QApplication a(argc, argv);
15
16    QTranslator translator;
17    QLocale mylocale;
18    QString langCode = mylocale.name();
19    if ( ! QFile::exists( PREFIX + "/share/pcbsd/i18n/ServiceManager_" + langCode + ".qm" ) )
20      langCode.truncate(langCode.indexOf("_"));
21    translator.load( QString("ServiceManager_") + langCode, PREFIX + "/share/pcbsd/i18n/" );
22    a.installTranslator( &translator );
23    qDebug() << "Locale:" << langCode;
24
25    QString chroot, ip;
26    if ( argc >= 2)
27    {
28       QString chkarg = argv[1];
29       // Running in a warden jail?
30       if ( chkarg == "-warden" )
31         if ( argc == 4 ) {
32           chroot = argv[2];
33           ip = argv[3];
34         }else{
35           qDebug() << "Usage: -warden <directory> <ip>";
36           exit(1);
37         }
38    }
39
40    // Make sure we are running as root
41    if (getuid() != 0) {
42       qDebug("Error, needs to be run as root");
43       exit(1);
44    }
45
46    //Init GUI
47    ServiceManager w;
48
49    w.ProgramInit(chroot, ip);
50
51    w.show();
52    a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
53    return a.exec();
54}
Note: See TracBrowser for help on using the repository browser.