summaryrefslogtreecommitdiffstats
path: root/src/sysInfo.cpp
blob: c9dfa76b5b16ec0a4bfdb092e75d699da84e11b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "sysInfo.h"
#include <QString>
#include <QTime>
#include <QNetworkInterface>

sysInfo::sysInfo(){}
sysInfo::~sysInfo(){}
QString sysInfo::getInfo(QString& infoName){
	if (debug) qDebug() << "sysInfo : getInfo(" << infoName << ")";
	if (infoName == QString("time"))
		return getTime();
	if (infoName == QString("MAC"))
		return getMACAddress();
	// still here? --> error
	return "error";
}
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;
	}
	// returns only the latest found interface ... to fix
	return macAddress;
}