summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-03-02 16:38:17 (UTC)
committer mickeyl <mickeyl>2003-03-02 16:38:17 (UTC)
commitd0e64d0c7961de1c3ecb886ae76c6701f268d767 (patch) (unidiff)
tree2ea00b7cd496bb0720b9730bbf993f2013a87d3e
parenta0ae7d2b8cfef3f643c4aa536bdf25d7da510142 (diff)
downloadopie-d0e64d0c7961de1c3ecb886ae76c6701f268d767.zip
opie-d0e64d0c7961de1c3ecb886ae76c6701f268d767.tar.gz
opie-d0e64d0c7961de1c3ecb886ae76c6701f268d767.tar.bz2
first attempt to add session persistence
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/cornucopia/README127
-rw-r--r--noncore/net/wellenreiter/cornucopia/olistview.cpp151
-rw-r--r--noncore/net/wellenreiter/cornucopia/olistview.h87
-rw-r--r--noncore/net/wellenreiter/gui/gui.pro2
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp36
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.h1
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp130
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h77
-rw-r--r--noncore/net/wellenreiter/gui/scanlistitem.cpp121
-rw-r--r--noncore/net/wellenreiter/gui/scanlistitem.h83
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp8
11 files changed, 578 insertions, 245 deletions
diff --git a/noncore/net/wellenreiter/cornucopia/README b/noncore/net/wellenreiter/cornucopia/README
index 36a6954..486dc67 100644
--- a/noncore/net/wellenreiter/cornucopia/README
+++ b/noncore/net/wellenreiter/cornucopia/README
@@ -1,3 +1,124 @@
1--------------------------------------------------------------- 1/********************************************************************
2Dies ist ein Testballon für opielibs1.2 - Codename: Cornucopia 2/* This is an overview of the opielibs 1.2 project
3--------------------------------------------------------------- 3/********************************************************************/
4
5 Origin: opielibs is about creating classes to
6 * optimize Qt classes for the embedded environment
7 * provide sophisticated abstractions for developers
8 * provide complete documentation and working examples
9 * provide end users with a common look and feel
10 * reduce memory footprint through sharing code
11 * reduce possible bugs through reusing tested code
12
13--------------------------------------------------------
141. General Overview
15--------------------------------------------------------
16
17Separation into the following libraries:
18 - libopiecore
19 - libopieui
20 - libopiepim
21 - libopienet
22
231.1 Contents of libopiecore [ opiecore ]
24--------------------------------------------------------
25
26 - oprocctrl
27 - oprocess
28 - odevice
29 - odevicebutton
30
31 - oconfig
32 - oconfiggroupsaver
33 - ocompletionbase
34 - ocompletion
35 - ocomptreenodelist
36 - ocomptreenode
37 - ocompletionwrapper
38 - oglobal
39 - oglobalsettings
40 - osortableitem
41 - osortablevaluelist
42
431.2 Contents of libopieui [ opieui ]
44--------------------------------------------------------
45
46 - oapplication
47
48 - ofiledialog
49 - colordialog
50 - oclickablelabel
51 - ocolorbutton
52 - colorpopupmenu
53 - otabinfo
54 - otabbar
55 - otabwidget
56 - ofontmenu
57 - ofontselector
58 - ofileview
59 - oticker
60
61 - olistview
62 - olistviewitem
63 - oversatileview
64 - oversatileviewitem
65 - ocompletionbox
66 - olineedit
67 - ocombobox
68 - ohistorycombo
69
70 - omessagebox
71 - odialogbase
72
73 - todayconfigwidget (rather into opiepim?)
74 - orecurrancewidget (rather into opiepim?)
75 - otimepicker (rather into opiepim?)
76
771.3 Contents of libopiepim [ opiepim ]
78--------------------------------------------------------
79
80 - ocheckitem
81 - todoevent
82 - todoresource
83 - todayplugininterface
84 - todovcalresource
85
861.4 Contents of libopiedb [ opiedb ]
87--------------------------------------------------------
88
89 - tododb
90 - xmltree
91
921.5 Contents of libopienet [ opienet ]
93--------------------------------------------------------
94
95 <libmail stuff>
96 <libbend stuff>
97 <libftp stuff>
98
99--------------------------------------------------------
1002.0 Feature Description
101--------------------------------------------------------
102
1032.1 libopiecore
104
105...
106
1072.2 libopieui
108
109...
110
1112.2.x OListView, OListViewItem, OListViewFactory
112
113...
114
1152.3 libopiepim
116
117...
118
1192.4 libopiedb
120
121...
122
1232.5 libopienet
124
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.cpp b/noncore/net/wellenreiter/cornucopia/olistview.cpp
index 8bc59de..f2d3730 100644
--- a/noncore/net/wellenreiter/cornucopia/olistview.cpp
+++ b/noncore/net/wellenreiter/cornucopia/olistview.cpp
@@ -30,233 +30,378 @@
30 30
31*/ 31*/
32 32
33#include <qcolor.h> 33#include <qcolor.h>
34#include <qheader.h> 34#include <qheader.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <qpixmap.h> 36#include <qpixmap.h>
37 37
38#include "olistview.h" 38#include "olistview.h"
39 39
40//****************************** OListView ************************************************************************** 40//****************************** OListView **************************************************************************
41 41
42OListView::OListView( QWidget *parent, const char *name ) 42OListView::OListView( QWidget *parent, const char *name )
43 :QListView( parent, name ) 43 :QListView( parent, name )
44{ 44{
45 //FIXME: get from global settings and calculate ==> see oglobalsettings.* 45 //FIXME: get from global settings and calculate ==> see oglobalsettings.*
46 46
47 m_alternateBackground = QColor( 238, 246, 255 ); 47 m_alternateBackground = QColor( 238, 246, 255 );
48 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); 48 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine );
49 m_fullWidth = true; 49 m_fullWidth = true;
50} 50}
51 51
52OListView::~OListView() 52OListView::~OListView()
53{ 53{
54} 54}
55 55
56void OListView::setFullWidth( bool fullWidth ) 56void OListView::setFullWidth( bool fullWidth )
57{ 57{
58 m_fullWidth = m_fullWidth; 58 m_fullWidth = m_fullWidth;
59 #if QT_VERSION > 290 59 #if QT_VERSION > 290
60 header()->setStretchEnabled( fullWidth, columns()-1 ); 60 header()->setStretchEnabled( fullWidth, columns()-1 );
61 #endif 61 #endif
62} 62}
63 63
64bool OListView::fullWidth() const 64bool OListView::fullWidth() const
65{ 65{
66 return m_fullWidth; 66 return m_fullWidth;
67} 67}
68 68
69int OListView::addColumn( const QString& label, int width ) 69int OListView::addColumn( const QString& label, int width )
70{ 70{
71 int result = QListView::addColumn( label, width ); 71 int result = QListView::addColumn( label, width );
72 #if QT_VERSION > 290 72 #if QT_VERSION > 290
73 if (m_fullWidth) { 73 if (m_fullWidth) {
74 header()->setStretchEnabled( false, columns()-2 ); 74 header()->setStretchEnabled( false, columns()-2 );
75 header()->setStretchEnabled( true, columns()-1 ); 75 header()->setStretchEnabled( true, columns()-1 );
76 } 76 }
77 #endif 77 #endif
78 return result; 78 return result;
79} 79}
80 80
81int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) 81int OListView::addColumn( const QIconSet& iconset, const QString& label, int width )
82{ 82{
83 int result = QListView::addColumn( iconset, label, width ); 83 int result = QListView::addColumn( iconset, label, width );
84 #if QT_VERSION > 290 84 #if QT_VERSION > 290
85 if (m_fullWidth) { 85 if (m_fullWidth) {
86 header()->setStretchEnabled( false, columns()-2 ); 86 header()->setStretchEnabled( false, columns()-2 );
87 header()->setStretchEnabled( true, columns()-1 ); 87 header()->setStretchEnabled( true, columns()-1 );
88 } 88 }
89 #endif 89 #endif
90 return result; 90 return result;
91} 91}
92 92
93void OListView::removeColumn( int index ) 93void OListView::removeColumn( int index )
94{ 94{
95 QListView::removeColumn(index); 95 QListView::removeColumn(index);
96 #if QT_VERSION > 290 96 #if QT_VERSION > 290
97 if ( m_fullWidth && index == columns() ) 97 if ( m_fullWidth && index == columns() )
98 { 98 {
99 header()->setStretchEnabled( true, columns()-1 ); 99 header()->setStretchEnabled( true, columns()-1 );
100 } 100 }
101 #endif 101 #endif
102} 102}
103 103
104const QColor& OListView::alternateBackground() const 104const QColor& OListView::alternateBackground() const
105{ 105{
106 return m_alternateBackground; 106 return m_alternateBackground;
107} 107}
108 108
109void OListView::setAlternateBackground( const QColor &c ) 109void OListView::setAlternateBackground( const QColor &c )
110{ 110{
111 m_alternateBackground = c; 111 m_alternateBackground = c;
112 repaint(); 112 repaint();
113} 113}
114 114
115const QPen& OListView::columnSeparator() const 115const QPen& OListView::columnSeparator() const
116{ 116{
117 return m_columnSeparator; 117 return m_columnSeparator;
118} 118}
119 119
120void OListView::setColumnSeparator( const QPen& p ) 120void OListView::setColumnSeparator( const QPen& p )
121{ 121{
122 m_columnSeparator = p; 122 m_columnSeparator = p;
123 repaint(); 123 repaint();
124} 124}
125 125
126#ifndef QT_NO_DATASTREAM
127void OListView::serializeTo( QDataStream& s ) const
128{
129 #warning Caution... the binary format is still under construction...
130 qDebug( "storing OListView..." );
131
132 // store number of columns and the labels
133 s << columns();
134 for ( int i = 0; i < columns(); ++i )
135 s << columnText( i );
136
137 // calculate the number of top-level items to serialize
138 int items = 0;
139 QListViewItem* item = firstChild();
140 while ( item )
141 {
142 item = item->nextSibling();
143 items++;
144 }
145
146 // store number of items and the items itself
147 s << items;
148 item = firstChild();
149 for ( int i = 0; i < items; ++i )
150 {
151 s << *static_cast<OListViewItem*>( item );
152 item = item->nextSibling();
153 }
154
155 qDebug( "OListview stored." );
156}
157
158void OListView::serializeFrom( QDataStream& s )
159{
160 #warning Caution... the binary format is still under construction...
161 qDebug( "loading OListView..." );
162
163 int cols;
164 s >> cols;
165 qDebug( "read number of columns = %d", cols );
166
167 while ( columns() < cols ) addColumn( QString::null );
168
169 for ( int i = 0; i < cols; ++i )
170 {
171 QString coltext;
172 s >> coltext;
173 qDebug( "read text '%s' for column %d", (const char*) coltext, i );
174 setColumnText( i, coltext );
175 }
176
177 int items;
178 s >> items;
179 qDebug( "read number of items = %d", items );
180
181 for ( int i = 0; i < items; ++i )
182 {
183 OListViewItem* item = new OListViewItem( this );
184 s >> *item;
185 }
186
187 qDebug( "OListView loaded." );
188
189}
190
191QDataStream& operator<<( QDataStream& s, const OListView& lv )
192{
193 lv.serializeTo( s );
194}
195
196QDataStream& operator>>( QDataStream& s, OListView& lv )
197{
198 lv.serializeFrom( s );
199}
200#endif // QT_NO_DATASTREAM
201
126//****************************** OListViewItem *********************************************************************** 202//****************************** OListViewItem ***********************************************************************
127 203
128OListViewItem::OListViewItem(QListView *parent) 204OListViewItem::OListViewItem(QListView *parent)
129 : QListViewItem(parent) 205 : QListViewItem(parent)
130{ 206{
131 init(); 207 init();
132} 208}
133 209
134OListViewItem::OListViewItem(QListViewItem *parent) 210OListViewItem::OListViewItem(QListViewItem *parent)
135 : QListViewItem(parent) 211 : QListViewItem(parent)
136{ 212{
137 init(); 213 init();
138} 214}
139 215
140OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) 216OListViewItem::OListViewItem(QListView *parent, QListViewItem *after)
141 : QListViewItem(parent, after) 217 : QListViewItem(parent, after)
142{ 218{
143 init(); 219 init();
144} 220}
145 221
146OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) 222OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after)
147 : QListViewItem(parent, after) 223 : QListViewItem(parent, after)
148{ 224{
149 init(); 225 init();
150} 226}
151 227
152OListViewItem::OListViewItem(QListView *parent, 228OListViewItem::OListViewItem(QListView *parent,
153 QString label1, QString label2, QString label3, QString label4, 229 QString label1, QString label2, QString label3, QString label4,
154 QString label5, QString label6, QString label7, QString label8) 230 QString label5, QString label6, QString label7, QString label8)
155 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 231 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
156{ 232{
157 init(); 233 init();
158} 234}
159 235
160OListViewItem::OListViewItem(QListViewItem *parent, 236OListViewItem::OListViewItem(QListViewItem *parent,
161 QString label1, QString label2, QString label3, QString label4, 237 QString label1, QString label2, QString label3, QString label4,
162 QString label5, QString label6, QString label7, QString label8) 238 QString label5, QString label6, QString label7, QString label8)
163 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 239 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
164{ 240{
165 init(); 241 init();
166} 242}
167 243
168OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, 244OListViewItem::OListViewItem(QListView *parent, QListViewItem *after,
169 QString label1, QString label2, QString label3, QString label4, 245 QString label1, QString label2, QString label3, QString label4,
170 QString label5, QString label6, QString label7, QString label8) 246 QString label5, QString label6, QString label7, QString label8)
171 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 247 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
172{ 248{
173 init(); 249 init();
174} 250}
175 251
176OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, 252OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after,
177 QString label1, QString label2, QString label3, QString label4, 253 QString label1, QString label2, QString label3, QString label4,
178 QString label5, QString label6, QString label7, QString label8) 254 QString label5, QString label6, QString label7, QString label8)
179 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 255 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
180{ 256{
181 init(); 257 init();
182} 258}
183 259
184OListViewItem::~OListViewItem() 260OListViewItem::~OListViewItem()
185{ 261{
186} 262}
187 263
188void OListViewItem::init() 264void OListViewItem::init()
189{ 265{
190 m_known = false; 266 m_known = false;
191} 267}
192 268
193const QColor &OListViewItem::backgroundColor() 269const QColor &OListViewItem::backgroundColor()
194{ 270{
195 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : 271 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() :
196 listView()->viewport()->colorGroup().base(); 272 listView()->viewport()->colorGroup().base();
197} 273}
198 274
199bool OListViewItem::isAlternate() 275bool OListViewItem::isAlternate()
200{ 276{
201 OListView *lv = static_cast<OListView*>( listView() ); 277 OListView *lv = static_cast<OListView*>( listView() );
202 278
203 // check if the item above is an OListViewItem 279 // check if the item above is an OListViewItem
204 OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); 280 OListViewItem *above = static_cast<OListViewItem*>( itemAbove() );
205 /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ 281 /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/
206 282
207 // check if we have a valid alternate background color 283 // check if we have a valid alternate background color
208 if (!(lv && lv->alternateBackground().isValid())) return false; 284 if (!(lv && lv->alternateBackground().isValid())) return false;
209 285
210 m_known = above ? above->m_known : true; 286 m_known = above ? above->m_known : true;
211 if (m_known) 287 if (m_known)
212 { 288 {
213 m_odd = above ? !above->m_odd : false; 289 m_odd = above ? !above->m_odd : false;
214 } 290 }
215 else 291 else
216 { 292 {
217 OListViewItem *item; 293 OListViewItem *item;
218 bool previous = true; 294 bool previous = true;
219 if (parent()) 295 if (parent())
220 { 296 {
221 item = static_cast<OListViewItem *>(parent()); 297 item = static_cast<OListViewItem *>(parent());
222 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; 298 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd;
223 item = static_cast<OListViewItem *>(parent()->firstChild()); 299 item = static_cast<OListViewItem *>(parent()->firstChild());
224 /* if ( !item.inherits( "OListViewItem" ) item = 0; */ 300 /* if ( !item.inherits( "OListViewItem" ) item = 0; */
225 } 301 }
226 else 302 else
227 { 303 {
228 item = static_cast<OListViewItem *>(lv->firstChild()); 304 item = static_cast<OListViewItem *>(lv->firstChild());
229 } 305 }
230 306
231 while(item) 307 while(item)
232 { 308 {
233 item->m_odd = previous = !previous; 309 item->m_odd = previous = !previous;
234 item->m_known = true; 310 item->m_known = true;
235 item = static_cast<OListViewItem *>(item->nextSibling()); 311 item = static_cast<OListViewItem *>(item->nextSibling());
236 /* if (!item.inherits( "OListViewItem" ) ) break; */ 312 /* if (!item.inherits( "OListViewItem" ) ) break; */
237 } 313 }
238 } 314 }
239 return m_odd; 315 return m_odd;
240} 316}
241 317
242void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 318void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
243{ 319{
244 QColorGroup _cg = cg; 320 QColorGroup _cg = cg;
245 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 321 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
246 if (pm && !pm->isNull()) 322 if (pm && !pm->isNull())
247 { 323 {
248 _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); 324 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) );
249 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 325 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
250 } 326 }
251 else if ( isAlternate() ) 327 else if ( isAlternate() )
252 { 328 {
253 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); 329 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() );
254 } 330 }
255 QListViewItem::paintCell(p, _cg, column, width, alignment); 331 QListViewItem::paintCell( p, _cg, column, width, alignment );
256 332
257 //FIXME: Use styling here? 333 //FIXME: Use styling here!
258 334
259 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); 335 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator();
260 p->setPen( pen ); 336 p->setPen( pen );
261 p->drawLine( width-1, 0, width-1, height() ); 337 p->drawLine( width-1, 0, width-1, height() );
262} 338}
339
340#ifndef QT_NO_DATASTREAM
341void OListViewItem::serializeTo( QDataStream& s ) const
342{
343 #warning Caution... the binary format is still under construction...
344 qDebug( "storing OListViewItem..." );
345
346 // store item text
347 for ( int i = 0; i < listView()->columns(); ++i )
348 {
349 s << text( i );
350 }
351
352 // calculate the number of children to serialize
353 int items = 0;
354 QListViewItem* item = firstChild();
355 while ( item )
356 {
357 item = item->nextSibling();
358 items++;
359 }
360
361 // store number of items and the items itself
362 s << items;
363 item = firstChild();
364 for ( int i = 0; i < items; ++i )
365 {
366 s << *static_cast<OListViewItem*>( item );
367 item = item->nextSibling();
368 }
369
370 qDebug( "OListviewItem stored." );
371}
372void OListViewItem::serializeFrom( QDataStream& s )
373{
374 #warning Caution... the binary format is still under construction...
375 qDebug( "loading OListViewItem..." );
376
377 for ( int i = 0; i < listView()->columns(); ++i )
378 {
379 QString coltext;
380 s >> coltext;
381 qDebug( "read text '%s' for column %d", (const char*) coltext, i );
382 setText( i, coltext );
383 }
384
385 int items;
386 s >> items;
387 qDebug( "read number of items = %d", items );
388
389 for ( int i = 0; i < items; ++i )
390 {
391 OListViewItem* item = new OListViewItem( this );
392 s >> (*item);
393 }
394
395 qDebug( "OListViewItem loaded." );
396}
397
398QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi )
399{
400 lvi.serializeTo( s );
401}
402
403QDataStream& operator>>( QDataStream& s, OListViewItem& lvi )
404{
405 lvi.serializeFrom( s );
406}
407#endif // QT_NO_DATASTREAM
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.h b/noncore/net/wellenreiter/cornucopia/olistview.h
index 4b9e4b0..9df5500 100644
--- a/noncore/net/wellenreiter/cornucopia/olistview.h
+++ b/noncore/net/wellenreiter/cornucopia/olistview.h
@@ -1,168 +1,237 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              Copyright (C) 2003 Michael 'Mickey' Lauer 4              Copyright (C) 2003 Michael 'Mickey' Lauer
5 <mickey@tm.informatik.uni-frankfurt.de> 5 <mickey@tm.informatik.uni-frankfurt.de>
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30 30
31*/ 31*/
32 32
33#ifndef OLISTVIEW_H 33#ifndef OLISTVIEW_H
34#define OLISTVIEW_H 34#define OLISTVIEW_H
35 35
36#include <qlistview.h>
37#include <qcolor.h> 36#include <qcolor.h>
37#include <qlistview.h>
38#include <qpen.h> 38#include <qpen.h>
39#include <qdatastream.h>
40
41class OListViewFactory;
39 42
40/** 43/**
41 * A @ref QListView variant featuring visual enhancements 44 * A @ref QListView variant featuring visual and functional enhancements
42 * like an alternate background for odd rows and an autostretch 45 * like an alternate background for odd rows, an autostretch mode
43 * mode for the width of the widget. 46 * for the width of the widget ( >= Qt 3 only ) and persistence capabilities.
44 * 47 *
45 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 48 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
46 * @short OListView list/tree widget. 49 * @short OListView list/tree widget.
47 */ 50 */
48 class OListView: public QListView 51 class OListView: public QListView
49{ 52{
50 public: 53 public:
51 /** 54 /**
52 * Constructor. 55 * Constructor.
53 * 56 *
54 * The parameters @p parent and @p name are handled by 57 * The parameters @p parent and @p name are handled by
55 * @ref QListView, as usual. 58 * @ref QListView, as usual.
56 */ 59 */
57 OListView ( QWidget *parent = 0, const char *name = 0 ); 60 OListView ( QWidget *parent = 0, const char *name = 0 );
58 61
59 /** 62 /**
60 * Destructor. 63 * Destructor.
61 */ 64 */
62 virtual ~OListView(); 65 virtual ~OListView();
63 66
64 /** 67 /**
65 * Let the last column fit exactly all the available width. 68 * Let the last column fit exactly all the available width.
66 */ 69 */
67 void setFullWidth( bool fullWidth ); 70 void setFullWidth( bool fullWidth );
68 71
69 /** 72 /**
70 * Returns whether the last column is set to fit the available width. 73 * Returns whether the last column is set to fit the available width.
71 */ 74 */
72 bool fullWidth() const; 75 bool fullWidth() const;
73 76
74 /** 77 /**
75 * Reimplemented for full width support 78 * Reimplemented for full width support
76 */ 79 */
77 virtual int addColumn( const QString& label, int width = -1 ); 80 virtual int addColumn( const QString& label, int width = -1 );
78 81
79 /** 82 /**
80 * Reimplemented for full width support 83 * Reimplemented for full width support
81 */ 84 */
82 virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); 85 virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 );
83 86
84 /** 87 /**
85 * Reimplemented for full width support 88 * Reimplemented for full width support
86 */ 89 */
87 virtual void removeColumn(int index); 90 virtual void removeColumn(int index);
88 91
89 /** 92 /**
90 * sets the alternate background background color. 93 * sets the alternate background background color.
91 * This only has an effect if the items are OListViewItems 94 * This only has an effect if the items are OListViewItems
92 * 95 *
93 * @param c the color to use for every other item. Set to an invalid 96 * @param c the color to use for every other item. Set to an invalid
94 * color to disable alternate colors. 97 * color to disable alternate colors.
95 */ 98 */
96 void setAlternateBackground( const QColor &c ); 99 void setAlternateBackground( const QColor &c );
97 100
98 /** 101 /**
99 * sets the column separator pen. 102 * sets the column separator pen.
100 * 103 *
101 * @param p the pen used to draw the column separator. 104 * @param p the pen used to draw the column separator.
102 */ 105 */
103 void setColumnSeparator( const QPen &p ); 106 void setColumnSeparator( const QPen &p );
104 107
105 /** 108 /**
106 * @return the alternate background color 109 * @return the alternate background color
107 */ 110 */
108 const QColor& alternateBackground() const; 111 const QColor& alternateBackground() const;
109 112
110 /** 113 /**
111 * @return the column separator pen 114 * @return the column separator pen
112 */ 115 */
113 const QPen& columnSeparator() const; 116 const QPen& columnSeparator() const;
114 117
118 #ifndef QT_NO_DATASTREAM
119 /**
120 * serialize this object to a @ref QDataStream
121 * @param s the stream used to serialize this object.
122 */
123 virtual void serializeTo( QDataStream& s ) const;
124
125 /**
126 * serialize this object from a @ref QDataStream
127 * @param s the stream used to serialize this object.
128 */
129 virtual void serializeFrom( QDataStream& s );
130 #endif
131
132 /**
133 * returns a factory for OListView classes
134 * creates one on the fly if it doesn't exist
135 * @return the XML Factory
136 */
137 #ifndef QT_NO_XML
138 //OListViewFactory* Factory();
139 #endif
140
115 private: 141 private:
116 QColor m_alternateBackground; 142 QColor m_alternateBackground;
117 bool m_fullWidth; 143 bool m_fullWidth;
118 QPen m_columnSeparator; 144 QPen m_columnSeparator;
119 145 #ifndef QT_NO_XML
146 //OListViewFactory* m_Factory;
147 #endif
120}; 148};
121 149
150#ifndef QT_NO_DATASTREAM
151/**
152 * \relates QListView
153 * Writes a listview to the stream and returns a reference to the stream.
154 */
155QDataStream& operator<<( QDataStream& s, const OListView& lv );
156/**
157 * \relates QListView
158 * Reads a listview from the stream and returns a reference to the stream.
159 */
160QDataStream& operator>>( QDataStream& s, OListView& lv );
161#endif // QT_NO_DATASTREAM
162
122//****************************** OListViewItem ****************************************************************** 163//****************************** OListViewItem ******************************************************************
123 164
124class OListViewItem: public QListViewItem 165class OListViewItem: public QListViewItem
125{ 166{
126 public: 167 public:
127 OListViewItem( QListView * parent ); 168 OListViewItem( QListView * parent );
128 OListViewItem( QListViewItem * parent ); 169 OListViewItem( QListViewItem * parent );
129 OListViewItem( QListView * parent, QListViewItem * after ); 170 OListViewItem( QListView * parent, QListViewItem * after );
130 OListViewItem( QListViewItem * parent, QListViewItem * after ); 171 OListViewItem( QListViewItem * parent, QListViewItem * after );
131 172
132 OListViewItem( QListView * parent, 173 OListViewItem( QListView * parent,
133 QString, QString = QString::null, 174 QString, QString = QString::null,
134 QString = QString::null, QString = QString::null, 175 QString = QString::null, QString = QString::null,
135 QString = QString::null, QString = QString::null, 176 QString = QString::null, QString = QString::null,
136 QString = QString::null, QString = QString::null ); 177 QString = QString::null, QString = QString::null );
137 178
138 OListViewItem( QListViewItem * parent, 179 OListViewItem( QListViewItem * parent,
139 QString, QString = QString::null, 180 QString, QString = QString::null,
140 QString = QString::null, QString = QString::null, 181 QString = QString::null, QString = QString::null,
141 QString = QString::null, QString = QString::null, 182 QString = QString::null, QString = QString::null,
142 QString = QString::null, QString = QString::null ); 183 QString = QString::null, QString = QString::null );
143 184
144 OListViewItem( QListView * parent, QListViewItem * after, 185 OListViewItem( QListView * parent, QListViewItem * after,
145 QString, QString = QString::null, 186 QString, QString = QString::null,
146 QString = QString::null, QString = QString::null, 187 QString = QString::null, QString = QString::null,
147 QString = QString::null, QString = QString::null, 188 QString = QString::null, QString = QString::null,
148 QString = QString::null, QString = QString::null ); 189 QString = QString::null, QString = QString::null );
149 190
150 OListViewItem( QListViewItem * parent, QListViewItem * after, 191 OListViewItem( QListViewItem * parent, QListViewItem * after,
151 QString, QString = QString::null, 192 QString, QString = QString::null,
152 QString = QString::null, QString = QString::null, 193 QString = QString::null, QString = QString::null,
153 QString = QString::null, QString = QString::null, 194 QString = QString::null, QString = QString::null,
154 QString = QString::null, QString = QString::null ); 195 QString = QString::null, QString = QString::null );
155 196
156 virtual ~OListViewItem(); 197 virtual ~OListViewItem();
157 198
158 const QColor& backgroundColor(); 199 const QColor& backgroundColor();
159 bool isAlternate(); 200 bool isAlternate();
160 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); 201 void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );
161 void init(); 202 void init();
162 203
204 #ifndef QT_NO_DATASTREAM
205 /**
206 * serialize this object to or from a @ref QDataStream
207 * @param s the stream used to serialize this object.
208 */
209 virtual void serializeTo( QDataStream& s ) const;
210
211 /**
212 * serialize this object to or from a @ref QDataStream
213 * @param s the stream used to serialize this object.
214 */
215 virtual void serializeFrom( QDataStream& s );
216 #endif
217
163 private: 218 private:
164 bool m_known; 219 bool m_known;
165 bool m_odd; 220 bool m_odd;
166}; 221};
167 222
168#endif 223#ifndef QT_NO_DATASTREAM
224/**
225 * \relates QListViewItem
226 * Writes a listview item and all subitems recursively to the stream
227 * and returns a reference to the stream.
228 */
229QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi );
230/**
231 * \relates QListViewItem
232 * Reads a listview item from the stream and returns a reference to the stream.
233 */
234QDataStream& operator>>( QDataStream &s, OListViewItem& lvi );
235#endif // QT_NO_DATASTREAM
236
237#endif // OLISTVIEW_H
diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro
index 6037661..8861a50 100644
--- a/noncore/net/wellenreiter/gui/gui.pro
+++ b/noncore/net/wellenreiter/gui/gui.pro
@@ -1,49 +1,47 @@
1MOC_DIR = ./tmp 1MOC_DIR = ./tmp
2OBJECTS_DIR = ./tmp 2OBJECTS_DIR = ./tmp
3DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4TEMPLATE = app 4TEMPLATE = app
5CONFIG = qt warn_on debug 5CONFIG = qt warn_on debug
6 6
7HEADERS = wellenreiterbase.h \ 7HEADERS = wellenreiterbase.h \
8 mainwindow.h \ 8 mainwindow.h \
9 wellenreiter.h \ 9 wellenreiter.h \
10 scanlistitem.h \
11 scanlist.h \ 10 scanlist.h \
12 logwindow.h \ 11 logwindow.h \
13 hexwindow.h \ 12 hexwindow.h \
14 configwindow.h \ 13 configwindow.h \
15 wlan.h \ 14 wlan.h \
16 cardconfig.h \ 15 cardconfig.h \
17 manufacturers.h 16 manufacturers.h
18 17
19SOURCES = main.cpp \ 18SOURCES = main.cpp \
20 mainwindow.cpp \ 19 mainwindow.cpp \
21 wellenreiterbase.cpp \ 20 wellenreiterbase.cpp \
22 wellenreiter.cpp \ 21 wellenreiter.cpp \
23 scanlistitem.cpp \
24 scanlist.cpp \ 22 scanlist.cpp \
25 logwindow.cpp \ 23 logwindow.cpp \
26 hexwindow.cpp \ 24 hexwindow.cpp \
27 configwindow.cpp \ 25 configwindow.cpp \
28 wlan.cpp \ 26 wlan.cpp \
29 cardconfig.cpp \ 27 cardconfig.cpp \
30 manufacturers.cpp 28 manufacturers.cpp
31 29
32INCLUDEPATH += $(OPIEDIR)/include ../ 30INCLUDEPATH += $(OPIEDIR)/include ../
33DEPENDPATH += $(OPIEDIR)/include ../ 31DEPENDPATH += $(OPIEDIR)/include ../
34LIBS += -L. -lwellenreiter -lcornucopia 32LIBS += -L. -lwellenreiter -lcornucopia
35INTERFACES = configbase.ui 33INTERFACES = configbase.ui
36TARGET = wellenreiter 34TARGET = wellenreiter
37 35
38!contains( platform, x11 ) { 36!contains( platform, x11 ) {
39 message( qws ) 37 message( qws )
40 include ( $(OPIEDIR)/include.pro ) 38 include ( $(OPIEDIR)/include.pro )
41 LIBS += -lqpe -lopie 39 LIBS += -lqpe -lopie
42} 40}
43 41
44contains( platform, x11 ) { 42contains( platform, x11 ) {
45 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 43 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
46 SOURCES += resource.cpp 44 SOURCES += resource.cpp
47 HEADERS += resource.h 45 HEADERS += resource.h
48} 46}
49 47
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index e388fc5..0ef89d4 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -1,240 +1,266 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "configwindow.h" 16#include "configwindow.h"
17#include "logwindow.h" 17#include "logwindow.h"
18#include "mainwindow.h" 18#include "mainwindow.h"
19#include "wellenreiter.h" 19#include "wellenreiter.h"
20 20
21#include "scanlist.h" 21#include "scanlist.h"
22 22
23#include <qcombobox.h> 23#include <qcombobox.h>
24#include <qdatastream.h>
24#include <qfile.h> 25#include <qfile.h>
25#include <qiconset.h> 26#include <qiconset.h>
26#include <qmenubar.h> 27#include <qmenubar.h>
27#include <qmessagebox.h> 28#include <qmessagebox.h>
28#include <qpopupmenu.h> 29#include <qpopupmenu.h>
29#include <qstatusbar.h> 30#include <qstatusbar.h>
30#include <qtextstream.h> 31#include <qtextstream.h>
31#include <qtoolbutton.h> 32#include <qtoolbutton.h>
32 33
33#ifdef QWS 34#ifdef QWS
34#include <qpe/resource.h> 35#include <qpe/resource.h>
35#else 36#else
36#include "resource.h" 37#include "resource.h"
37#endif 38#endif
38 39
39WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) 40WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f )
40 :QMainWindow( parent, name, f ) 41 :QMainWindow( parent, name, f )
41{ 42{
42 cw = new WellenreiterConfigWindow( this ); 43 cw = new WellenreiterConfigWindow( this );
43 mw = new Wellenreiter( this ); 44 mw = new Wellenreiter( this );
44 mw->setConfigWindow( cw ); 45 mw->setConfigWindow( cw );
45 setCentralWidget( mw ); 46 setCentralWidget( mw );
46 47
48 // setup application icon
49
50 #ifndef QWS
51 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) );
52 setIconText( "Wellenreiter/X11" );
53 #endif
54
47 // setup icon sets 55 // setup icon sets
48 56
49 infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); 57 infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) );
50 settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); 58 settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) );
51 #ifdef QWS 59 #ifdef QWS
52 searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); 60 searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) );
53 cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); 61 cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) );
54 #else 62 #else
55 startStopIconSet = new QIconSet(); 63 startStopIconSet = new QIconSet();
56 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off ); 64 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off );
57 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On ); 65 startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On );
58 #endif 66 #endif
59 67
60 // setup tool buttons 68 // setup tool buttons
61 69
62 startStopButton = new QToolButton( 0 ); 70 startStopButton = new QToolButton( 0 );
63 #ifdef QWS 71 #ifdef QWS
64 startStopButton->setAutoRaise( true ); 72 startStopButton->setAutoRaise( true );
65 #endif 73 #endif
66 #ifdef QWS 74 #ifdef QWS
67 startStopButton->setOnIconSet( *cancelIconSet ); 75 startStopButton->setOnIconSet( *cancelIconSet );
68 startStopButton->setOffIconSet( *searchIconSet ); 76 startStopButton->setOffIconSet( *searchIconSet );
69 #else 77 #else
70 startStopButton->setIconSet( *startStopIconSet ); 78 startStopButton->setIconSet( *startStopIconSet );
71 #endif 79 #endif
72 startStopButton->setToggleButton( true ); 80 startStopButton->setToggleButton( true );
73 connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) ); 81 connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) );
74 startStopButton->setEnabled( false ); 82 startStopButton->setEnabled( false );
75 83
76 QToolButton* c = new QToolButton( 0 ); 84 QToolButton* c = new QToolButton( 0 );
77 #ifdef QWS 85 #ifdef QWS
78 c->setAutoRaise( true ); 86 c->setAutoRaise( true );
79 #endif 87 #endif
80 c->setIconSet( *infoIconSet ); 88 c->setIconSet( *infoIconSet );
81 c->setEnabled( false ); 89 c->setEnabled( false );
82 90
83 QToolButton* d = new QToolButton( 0 ); 91 QToolButton* d = new QToolButton( 0 );
84 #ifdef QWS 92 #ifdef QWS
85 d->setAutoRaise( true ); 93 d->setAutoRaise( true );
86 #endif 94 #endif
87 d->setIconSet( *settingsIconSet ); 95 d->setIconSet( *settingsIconSet );
88 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); 96 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) );
89 97
90 // setup menu bar 98 // setup menu bar
91 99
92 int id; 100 int id;
93 101
94 QMenuBar* mb = menuBar(); 102 QMenuBar* mb = menuBar();
95 103
96 QPopupMenu* fileSave = new QPopupMenu( mb ); 104 QPopupMenu* fileSave = new QPopupMenu( mb );
97 fileSave->insertItem( "&Session", this, SLOT( fileSaveSession() ) ); 105 fileSave->insertItem( "&Session", this, SLOT( fileSaveSession() ) );
98 fileSave->insertItem( "&Log", this, SLOT( fileSaveLog() ) ); 106 fileSave->insertItem( "&Log", this, SLOT( fileSaveLog() ) );
99 107
100 QPopupMenu* fileLoad = new QPopupMenu( mb ); 108 QPopupMenu* fileLoad = new QPopupMenu( mb );
101 fileLoad->insertItem( "&Session", this, SLOT( fileLoadSession() ) ); 109 fileLoad->insertItem( "&Session", this, SLOT( fileLoadSession() ) );
102 fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); 110 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) );
103 111
104 QPopupMenu* file = new QPopupMenu( mb ); 112 QPopupMenu* file = new QPopupMenu( mb );
105 id = file->insertItem( "&Load", fileLoad ); 113 id = file->insertItem( "&Load", fileLoad );
106 file->setItemEnabled( id, false );
107 file->insertItem( "&Save", fileSave ); 114 file->insertItem( "&Save", fileSave );
108 115
109 QPopupMenu* view = new QPopupMenu( mb ); 116 QPopupMenu* view = new QPopupMenu( mb );
110 view->insertItem( "&Configure..." ); 117 view->insertItem( "&Configure..." );
111 118
112 QPopupMenu* sniffer = new QPopupMenu( mb ); 119 QPopupMenu* sniffer = new QPopupMenu( mb );
113 sniffer->insertItem( "&Configure..." ); 120 sniffer->insertItem( "&Configure..." );
114 sniffer->insertSeparator(); 121 sniffer->insertSeparator();
115 122
116 QPopupMenu* demo = new QPopupMenu( mb ); 123 QPopupMenu* demo = new QPopupMenu( mb );
117 demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) ); 124 demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) );
118 125
119 id = mb->insertItem( "&File", file ); 126 id = mb->insertItem( "&File", file );
120 id = mb->insertItem( "&View", view ); 127 id = mb->insertItem( "&View", view );
121 mb->setItemEnabled( id, false ); 128 mb->setItemEnabled( id, false );
122 id = mb->insertItem( "&Sniffer", sniffer ); 129 id = mb->insertItem( "&Sniffer", sniffer );
123 mb->setItemEnabled( id, false ); 130 mb->setItemEnabled( id, false );
124 id = mb->insertItem( "&Demo", demo ); 131 id = mb->insertItem( "&Demo", demo );
125 mb->setItemEnabled( id, true ); 132 mb->setItemEnabled( id, true );
126 133
127 #ifdef QWS 134 #ifdef QWS
128 mb->insertItem( startStopButton ); 135 mb->insertItem( startStopButton );
129 mb->insertItem( c ); 136 mb->insertItem( c );
130 mb->insertItem( d ); 137 mb->insertItem( d );
131 #else // Qt3 changed the insertion order. It's now totally random :( 138 #else // Qt3 changed the insertion order. It's now totally random :(
132 mb->insertItem( d ); 139 mb->insertItem( d );
133 mb->insertItem( c ); 140 mb->insertItem( c );
134 mb->insertItem( startStopButton ); 141 mb->insertItem( startStopButton );
135 #endif 142 #endif
136 143
137 // setup status bar (for now only on X11) 144 // setup status bar (for now only on X11)
138 145
139 #ifndef QWS 146 #ifndef QWS
140 statusBar()->message( "Ready." ); 147 statusBar()->message( "Ready." );
141 #endif 148 #endif
142 149
143}; 150};
144 151
145void WellenreiterMainWindow::showConfigure() 152void WellenreiterMainWindow::showConfigure()
146{ 153{
147 qDebug( "show configure..." ); 154 qDebug( "show configure..." );
148 cw->setCaption( tr( "Configure" ) ); 155 cw->setCaption( tr( "Configure" ) );
149 #ifdef QWS 156 #ifdef QWS
150 cw->showMaximized(); 157 cw->showMaximized();
151 #endif 158 #endif
152 int result = cw->exec(); 159 int result = cw->exec();
153 160
154 if ( result ) 161 if ( result )
155 { 162 {
156 // check configuration from config window 163 // check configuration from config window
157 164
158 const QString& interface = cw->interfaceName->currentText(); 165 const QString& interface = cw->interfaceName->currentText();
159 const int cardtype = cw->daemonDeviceType(); 166 const int cardtype = cw->daemonDeviceType();
160 const int interval = cw->daemonHopInterval(); 167 const int interval = cw->daemonHopInterval();
161 168
162 if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) 169 if ( ( interface != "<select>" ) && ( cardtype != 0 ) )
163 startStopButton->setEnabled( true ); 170 startStopButton->setEnabled( true );
164 //TODO ... 171 //TODO ...
165 else 172 else
166 startStopButton->setEnabled( false ); 173 startStopButton->setEnabled( false );
167 //TODO ... 174 //TODO ...
168 } 175 }
169} 176}
170 177
171WellenreiterMainWindow::~WellenreiterMainWindow() 178WellenreiterMainWindow::~WellenreiterMainWindow()
172{ 179{
173 180
174 delete infoIconSet; 181 delete infoIconSet;
175 delete settingsIconSet; 182 delete settingsIconSet;
176 #ifdef QWS 183 #ifdef QWS
177 delete searchIconSet; 184 delete searchIconSet;
178 delete cancelIconSet; 185 delete cancelIconSet;
179 #else 186 #else
180 delete startStopIconSet; 187 delete startStopIconSet;
181 #endif 188 #endif
182 189
183}; 190};
184 191
185void WellenreiterMainWindow::demoAddStations() 192void WellenreiterMainWindow::demoAddStations()
186{ 193{
187 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); 194 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 );
188 mw->netView()->addNewItem( "managed", "Vanille", "00:00:1c:EF:A6:23", true, 11, 10 ); 195 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 );
189 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); 196 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 );
190 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); 197 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 );
191 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 ); 198 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 );
192} 199}
193 200
194void WellenreiterMainWindow::fileSaveLog() 201void WellenreiterMainWindow::fileSaveLog()
195{ 202{
196 const QString fname( "/tmp/log.txt" ); 203 const QString fname( "/tmp/log.txt" );
197 QFile f( fname ); 204 QFile f( fname );
198 if ( f.open(IO_WriteOnly) ) 205 if ( f.open(IO_WriteOnly) )
199 { 206 {
200 QTextStream t( &f ); 207 QTextStream t( &f );
201 t << mw->logWindow()->getLog(); 208 t << mw->logWindow()->getLog();
202 f.close(); 209 f.close();
203 qDebug( "Saved log to file '%s'", (const char*) fname ); 210 qDebug( "Saved log to file '%s'", (const char*) fname );
204 } 211 }
205 else 212 else
206 { 213 {
207 qDebug( "Problem saving log to file '%s'", (const char*) fname ); 214 qDebug( "Problem saving log to file '%s'", (const char*) fname );
208 } 215 }
209 216
210} 217}
211 218
212void WellenreiterMainWindow::fileSaveSession() 219void WellenreiterMainWindow::fileSaveSession()
213{ 220{
214 const QString fname( "/tmp/session.xml" ); 221 const QString fname( "/tmp/session.xml" );
215 QFile f( fname ); 222 QFile f( fname );
216 if ( f.open(IO_WriteOnly) ) 223 if ( f.open(IO_WriteOnly) )
217 { 224 {
218 QTextStream t( &f ); 225 QDataStream t( &f );
219 mw->netView()->dump( t ); 226 t << *mw->netView();
220 f.close(); 227 f.close();
221 qDebug( "Saved session to file '%s'", (const char*) fname ); 228 qDebug( "Saved session to file '%s'", (const char*) fname );
222 } 229 }
223 else 230 else
224 { 231 {
225 qDebug( "Problem saving session to file '%s'", (const char*) fname ); 232 qDebug( "Problem saving session to file '%s'", (const char*) fname );
226 } 233 }
227} 234}
228 235
236void WellenreiterMainWindow::fileLoadSession()
237{
238 const QString fname( "/tmp/session.xml" );
239 QFile f( fname );
240
241 if ( f.open(IO_ReadOnly) )
242 {
243 QDataStream t( &f );
244 t >> *mw->netView();
245 f.close();
246 qDebug( "Loaded session from file '%s'", (const char*) fname );
247 }
248 else
249 {
250 qDebug( "Problem loading session from file '%s'", (const char*) fname );
251 }
252
253}
254
229void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) 255void WellenreiterMainWindow::closeEvent( QCloseEvent* e )
230{ 256{
231 if ( mw->isDaemonRunning() ) 257 if ( mw->isDaemonRunning() )
232 { 258 {
233 QMessageBox::warning( this, "Wellenreiter/Opie", "Sniffing in progress!\nPlease stop sniffing before closing." ); 259 QMessageBox::warning( this, "Wellenreiter/Opie", "Sniffing in progress!\nPlease stop sniffing before closing." );
234 e->ignore(); 260 e->ignore();
235 } 261 }
236 else 262 else
237 { 263 {
238 QMainWindow::closeEvent( e ); 264 QMainWindow::closeEvent( e );
239 } 265 }
240} 266}
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h
index 8bfccf3..59f259d 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.h
+++ b/noncore/net/wellenreiter/gui/mainwindow.h
@@ -1,56 +1,57 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef MAINWINDOW_H 16#ifndef MAINWINDOW_H
17#define MAINWINDOW_H 17#define MAINWINDOW_H
18 18
19#include <qmainwindow.h> 19#include <qmainwindow.h>
20 20
21class Wellenreiter; 21class Wellenreiter;
22class WellenreiterConfigWindow; 22class WellenreiterConfigWindow;
23class QIconSet; 23class QIconSet;
24class QToolButton; 24class QToolButton;
25 25
26class WellenreiterMainWindow: public QMainWindow 26class WellenreiterMainWindow: public QMainWindow
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30 public: 30 public:
31 WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); 31 WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 );
32 ~WellenreiterMainWindow(); 32 ~WellenreiterMainWindow();
33 33
34 protected: 34 protected:
35 Wellenreiter* mw; 35 Wellenreiter* mw;
36 WellenreiterConfigWindow* cw; 36 WellenreiterConfigWindow* cw;
37 37
38 QIconSet* startStopIconSet; 38 QIconSet* startStopIconSet;
39 const QIconSet* searchIconSet; 39 const QIconSet* searchIconSet;
40 const QIconSet* infoIconSet; 40 const QIconSet* infoIconSet;
41 const QIconSet* settingsIconSet; 41 const QIconSet* settingsIconSet;
42 const QIconSet* cancelIconSet; 42 const QIconSet* cancelIconSet;
43 43
44 QToolButton* startStopButton; 44 QToolButton* startStopButton;
45 45
46 protected: 46 protected:
47 virtual void closeEvent( QCloseEvent* ); 47 virtual void closeEvent( QCloseEvent* );
48 48
49 public slots: 49 public slots:
50 void showConfigure(); 50 void showConfigure();
51 void demoAddStations(); 51 void demoAddStations();
52 void fileSaveLog(); 52 void fileSaveLog();
53 void fileSaveSession(); 53 void fileSaveSession();
54 void fileLoadSession();
54}; 55};
55 56
56#endif 57#endif
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index cdc2c48..58a04fb 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -1,167 +1,263 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "scanlist.h" 16#include "scanlist.h"
17#include "scanlistitem.h"
18 17
19#include <assert.h> 18#include <assert.h>
20
21#include "manufacturers.h" 19#include "manufacturers.h"
22 20#include <qdatetime.h>
23#include <qtextstream.h> 21#include <qtextstream.h>
24 22
25MScanListView::MScanListView( QWidget* parent, const char* name ) 23MScanListView::MScanListView( QWidget* parent, const char* name )
26 :OListView( parent, name ), _manufacturerdb( 0 ) 24 :OListView( parent, name ), _manufacturerdb( 0 )
27{ 25{
28 26
29 setFrameShape( QListView::StyledPanel ); 27 setFrameShape( QListView::StyledPanel );
30 setFrameShadow( QListView::Sunken ); 28 setFrameShadow( QListView::Sunken );
31 29
32 addColumn( tr( "Net/Station" ) ); 30 addColumn( tr( "Net/Station" ) );
33 setColumnAlignment( 0, AlignLeft || AlignVCenter ); 31 setColumnAlignment( 0, AlignLeft || AlignVCenter );
34 addColumn( tr( "B" ) ); 32 addColumn( tr( "B" ) );
35 setColumnAlignment( 1, AlignCenter ); 33 setColumnAlignment( 1, AlignCenter );
36 addColumn( tr( "AP" ) ); 34 addColumn( tr( "AP" ) );
37 setColumnAlignment( 2, AlignCenter ); 35 setColumnAlignment( 2, AlignCenter );
38 addColumn( tr( "Chn" ) ); 36 addColumn( tr( "Chn" ) );
39 setColumnAlignment( 3, AlignCenter ); 37 setColumnAlignment( 3, AlignCenter );
40 addColumn( tr( "W" ) ); 38 addColumn( tr( "W" ) );
41 setColumnAlignment( 4, AlignCenter ); 39 setColumnAlignment( 4, AlignCenter );
42 addColumn( tr( "T" ) ); 40 addColumn( tr( "T" ) );
43 setColumnAlignment( 5, AlignCenter ); 41 setColumnAlignment( 5, AlignCenter );
44 addColumn( tr( "Manufacturer" ) ); 42 addColumn( tr( "Manufacturer" ) );
45 setColumnAlignment( 6, AlignCenter ); 43 setColumnAlignment( 6, AlignCenter );
46 addColumn( tr( "First Seen" ) ); 44 addColumn( tr( "First Seen" ) );
47 setColumnAlignment( 7, AlignCenter ); 45 setColumnAlignment( 7, AlignCenter );
48 addColumn( tr( "Last Seen" ) ); 46 addColumn( tr( "Last Seen" ) );
49 setColumnAlignment( 8, AlignCenter ); 47 setColumnAlignment( 8, AlignCenter );
50 setRootIsDecorated( true ); 48 setRootIsDecorated( true );
51 setAllColumnsShowFocus( true ); 49 setAllColumnsShowFocus( true );
52}; 50};
53 51
54MScanListView::~MScanListView() 52MScanListView::~MScanListView()
55{ 53{
56}; 54};
57 55
56void MScanListView::serializeTo( QDataStream& s) const
57{
58 qDebug( "serializing MScanListView" );
59 OListView::serializeTo( s );
60}
61
62void MScanListView::serializeFrom( QDataStream& s)
63{
64 qDebug( "serializing MScanListView" );
65 OListView::serializeFrom( s );
66}
67
58void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) 68void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb )
59{ 69{
60 _manufacturerdb = manufacturerdb; 70 _manufacturerdb = manufacturerdb;
61} 71}
62 72
63void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 73void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
64{ 74{
65 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) 75 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...)
66 76
67 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", 77 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]",
68 (const char*) type, 78 (const char*) type,
69 (const char*) essid, 79 (const char*) essid,
70 (const char*) macaddr, 80 (const char*) macaddr,
71 channel ); 81 channel );
72 82
73 // search, if we already have seen this net 83 // search, if we already have seen this net
74 84
75 QString s; 85 QString s;
76 MScanListItem* network; 86 MScanListItem* network;
77 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 87 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
78 88
79 while ( item && ( item->text( 0 ) != essid ) ) 89 while ( item && ( item->text( 0 ) != essid ) )
80 { 90 {
81 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 91 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
82 item = static_cast<MScanListItem*> ( item->itemBelow() ); 92 item = static_cast<MScanListItem*> ( item->itemBelow() );
83 } 93 }
84 if ( item ) 94 if ( item )
85 { 95 {
86 // animate the item 96 // animate the item
87 97
88 /* 98 /*
89 99
90 const QPixmap* pixmap = item->pixmap( 0 ); 100 const QPixmap* pixmap = item->pixmap( 0 );
91 const QPixmap* nextpixmap = ani2; 101 const QPixmap* nextpixmap = ani2;
92 if ( pixmap == ani1 ) 102 if ( pixmap == ani1 )
93 nextpixmap = ani2; 103 nextpixmap = ani2;
94 else if ( pixmap == ani2 ) 104 else if ( pixmap == ani2 )
95 nextpixmap = ani3; 105 nextpixmap = ani3;
96 else if ( pixmap == ani3 ) 106 else if ( pixmap == ani3 )
97 nextpixmap = ani4; 107 nextpixmap = ani4;
98 else if ( pixmap == ani4 ) 108 else if ( pixmap == ani4 )
99 nextpixmap = ani1; 109 nextpixmap = ani1;
100 item->setPixmap( 0, *nextpixmap ); */ 110 item->setPixmap( 0, *nextpixmap ); */
101 111
102 //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); 112 //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap );
103 113
104 // we have already seen this net, check all childs if MAC exists 114 // we have already seen this net, check all childs if MAC exists
105 115
106 network = item; 116 network = item;
107 117
108 item = static_cast<MScanListItem*> ( item->firstChild() ); 118 item = static_cast<MScanListItem*> ( item->firstChild() );
109 assert( item ); // this shouldn't fail 119 assert( item ); // this shouldn't fail
110 120
111 while ( item && ( item->text( 2 ) != macaddr ) ) 121 while ( item && ( item->text( 2 ) != macaddr ) )
112 { 122 {
113 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); 123 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
114 item = static_cast<MScanListItem*> ( item->itemBelow() ); 124 item = static_cast<MScanListItem*> ( item->itemBelow() );
115 } 125 }
116 126
117 if ( item ) 127 if ( item )
118 { 128 {
119 // we have already seen this item, it's a dupe 129 // we have already seen this item, it's a dupe
120 #ifdef DEBUG 130 #ifdef DEBUG
121 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 131 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
122 #endif 132 #endif
123 item->receivedBeacon(); 133 item->receivedBeacon();
124 return; 134 return;
125 } 135 }
126 } 136 }
127 else 137 else
128 { 138 {
129 s.sprintf( "(i) new network: '%s'", (const char*) essid ); 139 s.sprintf( "(i) new network: '%s'", (const char*) essid );
130 140
131 network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); 141 network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 );
132 } 142 }
133 143
134 144
135 // insert new station as child from network 145 // insert new station as child from network
136 146
137 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 147 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
138 148
139 qDebug( "inserting new station %s", (const char*) macaddr ); 149 qDebug( "inserting new station %s", (const char*) macaddr );
140 150
141 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 151 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
142 if ( _manufacturerdb ) 152 if ( _manufacturerdb )
143 station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); 153 station->setManufacturer( _manufacturerdb->lookup( macaddr ) );
144 154
145 if ( type == "managed" ) 155 if ( type == "managed" )
146 { 156 {
147 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); 157 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel );
148 } 158 }
149 else 159 else
150 { 160 {
151 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); 161 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel );
152 } 162 }
153 163
154} 164}
155 165
156void MScanListView::dump( QTextStream& t ) const 166#ifdef QWS
167#include <qpe/resource.h>
168#else
169#include "resource.h"
170#endif
171
172const int col_type = 0;
173const int col_essid = 0;
174const int col_sig = 1;
175const int col_ap = 2;
176const int col_channel = 3;
177const int col_wep = 4;
178const int col_traffic = 5;
179const int col_manuf = 6;
180const int col_firstseen = 7;
181const int col_lastseen = 8;
182
183MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
184 bool wep, int channel, int signal )
185 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
186 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
187 _channel( channel ), _signal( signal ), _beacons( 0 )
157{ 188{
158 qDebug( "dumping scanlist..." ); 189 qDebug( "creating scanlist item" );
190 decorateItem( type, essid, macaddr, wep, channel, signal );
191}
159 192
160 QListViewItemIterator it( const_cast<MScanListView*>( this ) ); 193MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
161 for ( ; it.current(); ++it ) 194 bool wep, int channel, int signal )
162 { 195 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
163 static_cast<MScanListItem*>( it.current() )->dump( t ); 196{
164 } 197 qDebug( "creating scanlist item" );
198 decorateItem( type, essid, macaddr, wep, channel, signal );
199}
165 200
166 qDebug( "dump finished." ); 201void MScanListItem::serializeTo( QDataStream& s ) const
202{
203 OListViewItem::serializeTo( s );
204}
205
206void MScanListItem::serializeFrom( QDataStream& s )
207{
208 OListViewItem::serializeFrom( s );
167} 209}
210
211void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
212{
213 qDebug( "decorating scanlist item %s / %s / %s [%d]",
214 (const char*) type,
215 (const char*) essid,
216 (const char*) macaddr,
217 channel );
218
219 // set icon for managed or adhoc mode
220 QString name;
221 name.sprintf( "wellenreiter/%s", (const char*) type );
222 setPixmap( col_type, Resource::loadPixmap( name ) );
223
224 // set icon for wep (wireless encryption protocol)
225 if ( wep )
226 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
227
228 // set channel and signal text
229
230 if ( signal != -1 )
231 setText( col_sig, QString::number( signal ) );
232 if ( channel != -1 )
233 setText( col_channel, QString::number( channel ) );
234
235 setText( col_firstseen, QTime::currentTime().toString() );
236 //setText( col_lastseen, QTime::currentTime().toString() );
237
238 listView()->triggerUpdate();
239
240 this->type = type;
241 _type = type;
242 _essid = essid;
243 _macaddr = macaddr;
244 _channel = channel;
245 _beacons = 0;
246 _signal = 0;
247}
248
249void MScanListItem::setManufacturer( const QString& manufacturer )
250{
251 setText( col_manuf, manufacturer );
252}
253
254void MScanListItem::receivedBeacon()
255{
256 _beacons++;
257 #ifdef DEBUG
258 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
259 #endif
260 setText( col_sig, QString::number( _beacons ) );
261 setText( col_lastseen, QTime::currentTime().toString() );
262}
263
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index f06f251..66c701b 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -1,46 +1,119 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef SCANLIST_H 16#ifndef SCANLIST_H
17#define SCANLIST_H 17#define SCANLIST_H
18 18
19#include <cornucopia/olistview.h> 19#include <cornucopia/olistview.h>
20 20
21#include <qtextstream.h> 21#include <qtextstream.h>
22 22
23class QString; 23class QString;
24class ManufacturerDB; 24class ManufacturerDB;
25 25
26class MScanListView: public OListView 26class MScanListView: public OListView
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30 public: 30 public:
31 MScanListView( QWidget* parent = 0, const char* name = 0 ); 31 MScanListView( QWidget* parent = 0, const char* name = 0 );
32 virtual ~MScanListView(); 32 virtual ~MScanListView();
33 33
34 void setManufacturerDB( ManufacturerDB* manufacturerdb ); 34 void setManufacturerDB( ManufacturerDB* manufacturerdb );
35 void dump( QTextStream& t ) const; 35
36 virtual void serializeTo( QDataStream& s ) const;
37 virtual void serializeFrom( QDataStream& s );
36 38
37 public slots: 39 public slots:
38 void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 40 void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
39 41
40 private: 42 private:
41 ManufacturerDB* _manufacturerdb; 43 ManufacturerDB* _manufacturerdb;
42 44
43}; 45};
44 46
47//****************************** MScanListItem ****************************************************************
48
49class MScanListItem: public OListViewItem
50{
51 public:
52 MScanListItem::MScanListItem( QListView* parent,
53 QString type,
54 QString essid,
55 QString macaddr,
56 bool wep,
57 int channel,
58 int signal );
59
60 MScanListItem::MScanListItem( QListViewItem* parent,
61 QString type,
62 QString essid,
63 QString macaddr,
64 bool wep,
65 int channel,
66 int signal );
67
68
69 protected:
70 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
71
72 public:
73 QString type;
74
75 public:
76 //const QString& type() { return _type; };
77 const QString& essid() { return _essid; };
78 const QString& macaddr() { return _macaddr; };
79 bool wep() { return _wep; };
80 int channel() { return _channel; };
81 int signal() { return _signal; };
82 int beacons() { return _beacons; };
83
84 void setSignal( int signal ) { /* TODO */ };
85 void receivedBeacon();
86
87 void setManufacturer( const QString& manufacturer );
88
89 virtual void serializeTo( QDataStream& s ) const;
90 virtual void serializeFrom( QDataStream& s );
91
92 private:
93 QString _type;
94 QString _essid;
95 QString _macaddr;
96 bool _wep;
97 int _channel;
98 int _signal;
99 int _beacons;
100
101};
102
103//****************************** MScanListViewFactory ****************************************************************
104
105/*
106
107class MScanListViewFactory : public OListViewFactory
108{
109public:
110 virtual QListView* listViewFactory();
111 virtual QListViewItem* listViewItemFactory( QListView* lv );
112 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi );
113 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text );
114 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text );
115}
116*/
117
45#endif 118#endif
46 119
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp
deleted file mode 100644
index 4aecd2b..0000000
--- a/noncore/net/wellenreiter/gui/scanlistitem.cpp
+++ b/dev/null
@@ -1,121 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3**
4** This file is part of Opie Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#include "scanlistitem.h"
17#include <assert.h>
18#include <qdatetime.h>
19#include <qpixmap.h>
20
21#ifdef QWS
22#include <qpe/resource.h>
23#else
24#include "resource.h"
25#endif
26
27const int col_type = 0;
28const int col_essid = 0;
29const int col_sig = 1;
30const int col_ap = 2;
31const int col_channel = 3;
32const int col_wep = 4;
33const int col_traffic = 5;
34const int col_manuf = 6;
35const int col_firstseen = 7;
36const int col_lastseen = 8;
37
38MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
39 bool wep, int channel, int signal )
40 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
41 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
42 _channel( channel ), _signal( signal ), _beacons( 0 )
43{
44 qDebug( "creating scanlist item" );
45 decorateItem( type, essid, macaddr, wep, channel, signal );
46}
47
48MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
49 bool wep, int channel, int signal )
50 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
51{
52 qDebug( "creating scanlist item" );
53 decorateItem( type, essid, macaddr, wep, channel, signal );
54}
55
56void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
57{
58 qDebug( "decorating scanlist item %s / %s / %s [%d]",
59 (const char*) type,
60 (const char*) essid,
61 (const char*) macaddr,
62 channel );
63
64 // set icon for managed or adhoc mode
65 QString name;
66 name.sprintf( "wellenreiter/%s", (const char*) type );
67 setPixmap( col_type, Resource::loadPixmap( name ) );
68
69 // set icon for wep (wireless encryption protocol)
70 if ( wep )
71 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
72
73 // set channel and signal text
74
75 if ( signal != -1 )
76 setText( col_sig, QString::number( signal ) );
77 if ( channel != -1 )
78 setText( col_channel, QString::number( channel ) );
79
80 setText( col_firstseen, QTime::currentTime().toString() );
81 //setText( col_lastseen, QTime::currentTime().toString() );
82
83 listView()->triggerUpdate();
84
85 this->type = type;
86 _type = type;
87 _essid = essid;
88 _macaddr = macaddr;
89 _channel = channel;
90 _beacons = 0;
91 _signal = 0;
92}
93
94void MScanListItem::setManufacturer( const QString& manufacturer )
95{
96 setText( col_manuf, manufacturer );
97}
98
99void MScanListItem::receivedBeacon()
100{
101 _beacons++;
102 #ifdef DEBUG
103 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
104 #endif
105 setText( col_sig, QString::number( _beacons ) );
106 setText( col_lastseen, QTime::currentTime().toString() );
107}
108
109void MScanListItem::dump( QTextStream& t ) const
110{
111 qDebug( "dumping scanlistitem at <%d>", this );
112 t << "<ITEM type=" << _type;
113 t << " ESSID='" << _essid;
114 t << "' MAC=" << _macaddr;
115 t << " WEP=" << _wep;
116 t << " CHANNEL=" << _channel;
117 t << " SIGNAL=" << _signal;
118 t << " BEACONS=" << _beacons;
119 t << ">\n";
120}
121
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.h b/noncore/net/wellenreiter/gui/scanlistitem.h
deleted file mode 100644
index 5f6ae40..0000000
--- a/noncore/net/wellenreiter/gui/scanlistitem.h
+++ b/dev/null
@@ -1,83 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3**
4** This file is part of Opie Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#ifndef SCANLISTITEM_H
17#define SCANLISTITEM_H
18
19#include <cornucopia/olistview.h>
20
21#include <qtextstream.h>
22
23class QString;
24
25class MScanListItem: public OListViewItem
26{
27 public:
28
29 MScanListItem::MScanListItem( QListView* parent,
30 QString type,
31 QString essid,
32 QString macaddr,
33 bool wep,
34 int channel,
35 int signal );
36
37 MScanListItem::MScanListItem( QListViewItem* parent,
38 QString type,
39 QString essid,
40 QString macaddr,
41 bool wep,
42 int channel,
43 int signal );
44
45
46 protected:
47
48 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
49
50 public:
51
52 QString type;
53
54 public:
55
56 //const QString& type() { return _type; };
57 const QString& essid() { return _essid; };
58 const QString& macaddr() { return _macaddr; };
59 bool wep() { return _wep; };
60 int channel() { return _channel; };
61 int signal() { return _signal; };
62 int beacons() { return _beacons; };
63
64 void setSignal( int signal ) { /* TODO */ };
65 void receivedBeacon();
66
67 void setManufacturer( const QString& manufacturer );
68
69 void dump( QTextStream& t ) const;
70
71 private:
72 QString _type;
73 QString _essid;
74 QString _macaddr;
75 bool _wep;
76 int _channel;
77 int _signal;
78 int _beacons;
79
80};
81
82#endif
83
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 1ccf971..dd8a365 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -30,197 +30,205 @@
30 30
31// Opie 31// Opie
32 32
33#ifdef QWS 33#ifdef QWS
34#include <opie/odevice.h> 34#include <opie/odevice.h>
35using namespace Opie; 35using namespace Opie;
36#endif 36#endif
37 37
38// Standard 38// Standard
39 39
40#include <assert.h> 40#include <assert.h>
41#include <errno.h> 41#include <errno.h>
42#include <unistd.h> 42#include <unistd.h>
43#include <string.h> 43#include <string.h>
44#include <sys/types.h> 44#include <sys/types.h>
45#include <sys/socket.h> 45#include <sys/socket.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <fcntl.h> 47#include <fcntl.h>
48 48
49// Local 49// Local
50 50
51#include "wellenreiter.h" 51#include "wellenreiter.h"
52#include "scanlist.h" 52#include "scanlist.h"
53#include "logwindow.h" 53#include "logwindow.h"
54#include "hexwindow.h" 54#include "hexwindow.h"
55#include "configwindow.h" 55#include "configwindow.h"
56 56
57#include "manufacturers.h" 57#include "manufacturers.h"
58 58
59#include <daemon/source/config.hh> 59#include <daemon/source/config.hh>
60#include <libwellenreiter/source/wl_types.hh> 60#include <libwellenreiter/source/wl_types.hh>
61#include <libwellenreiter/source/wl_sock.hh> 61#include <libwellenreiter/source/wl_sock.hh>
62#include <libwellenreiter/source/wl_proto.hh> 62#include <libwellenreiter/source/wl_proto.hh>
63 63
64Wellenreiter::Wellenreiter( QWidget* parent ) 64Wellenreiter::Wellenreiter( QWidget* parent )
65 : WellenreiterBase( parent, 0, 0 ), 65 : WellenreiterBase( parent, 0, 0 ),
66 daemonRunning( false ), manufacturerdb( 0 ), configwindow( 0 ) 66 daemonRunning( false ), manufacturerdb( 0 ), configwindow( 0 )
67{ 67{
68 68
69 // 69 //
70 // construct manufacturer database 70 // construct manufacturer database
71 // 71 //
72 72
73 QString manufile; 73 QString manufile;
74 #ifdef QWS 74 #ifdef QWS
75 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); 75 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() );
76 #else 76 #else
77 manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); 77 manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" );
78 #endif 78 #endif
79 manufacturerdb = new ManufacturerDB( manufile ); 79 manufacturerdb = new ManufacturerDB( manufile );
80 80
81 logwindow->log( "(i) Wellenreiter has been started." ); 81 logwindow->log( "(i) Wellenreiter has been started." );
82 82
83 // 83 //
84 // detect operating system 84 // detect operating system
85 // 85 //
86 86
87 #ifdef QWS 87 #ifdef QWS
88 QString sys; 88 QString sys;
89 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 89 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
90 _system = ODevice::inst()->system(); 90 _system = ODevice::inst()->system();
91 logwindow->log( sys ); 91 logwindow->log( sys );
92 #endif 92 #endif
93 93
94 // 94 //
95 // setup socket for daemon communication, register socket notifier 95 // setup socket for daemon communication, register socket notifier
96 // 96 //
97 97
98 // struct sockaddr_in sockaddr; 98 // struct sockaddr_in sockaddr;
99 daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr ); 99 daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr );
100 if ( daemon_fd == -1 ) 100 if ( daemon_fd == -1 )
101 { 101 {
102 logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); 102 logwindow->log( "(E) Couldn't get file descriptor for commsocket." );
103 } 103 }
104 else 104 else
105 { 105 {
106 int flags; 106 int flags;
107 flags = fcntl( daemon_fd, F_GETFL, 0 ); 107 flags = fcntl( daemon_fd, F_GETFL, 0 );
108 fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); 108 fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK );
109 QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, parent ); 109 QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, parent );
110 connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); 110 connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) );
111 } 111 }
112 112
113 // setup GUI 113 // setup GUI
114 netview->setColumnWidthMode( 1, QListView::Manual ); 114 netview->setColumnWidthMode( 1, QListView::Manual );
115 115
116 if ( manufacturerdb ) 116 if ( manufacturerdb )
117 netview->setManufacturerDB( manufacturerdb ); 117 netview->setManufacturerDB( manufacturerdb );
118 118
119} 119}
120 120
121Wellenreiter::~Wellenreiter() 121Wellenreiter::~Wellenreiter()
122{ 122{
123 // no need to delete child widgets, Qt does it all for us 123 // no need to delete child widgets, Qt does it all for us
124 124
125 delete manufacturerdb; 125 delete manufacturerdb;
126
127 // X11-only - Hmm... Closing the socket here segfaults on exit,
128 // Maybe because the notifier still has a handle to it!? Seems not to
129 // occur on Qt/Embedded
130
131 #ifdef QWS
126 if ( daemon_fd != -1 ) 132 if ( daemon_fd != -1 )
127 { 133 {
128 qDebug( "closing comm socket" ); 134 qDebug( "closing comm socket" );
129 close( daemon_fd ); 135 close( daemon_fd );
130 } 136 }
137 #endif
138
131} 139}
132 140
133void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 141void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
134{ 142{
135 configwindow = cw; 143 configwindow = cw;
136} 144}
137 145
138void Wellenreiter::handleMessage() 146void Wellenreiter::handleMessage()
139{ 147{
140 // FIXME: receive message and handle it 148 // FIXME: receive message and handle it
141 149
142 qDebug( "received message from daemon." ); 150 qDebug( "received message from daemon." );
143 151
144 /*char buffer[10000]; 152 /*char buffer[10000];
145 memset( &buffer, 0, sizeof( buffer ) );*/ 153 memset( &buffer, 0, sizeof( buffer ) );*/
146 154
147 char buffer[WL_SOCKBUF]; 155 char buffer[WL_SOCKBUF];
148 156
149 // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); 157 // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) );
150 158
151 /* 159 /*
152 160
153 struct sockaddr from; 161 struct sockaddr from;
154 socklen_t len; 162 socklen_t len;
155 163
156 int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); 164 int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len );
157 qDebug( "received %d from recv [%d bytes]", result, len ); 165 qDebug( "received %d from recv [%d bytes]", result, len );
158 166
159 */ 167 */
160 168
161 int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF ); 169 int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF );
162 170
163 if ( result == -1 ) 171 if ( result == -1 )
164 { 172 {
165 qDebug( "Warning: %s", strerror( errno ) ); 173 qDebug( "Warning: %s", strerror( errno ) );
166 return; 174 return;
167 } 175 }
168 176
169 int command = buffer[1] - 48; 177 int command = buffer[1] - 48;
170 178
171/* 179/*
172typedef struct { 180typedef struct {
173 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc 181 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc
174 int ssid_len; Length of SSID 182 int ssid_len; Length of SSID
175 int channel; Channel 183 int channel; Channel
176 int wep; 1 = WEP enabled ; 0 = disabled 184 int wep; 1 = WEP enabled ; 0 = disabled
177 char mac[64]; MAC address of Accesspoint 185 char mac[64]; MAC address of Accesspoint
178 char bssid[128]; BSSID of Accesspoint 186 char bssid[128]; BSSID of Accesspoint
179} wl_network_t; 187} wl_network_t;
180*/ 188*/
181 189
182 qDebug( "Recv result: %d", ( result ) ); 190 qDebug( "Recv result: %d", ( result ) );
183 qDebug( "Sniffer sent: '%s'", (const char*) buffer ); 191 qDebug( "Sniffer sent: '%s'", (const char*) buffer );
184 hexwindow->log( (const char*) &buffer ); 192 hexwindow->log( (const char*) &buffer );
185 193
186 if ( command == NETFOUND ) /* new network found */ 194 if ( command == NETFOUND ) /* new network found */
187 { 195 {
188 qDebug( "Sniffer said: new network found." ); 196 qDebug( "Sniffer said: new network found." );
189 wl_network_t n; 197 wl_network_t n;
190 get_network_found( &n, (char*) &buffer ); 198 get_network_found( &n, (char*) &buffer );
191 199
192 qDebug( "Sniffer said: net_type is %d.", n.net_type ); 200 qDebug( "Sniffer said: net_type is %d.", n.net_type );
193 qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); 201 qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac );
194 202
195 //n.bssid[n.ssid_len] = "\0"; 203 //n.bssid[n.ssid_len] = "\0";
196 204
197 QString type; 205 QString type;
198 206
199 if ( n.net_type == 1 ) 207 if ( n.net_type == 1 )
200 type = "managed"; 208 type = "managed";
201 else 209 else
202 type = "adhoc"; 210 type = "adhoc";
203 211
204 netview->addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); 212 netview->addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 );
205 213
206 } 214 }
207 215
208 else 216 else
209 217
210 { 218 {
211 qDebug( "unknown sniffer command." ); 219 qDebug( "unknown sniffer command." );
212 } 220 }
213 221
214} 222}
215 223
216void Wellenreiter::dataReceived() 224void Wellenreiter::dataReceived()
217{ 225{
218 logwindow->log( "(d) Received data from daemon" ); 226 logwindow->log( "(d) Received data from daemon" );
219 handleMessage(); 227 handleMessage();
220} 228}
221 229
222void Wellenreiter::startStopClicked() 230void Wellenreiter::startStopClicked()
223{ 231{
224 if ( daemonRunning ) 232 if ( daemonRunning )
225 { 233 {
226 daemonRunning = false; 234 daemonRunning = false;