author | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-04 13:54:40 (UTC) |
commit | 16cf79e90b5217f8d4bfce2a0fa817ae4b73db36 (patch) (unidiff) | |
tree | 0701eae15aa606a0211a2fccfde0eafdac69357c /noncore/net/wellenreiter/gui/main.cpp | |
parent | 8d2d2664e5f544b8292806e617deb7a0e4170dc0 (diff) | |
download | opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.zip opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.gz opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.bz2 |
convert to Opie Debugging Framework
Diffstat (limited to 'noncore/net/wellenreiter/gui/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/main.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index 6bbc39b..62db967 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp | |||
@@ -5,97 +5,100 @@ | |||
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | |||
17 | #ifdef QWS | 18 | #ifdef QWS |
19 | #include <opie2/odebug.h> | ||
18 | #include <opie2/oapplication.h> | 20 | #include <opie2/oapplication.h> |
19 | #include <opie2/oprocess.h> | 21 | #include <opie2/oprocess.h> |
20 | #else | 22 | #else |
21 | #include <qapplication.h> | 23 | #include <qapplication.h> |
22 | #endif | 24 | #endif |
23 | 25 | ||
26 | /* QT */ | ||
24 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
25 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
26 | 29 | ||
30 | /* STD */ | ||
27 | #include <errno.h> | 31 | #include <errno.h> |
28 | #include <signal.h> | 32 | #include <signal.h> |
29 | #include <string.h> | 33 | #include <string.h> |
30 | #include <unistd.h> | 34 | #include <unistd.h> |
31 | 35 | ||
32 | using namespace Opie::Core; | 36 | using namespace Opie::Core; |
33 | using namespace Opie::Core; | 37 | |
34 | using namespace Opie::Core; | ||
35 | int main( int argc, char **argv ) | 38 | int main( int argc, char **argv ) |
36 | { | 39 | { |
37 | #ifdef QWS | 40 | #ifdef QWS |
38 | OApplication a( argc, argv, "Wellenreiter II" ); | 41 | OApplication a( argc, argv, "Wellenreiter II" ); |
39 | #else | 42 | #else |
40 | QApplication a( argc, argv ); | 43 | QApplication a( argc, argv ); |
41 | #endif | 44 | #endif |
42 | WellenreiterMainWindow* w = new WellenreiterMainWindow(); | 45 | WellenreiterMainWindow* w = new WellenreiterMainWindow(); |
43 | #ifdef QWS | 46 | #ifdef QWS |
44 | a.showMainWidget( w ); | 47 | a.showMainWidget( w ); |
45 | #else | 48 | #else |
46 | a.setMainWidget( w ); | 49 | a.setMainWidget( w ); |
47 | w->setCaption( "Wellenreiter II" ); | 50 | w->setCaption( "Wellenreiter II" ); |
48 | w->show(); | 51 | w->show(); |
49 | #endif | 52 | #endif |
50 | 53 | ||
51 | a.processEvents(); // show the window before doing the safety checks | 54 | a.processEvents(); // show the window before doing the safety checks |
52 | int result = -1; | 55 | int result = -1; |
53 | static int killed = false; | 56 | static int killed = false; |
54 | 57 | ||
55 | bool check = true; | 58 | bool check = true; |
56 | for ( int i = 1; i < argc; ++i ) | 59 | for ( int i = 1; i < argc; ++i ) |
57 | { | 60 | { |
58 | qDebug( "Wellenreiter::main() parsing argument %d = '%s'", i, argv[i] ); | 61 | odebug << "Wellenreiter::main() parsing argument " << i << " = '" << argv[i] << "'" << oendl; |
59 | if ( !strcmp( "-nocheck", argv[i] ) ) | 62 | if ( !strcmp( "-nocheck", argv[i] ) ) |
60 | { | 63 | { |
61 | qDebug( "-nocheck found" ); | 64 | odebug << "-nocheck found" << oendl; |
62 | check = false; | 65 | check = false; |
63 | break; | 66 | break; |
64 | } | 67 | } |
65 | } | 68 | } |
66 | 69 | ||
67 | if ( check ) | 70 | if ( check ) |
68 | { | 71 | { |
69 | // root check | 72 | // root check |
70 | if ( getuid() ) | 73 | if ( getuid() ) |
71 | { | 74 | { |
72 | qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); | 75 | owarn << QObject::tr( "Wellenreiter: trying to run as non-root!" ) << oendl; |
73 | result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" | 76 | result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" |
74 | "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), | 77 | "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), |
75 | QMessageBox::Yes, QMessageBox::No ); | 78 | QMessageBox::Yes, QMessageBox::No ); |
76 | if ( result == QMessageBox::No ) return -1; | 79 | if ( result == QMessageBox::No ) return -1; |
77 | } | 80 | } |
78 | 81 | ||
79 | int dhcpid = OProcess::processPID( "dhcpc" ); | 82 | int dhcpid = OProcess::processPID( "dhcpc" ); |
80 | 83 | ||
81 | if ( dhcpid ) | 84 | if ( dhcpid ) |
82 | { | 85 | { |
83 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" | 86 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" |
84 | "(PID = %1)\nThis can severly limit scanning!\nShould I kill it for you?" ).arg( dhcpid ), | 87 | "(PID = %1)\nThis can severly limit scanning!\nShould I kill it for you?" ).arg( dhcpid ), |
85 | QMessageBox::Yes, QMessageBox::No ); | 88 | QMessageBox::Yes, QMessageBox::No ); |
86 | if ( result == QMessageBox::Yes ) | 89 | if ( result == QMessageBox::Yes ) |
87 | { | 90 | { |
88 | if ( -1 == ::kill( dhcpid, SIGTERM ) ) | 91 | if ( -1 == ::kill( dhcpid, SIGTERM ) ) |
89 | qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); | 92 | owarn << "Wellenreiter: can't kill process #" << result << " (" << strerror( errno ) << ")" << oendl; |
90 | else | 93 | else |
91 | killed = true; | 94 | killed = true; |
92 | } | 95 | } |
93 | } | 96 | } |
94 | } | 97 | } |
95 | 98 | ||
96 | a.exec(); | 99 | a.exec(); |
97 | 100 | ||
98 | if ( check ) | 101 | if ( check ) |
99 | { | 102 | { |
100 | 103 | ||
101 | if ( killed ) | 104 | if ( killed ) |