summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas2011-11-04 13:27:32 +0100
committerNiklas2011-11-04 13:27:32 +0100
commit9256ad9bd3d7d65732498b370501f3d970c83f0c (patch)
tree3c29a68e4dec228163affb6ebbf8fcc1ce2eb857
parentlast changes (diff)
downloadfbgui-9256ad9bd3d7d65732498b370501f3d970c83f0c.tar.gz
fbgui-9256ad9bd3d7d65732498b370501f3d970c83f0c.tar.xz
fbgui-9256ad9bd3d7d65732498b370501f3d970c83f0c.zip
changed the tryagain
-rw-r--r--src/ndgui.cpp151
-rw-r--r--src/networkdiscovery.cpp48
-rw-r--r--src/networkdiscovery.h1
3 files changed, 90 insertions, 110 deletions
diff --git a/src/ndgui.cpp b/src/ndgui.cpp
index 6988477..c059cf2 100644
--- a/src/ndgui.cpp
+++ b/src/ndgui.cpp
@@ -10,47 +10,7 @@ QString gPathToDhcpExe("");
/*constructor*/
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)), 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();
-
}
@@ -67,49 +27,56 @@ ndgui::~ndgui() {
/**/
-void ndgui::init () {
+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(_networkDiscovery, SIGNAL(continueBootWithoutCheck(QString )), this, SLOT(continueBootWithoutCheck(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"));
+ _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(_networkDiscovery, SIGNAL(continueBootWithoutCheck(QString )),
+ this, SLOT(continueBootWithoutCheck(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();
+ _webView->show();
}
@@ -219,7 +186,7 @@ void ndgui::setUserChoiceTrue() {
void ndgui::startSingleShot() {
qxtLog->debug() << _tag << "start singel shot";
- QTimer::singleShot(3000, this, SLOT(startNetworkDiscovery()));
+ QTimer::singleShot(3000, this, SLOT(startNetworkDiscovery()));
}
@@ -229,21 +196,14 @@ void ndgui::startSingleShot() {
* disconnect the loadFinished signal with the startNetworkDiscovery
* and starts the networkDiscovery.
*/
-void ndgui::startNetworkDiscovery(){
-
- disconnect(_webView,SIGNAL(loadFinished(bool)), this, SLOT(startSingleShot()));
- if(!_started) {
- if (!_tryAgain) {
- _started = true;
- QStringList l;
- l << "-d";
- _networkDiscovery->initAndRun(gServerIp, _userChoice, gAutoUp, logFilePath,"/var/tmp/qt_c_socket_custom", DEFAULT_PATHTODHCPCDEXE, &l);
- } else {
- _tryAgain = false;
- _networkDiscovery->tryAgain();
- }
- }
- else {
+void ndgui::startNetworkDiscovery() {
+ disconnect(_webView, SIGNAL(loadFinished(bool)), this,
+ SLOT(startSingleShot()));
+ if (!_started) {
+ _started = true;
+ _networkDiscovery->initAndRun(gServerIp, _userChoice, gAutoUp,
+ logFilePath, gSocketServerPath, gPathToDhcpExe);
+ } else {
qxtLog->debug() << _tag << "NetworkDiscovery already started";
}
}
@@ -409,6 +369,7 @@ QString ndgui::readLogFile() {
/**/
void ndgui::tryAgain() {
qxtLog->debug()<< _tag << " try again ";
+ _networkDiscovery->prepareTryAgain();
if(debugMode > -1) {
delete _splitter;
delete _debugConsole;
diff --git a/src/networkdiscovery.cpp b/src/networkdiscovery.cpp
index b0b7131..6039bef 100644
--- a/src/networkdiscovery.cpp
+++ b/src/networkdiscovery.cpp
@@ -22,6 +22,12 @@ NetworkDiscovery::NetworkDiscovery(QObject *parent) {
NetworkDiscovery::~NetworkDiscovery() {
delete _networkManager;
delete _server;
+ foreach(QProcess* p, _clientProcessToIfNameMap.keys()) {
+ delete p;
+ }
+ foreach(interfaceconfiguration* i, _ifcMap.values()) {
+ delete i;
+ }
}
@@ -365,7 +371,6 @@ void NetworkDiscovery::handleProcessStarted() {
* checkConnectivity() @see NetworkDiscovery::checkConnectivity()
* Unexpected exit:
* emit updateIfStatus() to process exited unexpected
- * TODO:: the reason for the unexpected exit should be presented in the logfile.
*
* @param exitCode
*
@@ -506,6 +511,7 @@ bool NetworkDiscovery::checkConnectivityViaTcp(QString server) {
} else {
return true;
}
+ delete tcpSocket;
}
@@ -777,31 +783,43 @@ void NetworkDiscovery::killDHCPCD() {
if (p->exitCode() > 0)
qxtLog->debug() << _tag << " [tryAgain] " << p->errorString();
- delete p;
+ delete p;
}
-/*
- *TODO: to be bug fixed
- *TODO: do it with kill and not QProcess("killall cdhcpcd")
- *TODO: still some bugs. if you press tryAgain it can happen that the app stops with the mainscreen.
- *TODO: reproducible: start normal with user choice. plug out the cable. press continue. abort screen should appear.
- *TODO: press tryAgain.
- */
-void NetworkDiscovery::tryAgain() {
+/**/
+void NetworkDiscovery::prepareTryAgain() {
// kill all cdhcpcd processes
killDHCPCD();
/*
- foreach(Q_PID pid , _pidsList) {
- if (kill(pid,SIGKILL) <= -1)
- qDebug() << _tag << " error: trying to kill process: " << pid << " error: " << strerror(errno);
- }
- */
+ foreach(Q_PID pid , _pidsList) {
+ if (kill(pid,SIGKILL) <= -1)
+ qDebug() << _tag << " error: trying to kill process: " << pid << " error: " << strerror(errno);
+ }
+ */
// reset everything
delete _networkManager;
delete _server;
+ foreach(QProcess* p, _clientProcessToIfNameMap.keys())
+ {
+ delete p;
+ }
+ foreach(interfaceconfiguration* i, _ifcMap.values())
+ {
+ delete i;
+ }
+}
+
+
+
+/*
+ *TODO: to be bug fixed
+ *TODO: do it with kill and not QProcess("killall cdhcpcd")
+ */
+void NetworkDiscovery::tryAgain() {
+ prepareTryAgain();
initAndRun(_serverIp, _userChoice, _autoUp, _pathToLogFile, _serverPath, DEFAULT_PATHTODHCPCDEXE);
}
diff --git a/src/networkdiscovery.h b/src/networkdiscovery.h
index d1792a8..021e512 100644
--- a/src/networkdiscovery.h
+++ b/src/networkdiscovery.h
@@ -44,6 +44,7 @@ public:
int ip4_setManualConfiguration(QVariantMap result);
QString readLogFile();
void tryAgain();
+ void prepareTryAgain();
bool checkConnectivity(QString ifName);
bool checkConnectivityViaTcp();
QVariantMap getInterfaceConfig(QString ifName);