summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan Bauer2011-05-16 16:21:59 +0200
committerJonathan Bauer2011-05-16 16:21:59 +0200
commit5996603b36d67278eb1cb83f4179a67a4dcd2fed (patch)
tree11ff96cdc7ce04d3f070c45f93fe2c154e135a33 /src
parentbuild.sh dummy (diff)
downloadfbgui-5996603b36d67278eb1cb83f4179a67a4dcd2fed.tar.gz
fbgui-5996603b36d67278eb1cb83f4179a67a4dcd2fed.tar.xz
fbgui-5996603b36d67278eb1cb83f4179a67a4dcd2fed.zip
cleanups...
Diffstat (limited to 'src')
-rw-r--r--src/fbgui.cpp11
-rw-r--r--src/fbgui.pro8
-rw-r--r--src/sysinfo.cpp152
-rw-r--r--src/sysinfo.h7
4 files changed, 9 insertions, 169 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index 9e3dba5..98ad874 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -3,7 +3,7 @@
#include "loggerengine.h"
#include "downloadmanager.h"
#include "javascriptinterface.h"
-#include "sysinfolibsysfs.h"
+//#include "sysinfolibsysfs.h"
#include <iostream>
#include <QThread>
@@ -35,11 +35,6 @@ int debugMode = -1;
*/
fbgui::fbgui() {
- // test for libsys function
- //SysInfo si;
- //qxtLog->debug() << si.getInfo("mbserial");
- //si.getInfo("usb");
-
setupLayout();
createActions();
@@ -478,7 +473,3 @@ void fbgui::createDebugConsole() {
void fbgui::toggleDebugConsole() {
(_debugConsole->isVisible()) ? _debugConsole->hide() : _debugConsole->show();
}
-//-------------------------------------------------------------------------------------------
-//
-
-//-------------------------------------------------------------------------------------------
diff --git a/src/fbgui.pro b/src/fbgui.pro
index d1c6bf7..55862f6 100644
--- a/src/fbgui.pro
+++ b/src/fbgui.pro
@@ -18,18 +18,16 @@ INCLUDEPATH += /usr/local/qjson/include \
/usr/local/Qxt/include/QxtCore \
/usr/include/sysfs \
/usr/include/libusb-1.0
-HEADERS += sysinfolibsysfs.h \
- sysinfo.h \
+HEADERS += sysinfo.h \
loggerengine.h \
javascriptinterface.h \
downloadmanager.h \
fbgui.h
-SOURCES += sysinfolibsysfs.cpp \
- sysinfo.cpp \
+SOURCES += sysinfo.cpp \
loggerengine.cpp \
javascriptinterface.cpp \
downloadmanager.cpp \
fbgui.cpp \
main.cpp
FORMS +=
-RESOURCES += fbgui.qrc
+RESOURCES += fbgui.qrc \ No newline at end of file
diff --git a/src/sysinfo.cpp b/src/sysinfo.cpp
index 4797a86..c9bb0e8 100644
--- a/src/sysinfo.cpp
+++ b/src/sysinfo.cpp
@@ -22,8 +22,6 @@ SysInfo::~SysInfo() {
*
* @param infoName
* Is of type QString. Defines which method will be called. Possible values are:
- * - mac
- * - ip
* - mbserial
* - usb
*
@@ -35,121 +33,17 @@ SysInfo::~SysInfo() {
*/
const QString SysInfo::getInfo(const QString& infoName) {
qxtLog->debug() << "[sysinfo] requested " << infoName;
- if (infoName == QString("mac"))
- return getMACAddress();
- else if (infoName == QString("ip"))
- return getIPAddress();
- else if (infoName == QString("all"))
- return getAllInfos();
- else if (infoName == QString("mbserial"))
+ if (infoName == QString("mbserial"))
return getMainboardSerial();
else if (infoName == QString("usb"))
return getUsbVendorIdProductIdSerialNumber();
- else if (infoName == QString("json"))
- return getNames();
/* unknown code */
qxtLog->debug() << "[sysinfo] unknown requested";
return "info_error";
}
-// ------------------------------------------------------------------------------------------------
-/**
- * This method returns the clients MAC-Address.
- *
- * This method returns the clients MAC-Address of the "eth0" interface.
- * The MAC-Address is used as part of the data to compute the
- * hardwarehash of the client machine. To call this method use the
- * SysInfo::getInfo(const QString& infoName) method with
- * the parameter "mac"
- *
- * @return QString
- * the MAC-Address or "no_eth0" if an error occurred.
- *
- * @see fbgui::generatePOSTData()
- * @see SysInfo::getInfo(const QString& infoName)
- */
-const QString SysInfo::getMACAddress() {
- // Returns MAC address of eth0 for now
- QNetworkInterface qni = QNetworkInterface::interfaceFromName(QString("eth0"));
- if (!qni.isValid()) {
- qxtLog->debug() << "[sysinfo] MAC Address: No interface matching \"eth0\" found.";
- return "no_eth0";
- }
- //eth0_index = qni.index();
- return qni.hardwareAddress();
-}
-// ------------------------------------------------------------------------------------------------
-/**
- * This method returns the clients IP-Address.
- *
- * This method returns the clients IP-Address of the "eth0" interface.
- * To call this method use the
- * SysInfo::getInfo(const QString& infoName) method with
- * the parameter "ip"
- *
- * @return QString
- * the IP-Address or "ip_error" if an error occurred.
- *
- * @see SysInfo::getInfo(const QString& infoName)
- */
-const QString SysInfo::getIPAddress() {
- // Again for eth0 only at the moment.
- // TODO: this doesn't quite work yet...
- QNetworkInterface qni = QNetworkInterface::interfaceFromName(QString("eth0"));
- QList<QHostAddress> addrlist = qni.allAddresses();
- // This is does not return the right IP atm...
- foreach(QHostAddress addr, addrlist)
- {
- if (addr.protocol() == QAbstractSocket::IPv4Protocol && addr != QHostAddress::LocalHost) {
- return addr.toString();
- }
- }
- // still here?
- qxtLog->debug() << "[sysinfo] IP Address: ip_error";
- return "ip_error";
-}
-// ------------------------------------------------------------------------------------------------
-/**
- * just a test method for json.
- */
-const QByteArray SysInfo::getNames() {
-
- QVariantMap foo;
- foo.insert("name", "foo");
- foo.insert("type", 123);
-
- QVariantMap fooo;
- fooo.insert("name", "boo");
- fooo.insert("type", 321);
-
- QVariantList jsonV;
- jsonV << foo << fooo;
-
- QJson::Serializer serializer;
- QByteArray json = serializer.serialize(jsonV);
-
- qxtLog->debug() << json;
- return json;
-
-}
-// ------------------------------------------------------------------------------------------------
-/**
- * just a test method for json.
- */
-QString SysInfo::getAllInfos() {
- QVariantMap infos;
- infos.insert("mac", getMACAddress());
- infos.insert("ip", getIPAddress());
- infos.insert("whoami", getScriptOutput("whoami"));
- //infos.insert("pwd", getScriptOutput("pwd"));
-
- //QJson::Serializer serializer;
- QByteArray json = serializer.serialize(infos);
-
- qxtLog->debug() << json;
- return json;
-}
-// ------------------------------------------------------------------------------------------------
-
+// -----------------------------------------------------------------------------------------------
+// Mainboard / USB Infos using libsysfs
+// -----------------------------------------------------------------------------------------------
/**
* This method returns the Mainboard Serial Number.
*
@@ -277,41 +171,3 @@ const QString SysInfo::getUsbVendorIdProductIdSerialNumber() {
qxtLog->debug() << tag + "json object: " + json;
return json;
}
-
-// ------------------------------------------------------------------------------------------------
-/**
- * This method returns the output of the provided script.
- *
- * This method returns the output of the provided script.
- * Script could be any command.
- * This method is not used so far.
- *
- * @param cmd
- * Is of type QString. The command which will be executed
- *
- * @return QString
- * output of the script.
- */
-QString SysInfo::getScriptOutput(QString cmd) {
- QProcess *process = new QProcess();
- qxtLog->debug() << "[sysinfo] Script Output: try to open: " << cmd;
- process->start(cmd, QIODevice::ReadOnly);
-
- if (!process->waitForStarted())
- qxtLog->debug() << "[sysinfo] Script Output: process couldn't get opened";
-
- QString output;
- process->waitForFinished();
-
- QTextStream *txt_stream = new QTextStream(process);
-
- while (!txt_stream->atEnd()) {
- qxtLog->debug() << "[sysinfo] Script Output: read output: ";
- QString tmp_str = txt_stream->readLine();
- output += tmp_str;
- qxtLog->debug() << "[sysinfo] Script Output: " << tmp_str;
- }
- qxtLog->debug() << "[sysinfo] Script Output: process finished: ";
- return output;
-}
-
diff --git a/src/sysinfo.h b/src/sysinfo.h
index 131b369..ae01447 100644
--- a/src/sysinfo.h
+++ b/src/sysinfo.h
@@ -35,21 +35,16 @@ class SysInfo {
public:
SysInfo();
~SysInfo();
- // public access, valid infoName: "mac", "ip", ...
+ // public access, valid infoName: "mbserial", "usb"
const QString getInfo(const QString& infoName);
private:
// private system information readers
- const QString getMACAddress();
- const QString getIPAddress();
const QString getMainboardSerial();
const QString getUsbVendorIdProductIdSerialNumber();
- QString getAllInfos();
- QString getScriptOutput(QString cmd);
// JSon testing
QJson::Serializer serializer;
- const QByteArray getNames();
};
#endif // SYSTINFO_H