/** * Copyright (c) 2010,2011 - RZ Uni Freiburg * Copyright (c) 2010,2011 - OpenSLX Project * * This program/file is free software distributed under the GPL version 2. * See http://openslx.org/COPYING * * If you have any feedback please consult http://openslx.org/feedback and * send your feedback to feedback@openslx.org * * General information about OpenSLX can be found under http://openslx.org */ #ifndef NetworkDiscovery_H #define NetworkDiscovery_H #include #include #include #include #include #include #include #include #include #include "interfaceconfiguration.h" #include "networkmanager.h" #include "dhcp.h" #include "globals.h" #include "../common/fbgui.h" class NetworkDiscovery: public QObject { Q_OBJECT public: NetworkDiscovery(QObject *parent = 0); ~NetworkDiscovery(); void initAndRun(bool userChoice, QStringList* args = NULL); int ip4_replaceDefaultRoute(QString ifName, QString gateway, int mss); int ip4_setManualConfiguration(QVariantMap result); void tryAgain(); void prepareTryAgain(); bool checkConnectivity(QString ifName); bool checkConnectivityViaTcp(); // Public member access QList getIfUpList(); InterfaceConfiguration* getInterfaceConfig(QString ifName); QString GetErrorStr(); QString getGatewayForInterface(QString ifName); public slots: void checkForIsRunning(); void handleNewConnection(); void handleClientDisconnect(); void handleNewInput(); void handleNewInputLine(QLocalSocket * client, QString data); void handleProcessStarted(); void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); void readyForRun(); signals: void addInterface(const QString &ifName); void changeProgressBarValue(const QString & ifName, const int $newValue); void connectionEstablished(QString ifName); void abortBoot(QString msg); void updateIfStatus(QString ifName, QString status); void updateStatus(QString status); void allProcessesFinished(); void continueBoot(QString ifName); void continueBootWithoutCheck(QString ifName); void setManualConfInterfaces(QString jsonArr); //void readyForRun(); private: void mainWork(); void killDHCPCD(); void handleNewInput(QLocalSocket * client); void runDHCPCD(QList &interfaces); void runDHCPCD(QString interface); bool checkCarrierState(QString interface); bool checkConnectivityViaTcp(QString server); bool checkBlackList(QString i); void getListOfNetworkInterfaces(); void getListOfNetworkInterfacesWithAutoUp(); QLocalServer *_server; QMap _clients; QLocalSocket *_client; QMap _ifNameToClient; QMap _clientProcessToIfNameMap; QStringList _dhcpcdArguments; int _numberOfProcesses; NetworkManager* _networkManager; bool _userChoice; bool _blocked; QList _ifUpList; QList _ifDownList; int _ifUpCountdown; QTimer*_timer; QList _pidsList; QString _errorStr; QMap _ifcMap; }; #endif // NetworkDiscovery_H