-rw-r--r-- | noncore/net/wellenreiter/TODO | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 34 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 15 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.h | 1 |
4 files changed, 32 insertions, 20 deletions
diff --git a/noncore/net/wellenreiter/TODO b/noncore/net/wellenreiter/TODO index fd70fc7..b6ec617 100644 --- a/noncore/net/wellenreiter/TODO +++ b/noncore/net/wellenreiter/TODO | |||
@@ -1,58 +1,60 @@ | |||
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) | ||
34 | |||
33 | --------- | 35 | --------- |
34 | UI | 36 | UI |
35 | --------- | 37 | --------- |
36 | 38 | ||
37 | - display interface capabilities (or rewrite networksettings?) | 39 | - display interface capabilities (or rewrite networksettings?) |
38 | 40 | ||
39 | - distinguish wireless bridges (WDS traffic) | 41 | - distinguish wireless bridges (WDS traffic) |
40 | 42 | ||
41 | - expand/collapse all | 43 | - expand/collapse all |
42 | 44 | ||
43 | - add configuration for scrollback buffer in hex window and log window | 45 | - add configuration for scrollback buffer in hex window and log window |
44 | 46 | ||
45 | - revamp hex window, make it more sophisticated than just a QMultiLineEdit | 47 | - revamp hex window, make it more sophisticated than just a QMultiLineEdit |
46 | - tree view | 48 | - tree view |
47 | 49 | ||
48 | - beep over headphone / customizable | 50 | - beep over headphone / customizable |
49 | 51 | ||
50 | --------- | 52 | --------- |
51 | FILES | 53 | FILES |
52 | --------- | 54 | --------- |
53 | 55 | ||
54 | - write kismet-like .network format and format to be importable into AutoRoute | 56 | - write kismet-like .network format and format to be importable into AutoRoute |
55 | 57 | ||
56 | - implement beacon stripping (the first beacon is enough to detect a | 58 | - implement beacon stripping (the first beacon is enough to detect a |
57 | new network - further beacons just blow up the capture file) | 59 | new network - further beacons just blow up the capture file) |
58 | 60 | ||
diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp index b814427..5b1b4a4 100644 --- a/noncore/net/wellenreiter/gui/gps.cpp +++ b/noncore/net/wellenreiter/gui/gps.cpp | |||
@@ -1,131 +1,127 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2003 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 "gps.h" | 16 | #include "gps.h" |
17 | 17 | ||
18 | /* QT */ | 18 | /* QT */ |
19 | #include <qtextstream.h> | 19 | #include <qtextstream.h> |
20 | 20 | ||
21 | /* STD */ | 21 | /* STD */ |
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <unistd.h> | 23 | #include <unistd.h> |
24 | 24 | ||
25 | GPS::GPS( QObject* parent, const char * name ) | 25 | GPS::GPS( QObject* parent, const char * name ) |
26 | :QObject( parent, name ) | 26 | :QObject( parent, name ) |
27 | { | 27 | { |
28 | qDebug( "GPS::GPS()" ); | 28 | qDebug( "GPS::GPS()" ); |
29 | _socket = new QSocket( this, "gpsd commsock" ); | 29 | _socket = new QSocket( this, "gpsd commsock" ); |
30 | } | 30 | } |
31 | 31 | ||
32 | 32 | ||
33 | GPS::~GPS() | 33 | GPS::~GPS() |
34 | { | 34 | { |
35 | qDebug( "GPS::~GPS()" ); | 35 | qDebug( "GPS::~GPS()" ); |
36 | } | 36 | } |
37 | 37 | ||
38 | 38 | ||
39 | bool GPS::open( const QString& host, int port ) | 39 | bool GPS::open( const QString& host, int port ) |
40 | { | 40 | { |
41 | _socket->connectToHost( host, port ); | 41 | _socket->connectToHost( host, port ); |
42 | } | 42 | } |
43 | 43 | ||
44 | 44 | ||
45 | GpsLocation GPS::position() const | 45 | GpsLocation GPS::position() const |
46 | { | 46 | { |
47 | char buf[256]; | 47 | char buf[256]; |
48 | double lat = -111.0; | ||
49 | double lon = -111.0; | ||
48 | 50 | ||
49 | int result = _socket->writeBlock( "p\r\n", 3 ); | 51 | int result = _socket->writeBlock( "p\r\n", 3 ); |
50 | _socket->flush(); | 52 | _socket->flush(); |
51 | if ( result ) | 53 | if ( result ) |
52 | { | 54 | { |
53 | int numAvail = _socket->bytesAvailable(); | 55 | int numAvail = _socket->bytesAvailable(); |
54 | qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); | 56 | qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); |
55 | if ( numAvail ) | 57 | if ( numAvail ) |
56 | { | 58 | { |
57 | QTextStream stream( _socket ); | 59 | int numRead = _socket->readBlock( &buf[0], sizeof buf ); |
58 | 60 | int numScan = sscanf( &buf[0], "GPSD,P=%lg %lg", &lat, &lon); | |
59 | QString str; | 61 | |
60 | stream.readRawBytes( &buf[0], 7 ); | 62 | if ( numRead < 7 || numScan != 2 ) |
61 | float lat = -111; | 63 | { |
62 | stream >> lat; | 64 | qDebug( "GPS read %d bytes succeeded, invalid response: '%s'", numRead, &buf[0] ); |
63 | stream.skipWhiteSpace(); | 65 | return GpsLocation( -111, -111 ); |
64 | float lon = -111; | 66 | } |
65 | stream >> lon; | 67 | else |
66 | stream.readRawBytes( &buf[0], 200 ); // read and discard the stuff until EOF | 68 | { |
67 | 69 | return GpsLocation( lat, lon ); | |
68 | return GpsLocation( lat, lon ); | 70 | } |
69 | } | 71 | } |
70 | } | 72 | } |
71 | return GpsLocation( -111, -111 ); | 73 | return GpsLocation( -111, -111 ); |
72 | } | 74 | } |
73 | 75 | ||
74 | 76 | ||
75 | QString GpsLocation::dmsPosition() const | 77 | QString GpsLocation::dmsPosition() const |
76 | { | 78 | { |
77 | if ( _latitude == -111 || _longitude == -111 ) | 79 | if ( _latitude == -111 || _longitude == -111 ) |
78 | return "N/A"; | 80 | return "N/A"; |
79 | if ( _latitude == 0.0 && _longitude == 0.0 ) | 81 | if ( _latitude == 0.0 && _longitude == 0.0 ) |
80 | return "NULL"; | 82 | return "NULL"; |
81 | 83 | ||
82 | /* compute latitude */ | 84 | /* compute latitude */ |
83 | 85 | ||
84 | QString dms = "N"; | 86 | QString dms = "N"; |
85 | if ( _latitude >= 0 ) dms.append( "+" ); | 87 | if ( _latitude >= 0 ) dms.append( "+" ); |
86 | 88 | ||
87 | int trunc = int( _latitude ); | 89 | int trunc = int( _latitude ); |
88 | float rest = _latitude - trunc; | 90 | float rest = _latitude - trunc; |
89 | 91 | ||
90 | float minf = rest * 60; | 92 | float minf = rest * 60; |
91 | int minutes = int( minf ); | 93 | int minutes = int( minf ); |
92 | 94 | ||
93 | rest = minf - minutes; | 95 | rest = minf - minutes; |
94 | int seconds = int( rest * 60 ); | 96 | int seconds = int( rest * 60 ); |
95 | 97 | ||
96 | dms.append( QString::number( trunc ) ); | 98 | dms.append( QString::number( trunc ) ); |
97 | dms.append( "° " ); | 99 | dms.append( "° " ); |
98 | dms.append( QString::number( ::abs( minutes ) ) ); | 100 | dms.append( QString::number( ::abs( minutes ) ) ); |
99 | dms.append( "' " ); | 101 | dms.append( "' " ); |
100 | dms.append( QString::number( ::abs( seconds ) ) ); | 102 | dms.append( QString::number( ::abs( seconds ) ) ); |
101 | dms.append( "'' " ); | 103 | dms.append( "'' " ); |
102 | 104 | ||
103 | /* compute longitude */ | 105 | /* compute longitude */ |
104 | 106 | ||
105 | dms.append( " | W" ); | 107 | dms.append( " | W" ); |
106 | if ( _longitude > 0 ) dms.append( "+" ); | 108 | if ( _longitude > 0 ) dms.append( "+" ); |
107 | 109 | ||
108 | trunc = int( _longitude ); | 110 | trunc = int( _longitude ); |
109 | rest = _longitude - trunc; | 111 | rest = _longitude - trunc; |
110 | 112 | ||
111 | minf = rest * 60; | 113 | minf = rest * 60; |
112 | minutes = int( minf ); | 114 | minutes = int( minf ); |
113 | 115 | ||
114 | rest = minf - minutes; | 116 | rest = minf - minutes; |
115 | seconds = int( rest * 60 ); | 117 | seconds = int( rest * 60 ); |
116 | 118 | ||
117 | dms.append( QString::number( trunc ) ); | 119 | dms.append( QString::number( trunc ) ); |
118 | dms.append( "° " ); | 120 | dms.append( "° " ); |
119 | dms.append( QString::number( ::abs( minutes ) ) ); | 121 | dms.append( QString::number( ::abs( minutes ) ) ); |
120 | dms.append( "' " ); | 122 | dms.append( "' " ); |
121 | dms.append( QString::number( ::abs( seconds ) ) ); | 123 | dms.append( QString::number( ::abs( seconds ) ) ); |
122 | dms.append( "'' " ); | 124 | dms.append( "'' " ); |
123 | 125 | ||
124 | return dms; | 126 | return dms; |
125 | } | 127 | } |
126 | |||
127 | |||
128 | |||
129 | |||
130 | |||
131 | |||
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 05a8913..b462afd 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp | |||
@@ -1,542 +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 <qtextstream.h> | 38 | #include <qtextstream.h> |
38 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
39 | 40 | ||
40 | #ifdef QWS | 41 | #ifdef QWS |
41 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
42 | #include <opie2/ofiledialog.h> | 43 | #include <opie2/ofiledialog.h> |
43 | using namespace Opie; | 44 | using namespace Opie; |
44 | #else | 45 | #else |
45 | #include "resource.h" | 46 | #include "resource.h" |
46 | #include <qapplication.h> | 47 | #include <qapplication.h> |
47 | #include <qfiledialog.h> | 48 | #include <qfiledialog.h> |
48 | #endif | 49 | #endif |
49 | 50 | ||
50 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) | 51 | WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) |
51 | :QMainWindow( parent, name, f ) | 52 | :QMainWindow( parent, name, f ) |
52 | { | 53 | { |
53 | cw = new WellenreiterConfigWindow( this ); | 54 | cw = new WellenreiterConfigWindow( this ); |
54 | mw = new Wellenreiter( this ); | 55 | mw = new Wellenreiter( this ); |
55 | mw->setConfigWindow( cw ); | 56 | mw->setConfigWindow( cw ); |
56 | setCentralWidget( mw ); | 57 | setCentralWidget( mw ); |
57 | 58 | ||
58 | // setup application icon | 59 | // setup application icon |
59 | 60 | ||
60 | #ifndef QWS | 61 | #ifndef QWS |
61 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); | 62 | setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); |
62 | setIconText( "Wellenreiter/X11" ); | 63 | setIconText( "Wellenreiter/X11" ); |
63 | #endif | 64 | #endif |
64 | 65 | ||
65 | // setup tool buttons | 66 | // setup tool buttons |
66 | 67 | ||
67 | startButton = new QToolButton( 0 ); | 68 | startButton = new QToolButton( 0 ); |
68 | #ifdef QWS | 69 | #ifdef QWS |
69 | startButton->setAutoRaise( true ); | 70 | startButton->setAutoRaise( true ); |
70 | #endif | 71 | #endif |
71 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); | 72 | startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); |
72 | startButton->setEnabled( false ); | 73 | startButton->setEnabled( false ); |
73 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); | 74 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); |
74 | 75 | ||
75 | stopButton = new QToolButton( 0 ); | 76 | stopButton = new QToolButton( 0 ); |
76 | #ifdef QWS | 77 | #ifdef QWS |
77 | stopButton->setAutoRaise( true ); | 78 | stopButton->setAutoRaise( true ); |
78 | #endif | 79 | #endif |
79 | stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); | 80 | stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); |
80 | stopButton->setEnabled( false ); | 81 | stopButton->setEnabled( false ); |
81 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); | 82 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); |
82 | 83 | ||
83 | QToolButton* d = new QToolButton( 0 ); | 84 | QToolButton* d = new QToolButton( 0 ); |
84 | #ifdef QWS | 85 | #ifdef QWS |
85 | d->setAutoRaise( true ); | 86 | d->setAutoRaise( true ); |
86 | #endif | 87 | #endif |
87 | d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); | 88 | d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); |
88 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); | 89 | connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); |
89 | 90 | ||
90 | uploadButton = new QToolButton( 0 ); | 91 | uploadButton = new QToolButton( 0 ); |
91 | #ifdef QWS | 92 | #ifdef QWS |
92 | uploadButton->setAutoRaise( true ); | 93 | uploadButton->setAutoRaise( true ); |
93 | #endif | 94 | #endif |
94 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); | 95 | uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); |
95 | uploadButton->setEnabled( false ); | 96 | uploadButton->setEnabled( false ); |
96 | //uploadButton->setEnabled( true ); // DEBUGGING | 97 | //uploadButton->setEnabled( true ); // DEBUGGING |
97 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); | 98 | connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); |
98 | 99 | ||
99 | // setup menu bar | 100 | // setup menu bar |
100 | 101 | ||
101 | int id; | 102 | int id; |
102 | 103 | ||
103 | QMenuBar* mb = menuBar(); | 104 | QMenuBar* mb = menuBar(); |
104 | 105 | ||
105 | QPopupMenu* fileSave = new QPopupMenu( mb ); | 106 | QPopupMenu* fileSave = new QPopupMenu( mb ); |
106 | fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); | 107 | fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); |
107 | fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); | 108 | fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); |
108 | fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); | 109 | fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); |
109 | 110 | ||
110 | QPopupMenu* fileLoad = new QPopupMenu( mb ); | 111 | QPopupMenu* fileLoad = new QPopupMenu( mb ); |
111 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); | 112 | fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); |
112 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); | 113 | //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); |
113 | 114 | ||
114 | QPopupMenu* file = new QPopupMenu( mb ); | 115 | QPopupMenu* file = new QPopupMenu( mb ); |
115 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); | 116 | file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); |
116 | id = file->insertItem( tr( "&Load" ), fileLoad ); | 117 | id = file->insertItem( tr( "&Load" ), fileLoad ); |
117 | file->insertItem( tr( "&Save" ), fileSave ); | 118 | file->insertItem( tr( "&Save" ), fileSave ); |
118 | file->insertSeparator(); | 119 | file->insertSeparator(); |
119 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); | 120 | uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); |
120 | file->insertSeparator(); | 121 | file->insertSeparator(); |
121 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); | 122 | file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); |
122 | 123 | ||
123 | QPopupMenu* view = new QPopupMenu( mb ); | 124 | QPopupMenu* view = new QPopupMenu( mb ); |
124 | view->insertItem( tr( "&Configure..." ) ); | 125 | view->insertItem( tr( "&Configure..." ) ); |
125 | 126 | ||
126 | QPopupMenu* sniffer = new QPopupMenu( mb ); | 127 | QPopupMenu* sniffer = new QPopupMenu( mb ); |
127 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); | 128 | sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); |
128 | sniffer->insertSeparator(); | 129 | sniffer->insertSeparator(); |
129 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); | 130 | startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); |
130 | sniffer->setItemEnabled( startID, false ); | 131 | sniffer->setItemEnabled( startID, false ); |
131 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); | 132 | stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); |
132 | sniffer->setItemEnabled( stopID, false ); | 133 | sniffer->setItemEnabled( stopID, false ); |
133 | 134 | ||
134 | QPopupMenu* demo = new QPopupMenu( mb ); | 135 | QPopupMenu* demo = new QPopupMenu( mb ); |
135 | 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() ) ); | ||
136 | 138 | ||
137 | id = mb->insertItem( tr( "&File" ), file ); | 139 | id = mb->insertItem( tr( "&File" ), file ); |
138 | //id = mb->insertItem( tr( "&View" ), view ); | 140 | //id = mb->insertItem( tr( "&View" ), view ); |
139 | //mb->setItemEnabled( id, false ); | 141 | //mb->setItemEnabled( id, false ); |
140 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); | 142 | id = mb->insertItem( tr( "&Sniffer" ), sniffer ); |
141 | 143 | ||
142 | id = mb->insertItem( tr( "&Demo" ), demo ); | 144 | id = mb->insertItem( tr( "&Demo" ), demo ); |
143 | mb->setItemEnabled( id, true ); | 145 | mb->setItemEnabled( id, true ); |
144 | mb->setItemEnabled( uploadID, false ); | 146 | mb->setItemEnabled( uploadID, false ); |
145 | 147 | ||
146 | #ifdef QWS | 148 | #ifdef QWS |
147 | mb->insertItem( startButton ); | 149 | mb->insertItem( startButton ); |
148 | mb->insertItem( stopButton ); | 150 | mb->insertItem( stopButton ); |
149 | mb->insertItem( uploadButton ); | 151 | mb->insertItem( uploadButton ); |
150 | mb->insertItem( d ); | 152 | mb->insertItem( d ); |
151 | #else // Qt3 changed the insertion order. It's now totally random :( | 153 | #else // Qt3 changed the insertion order. It's now totally random :( |
152 | mb->insertItem( d ); | 154 | mb->insertItem( d ); |
153 | mb->insertItem( uploadButton ); | 155 | mb->insertItem( uploadButton ); |
154 | mb->insertItem( stopButton ); | 156 | mb->insertItem( stopButton ); |
155 | mb->insertItem( startButton ); | 157 | mb->insertItem( startButton ); |
156 | #endif | 158 | #endif |
157 | 159 | ||
158 | updateToolButtonState(); | 160 | updateToolButtonState(); |
159 | 161 | ||
160 | // setup status bar (for now only on X11) | 162 | // setup status bar (for now only on X11) |
161 | 163 | ||
162 | #ifndef QWS | 164 | #ifndef QWS |
163 | statusBar()->message( tr( "Ready." ) ); | 165 | statusBar()->message( tr( "Ready." ) ); |
164 | #endif | 166 | #endif |
165 | 167 | ||
166 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); | 168 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); |
167 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); | 169 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); |
168 | }; | 170 | }; |
169 | 171 | ||
170 | 172 | ||
171 | 173 | ||
172 | void WellenreiterMainWindow::showConfigure() | 174 | void WellenreiterMainWindow::showConfigure() |
173 | { | 175 | { |
174 | qDebug( "show configure..." ); | 176 | qDebug( "show configure..." ); |
175 | cw->setCaption( tr( "Configure" ) ); | 177 | cw->setCaption( tr( "Configure" ) ); |
176 | #ifdef QWS | 178 | #ifdef QWS |
177 | cw->showMaximized(); | 179 | cw->showMaximized(); |
178 | #endif | 180 | #endif |
179 | int result = cw->exec(); | 181 | int result = cw->exec(); |
180 | 182 | ||
181 | if ( result ) updateToolButtonState(); | 183 | if ( result ) updateToolButtonState(); |
182 | } | 184 | } |
183 | 185 | ||
184 | 186 | ||
185 | void WellenreiterMainWindow::updateToolButtonState() | 187 | void WellenreiterMainWindow::updateToolButtonState() |
186 | { | 188 | { |
187 | const QString& interface = cw->interfaceName->currentText(); | 189 | const QString& interface = cw->interfaceName->currentText(); |
188 | const int cardtype = cw->driverType(); | 190 | const int cardtype = cw->driverType(); |
189 | 191 | ||
190 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | 192 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) |
191 | { | 193 | { |
192 | startButton->setEnabled( true ); | 194 | startButton->setEnabled( true ); |
193 | menuBar()->setItemEnabled( startID, true ); | 195 | menuBar()->setItemEnabled( startID, true ); |
194 | } | 196 | } |
195 | else | 197 | else |
196 | { | 198 | { |
197 | startButton->setEnabled( false ); | 199 | startButton->setEnabled( false ); |
198 | menuBar()->setItemEnabled( startID, false ); | 200 | menuBar()->setItemEnabled( startID, false ); |
199 | } | 201 | } |
200 | } | 202 | } |
201 | 203 | ||
202 | 204 | ||
203 | void WellenreiterMainWindow::changedSniffingState() | 205 | void WellenreiterMainWindow::changedSniffingState() |
204 | { | 206 | { |
205 | startButton->setEnabled( !mw->sniffing ); | 207 | startButton->setEnabled( !mw->sniffing ); |
206 | menuBar()->setItemEnabled( startID, !mw->sniffing ); | 208 | menuBar()->setItemEnabled( startID, !mw->sniffing ); |
207 | stopButton->setEnabled( mw->sniffing ); | 209 | stopButton->setEnabled( mw->sniffing ); |
208 | menuBar()->setItemEnabled( stopID, mw->sniffing ); | 210 | menuBar()->setItemEnabled( stopID, mw->sniffing ); |
209 | 211 | ||
210 | if ( !mw->sniffing ) | 212 | if ( !mw->sniffing ) |
211 | { | 213 | { |
212 | menuBar()->setItemEnabled( uploadID, true ); | 214 | menuBar()->setItemEnabled( uploadID, true ); |
213 | uploadButton->setEnabled( true ); | 215 | uploadButton->setEnabled( true ); |
214 | } | 216 | } |
215 | } | 217 | } |
216 | 218 | ||
217 | 219 | ||
218 | WellenreiterMainWindow::~WellenreiterMainWindow() | 220 | WellenreiterMainWindow::~WellenreiterMainWindow() |
219 | { | 221 | { |
220 | qDebug( "Wellenreiter:: bye." ); | 222 | qDebug( "Wellenreiter:: bye." ); |
221 | }; | 223 | }; |
222 | 224 | ||
223 | 225 | ||
224 | void WellenreiterMainWindow::demoAddStations() | 226 | void WellenreiterMainWindow::demoAddStations() |
225 | { | 227 | { |
226 | //mw = 0; // test SIGSGV handling | 228 | //mw = 0; // test SIGSEGV handling |
227 | 229 | ||
228 | 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) ); |
229 | 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 ) ); |
230 | 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 ) ); |
231 | 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 ) ); |
232 | 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 ) ); |
233 | } | 235 | } |
234 | 236 | ||
235 | 237 | ||
238 | void WellenreiterMainWindow::demoReadFromGps() | ||
239 | { | ||
240 | WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); | ||
241 | GPS* gps = new GPS( this ); | ||
242 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | ||
243 | GpsLocation loc = gps->position(); | ||
244 | |||
245 | QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n$1" ).arg( loc.dmsPosition() ) ); | ||
246 | } | ||
247 | |||
248 | |||
236 | QString WellenreiterMainWindow::getFileName( bool save ) | 249 | QString WellenreiterMainWindow::getFileName( bool save ) |
237 | { | 250 | { |
238 | QMap<QString, QStringList> map; | 251 | QMap<QString, QStringList> map; |
239 | map.insert( tr("All"), QStringList() ); | 252 | map.insert( tr("All"), QStringList() ); |
240 | QStringList text; | 253 | QStringList text; |
241 | text << "text/*"; | 254 | text << "text/*"; |
242 | map.insert( tr("Text"), text ); | 255 | map.insert( tr("Text"), text ); |
243 | text << "*"; | 256 | text << "*"; |
244 | map.insert( tr("All"), text ); | 257 | map.insert( tr("All"), text ); |
245 | 258 | ||
246 | QString str; | 259 | QString str; |
247 | if ( save ) | 260 | if ( save ) |
248 | { | 261 | { |
249 | #ifdef QWS | 262 | #ifdef QWS |
250 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 263 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
251 | #else | 264 | #else |
252 | str = QFileDialog::getSaveFileName(); | 265 | str = QFileDialog::getSaveFileName(); |
253 | #endif | 266 | #endif |
254 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) | 267 | if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) |
255 | return ""; | 268 | return ""; |
256 | } | 269 | } |
257 | else | 270 | else |
258 | { | 271 | { |
259 | #ifdef QWS | 272 | #ifdef QWS |
260 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); | 273 | str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); |
261 | #else | 274 | #else |
262 | str = QFileDialog::getOpenFileName(); | 275 | str = QFileDialog::getOpenFileName(); |
263 | #endif | 276 | #endif |
264 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) | 277 | if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) |
265 | return ""; | 278 | return ""; |
266 | } | 279 | } |
267 | return str; | 280 | return str; |
268 | } | 281 | } |
269 | 282 | ||
270 | 283 | ||
271 | void WellenreiterMainWindow::fileSaveLog() | 284 | void WellenreiterMainWindow::fileSaveLog() |
272 | { | 285 | { |
273 | QString fname = getFileName( true ); | 286 | QString fname = getFileName( true ); |
274 | if ( !fname.isEmpty() ) | 287 | if ( !fname.isEmpty() ) |
275 | { | 288 | { |
276 | QFile f( fname ); | 289 | QFile f( fname ); |
277 | if ( f.open(IO_WriteOnly) ) | 290 | if ( f.open(IO_WriteOnly) ) |
278 | { | 291 | { |
279 | QTextStream t( &f ); | 292 | QTextStream t( &f ); |
280 | t << mw->logWindow()->getLog(); | 293 | t << mw->logWindow()->getLog(); |
281 | f.close(); | 294 | f.close(); |
282 | qDebug( "Saved log to file '%s'", (const char*) fname ); | 295 | qDebug( "Saved log to file '%s'", (const char*) fname ); |
283 | } | 296 | } |
284 | else | 297 | else |
285 | { | 298 | { |
286 | qDebug( "Problem saving log to file '%s'", (const char*) fname ); | 299 | qDebug( "Problem saving log to file '%s'", (const char*) fname ); |
287 | } | 300 | } |
288 | } | 301 | } |
289 | } | 302 | } |
290 | 303 | ||
291 | void WellenreiterMainWindow::fileSaveSession() | 304 | void WellenreiterMainWindow::fileSaveSession() |
292 | { | 305 | { |
293 | QString fname = getFileName( true ); | 306 | QString fname = getFileName( true ); |
294 | if ( !fname.isEmpty() ) | 307 | if ( !fname.isEmpty() ) |
295 | { | 308 | { |
296 | 309 | ||
297 | QFile f( fname ); | 310 | QFile f( fname ); |
298 | if ( f.open(IO_WriteOnly) ) | 311 | if ( f.open(IO_WriteOnly) ) |
299 | { | 312 | { |
300 | QDataStream t( &f ); | 313 | QDataStream t( &f ); |
301 | t << *mw->netView(); | 314 | t << *mw->netView(); |
302 | f.close(); | 315 | f.close(); |
303 | qDebug( "Saved session to file '%s'", (const char*) fname ); | 316 | qDebug( "Saved session to file '%s'", (const char*) fname ); |
304 | } | 317 | } |
305 | else | 318 | else |
306 | { | 319 | { |
307 | qDebug( "Problem saving session to file '%s'", (const char*) fname ); | 320 | qDebug( "Problem saving session to file '%s'", (const char*) fname ); |
308 | } | 321 | } |
309 | } | 322 | } |
310 | } | 323 | } |
311 | 324 | ||
312 | void WellenreiterMainWindow::fileSaveHex() | 325 | void WellenreiterMainWindow::fileSaveHex() |
313 | { | 326 | { |
314 | QString fname = getFileName( true ); | 327 | QString fname = getFileName( true ); |
315 | if ( !fname.isEmpty() ) | 328 | if ( !fname.isEmpty() ) |
316 | { | 329 | { |
317 | QFile f( fname ); | 330 | QFile f( fname ); |
318 | if ( f.open(IO_WriteOnly) ) | 331 | if ( f.open(IO_WriteOnly) ) |
319 | { | 332 | { |
320 | QTextStream t( &f ); | 333 | QTextStream t( &f ); |
321 | t << mw->hexWindow()->getLog(); | 334 | t << mw->hexWindow()->getLog(); |
322 | f.close(); | 335 | f.close(); |
323 | qDebug( "Saved hex log to file '%s'", (const char*) fname ); | 336 | qDebug( "Saved hex log to file '%s'", (const char*) fname ); |
324 | } | 337 | } |
325 | else | 338 | else |
326 | { | 339 | { |
327 | qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); | 340 | qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); |
328 | } | 341 | } |
329 | } | 342 | } |
330 | } | 343 | } |
331 | 344 | ||
332 | void WellenreiterMainWindow::fileLoadSession() | 345 | void WellenreiterMainWindow::fileLoadSession() |
333 | { | 346 | { |
334 | QString fname = getFileName( false ); | 347 | QString fname = getFileName( false ); |
335 | if ( !fname.isEmpty() ) | 348 | if ( !fname.isEmpty() ) |
336 | { | 349 | { |
337 | QFile f( fname ); | 350 | QFile f( fname ); |
338 | if ( f.open(IO_ReadOnly) ) | 351 | if ( f.open(IO_ReadOnly) ) |
339 | { | 352 | { |
340 | QDataStream t( &f ); | 353 | QDataStream t( &f ); |
341 | t >> *mw->netView(); | 354 | t >> *mw->netView(); |
342 | f.close(); | 355 | f.close(); |
343 | qDebug( "Loaded session from file '%s'", (const char*) fname ); | 356 | qDebug( "Loaded session from file '%s'", (const char*) fname ); |
344 | } | 357 | } |
345 | else | 358 | else |
346 | { | 359 | { |
347 | qDebug( "Problem loading session from file '%s'", (const char*) fname ); | 360 | qDebug( "Problem loading session from file '%s'", (const char*) fname ); |
348 | } | 361 | } |
349 | } | 362 | } |
350 | } | 363 | } |
351 | 364 | ||
352 | 365 | ||
353 | void WellenreiterMainWindow::fileNew() | 366 | void WellenreiterMainWindow::fileNew() |
354 | { | 367 | { |
355 | mw->netView()->clear(); | 368 | mw->netView()->clear(); |
356 | mw->logWindow()->clear(); | 369 | mw->logWindow()->clear(); |
357 | mw->hexWindow()->clear(); | 370 | mw->hexWindow()->clear(); |
358 | } | 371 | } |
359 | 372 | ||
360 | 373 | ||
361 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) | 374 | void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) |
362 | { | 375 | { |
363 | if ( mw->isDaemonRunning() ) | 376 | if ( mw->isDaemonRunning() ) |
364 | { | 377 | { |
365 | QMessageBox::warning( this, "Wellenreiter/Opie", | 378 | QMessageBox::warning( this, "Wellenreiter/Opie", |
366 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); | 379 | tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); |
367 | e->ignore(); | 380 | e->ignore(); |
368 | } | 381 | } |
369 | else | 382 | else |
370 | { | 383 | { |
371 | QMainWindow::closeEvent( e ); | 384 | QMainWindow::closeEvent( e ); |
372 | } | 385 | } |
373 | } | 386 | } |
374 | 387 | ||
375 | static const char* CAP_hostname = "www.vanille.de"; | 388 | static const char* CAP_hostname = "www.vanille.de"; |
376 | 389 | ||
377 | #include <netdb.h> | 390 | #include <netdb.h> |
378 | #include <unistd.h> | 391 | #include <unistd.h> |
379 | #include <sys/types.h> | 392 | #include <sys/types.h> |
380 | #include <sys/socket.h> | 393 | #include <sys/socket.h> |
381 | 394 | ||
382 | void WellenreiterMainWindow::uploadSession() | 395 | void WellenreiterMainWindow::uploadSession() |
383 | { | 396 | { |
384 | QLineEdit* from; | 397 | QLineEdit* from; |
385 | QLineEdit* location; | 398 | QLineEdit* location; |
386 | QLineEdit* comments; | 399 | QLineEdit* comments; |
387 | QPushButton* accept; | 400 | QPushButton* accept; |
388 | QPushButton* reject; | 401 | QPushButton* reject; |
389 | 402 | ||
390 | QDialog* d = new QDialog( 0, "session upload", true ); | 403 | QDialog* d = new QDialog( 0, "session upload", true ); |
391 | d->setCaption( tr( "Upload Session" ) ); | 404 | d->setCaption( tr( "Upload Session" ) ); |
392 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); | 405 | QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); |
393 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); | 406 | g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); |
394 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); | 407 | g->addWidget( from = new QLineEdit( d ), 0, 1 ); |
395 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); | 408 | g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); |
396 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); | 409 | g->addWidget( location = new QLineEdit( d ), 1, 1 ); |
397 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); | 410 | g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); |
398 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); | 411 | g->addWidget( comments = new QLineEdit( d ), 2, 1 ); |
399 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); | 412 | g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); |
400 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); | 413 | g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); |
401 | accept->setDefault( true ); | 414 | accept->setDefault( true ); |
402 | accept->setAutoDefault( true ); | 415 | accept->setAutoDefault( true ); |
403 | from->setText( "WL II User" ); | 416 | from->setText( "WL II User" ); |
404 | location->setText( "WL II Location" ); | 417 | location->setText( "WL II Location" ); |
405 | comments->setText( "No Comments." ); | 418 | comments->setText( "No Comments." ); |
406 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); | 419 | connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); |
407 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); | 420 | connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); |
408 | int result = d->exec(); | 421 | int result = d->exec(); |
409 | 422 | ||
410 | if ( !result ) | 423 | if ( !result ) |
411 | { | 424 | { |
412 | qDebug( "Session upload cancelled :(" ); | 425 | qDebug( "Session upload cancelled :(" ); |
413 | return; | 426 | return; |
414 | } | 427 | } |
415 | 428 | ||
416 | qDebug( "Starting upload..." ); | 429 | qDebug( "Starting upload..." ); |
417 | 430 | ||
418 | struct sockaddr_in raddr; | 431 | struct sockaddr_in raddr; |
419 | struct hostent *rhost_info; | 432 | struct hostent *rhost_info; |
420 | int sock = -1; | 433 | int sock = -1; |
421 | bool ok = false; | 434 | bool ok = false; |
422 | 435 | ||
423 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); | 436 | rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); |
424 | if ( rhost_info ) | 437 | if ( rhost_info ) |
425 | { | 438 | { |
426 | 439 | ||
427 | 440 | ||
428 | if ( !QFile::exists( mw->captureFileName() ) ) | 441 | if ( !QFile::exists( mw->captureFileName() ) ) |
429 | { | 442 | { |
430 | 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() ) ); |
431 | return; | 444 | return; |
432 | } | 445 | } |
433 | 446 | ||
434 | QFile f( mw->captureFileName() ); | 447 | QFile f( mw->captureFileName() ); |
435 | if ( !f.open( IO_ReadOnly ) ) | 448 | if ( !f.open( IO_ReadOnly ) ) |
436 | { | 449 | { |
437 | 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() ) ); |
438 | return; | 451 | return; |
439 | } | 452 | } |
440 | 453 | ||
441 | int content_length = f.size(); | 454 | int content_length = f.size(); |
442 | 455 | ||
443 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); | 456 | ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); |
444 | ::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 ); |
445 | raddr.sin_family = rhost_info-> h_addrtype; | 458 | raddr.sin_family = rhost_info-> h_addrtype; |
446 | raddr.sin_port = htons ( 80 ); | 459 | raddr.sin_port = htons ( 80 ); |
447 | 460 | ||
448 | sock = ::socket( AF_INET, SOCK_STREAM, 0 ); | 461 | sock = ::socket( AF_INET, SOCK_STREAM, 0 ); |
449 | 462 | ||
450 | if ( sock >= 0 ) | 463 | if ( sock >= 0 ) |
451 | { | 464 | { |
452 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) | 465 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) |
453 | { | 466 | { |
454 | QString header; | 467 | QString header; |
455 | QString content; | 468 | QString content; |
456 | QString preambel; | 469 | QString preambel; |
457 | 470 | ||
458 | header = "" | 471 | header = "" |
459 | "POST /projects/capturedump.spy HTTP/1.1\r\n" | 472 | "POST /projects/capturedump.spy HTTP/1.1\r\n" |
460 | "Host: www.vanille.de\r\n" | 473 | "Host: www.vanille.de\r\n" |
461 | "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" |
462 | "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" |
463 | "Accept-Language: en\r\n" | 476 | "Accept-Language: en\r\n" |
464 | "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" | 477 | "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" |
465 | "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" |
466 | "Keep-Alive: 300\r\n" | 479 | "Keep-Alive: 300\r\n" |
467 | "Connection: keep-alive\r\n" | 480 | "Connection: keep-alive\r\n" |
468 | "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" | 481 | "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" |
469 | "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" | 482 | "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" |
470 | "Content-Length: %1\r\n" | 483 | "Content-Length: %1\r\n" |
471 | "\r\n"; | 484 | "\r\n"; |
472 | 485 | ||
473 | content = "" | 486 | content = "" |
474 | "-----------------------------97267758015830030481215568065\r\n" | 487 | "-----------------------------97267758015830030481215568065\r\n" |
475 | "Content-Disposition: form-data; name=\"Name\"\r\n" | 488 | "Content-Disposition: form-data; name=\"Name\"\r\n" |
476 | "\r\n" | 489 | "\r\n" |
477 | "%1\r\n" | 490 | "%1\r\n" |
478 | "-----------------------------97267758015830030481215568065\r\n" | 491 | "-----------------------------97267758015830030481215568065\r\n" |
479 | "Content-Disposition: form-data; name=\"Location\"\r\n" | 492 | "Content-Disposition: form-data; name=\"Location\"\r\n" |
480 | "\r\n" | 493 | "\r\n" |
481 | "%2\r\n" | 494 | "%2\r\n" |
482 | "-----------------------------97267758015830030481215568065\r\n" | 495 | "-----------------------------97267758015830030481215568065\r\n" |
483 | "Content-Disposition: form-data; name=\"Comments\"\r\n" | 496 | "Content-Disposition: form-data; name=\"Comments\"\r\n" |
484 | "\r\n" | 497 | "\r\n" |
485 | "%3\r\n" | 498 | "%3\r\n" |
486 | "-----------------------------97267758015830030481215568065\r\n" | 499 | "-----------------------------97267758015830030481215568065\r\n" |
487 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" | 500 | "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" |
488 | "Content-Type: application/octet-stream\r\n" | 501 | "Content-Type: application/octet-stream\r\n" |
489 | "\r\n"; | 502 | "\r\n"; |
490 | 503 | ||
491 | preambel = "" | 504 | preambel = "" |
492 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; | 505 | "\r\n-----------------------------97267758015830030481215568065--\r\n"; |
493 | 506 | ||
494 | 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() ); |
495 | 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() ); |
496 | 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() ); |
497 | content = content.arg( mw->captureFileName() ); | 510 | content = content.arg( mw->captureFileName() ); |
498 | 511 | ||
499 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); | 512 | header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); |
500 | 513 | ||
501 | // write header | 514 | // write header |
502 | 515 | ||
503 | const char* ascii = header.latin1(); | 516 | const char* ascii = header.latin1(); |
504 | uint ascii_len = ::strlen( ascii ); | 517 | uint ascii_len = ::strlen( ascii ); |
505 | ::write ( sock, ascii, ascii_len ); | 518 | ::write ( sock, ascii, ascii_len ); |
506 | 519 | ||
507 | // write fixed content | 520 | // write fixed content |
508 | 521 | ||
509 | ascii = content.latin1(); | 522 | ascii = content.latin1(); |
510 | ascii_len = ::strlen( ascii ); | 523 | ascii_len = ::strlen( ascii ); |
511 | ::write ( sock, ascii, ascii_len ); | 524 | ::write ( sock, ascii, ascii_len ); |
512 | 525 | ||
513 | // write variable content | 526 | // write variable content |
514 | 527 | ||
515 | char ch; | 528 | char ch; |
516 | while ( !f.atEnd() ) | 529 | while ( !f.atEnd() ) |
517 | { | 530 | { |
518 | f.readBlock( &ch, 1 ); | 531 | f.readBlock( &ch, 1 ); |
519 | ::write ( sock, &ch, 1 ); | 532 | ::write ( sock, &ch, 1 ); |
520 | } | 533 | } |
521 | 534 | ||
522 | // write preambel | 535 | // write preambel |
523 | 536 | ||
524 | ascii = preambel.latin1(); | 537 | ascii = preambel.latin1(); |
525 | ascii_len = ::strlen( ascii ); | 538 | ascii_len = ::strlen( ascii ); |
526 | ::write ( sock, ascii, ascii_len ); | 539 | ::write ( sock, ascii, ascii_len ); |
527 | 540 | ||
528 | // done! | 541 | // done! |
529 | 542 | ||
530 | ok = true; | 543 | ok = true; |
531 | } | 544 | } |
532 | } | 545 | } |
533 | ::close ( sock ); | 546 | ::close ( sock ); |
534 | } | 547 | } |
535 | if ( ok ) | 548 | if ( ok ) |
536 | QMessageBox::information( 0, tr( "Success" ), | 549 | QMessageBox::information( 0, tr( "Success" ), |
537 | 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 ) ); |
538 | else | 551 | else |
539 | QMessageBox::warning( 0, tr( "Error" ), | 552 | QMessageBox::warning( 0, tr( "Error" ), |
540 | 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 ) ); |
541 | } | 554 | } |
542 | 555 | ||
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h index 8d4e768..a5cb7a5 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.h +++ b/noncore/net/wellenreiter/gui/mainwindow.h | |||
@@ -1,62 +1,63 @@ | |||
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 | #ifndef MAINWINDOW_H | 16 | #ifndef MAINWINDOW_H |
17 | #define MAINWINDOW_H | 17 | #define MAINWINDOW_H |
18 | 18 | ||
19 | #include <qmainwindow.h> | 19 | #include <qmainwindow.h> |
20 | 20 | ||
21 | class Wellenreiter; | 21 | class Wellenreiter; |
22 | class WellenreiterConfigWindow; | 22 | class WellenreiterConfigWindow; |
23 | class QIconSet; | 23 | class QIconSet; |
24 | class QToolButton; | 24 | class QToolButton; |
25 | 25 | ||
26 | class WellenreiterMainWindow: public QMainWindow | 26 | class WellenreiterMainWindow: public QMainWindow |
27 | { | 27 | { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | 29 | ||
30 | public: | 30 | public: |
31 | WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); | 31 | WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); |
32 | ~WellenreiterMainWindow(); | 32 | ~WellenreiterMainWindow(); |
33 | QString getFileName( bool save ); | 33 | QString getFileName( bool save ); |
34 | 34 | ||
35 | protected: | 35 | protected: |
36 | Wellenreiter* mw; | 36 | Wellenreiter* mw; |
37 | WellenreiterConfigWindow* cw; | 37 | WellenreiterConfigWindow* cw; |
38 | 38 | ||
39 | QToolButton* startButton; | 39 | QToolButton* startButton; |
40 | QToolButton* stopButton; | 40 | QToolButton* stopButton; |
41 | QToolButton* uploadButton; | 41 | QToolButton* uploadButton; |
42 | int startID; | 42 | int startID; |
43 | int stopID; | 43 | int stopID; |
44 | int uploadID; | 44 | int uploadID; |
45 | 45 | ||
46 | protected: | 46 | protected: |
47 | virtual void closeEvent( QCloseEvent* ); | 47 | virtual void closeEvent( QCloseEvent* ); |
48 | void updateToolButtonState(); | 48 | void updateToolButtonState(); |
49 | 49 | ||
50 | public slots: | 50 | public slots: |
51 | void showConfigure(); | 51 | void showConfigure(); |
52 | void demoAddStations(); | 52 | void demoAddStations(); |
53 | void demoReadFromGps(); | ||
53 | void fileSaveLog(); | 54 | void fileSaveLog(); |
54 | void fileSaveHex(); | 55 | void fileSaveHex(); |
55 | void fileSaveSession(); | 56 | void fileSaveSession(); |
56 | void fileLoadSession(); | 57 | void fileLoadSession(); |
57 | void fileNew(); | 58 | void fileNew(); |
58 | void uploadSession(); | 59 | void uploadSession(); |
59 | void changedSniffingState(); | 60 | void changedSniffingState(); |
60 | }; | 61 | }; |
61 | 62 | ||
62 | #endif | 63 | #endif |