summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/cornucopia/olistview.cpp8
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp60
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.h4
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp32
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h10
-rw-r--r--noncore/net/wellenreiter/gui/scanlistitem.cpp21
-rw-r--r--noncore/net/wellenreiter/gui/scanlistitem.h4
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp5
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h1
9 files changed, 118 insertions, 27 deletions
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.cpp b/noncore/net/wellenreiter/cornucopia/olistview.cpp
index bca17b2..8bc59de 100644
--- a/noncore/net/wellenreiter/cornucopia/olistview.cpp
+++ b/noncore/net/wellenreiter/cornucopia/olistview.cpp
@@ -202,10 +202,10 @@ bool OListViewItem::isAlternate()
// check if the item above is an OListViewItem
OListViewItem *above = static_cast<OListViewItem*>( itemAbove() );
- /*if (not itemAbove()->inherits( "OListViewItem" )) return false;*/
+ /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/
// check if we have a valid alternate background color
- if (not (lv && lv->alternateBackground().isValid())) return false;
+ if (!(lv && lv->alternateBackground().isValid())) return false;
m_known = above ? above->m_known : true;
if (m_known)
@@ -221,7 +221,7 @@ bool OListViewItem::isAlternate()
item = static_cast<OListViewItem *>(parent());
if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd;
item = static_cast<OListViewItem *>(parent()->firstChild());
- /* if !( item.inherits( "OListViewItem" ) item = 0; */
+ /* if ( !item.inherits( "OListViewItem" ) item = 0; */
}
else
{
@@ -233,7 +233,7 @@ bool OListViewItem::isAlternate()
item->m_odd = previous = !previous;
item->m_known = true;
item = static_cast<OListViewItem *>(item->nextSibling());
- /* if !(item.inherits( "OListViewItem" ) ) break; */
+ /* if (!item.inherits( "OListViewItem" ) ) break; */
}
}
return m_odd;
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index cb003dd..e388fc5 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -24,6 +24,7 @@
#include <qfile.h>
#include <qiconset.h>
#include <qmenubar.h>
+#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qstatusbar.h>
#include <qtextstream.h>
@@ -59,7 +60,9 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n
// setup tool buttons
startStopButton = new QToolButton( 0 );
+ #ifdef QWS
startStopButton->setAutoRaise( true );
+ #endif
#ifdef QWS
startStopButton->setOnIconSet( *cancelIconSet );
startStopButton->setOffIconSet( *searchIconSet );
@@ -71,12 +74,16 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n
startStopButton->setEnabled( false );
QToolButton* c = new QToolButton( 0 );
+ #ifdef QWS
c->setAutoRaise( true );
+ #endif
c->setIconSet( *infoIconSet );
c->setEnabled( false );
QToolButton* d = new QToolButton( 0 );
+ #ifdef QWS
d->setAutoRaise( true );
+ #endif
d->setIconSet( *settingsIconSet );
connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) );
@@ -87,10 +94,15 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n
QMenuBar* mb = menuBar();
QPopupMenu* fileSave = new QPopupMenu( mb );
+ fileSave->insertItem( "&Session", this, SLOT( fileSaveSession() ) );
fileSave->insertItem( "&Log", this, SLOT( fileSaveLog() ) );
+ QPopupMenu* fileLoad = new QPopupMenu( mb );
+ fileLoad->insertItem( "&Session", this, SLOT( fileLoadSession() ) );
+ fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) );
+
QPopupMenu* file = new QPopupMenu( mb );
- id = file->insertItem( "&Load" );
+ id = file->insertItem( "&Load", fileLoad );
file->setItemEnabled( id, false );
file->insertItem( "&Save", fileSave );
@@ -172,11 +184,11 @@ WellenreiterMainWindow::~WellenreiterMainWindow()
void WellenreiterMainWindow::demoAddStations()
{
- mw->netView()->addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 );
- mw->netView()->addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 );
- mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 );
- mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 );
- mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 );
+ mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 );
+ mw->netView()->addNewItem( "managed", "Vanille", "00:00:1c:EF:A6:23", true, 11, 10 );
+ mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 );
+ mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 );
+ mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 );
}
void WellenreiterMainWindow::fileSaveLog()
@@ -188,11 +200,41 @@ void WellenreiterMainWindow::fileSaveLog()
QTextStream t( &f );
t << mw->logWindow()->getLog();
f.close();
- qDebug( "saved log in file '%s'", (const char*) fname );
+ qDebug( "Saved log to file '%s'", (const char*) fname );
+ }
+ else
+ {
+ qDebug( "Problem saving log to file '%s'", (const char*) fname );
+ }
+
+}
+
+void WellenreiterMainWindow::fileSaveSession()
+{
+ const QString fname( "/tmp/session.xml" );
+ QFile f( fname );
+ if ( f.open(IO_WriteOnly) )
+ {
+ QTextStream t( &f );
+ mw->netView()->dump( t );
+ f.close();
+ qDebug( "Saved session to file '%s'", (const char*) fname );
}
else
{
- qDebug( "Problem saving log in file '%s'", (const char*) fname );
+ qDebug( "Problem saving session to file '%s'", (const char*) fname );
}
+}
-} \ No newline at end of file
+void WellenreiterMainWindow::closeEvent( QCloseEvent* e )
+{
+ if ( mw->isDaemonRunning() )
+ {
+ QMessageBox::warning( this, "Wellenreiter/Opie", "Sniffing in progress!\nPlease stop sniffing before closing." );
+ e->ignore();
+ }
+ else
+ {
+ QMainWindow::closeEvent( e );
+ }
+}
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h
index 03aa08a..8bfccf3 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.h
+++ b/noncore/net/wellenreiter/gui/mainwindow.h
@@ -43,10 +43,14 @@ class WellenreiterMainWindow: public QMainWindow
QToolButton* startStopButton;
+ protected:
+ virtual void closeEvent( QCloseEvent* );
+
public slots:
void showConfigure();
void demoAddStations();
void fileSaveLog();
+ void fileSaveSession();
};
#endif
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 6d3469c..cdc2c48 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -20,13 +20,15 @@
#include "manufacturers.h"
+#include <qtextstream.h>
+
MScanListView::MScanListView( QWidget* parent, const char* name )
:OListView( parent, name ), _manufacturerdb( 0 )
{
setFrameShape( QListView::StyledPanel );
setFrameShadow( QListView::Sunken );
-
+
addColumn( tr( "Net/Station" ) );
setColumnAlignment( 0, AlignLeft || AlignVCenter );
addColumn( tr( "B" ) );
@@ -125,17 +127,17 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
else
{
s.sprintf( "(i) new network: '%s'", (const char*) essid );
-
+
network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 );
- }
-
-
+ }
+
+
// insert new station as child from network
-
+
// no essid to reduce clutter, maybe later we have a nick or stationname to display!?
-
+
qDebug( "inserting new station %s", (const char*) macaddr );
-
+
MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
if ( _manufacturerdb )
station->setManufacturer( _manufacturerdb->lookup( macaddr ) );
@@ -148,6 +150,18 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
{
s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel );
}
-
+
}
+void MScanListView::dump( QTextStream& t ) const
+{
+ qDebug( "dumping scanlist..." );
+
+ QListViewItemIterator it( const_cast<MScanListView*>( this ) );
+ for ( ; it.current(); ++it )
+ {
+ static_cast<MScanListItem*>( it.current() )->dump( t );
+ }
+
+ qDebug( "dump finished." );
+}
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index 475f7b6..f06f251 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -18,20 +18,22 @@
#include <cornucopia/olistview.h>
-class QString;
+#include <qtextstream.h>
+class QString;
class ManufacturerDB;
class MScanListView: public OListView
{
Q_OBJECT
-
+
public:
MScanListView( QWidget* parent = 0, const char* name = 0 );
virtual ~MScanListView();
-
+
void setManufacturerDB( ManufacturerDB* manufacturerdb );
-
+ void dump( QTextStream& t ) const;
+
public slots:
void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp
index bfa7aa9..4aecd2b 100644
--- a/noncore/net/wellenreiter/gui/scanlistitem.cpp
+++ b/noncore/net/wellenreiter/gui/scanlistitem.cpp
@@ -83,7 +83,12 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr,
listView()->triggerUpdate();
this->type = type;
-
+ _type = type;
+ _essid = essid;
+ _macaddr = macaddr;
+ _channel = channel;
+ _beacons = 0;
+ _signal = 0;
}
void MScanListItem::setManufacturer( const QString& manufacturer )
@@ -100,3 +105,17 @@ void MScanListItem::receivedBeacon()
setText( col_sig, QString::number( _beacons ) );
setText( col_lastseen, QTime::currentTime().toString() );
}
+
+void MScanListItem::dump( QTextStream& t ) const
+{
+ qDebug( "dumping scanlistitem at <%d>", this );
+ t << "<ITEM type=" << _type;
+ t << " ESSID='" << _essid;
+ t << "' MAC=" << _macaddr;
+ t << " WEP=" << _wep;
+ t << " CHANNEL=" << _channel;
+ t << " SIGNAL=" << _signal;
+ t << " BEACONS=" << _beacons;
+ t << ">\n";
+}
+
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.h b/noncore/net/wellenreiter/gui/scanlistitem.h
index 89b3bc4..5f6ae40 100644
--- a/noncore/net/wellenreiter/gui/scanlistitem.h
+++ b/noncore/net/wellenreiter/gui/scanlistitem.h
@@ -18,6 +18,8 @@
#include <cornucopia/olistview.h>
+#include <qtextstream.h>
+
class QString;
class MScanListItem: public OListViewItem
@@ -64,6 +66,8 @@ class MScanListItem: public OListViewItem
void setManufacturer( const QString& manufacturer );
+ void dump( QTextStream& t ) const;
+
private:
QString _type;
QString _essid;
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index c599bb4..1ccf971 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -123,6 +123,11 @@ Wellenreiter::~Wellenreiter()
// no need to delete child widgets, Qt does it all for us
delete manufacturerdb;
+ if ( daemon_fd != -1 )
+ {
+ qDebug( "closing comm socket" );
+ close( daemon_fd );
+ }
}
void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index ff523d4..ee9dca9 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -53,6 +53,7 @@ class Wellenreiter : public WellenreiterBase {
void setConfigWindow( WellenreiterConfigWindow* cw );
MScanListView* netView() const { return netview; };
MLogWindow* logWindow() const { return logwindow; };
+ bool isDaemonRunning() const { return daemonRunning; };
protected:
bool daemonRunning;