diff options
author | Jonathan Bauer | 2011-04-18 02:13:18 +0200 |
---|---|---|
committer | Jonathan Bauer | 2011-04-18 02:13:18 +0200 |
commit | e512c756586d5509ac11759bae40f7911fe0f948 (patch) | |
tree | 65873adce9fa6401026b1b4c89f12a1e8868e3c2 /src/main.cpp | |
parent | cursor hidden by QWSServer, added loading animation for preload page, started... (diff) | |
download | fbgui-e512c756586d5509ac11759bae40f7911fe0f948.tar.gz fbgui-e512c756586d5509ac11759bae40f7911fe0f948.tar.xz fbgui-e512c756586d5509ac11759bae40f7911fe0f948.zip |
uniformed formatting...
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 123 |
1 files changed, 63 insertions, 60 deletions
diff --git a/src/main.cpp b/src/main.cpp index 7d73754..0e7957c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,24 +7,30 @@ #include "loggerengine.h" #include "fbgui.h" -void printHelp() -{ +void printHelp() { QTextStream qout(stdout); qout << QObject::tr("Usage: ./fbgui [OPTIONS]") << endl; qout << QObject::tr("Options:") << endl; - qout << "-c <path>, --config=<path> " << QObject::tr("Path to configuration file.") << endl; - qout << "-u <URL>, --url=<URL> " << QObject::tr("Sets the URL to be loaded.") << endl; - qout << "-d <path>, --download=<path> " << QObject::tr("Specify the download directory.") << endl; - qout << "-t <path, --trigger=<path> " << QObject::tr("Specify location of the file triggering the URL load.") << endl; - qout << "-s <path, --serial=<path> " << QObject::tr("Specify location of the file containing the serial number.") << endl; - qout << "-D <level>, --debug=<level> " << QObject::tr("Activate debug mode. [0,1]") << endl; - qout << "-h, --help " << QObject::tr("Prints this help.") << endl; + qout << "-c <path>, --config=<path> " << QObject::tr( + "Path to configuration file.") << endl; + qout << "-u <URL>, --url=<URL> " << QObject::tr( + "Sets the URL to be loaded.") << endl; + qout << "-d <path>, --download=<path> " << QObject::tr( + "Specify the download directory.") << endl; + qout << "-t <path, --trigger=<path> " << QObject::tr( + "Specify location of the file triggering the URL load.") << endl; + qout << "-s <path, --serial=<path> " << QObject::tr( + "Specify location of the file containing the serial number.") + << endl; + qout << "-D <level>, --debug=<level> " << QObject::tr( + "Activate debug mode. [0,1]") << endl; + qout << "-h, --help " << QObject::tr( + "Prints this help.") << endl; qout.flush(); - exit(EXIT_SUCCESS); + exit( EXIT_SUCCESS); } -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { // Initialisation of the QApplication: // In QT, every application is composed of two separate // components: the GUI-Client and the GUI-Server. @@ -45,42 +51,36 @@ int main(int argc, char *argv[]) QMap<QString, QString> clOpts; int longIndex = 0; static const char *optString = "c:u:d:s:t:D:h"; - static const struct option longOpts[] = - { - {"config", required_argument, NULL, 'c'}, - {"url", required_argument, NULL, 'u'}, - {"download", required_argument, NULL, 'd'}, - {"serial", required_argument, NULL, 's'}, - {"trigger", required_argument, NULL, 't'}, - {"debug", required_argument, NULL, 'D'}, - {"help", no_argument, NULL, 'h'} - }; + static const struct option longOpts[] = { { "config", required_argument, + NULL, 'c' }, { "url", required_argument, NULL, 'u' }, { "download", + required_argument, NULL, 'd' }, { "serial", required_argument, + NULL, 's' }, { "trigger", required_argument, NULL, 't' }, { + "debug", required_argument, NULL, 'D' }, { "help", no_argument, + NULL, 'h' } }; int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); - while (opt != -1) - { - switch(opt) - { - case 'c': - clOpts.insert("configFile", optarg); - break; - case 'u': - clOpts.insert("url", optarg); - break; - case 'd': - clOpts.insert("downloadDir", optarg); - break; - case 's': - clOpts.insert("serialLocation", optarg); - break; - case 't': - clOpts.insert("trigger", optarg); - break; - case 'D': - clOpts.insert("debug", optarg); - break; - case 'h': - clOpts.insert("help", "help"); - break; + while (opt != -1) { + switch (opt) { + case 'c': + clOpts.insert("configFile", optarg); + break; + case 'u': + clOpts.insert("url", optarg); + break; + case 'd': + clOpts.insert("downloadDir", optarg); + break; + case 's': + clOpts.insert("serialLocation", optarg); + break; + case 't': + clOpts.insert("trigger", optarg); + break; + case 'D': + clOpts.insert("debug", optarg); + break; + case 'h': + clOpts.insert("help", "help"); + break; } opt = getopt_long(argc, argv, optString, longOpts, &longIndex); } @@ -88,7 +88,7 @@ int main(int argc, char *argv[]) if (clOpts.contains("help")) printHelp(); - if (clOpts.contains("debug")){ + if (clOpts.contains("debug")) { debugMode = clOpts.value("debug").toInt(); // start basic debug log qxtLog->disableLoggerEngine("DEFAULT"); @@ -97,8 +97,7 @@ int main(int argc, char *argv[]) qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); qxtLog->enableLogLevels(QxtLogger::DebugLevel); qxtLog->debug() << "Initializing fbgui..."; - } - else + } else debugMode = -1; // look for config file either in: @@ -111,7 +110,7 @@ int main(int argc, char *argv[]) if (clOpts.contains("configFile")) configFilePath = clOpts.value("configFile"); else { - confInfo = QFileInfo(QDir::home(), ".fbgui.conf"); + confInfo = QFileInfo(QDir::home(), ".fbgui.conf"); if (confInfo.exists()) configFilePath = confInfo.absoluteFilePath(); else { @@ -131,28 +130,31 @@ int main(int argc, char *argv[]) if (clOpts.contains("url")) baseURL = QUrl(clOpts.value("url")); else if (confFileSettings.contains("default/pbs_url")) - baseURL = confFileSettings.value("default/pbs_url").toUrl(); - else - baseURL = DEFAULT_URL; + baseURL = confFileSettings.value("default/pbs_url").toUrl(); + else + baseURL = DEFAULT_URL; // set directory for downloads if (clOpts.contains("downloadDir")) downloadPath = clOpts.value("downloadDir"); else if (confFileSettings.contains("default/download_directory")) - downloadPath = confFileSettings.value("default/download_directory").toString(); + downloadPath + = confFileSettings.value("default/download_directory").toString(); else downloadPath = DEFAULT_DOWNLOAD_DIR; if (confFileSettings.contains("default/update_interval")) - updateInterval = confFileSettings.value("default/update_interval").toInt(); - else - updateInterval = DEFAULT_UPDATE_INTERVAL; + updateInterval + = confFileSettings.value("default/update_interval").toInt(); + else + updateInterval = DEFAULT_UPDATE_INTERVAL; // set which file to watch to trigger loading of URL if (clOpts.contains("trigger")) fileToTriggerURL = clOpts.value("trigger"); else if (confFileSettings.contains("default/file_trigger")) - fileToTriggerURL = confFileSettings.value("default/file_trigger").toString(); + fileToTriggerURL + = confFileSettings.value("default/file_trigger").toString(); else fileToTriggerURL = DEFAULT_FILE_TRIGGER; @@ -160,7 +162,8 @@ int main(int argc, char *argv[]) if (clOpts.contains("serialLocation")) serialLocation = clOpts.value("serialLocation"); else if (confFileSettings.contains("default/serial_location")) - serialLocation = confFileSettings.value("default/serial_location").toString(); + serialLocation + = confFileSettings.value("default/serial_location").toString(); else serialLocation = QString("/serial"); // tests |