From 951db8ebf3f95ec6252f170bef7d3294b7bd6bc8 Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 21 Oct 2011 13:11:40 +0200 Subject: now the two versions of the NetworkDiscovery code should be the same (except for the qDebug...) --- NetworkDiscovery/networkdiscovery.cpp | 58 +++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 19 deletions(-) (limited to 'NetworkDiscovery/networkdiscovery.cpp') diff --git a/NetworkDiscovery/networkdiscovery.cpp b/NetworkDiscovery/networkdiscovery.cpp index bac824a..397ea43 100644 --- a/NetworkDiscovery/networkdiscovery.cpp +++ b/NetworkDiscovery/networkdiscovery.cpp @@ -66,23 +66,37 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp _dhcpcdArguments.append("-q"); _dhcpcdArguments.append(serverPath); } - if(QFile::exists(serverPath)){ - QFile::remove(serverPath); - } - if(!_server->listen(serverPath)){ - qDebug() << _tag << "Unable to start server: " << _server->errorString(); - abortBoot("Unable to start server: " + _server->errorString()); - return; - } - QFileInfo fInfo(_pathToDhcpcdExe); - if(!fInfo.exists()){ - qDebug() << _tag << "could not find customdhcpcd exe. Please check the path to this file."; - emit emit emit emit abortBoot("could not find customdhcpcd exe. Please check the path to this file."); - return; - } - connect(_server, SIGNAL(newConnection()), this, SLOT(handleNewConnection())); - connect(this, SIGNAL(readyForRun()), this, SLOT(slotReadyForRun())); - if (args != NULL && !args->isEmpty()) { + /* delete the file at serverPath. this is necessary since in case the application crashes, the file still + * exists which leads to an error. + */ + + if(QFile::exists(serverPath)) { + QFile::remove(serverPath); + } + + if (!_server->listen(serverPath)) { + // emit signal to the gui that a critial error occoured + qDebug() << _tag << "Unable to start server: " + << _server->errorString(); + emit + abortBoot("Unable to start server: " + _server->errorString()); + return; + } + + // check if the path to the customdhcpcd file is correct + QFileInfo fInfo(_pathToDhcpcdExe); + if (!fInfo.exists()) { + qDebug() << _tag + << " could not find customdhcpcd exe. Please check the path to this file."; + emit abortBoot( + "could not find customdhcpcd exe. Please check the path to this file."); + return; + } + + connect(_server, SIGNAL(newConnection()), this, SLOT(handleNewConnection())); + connect(this, SIGNAL(readyForRun()), this, SLOT(slotReadyForRun())); + + if (args != NULL && !args->isEmpty()) { qDebug() << _tag << "added additional args"; _dhcpcdArguments.append(*args); } @@ -353,6 +367,9 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() { qDebug() << _tag << " bring up .."; _ifDownList.append(nI.humanReadableName()); } + else if (!(nI.flags() & QNetworkInterface::IsRunning)) { + _ifDownList.append(nI.humanReadableName()); + } } } else { qDebug() << _tag << "no interfaces found!"; @@ -375,11 +392,14 @@ void NetworkDiscovery::getListOfNetworkInterfaces() { || nI.flags() & QNetworkInterface::IsLoopBack) || nI.flags() & QNetworkInterface::IsPointToPoint) || !(nI.flags() & QNetworkInterface::IsUp) - || !(nI.flags() & QNetworkInterface::IsRunning) || checkBlackList(nI.humanReadableName())) { continue; } - _ifUpList.append(nI.humanReadableName()); + if (!(nI.flags() & QNetworkInterface::IsRunning)) { + _ifDownList.append(nI.humanReadableName()); + } else { + _ifUpList.append(nI.humanReadableName()); + } } } else { qDebug() << _tag << "no interfaces found!"; -- cgit v1.2.3-55-g7522