summaryrefslogtreecommitdiffstats
path: root/NetworkDiscovery
diff options
context:
space:
mode:
Diffstat (limited to 'NetworkDiscovery')
-rw-r--r--NetworkDiscovery/ndgui.cpp3
-rw-r--r--NetworkDiscovery/networkdiscovery.cpp58
-rw-r--r--NetworkDiscovery/networkdiscovery.h27
3 files changed, 58 insertions, 30 deletions
diff --git a/NetworkDiscovery/ndgui.cpp b/NetworkDiscovery/ndgui.cpp
index 87fda02..c6b1a6d 100644
--- a/NetworkDiscovery/ndgui.cpp
+++ b/NetworkDiscovery/ndgui.cpp
@@ -29,7 +29,8 @@ ndgui::ndgui(QMainWindow *parent) :
_webView->load(QUrl("qrc:html/networkdiscovery_userchoice.html"));
_webView->show();
-
+
+ qDebug() << _tag << "start singel shot";
QTimer::singleShot(2000, this, SLOT(prepareNetworkDiscover()));
}
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!";
diff --git a/NetworkDiscovery/networkdiscovery.h b/NetworkDiscovery/networkdiscovery.h
index 2291a7c..cc79c36 100644
--- a/NetworkDiscovery/networkdiscovery.h
+++ b/NetworkDiscovery/networkdiscovery.h
@@ -27,16 +27,22 @@ class NetworkDiscovery: public QObject {
Q_OBJECT
public:
- NetworkDiscovery(QObject *parent = 0);
- ~NetworkDiscovery();
- void initAndRun(QString serverIp, bool userChoice, bool autoUp, QString pathToLogFile, QString serverPath = DEFAULT_QTSOCKETADDRESS, QString pathToExe = DEFAULT_PATHTODHCPCDEXE, QStringList *args = NULL);
- int ip4_replaceDefaultRoute(QString ifName, QString gateway, int mss);
- QString getGatewayForInterface(QString ifName);
- int ip4_setManualConfiguration(QVariantMap result);
- QString readLogFile();
- void tryAgain();
- bool checkConnectivityViaTcp();
- bool checkConnectivityViaTcp(QString server);
+ NetworkDiscovery(QObject *parent=0);
+ ~NetworkDiscovery();
+
+ void initAndRun(QString serverIp, bool userChoice,
+ bool autoUp,
+ QString pathToLogFile,
+ QString serverPath = DEFAULT_QTSOCKETADDRESS,
+ QString pathToExe = DEFAULT_PATHTODHCPCDEXE,
+ QStringList* args = NULL);
+ int ip4_replaceDefaultRoute(QString ifName, QString gateway, int mss);
+ QString getGatewayForInterface(QString ifName);
+
+ int ip4_setManualConfiguration(QVariantMap result);
+ QString readLogFile();
+ void tryAgain();
+ bool checkConnectivityViaTcp();
QVariantMap getInterfaceConfig(QString ifName);
private slots:
@@ -92,6 +98,7 @@ private:
bool checkCarrierState(QString interface);
bool checkConnectivity(QString ifName);
+ bool checkConnectivityViaTcp(QString server);
bool checkBlackList(QString i);
void getListOfNetworkInterfaces();