From 5a28603ff0af7bb5b2fdf2c0f8e8ef4fd1168f8a Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 7 Mar 2011 22:38:56 +0100 Subject: SysInfo class .. (bad name I know...) --- src/JSObject.cpp | 1 - src/SysInfo.cpp | 31 +++++++++++++++++++++++++++++++ src/SysInfo.h | 15 +++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/SysInfo.cpp create mode 100644 src/SysInfo.h (limited to 'src') diff --git a/src/JSObject.cpp b/src/JSObject.cpp index 8650451..2d926b5 100644 --- a/src/JSObject.cpp +++ b/src/JSObject.cpp @@ -20,7 +20,6 @@ JSObject::~JSObject() {} /* TEST */ QString JSObject::getInfo(QString info) { - //qDebug() << "Parent name: " << this->parent()->getMAC(); if (debug) qDebug() << "Requested info: " << info; if (info == QString("mac")) return "MAC_ADDRESS"; diff --git a/src/SysInfo.cpp b/src/SysInfo.cpp new file mode 100644 index 0000000..9ac02eb --- /dev/null +++ b/src/SysInfo.cpp @@ -0,0 +1,31 @@ +#include +#include +#include "SysInfo.h" + +extern bool debug; + +SysInfo::SysInfo(){} +SysInfo::~SysInfo(){} +QString SysInfo::getInfo(QString& infoName){ + if (infoName == QString("time")) + return getTime(); + if (infoName == QString("MAC")) + return getMACAddress(); +} +QString SysInfo::getTime(){ + return QTime::currentTime().toString("hh:mm:ss"); +} +QString SysInfo::getMACAddress(){ + QNetworkInterface *qNetI = new QNetworkInterface(); + QList list; + list=qNetI->allInterfaces(); + QString str; + QString macAddress; + for (int i = 0; i < list.size(); ++i) { + str = list.at(i).name(); + macAddress = list.at(i).hardwareAddress(); + if (debug) qDebug() << str << " : " << macAddress; + } + return macAddress; +} + diff --git a/src/SysInfo.h b/src/SysInfo.h new file mode 100644 index 0000000..cacb7ff --- /dev/null +++ b/src/SysInfo.h @@ -0,0 +1,15 @@ +#ifndef SYSTEMINFO_H +#define SYSTEMINFO_H + +class SysInfo { + public: + SysInfo(); + ~SysInfo(); + QString getInfo(QString& infoName); + + private: + QString getTime(); + QString getMACAddress(); +} + +#endif // SYSTEMINFO_H -- cgit v1.2.3-55-g7522