From 410676d8ddbde432321bbcb062b6117d2b6e7b41 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 21 Mar 2011 20:07:07 +0100 Subject: back to loading baseURL until display logic is implemented. working pbs test, working watcher, both disabled for now. --- build.sh | 4 +++- src/fbgui.cpp | 41 +++++++++++++++++++++++++++-------------- src/fbgui.h | 7 ++++--- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/build.sh b/build.sh index 9d5ce6b..ee00518 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,8 @@ #!/bin/bash +# adapt your version if needed +QT_VERSION=QtEmbedded-4.7.1 -QT_VERSION=QtEmbedded-4.7.2 +rm fbgui.tgz mkdir -p pkg diff --git a/src/fbgui.cpp b/src/fbgui.cpp index bf4a12c..f4154f8 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" @@ -8,10 +9,10 @@ #include 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; //------------------------------------------------------------------------------------------- @@ -26,19 +27,32 @@ fbgui::fbgui() qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); qxtLog->debug() << "Initializing fbgui..."; } - // base of the gui createActions(); _webView = new QWebView(this); + + // dhcp file watcher, disabled for now. _webView->load(baseURL); //watchDHCP(); + + /* PBS test (working dont delete) + QUrl test("http://132.230.4.27/fbgui/index"); + mgr = new QNetworkAccessManager(); + mgr->setCookieJar(new QNetworkCookieJar(this)); + QNetworkCookieJar *jar = mgr->cookieJar(); + QNetworkRequest req(test); + QByteArray postData = "mac=d8:d3:85:80:81:8b&hardwarehash=12341234123412341234123412341234&bootisoID=1"; + _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())); @@ -117,13 +131,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 +148,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 /etc/fbgui"; + QStringList pathToWatch("/etc/fbgui"); + _watcher = new QFileSystemWatcher(pathToWatch, this); + QObject::connect(_watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(netAccessible(const QString&))); } diff --git a/src/fbgui.h b/src/fbgui.h index 52f244f..53fd5c3 100644 --- a/src/fbgui.h +++ b/src/fbgui.h @@ -63,14 +63,15 @@ private: QAction* _toggleDebug; // - QFileSystemWatcher* _fileSystemWatcher; + QNetworkAccessManager *mgr; + QNetworkReply *rep; + QFileSystemWatcher* _watcher; private slots: // slots for processing actions void toggleDebug(); - void ipReceived(const QString& name); - + void netAccessible(const QString& name); }; #endif // FBGUI_H -- cgit v1.2.3-55-g7522