diff options
| author | Niklas Goby | 2011-03-30 00:28:00 +0200 |
|---|---|---|
| committer | Niklas Goby | 2011-03-30 00:28:00 +0200 |
| commit | c12df21f0186959410d185e0c12f80193bacad5d (patch) | |
| tree | 033dc889463e2341f31dd24cbcc79bc76ac7b2e8 /src/sysinfolibsysfs.cpp | |
| parent | missing file (diff) | |
| download | fbgui-c12df21f0186959410d185e0c12f80193bacad5d.tar.gz fbgui-c12df21f0186959410d185e0c12f80193bacad5d.tar.xz fbgui-c12df21f0186959410d185e0c12f80193bacad5d.zip | |
some changes in the sysinfolibsysfs class. json support
problem: can not get the ip and mac address until now
Diffstat (limited to 'src/sysinfolibsysfs.cpp')
| -rw-r--r-- | src/sysinfolibsysfs.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
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; } |
