summaryrefslogtreecommitdiffstats
path: root/NetworkDiscovery/networkdiscovery.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NetworkDiscovery/networkdiscovery.cpp')
-rw-r--r--NetworkDiscovery/networkdiscovery.cpp58
1 files changed, 39 insertions, 19 deletions
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!";