From 627bcf0ee7e209ed59394dcec85b2cfacd8ada4b Mon Sep 17 00:00:00 2001 From: Niklas Date: Thu, 22 Sep 2011 16:47:47 +0200 Subject: added some more js functions. abortBootDialog() and chooseInterfaceDialog() --- LogReceiver/html/js/nd-functions.js | 50 +++++++++++++++++++-- LogReceiver/html/networkdiscovery.html | 59 ++++++++++++++++++++++++- LogReceiver/logreceiver.cpp | 10 +++-- LogReceiver/logreceiver.h | 3 +- LogReceiver/ndgui.cpp | 80 +++++++++++----------------------- LogReceiver/ndgui.h | 8 ++-- 6 files changed, 140 insertions(+), 70 deletions(-) diff --git a/LogReceiver/html/js/nd-functions.js b/LogReceiver/html/js/nd-functions.js index ac8f273..e3ee793 100644 --- a/LogReceiver/html/js/nd-functions.js +++ b/LogReceiver/html/js/nd-functions.js @@ -1,9 +1,52 @@ +var abortBootDialog = function (m) { + $("#nd_abort_boot_msg").html(m); + $("#nd_abort_boot_dialog").dialog( + { buttons: { "Show Log": function() {fbgui.showLog(); + $(this).dialog("close");}, + "Restart": function() {fbgui.restartSystem(); + $(this).dialog("close"); }, + "Shut Down": function() { fbgui.shutDownSystem(); + $(this).dialog("close"); } + } , + minWidth: 450, + modal: true, + resizable: false, + draggable: false, + open: function(event, ui) { $(".ui-dialog-titlebar-close").hide();} + }); +}; + +var chooseInterfaceDialog = function (i) { + var cb = ""+ + ""; + $("#nd_choose_interface_msg").html(cb); + $("#nd_choose_interface_dialog").dialog( + { buttons: { "Show Log": function() {fbgui.showLog(); + $(this).dialog("close");}, + "Restart": function() {fbgui.restartSystem(); + $(this).dialog("close"); }, + "Shut Down": function() { fbgui.shutDownSystem(); + $(this).dialog("close"); }, + "Continue": function() { fbgui.continueBoot(); + $(this).dialog("close"); } + } , + minWidth: 550, + modal: true, + resizable: false, + draggable: false, + open: function(event, ui) { $(".ui-dialog-titlebar-close").hide();} + }); +} + var updateStatus = function (s){ }; -var updateIfProgressBar = function (i, p){ - fbgui.notifyCall(); +var updateIfProgressBar = function (i, p){ if (p >= 0 && p <= 100){ $("#"+i+"_progress").progressbar({ value: p }); }else{ @@ -12,11 +55,10 @@ var updateIfProgressBar = function (i, p){ }; var updateIfStatus = function(i, s){ - + $("#"+i+"_status").html(s); }; var addInterface = function (i){ - fbgui.notifyCall(); $("#nd_progress_container").append( "
"+ " Interface: " +i+ diff --git a/LogReceiver/html/networkdiscovery.html b/LogReceiver/html/networkdiscovery.html index 5e7aa64..ff8b587 100644 --- a/LogReceiver/html/networkdiscovery.html +++ b/LogReceiver/html/networkdiscovery.html @@ -1,5 +1,6 @@ + @@ -7,6 +8,50 @@ @@ -43,7 +90,15 @@ var addInterface = function (i){

Network Discovery

- + +
+

+

+ +
+

+
+
diff --git a/LogReceiver/logreceiver.cpp b/LogReceiver/logreceiver.cpp index 011d5f3..7f8c7f3 100644 --- a/LogReceiver/logreceiver.cpp +++ b/LogReceiver/logreceiver.cpp @@ -79,6 +79,10 @@ void LogReceiver::initAndRun(QString serverPath, QString pathToExe, } +int LogReceiver::replaceDefaultRoute(QString &ifName, QString &gateway, int af, int mss) { + rm.replaceDefaultRoute(ifName, gateway, mss, AF_INET); +} + QList LogReceiver::getListOfNetworkInterfaces() { QList nIList = QNetworkInterface::allInterfaces(); QList result; @@ -209,7 +213,7 @@ bool LogReceiver::checkConnectivity(QString ifName) { // blockiere jeden weiteren check // emite continueBoot _blocked = true; - emit continueBoot(ifName); + emit continueBoot(ifName, _userChoice); } else { emit connectionEstablished(&ifConf); } @@ -441,7 +445,7 @@ void LogReceiver::handleProcessFinished(int exitCode, QProcess* p = qobject_cast (QObject::sender()); QString ifName = clientProcessToIfNameMap.value(p, "ifName"); - if (!_blocked) { + if (!_blocked) { //_blocked becomes true, if _userChoice is false and we found a usable interface if (ifName.compare("ifName") == 0) { qDebug() << "--- \t [LogReceiver::handleProcessFinished] haven't found process!"; @@ -458,7 +462,7 @@ void LogReceiver::handleProcessFinished(int exitCode, checkConnectivity(ifName); } } - if (!_blocked) { + if (!_blocked) { //_blocked becomes true, if _userChoice is false and we found a usable interface QLocalSocket *client = ifNameToClient.value(ifName, 0); if (client != 0) { handleNewInput(client); diff --git a/LogReceiver/logreceiver.h b/LogReceiver/logreceiver.h index 41cd3c7..7cd12d8 100644 --- a/LogReceiver/logreceiver.h +++ b/LogReceiver/logreceiver.h @@ -46,6 +46,7 @@ public: void initAndRun(QString serverPath = DEFAULT_QTSOCKETADDRESS, QString pathToExe = DEFAULT_PATHTODHCPCDEXE, QStringList* args = NULL); + int replaceDefaultRoute(QString &ifName, QString &gateway, int af, int mss); private slots: void handleNewConnection(); @@ -62,7 +63,7 @@ signals: void abortBoot(QString msg); void updateStatusLabel(QString ifName, QString status); void allProcessesFinished(); - void continueBoot(QString ifName); + void continueBoot(QString ifName, bool userChoice); private: QLocalServer *server; diff --git a/LogReceiver/ndgui.cpp b/LogReceiver/ndgui.cpp index ccd67da..0394926 100644 --- a/LogReceiver/ndgui.cpp +++ b/LogReceiver/ndgui.cpp @@ -6,10 +6,10 @@ ndgui::ndgui(QMainWindow *parent) : connect(&logReceiver, SIGNAL(addInterface(const QString &)), this, SLOT(addInterface( const QString &))); connect(&logReceiver, SIGNAL(changeProgressBarValue(const QString & , const int& )), this, SLOT(updateIfProgressBar(const QString & , const int&))); //connect(&logReceiver, SIGNAL(connectionEstablished(interfaceconfiguration*)), this, SLOT(handleConnectionEstablished(interfaceconfiguration*))); - //connect(&logReceiver, SIGNAL(abortBoot(QString)), this, SLOT(handleAbortBoot(QString))); + connect(&logReceiver, SIGNAL(abortBoot(QString)), this, SLOT(abortBoot(const QString))); connect(&logReceiver, SIGNAL(updateStatusLabel(QString,QString)), this, SLOT(updateIfStatus(const QString &, const QString &))); //connect(&logReceiver, SIGNAL(allProcessesFinished()), this, SLOT(handleAllProcessesFinished())); - connect(&logReceiver, SIGNAL(continueBoot(QString)), this, SLOT(continueBoot(QString))); + connect(&logReceiver, SIGNAL(continueBoot(QString, bool)), this, SLOT(continueBoot(QString, bool))); _started = false; @@ -48,74 +48,33 @@ void ndgui::handleConnectionEstablished(interfaceconfiguration *ifConf) { finalUsableIntefacesMap.insert(ifConf->getInterface(), ifConf); } -void ndgui::handleAbortBoot(QString msg) { - qDebug() << "abort boot. reason:" << msg; - showAbortBootDialog(); -} - - void ndgui::handleAllProcessesFinished() { qDebug() << "all Processes finished"; - - if (finalUsableIntefacesMap.size() > 0) { - showChooseInterfaceDialog(); + if(finalUsableIntefacesMap.size() > 0) { + // chooseInterfaceDialog(); } else { - showAbortBootDialog(); + abortBoot("No usable interfaces found!"); } } -void ndgui::showAbortBootDialog() { - aBD = new AbortBootDialog(this); - connect(aBD, SIGNAL(showLogSignal()), this, SLOT(showLog())); - connect(aBD, SIGNAL(restartSignal()), this, SLOT(restartSystem())); - connect(aBD, SIGNAL(shutDownSignal()), this, SLOT(shutDownSystem())); - aBD->setModal(true); - aBD->show(); -} - -void ndgui::showChooseInterfaceDialog() { - QStringList list(finalUsableIntefacesMap.keys()); - cID = new ChooseInterfaceDialog(list, this); - connect(cID, SIGNAL(continueSignal(QString)), this, - SLOT(continueBoot(QString))); - connect(cID, SIGNAL(restartSignal()), this, SLOT(restartSystem())); - connect(cID, SIGNAL(shutDownSignal()), this, SLOT(shutDownSystem())); - cID->setModal(true); - cID->show(); -} - void ndgui::restartSystem() { - if (qobject_cast (QObject::sender()) > 0) { - qDebug() << "received Signal restart abd"; - aBD->closeDialog(); - } else if (qobject_cast (QObject::sender()) > 0) { - qDebug() << "received Signal restart cid"; - cID->close(); - } else { - qDebug() << "unknown sender" << QObject::sender(); - } - } void ndgui::shutDownSystem() { - if (qobject_cast (QObject::sender()) > 0) { - aBD->closeDialog(); - } else if (qobject_cast (QObject::sender()) > 0) { +} - cID->close(); +void ndgui::continueBoot(QString ifName, bool userChoice) { + if (!userChoice) { + QString text = "continue with interface: " + ifName; + qDebug() << text << "no user choice"; + _webView->load(QUrl("qrc:html/continueBoot.html")); } else { - qDebug() << "unknown sender" << QObject::sender(); + QString text = "continue with interface: " + ifName; + qDebug() << text << "with user choice"; + _webView->load(QUrl("qrc:html/continueBoot.html")); } - -} - -void ndgui::continueBoot(QString ifName) { - QString text = "continue with interface: " + ifName; - qDebug() << text; - _webView->load(QUrl("qrc:html/continueBoot.html")); - //cID->close(); } void ndgui::showLog() { @@ -166,6 +125,17 @@ void ndgui::loadJQuery() { // dieser code muss später in die javascriptInterface klasse der fbgui eingefügt werden // tausche dazu ndgui zu javascriptinterface // und _webView->page()->mainFrame() zu _parent + +void ndgui::abortBoot(const QString msg) { + QString code = QString("abortBootDialog('\%1')").arg(msg); + _webView->page()->mainFrame()->evaluateJavaScript(code); +} + +void ndgui::chooseInterfaceDialog(const QString msg) { + QString code = QString("chooseInterfaceDialog('\%1')").arg(msg); + _webView->page()->mainFrame()->evaluateJavaScript(code); +} + void ndgui::updateStatus(const QString &status) { if (status == "") return; diff --git a/LogReceiver/ndgui.h b/LogReceiver/ndgui.h index d0752e7..7cbfb20 100644 --- a/LogReceiver/ndgui.h +++ b/LogReceiver/ndgui.h @@ -23,17 +23,15 @@ public: public slots: void handleConnectionEstablished(interfaceconfiguration *ifConf); - void handleAbortBoot(QString msg); + void abortBoot(QString msg); + void chooseInterfaceDialog(QString msg); void handleAllProcessesFinished(); void restartSystem(); void shutDownSystem(); - void continueBoot(QString ifName); + void continueBoot(QString ifName, bool userChoice); void showLog(); - void showAbortBootDialog(); - void showChooseInterfaceDialog(); - void startNetworkDiscovery(); /*test for html gui version*/ -- cgit v1.2.3-55-g7522