summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--LogReceiver/html/continueBoot.html24
-rw-r--r--LogReceiver/html/js/nd-functions.js4
-rw-r--r--LogReceiver/html/networkdiscovery.html31
-rw-r--r--LogReceiver/logreceiver.cpp69
-rw-r--r--LogReceiver/logreceiver.h5
-rw-r--r--LogReceiver/nd.qrc1
-rw-r--r--LogReceiver/ndgui.cpp88
-rw-r--r--LogReceiver/ndgui.h30
8 files changed, 143 insertions, 109 deletions
diff --git a/LogReceiver/html/continueBoot.html b/LogReceiver/html/continueBoot.html
new file mode 100644
index 0000000..89020b7
--- /dev/null
+++ b/LogReceiver/html/continueBoot.html
@@ -0,0 +1,24 @@
+<html>
+<head>
+<link rel="stylesheet" type="text/css" href="qrc:/html/networkdiscovery.css">
+<link rel="stylesheet" type="text/css" href="qrc:/html/css/jquery-ui-1.8.16.css">
+<script type="text/javascript" src="qrc:/html/js/jquery-1.6.4.min.js"></script>
+<script type="text/javascript" src="qrc:/html/js/jquery-ui-1.8.16.min.js"></script>
+<script type="text/javascript" src="qrc:/html/js/nd-functions.js"></script>
+
+
+</head>
+<body>
+<div id="top">
+</div>
+<div id="message">
+ <h1>Continue Boot</h1>
+</div>
+<div id="container">
+ <div id="footer-spacer"></div>
+</div>
+<div id="footer">
+ <p>RZ Uni Freiburg, 2011</p>
+</div>
+</body>
+</html>
diff --git a/LogReceiver/html/js/nd-functions.js b/LogReceiver/html/js/nd-functions.js
index 7480763..ac8f273 100644
--- a/LogReceiver/html/js/nd-functions.js
+++ b/LogReceiver/html/js/nd-functions.js
@@ -3,6 +3,7 @@ var updateStatus = function (s){
};
var updateIfProgressBar = function (i, p){
+ fbgui.notifyCall();
if (p >= 0 && p <= 100){
$("#"+i+"_progress").progressbar({ value: p });
}else{
@@ -11,10 +12,11 @@ var updateIfProgressBar = function (i, p){
};
var updateIfStatus = function(i, s){
-
+
};
var addInterface = function (i){
+ fbgui.notifyCall();
$("#nd_progress_container").append(
"<div class='interface'>"+
" Interface: " +i+
diff --git a/LogReceiver/html/networkdiscovery.html b/LogReceiver/html/networkdiscovery.html
index 9ae0c5b..5e7aa64 100644
--- a/LogReceiver/html/networkdiscovery.html
+++ b/LogReceiver/html/networkdiscovery.html
@@ -5,6 +5,37 @@
<script type="text/javascript" src="qrc:/html/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="qrc:/html/js/jquery-ui-1.8.16.min.js"></script>
<script type="text/javascript" src="qrc:/html/js/nd-functions.js"></script>
+
+<script type="text/javascript">
+var updateStatus = function (s){
+
+};
+
+var updateIfProgressBar = function (i, p){
+ if (p >= 0 && p <= 100){
+ $("#"+i+"_progress").progressbar({ value: p });
+ }else{
+ $("#"+i+"_progress").progressbar({ value: 0 });
+ }
+};
+
+var updateIfStatus = function(i, s){
+ $("#"+i+"_status").html(s);
+};
+
+var addInterface = function (i){
+ $("#nd_progress_container").append(
+ "<div class='interface'>"+
+ " Interface: " +i+
+ " <span id='"+i+"_status'>Start DHCP </span>" +
+ " <div id='"+i+"_progress' class='progressbar' "+
+ " style='height: 10px;'></div>"+
+ "</div>"
+ );
+ $("#"+i+"_progress").progressbar({ value: 33 });
+};
+ </script>
+
</head>
<body>
<div id="top">
diff --git a/LogReceiver/logreceiver.cpp b/LogReceiver/logreceiver.cpp
index 7f573bf..011d5f3 100644
--- a/LogReceiver/logreceiver.cpp
+++ b/LogReceiver/logreceiver.cpp
@@ -1,4 +1,3 @@
-
#include "logreceiver.h"
#include "../common/fbgui.h"
@@ -15,6 +14,9 @@ LogReceiver::~LogReceiver() {
void LogReceiver::initAndRun(QString serverPath, QString pathToExe,
QStringList* args) {
+ _userChoice = false;
+ _blocked = false;
+
if (serverPath != DEFAULT_QTSOCKETADDRESS) {
dhcpcdArguments.append("-q");
dhcpcdArguments.append(serverPath);
@@ -179,7 +181,7 @@ void LogReceiver::runDHCPCD(QString interface) {
dhcpcdArguments.removeLast();
}
-void LogReceiver::checkConnectivity(QString ifName) {
+bool LogReceiver::checkConnectivity(QString ifName) {
int metric = 0;
// get gateway address
@@ -197,16 +199,24 @@ void LogReceiver::checkConnectivity(QString ifName) {
if (!tcpSocket->waitForConnected(500)) {
qDebug() << "no internet connection with interface" << ifName;
qDebug() << tcpSocket->errorString();
- emit updateStatusLabel(ifName, "connection not possible");
+ emit
+ updateStatusLabel(ifName, "connection not possible");
+ return false;
} else {
qDebug() << "internet: check passed! for interface" << ifName;
- emit
- updateStatusLabel(ifName, "connection possible");
- emit connectionEstablished(&ifConf);
+ emit updateStatusLabel(ifName, "connection possible");
+ if (!_userChoice) {
+ // blockiere jeden weiteren check
+ // emite continueBoot
+ _blocked = true;
+ emit continueBoot(ifName);
+ } else {
+ emit connectionEstablished(&ifConf);
+ }
+ return true;
}
}
-
/**
*
*/
@@ -346,7 +356,7 @@ void LogReceiver::handleNewInputLine(QLocalSocket * client, QString data) {
emit changeProgressBarValue(interface, 80);
break;
case DHCPCD_EXIT:
- //emit changeProgressBarValue(interface, 100);
+ emit changeProgressBarValue(interface, 100);
break;
case DHCPCD_LOG:
@@ -355,7 +365,7 @@ void LogReceiver::handleNewInputLine(QLocalSocket * client, QString data) {
}
break;
case LOG_ERR:
- qDebug() << "received stat_error";
+ qDebug() << "received error:" << msg;
break;
default:
//qDebug() << logMsg;
@@ -391,6 +401,7 @@ void LogReceiver::handleNewInputLine(QLocalSocket * client, QString data) {
*
* @see LogReceiver::getListOfNetworkInterfaces()
*/
+/*
void LogReceiver::handleProcessFinished(int exitCode,
QProcess::ExitStatus exitStatus) {
QProcess* p = qobject_cast<QProcess *> (QObject::sender());
@@ -412,8 +423,6 @@ void LogReceiver::handleProcessFinished(int exitCode,
changeProgressBarValue(ifName, 100);
emit
updateStatusLabel(ifName, "check connectivity");
- //checkInternetConnection(ifName);
- //checkInternetConnectionViaTCP(ifName);
checkConnectivity(ifName);
}
}
@@ -426,6 +435,44 @@ void LogReceiver::handleProcessFinished(int exitCode,
emit allProcessesFinished();
}
}
+*/
+void LogReceiver::handleProcessFinished(int exitCode,
+ QProcess::ExitStatus exitStatus) {
+
+ QProcess* p = qobject_cast<QProcess *> (QObject::sender());
+ QString ifName = clientProcessToIfNameMap.value(p, "ifName");
+ if (!_blocked) {
+ if (ifName.compare("ifName") == 0) {
+ qDebug()
+ << "--- \t [LogReceiver::handleProcessFinished] haven't found process!";
+ } else {
+ qDebug() << "process for interface" << ifName << "finished"
+ << exitCode << exitStatus;
+ if (exitCode > 0) {
+ qDebug() << "process exited unexpected";
+ emit updateStatusLabel(ifName, "process exited unexpected");
+ } else {
+ qDebug() << "process normal exit";
+ emit changeProgressBarValue(ifName, 100);
+ emit updateStatusLabel(ifName, "check connectivity");
+ checkConnectivity(ifName);
+ }
+ }
+ if (!_blocked) {
+ QLocalSocket *client = ifNameToClient.value(ifName, 0);
+ if (client != 0) {
+ handleNewInput(client);
+ }
+ numberOfProcesses = numberOfProcesses - 1;
+ if (numberOfProcesses <= 0 && _userChoice) {
+ emit allProcessesFinished();
+ }
+ }
+ } else {
+ qDebug() << "already blocked";
+ emit updateStatusLabel(ifName, "finished DHCP");
+ }
+}
/**
* This Method is called when a process is started.
*
diff --git a/LogReceiver/logreceiver.h b/LogReceiver/logreceiver.h
index 172b1ae..41cd3c7 100644
--- a/LogReceiver/logreceiver.h
+++ b/LogReceiver/logreceiver.h
@@ -62,6 +62,7 @@ signals:
void abortBoot(QString msg);
void updateStatusLabel(QString ifName, QString status);
void allProcessesFinished();
+ void continueBoot(QString ifName);
private:
QLocalServer *server;
@@ -78,6 +79,8 @@ private:
QNetworkAccessManager *accessManager;
int numberOfProcesses;
routemanager rm;
+ bool _userChoice;
+ bool _blocked;
void handleNewInput(QLocalSocket * client);
@@ -85,7 +88,7 @@ private:
void runDHCPCD(QString interface);
QList<QString>checkCarrierState(QList<QString> &interfaces);
bool checkCarrierState(QString interface);
- void checkConnectivity(QString ifName);
+ bool checkConnectivity(QString ifName);
QList<QString> getListOfNetworkInterfaces();
bool checkBlackList(QString i);
diff --git a/LogReceiver/nd.qrc b/LogReceiver/nd.qrc
index d9d4921..1719e6c 100644
--- a/LogReceiver/nd.qrc
+++ b/LogReceiver/nd.qrc
@@ -21,5 +21,6 @@
<file>html/css/images/ui-icons_ef8c08_256x240.png</file>
<file>html/css/images/ui-icons_ffd27a_256x240.png</file>
<file>html/css/images/ui-icons_ffffff_256x240.png</file>
+ <file>html/continueBoot.html</file>
</qresource>
</RCC>
diff --git a/LogReceiver/ndgui.cpp b/LogReceiver/ndgui.cpp
index 7514d8a..ccd67da 100644
--- a/LogReceiver/ndgui.cpp
+++ b/LogReceiver/ndgui.cpp
@@ -7,16 +7,19 @@ ndgui::ndgui(QMainWindow *parent) :
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(updateStatusLabel(QString,QString)), this, SLOT(handleUpdateStatusLabel(QString, 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)));
+ _started = false;
_webView = new QWebView(this);
+ connect(_webView->page()->mainFrame(), SIGNAL(
+ javaScriptWindowObjectCleared()), this, SLOT(attachToDOM()));
connect(_webView, SIGNAL(loadFinished(bool)), this,
- SLOT(loadFinished(bool)));
+ SLOT(startNetworkDiscovery()));
+
- connect(_webView->page()->mainFrame(), SIGNAL(
- javaScriptWindowObjectCleared()), this, SLOT(attachToDOM()));
setCentralWidget(_webView);
_webView->load(QUrl("qrc:html/networkdiscovery.html"));
@@ -25,71 +28,19 @@ ndgui::ndgui(QMainWindow *parent) :
setAttribute(Qt::WA_QuitOnClose, true);
setWindowFlags(Qt::FramelessWindowHint);
- logReceiver.initAndRun("/var/tmp/qt_c_socket_custom");
- numberOfInterfaces = 0;
-
-
}
ndgui::~ndgui() {
}
-void ndgui::buildGui() {
-
- ndStatusLabel = new QLabel(tr("test"));
- ndStatusLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- ndStatusLabel->setAlignment(Qt::AlignCenter);
- ndStatusLabel->setMinimumSize(100, 20);
-
- // create interface group box
- createInterfaceGroupBox();
-
- mainLayout = new QVBoxLayout;
- mainLayout->addWidget(ndStatusLabel);
- mainLayout->addWidget(interfaceGroupBox);
-
- setLayout(mainLayout);
-}
-
-void ndgui::createInterfaceGroupBox() {
- interfaceGroupBox = new QGroupBox(tr("Interfaces"));
-
- interfaceGroupBoxLayout = new QVBoxLayout;
- /* add interfaces via addInterfacesToGroupBox()*/
-
- interfaceGroupBox->setLayout(interfaceGroupBoxLayout);
-}
-
-void ndgui::addNewInterface(QString ifName) {
- qDebug() << "receive interface to add:" << ifName;
- QHBoxLayout *hBoxLayout = new QHBoxLayout;
- QLabel *label = new QLabel(ifName);
- QLabel *labelStatus = new QLabel("waiting");
- QProgressBar *pBar = new QProgressBar(this);
- pBar->setRange(1, 100);
- pBar->setMaximumSize(200, 20);
-
- statusLabels.insert(ifName, labelStatus);
- progressBars.insert(ifName, pBar);
-
- hBoxLayout->addWidget(label, Qt::AlignLeft);
- hBoxLayout->addWidget(labelStatus, Qt::AlignCenter);
- hBoxLayout->addWidget(pBar, Qt::AlignRight);
-
- numberOfInterfaces++;
-
- interfaceGroupBoxLayout->addLayout(hBoxLayout, 2);
-}
-
-void ndgui::handleProgress(QString ifName, int newValue) {
- qDebug() << "<[---]> SLOT handleProgress activated with: " << ifName
- << newValue;
- QProgressBar * pBar = progressBars.value(ifName);
- if (newValue >= pBar->value()) {
- pBar->setValue(newValue);
- } else {
- qDebug() << "Error: new value is smaller than the old value!";
+void ndgui::startNetworkDiscovery(){
+ if(!_started) {
+ _started = true;
+ logReceiver.initAndRun("/var/tmp/qt_c_socket_custom");
+ }
+ else {
+ qDebug() << "NetworkDiscovery already started";
}
}
@@ -102,10 +53,6 @@ void ndgui::handleAbortBoot(QString msg) {
showAbortBootDialog();
}
-void ndgui::handleUpdateStatusLabel(QString ifName, QString status) {
- QLabel* label = statusLabels.value(ifName);
- label->setText(status);
-}
void ndgui::handleAllProcessesFinished() {
qDebug() << "all Processes finished";
@@ -166,7 +113,9 @@ void ndgui::shutDownSystem() {
void ndgui::continueBoot(QString ifName) {
QString text = "continue with interface: " + ifName;
- cID->close();
+ qDebug() << text;
+ _webView->load(QUrl("qrc:html/continueBoot.html"));
+ //cID->close();
}
void ndgui::showLog() {
@@ -176,9 +125,6 @@ void ndgui::showLog() {
/*test html gui version*/
/* slots */
-void ndgui::loadFinished(bool ok) {
- qDebug() << "load finished:" << ok;
-}
/************************************************/
//////////////////////////////////////////////////
diff --git a/LogReceiver/ndgui.h b/LogReceiver/ndgui.h
index fd34ec4..d0752e7 100644
--- a/LogReceiver/ndgui.h
+++ b/LogReceiver/ndgui.h
@@ -22,11 +22,8 @@ public:
~ndgui();
public slots:
- void handleProgress(QString ifName, int newValue);
- void addNewInterface(QString ifName);
void handleConnectionEstablished(interfaceconfiguration *ifConf);
void handleAbortBoot(QString msg);
- void handleUpdateStatusLabel(QString ifName, QString status);
void handleAllProcessesFinished();
void restartSystem();
@@ -37,6 +34,8 @@ public slots:
void showAbortBootDialog();
void showChooseInterfaceDialog();
+ void startNetworkDiscovery();
+
/*test for html gui version*/
void attachToDOM();
void loadJQuery();
@@ -44,11 +43,12 @@ public slots:
void updateIfStatus(const QString &ifName, const QString &status);
void updateStatus(const QString &status);
void updateIfProgressBar(const QString &ifName, const int& percent);
- void loadFinished(bool ok);
void notifyCall();
+
private:
- Ui::ndguiClass ui;
+
+ bool _started;
QWebView * _webView;
@@ -56,29 +56,9 @@ private:
QMap<QString, interfaceconfiguration*> finalUsableIntefacesMap; // maps interfaceName to its gateway
- int numberOfInterfaces;
-
ChooseInterfaceDialog *cID;
AbortBootDialog *aBD;
- /*gui elements*/
- QMap<QString, QProgressBar *> progressBars;
- QMap<QString, QLabel*> statusLabels;
- QLabel *ndStatusLabel;
- QGroupBox *interfaceGroupBox;
- QVBoxLayout *mainLayout;
- QVBoxLayout *interfaceGroupBoxLayout;
- /**/
-
-
-
-
- /*gui functions*/
- void buildGui();
- void createInterfaceGroupBox();
-
-
-
};
#endif // NDGUI_H