summaryrefslogtreecommitdiffstats
path: root/src/ndgui.cpp
diff options
context:
space:
mode:
authorNiklas2011-10-27 23:12:30 +0200
committerNiklas2011-10-27 23:12:30 +0200
commitb92a0317173140f4765cbc7708121add810b54cb (patch)
tree86c61cf7bf53d2720af4758910c303bdcf82687c /src/ndgui.cpp
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.
Diffstat (limited to 'src/ndgui.cpp')
-rw-r--r--src/ndgui.cpp277
1 files changed, 184 insertions, 93 deletions
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);
}