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 /noncore/net | |
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 | |||
@@ -18,13 +18,21 @@ | |||
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 ) |
@@ -34,6 +42,15 @@ PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) | |||
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 ); |
@@ -45,12 +62,47 @@ PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) | |||
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 |
@@ -64,5 +116,5 @@ void PacketView::clear() | |||
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 | } |
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 | |||
@@ -20,27 +20,36 @@ | |||
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 | }; |
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 | |||
@@ -90,4 +90,5 @@ Wellenreiter::Wellenreiter( QWidget* parent ) | |||
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 ); |
@@ -661,5 +662,7 @@ void Wellenreiter::timerEvent( QTimerEvent* ) | |||
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 | } |