diff options
Diffstat (limited to 'src/fbgui.cpp')
| -rw-r--r-- | src/fbgui.cpp | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp index bf4a12c..d4b5c82 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -1,4 +1,5 @@ #include "fbgui.h" +#include "sysinfo.h" #include "loggerengine.h" #include "downloadmanager.h" #include "javascriptinterface.h" @@ -7,11 +8,12 @@ #include <QtWebKit> #include <QxtCore> +QString fileToTriggerURL(""); QString sessionID(""); -QUrl baseURL(DEFAULT_URL); +QUrl baseURL(""); QString binPath(""); -QString downloadPath("/tmp/fbgui/downloads"); -int updateInterval = DEFAULT_UPDATE_INTERVAL; +QString downloadPath(""); +int updateInterval = -1; int debugMode = -1; //------------------------------------------------------------------------------------------- @@ -19,26 +21,41 @@ fbgui::fbgui() { // setup basic debug qxtLog->disableLoggerEngine("DEFAULT"); - qxtLog->enableLogLevels(QxtLogger::DebugLevel); + //qxtLog->enableLogLevels(QxtLogger::DebugLevel); if (debugMode == 0){ qxtLog->addLoggerEngine("std_logger", new LoggerEngine_std); qxtLog->initLoggerEngine("std_logger"); qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); qxtLog->debug() << "Initializing fbgui..."; } - // base of the gui createActions(); _webView = new QWebView(this); - _webView->load(baseURL); + + // dhcp file watcher, disabled for now. + //_webView->load(baseURL); //watchDHCP(); + // PBS test (working dont delete) + QFileInfo fi("/tmp/serial"); + if (fi.exists()) + qxtLog->debug() << "Found /tmp/serial !"; + else + qxtLog->debug() << "No file /tmp/serial !"; + // TODO append serial number to postData. + + QNetworkRequest req(baseURL); + QByteArray postData = "mac=d8:d3:85:80:81:8b&hardwarehash=12341234123412341234123412341234&bootisoID=1&serial="; + _webView->load(req, QNetworkAccessManager::PostOperation, postData); + + // debug console split or normal browser if (debugMode == 1) setupDebugSplit(); else setCentralWidget(_webView); + // initialize javascript interface JavascriptInterface* jsi = new JavascriptInterface(_webView->page()->mainFrame()); QObject::connect(jsi, SIGNAL(quitFbgui()), this, SLOT(close())); @@ -83,7 +100,7 @@ void fbgui::setupDebugSplit() _debugConsole->insertPlainText("Debug console initialized.\n"); // enable custom logger engine qxtLog->addLoggerEngine("fb_logger", new LoggerEngine_fb(_debugConsole)); - qxtLog->initLoggerEngine("fb_logger"); + //qxtLog->initLoggerEngine("fb_logger"); qxtLog->setMinimumLevel("fb_logger", QxtLogger::DebugLevel); // display browser and debug in a splitter _splitter = new QSplitter(Qt::Vertical, this); @@ -117,13 +134,14 @@ bool fbgui::checkHost() const return true; } //------------------------------------------------------------------------------------------- -void fbgui::ipReceived(const QString& name) +void fbgui::netAccessible(const QString& name) { + //TODO change this to the actual file name... QFileInfo fi(name + "/foo"); if (fi.exists()){ qxtLog->debug() << "correct file!"; if (checkHost()){ - qxtLog->debug() << "DHCP active, loading URL..."; + qxtLog->debug() << "Received DHCP lease, loading URL..."; _webView->load(baseURL); } } @@ -133,12 +151,10 @@ void fbgui::ipReceived(const QString& name) //------------------------------------------------------------------------------------------- void fbgui::watchDHCP() { - qxtLog->debug() << "Watching /etc/fbgui"; - QStringList pathToWatch("/etc/fbgui"); - _fileSystemWatcher = new QFileSystemWatcher(pathToWatch, this); - // QString path //has to be set to some file or directory - // TODO change to the real path - // _fileSystemWatcher->addPath(QApplication::applicationDirPath() + "/testChange/"); - QObject::connect(_fileSystemWatcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(ipReceived(const QString&))); - _webView->load(QUrl("qrc:/html/loadAbout.html")); + _webView->load(QUrl("qrc:/html/loadAbout.html")); + // TODO change directory to the right one... + qxtLog->debug() << "Watching " << fileToTriggerURL; + QStringList pathToWatch(fileToTriggerURL); + _watcher = new QFileSystemWatcher(pathToWatch, this); + QObject::connect(_watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(netAccessible(const QString&))); } |
