From 259a2e0ff8984325b59bc6dd7d9611867557865d Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 23 Feb 2012 10:03:25 +0100 Subject: improved user choice coding... --- src/fbgui/networkdiscovery.cpp | 48 ++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'src/fbgui/networkdiscovery.cpp') 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 { @@ -497,6 +483,17 @@ bool NetworkDiscovery::checkConnectivity(QString ifName) { // Manual Configuration //------------------------------------------------------------------------- +/** +* @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 @@ -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) -- cgit v1.2.3-55-g7522