summaryrefslogtreecommitdiffstats
path: root/NetworkDiscovery/networkdiscovery.cpp
diff options
context:
space:
mode:
authorNiklas2011-10-21 13:11:40 +0200
committerNiklas2011-10-21 13:11:40 +0200
commit951db8ebf3f95ec6252f170bef7d3294b7bd6bc8 (patch)
tree5ee65f0cc4bf16470f32121b819ff1db96182b33 /NetworkDiscovery/networkdiscovery.cpp
parentput the NetworkDiscovery code into the src folder of the fbgui. made some tes... (diff)
downloadfbgui-951db8ebf3f95ec6252f170bef7d3294b7bd6bc8.tar.gz
fbgui-951db8ebf3f95ec6252f170bef7d3294b7bd6bc8.tar.xz
fbgui-951db8ebf3f95ec6252f170bef7d3294b7bd6bc8.zip
now the two versions of the NetworkDiscovery code should be the same (except for the qDebug...)
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!";