summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas2011-10-27 19:58:45 +0200
committerNiklas2011-10-27 19:58:45 +0200
commita418d8ca1e04fc4f216aa74e7827f755b02e0874 (patch)
tree8ba2a70eb79e3e99029e06a0324ece0531eb60c1
parentthe log message has now a newline (diff)
downloadfbgui-a418d8ca1e04fc4f216aa74e7827f755b02e0874.tar.gz
fbgui-a418d8ca1e04fc4f216aa74e7827f755b02e0874.tar.xz
fbgui-a418d8ca1e04fc4f216aa74e7827f755b02e0874.zip
disabled right click context menu, changed dialog button size (see css), changed customdhcp logger. it now sends all log messages through the socket
-rw-r--r--NetworkDiscovery/ndgui.cpp2
-rw-r--r--NetworkDiscovery/networkdiscovery.cpp4
-rw-r--r--NetworkDiscovery/networkdiscovery.h2
-rw-r--r--NetworkDiscovery/networkmanager.cpp2
-rw-r--r--customdhcpcd/src/logger.c14
-rw-r--r--customdhcpcd/src/logwriter.c26
-rw-r--r--src/html/js/networkDiscovery.js8
-rw-r--r--src/html/networkdiscovery.css4
-rw-r--r--src/html/networkdiscovery.html2
-rw-r--r--src/html/networkdiscovery_debug.html4
-rw-r--r--src/ndgui.cpp30
-rw-r--r--src/networkdiscovery.cpp795
-rw-r--r--src/networkdiscovery.h3
13 files changed, 464 insertions, 432 deletions
diff --git a/NetworkDiscovery/ndgui.cpp b/NetworkDiscovery/ndgui.cpp
index c6b1a6d..a1ccecb 100644
--- a/NetworkDiscovery/ndgui.cpp
+++ b/NetworkDiscovery/ndgui.cpp
@@ -15,7 +15,7 @@ ndgui::ndgui(QMainWindow *parent) :
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(updateStatusLabel(QString,QString)), this, SLOT(updateIfStatus(const QString &, const QString &)));
+ connect(&networkDiscovery, SIGNAL(updateIfStatus(QString,QString)), this, SLOT(updateIfStatus(const QString &, const QString &)));
connect(&networkDiscovery, SIGNAL(allProcessesFinished()), this, SLOT(handleAllProcessesFinished()));
connect(&networkDiscovery, SIGNAL(continueBoot(QString, int)), this, SLOT(continueBoot(QString, int)));
diff --git a/NetworkDiscovery/networkdiscovery.cpp b/NetworkDiscovery/networkdiscovery.cpp
index 397ea43..9ca0ec5 100644
--- a/NetworkDiscovery/networkdiscovery.cpp
+++ b/NetworkDiscovery/networkdiscovery.cpp
@@ -760,10 +760,10 @@ void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString data) {
* the exitCode. Further actions are taken according to the exitCode check.
* Normal exit:
* emit changeProgressBar() to 100%
- * emit updateStatusLabel() to check connection
+ * emit updateIfStatus() to check connection
* checkConnectivity() @see NetworkDiscovery::checkConnectivity()
* Unexpected exit:
- * emit updateStatusLabel() to process exited unexpected
+ * emit updateIfStatus() to process exited unexpected
* TODO:: the reason for the unexpected exit should be presented in the logfile.
*
* @param exitCode
diff --git a/NetworkDiscovery/networkdiscovery.h b/NetworkDiscovery/networkdiscovery.h
index cc79c36..9269610 100644
--- a/NetworkDiscovery/networkdiscovery.h
+++ b/NetworkDiscovery/networkdiscovery.h
@@ -61,7 +61,7 @@ signals:
void changeProgressBarValue(const QString & ifName, const int $newValue);
void connectionEstablished(QString ifName);
void abortBoot(QString msg);
- void updateStatusLabel(QString ifName, QString status);
+ void updateIfStatus(QString ifName, QString status);
void allProcessesFinished();
void continueBoot(QString ifName, int userChoice);
void setManualConfInterfaces(QString jsonArr);
diff --git a/NetworkDiscovery/networkmanager.cpp b/NetworkDiscovery/networkmanager.cpp
index c40c83d..6f8ae7e 100644
--- a/NetworkDiscovery/networkmanager.cpp
+++ b/NetworkDiscovery/networkmanager.cpp
@@ -60,7 +60,7 @@ int NetworkManager::replaceDefaultRoute(QString ifname, QString gateway,
qDebug() << _tag << "---doRoute() gwaddr" << gwaddr;
if (!(gw = nl_addr_parse(gwaddr, af))) {
- qDebug() << _tag << "Invalid router address given:" << gwaddr;
+ qDebug() << _tag << "Invalid gateway address given:" << gwaddr;
return -1;
}
diff --git a/customdhcpcd/src/logger.c b/customdhcpcd/src/logger.c
index 70c693a..c6498ed 100644
--- a/customdhcpcd/src/logger.c
+++ b/customdhcpcd/src/logger.c
@@ -79,15 +79,23 @@ void setlogprefix(const char *prefix) {
void logger(int level, const char *fmt, ...) {
va_list p;
- va_list p2;
+ //va_list p2;
// FILE *f = stderr;
FILE *f;
char* path = "/tmp/cdhcpcd.log";
+ int size = 512;
+ char *msg = (char *) malloc (size);
f = fopen(path,"a");
va_start (p, fmt);
- va_copy (p2, p);
+ //va_copy (p2, p);
+
+
+ vsnprintf (msg, size, fmt, p);
+ strcat(msg,"\n");
+ logToQt(level, DHCPCD_LOG, msg);
+
fprintf(f, "%s, %s", leveltolog(level), logprefix);
vfprintf(f, fmt, p);
@@ -134,7 +142,7 @@ void logger(int level, const char *fmt, ...) {
// }
// }
- va_end (p2);
+ //va_end (p2);
va_end (p);
}
diff --git a/customdhcpcd/src/logwriter.c b/customdhcpcd/src/logwriter.c
index e407bc2..67cf839 100644
--- a/customdhcpcd/src/logwriter.c
+++ b/customdhcpcd/src/logwriter.c
@@ -113,6 +113,8 @@ void sendToQt(log_msg * msg) {
*/
}
+
+
void logToQt(int status, int substatus, const char * msg) {
if (retval >= 0) {
log_msg lm;
@@ -124,6 +126,8 @@ void logToQt(int status, int substatus, const char * msg) {
}
}
+
+
void logSendToQt(int type) {
switch (type) {
case DHCP_DISCOVER:
@@ -155,24 +159,7 @@ void logSendToQt(int type) {
}
}
-void logLoggerToQt(int level, const char *fmt, ...) {
- // Format string into buffer
- va_list argptr;
- va_start (argptr, fmt);
- int size = 255 + 2;
- char *string = (char *) malloc (size);
- int required = vsnprintf (string, size, fmt, argptr);
- if (required >= size)
- {
- size = required + 2;
- string = (char *) realloc (string, size);
- vsnprintf (string, size, fmt, argptr);
- }
- va_end (argptr);
-
- strcat(string, "\n");
- logToQt(level, DHCPCD_LOG, string);
-}
+
static void print_addresses (FILE *f, const struct address_head *addresses)
{
@@ -184,6 +171,9 @@ static void print_addresses (FILE *f, const struct address_head *addresses)
fprintf (f, " ");
}
}
+
+
+
void logGatewayToFile(const interface_t *iface, const dhcp_t *dhcp) {
/*void logGatewayToFile(const interface_t iface, const dhcp_t *dhcp,
const options_t options)*/
diff --git a/src/html/js/networkDiscovery.js b/src/html/js/networkDiscovery.js
index 1057bd7..bc99a7c 100644
--- a/src/html/js/networkDiscovery.js
+++ b/src/html/js/networkDiscovery.js
@@ -47,7 +47,9 @@ var showLog = function (t) {
//$("#nd_show_log_msg").attr('readonly','readonly');
$('#nd_show_log_dialog').resizable("enable");
$("#nd_show_log_dialog").dialog(
- { minWidth: 600,
+ { buttons: { "Cancel": function() {
+ $(this).dialog("close");}},
+ minWidth: 600,
maxHeight: 400,
modal: true,
draggable: false,
@@ -127,7 +129,7 @@ var ip4_manualConfigurationDialog = function () {
$("#nd_manual_configuration_dialog").dialog(
{ buttons: { "Cancel": function() {
$(this).dialog("close");},
- "Ok": function() {
+ "Continue": function() {
var bValid = true;
allFields.removeClass("ui-state-error");
@@ -239,7 +241,7 @@ var chooseInterfaceDialog = function (i) {
var updateStatus = function (s){
-
+ $("#nd_status").html(s);
};
diff --git a/src/html/networkdiscovery.css b/src/html/networkdiscovery.css
index 1d3b406..cf4121d 100644
--- a/src/html/networkdiscovery.css
+++ b/src/html/networkdiscovery.css
@@ -69,6 +69,10 @@ aside {
margin-right: auto;
}
+ .ui-button-text {
+ font-size: 10px;
+}
+
textarea {
width: 400px;
height: 200px;
diff --git a/src/html/networkdiscovery.html b/src/html/networkdiscovery.html
index b8c24cd..25efee1 100644
--- a/src/html/networkdiscovery.html
+++ b/src/html/networkdiscovery.html
@@ -35,7 +35,7 @@ $(document).ready(function() {
<div id="mainContent">
<section>
<!-- Main content area -->
- <p id="nd_status">test</p>
+ <p id="nd_status"></p>
<!-- anchor for the show log dialog -->
<div id="nd_show_log_dialog" title="Log File">
<pre id="nd_show_log_msg"></pre>
diff --git a/src/html/networkdiscovery_debug.html b/src/html/networkdiscovery_debug.html
index 5f17a0c..9d539a3 100644
--- a/src/html/networkdiscovery_debug.html
+++ b/src/html/networkdiscovery_debug.html
@@ -23,7 +23,7 @@ $(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. 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">
@@ -34,7 +34,7 @@ $(document).ready(function() {
<div id="mainContent">
<section>
<!-- Main content area -->
- <p id="nd_status">test</p>
+ <p id="nd_status"></p>
<!-- anchor for the show log dialog -->
<div id="nd_show_log_dialog" title="Log File">
<pre id="nd_show_log_msg"></pre>
diff --git a/src/ndgui.cpp b/src/ndgui.cpp
index 145cd78..ff372f2 100644
--- a/src/ndgui.cpp
+++ b/src/ndgui.cpp
@@ -24,7 +24,8 @@ ndgui::ndgui(QMainWindow *parent) :
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(updateStatusLabel(QString,QString)), this, SLOT(updateIfStatus(const QString &, 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)));
@@ -41,18 +42,20 @@ ndgui::ndgui(QMainWindow *parent) :
_webView->load(QUrl("qrc:html/networkdiscovery_userchoice_debug.html"));
}
else {
- _webView->load(QUrl("prc:html/networkdiscovery_userchoice.html"));
+ _webView->load(QUrl("qrc:html/networkdiscovery_userchoice.html"));
+
}
_webView->show();
qxtLog->debug() << _tag << "start singel shot";
- QTimer::singleShot(2000, this, SLOT(prepareNetworkDiscover()));
+ QTimer::singleShot(5000, this, SLOT(prepareNetworkDiscover()));
}
+/*destructor*/
ndgui::~ndgui() {
}
@@ -70,6 +73,8 @@ ndgui::~ndgui() {
void ndgui::setupLayout() {
// setup layout of the gui: debug split or browser
_webView = new QWebView(this);
+ _webView->setContextMenuPolicy(Qt::NoContextMenu); // if this does not work try Qt::CustomContextMenu
+
if (debugMode == 1) {
// split main window in browser & debug console
createDebugConsole();
@@ -77,8 +82,10 @@ void ndgui::setupLayout() {
_splitter->addWidget(_webView);
_splitter->addWidget(_debugConsole);
setCentralWidget(_splitter);
- } else
+ } else {
+ _webView->page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
setCentralWidget(_webView);
+ }
}
@@ -276,18 +283,25 @@ void ndgui::shutDownSystem() {
void ndgui::continueBoot(QString ifName, int userChoice) {
if (!userChoice) {
QString text = "continue with interface: " + ifName;
- qxtLog->debug() << _tag << text << "no user choice";
+ qxtLog->debug() << _tag << " " << text << "no user choice";
} else {
+ int ret = 0;
QString text = "continue with interface: " + ifName;
- qxtLog->debug() << _tag << text << "with user choice";
+ qxtLog->debug() << _tag << " " << text << " with user choice";
QString gateway = networkDiscovery.getGatewayForInterface(ifName);
- networkDiscovery.ip4_replaceDefaultRoute(ifName,gateway,0);
+ 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 ");
+ abortBoot("Interface was suddenly made unusable. Please check the log and try again.");
}
}
diff --git a/src/networkdiscovery.cpp b/src/networkdiscovery.cpp
index 13242c2..aba01b8 100644
--- a/src/networkdiscovery.cpp
+++ b/src/networkdiscovery.cpp
@@ -62,6 +62,7 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp
_numberOfProcesses = 0;
_ifUpCountdown = 10;
+
if (serverPath != DEFAULT_QTSOCKETADDRESS) {
_dhcpcdArguments.append("-q");
_dhcpcdArguments.append(serverPath);
@@ -74,9 +75,10 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp
QFile::remove(serverPath);
}
+ emit updateStatus("try to create server socket");
if (!_server->listen(serverPath)) {
// emit signal to the gui that a critial error occoured
- qxtLog->debug() << _tag << "Unable to start server: "
+ qxtLog->debug() << _tag << " Unable to start server: "
<< _server->errorString();
emit
abortBoot("Unable to start server: " + _server->errorString());
@@ -84,6 +86,7 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp
}
// check if the path to the customdhcpcd file is correct
+ emit updateStatus("check if cdhcpcd is available");
QFileInfo fInfo(_pathToDhcpcdExe);
if (!fInfo.exists()) {
qxtLog->debug() << _tag
@@ -100,256 +103,26 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp
qxtLog->debug() << _tag << "added additional args";
_dhcpcdArguments.append(*args);
}
+ emit updateStatus("start mainwork");
mainWork();
}
-/**
- * emits the addInterface signal for each interface name in _ifUpList
- * and calls the runDHCPCD method.
- * if the _ifUpList is empty, this method emits an abortBoot signal.
- * connected to the readyForRun signal.
- */
-void NetworkDiscovery::slotReadyForRun() {
- if (_ifUpList.size() > 0) {
- foreach(QString i, _ifUpList) {
- qxtLog->debug() << _tag << "emit addInterface: " << i;
- emit addInterface(i);
- }
- _numberOfProcesses = _ifUpList.size();
- runDHCPCD( _ifUpList);
- } else {
- qxtLog->debug() << _tag << "list is empty. Have not found usable interface.";
- emit
- abortBoot("Have not found usable interface");
- return;
- }
-}
-
-
-
-/**
- * only called if autoUp == true.
- * check the IsRunning flag of each interface in the _ifDownList.
- * connected to the timeout signal of the timer.
- */
-void NetworkDiscovery::checkForIsRunning() {
- bool isRunning = false;
- QList<QString> copyOfIfDownList(_ifDownList);
- foreach(QString i, _ifDownList) {
- QNetworkInterface networkInterface = QNetworkInterface::interfaceFromName(i);
- isRunning = (networkInterface.flags() & QNetworkInterface::IsRunning);
- if (isRunning) {
- _ifUpList.append(i);
- _ifDownList.removeAt(_ifDownList.indexOf(i));
- }
- }
- _ifUpCountdown--;
- if ((_ifUpCountdown <= 0 ) || _ifDownList.isEmpty()) {
- // shut down timer
- _timer->stop();
- emit readyForRun();
- }
-}
-
-
-
-/**
- * replace the default route. sets af automatically to AF_INET
- *
- * @param ifName
- * interface name
- *
- * @param gateway
- * gateway address
- *
- * @param mss
- * 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);
-}
-
-
-
-/**
- * replace the dhcp configuration with the manual config, entered by the user.
- * if we can not establish a connection with the entered values, reset to the old
- * dhcp values.
- *
- * @param result
- * a json object formated string.
- *
- * @return
- * 0 if everything ok
- */
-int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) {
- QList<QString> dns;
- dns.append(result["dns"].toString());
- _networkManager.ip4_setManualConfiguration(result["ifname"].toString(),
- result["ipaddr"].toString(),
- result["netmask"].toString(),
- result["broadcast"].toString(),
- result["gateway"].toString(),
- 0,
- AF_INET,
- "/etc/",
- dns);
-
- qxtLog->debug() << _tag << "set man conf. and check connectivity";
-
- if (!checkConnectivityViaTcp(_serverIp)) {
- qxtLog->debug() << _tag << "no connectivity. reset conf.";
- interfaceconfiguration * ifc = _ifcMap.value(result["ifname"].toString(), NULL);
- if(ifc != NULL) {
- dns.clear();
- dns = ifc->getDnsservers().trimmed().split(" ");
- _networkManager.ip4_setManualConfiguration(result["ifname"].toString(),
- ifc->getIpAddress(),
- ifc->getNetmask(),
- ifc->getBroadcast(),
- ifc->getGateway(),
- 0,
- AF_INET,
- "/etc/",
- dns);
- }
-
- return 0;
- }
- emit continueBoot(result["ifname"].toString(), 0);
- return 0;
-}
-
-
-
-/**
- * returns the gateway address, written into the dhcp config file.
- *
- * @param ifName
- * name of the interface.
- *
- * @return
- * gateway address as string.
- */
-QString NetworkDiscovery::getGatewayForInterface(QString ifName) {
- interfaceconfiguration * ifConf = _ifcMap.value(ifName);
- return ifConf->getGateway();
-}
-
-
-
-/**
- * reads the log file.
- *
- * @return the log file as one string.
- */
-QString NetworkDiscovery::readLogFile() {
- // path to log file is in _pathToLogFile. initialized in initAndRun().
- QString retval("the log file\n");
- QFile logFile(_pathToLogFile);
- if (logFile.exists()) {
- if (logFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
- while (!logFile.atEnd()) {
- retval.append(logFile.readLine());
- }
- return retval;
- }
- }
- qxtLog->debug() << _tag << " could not open log file";
-}
-
-
-
-/*
- *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() {
- // kill all cdhcpcd processes
- qxtLog->debug() << " kill cdhcpcd processes";
- QProcess * p = new QProcess(this);
- p->start("killall cdhcpcd");
- p->waitForFinished();
- qxtLog->debug() << _tag << "[tryAgain]" << p->errorString();
- /*
- foreach(Q_PID pid , _pidsList) {
- if (kill(pid,SIGKILL) <= -1)
- qDebug() << _tag << " error: trying to kill process: " << pid << " error: " << strerror(errno);
- }
- */
- // 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();
-
- //SIGK
- //kill();
-}
-
-
-
-/**/
-QVariantMap NetworkDiscovery::getInterfaceConfig(QString ifName) {
- QVariantMap jsonObj;
- QList<QString> dns;
- interfaceconfiguration * ifc = _ifcMap.value(ifName, NULL);
- if (ifc != NULL) {
- jsonObj.insert("ipaddr",ifc->getIpAddress());
- jsonObj.insert("netmask",ifc->getNetmask());
- jsonObj.insert("broadcast",ifc->getBroadcast());
- jsonObj.insert("gateway",ifc->getGateway());
-
- dns.clear();
- dns = ifc->getDnsservers().trimmed().split(" ");
- jsonObj.insert("dns",dns.first());
-//
-// dns.clear();
-// dns = ifc->getDnsservers().trimmed().split(" ");
-//
-// //ifc->getIpAddress(), ifc->getNetmask(), ifc->getBroadcast(),
-// //ifc->getGateway(), 0, AF_INET, "/etc/", dns);
-//
- }
- return jsonObj;
-}
-
-
-
-/**
- * ================================================================================
- ********************************* Private Methods ********************************
- * ================================================================================
- **/
-
-
/**/
void NetworkDiscovery::mainWork()
{
if (_autoUp) {
+ emit updateStatus("search for usable interfaces (with auto Up)");
getListOfNetworkInterfacesWithAutoUp();
- _timer = new QTimer(this);
- connect(_timer, SIGNAL(timeout()), this, SLOT(checkForIsRunning()));
- _timer->start(1000);
-
} else {
+ emit updateStatus("search for usable interfaces");
getListOfNetworkInterfaces();
- emit readyForRun();
}
+ emit updateStatus("check if interfaces are in running state");
+ _timer = new QTimer(this);
+ connect(_timer, SIGNAL(timeout()), this, SLOT(checkForIsRunning()));
+ _timer->start(1000);
}
@@ -368,19 +141,19 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() {
{
qxtLog->debug() << _tag << "found Interface:" << nI.humanReadableName();
if ((nI.flags() & QNetworkInterface::CanBroadcast)) {
- qxtLog->debug() << _tag << "flags: can broadcast";
+ qxtLog->debug() << _tag << " flags: can broadcast ";
}
if ((nI.flags() & QNetworkInterface::IsLoopBack)) {
- qxtLog->debug() << _tag << "flags: is LoopBack";
+ qxtLog->debug() << _tag << " flags: is LoopBack ";
}
if ((nI.flags() & QNetworkInterface::IsPointToPoint)) {
- qxtLog->debug() << _tag << "flags: is Point to Point";
+ qxtLog->debug() << _tag << " flags: is Point to Point ";
}
if ((nI.flags() & QNetworkInterface::IsRunning)) {
- qxtLog->debug() << _tag << "flags: is Running";
+ qxtLog->debug() << _tag << " flags: is Running ";
}
if ((nI.flags() & QNetworkInterface::IsUp)) {
- qxtLog->debug() << _tag << "flags: is Up";
+ qxtLog->debug() << _tag << " flags: is Up ";
}
if (((!(nI.flags() & QNetworkInterface::CanBroadcast)
@@ -394,7 +167,7 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() {
}
else if (!(nI.flags() & QNetworkInterface::IsUp)) {
_networkManager.bringInterfaceUP(nI.humanReadableName());
- qxtLog->debug() << _tag << " bring up ..";
+ qxtLog->debug() << _tag << " bring up: " << nI.humanReadableName() ;
_ifDownList.append(nI.humanReadableName());
}
else if (!(nI.flags() & QNetworkInterface::IsRunning)) {
@@ -402,7 +175,7 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() {
}
}
} else {
- qxtLog->debug() << _tag << "no interfaces found!";
+ qxtLog->debug() << _tag << " no interfaces found! ";
}
}
@@ -418,7 +191,23 @@ void NetworkDiscovery::getListOfNetworkInterfaces() {
if (nIList.size() > 0) {
foreach(QNetworkInterface nI, nIList)
{
- qxtLog->debug() << _tag << "found Interface:" << nI.humanReadableName();
+ qxtLog->debug() << _tag << "found Interface:"
+ << nI.humanReadableName();
+ if ((nI.flags() & QNetworkInterface::CanBroadcast)) {
+ qxtLog->debug() << _tag << " flags: can broadcast ";
+ }
+ if ((nI.flags() & QNetworkInterface::IsLoopBack)) {
+ qxtLog->debug() << _tag << " flags: is LoopBack ";
+ }
+ if ((nI.flags() & QNetworkInterface::IsPointToPoint)) {
+ qxtLog->debug() << _tag << " flags: is Point to Point ";
+ }
+ if ((nI.flags() & QNetworkInterface::IsRunning)) {
+ qxtLog->debug() << _tag << " flags: is Running ";
+ }
+ if ((nI.flags() & QNetworkInterface::IsUp)) {
+ qxtLog->debug() << _tag << " flags: is Up ";
+ }
if (((!(nI.flags() & QNetworkInterface::CanBroadcast)
|| nI.flags() & QNetworkInterface::IsLoopBack)
|| nI.flags() & QNetworkInterface::IsPointToPoint)
@@ -433,58 +222,59 @@ void NetworkDiscovery::getListOfNetworkInterfaces() {
}
}
} else {
- qxtLog->debug() << _tag << "no interfaces found!";
+ qxtLog->debug() << _tag << " no interfaces found! ";
}
}
/**
- * not used so far. checks the carrier state using the sysfs library.
- * if carrier = 1 ==> the interface is running.
- * interfaces have to be up in order to get right results.
- *
- * @param interface
- * name of the interface
+ * only called if autoUp == true.
+ * check the IsRunning flag of each interface in the _ifDownList.
+ * connected to the timeout signal of the timer.
*/
-bool NetworkDiscovery::checkCarrierState(QString interface) {
+void NetworkDiscovery::checkForIsRunning() {
+ bool isRunning = false;
+ foreach(QString i, _ifDownList) {
+ QNetworkInterface networkInterface = QNetworkInterface::interfaceFromName(i);
+ isRunning = (networkInterface.flags() & QNetworkInterface::IsRunning);
+ if (isRunning) {
+ _ifUpList.append(i);
+ _ifDownList.removeAt(_ifDownList.indexOf(i));
+ }
+ }
+ _ifUpCountdown--;
+ if ((_ifUpCountdown <= 0 ) || _ifDownList.isEmpty()) {
+ // shut down timer
+ _timer->stop();
+ delete _timer;
+ emit readyForRun();
+ }
+}
- qxtLog->debug() << _tag << "check carrier state for interface " << interface;
- QByteArray ba = interface.toAscii();
- const char * iface = ba.data();
- struct sysfs_class_device *class_device = sysfs_open_class_device("net",
- iface);
- struct dlist *attrlist = sysfs_get_classdev_attributes(class_device);
- if (attrlist != NULL) {
- struct sysfs_attribute *attr = NULL;
- dlist_for_each_data(attrlist, attr, struct sysfs_attribute) {
- if (strcmp("carrier", attr->name) == 0) {
- QString value(attr->value);
- bool ok = false;
- bool * pok = &ok;
- int v = value.toInt(pok);
- if (*pok) {
- if (v == 1) {
- qxtLog->debug()
- << "carrier is 1. Cable is plugged. return true";
- return true;
- } else {
- qxtLog->debug()
- << "carrier is 0. Cable is unplugged. return false";
- return false;
- }
- } else {
- qxtLog->debug() << _tag << "conversion error";
- }
- }
+
+/**
+ * emits the addInterface signal for each interface name in _ifUpList
+ * and calls the runDHCPCD method.
+ * if the _ifUpList is empty, this method emits an abortBoot signal.
+ * connected to the readyForRun signal.
+ */
+void NetworkDiscovery::slotReadyForRun() {
+ if (_ifUpList.size() > 0) {
+ foreach(QString i, _ifUpList) {
+ qxtLog->debug() << _tag << " emit addInterface : " << i;
+ emit addInterface(i);
}
+ _numberOfProcesses = _ifUpList.size();
+ emit updateStatus("start dhcp client for each interface");
+ runDHCPCD( _ifUpList);
} else {
- qxtLog->debug() << _tag << "attrlist is Null";
+ qxtLog->debug() << _tag << " list is empty. Have not found usable interface. ";
+ emit
+ abortBoot("Have not found usable interface");
+ return;
}
- sysfs_close_class_device(class_device);
-
- return true;
}
@@ -511,11 +301,11 @@ void NetworkDiscovery::runDHCPCD(QList<QString> &interfaces) {
* name of an interface.
*/
void NetworkDiscovery::runDHCPCD(QString interface) {
- emit updateStatusLabel(interface, "start DHCP");
+ emit updateIfStatus(interface, "start DHCP");
_dhcpcdArguments.append(interface);
QProcess * p = new QProcess(this);
- qxtLog->debug() << _tag << _dhcpcdArguments;
+ qxtLog->debug() << _tag << " start cdhcpcd with arguments: " << _dhcpcdArguments;
_clientProcessToIfNameMap.insert(p, interface);
p->start(_pathToDhcpcdExe, _dhcpcdArguments);
@@ -528,6 +318,88 @@ void NetworkDiscovery::runDHCPCD(QString interface) {
/**
+ * This Method is called when a process is started.
+ *
+ * This Method is called when a process is started.
+ * It prints the message: "process started for interface: <interfaceName>".
+ */
+void NetworkDiscovery::handleProcessStarted() {
+ QProcess* p = qobject_cast<QProcess *> (QObject::sender());
+ QString ifName = _clientProcessToIfNameMap.value(p, "ifName");
+ qxtLog->debug() << _tag << " process started for interface: " << ifName;
+}
+
+
+
+/**
+ * This Method is called when a process is finished.
+ *
+ * This Method is called when a process is finished. This slot is connected
+ * with the signal finished() of the QProcess class.
+ * If the process finishes, it will be checked if the process exited normal
+ * or if an unexpected error occurred. For this, we determine the sender (which is a
+ * QProcess), get the corresponding interface (which is stored in a map), and check
+ * the exitCode. Further actions are taken according to the exitCode check.
+ * Normal exit:
+ * emit changeProgressBar() to 100%
+ * emit updateIfStatus() to check connection
+ * 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
+ *
+ * @param exitStatus
+ *
+ * @return bool
+ * returns true: if the interface name i starts with a letter in the blacklist.
+ *
+ * returns false: else
+ *
+ * @see NetworkDiscovery::getListOfNetworkInterfaces()
+ */
+void NetworkDiscovery::handleProcessFinished(int exitCode,
+ QProcess::ExitStatus exitStatus) {
+
+ QProcess* p = qobject_cast<QProcess *> (QObject::sender());
+ QString ifName = _clientProcessToIfNameMap.value(p, "ifName");
+ _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!";
+ } else {
+ 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());
+ } else {
+ qxtLog->debug() << _tag << " process normal exit ";
+ emit changeProgressBarValue(ifName, 100);
+ emit updateIfStatus(ifName, "check connectivity");
+ checkConnectivity(ifName);
+ }
+ }
+ 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);
+ }
+ //_numberOfProcesses = _numberOfProcesses - 1; && _userChoice
+ if (_numberOfProcesses <= 0 ) {
+ emit allProcessesFinished();
+ }
+ }
+ } else {
+ qxtLog->debug() << _tag << " already blocked";
+ emit updateIfStatus(ifName, "finished DHCP");
+ }
+}
+
+
+
+/**
* checks the connectivity. tries to open a TCP connection to the
* server (see _serverIp). For this it adjusts the routing table.
* (sets the gateway of the interface as default gateway)
@@ -557,9 +429,9 @@ bool NetworkDiscovery::checkConnectivity(QString ifName) {
ifConf->getGateway(), mss, AF_INET);
if (checkConnectivityViaTcp(_serverIp)) {
- qxtLog->debug() << _tag << "internet: check passed! for interface" << ifName;
+ qxtLog->debug() << _tag << " passed connectivity check! for interface " << ifName;
emit
- updateStatusLabel(ifName, "connection possible");
+ updateIfStatus(ifName, "connection possible");
if (!_userChoice) {
// blockiere jeden weiteren check
// emite continueBoot
@@ -570,9 +442,9 @@ bool NetworkDiscovery::checkConnectivity(QString ifName) {
}
return true;
} else {
- qxtLog->debug() << _tag << "no internet connection with interface" << ifName;
+ qxtLog->debug() << _tag << " failed connectivity check! for interface " << ifName;
emit
- updateStatusLabel(ifName, "connection not possible");
+ updateIfStatus(ifName, "connection not possible");
return false;
}
}
@@ -611,38 +483,6 @@ bool NetworkDiscovery::checkConnectivityViaTcp(QString server) {
/**
- * connected to the new client arrived signal.
- * connects the client readyRead signal with the handleNewInput slot.
- */
-void NetworkDiscovery::handleNewConnection() {
- qxtLog->debug() << _tag << "New Connection arrived";
-
- /*QLocalSocket **/
- _client = _server ->nextPendingConnection();
- _clients.insert(_client, _client);
- connect(_client, SIGNAL(disconnected()), this,
- SLOT(handleClientDisconnect()));
- connect(_client, SIGNAL(readyRead()), this, SLOT(handleNewInput()));
-}
-
-
-
-/**
- * called when a client disconnects.
- */
-void NetworkDiscovery::handleClientDisconnect() {
- QLocalSocket* socket = qobject_cast<QLocalSocket *> (QObject::sender());
-
- QLocalSocket * client = _clients.value(socket);
-
- qxtLog->debug() << _tag << "disconnect client";
- handleNewInput(client);
- client->deleteLater();
-}
-
-
-
-/**
* same function as handleNewInput() but with a client as parameter.
*
* @param cleint
@@ -675,12 +515,8 @@ void NetworkDiscovery::handleNewInput() {
QLocalSocket * client = _clients.value(socket);
QString data(client->read(DHCP_MESSAGE_SIZE));
- //client->write("ACK", ACK_SIZE);
- //client->waitForBytesWritten();
data = data.trimmed();
- //qxtLog->debug() << _tag << data;
QStringList lines = data.split("\n");
-
for (int i = 0; i < lines.length(); i++) {
handleNewInputLine(client, lines.at(i));
}
@@ -772,17 +608,17 @@ void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString data) {
qxtLog->debug() << _tag << " " << interface << " exiting";
break;
case DHCPCD_LOG:
-
+ qxtLog->debug() << _tag << " received dhcpcd log: " << msg;
default:
- qxtLog->debug() << _tag << " received error:" << msg;
+ qxtLog->debug() << _tag << " received unknown substatus: " << msg;
break;
}
break;
case LOG_ERR:
- qxtLog->debug() << _tag << " received error:" << msg;
+ qxtLog->debug() << _tag << " received error: " << msg;
break;
default:
- qxtLog->debug() << _tag << logMsg;
+ qxtLog->debug() << _tag << " " << logMsg;
break;
}
}
@@ -790,83 +626,208 @@ void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString data) {
/**
- * This Method is called when a process is finished.
+ * replace the default route. sets af automatically to AF_INET
*
- * This Method is called when a process is finished. This slot is connected
- * with the signal finished() of the QProcess class.
- * If the process finishes, it will be checked if the process exited normal
- * or if an unexpected error occurred. For this, we determine the sender (which is a
- * QProcess), get the corresponding interface (which is stored in a map), and check
- * the exitCode. Further actions are taken according to the exitCode check.
- * Normal exit:
- * emit changeProgressBar() to 100%
- * emit updateStatusLabel() to check connection
- * checkConnectivity() @see NetworkDiscovery::checkConnectivity()
- * Unexpected exit:
- * emit updateStatusLabel() to process exited unexpected
- * TODO:: the reason for the unexpected exit should be presented in the logfile.
+ * @param ifName
+ * interface name
*
- * @param exitCode
+ * @param gateway
+ * gateway address
*
- * @param exitStatus
+ * @param mss
+ * 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);
+}
+
+
+
+/**
+ * replace the dhcp configuration with the manual config, entered by the user.
+ * if we can not establish a connection with the entered values, reset to the old
+ * dhcp values.
*
- * @return bool
- * returns true: if the interface name i starts with a letter in the blacklist.
+ * @param result
+ * a json object formated string.
*
- * returns false: else
+ * @return
+ * 0 if everything ok
+ */
+int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) {
+ QList<QString> dns;
+ dns.append(result["dns"].toString());
+ _networkManager.ip4_setManualConfiguration(result["ifname"].toString(),
+ result["ipaddr"].toString(), result["netmask"].toString(),
+ result["broadcast"].toString(), result["gateway"].toString(), 0,
+ AF_INET, "/etc/", dns);
+
+ qxtLog->debug() << _tag << "set man conf. and check connectivity";
+
+ if (!checkConnectivityViaTcp(_serverIp)) {
+ qxtLog->debug() << _tag << "no connectivity. reset conf.";
+ interfaceconfiguration * ifc = _ifcMap.value(
+ result["ifname"].toString(), NULL);
+ if (ifc != NULL) {
+ dns.clear();
+ dns = ifc->getDnsservers().trimmed().split(" ");
+ _networkManager.ip4_setManualConfiguration(
+ result["ifname"].toString(), ifc->getIpAddress(),
+ ifc->getNetmask(), ifc->getBroadcast(), ifc->getGateway(),
+ 0, AF_INET, "/etc/", dns);
+ }
+
+ return 0;
+ } emit
+ continueBoot(result["ifname"].toString(), 0);
+ return 0;
+}
+
+
+
+/**
+ * returns the gateway address, written into the dhcp config file.
*
- * @see NetworkDiscovery::getListOfNetworkInterfaces()
+ * @param ifName
+ * name of the interface.
+ *
+ * @return
+ * gateway address as string. or empty string if no interface config was found.
*/
-void NetworkDiscovery::handleProcessFinished(int exitCode,
- QProcess::ExitStatus exitStatus) {
+QString NetworkDiscovery::getGatewayForInterface(QString ifName) {
+ interfaceconfiguration * ifConf = _ifcMap.value(ifName, NULL);
+ if (ifConf != NULL)
+ {
+ return ifConf->getGateway();
+ }
+ else {
+ qxtLog->debug() << _tag << " could not find interface configuration";
+ return "";
+ }
- QProcess* p = qobject_cast<QProcess *> (QObject::sender());
- QString ifName = _clientProcessToIfNameMap.value(p, "ifName");
- _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 << "--- \t [NetworkDiscovery::handleProcessFinished] haven't found process!";
- } else {
- qxtLog->debug() << _tag << " process for interface " << ifName << " finished "
- << " exit code: " << exitCode << " exit status " << exitStatus;
- if (exitCode > 0) {
- qxtLog->debug() << _tag << "process exited unexpected";
- emit updateStatusLabel(ifName, "process exited unexpected");
- } else {
- qxtLog->debug() << _tag << "process normal exit";
- emit changeProgressBarValue(ifName, 100);
- emit updateStatusLabel(ifName, "check connectivity");
- checkConnectivity(ifName);
+}
+
+
+
+/**
+ * reads the log file.
+ *
+ * @return the log file as one string.
+ */
+QString NetworkDiscovery::readLogFile() {
+ // path to log file is in _pathToLogFile. initialized in initAndRun().
+ QString retval("the log file\n");
+ QFile logFile(_pathToLogFile);
+ if (logFile.exists()) {
+ if (logFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ while (!logFile.atEnd()) {
+ retval.append(logFile.readLine());
}
}
- 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);
- }
- //_numberOfProcesses = _numberOfProcesses - 1; && _userChoice
- if (_numberOfProcesses <= 0 ) {
- emit allProcessesFinished();
- }
+ else {
+ qxtLog->debug() << _tag << " could not open log file";
+ retval = "could not open log file";
}
- } else {
- qxtLog->debug() << _tag << "already blocked";
- emit updateStatusLabel(ifName, "finished DHCP");
}
+ else {
+ qxtLog->debug() << _tag << " log file does not exist at: " << _pathToLogFile;
+ retval = " log file does not exist at: " + _pathToLogFile;
+ }
+ return retval;
+
+}
+
+
+
+/*
+ *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() {
+ // 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();
+
+ delete p;
+ /*
+ foreach(Q_PID pid , _pidsList) {
+ if (kill(pid,SIGKILL) <= -1)
+ qDebug() << _tag << " error: trying to kill process: " << pid << " error: " << strerror(errno);
+ }
+ */
+ // 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();
+}
+
+
+
+/**/
+QVariantMap NetworkDiscovery::getInterfaceConfig(QString ifName) {
+ QVariantMap jsonObj;
+ QList<QString> dns;
+ interfaceconfiguration * ifc = _ifcMap.value(ifName, NULL);
+ if (ifc != NULL) {
+ jsonObj.insert("ipaddr",ifc->getIpAddress());
+ jsonObj.insert("netmask",ifc->getNetmask());
+ jsonObj.insert("broadcast",ifc->getBroadcast());
+ jsonObj.insert("gateway",ifc->getGateway());
+
+ dns.clear();
+ dns = ifc->getDnsservers().trimmed().split(" ");
+ jsonObj.insert("dns",dns.first());
+ }
+ return jsonObj;
}
/**
- * This Method is called when a process is started.
- *
- * This Method is called when a process is started.
- * It prints the message: "process started for interface: <interfaceName>".
+ * connected to the new client arrived signal.
+ * connects the client readyRead signal with the handleNewInput slot.
*/
-void NetworkDiscovery::handleProcessStarted() {
- QProcess* p = qobject_cast<QProcess *> (QObject::sender());
- QString ifName = _clientProcessToIfNameMap.value(p, "ifName");
- qxtLog->debug() << _tag << "process started for interface:" << ifName;
+void NetworkDiscovery::handleNewConnection() {
+ qxtLog->debug() << _tag << "New Connection arrived";
+
+ /*QLocalSocket **/
+ _client = _server->nextPendingConnection();
+ _clients.insert(_client, _client);
+ connect(_client, SIGNAL(disconnected()), this,
+ SLOT(handleClientDisconnect()));
+ connect(_client, SIGNAL(readyRead()), this, SLOT(handleNewInput()));
+}
+
+
+
+/**
+ * called when a client disconnects.
+ */
+void NetworkDiscovery::handleClientDisconnect() {
+ QLocalSocket* socket = qobject_cast<QLocalSocket *> (QObject::sender());
+
+ QLocalSocket * client = _clients.value(socket);
+
+ qxtLog->debug() << _tag << "disconnect client";
+ handleNewInput(client);
+ client->deleteLater();
}
@@ -898,3 +859,55 @@ bool NetworkDiscovery::checkBlackList(QString i) {
return false;
}
}
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * not used so far. checks the carrier state using the sysfs library.
+ * if carrier = 1 ==> the interface is running.
+ * interfaces have to be up in order to get right results.
+ *
+ * @param interface
+ * name of the interface
+ */
+bool NetworkDiscovery::checkCarrierState(QString interface) {
+
+ qxtLog->debug() << _tag << "check carrier state for interface " << interface;
+ QByteArray ba = interface.toAscii();
+ const char * iface = ba.data();
+
+ struct sysfs_class_device *class_device = sysfs_open_class_device("net",
+ iface);
+ struct dlist *attrlist = sysfs_get_classdev_attributes(class_device);
+ if (attrlist != NULL) {
+ struct sysfs_attribute *attr = NULL;
+ dlist_for_each_data(attrlist, attr, struct sysfs_attribute) {
+ if (strcmp("carrier", attr->name) == 0) {
+ QString value(attr->value);
+ bool ok = false;
+ bool * pok = &ok;
+ int v = value.toInt(pok);
+ if (*pok) {
+ if (v == 1) {
+ qxtLog->debug()
+ << "carrier is 1. Cable is plugged. return true";
+ return true;
+ } else {
+ qxtLog->debug()
+ << "carrier is 0. Cable is unplugged. return false";
+ return false;
+ }
+ } else {
+ qxtLog->debug() << _tag << "conversion error";
+ }
+ }
+ }
+ } else {
+ qxtLog->debug() << _tag << "attrlist is Null";
+ }
+ sysfs_close_class_device(class_device);
+
+ return true;
+}
diff --git a/src/networkdiscovery.h b/src/networkdiscovery.h
index 3e34e7d..d49bc19 100644
--- a/src/networkdiscovery.h
+++ b/src/networkdiscovery.h
@@ -65,7 +65,8 @@ signals:
void changeProgressBarValue(const QString & ifName, const int $newValue);
void connectionEstablished(QString ifName);
void abortBoot(QString msg);
- void updateStatusLabel(QString ifName, QString status);
+ void updateIfStatus(QString ifName, QString status);
+ void updateStatus(QString status);
void allProcessesFinished();
void continueBoot(QString ifName, int userChoice);
void setManualConfInterfaces(QString jsonArr);