diff options
author | Niklas | 2011-10-19 17:00:58 +0200 |
---|---|---|
committer | Niklas | 2011-10-19 17:00:58 +0200 |
commit | 54e31640362a7a995dd49f100eee9550d745e58f (patch) | |
tree | 04fbf5a34cf1d98c53a4a766da023e9f6843dcd6 /src | |
parent | small changes in the networkmanager. added some ipv6 methods for adding a rou... (diff) | |
download | fbgui-54e31640362a7a995dd49f100eee9550d745e58f.tar.gz fbgui-54e31640362a7a995dd49f100eee9550d745e58f.tar.xz fbgui-54e31640362a7a995dd49f100eee9550d745e58f.zip |
put the NetworkDiscovery code into the src folder of the fbgui. made some test, building a usb stick iso and running it on a maschine. did some bug fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/fbgui.pro | 20 | ||||
-rw-r--r-- | src/html/js/networkDiscovery.js | 19 | ||||
-rw-r--r-- | src/html/networkdiscovery.css | 3 | ||||
-rw-r--r-- | src/html/networkdiscovery.html | 8 | ||||
-rw-r--r-- | src/main.cpp | 7 | ||||
-rw-r--r-- | src/ndgui.cpp | 35 | ||||
-rw-r--r-- | src/ndgui.h | 1 | ||||
-rw-r--r-- | src/networkdiscovery.cpp | 135 | ||||
-rw-r--r-- | src/networkdiscovery.h | 4 |
9 files changed, 158 insertions, 74 deletions
diff --git a/src/fbgui.pro b/src/fbgui.pro index c18e022..701402b 100644 --- a/src/fbgui.pro +++ b/src/fbgui.pro @@ -12,12 +12,20 @@ LIBS += -L/usr/local/qjson/lib \ -lQxtCore \ -L/usr/lib \ -lsysfs \ - -lusb-1.0 + -lnl \ + -lusb-1.0 \ + -L/usr/local/lib \ + -lcustomdhcpcd INCLUDEPATH += /usr/local/qjson/include \ /usr/local/Qxt/include \ /usr/local/Qxt/include/QxtCore \ /usr/include/sysfs \ - /usr/include/libusb-1.0 + /usr/include/libusb-1.0 \ + /usr/include/net \ + /usr/include/netlink \ + /usr/include/netlink/route \ + /usr/include/arpa \ + ./../customdhcpcd/src HEADERS += ../common/fbgui.h \ downloadmanager.h \ fbgui.h \ @@ -27,8 +35,12 @@ HEADERS += ../common/fbgui.h \ ndgui.h \ networkdiscovery.h \ networkmanager.h \ - sysinfo.h \ -SOURCES += sysinfo.cpp \ + sysinfo.h +SOURCES += networkdiscovery.cpp \ + networkmanager.cpp \ + ndgui.cpp \ + interfaceconfiguration.cpp \ + sysinfo.cpp \ loggerengine.cpp \ javascriptinterface.cpp \ downloadmanager.cpp \ diff --git a/src/html/js/networkDiscovery.js b/src/html/js/networkDiscovery.js index 2200d82..1d67eac 100644 --- a/src/html/js/networkDiscovery.js +++ b/src/html/js/networkDiscovery.js @@ -31,20 +31,23 @@ var checkRegexp = function ( o, regexp, n ) { }; var showLog = function (t) { - $("#nd_show_log_msg").val(t); - $("#nd_show_log_msg").attr('readonly','readonly'); + $("#nd_show_log_msg").html(t); + //$("#nd_show_log_msg").attr('readonly','readonly'); $("#nd_show_log_dialog").dialog( { minWidth: 450, modal: true, - resizable: false, draggable: false }); }; +var getInterfaceConf = function (i) { + var n = i.options[i.selectedIndex].text(); +}; + var ip4_manualConfigurationDialog = function () { var jsonArr = fbgui.getManualConfInterfaces(); //jsonArr = eval('(' + jsonArr + ')'); - var c = "<select name='nd_mc_ifname_select' id='nd_mc_ifname_select'>"; + var c = "<select name='nd_mc_ifname_select' id='nd_mc_ifname_select' onChange='getInterfaceConf(this)'>"; if(jsonArr == "") { c += "<option>NO INTERFACE</option>"; } else { @@ -118,12 +121,13 @@ var abortBootDialog = function (m) { ip4_manualConfigurationDialog();}, "Show Log": function() { var text = fbgui.readLogFile(); - showLog(text); - $(this).dialog("close");}, + showLog(text);}, "Restart": function() {fbgui.restartSystem(); $(this).dialog("close"); }, "Shut Down": function() { fbgui.shutDownSystem(); - $(this).dialog("close"); } + $(this).dialog("close"); }, + "Try Again": function() {fbgui.tryAgain(); + $(this).dialog("close"); } } , minWidth: 450, modal: true, @@ -137,6 +141,7 @@ var chooseInterfaceDialog = function (i) { var cb = "<label> Choose your interface: </label>"+ "<select id='nd_ifName_select'>"; jQuery.each(i, function() { + updateIfProgressBar(this, 100); cb += " <option>"+ this +"</option>"; } ); diff --git a/src/html/networkdiscovery.css b/src/html/networkdiscovery.css index 669ad58..a111ef6 100644 --- a/src/html/networkdiscovery.css +++ b/src/html/networkdiscovery.css @@ -66,7 +66,8 @@ aside { textarea { width: 400px; - resize: none; + height: 200px; + /*resize: none;*/ } h1 { diff --git a/src/html/networkdiscovery.html b/src/html/networkdiscovery.html index f6f50e4..1f24b0d 100644 --- a/src/html/networkdiscovery.html +++ b/src/html/networkdiscovery.html @@ -5,9 +5,9 @@ <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/networkDiscovery.js"></script> --> - +<script type="text/javascript" src="qrc:/html/js/networkDiscovery.js"></script> +<!-- <script type="text/javascript"> var updateTips = function ( t ) { @@ -208,7 +208,7 @@ var addInterface = function (i){ }; </script> - +--> </head> <body> <header> @@ -229,7 +229,7 @@ var addInterface = function (i){ <p>test</p> <!-- anchor for the show log dialog --> <div id="nd_show_log_dialog" title="Log File"> - <textarea id="nd_show_log_msg"></textarea> + <pre id="nd_show_log_msg"></pre> </div> <!-- anchor for the abort boot dialog --> <div id="nd_abort_boot_dialog" title="Abort Boot"> diff --git a/src/main.cpp b/src/main.cpp index 21983ca..e408a33 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -175,12 +175,13 @@ int main(int argc, char *argv[]) { else logFilePath = DEFAULT_LOG_FILE_PATH; - // activate file logger if debug mode activated. - if (debugMode > -1) { + // write always a log file + // // activate file logger if debug mode activated. + // if (debugMode > -1) { // start debug logging to file. qxtLog->addLoggerEngine("file_logger", new LoggerEngine_file(logFilePath)); qxtLog->setMinimumLevel("file_logger", QxtLogger::DebugLevel); - } + // } // print config qxtLog->debug() << "************* CONFIG INFO *************"; diff --git a/src/ndgui.cpp b/src/ndgui.cpp index 80a64bc..8daef9e 100644 --- a/src/ndgui.cpp +++ b/src/ndgui.cpp @@ -25,10 +25,12 @@ ndgui::ndgui(QMainWindow *parent) : setWindowTitle(tr("NetD")); setAttribute(Qt::WA_QuitOnClose, true); setWindowFlags(Qt::FramelessWindowHint); + showFullScreen(); _webView->load(QUrl("qrc:html/networkdiscovery_userchoice.html")); _webView->show(); - + + qxtLog->debug() << _tag << "start singel shot"; QTimer::singleShot(2000, this, SLOT(prepareNetworkDiscover())); } @@ -92,10 +94,13 @@ void ndgui::startNetworkDiscovery(){ disconnect(_webView,SIGNAL(loadFinished(bool)), this, SLOT(startNetworkDiscovery())); if(!_started) { _started = true; - networkDiscovery.initAndRun("209.85.148.105", _userChoice, true, "/var/tmp/logfile","/var/tmp/qt_c_socket_custom"); + qxtLog->debug() << _tag << "Initializing networkDiscovery ..."; + QStringList l; + l << "-d"; + networkDiscovery.initAndRun("209.85.148.105", _userChoice, true, "/tmp/fbgui.log","/var/tmp/qt_c_socket_custom", "/bin/cdhcpcd", &l); } else { - qDebug() << _tag << "NetworkDiscovery already started"; + qxtLog->debug() << _tag << "NetworkDiscovery already started"; } } @@ -122,7 +127,7 @@ void ndgui::handleConnectionEstablished(QString ifName) { * handleConnectionEstablished)). */ void ndgui::handleAllProcessesFinished() { - qDebug() << _tag << "all Processes finished"; + qxtLog->debug() << _tag << "all Processes finished"; if(_ifNameList.size() > 0) { QString jsonArr = "["; for(int i = 0; i < _ifNameList.size()-1; i++) { @@ -177,10 +182,10 @@ void ndgui::shutDownSystem() { void ndgui::continueBoot(QString ifName, int userChoice) { if (!userChoice) { QString text = "continue with interface: " + ifName; - qDebug() << _tag << text << "no user choice"; + qxtLog->debug() << _tag << text << "no user choice"; } else { QString text = "continue with interface: " + ifName; - qDebug() << _tag << text << "with user choice"; + qxtLog->debug() << _tag << text << "with user choice"; QString gateway = networkDiscovery.getGatewayForInterface(ifName); networkDiscovery.ip4_replaceDefaultRoute(ifName,gateway,0); } @@ -195,12 +200,20 @@ void ndgui::continueBoot(QString ifName, int userChoice) { * read the log file. Log File will be presented inside of a dialog. */ QString ndgui::readLogFile() { - qDebug() << _tag << "show log"; + qxtLog->debug() << _tag << "show log"; return networkDiscovery.readLogFile(); } +/**/ +void ndgui::tryAgain() { + qxtLog->debug() << _tag << "try again"; + +} + + + /*test html gui version*/ /** @@ -208,13 +221,13 @@ QString ndgui::readLogFile() { * dialog. */ QVariantList ndgui::getManualConfInterfaces() { - qDebug() << _tag << "call getManualConfInterfaces"; + qxtLog->debug() << _tag << "call getManualConfInterfaces"; QVariantList jsonArr; foreach (QString s, _manConfList) { QVariant e(s); jsonArr << e; } - qDebug() << _tag << "value of jsonArr:" << jsonArr; + qxtLog->debug() << _tag << "value of jsonArr:" << jsonArr; return jsonArr; } @@ -257,7 +270,7 @@ void ndgui::loadJQuery() { foreach(fi, fiList) { if (fi.suffix() == "js") { - //qDebug()<< fi.fileName(); + //qxtLog->debug()<< fi.fileName(); //qxtLog->debug() << fi.fileName(); //if (fi.fileName() != "test.js" && fi.fileName() != "nd-functions.js") { QFile file; @@ -366,5 +379,5 @@ void ndgui::addInterface(const QString &ifName) { * just for debugging. */ void ndgui::notifyCall(QString msg){ - qDebug() << _tag << "------ called:" << msg; + qxtLog->debug() << _tag << "------ called:" << msg; } diff --git a/src/ndgui.h b/src/ndgui.h index eb30d7a..ab1f82b 100644 --- a/src/ndgui.h +++ b/src/ndgui.h @@ -27,6 +27,7 @@ public slots: void restartSystem(); void shutDownSystem(); void continueBoot(QString ifName, int userChoice); + void tryAgain(); void prepareNetworkDiscover(); diff --git a/src/networkdiscovery.cpp b/src/networkdiscovery.cpp index da2cb1d..94d1f63 100644 --- a/src/networkdiscovery.cpp +++ b/src/networkdiscovery.cpp @@ -73,7 +73,7 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp if (!_server->listen(serverPath)) { // emit signal to the gui that a critial error occoured - qDebug() << _tag << "Unable to start server: " + qxtLog->debug() << _tag << "Unable to start server: " << _server->errorString(); emit abortBoot("Unable to start server: " + _server->errorString()); @@ -83,8 +83,8 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp // check if the path to the customdhcpcd file is correct QFileInfo fInfo(_pathToDhcpcdExe); if (!fInfo.exists()) { - qDebug() << _tag - << "could not find customdhcpcd exe. Please check the path to this file."; + qxtLog->debug() << _tag + << " could not find customdhcpcd exe. Please check the path to this file."; emit abortBoot( "could not find customdhcpcd exe. Please check the path to this file."); return; @@ -94,21 +94,27 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp connect(this, SIGNAL(readyForRun()), this, SLOT(slotReadyForRun())); if (args != NULL && !args->isEmpty()) { - qDebug() << _tag << "added additional args"; + qxtLog->debug() << _tag << "added additional args"; _dhcpcdArguments.append(*args); } // start the main work: if (_autoUp) { + qxtLog->debug() << _tag << " call getListOfNetworkInterfacesWithAutoUp ..."; getListOfNetworkInterfacesWithAutoUp(); - _timer = new QTimer(this); - connect(_timer, SIGNAL(timeout()), this, SLOT(checkForIsRunning())); - _timer->start(1000); + qxtLog->debug() << _tag << " ifUpList size: " << _ifUpList.size(); + qxtLog->debug() << _tag << " ifDownList size: " << _ifDownList.size(); } else { + qxtLog->debug() << _tag << " call getListOfNetworkInterfaces ..."; getListOfNetworkInterfaces(); - emit readyForRun(); } + + qxtLog->debug() << _tag << " init timer ..."; + _timer = new QTimer(this); + qxtLog->debug() << _tag << " call checkForIsRunning ..."; + connect(_timer, SIGNAL(timeout()), this, SLOT(checkForIsRunning())); + _timer->start(1000); } @@ -122,12 +128,13 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp 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 { - qDebug() << _tag << "list is empty. Have not found usable interface."; + qxtLog->debug() << _tag << "list is empty. Have not found usable interface."; emit abortBoot("Have not found usable interface"); return; @@ -204,10 +211,10 @@ int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) { "/etc/", dns); - qDebug() << _tag << "set man conf. and check connectivity"; + qxtLog->debug() << _tag << "set man conf. and check connectivity"; if (!checkConnectivityViaTcp(_serverIp)) { - qDebug() << _tag << "no connectivity. reset conf."; + qxtLog->debug() << _tag << "no connectivity. reset conf."; interfaceconfiguration * ifc = _ifcMap.value(result["ifname"].toString(), NULL); if(ifc != NULL) { dns.clear(); @@ -269,6 +276,13 @@ QString NetworkDiscovery::readLogFile() { +/**/ +void NetworkDiscovery::tryAgain() { + +} + + + /** * ================================================================================ ********************************* Private Methods ******************************** @@ -289,6 +303,23 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() { if (nIList.size() > 0) { foreach(QNetworkInterface nI, nIList) { + 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) @@ -300,12 +331,15 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() { } else if (!(nI.flags() & QNetworkInterface::IsUp)) { _networkManager.bringInterfaceUP(nI.humanReadableName()); - qDebug() << _tag << " bring up .."; + qxtLog->debug() << _tag << " bring up .."; + _ifDownList.append(nI.humanReadableName()); + } + else if (!(nI.flags() & QNetworkInterface::IsRunning)) { _ifDownList.append(nI.humanReadableName()); } } } else { - qDebug() << _tag << "no interfaces found!"; + qxtLog->debug() << _tag << "no interfaces found!"; } } @@ -321,18 +355,22 @@ void NetworkDiscovery::getListOfNetworkInterfaces() { if (nIList.size() > 0) { foreach(QNetworkInterface nI, nIList) { + qxtLog->debug() << _tag << "found Interface:" << nI.humanReadableName(); if (((!(nI.flags() & QNetworkInterface::CanBroadcast) || nI.flags() & QNetworkInterface::IsLoopBack) || nI.flags() & QNetworkInterface::IsPointToPoint) || !(nI.flags() & QNetworkInterface::IsUp) - || !(nI.flags() & QNetworkInterface::IsRunning) || checkBlackList(nI.humanReadableName())) { continue; } - _ifUpList.append(nI.humanReadableName()); + if (!(nI.flags() & QNetworkInterface::IsRunning)) { + _ifDownList.append(nI.humanReadableName()) + } else { + _ifUpList.append(nI.humanReadableName()); + } } } else { - qDebug() << _tag << "no interfaces found!"; + qxtLog->debug() << _tag << "no interfaces found!"; } } @@ -348,7 +386,7 @@ void NetworkDiscovery::getListOfNetworkInterfaces() { */ bool NetworkDiscovery::checkCarrierState(QString interface) { - qDebug() << _tag << "check carrier state for interface " << interface; + qxtLog->debug() << _tag << "check carrier state for interface " << interface; QByteArray ba = interface.toAscii(); const char * iface = ba.data(); @@ -365,21 +403,21 @@ bool NetworkDiscovery::checkCarrierState(QString interface) { int v = value.toInt(pok); if (*pok) { if (v == 1) { - qDebug() + qxtLog->debug() << "carrier is 1. Cable is plugged. return true"; return true; } else { - qDebug() + qxtLog->debug() << "carrier is 0. Cable is unplugged. return false"; return false; } } else { - qDebug() << _tag << "conversion error"; + qxtLog->debug() << _tag << "conversion error"; } } } } else { - qDebug() << _tag << "attrlist is Null"; + qxtLog->debug() << _tag << "attrlist is Null"; } sysfs_close_class_device(class_device); @@ -414,7 +452,7 @@ void NetworkDiscovery::runDHCPCD(QString interface) { _dhcpcdArguments.append(interface); QProcess * p = new QProcess(this); - qDebug() << _tag << _dhcpcdArguments; + qxtLog->debug() << _tag << _dhcpcdArguments; _clientProcessToIfNameMap.insert(p, interface); p->start(_pathToDhcpcdExe, _dhcpcdArguments); @@ -451,12 +489,12 @@ bool NetworkDiscovery::checkConnectivity(QString ifName) { _ifcMap.insert(ifName, ifConf); // replace default route - qDebug() << _tag << "replace default route"; + qxtLog->debug() << _tag << "replace default route"; _networkManager.replaceDefaultRoute(ifName, ifConf->getGateway(), mss, AF_INET); if (checkConnectivityViaTcp(_serverIp)) { - qDebug() << _tag << "internet: check passed! for interface" << ifName; + qxtLog->debug() << _tag << "internet: check passed! for interface" << ifName; emit updateStatusLabel(ifName, "connection possible"); if (!_userChoice) { @@ -469,7 +507,7 @@ bool NetworkDiscovery::checkConnectivity(QString ifName) { } return true; } else { - qDebug() << _tag << "no internet connection with interface" << ifName; + qxtLog->debug() << _tag << "no internet connection with interface" << ifName; emit updateStatusLabel(ifName, "connection not possible"); return false; @@ -493,7 +531,7 @@ bool NetworkDiscovery::checkConnectivityViaTcp(QString server) { QTcpSocket *tcpSocket = new QTcpSocket(this); tcpSocket->connectToHost(server, 80); if (!tcpSocket->waitForConnected(500)) { - qDebug() << _tag << tcpSocket->errorString(); + qxtLog->debug() << _tag << tcpSocket->errorString(); return false; } else { return true; @@ -507,7 +545,7 @@ bool NetworkDiscovery::checkConnectivityViaTcp(QString server) { * connects the client readyRead signal with the handleNewInput slot. */ void NetworkDiscovery::handleNewConnection() { - qDebug() << _tag << "New Connection arrived"; + qxtLog->debug() << _tag << "New Connection arrived"; /*QLocalSocket **/ _client = _server ->nextPendingConnection(); @@ -527,7 +565,7 @@ void NetworkDiscovery::handleClientDisconnect() { QLocalSocket * client = _clients.value(socket); - qDebug() << _tag << "disconnect client"; + qxtLog->debug() << _tag << "disconnect client"; handleNewInput(client); client->deleteLater(); } @@ -541,12 +579,12 @@ void NetworkDiscovery::handleClientDisconnect() { * a client */ void NetworkDiscovery::handleNewInput(QLocalSocket * client) { - qDebug() << _tag << "last read before exit"; + qxtLog->debug() << _tag << "last read before exit"; while (client->canReadLine()) { QString data(client->readLine()); data = data.trimmed(); - qDebug() << _tag << data; + qxtLog->debug() << _tag << data; QStringList lines = data.split("\n"); for (int i = 0; i < lines.length(); i++) { @@ -570,7 +608,7 @@ void NetworkDiscovery::handleNewInput() { client->write("ACK", ACK_SIZE); client->waitForBytesWritten(); data = data.trimmed(); - //qDebug() << _tag << data; + //qxtLog->debug() << _tag << data; QStringList lines = data.split("\n"); for (int i = 0; i < lines.length(); i++) { @@ -609,7 +647,7 @@ void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString data) { QString msg = logMsg.section(";", 3, 3); int st = s_state.trimmed().toInt(); int sst = s_subState.trimmed().toInt(); - //qDebug() << _tag << logMsg; + //qxtLog->debug() << _tag << logMsg; if (_ifNameToClient.size() < _numberOfProcesses && !_ifNameToClient.contains( interface)) { @@ -621,21 +659,27 @@ void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString data) { switch (sst) { case DHCP_DISCOVER: emit changeProgressBarValue(interface, 10); + qxtLog->debug() << _tag << " " << interface << " send discover"; break; case DHCP_OFFER: emit changeProgressBarValue(interface, 20); + qxtLog->debug() << _tag << " " << interface << " got offer"; break; case DHCP_REQUEST: emit changeProgressBarValue(interface, 30); + qxtLog->debug() << _tag << " " << interface << " send request"; break; case DHCP_ACK: emit changeProgressBarValue(interface, 40); + qxtLog->debug() << _tag << " " << interface << " ack"; break; case DHCP_NAK: emit changeProgressBarValue(interface, 40); + qxtLog->debug() << _tag << " " << interface << " nak"; break; case DHCPCD_ARP_TEST: emit changeProgressBarValue(interface, 50); + qxtLog->debug() << _tag << " " << interface << " do arp test"; break; case DHCP_DECLINE: emit changeProgressBarValue(interface, 60); @@ -647,24 +691,28 @@ void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString data) { break; case DHCPCD_CONFIGURE: emit changeProgressBarValue(interface, 70); + qxtLog->debug() << _tag << " " << interface << " do configure interface"; break; case DHCPCD_WRITE: emit changeProgressBarValue(interface, 80); + qxtLog->debug() << _tag << " " << interface << " write conf file"; break; case DHCPCD_EXIT: emit changeProgressBarValue(interface, 100); + qxtLog->debug() << _tag << " " << interface << " exiting"; break; case DHCPCD_LOG: default: + qxtLog->debug() << _tag << " received error:" << msg; break; } break; case LOG_ERR: - qDebug() << _tag << "received error:" << msg; + qxtLog->debug() << _tag << " received error:" << msg; break; default: - //qDebug() << _tag << logMsg; + qxtLog->debug() << _tag << logMsg; break; } } @@ -704,17 +752,18 @@ void NetworkDiscovery::handleProcessFinished(int exitCode, 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) { - qDebug() << _tag << "--- \t [NetworkDiscovery::handleProcessFinished] haven't found process!"; + qxtLog->debug() << _tag << "--- \t [NetworkDiscovery::handleProcessFinished] haven't found process!"; } else { - qDebug() << _tag << "process for interface" << ifName << "finished" - << exitCode << exitStatus; + qxtLog->debug() << _tag << " process for interface " << ifName << " finished " + << " exit code: " << exitCode << " exit status " << exitStatus; if (exitCode > 0) { - qDebug() << _tag << "process exited unexpected"; + qxtLog->debug() << _tag << "process exited unexpected"; emit updateStatusLabel(ifName, "process exited unexpected"); } else { - qDebug() << _tag << "process normal exit"; + qxtLog->debug() << _tag << "process normal exit"; emit changeProgressBarValue(ifName, 100); emit updateStatusLabel(ifName, "check connectivity"); checkConnectivity(ifName); @@ -725,13 +774,13 @@ void NetworkDiscovery::handleProcessFinished(int exitCode, if (client != 0) { handleNewInput(client); } - _numberOfProcesses = _numberOfProcesses - 1; - if (_numberOfProcesses <= 0 && _userChoice) { + //_numberOfProcesses = _numberOfProcesses - 1; && _userChoice + if (_numberOfProcesses <= 0 ) { emit allProcessesFinished(); } } } else { - qDebug() << _tag << "already blocked"; + qxtLog->debug() << _tag << "already blocked"; emit updateStatusLabel(ifName, "finished DHCP"); } } @@ -747,7 +796,7 @@ void NetworkDiscovery::handleProcessFinished(int exitCode, void NetworkDiscovery::handleProcessStarted() { QProcess* p = qobject_cast<QProcess *> (QObject::sender()); QString ifName = _clientProcessToIfNameMap.value(p, "ifName"); - qDebug() << _tag << "process started for interface:" << ifName; + qxtLog->debug() << _tag << "process started for interface:" << ifName; } diff --git a/src/networkdiscovery.h b/src/networkdiscovery.h index 49ac731..c45b5aa 100644 --- a/src/networkdiscovery.h +++ b/src/networkdiscovery.h @@ -22,7 +22,8 @@ #define DEFAULT_QTSOCKETADDRESS "/var/tmp/qt_c_socket_default" -#define DEFAULT_PATHTODHCPCDEXE "/home/niklas/fbgui/customdhcpcd/src/build/cdhcpcd" +//#define DEFAULT_PATHTODHCPCDEXE "/home/niklas/fbgui/customdhcpcd/src/build/cdhcpcd" +#define DEFAULT_PATHTODHCPCDEXE "/bin/cdhcpcd" class NetworkDiscovery: public QObject { Q_OBJECT @@ -42,6 +43,7 @@ public: int ip4_setManualConfiguration(QVariantMap result); QString readLogFile(); + void tryAgain(); private slots: void handleNewConnection(); |