src/hbservers/hbthemeserver/main.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
    26 #include "hbthemeserverapplication_p.h"
    26 #include "hbthemeserverapplication_p.h"
    27 #include <QTextStream>
    27 #include <QTextStream>
    28 #include <cstdlib>
    28 #include <cstdlib>
    29 #include <QDebug>
    29 #include <QDebug>
    30 
    30 
    31 void showHelp(const QString &argv0, const QString &error = QString())
       
    32 {
       
    33     QTextStream qerr(stderr);
       
    34     qerr << "Hb Theme Server" << endl;
       
    35     if (!error.isEmpty()) {
       
    36         qerr << argv0 << ": " << error << endl;
       
    37     }
       
    38     qerr << "Usage: " << argv0 << " [options]" << endl;
       
    39     qerr << endl;
       
    40     qerr << "Options:" << endl;
       
    41     qerr << "  -start               start a new server" << endl;
       
    42     qerr << "  -restart             same as -stop -start" << endl;
       
    43     qerr << "  -stop                stop an existing server instance" << endl;
       
    44     qerr << "  -persistent          keep server running when the last client disconnects" << endl;
       
    45     qerr << "  -h, -help            display this information" << endl;
       
    46 }
       
    47 
       
    48 int main(int argc, char *argv[])
    31 int main(int argc, char *argv[])
    49 {
    32 {
    50     // Hiding theme server from the start up in first phase
    33     // Hiding theme server from the start up in first phase
    51 #if QT_VERSION >= 0x040601
    34 #if QT_VERSION >= 0x040601
    52     QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes);
    35     QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes);
    60         return 0;
    43         return 0;
    61     }
    44     }
    62     
    45     
    63     HbThemeServerApplication app(argc, argv);
    46     HbThemeServerApplication app(argc, argv);
    64 
    47 
    65     if (HbThemeServerApplication::Options::help) {
    48     if (app.isRunning()) {
    66         showHelp(argv[0], HbThemeServerApplication::Options::error);
       
    67         return EXIT_SUCCESS;
       
    68     }
       
    69 
       
    70     if (HbThemeServerApplication::Options::stop) {
       
    71         app.stop();
       
    72     }
       
    73 
       
    74     if (app.isRunning() || !HbThemeServerApplication::Options::start) {
       
    75         return EXIT_SUCCESS;
    49         return EXIT_SUCCESS;
    76     }
    50     }
    77 
    51 
    78     if (app.initialize()) {
    52     if (app.initialize()) {
    79         return app.exec();
    53         return app.exec();