diff options
author | Niklas | 2011-11-04 11:56:28 +0100 |
---|---|---|
committer | Niklas | 2011-11-04 11:56:28 +0100 |
commit | 5d215d54cbb33f3ef5fb4f5da9a860b0a105ae9b (patch) | |
tree | 8965df059ab3acff163d0b7c907f35754472ee23 /src/networkdiscovery.cpp | |
parent | changed the tryout, also some big changes in program flow. there is now userc... (diff) | |
download | fbgui-5d215d54cbb33f3ef5fb4f5da9a860b0a105ae9b.tar.gz fbgui-5d215d54cbb33f3ef5fb4f5da9a860b0a105ae9b.tar.xz fbgui-5d215d54cbb33f3ef5fb4f5da9a860b0a105ae9b.zip |
last changes
Diffstat (limited to 'src/networkdiscovery.cpp')
-rw-r--r-- | src/networkdiscovery.cpp | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/networkdiscovery.cpp b/src/networkdiscovery.cpp index 9361887..b0b7131 100644 --- a/src/networkdiscovery.cpp +++ b/src/networkdiscovery.cpp @@ -64,6 +64,7 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp _numberOfProcesses = 0; _ifUpCountdown = 10; + _errorStr = ""; _networkManager = new NetworkManager(); _clientProcessToIfNameMap.clear(); _clients.clear(); @@ -148,7 +149,8 @@ void NetworkDiscovery::mainWork() */ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() { QList<QNetworkInterface> nIList = QNetworkInterface::allInterfaces(); - + _ifUpList.clear(); + _ifDownList.clear(); if (nIList.size() > 0) { foreach(QNetworkInterface nI, nIList) { @@ -180,7 +182,7 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() { } else if (!(nI.flags() & QNetworkInterface::IsUp)) { _networkManager->bringInterfaceUP(nI.humanReadableName()); - qxtLog->debug() << _tag << " bring up: " << nI.humanReadableName() ; + qxtLog->debug() << _tag << " interface is down, try to bring up: " << nI.humanReadableName() ; _ifDownList.append(nI.humanReadableName()); } else if (!(nI.flags() & QNetworkInterface::IsRunning)) { @@ -200,7 +202,8 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() { */ void NetworkDiscovery::getListOfNetworkInterfaces() { QList<QNetworkInterface> nIList = QNetworkInterface::allInterfaces(); - + _ifUpList.clear(); + _ifDownList.clear(); if (nIList.size() > 0) { foreach(QNetworkInterface nI, nIList) { @@ -285,7 +288,10 @@ void NetworkDiscovery::slotReadyForRun() { } else { qxtLog->debug() << _tag << " list is empty. Have not found usable interface. "; emit - abortBoot("Have not found usable interface"); + foreach(QString i, _ifDownList) { + qxtLog->debug() << _tag << " " << i << " is not in running state. (check cable)"; + } + abortBoot("All interfaces are not usable. (e.g. please check if all network cables are plugged in. Read the log for more informations.)"); return; } } @@ -487,10 +493,15 @@ bool NetworkDiscovery::checkConnectivityViaTcp() { */ bool NetworkDiscovery::checkConnectivityViaTcp(QString server) { // check connectivity via tcp connection + qxtLog->debug() << _tag << " check connectivity to server: " << server; + // do host lookup + //QHostInfo hostInfo = QHostInfo::fromName(server); QTcpSocket *tcpSocket = new QTcpSocket(this); + //qxtLog->debug() << _tag << " hostInfo first address: " << hostInfo.addresses().first().toString(); //hostInfo.addresses().first() tcpSocket->connectToHost(server, 80); if (!tcpSocket->waitForConnected(500)) { qxtLog->debug() << _tag << tcpSocket->errorString(); + _errorStr += tcpSocket->errorString(); return false; } else { return true; @@ -608,7 +619,7 @@ void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString data) { emit changeProgressBarValue(interface, 60); break; case DHCP_RELEASE: - + qxtLog->debug() << _tag << " " << interface << " release"; break; case DHCP_INFORM: break; @@ -679,10 +690,10 @@ int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) { result["broadcast"].toString(), result["gateway"].toString(), 0, AF_INET, "/etc/", dns); - qxtLog->debug() << _tag << "set man conf. and check connectivity"; + qxtLog->debug() << _tag << " set man conf. and check connectivity"; if (!checkConnectivityViaTcp(_serverIp)) { - qxtLog->debug() << _tag << "no connectivity. reset conf."; + qxtLog->debug() << _tag << " no connectivity. reset conf."; interfaceconfiguration * ifc = _ifcMap.value( result["ifname"].toString(), NULL); if (ifc != NULL) { @@ -695,8 +706,10 @@ int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) { } return 0; - } emit - continueBoot(result["ifname"].toString()); + } + qxtLog->debug() << _tag << " emit signal continueBootWithoutCheck(" << result["ifname"].toString() << ")"; + emit + continueBootWithoutCheck(result["ifname"].toString()); return 0; } @@ -762,7 +775,7 @@ void NetworkDiscovery::killDHCPCD() { p->start("killall cdhcpcd"); p->waitForFinished(); if (p->exitCode() > 0) - qxtLog->debug() << _tag << "[tryAgain]" << p->errorString(); + qxtLog->debug() << _tag << " [tryAgain] " << p->errorString(); delete p; } @@ -819,7 +832,7 @@ QVariantMap NetworkDiscovery::getInterfaceConfig(QString ifName) { * connects the client readyRead signal with the handleNewInput slot. */ void NetworkDiscovery::handleNewConnection() { - qxtLog->debug() << _tag << "New Connection arrived"; + qxtLog->debug() << _tag << " New Connection arrived"; /*QLocalSocket **/ _client = _server->nextPendingConnection(); @@ -839,7 +852,7 @@ void NetworkDiscovery::handleClientDisconnect() { QLocalSocket * client = _clients.value(socket); - qxtLog->debug() << _tag << "disconnect client"; + qxtLog->debug() << _tag << " disconnect client"; handleNewInput(client); client->deleteLater(); } @@ -876,6 +889,13 @@ bool NetworkDiscovery::checkBlackList(QString i) { +/**/ +QString NetworkDiscovery::GetErrorStr() { + return _errorStr; +} + + + ////////////////////////////////////////////////////////////////////////////////////// /** |