#include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif #include "dhcpcd/config.h" #include "dhcpcd/client.h" #include "dhcpcd/dhcpcd.h" #include "dhcpcd/dhcp.h" #include "dhcpcd/interface.h" #include "dhcpcd/logger.h" #include "dhcpcd/socket.h" #include "dhcpcd/version.h" #ifdef __cplusplus } #endif #ifdef __cplusplus #include #include "networkdiscovery.h" #include #include #endif NetworkDiscovery::NetworkDiscovery(QWidget *parent) : QWidget(parent) { ui.setupUi(this); QList interfaces = getListOfNetworkInterfaces(); /** * test if i get some dhcp values for the dummy0 interface */ doDHCP(interfaces); doDhcp(interfaces.first()); } NetworkDiscovery::~NetworkDiscovery() { } QList NetworkDiscovery::getListOfNetworkInterfaces() { QList nIList = QNetworkInterface::allInterfaces(); QList result; foreach(QNetworkInterface nI, nIList) { if (((!(nI.flags() & QNetworkInterface::CanBroadcast)|| nI.flags() & QNetworkInterface::IsLoopBack) || nI.flags() & QNetworkInterface::IsPointToPoint)) { continue; } qDebug() << nI.humanReadableName(); result.append(nI); } return result; } int NetworkDiscovery::doDHCP(QList interfaces) { return 0; } int NetworkDiscovery::doDhcp(QNetworkInterface interface) { nd_main("eth0"); } void NetworkDiscovery::listenToLogger() { skt = new QLocalSocket(this); // connect(socket, SIGNAL(readyRead()), this, ) connect(skt, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(displayError(QLocalSocket::LocalSocketError))); } void NetworkDiscovery::displayError(QLocalSocket::LocalSocketError socketError) { switch (socketError) { case QLocalSocket::ServerNotFoundError: QMessageBox::information(this, tr("Fortune Client"), tr("The host was not found. Please check the " "host name and port settings.")); break; case QLocalSocket::ConnectionRefusedError: QMessageBox::information(this, tr("Fortune Client"), tr("The connection was refused by the peer. " "Make sure the fortune server is running, " "and check that the host name and port " "settings are correct.")); break; case QLocalSocket::PeerClosedError: break; default: QMessageBox::information(this, tr("Fortune Client"), tr("The following error occurred: %1.") .arg(skt->errorString())); } }