author | mickeyl <mickeyl> | 2004-03-28 17:33:25 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-03-28 17:33:25 (UTC) |
commit | 43be19e2c53014ef83a53a2045c0e41265d574d6 (patch) (unidiff) | |
tree | e716b7b506cc77f98e894e248a11690a376dbe32 | |
parent | 1c151bedaa6cfcc8f10c7b5aa549de3e6628d271 (diff) | |
download | opie-43be19e2c53014ef83a53a2045c0e41265d574d6.zip opie-43be19e2c53014ef83a53a2045c0e41265d574d6.tar.gz opie-43be19e2c53014ef83a53a2045c0e41265d574d6.tar.bz2 |
more work on the new packet viewer
-rw-r--r-- | noncore/net/wellenreiter/gui/packetview.cpp | 70 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/packetview.h | 21 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 5 |
3 files changed, 80 insertions, 16 deletions
diff --git a/noncore/net/wellenreiter/gui/packetview.cpp b/noncore/net/wellenreiter/gui/packetview.cpp index e0e626c..3d3aa18 100644 --- a/noncore/net/wellenreiter/gui/packetview.cpp +++ b/noncore/net/wellenreiter/gui/packetview.cpp | |||
@@ -1,69 +1,121 @@ | |||
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 Wellenreiter II. | 4 | ** This file is part of Wellenreiter II. |
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 "packetview.h" | 16 | #include "packetview.h" |
17 | 17 | ||
18 | /* OPIE */ | 18 | /* OPIE */ |
19 | #include <opie2/opcap.h> | 19 | #include <opie2/opcap.h> |
20 | #include <opie2/odebug.h> | ||
21 | #include <opie2/olistview.h> | ||
20 | 22 | ||
21 | /* QT */ | 23 | /* QT */ |
22 | #include <qtextview.h> | 24 | #include <qfont.h> |
23 | #include <qspinbox.h> | ||
24 | #include <qlabel.h> | 25 | #include <qlabel.h> |
25 | #include <qlayout.h> | 26 | #include <qlayout.h> |
26 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include <qlistview.h> | ||
29 | #include <qobjectlist.h> | ||
30 | #include <qspinbox.h> | ||
31 | #include <qtextview.h> | ||
27 | 32 | ||
28 | using namespace Opie::Net; | 33 | using namespace Opie::Net; |
34 | using namespace Opie::Core; | ||
35 | using namespace Opie::Ui; | ||
36 | |||
29 | PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) | 37 | PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) |
30 | :QFrame( parent, name, f ) | 38 | :QFrame( parent, name, f ) |
31 | { | 39 | { |
32 | _number = new QSpinBox( this ); | 40 | _number = new QSpinBox( this ); |
33 | _number->setPrefix( "Packet # " ); | 41 | _number->setPrefix( "Packet # " ); |
34 | _label = new QLabel( this ); | 42 | _label = new QLabel( this ); |
35 | _label->setText( "eth0 2004/03/08 - 00:00:21" ); | 43 | _label->setText( "eth0 2004/03/08 - 00:00:21" ); |
36 | _list = new QLabel( this ); | 44 | |
45 | _list = new OListView( this ); | ||
46 | _list->addColumn( "#" ); | ||
47 | _list->addColumn( "Packet Type" ); | ||
48 | _list->setColumnAlignment( 0, Qt::AlignCenter ); | ||
49 | _list->setColumnAlignment( 1, Qt::AlignLeft ); | ||
50 | _list->setAllColumnsShowFocus( true ); | ||
51 | _list->setFont( QFont( "Fixed", 8 ) ); | ||
52 | |||
37 | _hex = new QTextView( this ); | 53 | _hex = new QTextView( this ); |
54 | _hex->setFont( QFont( "Fixed", 8 ) ); | ||
38 | 55 | ||
39 | QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 ); | 56 | QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 ); |
40 | QHBoxLayout* hb = new QHBoxLayout( vb, 2 ); | 57 | QHBoxLayout* hb = new QHBoxLayout( vb, 2 ); |
41 | hb->addWidget( _label ); | 58 | hb->addWidget( _label ); |
42 | hb->addWidget( _number ); | 59 | hb->addWidget( _number ); |
43 | vb->addWidget( _list ); | 60 | vb->addWidget( _list ); |
44 | vb->addWidget( _hex ); | 61 | vb->addWidget( _hex ); |
45 | 62 | ||
46 | _packets.setAutoDelete( true ); | 63 | _packets.setAutoDelete( true ); |
64 | |||
65 | connect( _number, SIGNAL( valueChanged( int ) ), this, SLOT( showPacket( int ) ) ); | ||
66 | } | ||
47 | 67 | ||
48 | _list->setText( "<b>[ 802.11 [ LLC [ IP [ UDP [ DHCP ] ] ] ] ]</b>" ); | 68 | void PacketView::add( const OPacket* p ) |
49 | }; | ||
50 | |||
51 | void PacketView::add( OPacket* p ) | ||
52 | { | 69 | { |
53 | _packets.append( p ); | 70 | _packets.append( p ); |
54 | }; | 71 | // Add Circular Buffer and check for number of elements here |
72 | } | ||
73 | |||
74 | void PacketView::showPacket( int number ) | ||
75 | { | ||
76 | _list->clear(); | ||
77 | _hex->setText(""); | ||
78 | const OPacket* p = _packets.at( number ); | ||
79 | |||
80 | if ( p ) | ||
81 | { | ||
82 | _doSubPackets( const_cast<QObjectList*>( p->children() ), 0 ); | ||
83 | _doHexPacket( p ); | ||
84 | } | ||
85 | else | ||
86 | { | ||
87 | qDebug( "D'oh! No packet!" ); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | void PacketView::_doSubPackets( QObjectList* l, int counter ) | ||
92 | { | ||
93 | if (!l) return; | ||
94 | QObject* o = l->first(); | ||
95 | while ( o ) | ||
96 | { | ||
97 | new OListViewItem( _list, QString::number( counter++ ), o->name() ); | ||
98 | _doSubPackets( const_cast<QObjectList*>( o->children() ), counter ); | ||
99 | o = l->next(); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | void PacketView::_doHexPacket( const OPacket* p ) | ||
104 | { | ||
105 | _hex->setText( p->dump( 16 ) ); | ||
106 | } | ||
55 | 107 | ||
56 | const QString PacketView::getLog() const | 108 | const QString PacketView::getLog() const |
57 | { | 109 | { |
58 | } | 110 | } |
59 | 111 | ||
60 | void PacketView::clear() | 112 | void PacketView::clear() |
61 | { | 113 | { |
62 | _packets.clear(); | 114 | _packets.clear(); |
63 | _number->setMinValue( 0 ); | 115 | _number->setMinValue( 0 ); |
64 | _number->setMaxValue( 0 ); | 116 | _number->setMaxValue( 0 ); |
65 | _label->setText( "---" ); | 117 | _label->setText( "---" ); |
66 | _list->setText( " <b>-- no Packet available --</b> " ); | 118 | _list->clear(); |
67 | _hex->setText( " <i>-- no Packet available --</i> " ); | 119 | _hex->setText( " <i>-- no Packet available --</i> " ); |
68 | } | 120 | } |
69 | 121 | ||
diff --git a/noncore/net/wellenreiter/gui/packetview.h b/noncore/net/wellenreiter/gui/packetview.h index 938aa19..affedab 100644 --- a/noncore/net/wellenreiter/gui/packetview.h +++ b/noncore/net/wellenreiter/gui/packetview.h | |||
@@ -1,49 +1,58 @@ | |||
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 Wellenreiter II. | 4 | ** This file is part of Wellenreiter II. |
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 PACKETVIEW_H | 16 | #ifndef PACKETVIEW_H |
17 | #define PACKETVIEW_H | 17 | #define PACKETVIEW_H |
18 | 18 | ||
19 | #include <qlist.h> | 19 | #include <qlist.h> |
20 | #include <qframe.h> | 20 | #include <qframe.h> |
21 | 21 | ||
22 | class QLabel; | ||
22 | class QString; | 23 | class QString; |
23 | class QSpinBox; | 24 | class QSpinBox; |
24 | class QLabel; | ||
25 | class QTextView; | 25 | class QTextView; |
26 | class QObjectList; | ||
26 | namespace Opie {namespace Net {class OPacket;}} | 27 | namespace Opie {namespace Net {class OPacket;}} |
28 | namespace Opie {namespace Ui {class OListView;}} | ||
27 | 29 | ||
28 | class PacketView: public QFrame | 30 | class PacketView: public QFrame |
29 | { | 31 | { |
30 | 32 | Q_OBJECT | |
33 | |||
31 | public: | 34 | public: |
32 | PacketView( QWidget * parent = 0, const char * name = "PacketView", WFlags f = 0 ); | 35 | PacketView( QWidget * parent = 0, const char * name = "PacketView", WFlags f = 0 ); |
33 | 36 | ||
34 | void add( Opie::Net::OPacket* p ); | 37 | void add( const Opie::Net::OPacket* p ); |
35 | const QString getLog() const; | 38 | const QString getLog() const; |
36 | void clear(); | 39 | void clear(); |
40 | |||
41 | public slots: | ||
42 | void showPacket( int number ); | ||
37 | 43 | ||
38 | protected: | 44 | protected: |
39 | |||
40 | QSpinBox* _number; | 45 | QSpinBox* _number; |
41 | QLabel* _label; | 46 | QLabel* _label; |
42 | QLabel* _list; | 47 | Opie::Ui::OListView* _list; |
43 | QTextView* _hex; | 48 | QTextView* _hex; |
44 | QList<Opie::Net::OPacket> _packets; | 49 | QList<const Opie::Net::OPacket> _packets; |
50 | |||
51 | protected: | ||
52 | void _doSubPackets( QObjectList*, int ); | ||
53 | void _doHexPacket( const Opie::Net::OPacket* ); | ||
45 | 54 | ||
46 | }; | 55 | }; |
47 | 56 | ||
48 | #endif | 57 | #endif |
49 | 58 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index c8d77a7..fff7c35 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -68,48 +68,49 @@ using namespace Opie::Core; | |||
68 | using namespace Opie::Net; | 68 | using namespace Opie::Net; |
69 | using namespace Opie::Core; | 69 | using namespace Opie::Core; |
70 | Wellenreiter::Wellenreiter( QWidget* parent ) | 70 | Wellenreiter::Wellenreiter( QWidget* parent ) |
71 | : WellenreiterBase( parent, 0, 0 ), | 71 | : WellenreiterBase( parent, 0, 0 ), |
72 | sniffing( false ), iface( 0 ), configwindow( 0 ) | 72 | sniffing( false ), iface( 0 ), configwindow( 0 ) |
73 | { | 73 | { |
74 | 74 | ||
75 | logwindow->log( "(i) Wellenreiter has been started." ); | 75 | logwindow->log( "(i) Wellenreiter has been started." ); |
76 | 76 | ||
77 | // | 77 | // |
78 | // detect operating system | 78 | // detect operating system |
79 | // | 79 | // |
80 | 80 | ||
81 | #ifdef QWS | 81 | #ifdef QWS |
82 | QString sys; | 82 | QString sys; |
83 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 83 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
84 | _system = ODevice::inst()->system(); | 84 | _system = ODevice::inst()->system(); |
85 | logwindow->log( sys ); | 85 | logwindow->log( sys ); |
86 | #endif | 86 | #endif |
87 | 87 | ||
88 | netview->setColumnWidthMode( 1, QListView::Manual ); | 88 | netview->setColumnWidthMode( 1, QListView::Manual ); |
89 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), | 89 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), |
90 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); | 90 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); |
91 | pcap = new OPacketCapturer(); | 91 | pcap = new OPacketCapturer(); |
92 | pcap->setAutoDelete( false ); | ||
92 | 93 | ||
93 | gps = new GPS( this ); | 94 | gps = new GPS( this ); |
94 | 95 | ||
95 | QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); | 96 | QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); |
96 | 97 | ||
97 | } | 98 | } |
98 | 99 | ||
99 | 100 | ||
100 | Wellenreiter::~Wellenreiter() | 101 | Wellenreiter::~Wellenreiter() |
101 | { | 102 | { |
102 | delete pcap; | 103 | delete pcap; |
103 | } | 104 | } |
104 | 105 | ||
105 | 106 | ||
106 | void Wellenreiter::initialTimer() | 107 | void Wellenreiter::initialTimer() |
107 | { | 108 | { |
108 | qDebug( "Wellenreiter::preloading manufacturer database..." ); | 109 | qDebug( "Wellenreiter::preloading manufacturer database..." ); |
109 | OManufacturerDB::instance(); | 110 | OManufacturerDB::instance(); |
110 | } | 111 | } |
111 | 112 | ||
112 | 113 | ||
113 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 114 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
114 | { | 115 | { |
115 | configwindow = cw; | 116 | configwindow = cw; |
@@ -639,49 +640,51 @@ void Wellenreiter::startClicked() | |||
639 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 640 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
640 | #endif | 641 | #endif |
641 | 642 | ||
642 | emit( startedSniffing() ); | 643 | emit( startedSniffing() ); |
643 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 644 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
644 | else | 645 | else |
645 | { | 646 | { |
646 | assert( parent() ); | 647 | assert( parent() ); |
647 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); | 648 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); |
648 | } | 649 | } |
649 | } | 650 | } |
650 | 651 | ||
651 | 652 | ||
652 | void Wellenreiter::timerEvent( QTimerEvent* ) | 653 | void Wellenreiter::timerEvent( QTimerEvent* ) |
653 | { | 654 | { |
654 | qDebug( "Wellenreiter::timerEvent()" ); | 655 | qDebug( "Wellenreiter::timerEvent()" ); |
655 | OPacket* p = pcap->next(); | 656 | OPacket* p = pcap->next(); |
656 | if ( !p ) // no more packets available | 657 | if ( !p ) // no more packets available |
657 | { | 658 | { |
658 | stopClicked(); | 659 | stopClicked(); |
659 | } | 660 | } |
660 | else | 661 | else |
661 | { | 662 | { |
662 | receivePacket( p ); | 663 | receivePacket( p ); |
663 | delete p; | 664 | // We no longer delete packets here. Ownership of the packets is |
665 | // transferred to the PacketView. | ||
666 | //delete p; | ||
664 | } | 667 | } |
665 | } | 668 | } |
666 | 669 | ||
667 | 670 | ||
668 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) | 671 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) |
669 | { | 672 | { |
670 | #ifdef QWS | 673 | #ifdef QWS |
671 | if ( action == "TouchSound" ) | 674 | if ( action == "TouchSound" ) |
672 | ODevice::inst()->playTouchSound(); | 675 | ODevice::inst()->playTouchSound(); |
673 | else if ( action == "AlarmSound" ) | 676 | else if ( action == "AlarmSound" ) |
674 | ODevice::inst()->playAlarmSound(); | 677 | ODevice::inst()->playAlarmSound(); |
675 | else if ( action == "KeySound" ) | 678 | else if ( action == "KeySound" ) |
676 | ODevice::inst()->playKeySound(); | 679 | ODevice::inst()->playKeySound(); |
677 | else if ( action == "LedOn" ) | 680 | else if ( action == "LedOn" ) |
678 | ODevice::inst()->setLedState( Led_Mail, Led_On ); | 681 | ODevice::inst()->setLedState( Led_Mail, Led_On ); |
679 | else if ( action == "LedOff" ) | 682 | else if ( action == "LedOff" ) |
680 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 683 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
681 | else if ( action == "LogMessage" ) | 684 | else if ( action == "LogMessage" ) |
682 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 685 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
683 | else if ( action == "MessageBox" ) | 686 | else if ( action == "MessageBox" ) |
684 | QMessageBox::information( this, "Notification!", | 687 | QMessageBox::information( this, "Notification!", |
685 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 688 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
686 | #else | 689 | #else |
687 | #warning Actions do not work with Qt/X11 yet | 690 | #warning Actions do not work with Qt/X11 yet |