From 2c81a5dadc01fa5aaf22dc0af30c7163e4c81728 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 24 Mar 2011 12:12:26 +0100 Subject: cleanups.... --- src/downloadmanager.h | 8 ++++++-- src/fbgui.cpp | 37 ++++++++++++++++++------------------- src/fbgui.h | 18 +++++++++++------- src/javascriptinterface.h | 9 +++++---- src/loggerengine.cpp | 4 ++-- src/loggerengine.h | 9 ++++++--- 6 files changed, 48 insertions(+), 37 deletions(-) diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 0cc1a35..1b7d8af 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -11,7 +11,10 @@ # General information about OpenSLX can be found under http://openslx.org # # -# Helper class managing downloads. +# Class managing download requests: +# - provides queueing functionality +# - static info: filename, filesize +# - dynamic info: download progress, current speed # */ @@ -55,7 +58,7 @@ private: static int downloaded; signals: - // notify sends a message to the javascript interface. + // notify sends a message to the javascript interface to be evaluated there void notify(const QString& msg); // downloadInfo sends static information (name, size) to the interface. void downloadInfo(const QString& filename, const double& filesize); @@ -67,6 +70,7 @@ signals: public slots: // public slots to receive download requests. void downloadFile(const QUrl& fileUrl); + // convenience function void downloadFile(const QString& fileUrl); private slots: diff --git a/src/fbgui.cpp b/src/fbgui.cpp index 7c590c5..66e5670 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -23,9 +23,9 @@ fbgui::fbgui() { // test for libsys function - //SysInfoLibsysfs* sil = new SysInfoLibsysfs(); - //sil->getInfoAboutNetworkInterface(); - //sil->getInfoAboutClassNet(); + SysInfoLibsysfs* sil = new SysInfoLibsysfs(); + sil->getInfoAboutNetworkInterface(); + sil->getInfoAboutClassNet(); // start basic console debug log qxtLog->disableLoggerEngine("DEFAULT"); @@ -74,7 +74,6 @@ fbgui::fbgui() setAttribute(Qt::WA_QuitOnClose, true); setWindowFlags(Qt::FramelessWindowHint); showFullScreen(); - } //------------------------------------------------------------------------------------------- void fbgui::createActions() @@ -127,25 +126,12 @@ void fbgui::checkForTrigger(const QString& dirname) QFileInfo tfi(fileToTriggerURL); QFileInfo fi(dirname + "/" + tfi.fileName()); if (fi.exists()){ - qxtLog->debug() << fileToTriggerURL << " detected."; + qxtLog->debug() << "[watcher] " << fileToTriggerURL << " detected."; loadURL(); } else // do nothing / keep watching - qxtLog->debug() << "weird file!"; -} -//------------------------------------------------------------------------------------------- -bool fbgui::checkHost() const -{ - QHostInfo hostInfo = QHostInfo::fromName(baseURL.host()); - if (hostInfo.error() != QHostInfo::NoError){ - qxtLog->debug() << "Lookup of " << baseURL.host() << "failed. Exiting..."; - return false; - } - else{ - qxtLog->debug() << "Lookup of " << baseURL.host() << " succeeded."; - return true; - } + qxtLog->debug() << "[watcher] weird file!"; } //------------------------------------------------------------------------------------------- void fbgui::loadURL(){ @@ -185,6 +171,19 @@ void fbgui::loadURL(){ } } //------------------------------------------------------------------------------------------- +bool fbgui::checkHost() const +{ + QHostInfo hostInfo = QHostInfo::fromName(baseURL.host()); + if (hostInfo.error() != QHostInfo::NoError){ + qxtLog->debug() << "Lookup of " << baseURL.host() << "failed. Exiting..."; + return false; + } + else{ + qxtLog->debug() << "Lookup of " << baseURL.host() << " succeeded."; + return true; + } +} +//------------------------------------------------------------------------------------------- void fbgui::setupDebugSplit() { _debugConsole = new QTextEdit(this); diff --git a/src/fbgui.h b/src/fbgui.h index a870dba..6350ee2 100644 --- a/src/fbgui.h +++ b/src/fbgui.h @@ -11,7 +11,8 @@ # General information about OpenSLX can be found under http://openslx.org # # -# Main class of the fbgui. +# Main class of the fbgui: +# - Manages display of components and their communications # */ @@ -32,7 +33,7 @@ #define DEFAULT_FILE_TRIGGER "/tmp/fbgui/trigger" -// Global settings +// Global settings variables extern QString serialLocation; extern QString fileToTriggerURL; extern QString sessionID; @@ -53,11 +54,12 @@ private: // setup procedures void setupDebugSplit(); void createActions(); - bool checkHost() const; + + // functions to trigger the loading of baseURL void watchForTrigger(); + bool checkHost() const; void loadURL(); - // widgets constituing the gui QWebView* _webView; QSplitter* _splitter; @@ -67,14 +69,16 @@ private: QAction* _quit; QAction* _toggleDebug; - // + // watcher to detect changes in the observed directory QFileSystemWatcher* _watcher; private slots: - void checkForTrigger(const QString& dirname); - // slots for processing actions + // action slots void toggleDebug(); + // checks if the change reported by _watcher is the one we are looking for + // e.g. fileToTriggerURL has been created, ignores other events. + void checkForTrigger(const QString& dirname); }; #endif // FBGUI_H diff --git a/src/javascriptinterface.h b/src/javascriptinterface.h index 9a6477f..6606441 100644 --- a/src/javascriptinterface.h +++ b/src/javascriptinterface.h @@ -23,16 +23,16 @@ class JavascriptInterface : public QObject { Q_OBJECT +public: + JavascriptInterface(QWebFrame* parent); + ~JavascriptInterface(); + private: QWebFrame* _parent; QString _callbackOnDownloadsFinished; void loadJQuery(); -public: - JavascriptInterface(QWebFrame* parent); - ~JavascriptInterface(); - signals: void requestFile(const QString& filename); void quitFbgui(); @@ -49,6 +49,7 @@ public slots: const QString getSysInfo(const QString& info); void quit(); + // testing watcher of fbgui. void trigger(); }; diff --git a/src/loggerengine.cpp b/src/loggerengine.cpp index 6be143a..8f051c8 100644 --- a/src/loggerengine.cpp +++ b/src/loggerengine.cpp @@ -1,7 +1,7 @@ #include "loggerengine.h" // -------------------------------------------------------------------------------------------------- -// Custom Logger Engine for debugging on framebuffer +// base of a custom logger engine for the framebuffer //--------------------------------------------------------------------------------------------------- LoggerEngine_fb::LoggerEngine_fb(QTextEdit *parent) : QxtLoggerEngine(){ // TODO: silly parent storing ... to change! @@ -49,7 +49,7 @@ void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, const QList #include //--------------------------------------------------------------------------------------------------- -// custom engine feeding the debug console widget +// base of a custom logger engine for the framebuffer //--------------------------------------------------------------------------------------------------- class LoggerEngine_fb : public QxtLoggerEngine { public: LoggerEngine_fb(QTextEdit* parent); ~LoggerEngine_fb(); + + // parent widget, target of messages QTextEdit *_debugConsole; bool _initialized; @@ -39,12 +41,13 @@ public: }; //--------------------------------------------------------------------------------------------------- -// minor changes to QxtBasicSTDLoggerEngine +// slighty modified QxtBasicSTDLoggerEngine //--------------------------------------------------------------------------------------------------- class LoggerEngine_std : public QxtBasicSTDLoggerEngine { public: LoggerEngine_std(); ~LoggerEngine_std(); + // reimplemented virtual functions of QxtBasicSTDLoggerEngineqqq void writeToStdOut(const QString& level, const QList &msgs); void writeToStdErr(const QString& str_level, const QList &msgs); -- cgit v1.2.3-55-g7522