summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/packetview.cpp68
-rw-r--r--noncore/net/wellenreiter/gui/packetview.h19
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp5
3 files changed, 78 insertions, 14 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
@@ -19,6 +19,7 @@
#include <opie2/opcap.h>
+#include <opie2/odebug.h>
+#include <opie2/olistview.h>
/* QT */
-#include <qtextview.h>
-#include <qspinbox.h>
+#include <qfont.h>
#include <qlabel.h>
@@ -26,4 +27,11 @@
#include <qlist.h>
+#include <qlistview.h>
+#include <qobjectlist.h>
+#include <qspinbox.h>
+#include <qtextview.h>
using namespace Opie::Net;
+using namespace Opie::Core;
+using namespace Opie::Ui;
+
PacketView::PacketView( QWidget * parent, const char * name, WFlags f )
@@ -35,4 +43,13 @@ PacketView::PacketView( QWidget * parent, const char * name, WFlags f )
_label->setText( "eth0 2004/03/08 - 00:00:21" );
- _list = new QLabel( this );
+
+ _list = new OListView( this );
+ _list->addColumn( "#" );
+ _list->addColumn( "Packet Type" );
+ _list->setColumnAlignment( 0, Qt::AlignCenter );
+ _list->setColumnAlignment( 1, Qt::AlignLeft );
+ _list->setAllColumnsShowFocus( true );
+ _list->setFont( QFont( "Fixed", 8 ) );
+
_hex = new QTextView( this );
+ _hex->setFont( QFont( "Fixed", 8 ) );
@@ -47,9 +64,44 @@ PacketView::PacketView( QWidget * parent, const char * name, WFlags f )
- _list->setText( "<b>[ 802.11 [ LLC [ IP [ UDP [ DHCP ] ] ] ] ]</b>" );
-};
+ connect( _number, SIGNAL( valueChanged( int ) ), this, SLOT( showPacket( int ) ) );
+}
-void PacketView::add( OPacket* p )
+void PacketView::add( const OPacket* p )
{
_packets.append( p );
-};
+ // Add Circular Buffer and check for number of elements here
+}
+
+void PacketView::showPacket( int number )
+{
+ _list->clear();
+ _hex->setText("");
+ const OPacket* p = _packets.at( number );
+
+ if ( p )
+ {
+ _doSubPackets( const_cast<QObjectList*>( p->children() ), 0 );
+ _doHexPacket( p );
+ }
+ else
+ {
+ qDebug( "D'oh! No packet!" );
+ }
+}
+
+void PacketView::_doSubPackets( QObjectList* l, int counter )
+{
+ if (!l) return;
+ QObject* o = l->first();
+ while ( o )
+ {
+ new OListViewItem( _list, QString::number( counter++ ), o->name() );
+ _doSubPackets( const_cast<QObjectList*>( o->children() ), counter );
+ o = l->next();
+ }
+}
+
+void PacketView::_doHexPacket( const OPacket* p )
+{
+ _hex->setText( p->dump( 16 ) );
+}
@@ -65,3 +117,3 @@ void PacketView::clear()
_label->setText( "---" );
- _list->setText( " <b>-- no Packet available --</b> " );
+ _list->clear();
_hex->setText( " <i>-- no Packet available --</i> " );
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
@@ -21,7 +21,9 @@
+class QLabel;
class QString;
class QSpinBox;
-class QLabel;
class QTextView;
+class QObjectList;
namespace Opie {namespace Net {class OPacket;}}
+namespace Opie {namespace Ui {class OListView;}}
@@ -29,2 +31,3 @@ class PacketView: public QFrame
{
+ Q_OBJECT
@@ -33,3 +36,3 @@ class PacketView: public QFrame
- void add( Opie::Net::OPacket* p );
+ void add( const Opie::Net::OPacket* p );
const QString getLog() const;
@@ -37,9 +40,15 @@ class PacketView: public QFrame
- protected:
+ public slots:
+ void showPacket( int number );
+ protected:
QSpinBox* _number;
QLabel* _label;
- QLabel* _list;
+ Opie::Ui::OListView* _list;
QTextView* _hex;
- QList<Opie::Net::OPacket> _packets;
+ QList<const Opie::Net::OPacket> _packets;
+
+ protected:
+ void _doSubPackets( QObjectList*, int );
+ void _doHexPacket( const Opie::Net::OPacket* );
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
@@ -91,2 +91,3 @@ Wellenreiter::Wellenreiter( QWidget* parent )
pcap = new OPacketCapturer();
+ pcap->setAutoDelete( false );
@@ -662,3 +663,5 @@ void Wellenreiter::timerEvent( QTimerEvent* )
receivePacket( p );
- delete p;
+ // We no longer delete packets here. Ownership of the packets is
+ // transferred to the PacketView.
+ //delete p;
}