author | mickeyl <mickeyl> | 2004-01-13 20:03:55 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-13 20:03:55 (UTC) |
commit | a730fd614ed213ca590ae075ed99feec65522868 (patch) (side-by-side diff) | |
tree | 072f5342fc43c4cd5acf9620a150bd9247469f91 | |
parent | e117e8427cd8bcd0ab1a74abdc5cd4ab12654194 (diff) | |
download | opie-a730fd614ed213ca590ae075ed99feec65522868.zip opie-a730fd614ed213ca590ae075ed99feec65522868.tar.gz opie-a730fd614ed213ca590ae075ed99feec65522868.tar.bz2 |
use OProcess::processPID()
-rw-r--r-- | noncore/net/wellenreiter/gui/main.cpp | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index 702a7cc..d32b362 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp @@ -1,47 +1,42 @@ /********************************************************************** -** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. +** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Opie Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "mainwindow.h" #ifdef QWS #include <opie2/oapplication.h> +#include <opie2/oprocess.h> #else #include <qapplication.h> #endif #include <qmessagebox.h> #include <qstringlist.h> -// ==> OProcess -#include <qdir.h> -#include <qfileinfo.h> -#include <qregexp.h> -#include <qtextstream.h> - #include <errno.h> #include <signal.h> #include <string.h> #include <unistd.h> int main( int argc, char **argv ) { #ifdef QWS OApplication a( argc, argv, "Wellenreiter II" ); #else QApplication a( argc, argv ); #endif WellenreiterMainWindow* w = new WellenreiterMainWindow(); #ifdef QWS a.showMainWidget( w ); #else @@ -64,59 +59,40 @@ int main( int argc, char **argv ) break; } } if ( check ) { // root check if ( getuid() ) { qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), QMessageBox::Yes, QMessageBox::No ); if ( result == QMessageBox::No ) return -1; } - // dhcp check - NOT HERE! This really belongs as a static member to OProcess - // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ... - - QString line; - QDir d = QDir( "/proc" ); - QStringList dirs = d.entryList( QDir::Dirs ); - QStringList::Iterator it; - for ( it = dirs.begin(); it != dirs.end(); ++it ) - { - //qDebug( "next entry: %s", (const char*) *it ); - QFile file( "/proc/"+*it+"/cmdline" ); - file.open( IO_ReadOnly ); - if ( !file.isOpen() ) continue; - QTextStream t( &file ); - line = t.readLine(); - //qDebug( "cmdline = %s", (const char*) line ); - if ( line.contains( "dhcp" ) ) break; - } - if ( line.contains( "dhcp" ) ) + if ( OProcess::processPID( "dhcpc" ) ) { - qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() ); result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" "This can severly limit scanning!\nShould I kill it for you?" ), QMessageBox::Yes, QMessageBox::No ); if ( result == QMessageBox::Yes ) { - if ( -1 == ::kill( (*it).toInt(), SIGTERM ) ) + if ( -1 == ::kill( OProcess::processPID( "dhcpc" ), SIGTERM ) ) qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); else killed = true; } } } a.exec(); if ( check ) { if ( killed ) { result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); if ( result == QMessageBox::Yes ) |