diff options
Diffstat (limited to 'src/fbgui')
-rw-r--r-- | src/fbgui/interfaceconfiguration.cpp | 15 | ||||
-rw-r--r-- | src/fbgui/main.cpp | 19 | ||||
-rw-r--r-- | src/fbgui/ndgui.h | 3 | ||||
-rw-r--r-- | src/fbgui/networkmanager.cpp | 50 | ||||
-rw-r--r-- | src/fbgui/sysinfo.cpp | 2 |
5 files changed, 55 insertions, 34 deletions
diff --git a/src/fbgui/interfaceconfiguration.cpp b/src/fbgui/interfaceconfiguration.cpp index 3d09e52..d9d72df 100644 --- a/src/fbgui/interfaceconfiguration.cpp +++ b/src/fbgui/interfaceconfiguration.cpp @@ -12,6 +12,13 @@ #include "interfaceconfiguration.h" +#include <log4cxx/logger.h> +#include "qlog4cxx.h" + +using namespace log4cxx; +using namespace log4cxx::helpers; +LoggerPtr ndifLogger(Logger::getLogger("fbgui.nd.ifconf")); + interfaceconfiguration::interfaceconfiguration() { _tag = "[nd:InterfaceConfiguration]"; } @@ -34,10 +41,10 @@ bool interfaceconfiguration::readConfigOutOfFile(QString pathToConfig) { QFile file(pathToConfig); if (file.exists()) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug() << _tag << "couldn't open file:" << pathToConfig; + LOG4CXX_DEBUG(ndifLogger, _tag << "couldn't open file:" << pathToConfig); return false; } - qDebug() << _tag << "read config file"; + LOG4CXX_DEBUG(ndifLogger, _tag << "read config file"); while (!file.atEnd()) { QString line(file.readLine()); QStringList splitedLine = line.split("="); @@ -74,11 +81,11 @@ bool interfaceconfiguration::readConfigOutOfFile(QString pathToConfig) { } else if (name.compare("DHCPCHADDR") == 0) { this->dhcpchaddr = values; } else { - qDebug() << _tag << "read unknown name" << name << values; + LOG4CXX_DEBUG(ndifLogger, _tag << "read unknown name" << name << values); } } } else { - qDebug() << _tag << "file doesn't exist:" << pathToConfig; + LOG4CXX_DEBUG(ndifLogger, _tag << "file doesn't exist:" << pathToConfig); return false; } return true; diff --git a/src/fbgui/main.cpp b/src/fbgui/main.cpp index d883469..051ce65 100644 --- a/src/fbgui/main.cpp +++ b/src/fbgui/main.cpp @@ -55,6 +55,17 @@ int main(int argc, char *argv[]) { // The third parameter sets the application as the // GUI-Server (aswell as the GUI-Client). + QApplication app(argc, argv, QApplication::GuiServer); + app.setOrganizationName("team_projekt_2011"); + app.setApplicationName("prebootGUI"); + binPath = QApplication::applicationDirPath(); + + QTranslator translator; + translator.load(":" + QLocale::system().name()); + app.installTranslator(&translator); + + + // LOG4CXX Logger Init QFileInfo loggingConfInfo = QFileInfo(QDir::home(), ".fbgui.logging.conf"); QString loggingConfigFilePath; if (loggingConfInfo.exists()) @@ -74,14 +85,6 @@ int main(int argc, char *argv[]) { BasicConfigurator::configure(); } - QApplication app(argc, argv, QApplication::GuiServer); - app.setOrganizationName("team_projekt_2011"); - app.setApplicationName("prebootGUI"); - binPath = QApplication::applicationDirPath(); - - QTranslator translator; - translator.load(":" + QLocale::system().name()); - app.installTranslator(&translator); // parse command line arguments using getopt QMap<QString, QString> clOpts; diff --git a/src/fbgui/ndgui.h b/src/fbgui/ndgui.h index 1cb285c..18fe5c7 100644 --- a/src/fbgui/ndgui.h +++ b/src/fbgui/ndgui.h @@ -73,6 +73,7 @@ signals: private slots: void setUserChoiceTrue(); + void toggleDebugConsole(); private: @@ -109,7 +110,7 @@ private: void setupLayout(); void createDebugConsole(); - void toggleDebugConsole(); + }; diff --git a/src/fbgui/networkmanager.cpp b/src/fbgui/networkmanager.cpp index ce2186a..8a3e529 100644 --- a/src/fbgui/networkmanager.cpp +++ b/src/fbgui/networkmanager.cpp @@ -10,6 +10,13 @@ #include "networkmanager.h" +#include <log4cxx/logger.h> +#include "qlog4cxx.h" + +using namespace log4cxx; +using namespace log4cxx::helpers; +LoggerPtr ndnmLogger(Logger::getLogger("fbgui.nd.nm")); + NetworkManager::NetworkManager() { // TODO Auto-generated constructor stub @@ -59,11 +66,12 @@ NetworkManager::replaceDefaultRoute(QString ifname, QString gateway, int mss, QByteArray ba_gw = gateway.toAscii(); char * gwaddr = ba_gw.data(); - qDebug() << "---doRoute() gwaddr" << gwaddr; + LOG4CXX_DEBUG(ndnmLogger, "---doRoute() gwaddr" << gwaddr); + //qDebug() << "---doRoute() gwaddr" << gwaddr; if (!(gw = nl_addr_parse(gwaddr, af))) { - qDebug() << "Invalid router address given:" << gwaddr; + LOG4CXX_DEBUG(ndnmLogger, "Invalid router address given:" << gwaddr); return -1; } @@ -72,7 +80,7 @@ NetworkManager::replaceDefaultRoute(QString ifname, QString gateway, int mss, if ((cache = rtnl_link_alloc_cache(rtsock)) == NULL) { - qDebug() << "error with link cache alloc \n"; + LOG4CXX_DEBUG(ndnmLogger, "error with link cache alloc \n"); } iface_idx = rtnl_link_name2i(cache, ifn); @@ -88,7 +96,7 @@ NetworkManager::replaceDefaultRoute(QString ifname, QString gateway, int mss, } retval = rtnl_route_add(rtsock, route, NLM_F_REPLACE); - qDebug() << "return value:" << retval << ":" << strerror(-retval); + LOG4CXX_DEBUG(ndnmLogger, "return value:" << retval << ":" << strerror(-retval)); rtnl_route_put(route); nl_addr_put(gw); @@ -268,7 +276,7 @@ NetworkManager::bringInterfaceUpDown(QString ifname, bool up) if (!(request = rtnl_link_alloc())) { - qDebug() << "error. couldn't allocate a rtnl link"; + LOG4CXX_DEBUG(ndnmLogger, "error. couldn't allocate a rtnl link"); return -1; } @@ -286,20 +294,20 @@ NetworkManager::bringInterfaceUpDown(QString ifname, bool up) if ((cache = rtnl_link_alloc_cache(rtsock)) == NULL) { - qDebug() << "error with link cache alloc "; + LOG4CXX_DEBUG(ndnmLogger, "error with link cache alloc "); } old = rtnl_link_get_by_name(cache, ifn); if (old) { - qDebug() << "change link"; + LOG4CXX_DEBUG(ndnmLogger, "change link"); retval = rtnl_link_change(rtsock, old, request, 0); } else { - qDebug() << "change failed"; + LOG4CXX_DEBUG(ndnmLogger, "change failed"); retval = -1; - qDebug() << "return value:" << retval << ":" << strerror(-retval); + LOG4CXX_DEBUG(ndnmLogger, "return value:" << retval << ":" << strerror(-retval)); } rtnl_link_put(old); @@ -383,7 +391,7 @@ NetworkManager::ip4_configureInterface(QString ifname, QString ipAddress, if ((cache = rtnl_link_alloc_cache(rtsock)) == NULL) { - qDebug() << "error with link cache alloc"; + LOG4CXX_DEBUG(ndnmLogger, "error with link cache alloc"); return -1; } @@ -391,7 +399,7 @@ NetworkManager::ip4_configureInterface(QString ifname, QString ipAddress, if (!(addr = rtnl_addr_alloc())) { - qDebug() << "error with addr alloc"; + LOG4CXX_DEBUG(ndnmLogger, "error with addr alloc"); return -1; } @@ -400,11 +408,11 @@ NetworkManager::ip4_configureInterface(QString ifname, QString ipAddress, nl_addr_put(local); if (err != 0) { - qDebug() << "error with set local addr"; + LOG4CXX_DEBUG(ndnmLogger, "error with set local addr"); } prefixLength = ip4_netmaskToPrefix(ipAddress, netmask); - qDebug() << "prefix length:" << prefixLength; + LOG4CXX_DEBUG(ndnmLogger, "prefix length:" << prefixLength); rtnl_addr_set_prefixlen(addr, prefixLength); local = nl_addr_parse(bcaddr, af); @@ -412,7 +420,7 @@ NetworkManager::ip4_configureInterface(QString ifname, QString ipAddress, nl_addr_put(local); if (err != 0) { - qDebug() << "error with set broadcast addr"; + LOG4CXX_DEBUG(ndnmLogger, "error with set broadcast addr"); } rtnl_addr_set_ifindex(addr, iface_idx); @@ -420,7 +428,7 @@ NetworkManager::ip4_configureInterface(QString ifname, QString ipAddress, retval = sync_address(ifn, iface_idx, af, addr); if (retval < 0) { - qDebug() << "error in sync_address"; + LOG4CXX_DEBUG(ndnmLogger, "error in sync_address"); } rtnl_addr_put(addr); @@ -446,7 +454,7 @@ NetworkManager::ip4_netmaskToPrefix(QString ipAddr, QString netmask) if (netmask == "") { - qDebug() << "error: netmask is empty"; + LOG4CXX_DEBUG(ndnmLogger, "error: netmask is empty"); return retval; } nae.setIp(QHostAddress(ipAddr)); @@ -469,7 +477,7 @@ NetworkManager::ip6_addAddress(struct ip6_addr* ip6Addr, const char *iface) if ((cache = rtnl_link_alloc_cache(rtsock)) == NULL) { - qDebug() << "error with link cache alloc"; + LOG4CXX_DEBUG(ndnmLogger, "error with link cache alloc"); return -1; } @@ -638,7 +646,7 @@ nlh = nl_handle_alloc(); { //nm_log_err (log_domain, "(%s): error %d returned from rtnl_addr_delete(): %s", // iface, err, nl_geterror ()); - qDebug() << "error with delete addr"; + LOG4CXX_DEBUG(ndnmLogger, "error with delete addr"); } } @@ -671,7 +679,7 @@ if (buf_valid == 0) { //nm_log_dbg (log_domain, "(%s): adding address '%s/%d'", //iface, buf, nl_addr_get_prefixlen (nladdr)); - qDebug() << "buf valid adding addr"; + LOG4CXX_DEBUG(ndnmLogger, "buf valid adding addr"); } err = rtnl_addr_add(nlh, addr, 0); @@ -680,7 +688,7 @@ if (err < 0) //nm_log_err (log_domain, // "(%s): error %d returned from rtnl_addr_add():\n%s", // iface, err, nl_geterror ()); - qDebug() << "error with add addr" << strerror(-err); + LOG4CXX_DEBUG(ndnmLogger, "error with add addr" << strerror(-err)); } rtnl_addr_put(addr); @@ -710,7 +718,7 @@ NetworkManager::writeResolvConf(QString path, QString ifname, QFile file(path + "resolv.conf"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - qDebug() << "error couldn't open file:" << path; + LOG4CXX_DEBUG(ndnmLogger, "error couldn't open file:" << path); return -1; } QTextStream out(&file); diff --git a/src/fbgui/sysinfo.cpp b/src/fbgui/sysinfo.cpp index 1af6f76..6338025 100644 --- a/src/fbgui/sysinfo.cpp +++ b/src/fbgui/sysinfo.cpp @@ -94,6 +94,8 @@ const QString SysInfo::getMainboardSerial() { QVariantMap a; if(QString(attr->name) == QString("board_serial")) { out = QString(attr->value); + if (out.endsWith("\n")) + out.chop(1); } } LOG4CXX_DEBUG(siLogger, "Mainboard Serial: " + out); |