From 1fe9c90f77990e740c205a5113340583146536e8 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 1 Feb 2012 15:31:48 +0100 Subject: adapted existing classes to reflect changes --- src/fbgui/ndgui.cpp | 153 ++++++---------------------------------------------- 1 file changed, 17 insertions(+), 136 deletions(-) (limited to 'src/fbgui/ndgui.cpp') diff --git a/src/fbgui/ndgui.cpp b/src/fbgui/ndgui.cpp index 4e0b3f6..34a3f2d 100644 --- a/src/fbgui/ndgui.cpp +++ b/src/fbgui/ndgui.cpp @@ -30,8 +30,8 @@ QString gPathToDhcpExe(""); /** * constructor */ -ndgui::ndgui(QMainWindow *parent) : - QMainWindow(parent) { +ndgui::ndgui() : + agui() { } @@ -41,11 +41,11 @@ ndgui::ndgui(QMainWindow *parent) : */ ndgui::~ndgui() { - delete _debugConsole; - delete _toggleDebugConsole; + //delete _debugConsole; + //delete _toggleDebugConsole; delete _allowUserChoice; delete _tryAgain; - delete _webView; + //delete _webView; delete _networkDiscovery; } @@ -57,13 +57,14 @@ ndgui::~ndgui() { */ void ndgui::init() { + LOG4CXX_DEBUG(ndLogger, "Initializing ndgui..."); + _started = false; _userChoice = false; _ifNameList.clear(); _manConfList.clear(); - setupLayout(); - createAction(); + addActions(); _networkDiscovery = new NetworkDiscovery(); connect(_networkDiscovery, SIGNAL(addInterface(const QString &)), this, @@ -90,101 +91,24 @@ void ndgui::init() { javaScriptWindowObjectCleared()), this, SLOT(attachToDOM())); connect(_webView, SIGNAL(loadFinished(bool)), this, SLOT(startSingleShot())); - setWindowTitle(tr("NetD")); - setAttribute(Qt::WA_QuitOnClose, true); - setWindowFlags(Qt::FramelessWindowHint); - showFullScreen(); if (debugMode > -1) { _webView->load(QUrl("qrc:html/networkdiscovery_debug.html")); } else { _webView->load(QUrl("qrc:html/networkdiscovery.html")); - } - _webView->show(); -} - - - -/** - * @brief This method sets the used Layout. - * - * This method sets the used Layout. Possible layout are: - * - browser mode: only the browser is visible - * - debug mode: the screen is divided into the browser and a debug - * out console - */ -void ndgui::setupLayout() { - // setup layout of the gui: debug split or browser - _webView = new QWebView(this); - _webView->setContextMenuPolicy(Qt::NoContextMenu); // if this does not work try Qt::CustomContextMenu - - if (debugMode == 1) { - // split main window in browser & debug console - createDebugConsole(); - _splitter = new QSplitter(Qt::Vertical, this); - _splitter->addWidget(_webView); - _splitter->addWidget(_debugConsole); - setCentralWidget(_splitter); - } else { - _webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); - setCentralWidget(_webView); - } -} - - - -/** - * @brief This method creates a debug console as a widget. - * - * It is basicly a QTextEdit widget as provided by QT's Framework. - * An action to toggle this widget is implemented (CTRL + D). - * - * @see fbgui::toggleDebugConsole() - */ -void ndgui::createDebugConsole() { - // create the debug console widget - _debugConsole = new QTextEdit(this); - _debugConsole->setWindowFlags(Qt::FramelessWindowHint); - // fanciness - QPalette pal; - pal.setColor(QPalette::Base, Qt::black); - _debugConsole->setPalette(pal); - _debugConsole->setTextColor(Qt::white); - // enable custom logger engine -// qxtLog->addLoggerEngine("fb_logger", new LoggerEngine_fb(_debugConsole)); - //qxtLog->initLoggerEngine("fb_logger"); -// qxtLog->setMinimumLevel("fb_logger", QxtLogger::DebugLevel); - // CTRL + D toggles debug window - _toggleDebugConsole = new QAction(tr("&toggleDebug"), this); - _toggleDebugConsole->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); - addAction(_toggleDebugConsole); - connect(_toggleDebugConsole, SIGNAL(triggered()), this, SLOT( - toggleDebugConsole())); -} - - - -/** - * @brief This method toggles the debug console. - * - * Toggle the visibility of the debug console if the action _toggleDebugConsole is triggered. - * - * @see fbgui::createDebugConsole() - */ -void ndgui::toggleDebugConsole() { - (_debugConsole->isVisible()) ? _debugConsole->hide() : _debugConsole->show(); + setWindowTitle(tr("NetD")); + showFullScreen(); } - /** - * @brief Create actions + * @brief Add actions * - * creates an action which you can trigger with the F5 and F9 Button. + * Add actions which you can trigger with the F5 and F9 Button. */ -void ndgui::createAction() { +void ndgui::addActions() { _allowUserChoice = new QAction(tr("&userChoice"), this); _allowUserChoice->setShortcut(QKeySequence(Qt::Key_F5)); connect(_allowUserChoice, SIGNAL(triggered()), this, SLOT(setUserChoiceTrue())); @@ -195,8 +119,6 @@ void ndgui::createAction() { this->addAction(_tryAgain); } - - /** * @brief set userChoice true * @@ -300,43 +222,6 @@ void ndgui::handleAllProcessesFinished() { } - -/** - * @brief restart the system - * - * this method will restart the system. - * triggered through a button click in the gui. - */ -void ndgui::restartSystem() { - QFile file("/proc/sysrq-trigger"); - if (file.open(QIODevice::WriteOnly)) { - file.write("b"); - file.close(); - } else { - LOG4CXX_DEBUG(ndLogger, "Could not open /proc/sysrq-trigger"); - } -} - - - -/** - * @brief shut down the system - * - * this method will restart the system. - * triggered through a button click in the gui. - */ -void ndgui::shutDownSystem() { - QFile file("/proc/sysrq-trigger"); - if (file.open(QIODevice::WriteOnly)) { - file.write("o"); - file.close(); - } else { - LOG4CXX_DEBUG(ndLogger, "Could not open /proc/sysrq-trigger"); - } -} - - - /** * @brief continue the boot sequence * @@ -358,7 +243,6 @@ void ndgui::continueBoot(QString ifName) { } - /** * @brief continue the boot sequence without further checking if the connection is still possible. */ @@ -369,7 +253,6 @@ void ndgui::continueBootWithoutCheck(QString ifName) { } - /** * @brief read the log file. Log File will be presented inside of a dialog. */ @@ -379,7 +262,6 @@ QString ndgui::readLogFile() { } - /** * @brief starts the whole application again. */ @@ -387,13 +269,13 @@ void ndgui::tryAgain() { LOG4CXX_DEBUG(ndLogger, " try again "); _networkDiscovery->prepareTryAgain(); if(debugMode > -1) { - delete _splitter; - delete _debugConsole; - delete _toggleDebugConsole; + //delete _splitter; + //delete _debugConsole; + //delete _toggleDebugConsole; } delete _allowUserChoice; delete _tryAgain; - delete _webView; + //delete _webView; delete _networkDiscovery; init(); @@ -401,7 +283,6 @@ void ndgui::tryAgain() { } - /*test html gui version*/ /** -- cgit v1.2.3-55-g7522 From 3084244f6af4492582c05d27819b6aa61e36c688 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 1 Feb 2012 15:46:36 +0100 Subject: sysInfo gets interface name for MAC adress from networkdiscovery --- src/fbgui/fbgui.cpp | 2 +- src/fbgui/fbgui.h | 1 + src/fbgui/main.cpp | 2 -- src/fbgui/ndgui.cpp | 4 +++- src/fbgui/sysinfo.cpp | 17 +++++------------ 5 files changed, 10 insertions(+), 16 deletions(-) (limited to 'src/fbgui/ndgui.cpp') diff --git a/src/fbgui/fbgui.cpp b/src/fbgui/fbgui.cpp index ee74452..7bf84e8 100644 --- a/src/fbgui/fbgui.cpp +++ b/src/fbgui/fbgui.cpp @@ -57,7 +57,7 @@ void fbgui::init() { _webView->page()->mainFrame()); QObject::connect(jsi, SIGNAL(quitFbgui()), this, SLOT(close())); QObject::connect(jsi, SIGNAL(shutDownClient()), this, - SLOT(performShutDown())); + SLOT(shutdownSystem())); QObject::connect(_webView->page()->mainFrame(), SIGNAL( javaScriptWindowObjectCleared()), jsi, SLOT(attachToDOM())); diff --git a/src/fbgui/fbgui.h b/src/fbgui/fbgui.h index 2feafa1..46c3b9b 100644 --- a/src/fbgui/fbgui.h +++ b/src/fbgui/fbgui.h @@ -46,6 +46,7 @@ extern QString downloadPath; extern QUrl baseURL; extern int debugMode; extern int updateInterval; +extern QString interfaceName; class fbgui : public agui { diff --git a/src/fbgui/main.cpp b/src/fbgui/main.cpp index e14e683..6286b9f 100644 --- a/src/fbgui/main.cpp +++ b/src/fbgui/main.cpp @@ -10,10 +10,8 @@ #include #include "qlog4cxx.h" -#include "agui.h" #include "fbgui.h" #include "ndgui.h" -#include "console.h" #include "../common/fbgui.h" diff --git a/src/fbgui/ndgui.cpp b/src/fbgui/ndgui.cpp index 34a3f2d..67bfa79 100644 --- a/src/fbgui/ndgui.cpp +++ b/src/fbgui/ndgui.cpp @@ -24,7 +24,7 @@ QString gServerIp(""); bool gAutoUp = true; QString gSocketServerPath(""); QString gPathToDhcpExe(""); - +QString interfaceName(""); /** @@ -233,6 +233,7 @@ void ndgui::handleAllProcessesFinished() { void ndgui::continueBoot(QString ifName) { if (_networkDiscovery->checkConnectivity(ifName)) { LOG4CXX_DEBUG(ndLogger, " continue with interface: " << ifName); + interfaceName = ifName; emit initFbgui(); this->close(); } else { @@ -248,6 +249,7 @@ void ndgui::continueBoot(QString ifName) { */ void ndgui::continueBootWithoutCheck(QString ifName) { LOG4CXX_DEBUG(ndLogger, " continue with interface: " << ifName); + interfaceName = ifName; emit initFbgui(); this->close(); } diff --git a/src/fbgui/sysinfo.cpp b/src/fbgui/sysinfo.cpp index 6338025..807413b 100644 --- a/src/fbgui/sysinfo.cpp +++ b/src/fbgui/sysinfo.cpp @@ -41,7 +41,6 @@ SysInfo::~SysInfo() { * @see JavascriptInterface::getSysInfo(const QString& info) */ const QString SysInfo::getInfo(const QString& infoName) { - LOG4CXX_DEBUG(siLogger, "requested " << infoName); if (infoName == QString("mbserial")) return getMainboardSerial(); else if (infoName == QString("usb")) @@ -55,12 +54,12 @@ const QString SysInfo::getInfo(const QString& infoName) { } const QString SysInfo::getMACAddress() { // Returns MAC address of eth0 for now - QNetworkInterface qni = QNetworkInterface::interfaceFromName(QString("eth0")); + LOG4CXX_DEBUG(siLogger, "Requesting MAC of: " << interfaceName << " ..."); + QNetworkInterface qni = QNetworkInterface::interfaceFromName(interfaceName); if (!qni.isValid()) { - //qxtLog->debug() << "[sysinfo] MAC Address: No interface matching \"eth0\" found."; - return "no_eth0"; + LOG4CXX_DEBUG(siLogger, "No valid interface with name: " << interfaceName); + return "no_interface"; } - //eth0_index = qni.index(); return qni.hardwareAddress(); } // ----------------------------------------------------------------------------------------------- @@ -82,6 +81,7 @@ const QString SysInfo::getMACAddress() { * @see SysInfo::getInfo(const QString& infoName) */ const QString SysInfo::getMainboardSerial() { + LOG4CXX_DEBUG(siLogger, "Requesting Mainboard Serial..."); QString out = ""; struct sysfs_class_device *class_device = sysfs_open_class_device("dmi", "id"); @@ -214,11 +214,4 @@ const QString SysInfo::getUsbVendorIdProductIdSerialNumber() { } libusb_free_device_list(devs, 1); //free the list, unref the devices in it libusb_exit(ctx); //close the session - - - /* - QByteArray json = serializer.serialize(list); - LOG4CXX_DEBUG(siLogger, tag + "json object: " + json); - return json; - */ } -- cgit v1.2.3-55-g7522 From 45af1710d08d9896468390a21f4e0a199c7573e5 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 3 Feb 2012 17:09:33 +0100 Subject: minor changes --- src/fbgui/agui.cpp | 6 ++---- src/fbgui/console.cpp | 8 ++++---- src/fbgui/console.h | 6 +++--- src/fbgui/javascriptinterface.cpp | 13 ------------- src/fbgui/javascriptinterface.h | 2 -- src/fbgui/main.cpp | 5 +++++ src/fbgui/ndgui.cpp | 11 ----------- testApp.sh | 2 +- 8 files changed, 15 insertions(+), 38 deletions(-) (limited to 'src/fbgui/ndgui.cpp') diff --git a/src/fbgui/agui.cpp b/src/fbgui/agui.cpp index 7759800..3f2fd68 100644 --- a/src/fbgui/agui.cpp +++ b/src/fbgui/agui.cpp @@ -40,13 +40,11 @@ agui::~agui() { void agui::setupLayout() { // setup layout of the gui: debug split or browser _webView = new QWebView(this); - _webView->setContextMenuPolicy(Qt::NoContextMenu); // if this does not work try Qt::CustomContextMenu + //_webView->setContextMenuPolicy(Qt::NoContextMenu); // if this does not work try Qt::CustomContextMenu _webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); - LOG4CXX_DEBUG(aguiCoreLogger, "Debug Mode: " << debugMode); if (debugMode > -1) { // split main window in browser & debug console - //createDebugConsole(); - console* debugConsole = new console(this); + Console* debugConsole = new Console(this); QSplitter* _splitter = new QSplitter(Qt::Vertical, this); _splitter->addWidget(_webView); _splitter->addWidget(debugConsole); diff --git a/src/fbgui/console.cpp b/src/fbgui/console.cpp index ffd425f..b4fcddf 100644 --- a/src/fbgui/console.cpp +++ b/src/fbgui/console.cpp @@ -7,7 +7,7 @@ #include "console.h" -console::console(QMainWindow* parent) : +Console::Console(QMainWindow* parent) : QTextEdit(parent) { setWindowFlags(Qt::FramelessWindowHint); @@ -39,12 +39,12 @@ console::console(QMainWindow* parent) : } } -console::~console() { +Console::~Console() { delete _logFile; delete _logFileIn; } -void console::refresh(const QString& fileName) { +void Console::refresh(const QString& fileName) { if (fileName == logFilePath) { while (!_logFileIn->atEnd()) { QString line = _logFileIn->readLine(); @@ -55,6 +55,6 @@ void console::refresh(const QString& fileName) { } } -void console::toggle() { +void Console::toggle() { (this->isVisible()) ? this->hide() : this->show(); } diff --git a/src/fbgui/console.h b/src/fbgui/console.h index cb6dd34..bc6ec50 100644 --- a/src/fbgui/console.h +++ b/src/fbgui/console.h @@ -13,13 +13,13 @@ extern QString logFilePath; -class console : public QTextEdit +class Console : public QTextEdit { Q_OBJECT public: - console(QMainWindow* parent = 0); - virtual ~console(); + Console(QMainWindow* parent = 0); + virtual ~Console(); private: QFile* _logFile; diff --git a/src/fbgui/javascriptinterface.cpp b/src/fbgui/javascriptinterface.cpp index 3afd3f6..8260fab 100644 --- a/src/fbgui/javascriptinterface.cpp +++ b/src/fbgui/javascriptinterface.cpp @@ -229,16 +229,3 @@ void JavascriptInterface::callbackOnFinished() { QString code = QString("\%1").arg(_callbackOnDownloadsFinished); _parent->evaluateJavaScript(code); } -//------------------------------------------------------------------------------------------------------- -/** - * This method triggers the URL load *FOR DEBUGGING/TESTING PURPOSES* - - */ -void JavascriptInterface::trigger() { - QFile file(fileToTriggerURL); - if (file.open(QIODevice::WriteOnly)) { - file.write("data\n"); - LOG4CXX_DEBUG(jsiLogger, "*trigger watcher*"); - } - file.close(); -} diff --git a/src/fbgui/javascriptinterface.h b/src/fbgui/javascriptinterface.h index 5d45964..b15c134 100644 --- a/src/fbgui/javascriptinterface.h +++ b/src/fbgui/javascriptinterface.h @@ -66,8 +66,6 @@ public slots: void downloadInfo(const QString& filename, const double& filesize); void notify(const QString& msg); - // functions to help test functionality - void trigger(); }; #endif // JAVASCRIPTINTERFACE_H_ diff --git a/src/fbgui/main.cpp b/src/fbgui/main.cpp index 6286b9f..d379c1e 100644 --- a/src/fbgui/main.cpp +++ b/src/fbgui/main.cpp @@ -61,6 +61,8 @@ int main(int argc, char *argv[]) { app.setApplicationName("prebootGUI"); binPath = QApplication::applicationDirPath(); + + QTranslator translator; translator.load(":" + QLocale::system().name()); app.installTranslator(&translator); @@ -290,6 +292,9 @@ int main(int argc, char *argv[]) { } LOG4CXX_DEBUG(logger, "*******************************************"); + //if (QSslSocket::supportsSsl()) + // LOG4CXX_DEBUG(logger, "SUPPORT SSL!"); + // set invisible cursor //QWSServer::instance()->setCursorVisible(false); diff --git a/src/fbgui/ndgui.cpp b/src/fbgui/ndgui.cpp index 67bfa79..a95d884 100644 --- a/src/fbgui/ndgui.cpp +++ b/src/fbgui/ndgui.cpp @@ -11,7 +11,6 @@ #include "ndgui.h" - #include #include "qlog4cxx.h" @@ -41,11 +40,8 @@ ndgui::ndgui() : */ ndgui::~ndgui() { - //delete _debugConsole; - //delete _toggleDebugConsole; delete _allowUserChoice; delete _tryAgain; - //delete _webView; delete _networkDiscovery; } @@ -181,8 +177,6 @@ void ndgui::handleConnectionEstablished(QString ifName) { _ifNameList.append(ifName); } - - /** * @brief determines if we continue the boot sequence or if we show the chooseInterface or abortBoot dialog * @@ -270,11 +264,6 @@ QString ndgui::readLogFile() { void ndgui::tryAgain() { LOG4CXX_DEBUG(ndLogger, " try again "); _networkDiscovery->prepareTryAgain(); - if(debugMode > -1) { - //delete _splitter; - //delete _debugConsole; - //delete _toggleDebugConsole; - } delete _allowUserChoice; delete _tryAgain; //delete _webView; diff --git a/testApp.sh b/testApp.sh index 8a4843a..790637e 100755 --- a/testApp.sh +++ b/testApp.sh @@ -13,7 +13,7 @@ # Note: all path are expected to be absolute. # # Adapt these to your own system. -QT_VERSION=Qt-4.7.2 +QT_VERSION=Qt-4.8.0 #PATH_TO_FBGUI_BUILD=/home/joe/fbgui/build PATH_TO_FBGUI_BUILD=/home/joe/workspace/fbgui -- cgit v1.2.3-55-g7522