From a69b9be86e5209b4f168ac64b3357c7a2b9899b5 Mon Sep 17 00:00:00 2001 From: Niklas Goby Date: Thu, 10 Mar 2011 17:01:58 +0100 Subject: now using the qjson parser in the getAllInfo method and added some if (debug) commands --- src/sysInfo.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/sysInfo.cpp b/src/sysInfo.cpp index ddd400a..f5cd18d 100644 --- a/src/sysInfo.cpp +++ b/src/sysInfo.cpp @@ -48,12 +48,12 @@ QString sysInfo::getIPAddress(){ // This is does not return the right IP atm... foreach(QHostAddress addr, addrlist){ if (addr.protocol() == QAbstractSocket::IPv4Protocol && addr != QHostAddress::LocalHost){ - qDebug() << "eth0: IPv4 Address: " << addr.toString(); + if (debug) qDebug() << "eth0: IPv4 Address: " << addr.toString(); return addr.toString(); } } // still here? - qDebug() << "ip_error"; + if (debug) qDebug() << "ip_error"; return "ip_error"; } QByteArray sysInfo::getNames(){ @@ -72,13 +72,19 @@ QByteArray sysInfo::getNames(){ QJson::Serializer serializer; QByteArray json = serializer.serialize(jsonV); - qDebug() << json; + if (debug) qDebug() << json; return json; } // ------------------------------------------------------------------------------------------------ QString sysInfo::getAllInfos(){ - QString tmp = "\"mac\":\"" + getMACAddress() + "\", \"ip\":\"" + getIPAddress() +"\""; + QVariantMap infos; + infos.insert("mac", getMACAddress()); + infos.insert("ip", getIPAddress()); - return tmp; + QJson::Serializer serializer; + QByteArray json = serializer.serialize(infos); + + if (debug) qDebug() << json; + return json; } -- cgit v1.2.3-55-g7522