From 19316e9142c5ab4a4e1603715fbbf555aac97826 Mon Sep 17 00:00:00 2001 From: Alexander Hoppe Date: Tue, 3 Aug 2010 18:23:24 +0200 Subject: Anpassungen fuer Win32-build. Aufspaltung der ClientGUIUtils in 2 Versionen Anpassungen des HomeDir Alle Aenderungen sollten unschaedlich fuer den Linux-build-Prozess sein. --- src/util/consoleLogger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 src/util/consoleLogger.cpp (limited to 'src/util/consoleLogger.cpp') diff --git a/src/util/consoleLogger.cpp b/src/util/consoleLogger.cpp old mode 100644 new mode 100755 index b523b40..ae29989 --- a/src/util/consoleLogger.cpp +++ b/src/util/consoleLogger.cpp @@ -226,7 +226,7 @@ void ConsoleLogger::_prepareLog() _logFileGood = false; _readLog(); - mkdir(getPolicyFilePath(QString()).toUtf8().data(), 0777); + createPolicyDir(); QString fullpath; fullpath.append(_logPath); //TODO: handle wether path/ or path were entered? -- cgit v1.2.3-55-g7522 From c1d871390c75e46bf2cbc71b38796b5c33e67c77 Mon Sep 17 00:00:00 2001 From: Johann Latocha Date: Mon, 30 Aug 2010 17:21:30 +0200 Subject: Defect #644 and cleanout some old code --- CMakeLists.txt | 2 - i18n/pvs_ar_JO.ts | 58 ++++++------- i18n/pvs_de_DE.ts | 58 ++++++------- i18n/pvs_es_MX.ts | 58 ++++++------- i18n/pvs_fr_FR.ts | 58 ++++++------- i18n/pvs_pl_PL.ts | 58 ++++++------- misc/pvs.conf | 3 + src/pvs.cpp | 11 +-- src/pvsDaemon.cpp | 107 ++++++----------------- src/pvsmgr.cpp | 2 - src/pvsmgrtouch.cpp | 3 - src/util/consoleLogger.cpp | 6 +- src/util/pvsSettingsManager.cpp | 185 ---------------------------------------- src/util/pvsSettingsManager.h | 50 ----------- 14 files changed, 177 insertions(+), 482 deletions(-) delete mode 100644 src/util/pvsSettingsManager.cpp delete mode 100644 src/util/pvsSettingsManager.h (limited to 'src/util/consoleLogger.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt index f829f33..a98022d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,6 @@ SET( PVSMGR_SRCS src/net/pvsClientConnection.cpp src/net/pvsServiceBroadcast.cpp src/util/consoleLogger.cpp - src/util/pvsSettingsManager.cpp src/util/util.cpp src/net/SslServer.cpp src/util/CertManager.cpp @@ -88,7 +87,6 @@ SET( PVS_SRCS src/util/util.cpp src/util/consoleLogger.cpp src/util/clientGUIUtils${sysdep_suffix}.cpp - src/util/pvsSettingsManager.cpp src/core/pvsChatClient.cpp src/net/pvsServiceDiscovery.cpp src/net/pvsDiscoveredServer.cpp diff --git a/i18n/pvs_ar_JO.ts b/i18n/pvs_ar_JO.ts index 4fe4627..2f5b77e 100644 --- a/i18n/pvs_ar_JO.ts +++ b/i18n/pvs_ar_JO.ts @@ -4,22 +4,22 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! @@ -27,127 +27,127 @@ QObject - + Version: - + Usage: - + <<option> <value>, ... > - + Options: - + -vncScriptFile <fullpath\filename> - + Specifies a custom location for the vnc-start/stop-script. - + If not specified, /usr/bin/pvs-vncsrv is expected. - + -freq <seconds> - + Specifies how long to wait until a reconnection attempt is made. - + Default is 5. - + -port <port> - + Specifies on which port to run. - + Default is - + -h or --help - + Shows this help text and exits. - + -v or --version - + Shows the current version and exits. - + -d or --daemon - + Start as daemon. - + -c <string command>:<string value> - + Sends the command and the optional value to a running PVS-Client. - + Command and value may not contain spaces or colons. - + The dividing colon is mandatory. - + Prints out available commands to use with -c. - + Use -h or --help to get a listing of all options. -v or --version gives you the current version. diff --git a/i18n/pvs_de_DE.ts b/i18n/pvs_de_DE.ts index 7bd9dff..20da674 100644 --- a/i18n/pvs_de_DE.ts +++ b/i18n/pvs_de_DE.ts @@ -4,22 +4,22 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! @@ -27,127 +27,127 @@ QObject - + Version: - + Usage: - + <<option> <value>, ... > - + Options: - + -vncScriptFile <fullpath\filename> - + Specifies a custom location for the vnc-start/stop-script. - + If not specified, /usr/bin/pvs-vncsrv is expected. - + -freq <seconds> - + Specifies how long to wait until a reconnection attempt is made. - + Default is 5. - + -port <port> - + Specifies on which port to run. - + Default is - + -h or --help - + Shows this help text and exits. - + -v or --version - + Shows the current version and exits. - + -d or --daemon - + Start as daemon. - + -c <string command>:<string value> - + Sends the command and the optional value to a running PVS-Client. - + Command and value may not contain spaces or colons. - + The dividing colon is mandatory. - + Prints out available commands to use with -c. - + Use -h or --help to get a listing of all options. -v or --version gives you the current version. diff --git a/i18n/pvs_es_MX.ts b/i18n/pvs_es_MX.ts index 4fe4627..2f5b77e 100644 --- a/i18n/pvs_es_MX.ts +++ b/i18n/pvs_es_MX.ts @@ -4,22 +4,22 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! @@ -27,127 +27,127 @@ QObject - + Version: - + Usage: - + <<option> <value>, ... > - + Options: - + -vncScriptFile <fullpath\filename> - + Specifies a custom location for the vnc-start/stop-script. - + If not specified, /usr/bin/pvs-vncsrv is expected. - + -freq <seconds> - + Specifies how long to wait until a reconnection attempt is made. - + Default is 5. - + -port <port> - + Specifies on which port to run. - + Default is - + -h or --help - + Shows this help text and exits. - + -v or --version - + Shows the current version and exits. - + -d or --daemon - + Start as daemon. - + -c <string command>:<string value> - + Sends the command and the optional value to a running PVS-Client. - + Command and value may not contain spaces or colons. - + The dividing colon is mandatory. - + Prints out available commands to use with -c. - + Use -h or --help to get a listing of all options. -v or --version gives you the current version. diff --git a/i18n/pvs_fr_FR.ts b/i18n/pvs_fr_FR.ts index 4fe4627..2f5b77e 100644 --- a/i18n/pvs_fr_FR.ts +++ b/i18n/pvs_fr_FR.ts @@ -4,22 +4,22 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! @@ -27,127 +27,127 @@ QObject - + Version: - + Usage: - + <<option> <value>, ... > - + Options: - + -vncScriptFile <fullpath\filename> - + Specifies a custom location for the vnc-start/stop-script. - + If not specified, /usr/bin/pvs-vncsrv is expected. - + -freq <seconds> - + Specifies how long to wait until a reconnection attempt is made. - + Default is 5. - + -port <port> - + Specifies on which port to run. - + Default is - + -h or --help - + Shows this help text and exits. - + -v or --version - + Shows the current version and exits. - + -d or --daemon - + Start as daemon. - + -c <string command>:<string value> - + Sends the command and the optional value to a running PVS-Client. - + Command and value may not contain spaces or colons. - + The dividing colon is mandatory. - + Prints out available commands to use with -c. - + Use -h or --help to get a listing of all options. -v or --version gives you the current version. diff --git a/i18n/pvs_pl_PL.ts b/i18n/pvs_pl_PL.ts index 4fe4627..2f5b77e 100644 --- a/i18n/pvs_pl_PL.ts +++ b/i18n/pvs_pl_PL.ts @@ -4,22 +4,22 @@ PVS - + Message - + VNC connection - + The host - + requested your screen! @@ -27,127 +27,127 @@ QObject - + Version: - + Usage: - + <<option> <value>, ... > - + Options: - + -vncScriptFile <fullpath\filename> - + Specifies a custom location for the vnc-start/stop-script. - + If not specified, /usr/bin/pvs-vncsrv is expected. - + -freq <seconds> - + Specifies how long to wait until a reconnection attempt is made. - + Default is 5. - + -port <port> - + Specifies on which port to run. - + Default is - + -h or --help - + Shows this help text and exits. - + -v or --version - + Shows the current version and exits. - + -d or --daemon - + Start as daemon. - + -c <string command>:<string value> - + Sends the command and the optional value to a running PVS-Client. - + Command and value may not contain spaces or colons. - + The dividing colon is mandatory. - + Prints out available commands to use with -c. - + Use -h or --help to get a listing of all options. -v or --version gives you the current version. diff --git a/misc/pvs.conf b/misc/pvs.conf index f91a63c..93c4ac5 100644 --- a/misc/pvs.conf +++ b/misc/pvs.conf @@ -1,3 +1,6 @@ +[VNC] +script=/usr/local/bin/pvs-vncsrv + [Permissions] vnc_lecturer=ro vnc_other=no diff --git a/src/pvs.cpp b/src/pvs.cpp index 61df049..07b9005 100755 --- a/src/pvs.cpp +++ b/src/pvs.cpp @@ -30,13 +30,6 @@ extern PVS *mainClient; PVS::PVS() : QObject() { - if (!QFile::exists(_settings.fileName())) - { - QDir::root().mkpath(QFileInfo(_settings.fileName()).path()); - QFile::copy("/etc/openslx/pvs.conf", _settings.fileName()); - } - - _pvsServerConnection = new PVSServerConnection(this); _locked = false; _vncAllowed = false; @@ -61,9 +54,9 @@ PVS::PVS() : new PvsAdaptor(this); QDBusConnection dbus = QDBusConnection::sessionBus(); if (!dbus.registerObject("/", this)) - qDebug("[ERROR] DBus: Could not register object"); + printf("[ERROR] DBus: Could not register object\n"); if (!dbus.registerService("org.openslx.pvs")) - qDebug("[ERROR] DBus: Could not register service"); + printf("[ERROR] DBus: Could not register service\n"); _sdClient = new PVSServiceDiscovery(this); diff --git a/src/pvsDaemon.cpp b/src/pvsDaemon.cpp index b23bc57..a0405d0 100755 --- a/src/pvsDaemon.cpp +++ b/src/pvsDaemon.cpp @@ -3,7 +3,6 @@ #include #include "pvs.h" #include "src/net/pvsLocalhostCommunicator.h" -#include "src/util/pvsSettingsManager.h" #include "setup.h" #include "src/net/pvsMsg.h" #include "src/core/pvsChatClient.h" @@ -67,19 +66,6 @@ int main(int argc, char** argv) int frequency = 5; int port = -1; - QFileInfo script; - #ifdef __WIN32__ - //TODO Win32 - if (!script.exists()) - script.setFile(getHomeDir() + "/.pvs/pvs-vncsrv_win32.bat"); - #else - script.setFile("/usr/bin/pvs-vncsrv"); - if (!script.exists()) - script.setFile("/usr/local/bin/pvs-vncsrv"); - if (!script.exists()) - script.setFile(getHomeDir() + "/.pvs/pvs-vncsrv"); - #endif //__WIN32__ - QCoreApplication app(argc, argv); app.setOrganizationName("openslx"); app.setOrganizationDomain("openslx.org"); @@ -89,6 +75,27 @@ int main(int argc, char** argv) translator.load(":pvs"); app.installTranslator(&translator); + QFileInfo script; +#ifdef __WIN32__ + //TODO Win32 + if (!script.exists()) + script.setFile(getHomeDir() + "/.pvs/pvs-vncsrv_win32.bat"); +#else + QSettings settings; + if (!QFile::exists(settings.fileName())) + { + QDir::root().mkpath(QFileInfo(settings.fileName()).path()); + QFile::copy("/etc/openslx/pvs.conf", settings.fileName()); + } + QString s = settings.value("VNC/script").toString(); + script.setFile(s); + if (!script.exists()) + script.setFile("/usr/bin/pvs-vncsrv"); + if (!script.exists()) + script.setFile("/usr/local/bin/pvs-vncsrv"); + if (!script.exists()) + script.setFile(getHomeDir() + "/.pvs/pvs-vncsrv"); +#endif //__WIN32__ PVSLocalhostCommunicator com(getPolicyFilePath(QString( ".comfile"))); @@ -149,73 +156,17 @@ int main(int argc, char** argv) } else { - QStringList line = QString::fromLocal8Bit(argv[option_index - + 1]).split(":"); - QString &ident = line[0]; - QString message; - if (line.size() > 1) - message = line[1]; - if (ident.size() > 0) // no use sending empty idents... not even sure if this COULD happen - { - bool flag = false; - if (ident == "make") - PVSSettingsManager::getManager()->setConfigs(); - else if (ident == "chat" && message == "boss") - { - PVSSettingsManager::getManager()->reWriteConfigs("chatmode", "bossmode"); - flag = true; - - } - else if (ident == "chat" && message == "all") - { - PVSSettingsManager::getManager()->reWriteConfigs("chatmode", "community"); - flag = true; - } - else if (ident == "chat" && message == "private") - { - PVSSettingsManager::getManager()->reWriteConfigs("chatmode", "private"); - flag = true; - } - else if (ident == "chat" && message == "on") - { - PVSSettingsManager::getManager()->reWriteConfigs("chatstate", "on"); - flag = true; - } - else if (ident == "chat" && message == "off") - { - PVSSettingsManager::getManager()->reWriteConfigs("chatstate", "off"); - flag = true; - } - else if (ident == "room") - { - //PVSSettingsManager::getManager()->reWriteConfigs(ident, message); - flag = true; - } - else if (ident == "stop" && message == NULL) - flag = true; - else - printf("option %s doesn't exist\n", ident.toUtf8().data()); - - if (flag) - { - qDebug("Will send i: %s, m: %s\n", ident.toUtf8().data(), message.toUtf8().data()); - com.sendCommand(ident, message); - QCoreApplication::processEvents(QEventLoop::AllEvents); - printf("Sent command. Exiting.\n"); - } - } - - else - printf("Something went horribly wrong, since the ident is empty.\n"); - - } + printf("Will send i: %s, m: %s\n", argv[option_index + 1], ""); + com.sendCommand(QString(argv[option_index + 1]), ""); + QCoreApplication::processEvents(QEventLoop::AllEvents); + printf("Sent command. Exiting.\n"); + } } else { printf("Error. No command issued. Exiting.\n"); } exit(0); // and gone - break; } case 'f': { @@ -336,7 +287,6 @@ int main(int argc, char** argv) } mainClient = new PVS(); - PVSSettingsManager::getManager()->setConfigFile(getPolicyFilePath("clientconf")); com.getDispatcher()->addListener("*", mainClient, &PVS::onDaemonCommand); if (port <= 0) @@ -347,11 +297,6 @@ int main(int argc, char** argv) createPolicyDir(); createPolicyFiles(); - // long int gr = 0; - mainClient->setScriptPath(script.filePath()); app.exec(); - delete mainClient; - - return 0; } diff --git a/src/pvsmgr.cpp b/src/pvsmgr.cpp index 83f5fe0..dd00c0e 100644 --- a/src/pvsmgr.cpp +++ b/src/pvsmgr.cpp @@ -18,7 +18,6 @@ #include #include "gui/mainWindow.h" #include "util/consoleLogger.h" -#include "util/pvsSettingsManager.h" #include "util/CertManager.h" QApplication *qtApp; @@ -47,7 +46,6 @@ int main(int argc, char** argv) exit(123); } */ - PVSSettingsManager::getManager()->setConfigFile(getPolicyFilePath("serverconf")); MainWindow w; w.show(); return qtApp->exec(); diff --git a/src/pvsmgrtouch.cpp b/src/pvsmgrtouch.cpp index fa34294..d14ea56 100644 --- a/src/pvsmgrtouch.cpp +++ b/src/pvsmgrtouch.cpp @@ -16,9 +16,7 @@ #include #include -#include "gui/touchgui.h" #include "util/consoleLogger.h" -#include "util/pvsSettingsManager.h" #include "util/CertManager.h" QApplication *qtApp; @@ -47,7 +45,6 @@ int main(int argc, char** argv) exit(123); } */ - PVSSettingsManager::getManager()->setConfigFile(getPolicyFilePath("serverconf")); pvsMainWindow w; w.show(); return qtApp->exec(); diff --git a/src/util/consoleLogger.cpp b/src/util/consoleLogger.cpp index ae29989..5d07dbe 100755 --- a/src/util/consoleLogger.cpp +++ b/src/util/consoleLogger.cpp @@ -233,14 +233,10 @@ void ConsoleLogger::_prepareLog() fullpath.append(_logName); _logFile.open(fullpath.toUtf8().data(), std::ofstream::out | std::ofstream::app); if (_logFile.good()) - { _logFileGood = true; - writeTerminal(QString("LogPath/Name changed to: ").append(fullpath)); - } else - { printf("ERROR: Logfile ( %s ) not accessible/found. Logs will not be available.\n", _logPath.toUtf8().data()); - } + _logFile.close(); } diff --git a/src/util/pvsSettingsManager.cpp b/src/util/pvsSettingsManager.cpp deleted file mode 100644 index a6a742b..0000000 --- a/src/util/pvsSettingsManager.cpp +++ /dev/null @@ -1,185 +0,0 @@ -#include "pvsSettingsManager.h" -#include "TextFile.h" - -PVSSettingsManager* PVSSettingsManager::getManager() -{ - if (myself) - return myself; - else - return myself = new PVSSettingsManager; -} - -void PVSSettingsManager::setConfigFile(QString path) -{ - if (path.size() && fileExists(path)) - { - _path = path; - _parseFile(_path); - - } - else - ConsoleLog writeError(QString("Can't open config file \"").append(QString(path).append("\""))); -} - -bool PVSSettingsManager::hasEntry(QString name) -{ - for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++) - { - if ((*it).first.compare(name) == 0) - { - return true; - } - } - return false; -} - -QString PVSSettingsManager::getEntryString(QString name) -{ - for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++) - { - if ((*it).first.compare(name) == 0) - { - return (*it).second; - } - } - return QString(); -} - -void PVSSettingsManager::writeEntry(QString name, QString value) -{ - if (name.size() && value.size()) - return; - bool unique = true; - for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++) - { - if ((*it).first.compare(name) == 0) - { - unique = false; - (*it).second = value; - break; - } - } - if (unique) - { - SettingsEntry tmp(name, value); - settingsList.push_back(tmp); - } -} - - -PVSSettingsManager* PVSSettingsManager::myself = NULL; - -PVSSettingsManager::PVSSettingsManager() -{ - -} - -void PVSSettingsManager::setConfigs() -{ - //default settings - _configs.setValue("Chat/chatstate", "on"); - _configs.setValue("Chat/chatmode", "bossmode"); - _configs.setValue("Room/roomId", "0"); - _configs.setValue("VNC/permit", "off"); - _configs.setValue("VNC/quality", "high"); - _configs.sync(); -} -void PVSSettingsManager::reWriteConfigs(QString set, QString val) -{ - _configs.setValue(set, val); - _configs.sync(); -} - -void PVSSettingsManager::readConfigs(QString sett, QString vall) -{ - //TODO: read the config file.. - _configs.value("Chat/chatstate").toBool(); - _configs.value("Chat/chatmode").toString(); - _configs.value("Room/room").toInt(); - _configs.value("VNC/permit").toBool(); - _configs.value("VNC/quality").toString(); -} - -void PVSSettingsManager::_parseFile(QString path) -{ - QString line; - TextFile file(path); - - SettingsList tmpList; - - if (file.good()) - { - while (!file.eof()) - { - line = file.readLine(); - if (!(line.length() <=1)) // ignore blank - { - if (!(line[0] == '#' || line[0] == '/' || line[0] == '[')) // ignore comments and section headers - { - SettingsEntry tmp = _parseLine(line); - if (tmp.first.size() && tmp.second.size()) - { - bool unique = true; - for (SettingsIter it = tmpList.begin(); it != tmpList.end(); it++) - { - if ((*it).first.compare(tmp.first) == 0) - { - unique = false; - break; - } - } - if (unique) - tmpList.push_back(tmp); - } - } - } - } - } - else - { - ConsoleLog writeError(QString("No configfile \"").append(QString(path).append("\" found or file corrupt."))); - } - - if (tmpList.size()) - settingsList = tmpList; -} -#ifdef verbose -ConsoleLog writeLine(QString("Dumping Config Content of ").append(QString(path).append(" : "))); -for (SettingsIter it = settingsList.begin(); it != settingsList.end(); it++) -{ - ConsoleLog writeLine(QString("Option: ").append(QString((*it).first).append(QString(" | Value: ").append((*it).second)))); -} -ConsoleLog writeLine(QString("End of ").append(QString(path).append("."))); -#endif - -SettingsEntry PVSSettingsManager::_parseLine(QString line) -{ - QString name; - QString value; - - name = lineSplitter(line, "=\n\t", true); - value = lineSplitter(line, "=\n\t", false); - - if (!(name.size() && value.size())) - return SettingsEntry("",""); - - - // remove whitespaces in front of option name - for (int i = 0; i < name.size(); i++) - { - if (name[i] == '\t' || name[i] == ' ') - { - name.remove(i, 1); - i--; - } - else - break; - } - // whitespaces after the value are trimmed by the lineSplitter - - SettingsEntry tmp(name, value); - return tmp; -} - - - diff --git a/src/util/pvsSettingsManager.h b/src/util/pvsSettingsManager.h deleted file mode 100644 index 78607eb..0000000 --- a/src/util/pvsSettingsManager.h +++ /dev/null @@ -1,50 +0,0 @@ -/// documentation test 1 -/// line 2 -/// line 3 -#ifndef _PVSSETTINGSMANGER_H_ -#define _PVSSETTINGSMANGER_H_ - -#include -#include -#include -#include -#include - - -/// documentation test 1.1 -/// line 2.1 -/// line 3.1 - -typedef std::pair SettingsEntry; ///< first = option name, second = option value -typedef std::list SettingsList; ///< obvious -typedef std::list::iterator SettingsIter; - - -class PVSSettingsManager; -/// documentation test 1.2 -/// line 2.2 -/// line 3.2 -class PVSSettingsManager -{ -public: - static PVSSettingsManager* getManager(); - void setConfigFile(QString path); - bool hasEntry(QString name); - QString getEntryString(QString name); - void writeEntry(QString name, QString value); - void setConfigs(); - void reWriteConfigs(QString set, QString val); - void readConfigs(QString sett, QString vall); -private: - static PVSSettingsManager* myself; - PVSSettingsManager(); - void _parseFile(QString path); - SettingsEntry _parseLine(QString line); - QString _path; - SettingsList settingsList; - QSettings _configs; - -}; - - -#endif -- cgit v1.2.3-55-g7522 From f6fca1c3c5279c820be3860b0074831f920219d6 Mon Sep 17 00:00:00 2001 From: Johann Latocha Date: Wed, 1 Sep 2010 01:02:39 +0200 Subject: All printf() replaced with qDebug() --- CMakeLists.txt | 6 +----- src/gui/mainWindow.cpp | 2 +- src/net/SslServer.cpp | 4 ++-- src/net/pvsClientConnection.cpp | 2 +- src/net/pvsDiscoveredServer.cpp | 22 +++++++++++----------- src/net/pvsListenServer.cpp | 7 +++---- src/net/pvsListenServer.h | 2 +- src/net/pvsLocalhostCommunicator.cpp | 6 +++--- src/net/pvsServerConnection.cpp | 2 +- src/net/pvsServiceDiscovery.cpp | 2 +- src/pvs.cpp | 4 ++-- src/pvsDaemon.cpp | 29 ++++++++++++++--------------- src/util/consoleLogger.cpp | 2 +- src/util/consoleLogger.h | 2 +- src/util/util.cpp | 6 +++--- 15 files changed, 46 insertions(+), 52 deletions(-) (limited to 'src/util/consoleLogger.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt index a98022d..fa4da6a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,15 +11,11 @@ CMAKE_MINIMUM_REQUIRED( VERSION 2.6.2 ) # set compiler optimizations for debug and release SET(CMAKE_BUILD_TYPE Debug) SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall") -SET(CMAKE_CXX_FLAGS_RELEASE "-O2" ) -#-march=native -DQT_NO_DEBUG_OUTPUT +SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -DQT_NO_DEBUG_OUTPUT" ) # local cmake modules SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}) -#Test -SET(CMAKE_EDIT_COMMAND ${CMAKE_SOURCE_DIR}) - # this command finds libraries and sets all required variables FIND_PACKAGE( Qt4 4.5.0 REQUIRED ) FIND_PACKAGE( X11 REQUIRED ) diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index bea636f..10c64d6 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -813,7 +813,7 @@ void MainWindow::foto() // makes a screenshot of the selected client img.save(path, format.toAscii()); } else - printf("Cannot save screen: Image is null.\n"); + qDebug("Cannot save screen: Image is null."); } } else diff --git a/src/net/SslServer.cpp b/src/net/SslServer.cpp index e353e0a..9940a61 100644 --- a/src/net/SslServer.cpp +++ b/src/net/SslServer.cpp @@ -59,7 +59,7 @@ void SslServer::incomingConnection(int socketDescriptor) void SslServer :: sslErrors ( const QList & errors ) { - printf("FIXME: SSL ERRORS on SERVER: %s\n", errors.begin()->errorString().toUtf8().data()); + qDebug("FIXME: SSL ERRORS on SERVER: %s", qPrintable(errors.begin()->errorString())); } void SslServer::timerEvent (QTimerEvent* event) @@ -98,7 +98,7 @@ bool SslServer::hasPendingConnections() { for (QList::iterator it = _pending.begin(); it != _pending.end(); it++) { - printf("State: %d - Encrypted: %d\n", (int)(*it)->state(), (*it)->isEncrypted()); + qDebug("State: %d - Encrypted: %d", (int)(*it)->state(), (*it)->isEncrypted()); if ((*it)->state() == QAbstractSocket::ConnectedState && (*it)->isEncrypted()) return true; } return false; diff --git a/src/net/pvsClientConnection.cpp b/src/net/pvsClientConnection.cpp index dff40d5..5354e95 100644 --- a/src/net/pvsClientConnection.cpp +++ b/src/net/pvsClientConnection.cpp @@ -134,7 +134,7 @@ bool PVSClientConnection::push_back_send(PVSMsg newMsg) char *tmp = data; if (!newMsg.getBinaryData(tmp, len)) { - printf("Message empty. Ignored.\n"); + qDebug("Message empty. Ignored."); return false; } QByteArray ba; diff --git a/src/net/pvsDiscoveredServer.cpp b/src/net/pvsDiscoveredServer.cpp index dddb5a0..efa1506 100644 --- a/src/net/pvsDiscoveredServer.cpp +++ b/src/net/pvsDiscoveredServer.cpp @@ -48,7 +48,7 @@ void PVSDiscoveredServer::ssl_Error( const QList & errors ) } //ConsoleLog writeNetwork(err.errorString().toUtf8().data()); //ConsoleLog writeNetwork("***** SSL ERROR, ABORTING *****"); - printf("Unhandled SSL Error in SD: %s\n", err.errorString().toUtf8().data()); + qDebug("Unhandled SSL Error in SD: %s", qPrintable(err.errorString())); return; } _socket->ignoreSslErrors(); @@ -70,30 +70,30 @@ void PVSDiscoveredServer::sock_connected() QByteArray cert = _socket->peerCertificate().digest(QCryptographicHash::Sha1); if (_socket->peerCertificate().isNull()) { - printf("**** WARNING - PEER CERTIFICATE IS NULL ****\n"); + qDebug("**** WARNING - PEER CERTIFICATE IS NULL ****"); } else { - printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::Organization).toUtf8().data()); - printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::CommonName).toUtf8().data()); - printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::LocalityName).toUtf8().data()); - printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::OrganizationalUnitName ).toUtf8().data()); - printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::CountryName ).toUtf8().data()); - printf("%s\n", _socket->peerCertificate().subjectInfo(QSslCertificate::StateOrProvinceName ).toUtf8().data()); + qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::Organization))); + qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::CommonName))); + qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::LocalityName))); + qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::OrganizationalUnitName))); + qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::CountryName))); + qDebug("%s", qPrintable(_socket->peerCertificate().subjectInfo(QSslCertificate::StateOrProvinceName))); } if (cert == _fingerprint && !_validated) { _validated = true; emit validated(this); - printf("Validated certificate of %s :)\n", _socket->peerAddress().toString().toUtf8().data()); + qDebug("Validated certificate of %s :)", qPrintable(_socket->peerAddress().toString())); } else { - printf("Certificate of %s is invalid :(\n", _socket->peerAddress().toString().toUtf8().data()); + qDebug("Certificate of %s is invalid :(", qPrintable(_socket->peerAddress().toString())); QByteArray is, should; is = cert.toBase64(); should = _fingerprint.toBase64(); - printf("Is %s and should be %s\n", is.data(), should.data()); + qDebug("Is %s and should be %s", is.data(), should.data()); } _socket->disconnectFromHost(); } diff --git a/src/net/pvsListenServer.cpp b/src/net/pvsListenServer.cpp index f21303e..58d4aee 100644 --- a/src/net/pvsListenServer.cpp +++ b/src/net/pvsListenServer.cpp @@ -137,7 +137,7 @@ void PVSListenServer::timerEvent(QTimerEvent *event) } if (client->lastData() < refval) { // ping timeout - printf("Ping timeout for client %s\n", client->getNameUser().toLocal8Bit().data()); + qDebug("Ping timeout for client %s", qPrintable(client->getNameUser())); if (disconnectClient(client)) break; // list was modified, iterator not valid anymore } @@ -283,9 +283,8 @@ void PVSListenServer::server_connectionRequest() void PVSListenServer::handleClientMsg(unsigned int clientID, PVSMsg msg) { - printf("Got Message for client %ud: [%c][%s][%s]\n", clientID, - (char) msg.getType(), msg.getIdent().toUtf8().data(), - msg.getMessage().toUtf8().data()); + qDebug("Got Message for client %ud: [%c][%s][%s]", clientID, + (char) msg.getType(), qPrintable(msg.getIdent()), qPrintable(msg.getMessage())); msg.setSndID(clientID); if (msg.getType() == PVSCOMMAND) _commandDispatcher.fire(msg.getIdent(), msg); diff --git a/src/net/pvsListenServer.h b/src/net/pvsListenServer.h index ab021c7..b43b730 100644 --- a/src/net/pvsListenServer.h +++ b/src/net/pvsListenServer.h @@ -73,7 +73,7 @@ public: template void addLoginHandler(QString ident, T* who, void (T :: *func)(PVSMsg)) { - printf("Listener got added to LoginHandler\n"); + qDebug("Listener got added to LoginHandler"); _loginDispatcher.addListener(ident, who, func); }; template void removeLoginHandler(QString ident, T* who, void (T :: *func)(PVSMsg)) diff --git a/src/net/pvsLocalhostCommunicator.cpp b/src/net/pvsLocalhostCommunicator.cpp index 199b39c..20783bb 100644 --- a/src/net/pvsLocalhostCommunicator.cpp +++ b/src/net/pvsLocalhostCommunicator.cpp @@ -83,7 +83,7 @@ void PVSLocalhostCommunicator::sendCommand(QString ident, QString cmd) int len; sender.getBinaryData(data, len); QByteArray qba(data, len); - printf("Sending %d bytes to daemon...\n", qba.length()); + qDebug("Sending %d bytes to daemon...", qba.length()); qint64 result = _sock->writeDatagram(qba, localhost, localport); _sock->waitForBytesWritten(100); @@ -92,11 +92,11 @@ void PVSLocalhostCommunicator::sendCommand(QString ident, QString cmd) { if (result == -1) { - printf("Error sending PVSMsg to daemon: %s\n", _sock->errorString().toUtf8().data()); + qDebug("Error sending PVSMsg to daemon: %s", qPrintable(_sock->errorString())); } else { - printf("Sent PVSMsg was incomplete.\n"); + qDebug("Sent PVSMsg was incomplete."); } stop(); } diff --git a/src/net/pvsServerConnection.cpp b/src/net/pvsServerConnection.cpp index 04a1ef6..d187ce3 100644 --- a/src/net/pvsServerConnection.cpp +++ b/src/net/pvsServerConnection.cpp @@ -70,7 +70,7 @@ void PVSServerConnection::sslErrors ( const QList & errors ) for (QList::const_iterator it = errors.begin(); it != errors.end(); it++) { QSslError err = *it; - printf("Connect SSL: %s\n", err.errorString().toUtf8().data()); + qDebug("Connect SSL: %s", qPrintable(err.errorString())); if (err.error() == QSslError::HostNameMismatch) continue; // We don't pay attention to hostnames for validation if (err.error() == QSslError::SelfSignedCertificate) continue; // Also, this will always be the case; we check the fingerprint later ConsoleLog writeNetwork(err.errorString().toUtf8().data()); diff --git a/src/net/pvsServiceDiscovery.cpp b/src/net/pvsServiceDiscovery.cpp index 0a99802..dd6b500 100644 --- a/src/net/pvsServiceDiscovery.cpp +++ b/src/net/pvsServiceDiscovery.cpp @@ -30,7 +30,7 @@ PVSServiceDiscovery::PVSServiceDiscovery(PVS* client) bool ret = _sock.bind(SD_PORT_CLIENT); if (!ret) { - printf("Could not open SERVICE DISCOVERY port\n"); + qDebug("Could not open SERVICE DISCOVERY port"); exit(1); } connect(&_sock, SIGNAL(readyRead()), this, SLOT(sock_dataArrival())); diff --git a/src/pvs.cpp b/src/pvs.cpp index 07b9005..2aaec8a 100755 --- a/src/pvs.cpp +++ b/src/pvs.cpp @@ -54,9 +54,9 @@ PVS::PVS() : new PvsAdaptor(this); QDBusConnection dbus = QDBusConnection::sessionBus(); if (!dbus.registerObject("/", this)) - printf("[ERROR] DBus: Could not register object\n"); + qDebug("[ERROR] DBus: Could not register object"); if (!dbus.registerService("org.openslx.pvs")) - printf("[ERROR] DBus: Could not register service\n"); + qDebug("[ERROR] DBus: Could not register service"); _sdClient = new PVSServiceDiscovery(this); diff --git a/src/pvsDaemon.cpp b/src/pvsDaemon.cpp index 4d3e146..cc11bd4 100755 --- a/src/pvsDaemon.cpp +++ b/src/pvsDaemon.cpp @@ -13,8 +13,8 @@ QTextStream qout(stdout); /// VERSION_STRING is defined in src/version.h void printVersion(bool doExit) { - QTextStream qout(stdout); - printf("Version:\t"VERSION_STRING"\n"); + qout << "Version:\t"VERSION_STRING"\n"; + qout.flush(); if (doExit) exit(0); } @@ -36,7 +36,7 @@ void printHelp() qout << QObject::tr("-v or --version") << "\n\t" << QObject::tr("Shows the current version and exits.") << "\n"; qout << QObject::tr("-d or --daemon") << "\n\t" << QObject::tr("Start as daemon.") << "\n"; qout << QObject::tr("-c :") << "\n\t" << QObject::tr("Sends the command and the optional value to a running PVS-Client.") << "\n\t" << QObject::tr("Command and value may not contain spaces or colons.") << "\n\t" << QObject::tr("The dividing colon is mandatory.") << "\n"; - qout << "-commands: \n\t" << QObject::tr("Prints out available commands to use with -c.") << "\n"; + qout << "--commands: \n\t" << QObject::tr("Prints out available commands to use with -c.") << "\n"; qout << "**************************************************************\n"; qout.flush(); exit(0); @@ -51,11 +51,10 @@ void printNotice() void printCommands() { - printf("**************************************************************\n"); - printf("chat:\n "); - printf("on = turns that chat option on\n off = turns the chat option off\n 1 = bossmode\n 2 = community\n 3 = private\n"); - printf("stop \n\t Stops the running PVS-Client.\n"); - printf("**************************************************************\n"); + qout << "**************************************************************\n"; + qout << "stop \n\t Stops the running PVS-Client.\n"; + qout << "**************************************************************\n"; + qout.flush(); exit(0); } @@ -102,7 +101,7 @@ int main(int argc, char** argv) com.run(); if (!(com.running())) { - printf("Error. UDS Communicator is not running. Exiting.\n"); + qDebug("Error. UDS Communicator is not running. Exiting."); exit(0); } @@ -151,20 +150,20 @@ int main(int argc, char** argv) if (com.server()) { // wont work, no daemon running - printf("Error. No running PVS-Client found. Exiting.\n"); + qDebug("Error. No running PVS-Client found. Exiting."); com.stop(); } else { - printf("Will send i: %s, m: %s\n", argv[option_index + 1], ""); + qDebug("Will send i: %s, m: %s\n", argv[option_index + 1], ""); com.sendCommand(QString(argv[option_index + 1]), ""); QCoreApplication::processEvents(QEventLoop::AllEvents); - printf("Sent command. Exiting.\n"); + qDebug("Sent command. Exiting."); } } else { - printf("Error. No command issued. Exiting.\n"); + qDebug("Error. No command issued. Exiting."); } exit(0); // and gone } @@ -211,7 +210,7 @@ int main(int argc, char** argv) { if (option_index + 1 < argc) { - printf("WARNING: -e is deprecated\n"); + qDebug("WARNING: -e is deprecated"); option_index++; continue; } @@ -243,7 +242,7 @@ int main(int argc, char** argv) if (!com.server()) { - printf("Error. PoolVSClient already running. Exiting\n"); + qDebug("Error. PoolVSClient already running. Exiting"); com.stop(); exit(0); } diff --git a/src/util/consoleLogger.cpp b/src/util/consoleLogger.cpp index 5d07dbe..9189543 100755 --- a/src/util/consoleLogger.cpp +++ b/src/util/consoleLogger.cpp @@ -235,7 +235,7 @@ void ConsoleLogger::_prepareLog() if (_logFile.good()) _logFileGood = true; else - printf("ERROR: Logfile ( %s ) not accessible/found. Logs will not be available.\n", _logPath.toUtf8().data()); + qDebug("ERROR: Logfile ( %s ) not accessible/found. Logs will not be available.", qPrintable(_logPath)); _logFile.close(); } diff --git a/src/util/consoleLogger.h b/src/util/consoleLogger.h index 3a0950d..e4cb291 100644 --- a/src/util/consoleLogger.h +++ b/src/util/consoleLogger.h @@ -116,7 +116,7 @@ public: _line.push_back('\n'); // add an explicit newline char, so it looks better in the logfile //#ifndef as_daemon if (_level == LOG_TERMINAL) // may look strange here, but its quite central :-) - printf("%s\n", _line.toUtf8().data()); + qDebug("%s", qPrintable(_line)); //#endif }; LOG_LEVEL getLevel() diff --git a/src/util/util.cpp b/src/util/util.cpp index 8b25b12..05a209f 100755 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -213,7 +213,7 @@ QString getUserName() #endif //#ifdef __WIN32__ if (username.isEmpty()) { - printf("USERNAME COULDNT BE RETRIEVED!\n"); + qDebug("USERNAME COULDNT BE RETRIEVED!"); username = QString("USERNAMEERROR"); } return username; @@ -323,7 +323,7 @@ QString readPassFromPassFile() } bool getAllowed() { - printf("Checking %s\n", getPolicyFilePath(QString(".allow")).toUtf8().data()); + qDebug("Checking %s", qPrintable(getPolicyFilePath(QString(".allow")))); TextFile file(getPolicyFilePath(".allow")); if (file.good()) // should have been checked via exists before, but better be safe { @@ -338,7 +338,7 @@ bool getAllowed() (allowed.compare(QString("TRUE")) == 0) ) return true; } - printf("...negative\n"); + qDebug("...negative"); return false; } -- cgit v1.2.3-55-g7522