From 1c6bebb8f86969a2111936e0107fa163e10fec21 Mon Sep 17 00:00:00 2001 From: Niklas Goby Date: Tue, 8 Mar 2011 16:34:00 +0100 Subject: added the getSysInfo Method getIPAddress: --- src/sysInfo.cpp | 15 +++++++++++++++ src/sysInfo.h | 1 + 2 files changed, 16 insertions(+) (limited to 'src') 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 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 -- cgit v1.2.3-55-g7522