summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan Bauer2011-05-16 16:41:26 +0200
committerJonathan Bauer2011-05-16 16:41:26 +0200
commit424c28df8bdb08e195c6e8801d3ed8b032446bd4 (patch)
tree9af0dd135eb63c1512ea7597a993fe5c032ba9c7 /src
parentcleanups... (diff)
downloadfbgui-424c28df8bdb08e195c6e8801d3ed8b032446bd4.tar.gz
fbgui-424c28df8bdb08e195c6e8801d3ed8b032446bd4.tar.xz
fbgui-424c28df8bdb08e195c6e8801d3ed8b032446bd4.zip
more cleanups
Diffstat (limited to 'src')
-rw-r--r--src/fbgui.cpp4
-rw-r--r--src/javascriptinterface.cpp75
-rw-r--r--src/javascriptinterface.h6
-rw-r--r--src/sysinfo.cpp13
-rw-r--r--src/sysinfolibsysfs.cpp145
-rw-r--r--src/sysinfolibsysfs.h54
6 files changed, 45 insertions, 252 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index 98ad874..4629306 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -3,7 +3,6 @@
#include "loggerengine.h"
#include "downloadmanager.h"
#include "javascriptinterface.h"
-//#include "sysinfolibsysfs.h"
#include <iostream>
#include <QThread>
@@ -257,7 +256,8 @@ QByteArray fbgui::generatePOSTData() {
if (!mbserial.isEmpty())
data.append(mbserial);
else {
- qxtLog->debug() << "[gui] Mainboard serial was empty. Not appending to base hash data.";
+ qxtLog->debug()
+ << "[gui] Mainboard serial was empty. Not appending to base hash data.";
}
qxtLog->debug() << "[post] Hashing: " << data;
// generate MD5 hash of data
diff --git a/src/javascriptinterface.cpp b/src/javascriptinterface.cpp
index b480635..b45a2f9 100644
--- a/src/javascriptinterface.cpp
+++ b/src/javascriptinterface.cpp
@@ -49,6 +49,7 @@ void JavascriptInterface::attachToDOM() {
* @see JavascriptInterface::attachToDOM()
*/
void JavascriptInterface::loadJQuery() {
+ // to test if this actually works...
QString js;
QString pathToJsDir(DEFAULT_QRC_HTML_DIR);
pathToJsDir.append("/js");
@@ -56,23 +57,23 @@ void JavascriptInterface::loadJQuery() {
QDir qrcJSDir(pathToJsDir);
QFileInfoList fiList = qrcJSDir.entryInfoList();
QFileInfo fi;
- foreach(fi, fiList)
- {
- if (fi.suffix() == "js") {
- //qDebug()<< fi.fileName();
- //qxtLog->debug() << fi.fileName();
- if (fi.fileName() != "test.js") {
- QFile file;
- file.setFileName(pathToJsDir + "/" + fi.fileName());
- file.open(QIODevice::ReadOnly);
- js = file.readAll();
- file.close();
+foreach(fi, fiList)
+{
+ if (fi.suffix() == "js") {
+ //qDebug()<< fi.fileName();
+ //qxtLog->debug() << fi.fileName();
+ if (fi.fileName() != "test.js") {
+ QFile file;
+ file.setFileName(pathToJsDir + "/" + fi.fileName());
+ file.open(QIODevice::ReadOnly);
+ js = file.readAll();
+ file.close();
- _parent->evaluateJavaScript(js);
- //qxtLog->debug() << "evaluated " + fi.fileName();
- }
- }
+ _parent->evaluateJavaScript(js);
+ //qxtLog->debug() << "evaluated " + fi.fileName();
}
+ }
+}
}
//-------------------------------------------------------------------------------------------------------
// Javascript functions for webpage
@@ -178,31 +179,33 @@ void JavascriptInterface::reboot() {
*
* @todo add some more informations
*/
-void JavascriptInterface::downloadInfo(const QString& filename, const double& filesize) {
- QString code = QString("downloadInfo('\%1', \%2)").arg(filename).arg(filesize);
+void JavascriptInterface::downloadInfo(const QString& filename,
+ const double& filesize) {
+ QString code = QString("downloadInfo('\%1', \%2)").arg(filename).arg(
+ filesize);
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
/**
* This method updates the progress bar.
*
- * This method updates the progress bar of the HTML page when an download
- * happens.
+ * This method calls a Javascript function to update the progress bar of the download.
+ * Javascript must have a function called "updateProgress" to receive this information.
*
* @todo add some more informations
*/
-void JavascriptInterface::updateProgressBar(const int& percent, const double& speed,
- const QString& unit) {
+void JavascriptInterface::updateProgressBar(const int& percent,
+ const double& speed, const QString& unit) {
if (percent == 0)
return;
- QString code = QString("updateProgress(\%1, \%2, '\%3')").arg(percent).arg(speed).arg(unit);
+ QString code = QString("updateProgress(\%1, \%2, '\%3')").arg(percent).arg(
+ speed).arg(unit);
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
/**
- * This method sends notifications.
- *
- * @todo add some more informations.
+ * This method sends out messages to Javascript. A corresponding function must be implemented
+ * on the webpage to receive these.
*/
void JavascriptInterface::notify(const QString& msg) {
qxtLog->debug() << "[jsi] Notifying: " << msg;
@@ -211,27 +214,16 @@ void JavascriptInterface::notify(const QString& msg) {
}
//-------------------------------------------------------------------------------------------------------
/**
- * @todo add some more informations
+ * Sets a callback function for when downloads are finished (will be called when the queue is empty).
*/
void JavascriptInterface::callbackOnFinished() {
QString code = QString("\%1").arg(_callbackOnDownloadsFinished);
_parent->evaluateJavaScript(code);
}
//-------------------------------------------------------------------------------------------------------
-//-------------------------------------------------------------------------------------------------------
/**
- * This method triggers the arriving of the IP address *FOR TESTING PURPOSES*
- *
- * Used for testing. This method triggers the arriving of the IP address.
- * Not needed in the final version since the here simulated event will be
- * fired automaticali by the udhcpc command.
- * This methods writes some data into a specific file. This file is watched by an
- * other process which will fire an event as soon as the file changes.
- *
- * @see fbgui::watchForTrigger()
- * @see fbgui::checkForTrigger(const QString& dirname)
- * @see bool fbgui::checkHost()
- * @see void fbgui::loadURL()
+ * This method triggers the URL load *FOR DEBUGGING/TESTING PURPOSES*
+
*/
void JavascriptInterface::trigger() {
QFile file(fileToTriggerURL);
@@ -241,8 +233,3 @@ void JavascriptInterface::trigger() {
}
file.close();
}
-//-------------------------------------------------------------------------------------------------------
-void JavascriptInterface::alert(const QString& message) {
- // expects a formatted message.
- _parent->evaluateJavaScript(QString("alert(").append(message));
-}
diff --git a/src/javascriptinterface.h b/src/javascriptinterface.h
index 8826e46..cf2ec5b 100644
--- a/src/javascriptinterface.h
+++ b/src/javascriptinterface.h
@@ -34,7 +34,7 @@ private:
// loads jQuery code
void loadJQuery();
-signals:
+ signals:
// request the file from download manager
void requestFile(const QString& filename);
// quit the application
@@ -60,13 +60,13 @@ public slots:
void callbackOnFinished();
// slots for information exchange with the download manager.
- void updateProgressBar(const int& percent, const double& speed, const QString& unit);
+ void updateProgressBar(const int& percent, const double& speed,
+ const QString& unit);
void downloadInfo(const QString& filename, const double& filesize);
void notify(const QString& msg);
// functions to help test functionality
void trigger();
- void alert(const QString& message);
};
#endif // JAVASCRIPTINTERFACE_H_
diff --git a/src/sysinfo.cpp b/src/sysinfo.cpp
index c9bb0e8..e942e94 100644
--- a/src/sysinfo.cpp
+++ b/src/sysinfo.cpp
@@ -61,7 +61,8 @@ const QString SysInfo::getInfo(const QString& infoName) {
*/
const QString SysInfo::getMainboardSerial() {
QString out = "";
- struct sysfs_class_device *class_device = sysfs_open_class_device("dmi", "id");
+ struct sysfs_class_device *class_device = sysfs_open_class_device("dmi",
+ "id");
struct dlist *attrlist = sysfs_get_classdev_attributes(class_device);
struct sysfs_device *device = sysfs_get_classdev_device(class_device);
@@ -104,6 +105,7 @@ const QString SysInfo::getMainboardSerial() {
* @see SysInfo::getInfo(const QString& infoName)
*/
const QString SysInfo::getUsbVendorIdProductIdSerialNumber() {
+
QString tag = "[sysinfo] Usb Serial:";
QString out = "";
QVariantList list;
@@ -142,19 +144,22 @@ const QString SysInfo::getUsbVendorIdProductIdSerialNumber() {
qxtLog->debug() << tag + "failed to get handler / fail to open device";
return "error";
}
- re = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, string, sizeof(string));
+ re = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber,
+ string, sizeof(string));
if (re < 0) {
qxtLog->debug() << tag + "failed to get SerialNumber";
return "error";
}
infos.insert("serialnumber", QString((const char *) string));
- re = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string, sizeof(string));
+ re = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string,
+ sizeof(string));
if (re < 0) {
qxtLog->debug() << tag + "failed to get Product";
return "error";
}
infos.insert("product", QString((const char *) string));
- re = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, string, sizeof(string));
+ re = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer,
+ string, sizeof(string));
if (re < 0) {
qxtLog->debug() << tag + "failed to get Product";
return "error";
diff --git a/src/sysinfolibsysfs.cpp b/src/sysinfolibsysfs.cpp
deleted file mode 100644
index 6dcbcd2..0000000
--- a/src/sysinfolibsysfs.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * sysinfolibsysfs.cpp
- *
- * This class uses the libsysfs library to collect informations about
- * the hardware devices of the client machine.
- *
- * Created on: Mar 23, 2011
- * Author: niklas
- */
-
-#include "sysinfolibsysfs.h"
-
-//-------------------------------------------------------------------------------------------------------
-// Initialisation
-//-------------------------------------------------------------------------------------------------------
-SysInfoLibsysfs::SysInfoLibsysfs() {
- // TODO Auto-generated constructor stub
-
-}
-
-SysInfoLibsysfs::~SysInfoLibsysfs() {
- // TODO Auto-generated destructor stub
-}
-
-void SysInfoLibsysfs::getInfoAboutNetworkInterface() {
- struct sysfs_class_device *class_device = sysfs_open_class_device("net", "eth0");
- //struct dlist *attrlist = sysfs_get_classdev_attributes(class_device);
- struct sysfs_device *device = sysfs_get_classdev_device(class_device);
- //struct sysfs_driver *driver = sysfs_get_classdev_driver(class_device);
- if (device == NULL) {
- //qxtLog->debug() << "[libsysfs] device is NULL!";
- } else {
- qDebug() << "--- print eth0 device path:";
- qDebug() << QString(device->path);
- }
-
- sysfs_close_class_device(class_device);
-}
-
-void SysInfoLibsysfs::getInfoMbSerial() {
- QJson::Serializer serializer;
- QVariantList listOfDevices;
-
- struct sysfs_class_device *class_device = sysfs_open_class_device("dmi", "id");
- struct dlist *attrlist = sysfs_get_classdev_attributes(class_device);
- //struct sysfs_device *device = sysfs_get_classdev_device(class_device);
-
- if (attrlist != NULL) {
- struct sysfs_attribute *attr = NULL;
- QVariantList list;
- dlist_for_each_data(attrlist, attr, struct sysfs_attribute) {
- QVariantMap a;
- if(QString(attr->name) == QString("board_serial")) {
- a.insert("name", QString(attr->name));
- a.insert("value", QString(attr->value));
- a.insert("len", QString(attr->len));
- a.insert("path", QString(attr->path));
- a.insert("method", QString(attr->method));
- list << a;
- }
- }
- QByteArray json = serializer.serialize(list);
-
- qDebug() << json;
- return;
- }
- qDebug() << "attrlist is null!";
- sysfs_close_class_device(class_device);
-}
-
-QString SysInfoLibsysfs::getInfoMainboardSerial() {
- QString out = "";
- struct sysfs_class_device *class_device = sysfs_open_class_device("dmi", "id");
- struct dlist *attrlist = sysfs_get_classdev_attributes(class_device);
- //struct sysfs_device *device = sysfs_get_classdev_device(class_device);
-
- if (attrlist != NULL) {
- struct sysfs_attribute *attr = NULL;
- dlist_for_each_data(attrlist, attr, struct sysfs_attribute) {
- QVariantMap a;
- if(QString(attr->name) == QString("board_serial")) {
- out = QString(attr->value);
- }
- }
-
- qDebug() << out;
- return out;
- }
- qDebug() << "attrlist is null!";
- sysfs_close_class_device(class_device);
- return NULL;
-}
-
-void SysInfoLibsysfs::getInfoAboutClassNet() {
- QJson::Serializer serializer;
- QVariantList listOfDevices;
-
- struct sysfs_class *sysfsclass = sysfs_open_class("net");
- struct dlist *devices = sysfs_get_class_devices(sysfsclass);
- struct sysfs_device *dev = NULL;
- dlist_for_each_data(devices,dev, struct sysfs_device) {
- if(dev == NULL) {
- qDebug() << "device is NULL!";
- //qxtLog->debug() << "[libsysfs] device is NULL!";
- }
- else {
-
- qDebug() << "--- print device:";
-
- QVariantMap infos;
- infos.insert("name", QString(dev->name));
- infos.insert("bus", QString(dev->bus));
- infos.insert("bus_id", QString(dev->bus_id));
- infos.insert("driver_name", QString(dev->driver_name));
- infos.insert("path", QString(dev->path));
- infos.insert("subsystem", QString(dev->subsystem));
- struct dlist *attrlist = dev->attrlist;
- if (attrlist != NULL) {
- struct sysfs_attribute *attr = NULL;
- QVariantList list;
- dlist_for_each_data(attrlist, attr, struct sysfs_attribute) {
- QVariantMap a;
- a.insert("name", QString(attr->name));
- a.insert("value", QString(attr->value));
- a.insert("len", QString(attr->len));
- a.insert("path", QString(attr->path));
- a.insert("method", QString(attr->method));
- list << a;
- }
- QByteArray json = serializer.serialize(list);
-
- qDebug() << json;
- infos.insert("attrlist", list);
- }
- listOfDevices << infos;
- }
-
- }
-
- sysfs_close_class(sysfsclass);
-
- QByteArray json = serializer.serialize(listOfDevices);
-
- qDebug() << json;
-}
diff --git a/src/sysinfolibsysfs.h b/src/sysinfolibsysfs.h
deleted file mode 100644
index c933efa..0000000
--- a/src/sysinfolibsysfs.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2010,2011 - RZ Uni Freiburg
- * Copyright (c) 2010,2011 - OpenSLX Project
- *
- * This program/file is free software distributed under the GPL version 2.
- * See http://openslx.org/COPYING
- *
- * If you have any feedback please consult http://openslx.org/feedback and
- * send your feedback to feedback@openslx.org
- *
- * General information about OpenSLX can be found under http://openslx.org
- *
- *
- * Class collects informations about hardware devices of the client:
- * - ip address
- * - mac address
- *
- *
- * All methods return the collected informations as json- parsable object.
-
- * sysinfolibsysfs.h
- *
- * Created on: Mar 23, 2011
- * Author: niklas
- */
-
-#ifndef SYSINFOLIBSYSFS_H_
-#define SYSINFOLIBSYSFS_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "sysfs/libsysfs.h"
-#ifdef __cplusplus
-}
-#endif
-
-#include "fbgui.h"
-#include <qjson/serializer.h>
-
-class SysInfoLibsysfs: public QObject {
-Q_OBJECT
-public:
- SysInfoLibsysfs();
- virtual ~SysInfoLibsysfs();
- void getInfoAboutNetworkInterface();
- void getInfoAboutClassNet();
- void getInfoMbSerial();
- QString getInfoMainboardSerial();
-
-};
-
-#endif /* SYSINFOLIBSYSFS_H_ */