-rw-r--r-- | noncore/net/wellenreiter/TODO | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/main.cpp | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 2 |
3 files changed, 8 insertions, 4 deletions
diff --git a/noncore/net/wellenreiter/TODO b/noncore/net/wellenreiter/TODO index b6ec617..01e731f 100644 --- a/noncore/net/wellenreiter/TODO +++ b/noncore/net/wellenreiter/TODO | |||
@@ -1,60 +1,62 @@ | |||
1 | /************************************************************************ | 1 | /************************************************************************ |
2 | /* W e l l e n r e i t e r I I | 2 | /* W e l l e n r e i t e r I I |
3 | /* =============================== | 3 | /* =============================== |
4 | /* | 4 | /* |
5 | /* Version: 1.0.2 | 5 | /* Version: 1.0.2 |
6 | /************************************************************************ | 6 | /************************************************************************ |
7 | 7 | ||
8 | ---------------------------------------------------- | 8 | ---------------------------------------------------- |
9 | Ideas as of Wellenreiter II / December 2003 | 9 | Ideas as of Wellenreiter II / December 2003 |
10 | ---------------------------------------------------- | 10 | ---------------------------------------------------- |
11 | 11 | ||
12 | -------- | 12 | -------- |
13 | ENGINE | 13 | ENGINE |
14 | -------- | 14 | -------- |
15 | 15 | ||
16 | - enable multiple packet sources | 16 | - enable multiple packet sources |
17 | - infrared | 17 | - infrared |
18 | - bluetooth | 18 | - bluetooth |
19 | - usb? | 19 | - usb? |
20 | 20 | ||
21 | - define packet structure in a metalanguage and generate | 21 | - define packet structure in a metalanguage and generate |
22 | the actual parsing code (hmmm) | 22 | the actual parsing code (hmmm) |
23 | 23 | ||
24 | - pester the ethereal folks to settle for an application independant | 24 | - pester the ethereal folks to settle for an application independant |
25 | packet dissection framework... (unlikely) | 25 | packet dissection framework... (unlikely) |
26 | 26 | ||
27 | - adaptive hopping scheme ! | 27 | - adaptive hopping scheme ! |
28 | 28 | ||
29 | - gather interface capabilities | 29 | - gather interface capabilities |
30 | 30 | ||
31 | - enable sniffing in wired networks | 31 | - enable sniffing in wired networks |
32 | 32 | ||
33 | - fix autodetection (interface name) | 33 | - fix autodetection (interface name) |
34 | 34 | ||
35 | --------- | 35 | --------- |
36 | UI | 36 | UI |
37 | --------- | 37 | --------- |
38 | 38 | ||
39 | - display interface capabilities (or rewrite networksettings?) | 39 | - display interface capabilities (or rewrite networksettings?) |
40 | 40 | ||
41 | - distinguish wireless bridges (WDS traffic) | 41 | - distinguish wireless bridges (WDS traffic) |
42 | 42 | ||
43 | - expand/collapse all | 43 | - expand/collapse all |
44 | 44 | ||
45 | - add configuration for scrollback buffer in hex window and log window | 45 | - add configuration for scrollback buffer in hex window and log window |
46 | 46 | ||
47 | - revamp hex window, make it more sophisticated than just a QMultiLineEdit | 47 | - revamp hex window, make it more sophisticated than just a QMultiLineEdit |
48 | - tree view | 48 | - tree view |
49 | 49 | ||
50 | - beep over headphone / customizable | 50 | - beep over headphone / customizable |
51 | 51 | ||
52 | - count/display number of wireless networks / APs since last start/stop | ||
53 | |||
52 | --------- | 54 | --------- |
53 | FILES | 55 | FILES |
54 | --------- | 56 | --------- |
55 | 57 | ||
56 | - write kismet-like .network format and format to be importable into AutoRoute | 58 | - write kismet-like .network format and format to be importable into AutoRoute |
57 | 59 | ||
58 | - implement beacon stripping (the first beacon is enough to detect a | 60 | - implement beacon stripping (the first beacon is enough to detect a |
59 | new network - further beacons just blow up the capture file) | 61 | new network - further beacons just blow up the capture file) |
60 | 62 | ||
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index d32b362..8ef62e9 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp | |||
@@ -1,107 +1,109 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
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 | #ifdef QWS | 17 | #ifdef QWS |
18 | #include <opie2/oapplication.h> | 18 | #include <opie2/oapplication.h> |
19 | #include <opie2/oprocess.h> | 19 | #include <opie2/oprocess.h> |
20 | #else | 20 | #else |
21 | #include <qapplication.h> | 21 | #include <qapplication.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #include <qmessagebox.h> | 24 | #include <qmessagebox.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | 26 | ||
27 | #include <errno.h> | 27 | #include <errno.h> |
28 | #include <signal.h> | 28 | #include <signal.h> |
29 | #include <string.h> | 29 | #include <string.h> |
30 | #include <unistd.h> | 30 | #include <unistd.h> |
31 | 31 | ||
32 | int main( int argc, char **argv ) | 32 | int main( int argc, char **argv ) |
33 | { | 33 | { |
34 | #ifdef QWS | 34 | #ifdef QWS |
35 | OApplication a( argc, argv, "Wellenreiter II" ); | 35 | OApplication a( argc, argv, "Wellenreiter II" ); |
36 | #else | 36 | #else |
37 | QApplication a( argc, argv ); | 37 | QApplication a( argc, argv ); |
38 | #endif | 38 | #endif |
39 | WellenreiterMainWindow* w = new WellenreiterMainWindow(); | 39 | WellenreiterMainWindow* w = new WellenreiterMainWindow(); |
40 | #ifdef QWS | 40 | #ifdef QWS |
41 | a.showMainWidget( w ); | 41 | a.showMainWidget( w ); |
42 | #else | 42 | #else |
43 | a.setMainWidget( w ); | 43 | a.setMainWidget( w ); |
44 | w->setCaption( "Wellenreiter II" ); | 44 | w->setCaption( "Wellenreiter II" ); |
45 | w->show(); | 45 | w->show(); |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | a.processEvents(); // show the window before doing the safety checks | 48 | a.processEvents(); // show the window before doing the safety checks |
49 | int result = -1; | 49 | int result = -1; |
50 | static int killed = false; | 50 | static int killed = false; |
51 | 51 | ||
52 | bool check = true; | 52 | bool check = true; |
53 | for ( int i = 1; i < argc; ++i ) | 53 | for ( int i = 1; i < argc; ++i ) |
54 | { | 54 | { |
55 | if ( !strcmp( "-nocheck", argv[i] ) ) | 55 | if ( !strcmp( "-nocheck", argv[i] ) ) |
56 | { | 56 | { |
57 | qDebug( "-nocheck found" ); | 57 | qDebug( "-nocheck found" ); |
58 | check = false; | 58 | check = false; |
59 | break; | 59 | break; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | if ( check ) | 63 | if ( check ) |
64 | { | 64 | { |
65 | // root check | 65 | // root check |
66 | if ( getuid() ) | 66 | if ( getuid() ) |
67 | { | 67 | { |
68 | qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); | 68 | qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); |
69 | result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" | 69 | result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" |
70 | "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), | 70 | "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), |
71 | QMessageBox::Yes, QMessageBox::No ); | 71 | QMessageBox::Yes, QMessageBox::No ); |
72 | if ( result == QMessageBox::No ) return -1; | 72 | if ( result == QMessageBox::No ) return -1; |
73 | } | 73 | } |
74 | 74 | ||
75 | if ( OProcess::processPID( "dhcpc" ) ) | 75 | int dhcpid = OProcess::processPID( "dhcpc" ); |
76 | |||
77 | if ( dhcpid ) | ||
76 | { | 78 | { |
77 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" | 79 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" |
78 | "This can severly limit scanning!\nShould I kill it for you?" ), | 80 | "(PID = %1)\nThis can severly limit scanning!\nShould I kill it for you?" ).arg( dhcpid ), |
79 | QMessageBox::Yes, QMessageBox::No ); | 81 | QMessageBox::Yes, QMessageBox::No ); |
80 | if ( result == QMessageBox::Yes ) | 82 | if ( result == QMessageBox::Yes ) |
81 | { | 83 | { |
82 | if ( -1 == ::kill( OProcess::processPID( "dhcpc" ), SIGTERM ) ) | 84 | if ( -1 == ::kill( dhcpid, SIGTERM ) ) |
83 | qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); | 85 | qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); |
84 | else | 86 | else |
85 | killed = true; | 87 | killed = true; |
86 | } | 88 | } |
87 | } | 89 | } |
88 | } | 90 | } |
89 | 91 | ||
90 | a.exec(); | 92 | a.exec(); |
91 | 93 | ||
92 | if ( check ) | 94 | if ( check ) |
93 | { | 95 | { |
94 | 96 | ||
95 | if ( killed ) | 97 | if ( killed ) |
96 | { | 98 | { |
97 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); | 99 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); |
98 | if ( result == QMessageBox::Yes ) | 100 | if ( result == QMessageBox::Yes ) |
99 | { | 101 | { |
100 | ::system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); | 102 | ::system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); |
101 | } | 103 | } |
102 | } | 104 | } |
103 | 105 | ||
104 | delete w; | 106 | delete w; |
105 | } | 107 | } |
106 | return 0; | 108 | return 0; |
107 | } | 109 | } |
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index b462afd..72624f7 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -1,555 +1,555 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
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 "configwindow.h" | 16 | #include "configwindow.h" |
17 | #include "gps.h" | 17 | #include "gps.h" |
18 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | #include "hexwindow.h" | 19 | #include "hexwindow.h" |
20 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
21 | #include "wellenreiter.h" | 21 | #include "wellenreiter.h" |
22 | #include "scanlist.h" | 22 | #include "scanlist.h" |
23 | 23 | ||
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qdatastream.h> | 25 | #include <qdatastream.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qfileinfo.h> | 27 | #include <qfileinfo.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qiconset.h> | 31 | #include <qiconset.h> |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qstatusbar.h> | 36 | #include <qstatusbar.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
39 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
40 | 40 | ||
41 | #ifdef QWS | 41 | #ifdef QWS |
42 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
43 | #include <opie2/ofiledialog.h> | 43 | #include <opie2/ofiledialog.h> |
44 | using namespace Opie; | 44 | using namespace Opie; |
45 | #else | 45 | #else |
46 | #include "resource.h" | 46 | #include "resource.h" |
47 | #include <qapplication.h> | 47 | #include <qapplication.h> |
48 | #include <qfiledialog.h> | 48 | #include <qfiledialog.h> |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 51 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) |
52 | :QMainWindow( parent, name, f ) | 52 | :QMainWindow( parent, name, f ) |
53 | { | 53 | { |
54 | cw = new WellenreiterConfigWindow( this ); | 54 | cw = new WellenreiterConfigWindow( this ); |
55 | mw = new Wellenreiter( this ); | 55 | mw = new Wellenreiter( this ); |
56 | mw->setConfigWindow( cw ); | 56 | mw->setConfigWindow( cw ); |
57 | setCentralWidget( mw ); | 57 | setCentralWidget( mw ); |
58 | 58 | ||
59 | // setup application icon | 59 | // setup application icon |
60 | 60 | ||
61 | #ifndef QWS | 61 | #ifndef QWS |
62 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); | 62 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); |
63 | setIconText( "Wellenreiter/X11" ); | 63 | setIconText( "Wellenreiter/X11" ); |
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | // setup tool buttons | 66 | // setup tool buttons |
67 | 67 | ||
68 | startButton = new QToolButton( 0 ); | 68 | startButton = new QToolButton( 0 ); |
69 | #ifdef QWS | 69 | #ifdef QWS |
70 | startButton->setAutoRaise( true ); | 70 | startButton->setAutoRaise( true ); |
71 | #endif | 71 | #endif |
72 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); | 72 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); |
73 | startButton->setEnabled( false ); | 73 | startButton->setEnabled( false ); |
74 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); | 74 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); |
75 | 75 | ||
76 | stopButton = new QToolButton( 0 ); | 76 | stopButton = new QToolButton( 0 ); |
77 | #ifdef QWS | 77 | #ifdef QWS |
78 | stopButton->setAutoRaise( true ); | 78 | stopButton->setAutoRaise( true ); |
79 | #endif | 79 | #endif |
80 | stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); | 80 | stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); |
81 | stopButton->setEnabled( false ); | 81 | stopButton->setEnabled( false ); |
82 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); | 82 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); |
83 | 83 | ||
84 | QToolButton* d = new QToolButton( 0 ); | 84 | QToolButton* d = new QToolButton( 0 ); |
85 | #ifdef QWS | 85 | #ifdef QWS |
86 | d->setAutoRaise( true ); | 86 | d->setAutoRaise( true ); |
87 | #endif | 87 | #endif |
88 | d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); | 88 | d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); |
89 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); | 89 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); |
90 | 90 | ||
91 | uploadButton = new QToolButton( 0 ); | 91 | uploadButton = new QToolButton( 0 ); |
92 | #ifdef QWS | 92 | #ifdef QWS |
93 | uploadButton->setAutoRaise( true ); | 93 | uploadButton->setAutoRaise( true ); |
94 | #endif | 94 | #endif |
95 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); | 95 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); |
96 | uploadButton->setEnabled( false ); | 96 | uploadButton->setEnabled( false ); |
97 | //uploadButton->setEnabled( true ); // DEBUGGING | 97 | //uploadButton->setEnabled( true ); // DEBUGGING |
98 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); | 98 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); |
99 | 99 | ||
100 | // setup menu bar | 100 | // setup menu bar |
101 | 101 | ||
102 | int id; | 102 | int id; |
103 | 103 | ||
104 | QMenuBar* mb = menuBar(); | 104 | QMenuBar* mb = menuBar(); |
105 | 105 | ||
106 | QPopupMenu* fileSave = new QPopupMenu( mb ); | 106 | QPopupMenu* fileSave = new QPopupMenu( mb ); |
107 | fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); | 107 | fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); |
108 | fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); | 108 | fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); |
109 | fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); | 109 | fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); |
110 | 110 | ||
111 | QPopupMenu* fileLoad = new QPopupMenu( mb ); | 111 | QPopupMenu* fileLoad = new QPopupMenu( mb ); |
112 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); | 112 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); |
113 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); | 113 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); |
114 | 114 | ||
115 | QPopupMenu* file = new QPopupMenu( mb ); | 115 | QPopupMenu* file = new QPopupMenu( mb ); |
116 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); | 116 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); |
117 | id = file->insertItem( tr( "&Load" ), fileLoad ); | 117 | id = file->insertItem( tr( "&Load" ), fileLoad ); |
118 | file->insertItem( tr( "&Save" ), fileSave ); | 118 | file->insertItem( tr( "&Save" ), fileSave ); |
119 | file->insertSeparator(); | 119 | file->insertSeparator(); |
120 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); | 120 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); |
121 | file->insertSeparator(); | 121 | file->insertSeparator(); |
122 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); | 122 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); |
123 | 123 | ||
124 | QPopupMenu* view = new QPopupMenu( mb ); | 124 | QPopupMenu* view = new QPopupMenu( mb ); |
125 | view->insertItem( tr( "&Configure..." ) ); | 125 | view->insertItem( tr( "&Configure..." ) ); |
126 | 126 | ||
127 | QPopupMenu* sniffer = new QPopupMenu( mb ); | 127 | QPopupMenu* sniffer = new QPopupMenu( mb ); |
128 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); | 128 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); |
129 | sniffer->insertSeparator(); | 129 | sniffer->insertSeparator(); |
130 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); | 130 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); |
131 | sniffer->setItemEnabled( startID, false ); | 131 | sniffer->setItemEnabled( startID, false ); |
132 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); | 132 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); |
133 | sniffer->setItemEnabled( stopID, false ); | 133 | sniffer->setItemEnabled( stopID, false ); |
134 | 134 | ||
135 | QPopupMenu* demo = new QPopupMenu( mb ); | 135 | QPopupMenu* demo = new QPopupMenu( mb ); |
136 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); | 136 | demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); |
137 | demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); | 137 | demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); |
138 | 138 | ||
139 | id = mb->insertItem( tr( "&File" ), file ); | 139 | id = mb->insertItem( tr( "&File" ), file ); |
140 | //id = mb->insertItem( tr( "&View" ), view ); | 140 | //id = mb->insertItem( tr( "&View" ), view ); |
141 | //mb->setItemEnabled( id, false ); | 141 | //mb->setItemEnabled( id, false ); |
142 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); | 142 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); |
143 | 143 | ||
144 | id = mb->insertItem( tr( "&Demo" ), demo ); | 144 | id = mb->insertItem( tr( "&Demo" ), demo ); |
145 | mb->setItemEnabled( id, true ); | 145 | mb->setItemEnabled( id, true ); |
146 | mb->setItemEnabled( uploadID, false ); | 146 | mb->setItemEnabled( uploadID, false ); |
147 | 147 | ||
148 | #ifdef QWS | 148 | #ifdef QWS |
149 | mb->insertItem( startButton ); | 149 | mb->insertItem( startButton ); |
150 | mb->insertItem( stopButton ); | 150 | mb->insertItem( stopButton ); |
151 | mb->insertItem( uploadButton ); | 151 | mb->insertItem( uploadButton ); |
152 | mb->insertItem( d ); | 152 | mb->insertItem( d ); |
153 | #else // Qt3 changed the insertion order. It's now totally random :( | 153 | #else // Qt3 changed the insertion order. It's now totally random :( |
154 | mb->insertItem( d ); | 154 | mb->insertItem( d ); |
155 | mb->insertItem( uploadButton ); | 155 | mb->insertItem( uploadButton ); |
156 | mb->insertItem( stopButton ); | 156 | mb->insertItem( stopButton ); |
157 | mb->insertItem( startButton ); | 157 | mb->insertItem( startButton ); |
158 | #endif | 158 | #endif |
159 | 159 | ||
160 | updateToolButtonState(); | 160 | updateToolButtonState(); |
161 | 161 | ||
162 | // setup status bar (for now only on X11) | 162 | // setup status bar (for now only on X11) |
163 | 163 | ||
164 | #ifndef QWS | 164 | #ifndef QWS |
165 | statusBar()->message( tr( "Ready." ) ); | 165 | statusBar()->message( tr( "Ready." ) ); |
166 | #endif | 166 | #endif |
167 | 167 | ||
168 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); | 168 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); |
169 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); | 169 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); |
170 | }; | 170 | }; |
171 | 171 | ||
172 | 172 | ||
173 | 173 | ||
174 | void WellenreiterMainWindow::showConfigure() | 174 | void WellenreiterMainWindow::showConfigure() |
175 | { | 175 | { |
176 | qDebug( "show configure..." ); | 176 | qDebug( "show configure..." ); |
177 | cw->setCaption( tr( "Configure" ) ); | 177 | cw->setCaption( tr( "Configure" ) ); |
178 | #ifdef QWS | 178 | #ifdef QWS |
179 | cw->showMaximized(); | 179 | cw->showMaximized(); |
180 | #endif | 180 | #endif |
181 | int result = cw->exec(); | 181 | int result = cw->exec(); |
182 | 182 | ||
183 | if ( result ) updateToolButtonState(); | 183 | if ( result ) updateToolButtonState(); |
184 | } | 184 | } |
185 | 185 | ||
186 | 186 | ||
187 | void WellenreiterMainWindow::updateToolButtonState() | 187 | void WellenreiterMainWindow::updateToolButtonState() |
188 | { | 188 | { |
189 | const QString& interface = cw->interfaceName->currentText(); | 189 | const QString& interface = cw->interfaceName->currentText(); |
190 | const int cardtype = cw->driverType(); | 190 | const int cardtype = cw->driverType(); |
191 | 191 | ||
192 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | 192 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) |
193 | { | 193 | { |
194 | startButton->setEnabled( true ); | 194 | startButton->setEnabled( true ); |
195 | menuBar()->setItemEnabled( startID, true ); | 195 | menuBar()->setItemEnabled( startID, true ); |
196 | } | 196 | } |
197 | else | 197 | else |
198 | { | 198 | { |
199 | startButton->setEnabled( false ); | 199 | startButton->setEnabled( false ); |
200 | menuBar()->setItemEnabled( startID, false ); | 200 | menuBar()->setItemEnabled( startID, false ); |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | void WellenreiterMainWindow::changedSniffingState() | 205 | void WellenreiterMainWindow::changedSniffingState() |
206 | { | 206 | { |
207 | startButton->setEnabled( !mw->sniffing ); | 207 | startButton->setEnabled( !mw->sniffing ); |
208 | menuBar()->setItemEnabled( startID, !mw->sniffing ); | 208 | menuBar()->setItemEnabled( startID, !mw->sniffing ); |
209 | stopButton->setEnabled( mw->sniffing ); | 209 | stopButton->setEnabled( mw->sniffing ); |
210 | menuBar()->setItemEnabled( stopID, mw->sniffing ); | 210 | menuBar()->setItemEnabled( stopID, mw->sniffing ); |
211 | 211 | ||
212 | if ( !mw->sniffing ) | 212 | if ( !mw->sniffing ) |
213 | { | 213 | { |
214 | menuBar()->setItemEnabled( uploadID, true ); | 214 | menuBar()->setItemEnabled( uploadID, true ); |
215 | uploadButton->setEnabled( true ); | 215 | uploadButton->setEnabled( true ); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | 219 | ||
220 | WellenreiterMainWindow::~WellenreiterMainWindow() | 220 | WellenreiterMainWindow::~WellenreiterMainWindow() |
221 | { | 221 | { |
222 | qDebug( "Wellenreiter:: bye." ); | 222 | qDebug( "Wellenreiter:: bye." ); |
223 | }; | 223 | }; |
224 | 224 | ||
225 | 225 | ||
226 | void WellenreiterMainWindow::demoAddStations() | 226 | void WellenreiterMainWindow::demoAddStations() |
227 | { | 227 | { |
228 | //mw = 0; // test SIGSEGV handling | 228 | //mw = 0; // test SIGSEGV handling |
229 | 229 | ||
230 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); | 230 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); |
231 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); | 231 | mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); |
232 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); | 232 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); |
233 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); | 233 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); |
234 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); | 234 | mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); |
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | void WellenreiterMainWindow::demoReadFromGps() | 238 | void WellenreiterMainWindow::demoReadFromGps() |
239 | { | 239 | { |
240 | WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); | 240 | WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); |
241 | GPS* gps = new GPS( this ); | 241 | GPS* gps = new GPS( this ); |
242 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 242 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
243 | GpsLocation loc = gps->position(); | 243 | GpsLocation loc = gps->position(); |
244 | 244 | ||
245 | QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n$1" ).arg( loc.dmsPosition() ) ); | 245 | QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n%1" ).arg( loc.dmsPosition() ) ); |
246 | } | 246 | } |
247 | 247 | ||
248 | 248 | ||
249 | QString WellenreiterMainWindow::getFileName( bool save ) | 249 | QString WellenreiterMainWindow::getFileName( bool save ) |
250 | { | 250 | { |
251 | QMap<QString, QStringList> map; | 251 | QMap<QString, QStringList> map; |
252 | map.insert( tr("All"), QStringList() ); | 252 | map.insert( tr("All"), QStringList() ); |
253 | QStringList text; | 253 | QStringList text; |
254 | text << "text/*"; | 254 | text << "text/*"; |
255 | map.insert( tr("Text"), text ); | 255 | map.insert( tr("Text"), text ); |
256 | text << "*"; | 256 | text << "*"; |
257 | map.insert( tr("All"), text ); | 257 | map.insert( tr("All"), text ); |
258 | 258 | ||
259 | QString str; | 259 | QString str; |
260 | if ( save ) | 260 | if ( save ) |
261 | { | 261 | { |
262 | #ifdef QWS | 262 | #ifdef QWS |
263 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 263 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
264 | #else | 264 | #else |
265 | str = QFileDialog::getSaveFileName(); | 265 | str = QFileDialog::getSaveFileName(); |
266 | #endif | 266 | #endif |
267 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) | 267 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) |
268 | return ""; | 268 | return ""; |
269 | } | 269 | } |
270 | else | 270 | else |
271 | { | 271 | { |
272 | #ifdef QWS | 272 | #ifdef QWS |
273 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); | 273 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); |
274 | #else | 274 | #else |
275 | str = QFileDialog::getOpenFileName(); | 275 | str = QFileDialog::getOpenFileName(); |
276 | #endif | 276 | #endif |
277 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) | 277 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) |
278 | return ""; | 278 | return ""; |
279 | } | 279 | } |
280 | return str; | 280 | return str; |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | void WellenreiterMainWindow::fileSaveLog() | 284 | void WellenreiterMainWindow::fileSaveLog() |
285 | { | 285 | { |
286 | QString fname = getFileName( true ); | 286 | QString fname = getFileName( true ); |
287 | if ( !fname.isEmpty() ) | 287 | if ( !fname.isEmpty() ) |
288 | { | 288 | { |
289 | QFile f( fname ); | 289 | QFile f( fname ); |
290 | if ( f.open(IO_WriteOnly) ) | 290 | if ( f.open(IO_WriteOnly) ) |
291 | { | 291 | { |
292 | QTextStream t( &f ); | 292 | QTextStream t( &f ); |
293 | t << mw->logWindow()->getLog(); | 293 | t << mw->logWindow()->getLog(); |
294 | f.close(); | 294 | f.close(); |
295 | qDebug( "Saved log to file '%s'", (const char*) fname ); | 295 | qDebug( "Saved log to file '%s'", (const char*) fname ); |
296 | } | 296 | } |
297 | else | 297 | else |
298 | { | 298 | { |
299 | qDebug( "Problem saving log to file '%s'", (const char*) fname ); | 299 | qDebug( "Problem saving log to file '%s'", (const char*) fname ); |
300 | } | 300 | } |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | void WellenreiterMainWindow::fileSaveSession() | 304 | void WellenreiterMainWindow::fileSaveSession() |
305 | { | 305 | { |
306 | QString fname = getFileName( true ); | 306 | QString fname = getFileName( true ); |
307 | if ( !fname.isEmpty() ) | 307 | if ( !fname.isEmpty() ) |
308 | { | 308 | { |
309 | 309 | ||
310 | QFile f( fname ); | 310 | QFile f( fname ); |
311 | if ( f.open(IO_WriteOnly) ) | 311 | if ( f.open(IO_WriteOnly) ) |
312 | { | 312 | { |
313 | QDataStream t( &f ); | 313 | QDataStream t( &f ); |
314 | t << *mw->netView(); | 314 | t << *mw->netView(); |
315 | f.close(); | 315 | f.close(); |
316 | qDebug( "Saved session to file '%s'", (const char*) fname ); | 316 | qDebug( "Saved session to file '%s'", (const char*) fname ); |
317 | } | 317 | } |
318 | else | 318 | else |
319 | { | 319 | { |
320 | qDebug( "Problem saving session to file '%s'", (const char*) fname ); | 320 | qDebug( "Problem saving session to file '%s'", (const char*) fname ); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | } | 323 | } |
324 | 324 | ||
325 | void WellenreiterMainWindow::fileSaveHex() | 325 | void WellenreiterMainWindow::fileSaveHex() |
326 | { | 326 | { |
327 | QString fname = getFileName( true ); | 327 | QString fname = getFileName( true ); |
328 | if ( !fname.isEmpty() ) | 328 | if ( !fname.isEmpty() ) |
329 | { | 329 | { |
330 | QFile f( fname ); | 330 | QFile f( fname ); |
331 | if ( f.open(IO_WriteOnly) ) | 331 | if ( f.open(IO_WriteOnly) ) |
332 | { | 332 | { |
333 | QTextStream t( &f ); | 333 | QTextStream t( &f ); |
334 | t << mw->hexWindow()->getLog(); | 334 | t << mw->hexWindow()->getLog(); |
335 | f.close(); | 335 | f.close(); |
336 | qDebug( "Saved hex log to file '%s'", (const char*) fname ); | 336 | qDebug( "Saved hex log to file '%s'", (const char*) fname ); |
337 | } | 337 | } |
338 | else | 338 | else |
339 | { | 339 | { |
340 | qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); | 340 | qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | void WellenreiterMainWindow::fileLoadSession() | 345 | void WellenreiterMainWindow::fileLoadSession() |
346 | { | 346 | { |
347 | QString fname = getFileName( false ); | 347 | QString fname = getFileName( false ); |
348 | if ( !fname.isEmpty() ) | 348 | if ( !fname.isEmpty() ) |
349 | { | 349 | { |
350 | QFile f( fname ); | 350 | QFile f( fname ); |
351 | if ( f.open(IO_ReadOnly) ) | 351 | if ( f.open(IO_ReadOnly) ) |
352 | { | 352 | { |
353 | QDataStream t( &f ); | 353 | QDataStream t( &f ); |
354 | t >> *mw->netView(); | 354 | t >> *mw->netView(); |
355 | f.close(); | 355 | f.close(); |
356 | qDebug( "Loaded session from file '%s'", (const char*) fname ); | 356 | qDebug( "Loaded session from file '%s'", (const char*) fname ); |
357 | } | 357 | } |
358 | else | 358 | else |
359 | { | 359 | { |
360 | qDebug( "Problem loading session from file '%s'", (const char*) fname ); | 360 | qDebug( "Problem loading session from file '%s'", (const char*) fname ); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | void WellenreiterMainWindow::fileNew() | 366 | void WellenreiterMainWindow::fileNew() |
367 | { | 367 | { |
368 | mw->netView()->clear(); | 368 | mw->netView()->clear(); |
369 | mw->logWindow()->clear(); | 369 | mw->logWindow()->clear(); |
370 | mw->hexWindow()->clear(); | 370 | mw->hexWindow()->clear(); |
371 | } | 371 | } |
372 | 372 | ||
373 | 373 | ||
374 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) | 374 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) |
375 | { | 375 | { |
376 | if ( mw->isDaemonRunning() ) | 376 | if ( mw->isDaemonRunning() ) |
377 | { | 377 | { |
378 | QMessageBox::warning( this, "Wellenreiter/Opie", | 378 | QMessageBox::warning( this, "Wellenreiter/Opie", |
379 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); | 379 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); |
380 | e->ignore(); | 380 | e->ignore(); |
381 | } | 381 | } |
382 | else | 382 | else |
383 | { | 383 | { |
384 | QMainWindow::closeEvent( e ); | 384 | QMainWindow::closeEvent( e ); |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | static const char* CAP_hostname = "www.vanille.de"; | 388 | static const char* CAP_hostname = "www.vanille.de"; |
389 | 389 | ||
390 | #include <netdb.h> | 390 | #include <netdb.h> |
391 | #include <unistd.h> | 391 | #include <unistd.h> |
392 | #include <sys/types.h> | 392 | #include <sys/types.h> |
393 | #include <sys/socket.h> | 393 | #include <sys/socket.h> |
394 | 394 | ||
395 | void WellenreiterMainWindow::uploadSession() | 395 | void WellenreiterMainWindow::uploadSession() |
396 | { | 396 | { |
397 | QLineEdit* from; | 397 | QLineEdit* from; |
398 | QLineEdit* location; | 398 | QLineEdit* location; |
399 | QLineEdit* comments; | 399 | QLineEdit* comments; |
400 | QPushButton* accept; | 400 | QPushButton* accept; |
401 | QPushButton* reject; | 401 | QPushButton* reject; |
402 | 402 | ||
403 | QDialog* d = new QDialog( 0, "session upload", true ); | 403 | QDialog* d = new QDialog( 0, "session upload", true ); |
404 | d->setCaption( tr( "Upload Session" ) ); | 404 | d->setCaption( tr( "Upload Session" ) ); |
405 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); | 405 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); |
406 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); | 406 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); |
407 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); | 407 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); |
408 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); | 408 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); |
409 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); | 409 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); |
410 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); | 410 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); |
411 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); | 411 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); |
412 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); | 412 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); |
413 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); | 413 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); |
414 | accept->setDefault( true ); | 414 | accept->setDefault( true ); |
415 | accept->setAutoDefault( true ); | 415 | accept->setAutoDefault( true ); |
416 | from->setText( "WL II User" ); | 416 | from->setText( "WL II User" ); |
417 | location->setText( "WL II Location" ); | 417 | location->setText( "WL II Location" ); |
418 | comments->setText( "No Comments." ); | 418 | comments->setText( "No Comments." ); |
419 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); | 419 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); |
420 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); | 420 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); |
421 | int result = d->exec(); | 421 | int result = d->exec(); |
422 | 422 | ||
423 | if ( !result ) | 423 | if ( !result ) |
424 | { | 424 | { |
425 | qDebug( "Session upload cancelled :(" ); | 425 | qDebug( "Session upload cancelled :(" ); |
426 | return; | 426 | return; |
427 | } | 427 | } |
428 | 428 | ||
429 | qDebug( "Starting upload..." ); | 429 | qDebug( "Starting upload..." ); |
430 | 430 | ||
431 | struct sockaddr_in raddr; | 431 | struct sockaddr_in raddr; |
432 | struct hostent *rhost_info; | 432 | struct hostent *rhost_info; |
433 | int sock = -1; | 433 | int sock = -1; |
434 | bool ok = false; | 434 | bool ok = false; |
435 | 435 | ||
436 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); | 436 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); |
437 | if ( rhost_info ) | 437 | if ( rhost_info ) |
438 | { | 438 | { |
439 | 439 | ||
440 | 440 | ||
441 | if ( !QFile::exists( mw->captureFileName() ) ) | 441 | if ( !QFile::exists( mw->captureFileName() ) ) |
442 | { | 442 | { |
443 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); | 443 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); |
444 | return; | 444 | return; |
445 | } | 445 | } |
446 | 446 | ||
447 | QFile f( mw->captureFileName() ); | 447 | QFile f( mw->captureFileName() ); |
448 | if ( !f.open( IO_ReadOnly ) ) | 448 | if ( !f.open( IO_ReadOnly ) ) |
449 | { | 449 | { |
450 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); | 450 | QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); |
451 | return; | 451 | return; |
452 | } | 452 | } |
453 | 453 | ||
454 | int content_length = f.size(); | 454 | int content_length = f.size(); |
455 | 455 | ||
456 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); | 456 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); |
457 | ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 457 | ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
458 | raddr.sin_family = rhost_info-> h_addrtype; | 458 | raddr.sin_family = rhost_info-> h_addrtype; |
459 | raddr.sin_port = htons ( 80 ); | 459 | raddr.sin_port = htons ( 80 ); |
460 | 460 | ||
461 | sock = ::socket( AF_INET, SOCK_STREAM, 0 ); | 461 | sock = ::socket( AF_INET, SOCK_STREAM, 0 ); |
462 | 462 | ||
463 | if ( sock >= 0 ) | 463 | if ( sock >= 0 ) |
464 | { | 464 | { |
465 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) | 465 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) |
466 | { | 466 | { |
467 | QString header; | 467 | QString header; |
468 | QString content; | 468 | QString content; |
469 | QString preambel; | 469 | QString preambel; |
470 | 470 | ||
471 | header = "" | 471 | header = "" |
472 | "POST /projects/capturedump.spy HTTP/1.1\r\n" | 472 | "POST /projects/capturedump.spy HTTP/1.1\r\n" |
473 | "Host: www.vanille.de\r\n" | 473 | "Host: www.vanille.de\r\n" |
474 | "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n" | 474 | "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n" |
475 | "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n" | 475 | "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n" |
476 | "Accept-Language: en\r\n" | 476 | "Accept-Language: en\r\n" |
477 | "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" | 477 | "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" |
478 | "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n" | 478 | "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n" |
479 | "Keep-Alive: 300\r\n" | 479 | "Keep-Alive: 300\r\n" |
480 | "Connection: keep-alive\r\n" | 480 | "Connection: keep-alive\r\n" |
481 | "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" | 481 | "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" |
482 | "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" | 482 | "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" |
483 | "Content-Length: %1\r\n" | 483 | "Content-Length: %1\r\n" |
484 | "\r\n"; | 484 | "\r\n"; |
485 | 485 | ||
486 | content = "" | 486 | content = "" |
487 | "-----------------------------97267758015830030481215568065\r\n" | 487 | "-----------------------------97267758015830030481215568065\r\n" |
488 | "Content-Disposition: form-data; name=\"Name\"\r\n" | 488 | "Content-Disposition: form-data; name=\"Name\"\r\n" |
489 | "\r\n" | 489 | "\r\n" |
490 | "%1\r\n" | 490 | "%1\r\n" |
491 | "-----------------------------97267758015830030481215568065\r\n" | 491 | "-----------------------------97267758015830030481215568065\r\n" |
492 | "Content-Disposition: form-data; name=\"Location\"\r\n" | 492 | "Content-Disposition: form-data; name=\"Location\"\r\n" |
493 | "\r\n" | 493 | "\r\n" |
494 | "%2\r\n" | 494 | "%2\r\n" |
495 | "-----------------------------97267758015830030481215568065\r\n" | 495 | "-----------------------------97267758015830030481215568065\r\n" |
496 | "Content-Disposition: form-data; name=\"Comments\"\r\n" | 496 | "Content-Disposition: form-data; name=\"Comments\"\r\n" |
497 | "\r\n" | 497 | "\r\n" |
498 | "%3\r\n" | 498 | "%3\r\n" |
499 | "-----------------------------97267758015830030481215568065\r\n" | 499 | "-----------------------------97267758015830030481215568065\r\n" |
500 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" | 500 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" |
501 | "Content-Type: application/octet-stream\r\n" | 501 | "Content-Type: application/octet-stream\r\n" |
502 | "\r\n"; | 502 | "\r\n"; |
503 | 503 | ||
504 | preambel = "" | 504 | preambel = "" |
505 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; | 505 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; |
506 | 506 | ||
507 | content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); | 507 | content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); |
508 | content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); | 508 | content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); |
509 | content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); | 509 | content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); |
510 | content = content.arg( mw->captureFileName() ); | 510 | content = content.arg( mw->captureFileName() ); |
511 | 511 | ||
512 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); | 512 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); |
513 | 513 | ||
514 | // write header | 514 | // write header |
515 | 515 | ||
516 | const char* ascii = header.latin1(); | 516 | const char* ascii = header.latin1(); |
517 | uint ascii_len = ::strlen( ascii ); | 517 | uint ascii_len = ::strlen( ascii ); |
518 | ::write ( sock, ascii, ascii_len ); | 518 | ::write ( sock, ascii, ascii_len ); |
519 | 519 | ||
520 | // write fixed content | 520 | // write fixed content |
521 | 521 | ||
522 | ascii = content.latin1(); | 522 | ascii = content.latin1(); |
523 | ascii_len = ::strlen( ascii ); | 523 | ascii_len = ::strlen( ascii ); |
524 | ::write ( sock, ascii, ascii_len ); | 524 | ::write ( sock, ascii, ascii_len ); |
525 | 525 | ||
526 | // write variable content | 526 | // write variable content |
527 | 527 | ||
528 | char ch; | 528 | char ch; |
529 | while ( !f.atEnd() ) | 529 | while ( !f.atEnd() ) |
530 | { | 530 | { |
531 | f.readBlock( &ch, 1 ); | 531 | f.readBlock( &ch, 1 ); |
532 | ::write ( sock, &ch, 1 ); | 532 | ::write ( sock, &ch, 1 ); |
533 | } | 533 | } |
534 | 534 | ||
535 | // write preambel | 535 | // write preambel |
536 | 536 | ||
537 | ascii = preambel.latin1(); | 537 | ascii = preambel.latin1(); |
538 | ascii_len = ::strlen( ascii ); | 538 | ascii_len = ::strlen( ascii ); |
539 | ::write ( sock, ascii, ascii_len ); | 539 | ::write ( sock, ascii, ascii_len ); |
540 | 540 | ||
541 | // done! | 541 | // done! |
542 | 542 | ||
543 | ok = true; | 543 | ok = true; |
544 | } | 544 | } |
545 | } | 545 | } |
546 | ::close ( sock ); | 546 | ::close ( sock ); |
547 | } | 547 | } |
548 | if ( ok ) | 548 | if ( ok ) |
549 | QMessageBox::information( 0, tr( "Success" ), | 549 | QMessageBox::information( 0, tr( "Success" ), |
550 | QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); | 550 | QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); |
551 | else | 551 | else |
552 | QMessageBox::warning( 0, tr( "Error" ), | 552 | QMessageBox::warning( 0, tr( "Error" ), |
553 | QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); | 553 | QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); |
554 | } | 554 | } |
555 | 555 | ||