summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-30 13:37:26 +0200
committerJonathan Bauer2011-03-30 13:37:26 +0200
commit1601f7bb59f36a52e57aa8dc7d6a72d96f949c8c (patch)
tree5975fb4057e031d669c207264c15783cc1347da9 /src
parentjavascript interfaces header comments (diff)
parentsome changes in the sysinfolibsysfs class. json support (diff)
downloadfbgui-1601f7bb59f36a52e57aa8dc7d6a72d96f949c8c.tar.gz
fbgui-1601f7bb59f36a52e57aa8dc7d6a72d96f949c8c.tar.xz
fbgui-1601f7bb59f36a52e57aa8dc7d6a72d96f949c8c.zip
Merge branch 'master' of git.openslx.org:lsfks/master-teamprojekt/fbgui
Diffstat (limited to 'src')
-rw-r--r--src/fbgui.cpp4
-rw-r--r--src/sysinfolibsysfs.cpp44
-rw-r--r--src/sysinfolibsysfs.h20
3 files changed, 64 insertions, 4 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index b3b3ff4..de056d5 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -22,9 +22,9 @@ int debugMode = -1;
fbgui::fbgui()
{
// test for libsys function
- //SysInfoLibsysfs* sil = new SysInfoLibsysfs();
+ SysInfoLibsysfs* sil = new SysInfoLibsysfs();
//sil->getInfoAboutNetworkInterface();
- //sil->getInfoAboutClassNet();
+ sil->getInfoAboutClassNet();
setupLayout();
createActions();
diff --git a/src/sysinfolibsysfs.cpp b/src/sysinfolibsysfs.cpp
index feacd30..acfa014 100644
--- a/src/sysinfolibsysfs.cpp
+++ b/src/sysinfolibsysfs.cpp
@@ -1,6 +1,9 @@
/*
* 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
*/
@@ -23,7 +26,7 @@ void SysInfoLibsysfs::getInfoAboutNetworkInterface()
struct sysfs_device *device = sysfs_get_classdev_device(class_device);
//struct sysfs_driver *driver = sysfs_get_classdev_driver(class_device);
if(device == NULL) {
- qDebug() << "device is NULL!";
+ //qxtLog->debug() << "[libsysfs] device is NULL!";
}
else {
qDebug() << "--- print eth0 device path:";
@@ -35,18 +38,55 @@ void SysInfoLibsysfs::getInfoAboutNetworkInterface()
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:";
- qDebug() << QString(dev->name);
+
+ 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
index dc0f396..d473843 100644
--- a/src/sysinfolibsysfs.h
+++ b/src/sysinfolibsysfs.h
@@ -1,4 +1,23 @@
/*
+# 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
@@ -18,6 +37,7 @@ extern "C" {
#endif
#include "fbgui.h"
+#include <qjson/serializer.h>
class SysInfoLibsysfs : public QObject
{