summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/JSObject.cpp1
-rw-r--r--src/SysInfo.cpp31
-rw-r--r--src/SysInfo.h15
3 files changed, 46 insertions, 1 deletions
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 <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..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