diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/sysInfo.cpp | 15 | ||||
| -rw-r--r-- | src/sysInfo.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/sysInfo.cpp b/src/sysInfo.cpp index 8775777..8c93c52 100644 --- a/src/sysInfo.cpp +++ b/src/sysInfo.cpp @@ -11,6 +11,8 @@ QString sysInfo::getInfo(QString& infoName){ if (debug) qDebug() << "sysInfo : getInfo(" << infoName << ")"; if (infoName == QString("mac")) return getMACAddress(); + else if (infoName == QString("ip")) + return getIPAddress(); // still here? --> error return "error"; } @@ -28,3 +30,16 @@ QString sysInfo::getMACAddress(){ // returns only the latest found interface ... to fix return macAddress; } + +QString sysInfo::getIPAddress(){ + QString ipAddress = ""; + QNetworkInterface *qNetI = new QNetworkInterface(); + QList<QHostAddress> list; + list=qNetI->allAddresses(); + for (int i = 0; i < list.size(); ++i) { + ipAddress = list.at(i).toString(); + if (debug) qDebug() << "IP Address" << " : " << ipAddress; + } + // returns only the latest found interface ... to fix + return ipAddress; +} diff --git a/src/sysInfo.h b/src/sysInfo.h index e4a2354..86443b8 100644 --- a/src/sysInfo.h +++ b/src/sysInfo.h @@ -11,6 +11,7 @@ class sysInfo { private: QString getMACAddress(); + QString getIPAddress(); }; #endif // SYSTEMINFO_H |
