summaryrefslogtreecommitdiffstats
path: root/src/fbgui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fbgui.cpp')
-rw-r--r--src/fbgui.cpp41
1 files changed, 27 insertions, 14 deletions
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 <QxtCore>
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&)));
}