summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-03-28 17:33:25 (UTC)
committer mickeyl <mickeyl>2004-03-28 17:33:25 (UTC)
commit43be19e2c53014ef83a53a2045c0e41265d574d6 (patch) (side-by-side diff)
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
@@ -1,69 +1,121 @@
/**********************************************************************
** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Wellenreiter II.
**
** 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 "packetview.h"
/* OPIE */
#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>
#include <qlayout.h>
#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 )
:QFrame( parent, name, f )
{
_number = new QSpinBox( this );
_number->setPrefix( "Packet # " );
_label = new QLabel( this );
_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 ) );
QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 );
QHBoxLayout* hb = new QHBoxLayout( vb, 2 );
hb->addWidget( _label );
hb->addWidget( _number );
vb->addWidget( _list );
vb->addWidget( _hex );
_packets.setAutoDelete( true );
+
+ connect( _number, SIGNAL( valueChanged( int ) ), this, SLOT( showPacket( int ) ) );
+}
- _list->setText( "<b>[ 802.11 [ LLC [ IP [ UDP [ DHCP ] ] ] ] ]</b>" );
-};
-
-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 ) );
+}
const QString PacketView::getLog() const
{
}
void PacketView::clear()
{
_packets.clear();
_number->setMinValue( 0 );
_number->setMaxValue( 0 );
_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
@@ -1,49 +1,58 @@
/**********************************************************************
** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Wellenreiter II.
**
** 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.
**
**********************************************************************/
#ifndef PACKETVIEW_H
#define PACKETVIEW_H
#include <qlist.h>
#include <qframe.h>
+class QLabel;
class QString;
class QSpinBox;
-class QLabel;
class QTextView;
+class QObjectList;
namespace Opie {namespace Net {class OPacket;}}
+namespace Opie {namespace Ui {class OListView;}}
class PacketView: public QFrame
{
-
+ Q_OBJECT
+
public:
PacketView( QWidget * parent = 0, const char * name = "PacketView", WFlags f = 0 );
- void add( Opie::Net::OPacket* p );
+ void add( const Opie::Net::OPacket* p );
const QString getLog() const;
void clear();
+
+ 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* );
};
#endif
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;
using namespace Opie::Net;
using namespace Opie::Core;
Wellenreiter::Wellenreiter( QWidget* parent )
: WellenreiterBase( parent, 0, 0 ),
sniffing( false ), iface( 0 ), configwindow( 0 )
{
logwindow->log( "(i) Wellenreiter has been started." );
//
// detect operating system
//
#ifdef QWS
QString sys;
sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
_system = ODevice::inst()->system();
logwindow->log( sys );
#endif
netview->setColumnWidthMode( 1, QListView::Manual );
connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
pcap = new OPacketCapturer();
+ pcap->setAutoDelete( false );
gps = new GPS( this );
QTimer::singleShot( 1000, this, SLOT( initialTimer() ) );
}
Wellenreiter::~Wellenreiter()
{
delete pcap;
}
void Wellenreiter::initialTimer()
{
qDebug( "Wellenreiter::preloading manufacturer database..." );
OManufacturerDB::instance();
}
void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
{
configwindow = cw;
@@ -639,49 +640,51 @@ void Wellenreiter::startClicked()
#warning FIXME: setScreenSaverMode is not operational on the X11 build
#endif
emit( startedSniffing() );
if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
else
{
assert( parent() );
( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
}
}
void Wellenreiter::timerEvent( QTimerEvent* )
{
qDebug( "Wellenreiter::timerEvent()" );
OPacket* p = pcap->next();
if ( !p ) // no more packets available
{
stopClicked();
}
else
{
receivePacket( p );
- delete p;
+ // We no longer delete packets here. Ownership of the packets is
+ // transferred to the PacketView.
+ //delete p;
}
}
void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
{
#ifdef QWS
if ( action == "TouchSound" )
ODevice::inst()->playTouchSound();
else if ( action == "AlarmSound" )
ODevice::inst()->playAlarmSound();
else if ( action == "KeySound" )
ODevice::inst()->playKeySound();
else if ( action == "LedOn" )
ODevice::inst()->setLedState( Led_Mail, Led_On );
else if ( action == "LedOff" )
ODevice::inst()->setLedState( Led_Mail, Led_Off );
else if ( action == "LogMessage" )
logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
else if ( action == "MessageBox" )
QMessageBox::information( this, "Notification!",
QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
#else
#warning Actions do not work with Qt/X11 yet