diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/sysInfo.cpp | 31 | ||||
| -rw-r--r-- | src/sysInfo.h | 15 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/sysInfo.cpp b/src/sysInfo.cpp new file mode 100644 index 0000000..2c67cc1 --- /dev/null +++ b/src/sysInfo.cpp @@ -0,0 +1,31 @@ +#include <QString> +#include <QTime> +#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<QNetworkInterface> 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..86cc85a --- /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 |
