diff options
author | Jonathan Bauer | 2012-02-23 10:03:25 +0100 |
---|---|---|
committer | Jonathan Bauer | 2012-02-23 10:03:25 +0100 |
commit | 259a2e0ff8984325b59bc6dd7d9611867557865d (patch) | |
tree | 96ba68a14afdbfb3011a417a947a8b34358b6c6d /src/fbgui/networkdiscovery.cpp | |
parent | connected interfaces saved in networkdiscovery class and now accessed by gett... (diff) | |
download | fbgui-259a2e0ff8984325b59bc6dd7d9611867557865d.tar.gz fbgui-259a2e0ff8984325b59bc6dd7d9611867557865d.tar.xz fbgui-259a2e0ff8984325b59bc6dd7d9611867557865d.zip |
improved user choice coding...
Diffstat (limited to 'src/fbgui/networkdiscovery.cpp')
-rw-r--r-- | src/fbgui/networkdiscovery.cpp | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/src/fbgui/networkdiscovery.cpp b/src/fbgui/networkdiscovery.cpp index 7b75ec5..da9a148 100644 --- a/src/fbgui/networkdiscovery.cpp +++ b/src/fbgui/networkdiscovery.cpp @@ -46,31 +46,16 @@ NetworkDiscovery::~NetworkDiscovery() { /** * initialize all important class members and start the main work. * - * @param userChoice - * true if the user wishes to have a user choice. true: the chooseInterfaceDialog will be showed. - * * @param args * additional arguments for the customdhcpcd client. (default value: NULL) */ -void NetworkDiscovery::initAndRun(bool userChoice, QStringList* args) { +void NetworkDiscovery::init(QStringList* args) { - _userChoice = userChoice; _blocked = false; _numberOfProcesses = 0; _ifUpCountdown = 10; - _errorStr = ""; - - _clientProcessToIfNameMap.clear(); - _clients.clear(); - _dhcpcdArguments.clear(); - _ifDownList.clear(); - _ifNameToClient.clear(); - _ifUpList.clear(); - _ifcMap.clear(); - - _server = new QLocalServer(); _networkManager = new NetworkManager(); @@ -120,8 +105,9 @@ void NetworkDiscovery::initAndRun(bool userChoice, QStringList* args) { _dhcpcdArguments.append(*args); } emit updateStatus("start mainwork"); - mainWork(); + run(); } + //------------------------------------------------------------------------- // Main Network Discovery Flow //------------------------------------------------------------------------- @@ -132,7 +118,7 @@ void NetworkDiscovery::initAndRun(bool userChoice, QStringList* args) { * check every second the IsRunning state. Do this as long the counter (@see _ifUpCountdown) is greater than 0. * Default: _ifUpCountdown = 10. */ -void NetworkDiscovery::mainWork() { +void NetworkDiscovery::run() { gAutoUp ? emit updateStatus("search for usable interfaces (with auto Up)") : emit updateStatus("search for usable interfaces"); @@ -377,7 +363,7 @@ void NetworkDiscovery::handleProcessFinished(int exitCode, if (!_userChoice) { // blockiere jeden weiteren check _blocked = true; - emit allProcessesFinished(); + emit allProcessesFinished(_userChoice); } } } @@ -389,7 +375,7 @@ void NetworkDiscovery::handleProcessFinished(int exitCode, } //_numberOfProcesses = _numberOfProcesses - 1; && _userChoice if (_numberOfProcesses <= 0) { - emit allProcessesFinished(); + emit allProcessesFinished(_userChoice); } } } else { @@ -498,6 +484,17 @@ bool NetworkDiscovery::checkConnectivity(QString ifName) { //------------------------------------------------------------------------- /** +* @brief set userChoice true +* +* is the connected to the triggered action pressing the F5 button. +* set the _userChoice member true +*/ +void NetworkDiscovery::activateUserChoice() { + LOG4CXX_DEBUG(ndcLogger, "Activating user dialog..."); + _userChoice = true; +} + +/** * 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. @@ -782,13 +779,22 @@ const QString& NetworkDiscovery::getErrorStr() { */ void NetworkDiscovery::tryAgain() { prepareTryAgain(); - initAndRun(_userChoice); + init(); } /**/ void NetworkDiscovery::prepareTryAgain() { // kill all cdhcpcd processes killDHCPCD(); + _clientProcessToIfNameMap.clear(); + _clients.clear(); + _dhcpcdArguments.clear(); + _ifDownList.clear(); + _ifNameToClient.clear(); + _ifUpList.clear(); + _ifcMap.clear(); + _errorStr = ""; + /* foreach(Q_PID pid , _pidsList) { if (kill(pid,SIGKILL) <= -1) |