author | mickeyl <mickeyl> | 2004-02-15 18:54:55 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-15 18:54:55 (UTC) |
commit | ef7f95fa147c7675999b091c76b081029c415d19 (patch) (side-by-side diff) | |
tree | 5563bb2697fa1764814adf28c276f310f069c05d | |
parent | 842923f72761677ea132c16a23091c5ee3a35780 (diff) | |
download | opie-ef7f95fa147c7675999b091c76b081029c415d19.zip opie-ef7f95fa147c7675999b091c76b081029c415d19.tar.gz opie-ef7f95fa147c7675999b091c76b081029c415d19.tar.bz2 |
default gps speed now 4800 - seems to be more compatible
-rw-r--r-- | noncore/net/wellenreiter/gui/configbase.ui | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gps.cpp | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 9 |
3 files changed, 8 insertions, 5 deletions
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index de6abfc..469effe 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui @@ -627,884 +627,884 @@ </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> <widget row="0" column="0" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>writeCaptureFile</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>text</name> <string>Write Capture Files To</string> </property> </widget> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Parse</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>5</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget row="0" column="0" > <class>ProtocolListView</class> <property stdset="1"> <name>name</name> <cstring>parsePackets</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>7</vsizetype> </sizepolicy> </property> </widget> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>UI</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>5</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>lookupVendor</cstring> </property> <property stdset="1"> <name>text</name> <string>Lookup MAC vendor names</string> </property> </widget> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>openTree</cstring> </property> <property stdset="1"> <name>text</name> <string>Open Tree On New Station</string> </property> </widget> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>disablePM</cstring> </property> <property stdset="1"> <name>text</name> <string>Disable Power Management</string> </property> </widget> <spacer> <property> <name>name</name> <cstring>Spacer3</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> <widget> <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>GroupBox4_2</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> <property stdset="1"> <name>title</name> <string>Action on detecting a new</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>3</number> </property> <property stdset="1"> <name>spacing</name> <number>0</number> </property> <widget row="0" column="0" > <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout6</cstring> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>2</number> </property> <property stdset="1"> <name>spacing</name> <number>2</number> </property> <widget row="4" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel3</cstring> </property> <property stdset="1"> <name>text</name> <string>Wired Station:</string> </property> </widget> <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_3</cstring> </property> <property stdset="1"> <name>text</name> <string>Network:</string> </property> </widget> <widget row="2" column="1" > <class>QComboBox</class> <item> <property> <name>text</name> <string><Ignore></string> </property> </item> <item> <property> <name>text</name> <string>Play Alarm</string> </property> </item> <item> <property> <name>text</name> <string>Play Click</string> </property> </item> <item> <property> <name>text</name> <string>Blink LED</string> </property> </item> <item> <property> <name>text</name> <string>Run Script</string> </property> </item> <property stdset="1"> <name>name</name> <cstring>newClientAction</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> </widget> <widget row="3" column="0" rowspan="1" colspan="2" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>newClientScript</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> </widget> <widget row="2" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel2</cstring> </property> <property stdset="1"> <name>text</name> <string>Wireless Station:</string> </property> </widget> <widget row="4" column="1" > <class>QComboBox</class> <item> <property> <name>text</name> <string><Ignore></string> </property> </item> <item> <property> <name>text</name> <string>Play Alarm</string> </property> </item> <item> <property> <name>text</name> <string>Play Click</string> </property> </item> <item> <property> <name>text</name> <string>Blink LED</string> </property> </item> <item> <property> <name>text</name> <string>Run Script</string> </property> </item> <property stdset="1"> <name>name</name> <cstring>newStationAction</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> </widget> <widget row="0" column="1" > <class>QComboBox</class> <item> <property> <name>text</name> <string><Ignore></string> </property> </item> <item> <property> <name>text</name> <string>Play Alarm</string> </property> </item> <item> <property> <name>text</name> <string>Play Click</string> </property> </item> <item> <property> <name>text</name> <string>Blink LED</string> </property> </item> <item> <property> <name>text</name> <string>Run Script</string> </property> </item> <property stdset="1"> <name>name</name> <cstring>newNetworkAction</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>editable</name> <bool>false</bool> </property> </widget> <widget row="1" column="0" rowspan="1" colspan="2" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>newNetworkScript</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> </widget> <widget row="5" column="0" rowspan="1" colspan="2" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>newStationScript</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>true</bool> </property> </widget> </grid> </widget> </grid> </widget> </vbox> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Intrusion</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>6</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="1" column="0" > <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>GroupBox3</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>title</name> <string>Link Level</string> </property> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_5</cstring> </property> <property stdset="1"> <name>text</name> <string>Fake Mac:</string> </property> </widget> <widget row="1" column="0" rowspan="1" colspan="2" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>sendProbeRequests</cstring> </property> <property stdset="1"> <name>text</name> <string>Send proble requests</string> </property> </widget> <widget row="0" column="1" > <class>QComboBox</class> <item> <property> <name>text</name> <string><automatic></string> </property> </item> <item> <property> <name>text</name> <string>44:44:44:44:44:44</string> </property> </item> <property stdset="1"> <name>name</name> <cstring>fakeMac</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>editable</name> <bool>true</bool> </property> <property stdset="1"> <name>currentItem</name> <number>1</number> </property> <property stdset="1"> <name>autoCompletion</name> <bool>true</bool> </property> </widget> <widget row="2" column="0" rowspan="1" colspan="2" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>tryToAuthenticate</cstring> </property> <property stdset="1"> <name>text</name> <string>Try to authenticate</string> </property> </widget> </grid> </widget> <widget row="0" column="0" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>enableActiveScanning</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>text</name> <string>Enable active scanning</string> </property> </widget> <widget row="2" column="0" > <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>GroupBox4</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>title</name> <string>IP Level</string> </property> <grid> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget row="1" column="0" rowspan="1" colspan="2" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>CheckBox24</cstring> </property> <property stdset="1"> <name>text</name> <string>Request DHCP Address</string> </property> </widget> <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_5_2</cstring> </property> <property stdset="1"> <name>text</name> <string>Fake IP:</string> </property> </widget> <widget row="0" column="1" > <class>QComboBox</class> <item> <property> <name>text</name> <string>192.168.125.1</string> </property> </item> <item> <property> <name>text</name> <string><automatic></string> </property> </item> <property stdset="1"> <name>name</name> <cstring>fakeIP</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>editable</name> <bool>true</bool> </property> <property stdset="1"> <name>currentItem</name> <number>0</number> </property> </widget> </grid> </widget> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>GPS</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>5</number> </property> <property stdset="1"> <name>spacing</name> <number>4</number> </property> <widget row="0" column="0" > <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout6</cstring> </property> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>enableGPS</cstring> </property> <property stdset="1"> <name>text</name> <string>Enable GPS logging w/ gpsd</string> </property> </widget> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout1</cstring> </property> <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_4</cstring> </property> <property stdset="1"> <name>text</name> <string>Host</string> </property> </widget> <widget> <class>QComboBox</class> <item> <property> <name>text</name> <string>localhost</string> </property> </item> <property stdset="1"> <name>name</name> <cstring>gpsdHost</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>editable</name> <bool>true</bool> </property> <property stdset="1"> <name>currentItem</name> <number>0</number> </property> </widget> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel2_2</cstring> </property> <property stdset="1"> <name>text</name> <string>:</string> </property> </widget> <widget> <class>QSpinBox</class> <property stdset="1"> <name>name</name> <cstring>gpsdPort</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>maxValue</name> <number>65535</number> </property> <property stdset="1"> <name>minValue</name> <number>1024</number> </property> <property stdset="1"> <name>value</name> <number>2947</number> </property> </widget> </hbox> </widget> <widget> <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>startGPS</cstring> </property> <property stdset="1"> <name>text</name> <string>Start gpsd on localhost</string> </property> </widget> <widget> <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>commandGPS</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>text</name> - <string>gpsd -p /dev/ttyS3 -s 57600</string> + <string>gpsd -p /dev/ttyS3 -s 4800</string> </property> </widget> <spacer> <property> <name>name</name> <cstring>Spacer4_2</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Vertical</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> </vbox> </widget> </grid> </widget> </widget> </grid> </widget> <customwidgets> <customwidget> <class>ProtocolListView</class> <header location="local">protolistview.h</header> <sizehint> <width>100</width> <height>100</height> </sizehint> <container>0</container> <sizepolicy> <hordata>3</hordata> <verdata>3</verdata> </sizepolicy> <pixmap>image0</pixmap> </customwidget> </customwidgets> <images> <image> <name>image0</name> <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> </image> </images> <connections> <connection> <sender>hopChannels</sender> <signal>toggled(bool)</signal> <receiver>hopInterval</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>hopChannels</sender> <signal>toggled(bool)</signal> <receiver>TextLabel1</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>enableActiveScanning</sender> <signal>toggled(bool)</signal> <receiver>GroupBox3</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>enableActiveScanning</sender> <signal>toggled(bool)</signal> <receiver>GroupBox4</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>writeCaptureFile</sender> <signal>toggled(bool)</signal> <receiver>getCaptureFileName</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>writeCaptureFile</sender> <signal>toggled(bool)</signal> <receiver>captureFileName</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>writeCaptureFile</sender> <signal>toggled(bool)</signal> <receiver>capturePackets</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>enableGPS</sender> <signal>toggled(bool)</signal> <receiver>gpsdHost</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>enableGPS</sender> <signal>toggled(bool)</signal> <receiver>gpsdPort</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>startGPS</sender> <signal>toggled(bool)</signal> <receiver>commandGPS</receiver> <slot>setEnabled(bool)</slot> </connection> </connections> </UI> diff --git a/noncore/net/wellenreiter/gui/gps.cpp b/noncore/net/wellenreiter/gui/gps.cpp index 5b1b4a4..b845aa1 100644 --- a/noncore/net/wellenreiter/gui/gps.cpp +++ b/noncore/net/wellenreiter/gui/gps.cpp @@ -1,127 +1,127 @@ /********************************************************************** ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Opie Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "gps.h" /* QT */ #include <qtextstream.h> /* STD */ #include <stdlib.h> #include <unistd.h> GPS::GPS( QObject* parent, const char * name ) :QObject( parent, name ) { qDebug( "GPS::GPS()" ); _socket = new QSocket( this, "gpsd commsock" ); } GPS::~GPS() { qDebug( "GPS::~GPS()" ); } bool GPS::open( const QString& host, int port ) { _socket->connectToHost( host, port ); } GpsLocation GPS::position() const { char buf[256]; double lat = -111.0; double lon = -111.0; int result = _socket->writeBlock( "p\r\n", 3 ); _socket->flush(); if ( result ) { int numAvail = _socket->bytesAvailable(); qDebug( "GPS write succeeded, %d bytes available for reading...", numAvail ); if ( numAvail ) { int numRead = _socket->readBlock( &buf[0], sizeof buf ); - int numScan = sscanf( &buf[0], "GPSD,P=%lg %lg", &lat, &lon); + int numScan = ::sscanf( &buf[0], "GPSD,P=%lg %lg", &lat, &lon); if ( numRead < 7 || numScan != 2 ) { qDebug( "GPS read %d bytes succeeded, invalid response: '%s'", numRead, &buf[0] ); return GpsLocation( -111, -111 ); } else { return GpsLocation( lat, lon ); } } } return GpsLocation( -111, -111 ); } QString GpsLocation::dmsPosition() const { if ( _latitude == -111 || _longitude == -111 ) return "N/A"; if ( _latitude == 0.0 && _longitude == 0.0 ) return "NULL"; /* compute latitude */ QString dms = "N"; if ( _latitude >= 0 ) dms.append( "+" ); int trunc = int( _latitude ); float rest = _latitude - trunc; float minf = rest * 60; int minutes = int( minf ); rest = minf - minutes; int seconds = int( rest * 60 ); dms.append( QString::number( trunc ) ); dms.append( "° " ); dms.append( QString::number( ::abs( minutes ) ) ); dms.append( "' " ); dms.append( QString::number( ::abs( seconds ) ) ); dms.append( "'' " ); /* compute longitude */ dms.append( " | W" ); if ( _longitude > 0 ) dms.append( "+" ); trunc = int( _longitude ); rest = _longitude - trunc; minf = rest * 60; minutes = int( minf ); rest = minf - minutes; seconds = int( rest * 60 ); dms.append( QString::number( trunc ) ); dms.append( "° " ); dms.append( QString::number( ::abs( minutes ) ) ); dms.append( "' " ); dms.append( QString::number( ::abs( seconds ) ) ); dms.append( "'' " ); return dms; } diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 72624f7..3729ed0 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -1,555 +1,558 @@ /********************************************************************** ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Opie Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "configwindow.h" #include "gps.h" #include "logwindow.h" #include "hexwindow.h" #include "mainwindow.h" #include "wellenreiter.h" #include "scanlist.h" #include <qcombobox.h> #include <qdatastream.h> #include <qfile.h> #include <qfileinfo.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qiconset.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qpushbutton.h> #include <qstatusbar.h> #include <qspinbox.h> #include <qtextstream.h> #include <qtoolbutton.h> #ifdef QWS #include <qpe/resource.h> #include <opie2/ofiledialog.h> using namespace Opie; #else #include "resource.h" #include <qapplication.h> #include <qfiledialog.h> #endif +#include <unistd.h> + WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) :QMainWindow( parent, name, f ) { cw = new WellenreiterConfigWindow( this ); mw = new Wellenreiter( this ); mw->setConfigWindow( cw ); setCentralWidget( mw ); // setup application icon #ifndef QWS setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); setIconText( "Wellenreiter/X11" ); #endif // setup tool buttons startButton = new QToolButton( 0 ); #ifdef QWS startButton->setAutoRaise( true ); #endif startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); startButton->setEnabled( false ); connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); stopButton = new QToolButton( 0 ); #ifdef QWS stopButton->setAutoRaise( true ); #endif stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); stopButton->setEnabled( false ); connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); QToolButton* d = new QToolButton( 0 ); #ifdef QWS d->setAutoRaise( true ); #endif d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); uploadButton = new QToolButton( 0 ); #ifdef QWS uploadButton->setAutoRaise( true ); #endif uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); uploadButton->setEnabled( false ); //uploadButton->setEnabled( true ); // DEBUGGING connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); // setup menu bar int id; QMenuBar* mb = menuBar(); QPopupMenu* fileSave = new QPopupMenu( mb ); fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); QPopupMenu* fileLoad = new QPopupMenu( mb ); fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); QPopupMenu* file = new QPopupMenu( mb ); file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); id = file->insertItem( tr( "&Load" ), fileLoad ); file->insertItem( tr( "&Save" ), fileSave ); file->insertSeparator(); uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); file->insertSeparator(); file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); QPopupMenu* view = new QPopupMenu( mb ); view->insertItem( tr( "&Configure..." ) ); QPopupMenu* sniffer = new QPopupMenu( mb ); sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); sniffer->insertSeparator(); startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); sniffer->setItemEnabled( startID, false ); stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); sniffer->setItemEnabled( stopID, false ); QPopupMenu* demo = new QPopupMenu( mb ); demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); - demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); + //demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); id = mb->insertItem( tr( "&File" ), file ); //id = mb->insertItem( tr( "&View" ), view ); //mb->setItemEnabled( id, false ); id = mb->insertItem( tr( "&Sniffer" ), sniffer ); id = mb->insertItem( tr( "&Demo" ), demo ); mb->setItemEnabled( id, true ); mb->setItemEnabled( uploadID, false ); #ifdef QWS mb->insertItem( startButton ); mb->insertItem( stopButton ); mb->insertItem( uploadButton ); mb->insertItem( d ); #else // Qt3 changed the insertion order. It's now totally random :( mb->insertItem( d ); mb->insertItem( uploadButton ); mb->insertItem( stopButton ); mb->insertItem( startButton ); #endif updateToolButtonState(); // setup status bar (for now only on X11) #ifndef QWS statusBar()->message( tr( "Ready." ) ); #endif connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); }; void WellenreiterMainWindow::showConfigure() { qDebug( "show configure..." ); cw->setCaption( tr( "Configure" ) ); #ifdef QWS cw->showMaximized(); #endif int result = cw->exec(); if ( result ) updateToolButtonState(); } void WellenreiterMainWindow::updateToolButtonState() { const QString& interface = cw->interfaceName->currentText(); const int cardtype = cw->driverType(); if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) { startButton->setEnabled( true ); menuBar()->setItemEnabled( startID, true ); } else { startButton->setEnabled( false ); menuBar()->setItemEnabled( startID, false ); } } void WellenreiterMainWindow::changedSniffingState() { startButton->setEnabled( !mw->sniffing ); menuBar()->setItemEnabled( startID, !mw->sniffing ); stopButton->setEnabled( mw->sniffing ); menuBar()->setItemEnabled( stopID, mw->sniffing ); if ( !mw->sniffing ) { menuBar()->setItemEnabled( uploadID, true ); uploadButton->setEnabled( true ); } } WellenreiterMainWindow::~WellenreiterMainWindow() { - qDebug( "Wellenreiter:: bye." ); + qDebug( "Wellenreiter: bye." ); }; void WellenreiterMainWindow::demoAddStations() { //mw = 0; // test SIGSEGV handling mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); } void WellenreiterMainWindow::demoReadFromGps() { WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); GPS* gps = new GPS( this ); + qDebug( "Wellenreiter::demoReadFromGps(): url=gps://%s:%d/", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); GpsLocation loc = gps->position(); - QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n%1" ).arg( loc.dmsPosition() ) ); + delete gps; } QString WellenreiterMainWindow::getFileName( bool save ) { QMap<QString, QStringList> map; map.insert( tr("All"), QStringList() ); QStringList text; text << "text/*"; map.insert( tr("Text"), text ); text << "*"; map.insert( tr("All"), text ); QString str; if ( save ) { #ifdef QWS str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); #else str = QFileDialog::getSaveFileName(); #endif if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) return ""; } else { #ifdef QWS str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); #else str = QFileDialog::getOpenFileName(); #endif if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) return ""; } return str; } void WellenreiterMainWindow::fileSaveLog() { QString fname = getFileName( true ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_WriteOnly) ) { QTextStream t( &f ); t << mw->logWindow()->getLog(); f.close(); qDebug( "Saved log to file '%s'", (const char*) fname ); } else { qDebug( "Problem saving log to file '%s'", (const char*) fname ); } } } void WellenreiterMainWindow::fileSaveSession() { QString fname = getFileName( true ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_WriteOnly) ) { QDataStream t( &f ); t << *mw->netView(); f.close(); qDebug( "Saved session to file '%s'", (const char*) fname ); } else { qDebug( "Problem saving session to file '%s'", (const char*) fname ); } } } void WellenreiterMainWindow::fileSaveHex() { QString fname = getFileName( true ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_WriteOnly) ) { QTextStream t( &f ); t << mw->hexWindow()->getLog(); f.close(); qDebug( "Saved hex log to file '%s'", (const char*) fname ); } else { qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); } } } void WellenreiterMainWindow::fileLoadSession() { QString fname = getFileName( false ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_ReadOnly) ) { QDataStream t( &f ); t >> *mw->netView(); f.close(); qDebug( "Loaded session from file '%s'", (const char*) fname ); } else { qDebug( "Problem loading session from file '%s'", (const char*) fname ); } } } void WellenreiterMainWindow::fileNew() { mw->netView()->clear(); mw->logWindow()->clear(); mw->hexWindow()->clear(); } void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) { if ( mw->isDaemonRunning() ) { QMessageBox::warning( this, "Wellenreiter/Opie", tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); e->ignore(); } else { QMainWindow::closeEvent( e ); } } static const char* CAP_hostname = "www.vanille.de"; #include <netdb.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> void WellenreiterMainWindow::uploadSession() { QLineEdit* from; QLineEdit* location; QLineEdit* comments; QPushButton* accept; QPushButton* reject; QDialog* d = new QDialog( 0, "session upload", true ); d->setCaption( tr( "Upload Session" ) ); QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); g->addWidget( from = new QLineEdit( d ), 0, 1 ); g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); g->addWidget( location = new QLineEdit( d ), 1, 1 ); g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); g->addWidget( comments = new QLineEdit( d ), 2, 1 ); g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); accept->setDefault( true ); accept->setAutoDefault( true ); from->setText( "WL II User" ); location->setText( "WL II Location" ); comments->setText( "No Comments." ); connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); int result = d->exec(); if ( !result ) { qDebug( "Session upload cancelled :(" ); return; } qDebug( "Starting upload..." ); struct sockaddr_in raddr; struct hostent *rhost_info; int sock = -1; bool ok = false; rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); if ( rhost_info ) { if ( !QFile::exists( mw->captureFileName() ) ) { QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); return; } QFile f( mw->captureFileName() ); if ( !f.open( IO_ReadOnly ) ) { QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); return; } int content_length = f.size(); ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); raddr.sin_family = rhost_info-> h_addrtype; raddr.sin_port = htons ( 80 ); sock = ::socket( AF_INET, SOCK_STREAM, 0 ); if ( sock >= 0 ) { if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { QString header; QString content; QString preambel; header = "" "POST /projects/capturedump.spy HTTP/1.1\r\n" "Host: www.vanille.de\r\n" "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n" "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" "Accept-Language: en\r\n" "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n" "Keep-Alive: 300\r\n" "Connection: keep-alive\r\n" "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" "Content-Length: %1\r\n" "\r\n"; content = "" "-----------------------------97267758015830030481215568065\r\n" "Content-Disposition: form-data; name=\"Name\"\r\n" "\r\n" "%1\r\n" "-----------------------------97267758015830030481215568065\r\n" "Content-Disposition: form-data; name=\"Location\"\r\n" "\r\n" "%2\r\n" "-----------------------------97267758015830030481215568065\r\n" "Content-Disposition: form-data; name=\"Comments\"\r\n" "\r\n" "%3\r\n" "-----------------------------97267758015830030481215568065\r\n" "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" "Content-Type: application/octet-stream\r\n" "\r\n"; preambel = "" "\r\n-----------------------------97267758015830030481215568065--\r\n"; content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); content = content.arg( mw->captureFileName() ); header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); // write header const char* ascii = header.latin1(); uint ascii_len = ::strlen( ascii ); ::write ( sock, ascii, ascii_len ); // write fixed content ascii = content.latin1(); ascii_len = ::strlen( ascii ); ::write ( sock, ascii, ascii_len ); // write variable content char ch; while ( !f.atEnd() ) { f.readBlock( &ch, 1 ); ::write ( sock, &ch, 1 ); } // write preambel ascii = preambel.latin1(); ascii_len = ::strlen( ascii ); ::write ( sock, ascii, ascii_len ); // done! ok = true; } } ::close ( sock ); } if ( ok ) QMessageBox::information( 0, tr( "Success" ), QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); else QMessageBox::warning( 0, tr( "Error" ), QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); } |