summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas2011-10-27 23:12:30 +0200
committerNiklas2011-10-27 23:12:30 +0200
commitb92a0317173140f4765cbc7708121add810b54cb (patch)
tree86c61cf7bf53d2720af4758910c303bdcf82687c
parentdisabled right click context menu, changed dialog button size (see css), chan... (diff)
downloadfbgui-b92a0317173140f4765cbc7708121add810b54cb.tar.gz
fbgui-b92a0317173140f4765cbc7708121add810b54cb.tar.xz
fbgui-b92a0317173140f4765cbc7708121add810b54cb.zip
changed the tryout, also some big changes in program flow. there is now userchoice page anymore. also it is now possible to press the user choice button f5 all the time.
-rw-r--r--src/html/js/networkDiscovery.js2
-rw-r--r--src/html/networkdiscovery.html4
-rw-r--r--src/html/networkdiscovery_debug.html4
-rw-r--r--src/ndgui.cpp277
-rw-r--r--src/ndgui.h8
-rw-r--r--src/networkdiscovery.cpp106
-rw-r--r--src/networkdiscovery.h11
7 files changed, 262 insertions, 150 deletions
diff --git a/src/html/js/networkDiscovery.js b/src/html/js/networkDiscovery.js
index bc99a7c..2aaea11 100644
--- a/src/html/js/networkDiscovery.js
+++ b/src/html/js/networkDiscovery.js
@@ -225,7 +225,7 @@ var chooseInterfaceDialog = function (i) {
$(this).dialog("close"); },
"Continue": function() {
var ifName = $("#nd_ifName_select :selected").text();
- fbgui.continueBoot(ifName,1);
+ fbgui.continueBoot(ifName);
$(this).dialog("close");
}
} ,
diff --git a/src/html/networkdiscovery.html b/src/html/networkdiscovery.html
index 25efee1..991ec0f 100644
--- a/src/html/networkdiscovery.html
+++ b/src/html/networkdiscovery.html
@@ -24,7 +24,9 @@ $(document).ready(function() {
<h1>Network Discovery</h1>
</header>
<section id="intro">
- <p>Welcome to the Network Discovery. We are now looking for usable interfaces and will go on as soon as we found one. This may take a few seconds.</p>
+ <p id="into_msg">Welcome to the Network Discovery. <br/>
+Please press <strong>F5</strong> if you want to choose which interface to use. <br/>
+We are now looking for usable interfaces and will go on as soon as we found one. This may take a few seconds.</p>
</section>
<div id="content">
<div id="left_spacer">
diff --git a/src/html/networkdiscovery_debug.html b/src/html/networkdiscovery_debug.html
index 9d539a3..be0c35f 100644
--- a/src/html/networkdiscovery_debug.html
+++ b/src/html/networkdiscovery_debug.html
@@ -23,7 +23,9 @@ $(document).ready(function() {
<h1>Network Discovery</h1>
</header>
<section id="intro">
- <p id="into_msg">Welcome to the Network Discovery. We are now looking for usable interfaces and will go on as soon as we found one. This may take a few seconds.</p>
+ <p id="into_msg">Welcome to the Network Discovery. <br/>
+Please press <strong>F5</strong> if you want to choose which interface to use. <br/>
+We are now looking for usable interfaces and will go on as soon as we found one. This may take a few seconds.</p>
</section>
<div id="content">
<div id="left_spacer">
diff --git a/src/ndgui.cpp b/src/ndgui.cpp
index ff372f2..d99dfd8 100644
--- a/src/ndgui.cpp
+++ b/src/ndgui.cpp
@@ -11,53 +11,104 @@ QString gPathToDhcpExe("");
ndgui::ndgui(QMainWindow *parent) :
QMainWindow(parent) {
- _tag = "[nd:ndgui]";
-
- _started = false;
- _userChoice = false;
- _tryAgain = false;
-
- setupLayout();
- createAction();
-
- connect(&networkDiscovery, SIGNAL(addInterface(const QString &)), this, SLOT(addInterface( const QString &)));
- connect(&networkDiscovery, SIGNAL(changeProgressBarValue(const QString & , const int& )), this, SLOT(updateIfProgressBar(const QString & , const int&)));
- connect(&networkDiscovery, SIGNAL(connectionEstablished(QString)), this, SLOT(handleConnectionEstablished(QString)));
- connect(&networkDiscovery, SIGNAL(abortBoot(QString)), this, SLOT(abortBoot(const QString)));
- connect(&networkDiscovery, SIGNAL(updateIfStatus(QString,QString)), this, SLOT(updateIfStatus(const QString &, const QString &)));
- connect(&networkDiscovery, SIGNAL(updateStatus(QString)), this, SLOT(updateStatus(const QString&)));
- connect(&networkDiscovery, SIGNAL(allProcessesFinished()), this, SLOT(handleAllProcessesFinished()));
- connect(&networkDiscovery, SIGNAL(continueBoot(QString, int)), this, SLOT(continueBoot(QString, int)));
-
+// _tag = "[nd:ndgui]";
+//
+// _started = false;
+// _userChoice = false;
+// _tryAgain = false;
+//
+// setupLayout();
+// createAction();
+//
+// connect(&networkDiscovery, SIGNAL(addInterface(const QString &)), this, SLOT(addInterface( const QString &)));
+// connect(&networkDiscovery, SIGNAL(changeProgressBarValue(const QString & , const int& )), this, SLOT(updateIfProgressBar(const QString & , const int&)));
+// connect(&networkDiscovery, SIGNAL(connectionEstablished(QString)), this, SLOT(handleConnectionEstablished(QString)));
+// connect(&networkDiscovery, SIGNAL(abortBoot(QString)), this, SLOT(abortBoot(const QString)));
+// connect(&networkDiscovery, SIGNAL(updateIfStatus(QString,QString)), this, SLOT(updateIfStatus(const QString &, const QString &)));
+// connect(&networkDiscovery, SIGNAL(updateStatus(QString)), this, SLOT(updateStatus(const QString&)));
+// connect(&networkDiscovery, SIGNAL(allProcessesFinished()), this, SLOT(handleAllProcessesFinished()));
+// connect(&networkDiscovery, SIGNAL(continueBoot(QString)), this, SLOT(continueBoot(QString)));
+//
+//
+// connect(_webView->page()->mainFrame(), SIGNAL(
+// javaScriptWindowObjectCleared()), this, SLOT(attachToDOM()));
+// connect(_webView, SIGNAL(loadFinished(bool)), this,
+// SLOT(startSingleShot()));
+//
+// setWindowTitle(tr("NetD"));
+// setAttribute(Qt::WA_QuitOnClose, true);
+// setWindowFlags(Qt::FramelessWindowHint);
+// showFullScreen();
+//
+// if (debugMode > -1) {
+// _webView->load(QUrl("qrc:html/networkdiscovery_debug.html"));
+// }
+// else {
+// _webView->load(QUrl("qrc:html/networkdiscovery.html"));
+//
+// }
+//
+// _webView->show();
+ init();
- connect(_webView->page()->mainFrame(), SIGNAL(
- javaScriptWindowObjectCleared()), this, SLOT(attachToDOM()));
+}
- setWindowTitle(tr("NetD"));
- setAttribute(Qt::WA_QuitOnClose, true);
- setWindowFlags(Qt::FramelessWindowHint);
- showFullScreen();
- if (debugMode > -1) {
- _webView->load(QUrl("qrc:html/networkdiscovery_userchoice_debug.html"));
- }
- else {
- _webView->load(QUrl("qrc:html/networkdiscovery_userchoice.html"));
- }
+/*destructor*/
+ndgui::~ndgui() {
+ delete _debugConsole;
+ delete _toggleDebugConsole;
+ delete _allowUserChoice;
+ delete _webView;
+ delete _networkDiscovery;
+}
- _webView->show();
-
- qxtLog->debug() << _tag << "start singel shot";
- QTimer::singleShot(5000, this, SLOT(prepareNetworkDiscover()));
-}
+/**/
+void ndgui::init () {
+ _tag = "[nd:ndgui]";
+ _started = false;
+ _userChoice = false;
+ _tryAgain = false;
+ _ifNameList.clear();
+ _manConfList.clear();
+
+ setupLayout();
+ createAction();
+
+ _networkDiscovery = new NetworkDiscovery();
+ connect(_networkDiscovery, SIGNAL(addInterface(const QString &)), this, SLOT(addInterface( const QString &)));
+ connect(_networkDiscovery, SIGNAL(changeProgressBarValue(const QString & , const int& )), this, SLOT(updateIfProgressBar(const QString & , const int&)));
+ connect(_networkDiscovery, SIGNAL(connectionEstablished(QString)), this, SLOT(handleConnectionEstablished(QString)));
+ connect(_networkDiscovery, SIGNAL(abortBoot(QString)), this, SLOT(abortBoot(const QString)));
+ connect(_networkDiscovery, SIGNAL(updateIfStatus(QString,QString)), this, SLOT(updateIfStatus(const QString &, const QString &)));
+ connect(_networkDiscovery, SIGNAL(updateStatus(QString)), this, SLOT(updateStatus(const QString&)));
+ connect(_networkDiscovery, SIGNAL(allProcessesFinished()), this, SLOT(handleAllProcessesFinished()));
+ connect(_networkDiscovery, SIGNAL(continueBoot(QString)), this, SLOT(continueBoot(QString)));
+
+
+ connect(_webView->page()->mainFrame(), SIGNAL(
+ javaScriptWindowObjectCleared()), this, SLOT(attachToDOM()));
+ connect(_webView, SIGNAL(loadFinished(bool)), this,
+ SLOT(startSingleShot()));
+
+ setWindowTitle(tr("NetD"));
+ setAttribute(Qt::WA_QuitOnClose, true);
+ setWindowFlags(Qt::FramelessWindowHint);
+ showFullScreen();
+
+ if (debugMode > -1) {
+ _webView->load(QUrl("qrc:html/networkdiscovery_debug.html"));
+ }
+ else {
+ _webView->load(QUrl("qrc:html/networkdiscovery.html"));
-/*destructor*/
-ndgui::~ndgui() {
+ }
+ _webView->show();
}
@@ -164,19 +215,10 @@ void ndgui::setUserChoiceTrue() {
* startNetworkDiscovery slot and removes the
* action.
*/
-void ndgui::prepareNetworkDiscover() {
- connect(_webView, SIGNAL(loadFinished(bool)), this,
- SLOT(startNetworkDiscovery()));
- this->removeAction(_allowUserChoice);
+void ndgui::startSingleShot() {
- if (debugMode > -1) {
- _webView->load(QUrl("qrc:html/networkdiscovery_debug.html"));
- }
- else {
- _webView->load(QUrl("qrc:html/networkdiscovery.html"));
- }
-
- _webView->show();
+ qxtLog->debug() << _tag << "start singel shot";
+ QTimer::singleShot(3000, this, SLOT(startNetworkDiscovery()));
}
@@ -188,16 +230,16 @@ void ndgui::prepareNetworkDiscover() {
*/
void ndgui::startNetworkDiscovery(){
- disconnect(_webView,SIGNAL(loadFinished(bool)), this, SLOT(startNetworkDiscovery()));
+ disconnect(_webView,SIGNAL(loadFinished(bool)), this, SLOT(startSingleShot()));
if(!_started) {
if (!_tryAgain) {
_started = true;
QStringList l;
l << "-d";
- networkDiscovery.initAndRun("209.85.148.105", _userChoice, true, logFilePath,"/var/tmp/qt_c_socket_custom", DEFAULT_PATHTODHCPCDEXE, &l);
+ _networkDiscovery->initAndRun(gServerIp, _userChoice, gAutoUp, logFilePath,"/var/tmp/qt_c_socket_custom", DEFAULT_PATHTODHCPCDEXE, &l);
} else {
_tryAgain = false;
- networkDiscovery.tryAgain();
+ _networkDiscovery->tryAgain();
}
}
else {
@@ -229,13 +271,23 @@ void ndgui::handleConnectionEstablished(QString ifName) {
*/
void ndgui::handleAllProcessesFinished() {
qxtLog->debug() << _tag << "all Processes finished";
- if(_ifNameList.size() > 0) {
- QString jsonArr = "[";
- for(int i = 0; i < _ifNameList.size()-1; i++) {
- jsonArr += "\"" + _ifNameList.value(i) + "\",";
+ if (_ifNameList.size() > 0) {
+ if (_userChoice) {
+ QString jsonArr = "[";
+ for (int i = 0; i < _ifNameList.size() - 1; i++) {
+ jsonArr += "\"" + _ifNameList.value(i) + "\",";
+ }
+ jsonArr += "\"" + _ifNameList.last() + "\"]";
+ chooseInterfaceDialog(jsonArr);
+ } else {
+ foreach(QString i, _ifNameList)
+ {
+ if (_networkDiscovery->checkConnectivity(i)) {
+ continueBoot(i);
+ break;
+ }
+ }
}
- jsonArr += "\"" + _ifNameList.last() + "\"]";
- chooseInterfaceDialog(jsonArr);
} else {
abortBoot("No usable interfaces found!");
}
@@ -280,30 +332,57 @@ void ndgui::shutDownSystem() {
* will start the fbgui screen. All networkDiscovery signals
* will be ignored after this point.
*/
-void ndgui::continueBoot(QString ifName, int userChoice) {
- if (!userChoice) {
- QString text = "continue with interface: " + ifName;
- qxtLog->debug() << _tag << " " << text << "no user choice";
- } else {
- int ret = 0;
- QString text = "continue with interface: " + ifName;
- qxtLog->debug() << _tag << " " << text << " with user choice";
- QString gateway = networkDiscovery.getGatewayForInterface(ifName);
- if (!gateway.isEmpty()) {
- qxtLog->debug() << _tag << " gateway is empty. this will produce errors";
- }
- ret = networkDiscovery.ip4_replaceDefaultRoute(ifName,gateway,0);
- if (0 != ret) {
- qxtLog->debug() << _tag << " set default route failed. returned with: " << ret << " : " << strerror(-ret);
- }
- }
- if (networkDiscovery.checkConnectivityViaTcp()) {
+//void ndgui::continueBoot(QString ifName, int userChoice) {
+void ndgui::continueBoot(QString ifName) {
+ if (_networkDiscovery->checkConnectivity(ifName)) {
+ qxtLog->debug() << _tag << " continue with interface: " << ifName;
emit initFbgui();
this->close();
} else {
- abortBoot("Interface was suddenly made unusable. Please check the log and try again.");
+ abortBoot(
+ "Interface was suddenly made unusable. Please check the log and try again.");
}
+
}
+//void ndgui::continueBoot(QString ifName) {
+// if (!_userChoice) {
+// foreach(QString i, _ifNameList)
+// {
+// if (_networkDiscovery->checkConnectivity(i)) {
+// QString text = "continue with interface: " + i;
+// qxtLog->debug() << _tag << " " << text << "no user choice";
+// emit
+// initFbgui();
+// this->close();
+// }
+// }
+// abortBoot(
+// "Interface was suddenly made unusable. Please check the log and try again.");
+// } else {
+// int ret = 0;
+// QString text = "continue with interface: " + ifName;
+// qxtLog->debug() << _tag << " " << text << " with user choice";
+// QString gateway = _networkDiscovery->getGatewayForInterface(ifName);
+// if (!gateway.isEmpty()) {
+// qxtLog->debug() << _tag
+// << " gateway is empty. this will produce errors";
+// }
+// ret = _networkDiscovery->ip4_replaceDefaultRoute(ifName, gateway, 0);
+// if (0 != ret) {
+// qxtLog->debug() << _tag
+// << " set default route failed. returned with: " << ret
+// << " : " << strerror(-ret);
+// }
+// if (_networkDiscovery->checkConnectivityViaTcp()) {
+// emit initFbgui();
+// this->close();
+// } else {
+// abortBoot(
+// "Interface was suddenly made unusable. Please check the log and try again.");
+// }
+// }
+//
+//}
@@ -312,7 +391,7 @@ void ndgui::continueBoot(QString ifName, int userChoice) {
*/
QString ndgui::readLogFile() {
qxtLog->debug() << _tag << "show log";
- return networkDiscovery.readLogFile();
+ return _networkDiscovery->readLogFile();
}
@@ -320,21 +399,33 @@ QString ndgui::readLogFile() {
/**/
void ndgui::tryAgain() {
qxtLog->debug()<< _tag << " try again ";
- _tryAgain = true;
- _started = false;
- _ifNameList.clear();
- _manConfList.clear();
- createAction();
- if (debugMode > -1) {
- _webView->load(QUrl("qrc:html/networkdiscovery_userchoice_debug.html"));
- }
- else {
- _webView->load(QUrl("qrc:html/networkdiscovery_userchoice.html"));
- }
- _webView->show();
+ delete _debugConsole;
+ delete _toggleDebugConsole;
+ delete _allowUserChoice;
+ delete _webView;
+ delete _networkDiscovery;
+
+ init();
- QTimer::singleShot(2000, this, SLOT(prepareNetworkDiscover()));
}
+///**/
+//void ndgui::tryAgain() {
+// qxtLog->debug()<< _tag << " try again ";
+// _tryAgain = true;
+// _started = false;
+// _ifNameList.clear();
+// _manConfList.clear();
+// createAction();
+// if (debugMode > -1) {
+// _webView->load(QUrl("qrc:html/networkdiscovery_userchoice_debug.html"));
+// }
+// else {
+// _webView->load(QUrl("qrc:html/networkdiscovery_userchoice.html"));
+// }
+// _webView->show();
+//
+// QTimer::singleShot(2000, this, SLOT(prepareNetworkDiscover()));
+//}
@@ -359,7 +450,7 @@ QVariantList ndgui::getManualConfInterfaces() {
/**/
QVariantMap ndgui::getInterfaceConf(QString ifName) {
- return networkDiscovery.getInterfaceConfig(ifName);
+ return _networkDiscovery->getInterfaceConfig(ifName);
}
@@ -369,7 +460,7 @@ QVariantMap ndgui::getInterfaceConf(QString ifName) {
* to the networkDiscovery for further actions.
*/
int ndgui::ip4_setManualConfiguration(QVariantMap jsonArr) {
- return networkDiscovery.ip4_setManualConfiguration(jsonArr);
+ return _networkDiscovery->ip4_setManualConfiguration(jsonArr);
}
diff --git a/src/ndgui.h b/src/ndgui.h
index 69a9f83..b6c23a6 100644
--- a/src/ndgui.h
+++ b/src/ndgui.h
@@ -34,11 +34,11 @@ public slots:
void restartSystem();
void shutDownSystem();
- void continueBoot(QString ifName, int userChoice);
+ void continueBoot(QString ifName);
void tryAgain();
- void prepareNetworkDiscover();
+ void startSingleShot();
void startNetworkDiscovery();
/*test for html gui version*/
@@ -72,7 +72,7 @@ private:
QAction * _allowUserChoice;
- NetworkDiscovery networkDiscovery;
+ NetworkDiscovery* _networkDiscovery;
QList<QString> _ifNameList; // maps interfaceName to its gateway
@@ -88,7 +88,7 @@ private:
// triggers toggleDebugConsole()
QAction* _toggleDebugConsole;
-
+ void init();
void setupLayout();
void createDebugConsole();
void toggleDebugConsole();
diff --git a/src/networkdiscovery.cpp b/src/networkdiscovery.cpp
index aba01b8..9361887 100644
--- a/src/networkdiscovery.cpp
+++ b/src/networkdiscovery.cpp
@@ -20,7 +20,8 @@ NetworkDiscovery::NetworkDiscovery(QObject *parent) {
* destructor
*/
NetworkDiscovery::~NetworkDiscovery() {
-
+ delete _networkManager;
+ delete _server;
}
@@ -56,12 +57,22 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp
_userChoice = userChoice;
_autoUp = autoUp;
_pathToLogFile = pathToLogFile;
+ _serverPath = serverPath;
_pathToDhcpcdExe = pathToExe;
_blocked = false;
_numberOfProcesses = 0;
_ifUpCountdown = 10;
+ _networkManager = new NetworkManager();
+ _clientProcessToIfNameMap.clear();
+ _clients.clear();
+ _dhcpcdArguments.clear();
+ _ifDownList.clear();
+ _ifNameToClient.clear();
+ _ifUpList.clear();
+ _ifcMap.clear();
+ _server = new QLocalServer();
if (serverPath != DEFAULT_QTSOCKETADDRESS) {
_dhcpcdArguments.append("-q");
@@ -85,6 +96,8 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp
return;
}
+ killDHCPCD();
+
// check if the path to the customdhcpcd file is correct
emit updateStatus("check if cdhcpcd is available");
QFileInfo fInfo(_pathToDhcpcdExe);
@@ -166,7 +179,7 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() {
_ifUpList.append(nI.humanReadableName());
}
else if (!(nI.flags() & QNetworkInterface::IsUp)) {
- _networkManager.bringInterfaceUP(nI.humanReadableName());
+ _networkManager->bringInterfaceUP(nI.humanReadableName());
qxtLog->debug() << _tag << " bring up: " << nI.humanReadableName() ;
_ifDownList.append(nI.humanReadableName());
}
@@ -367,18 +380,30 @@ void NetworkDiscovery::handleProcessFinished(int exitCode,
_numberOfProcesses = _numberOfProcesses - 1;
if (!_blocked) { //_blocked becomes true, if _userChoice is false and we already found a usable interface
if (ifName.compare("ifName") == 0) {
- qxtLog->debug() << _tag << " haven't found process!";
+ qxtLog->debug() << _tag << " haven't found process!";
} else {
- qxtLog->debug() << _tag << " process for interface " << ifName << " finished "
- << " exit code: " << exitCode << " exit status " << exitStatus;
+ qxtLog->debug() << _tag << " process for interface " << ifName
+ << " finished " << " exit code: " << exitCode
+ << " exit status " << exitStatus;
if (exitCode > 0) {
- qxtLog->debug() << _tag << " process exited unexpected: " << p->errorString();
- emit updateIfStatus(ifName, "process exited unexpected" + p->errorString());
+ qxtLog->debug() << _tag << " process exited unexpected: "
+ << p->errorString();
+ emit updateIfStatus(ifName, "process exited unexpected"
+ + p->errorString());
} else {
- qxtLog->debug() << _tag << " process normal exit ";
- emit changeProgressBarValue(ifName, 100);
- emit updateIfStatus(ifName, "check connectivity");
- checkConnectivity(ifName);
+ qxtLog->debug() << _tag << " process normal exit ";
+ emit
+ changeProgressBarValue(ifName, 100);
+ emit
+ updateIfStatus(ifName, "check connectivity");
+ if (checkConnectivity(ifName)) {
+ emit connectionEstablished(ifName);
+ if (!_userChoice) {
+ // blockiere jeden weiteren check
+ _blocked = true;
+ emit allProcessesFinished();
+ }
+ }
}
}
if (!_blocked) { //_blocked becomes true, if _userChoice is false and we found a usable interface
@@ -387,12 +412,12 @@ void NetworkDiscovery::handleProcessFinished(int exitCode,
handleNewInput(client);
}
//_numberOfProcesses = _numberOfProcesses - 1; && _userChoice
- if (_numberOfProcesses <= 0 ) {
+ if (_numberOfProcesses <= 0) {
emit allProcessesFinished();
}
}
} else {
- qxtLog->debug() << _tag << " already blocked";
+ qxtLog->debug() << _tag << " already blocked";
emit updateIfStatus(ifName, "finished DHCP");
}
}
@@ -425,21 +450,13 @@ bool NetworkDiscovery::checkConnectivity(QString ifName) {
// replace default route
qxtLog->debug() << _tag << "replace default route";
- _networkManager.replaceDefaultRoute(ifName,
+ _networkManager->replaceDefaultRoute(ifName,
ifConf->getGateway(), mss, AF_INET);
if (checkConnectivityViaTcp(_serverIp)) {
qxtLog->debug() << _tag << " passed connectivity check! for interface " << ifName;
emit
updateIfStatus(ifName, "connection possible");
- if (!_userChoice) {
- // blockiere jeden weiteren check
- // emite continueBoot
- _blocked = true;
- emit continueBoot(ifName, 0);
- } else {
- emit connectionEstablished(ifName);
- }
return true;
} else {
qxtLog->debug() << _tag << " failed connectivity check! for interface " << ifName;
@@ -638,7 +655,7 @@ void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString data) {
* mss value (i think this is the metric. in most cases this value is 0)
*/
int NetworkDiscovery::ip4_replaceDefaultRoute(QString ifName, QString gateway, int mss) {
- return _networkManager.replaceDefaultRoute(ifName, gateway, mss, AF_INET);
+ return _networkManager->replaceDefaultRoute(ifName, gateway, mss, AF_INET);
}
@@ -657,7 +674,7 @@ int NetworkDiscovery::ip4_replaceDefaultRoute(QString ifName, QString gateway, i
int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) {
QList<QString> dns;
dns.append(result["dns"].toString());
- _networkManager.ip4_setManualConfiguration(result["ifname"].toString(),
+ _networkManager->ip4_setManualConfiguration(result["ifname"].toString(),
result["ipaddr"].toString(), result["netmask"].toString(),
result["broadcast"].toString(), result["gateway"].toString(), 0,
AF_INET, "/etc/", dns);
@@ -671,7 +688,7 @@ int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) {
if (ifc != NULL) {
dns.clear();
dns = ifc->getDnsservers().trimmed().split(" ");
- _networkManager.ip4_setManualConfiguration(
+ _networkManager->ip4_setManualConfiguration(
result["ifname"].toString(), ifc->getIpAddress(),
ifc->getNetmask(), ifc->getBroadcast(), ifc->getGateway(),
0, AF_INET, "/etc/", dns);
@@ -679,7 +696,7 @@ int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) {
return 0;
} emit
- continueBoot(result["ifname"].toString(), 0);
+ continueBoot(result["ifname"].toString());
return 0;
}
@@ -738,6 +755,19 @@ QString NetworkDiscovery::readLogFile() {
}
+/**/
+void NetworkDiscovery::killDHCPCD() {
+ qxtLog->debug() << " kill cdhcpcd processes";
+ QProcess * p = new QProcess(this);
+ p->start("killall cdhcpcd");
+ p->waitForFinished();
+ if (p->exitCode() > 0)
+ qxtLog->debug() << _tag << "[tryAgain]" << p->errorString();
+
+ delete p;
+}
+
+
/*
*TODO: to be bug fixed
@@ -748,14 +778,8 @@ QString NetworkDiscovery::readLogFile() {
*/
void NetworkDiscovery::tryAgain() {
// kill all cdhcpcd processes
- qxtLog->debug() << " kill cdhcpcd processes";
- QProcess * p = new QProcess(this);
- p->start("killall cdhcpcd");
- p->waitForFinished();
- if (p->exitCode() > 0)
- qxtLog->debug() << _tag << "[tryAgain]" << p->errorString();
+ killDHCPCD();
- delete p;
/*
foreach(Q_PID pid , _pidsList) {
if (kill(pid,SIGKILL) <= -1)
@@ -763,19 +787,9 @@ void NetworkDiscovery::tryAgain() {
}
*/
// reset everything
- _clients.clear();
- _clientProcessToIfNameMap.clear();
- _ifNameToClient.clear();
- _numberOfProcesses = 0;
- _blocked = false;
- _ifUpCountdown = 10;
- _ifUpList.clear();
- _ifDownList.clear();
- _pidsList.clear();
- _ifcMap.clear();
-
- // start again
- mainWork();
+ delete _networkManager;
+ delete _server;
+ initAndRun(_serverIp, _userChoice, _autoUp, _pathToLogFile, _serverPath, DEFAULT_PATHTODHCPCDEXE);
}
diff --git a/src/networkdiscovery.h b/src/networkdiscovery.h
index d49bc19..3256ced 100644
--- a/src/networkdiscovery.h
+++ b/src/networkdiscovery.h
@@ -44,6 +44,7 @@ public:
int ip4_setManualConfiguration(QVariantMap result);
QString readLogFile();
void tryAgain();
+ bool checkConnectivity(QString ifName);
bool checkConnectivityViaTcp();
QVariantMap getInterfaceConfig(QString ifName);
@@ -68,7 +69,7 @@ signals:
void updateIfStatus(QString ifName, QString status);
void updateStatus(QString status);
void allProcessesFinished();
- void continueBoot(QString ifName, int userChoice);
+ void continueBoot(QString ifName);
void setManualConfInterfaces(QString jsonArr);
void readyForRun();
@@ -80,10 +81,11 @@ private:
QLocalSocket *_client;
QMap<QString,QLocalSocket*> _ifNameToClient;
QMap<QProcess*,QString> _clientProcessToIfNameMap;
+ QString _serverPath;
QString _pathToDhcpcdExe;
QStringList _dhcpcdArguments;
int _numberOfProcesses;
- NetworkManager _networkManager;
+ NetworkManager* _networkManager;
bool _userChoice;
bool _blocked;
bool _autoUp;
@@ -92,18 +94,19 @@ private:
QList<QString> _ifUpList;
QList<QString> _ifDownList;
int _ifUpCountdown;
- QTimer *_timer;
+ QTimer*_timer;
QList<Q_PID> _pidsList;
QMap<QString,interfaceconfiguration*> _ifcMap;
void mainWork();
+ void killDHCPCD();
+
void handleNewInput(QLocalSocket * client);
void runDHCPCD(QList<QString> &interfaces);
void runDHCPCD(QString interface);
bool checkCarrierState(QString interface);
- bool checkConnectivity(QString ifName);
bool checkConnectivityViaTcp(QString server);
bool checkBlackList(QString i);