summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-03-28 17:33:25 (UTC)
committer mickeyl <mickeyl>2004-03-28 17:33:25 (UTC)
commit43be19e2c53014ef83a53a2045c0e41265d574d6 (patch) (unidiff)
treee716b7b506cc77f98e894e248a11690a376dbe32
parent1c151bedaa6cfcc8f10c7b5aa549de3e6628d271 (diff)
downloadopie-43be19e2c53014ef83a53a2045c0e41265d574d6.zip
opie-43be19e2c53014ef83a53a2045c0e41265d574d6.tar.gz
opie-43be19e2c53014ef83a53a2045c0e41265d574d6.tar.bz2
more work on the new packet viewer
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/packetview.cpp70
-rw-r--r--noncore/net/wellenreiter/gui/packetview.h21
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp5
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
@@ -14,56 +14,108 @@
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
28using namespace Opie::Net; 33using namespace Opie::Net;
34using namespace Opie::Core;
35using namespace Opie::Ui;
36
29PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) 37PacketView::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>" ); 68void PacketView::add( const OPacket* p )
49};
50
51void 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
74void 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
91void 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
103void PacketView::_doHexPacket( const OPacket* p )
104{
105 _hex->setText( p->dump( 16 ) );
106}
55 107
56const QString PacketView::getLog() const 108const QString PacketView::getLog() const
57{ 109{
58} 110}
59 111
60void PacketView::clear() 112void 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
@@ -16,34 +16,43 @@
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
22class QLabel;
22class QString; 23class QString;
23class QSpinBox; 24class QSpinBox;
24class QLabel;
25class QTextView; 25class QTextView;
26class QObjectList;
26namespace Opie {namespace Net {class OPacket;}} 27namespace Opie {namespace Net {class OPacket;}}
28namespace Opie {namespace Ui {class OListView;}}
27 29
28class PacketView: public QFrame 30class 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
@@ -86,12 +86,13 @@ Wellenreiter::Wellenreiter( QWidget* parent )
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}
@@ -657,13 +658,15 @@ void Wellenreiter::timerEvent( QTimerEvent* )
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
668void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 671void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
669{ 672{