/* * Localwebfaker - Web sites faker for LAN * Copyright (C) 2007-2009 Lucas J. González * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see rxDomain()); QRegExpValidator *validator = new QRegExpValidator(rx, objeto); if( (validator->validate(userInput, pos)) == QValidator::Acceptable ) return true ; return false ; } bool Validacion::netdevValido (QString userInput) { if (userInput.isEmpty()) { std::cout << "You must set a network interface" << std::endl ; return false ; } QNetworkInterface interfaz = interfaz.interfaceFromName ( userInput ) ; if (!interfaz.isValid()) { std::cout << "The network interface \"" << qPrintable(userInput) << "\" is not valid" << std::endl ; return false ; } if ( !(interfaz.flags().testFlag(QNetworkInterface::IsUp) ) ) { std::cout << "The etwork interface \"" << qPrintable(userInput) << "\" is disabled" << std::endl ; return false ; } if ( !( interfaz.flags() & QNetworkInterface::IsRunning).testFlag(QNetworkInterface::IsRunning) ) { std::cout << "The network interface \"" << qPrintable(userInput) << "\" has no resources asigned" << std::endl ; return false ; } // Las interfaces funcionando, y siguen sin tener esta flag activa :S if ( interfaz.flags().testFlag(QNetworkInterface::IsLoopBack)) { std::cout << "This network interface (" << qPrintable(userInput) << ") is not valid for external communications!" << std::endl ; return false ; } if ( !( interfaz.flags().testFlag(QNetworkInterface::CanBroadcast)) ) { std::cout << "This network interface (" << qPrintable(userInput) << ") can not send broadcast packets" << std::endl ; return false ; } QList dirs = interfaz.addressEntries () ; QNetworkAddressEntry dir; if (dirs.size() <= 0) { std::cout << "The network interface (" << qPrintable(userInput) << ") has no IP address asigned" << std::endl ; return false; } return true ; } bool Validacion::ExisteDocRoot (QString userInput) { if( userInput == "" ) return false ; QDir *userProponeF = new QDir(userInput); return userProponeF->exists(); } bool Validacion::IpValida (QString userInput, QObject *objeto) { int pos = 0 ; Comun *conf = new Comun(); QRegExp rx(conf->rxIP()); QRegExpValidator *validator = new QRegExpValidator(rx, objeto); if( (validator->validate(userInput, pos)) == QValidator::Acceptable ) return true ; return false ; }