summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-03-28 16:52:43 (UTC)
committer mickeyl <mickeyl>2004-03-28 16:52:43 (UTC)
commite2368b92a101437f7ed289d5ae62f7e7e2466344 (patch) (unidiff)
tree1e7775ee681d970c9cd785b9afb6946143c212e1
parent6c102bd456d760fbe237fd49ce46f212614f228a (diff)
downloadopie-e2368b92a101437f7ed289d5ae62f7e7e2466344.zip
opie-e2368b92a101437f7ed289d5ae62f7e7e2466344.tar.gz
opie-e2368b92a101437f7ed289d5ae62f7e7e2466344.tar.bz2
OPacketCapturer API addition: setAutoDelete() and autoDelete()
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp21
-rw-r--r--libopie2/opienet/opcap.h20
2 files changed, 33 insertions, 8 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 4081d4f..c5df041 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -59,3 +59,3 @@ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char*
59{ 59{
60 //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); 60 qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen );
61 61
@@ -89,2 +89,3 @@ OPacket::~OPacket()
89{ 89{
90 qDebug( "OPacket::~OPacket( %s )", name() );
90} 91}
@@ -1065,3 +1066,3 @@ QString OWaveLanControlPacket::controlType() const
1065OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) 1066OPacketCapturer::OPacketCapturer( QObject* parent, const char* name )
1066 :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ) 1067 :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ), _autodelete( true )
1067{ 1068{
@@ -1080,2 +1081,14 @@ OPacketCapturer::~OPacketCapturer()
1080 1081
1082void OPacketCapturer::setAutoDelete( bool b )
1083{
1084 _autodelete = b;
1085}
1086
1087
1088bool OPacketCapturer::autoDelete() const
1089{
1090 return _autodelete;
1091}
1092
1093
1081void OPacketCapturer::setBlocking( bool b ) 1094void OPacketCapturer::setBlocking( bool b )
@@ -1323,4 +1336,4 @@ void OPacketCapturer::readyToReceive()
1323 emit receivedPacket( p ); 1336 emit receivedPacket( p );
1324 // emit is synchronous - packet has been dealt with, now it's safe to delete 1337 // emit is synchronous - packet has been dealt with, now it's safe to delete (if enabled)
1325 delete p; 1338 if ( _autodelete ) delete p;
1326} 1339}
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 72a78de..4ff8495 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -136,5 +136,4 @@ class OPacket : public QObject
136 136
137 private:
138
139 QString dumpStructure() const; 137 QString dumpStructure() const;
138 private:
140 QString _dumpStructure( QObjectList* ) const; 139 QString _dumpStructure( QObjectList* ) const;
@@ -695,2 +694,14 @@ class OPacketCapturer : public QObject
695 const QMap<QString,int>& statistics() const; 694 const QMap<QString,int>& statistics() const;
695 /**
696 * Enable or disable the auto-delete option.
697 * If auto-delete is enabled, then the packet capturer will delete a packet right
698 * after it has been emit'ted. This is the default, which is useful if the packet
699 * capturer has the only reference to the packets. If you pass the packet for adding
700 * into a collection or do processing after the SLOT, the auto delete must be disabled.
701 */
702 void setAutoDelete( bool enable );
703 /**
704 * @returns the auto-delete value.
705 */
706 bool autoDelete() const;
696 707
@@ -713,4 +724,5 @@ class OPacketCapturer : public QObject
713 QMap<QString, int> _stats; // statistics; 724 QMap<QString, int> _stats; // statistics;
714 class Private; // Private Forward declaration 725 bool _autodelete; // if we auto delete packets after emit
715 Private *d; // if we need to add data 726 class Private; // Private Forward declaration
727 Private *d; // if we need to add data
716}; 728};