Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 114 |
1 files changed, 105 insertions, 9 deletions
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 | |||
@@ -16,8 +16,6 @@ | |||
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> |
@@ -57,2 +55,14 @@ MScanListView::~MScanListView() | |||
57 | 55 | ||
56 | void MScanListView::serializeTo( QDataStream& s) const | ||
57 | { | ||
58 | qDebug( "serializing MScanListView" ); | ||
59 | OListView::serializeTo( s ); | ||
60 | } | ||
61 | |||
62 | void MScanListView::serializeFrom( QDataStream& s) | ||
63 | { | ||
64 | qDebug( "serializing MScanListView" ); | ||
65 | OListView::serializeFrom( s ); | ||
66 | } | ||
67 | |||
58 | void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) | 68 | void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) |
@@ -155,13 +165,99 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo | |||
155 | 165 | ||
156 | void MScanListView::dump( QTextStream& t ) const | 166 | #ifdef QWS |
167 | #include <qpe/resource.h> | ||
168 | #else | ||
169 | #include "resource.h" | ||
170 | #endif | ||
171 | |||
172 | const int col_type = 0; | ||
173 | const int col_essid = 0; | ||
174 | const int col_sig = 1; | ||
175 | const int col_ap = 2; | ||
176 | const int col_channel = 3; | ||
177 | const int col_wep = 4; | ||
178 | const int col_traffic = 5; | ||
179 | const int col_manuf = 6; | ||
180 | const int col_firstseen = 7; | ||
181 | const int col_lastseen = 8; | ||
182 | |||
183 | MScanListItem::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 ) | ||
188 | { | ||
189 | qDebug( "creating scanlist item" ); | ||
190 | decorateItem( type, essid, macaddr, wep, channel, signal ); | ||
191 | } | ||
192 | |||
193 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | ||
194 | bool wep, int channel, int signal ) | ||
195 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | ||
196 | { | ||
197 | qDebug( "creating scanlist item" ); | ||
198 | decorateItem( type, essid, macaddr, wep, channel, signal ); | ||
199 | } | ||
200 | |||
201 | void MScanListItem::serializeTo( QDataStream& s ) const | ||
202 | { | ||
203 | OListViewItem::serializeTo( s ); | ||
204 | } | ||
205 | |||
206 | void MScanListItem::serializeFrom( QDataStream& s ) | ||
207 | { | ||
208 | OListViewItem::serializeFrom( s ); | ||
209 | } | ||
210 | |||
211 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | ||
157 | { | 212 | { |
158 | qDebug( "dumping scanlist..." ); | 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 | ||
159 | 229 | ||
160 | QListViewItemIterator it( const_cast<MScanListView*>( this ) ); | 230 | if ( signal != -1 ) |
161 | for ( ; it.current(); ++it ) | 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 | |||
249 | void MScanListItem::setManufacturer( const QString& manufacturer ) | ||
162 | { | 250 | { |
163 | static_cast<MScanListItem*>( it.current() )->dump( t ); | 251 | setText( col_manuf, manufacturer ); |
164 | } | 252 | } |
165 | 253 | ||
166 | qDebug( "dump finished." ); | 254 | void 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() ); | ||
167 | } | 262 | } |
263 | |||