-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index d695c17..245290d 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,216 +1,217 @@ | |||
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 "configwindow.h" | 17 | #include "configwindow.h" |
18 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | 19 | ||
20 | #include <assert.h> | 20 | #include <assert.h> |
21 | #include <qcursor.h> | 21 | #include <qcursor.h> |
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
24 | #include <qpopupmenu.h> | 24 | #include <qpopupmenu.h> |
25 | #include <qcheckbox.h> | ||
25 | 26 | ||
26 | #ifdef QWS | 27 | #ifdef QWS |
27 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
28 | #include <opie/odevice.h> | 29 | #include <opie/odevice.h> |
29 | using namespace Opie; | 30 | using namespace Opie; |
30 | #endif | 31 | #endif |
31 | 32 | ||
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 | ||
39 | const int col_type = 0; | 40 | const int col_type = 0; |
40 | const int col_essid = 0; | 41 | const int col_essid = 0; |
41 | const int col_sig = 1; | 42 | const int col_sig = 1; |
42 | const int col_ap = 2; | 43 | const int col_ap = 2; |
43 | const int col_channel = 3; | 44 | const int col_channel = 3; |
44 | const int col_wep = 4; | 45 | const int col_wep = 4; |
45 | const int col_traffic = 5; | 46 | const int col_traffic = 5; |
46 | const int col_ip = 6; | 47 | const int col_ip = 6; |
47 | const int col_manuf = 7; | 48 | const int col_manuf = 7; |
48 | const int col_firstseen = 8; | 49 | const int col_firstseen = 8; |
49 | const int col_lastseen = 9; | 50 | const int col_lastseen = 9; |
50 | const int col_location = 10; | 51 | const int col_location = 10; |
51 | 52 | ||
52 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 53 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
53 | :OListView( parent, name ) | 54 | :OListView( parent, name ) |
54 | { | 55 | { |
55 | 56 | ||
56 | setFrameShape( QListView::StyledPanel ); | 57 | setFrameShape( QListView::StyledPanel ); |
57 | setFrameShadow( QListView::Sunken ); | 58 | setFrameShadow( QListView::Sunken ); |
58 | 59 | ||
59 | addColumn( tr( "Net/Station" ) ); | 60 | addColumn( tr( "Net/Station" ) ); |
60 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); | 61 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); |
61 | addColumn( tr( "#" ) ); | 62 | addColumn( tr( "#" ) ); |
62 | setColumnAlignment( col_sig, AlignCenter ); | 63 | setColumnAlignment( col_sig, AlignCenter ); |
63 | addColumn( tr( "MAC" ) ); | 64 | addColumn( tr( "MAC" ) ); |
64 | setColumnAlignment( col_ap, AlignCenter ); | 65 | setColumnAlignment( col_ap, AlignCenter ); |
65 | addColumn( tr( "Chn" ) ); | 66 | addColumn( tr( "Chn" ) ); |
66 | setColumnAlignment( col_channel, AlignCenter ); | 67 | setColumnAlignment( col_channel, AlignCenter ); |
67 | addColumn( tr( "W" ) ); | 68 | addColumn( tr( "W" ) ); |
68 | setColumnAlignment( col_wep, AlignCenter ); | 69 | setColumnAlignment( col_wep, AlignCenter ); |
69 | addColumn( tr( "T" ) ); | 70 | addColumn( tr( "T" ) ); |
70 | setColumnAlignment( col_traffic, AlignCenter ); | 71 | setColumnAlignment( col_traffic, AlignCenter ); |
71 | addColumn( tr( "IP" ) ); | 72 | addColumn( tr( "IP" ) ); |
72 | setColumnAlignment( col_ip, AlignCenter ); | 73 | setColumnAlignment( col_ip, AlignCenter ); |
73 | addColumn( tr( "Manufacturer" ) ); | 74 | addColumn( tr( "Manufacturer" ) ); |
74 | setColumnAlignment( col_manuf, AlignCenter ); | 75 | setColumnAlignment( col_manuf, AlignCenter ); |
75 | addColumn( tr( "First Seen" ) ); | 76 | addColumn( tr( "First Seen" ) ); |
76 | setColumnAlignment( col_firstseen, AlignCenter ); | 77 | setColumnAlignment( col_firstseen, AlignCenter ); |
77 | addColumn( tr( "Last Seen" ) ); | 78 | addColumn( tr( "Last Seen" ) ); |
78 | setColumnAlignment( col_lastseen, AlignCenter ); | 79 | setColumnAlignment( col_lastseen, AlignCenter ); |
79 | addColumn( tr( "Location" ) ); | 80 | addColumn( tr( "Location" ) ); |
80 | setColumnAlignment( col_location, AlignCenter ); | 81 | setColumnAlignment( col_location, AlignCenter ); |
81 | setRootIsDecorated( true ); | 82 | setRootIsDecorated( true ); |
82 | setAllColumnsShowFocus( true ); | 83 | setAllColumnsShowFocus( true ); |
83 | 84 | ||
84 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), | 85 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), |
85 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); | 86 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); |
86 | 87 | ||
87 | #ifdef QWS | 88 | #ifdef QWS |
88 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 89 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
89 | #endif | 90 | #endif |
90 | 91 | ||
91 | }; | 92 | }; |
92 | 93 | ||
93 | 94 | ||
94 | MScanListView::~MScanListView() | 95 | MScanListView::~MScanListView() |
95 | { | 96 | { |
96 | }; | 97 | }; |
97 | 98 | ||
98 | 99 | ||
99 | OListViewItem* MScanListView::childFactory() | 100 | OListViewItem* MScanListView::childFactory() |
100 | { | 101 | { |
101 | return new MScanListItem( this ); | 102 | return new MScanListItem( this ); |
102 | } | 103 | } |
103 | 104 | ||
104 | 105 | ||
105 | void MScanListView::serializeTo( QDataStream& s) const | 106 | void MScanListView::serializeTo( QDataStream& s) const |
106 | { | 107 | { |
107 | qDebug( "serializing MScanListView" ); | 108 | qDebug( "serializing MScanListView" ); |
108 | OListView::serializeTo( s ); | 109 | OListView::serializeTo( s ); |
109 | } | 110 | } |
110 | 111 | ||
111 | 112 | ||
112 | void MScanListView::serializeFrom( QDataStream& s) | 113 | void MScanListView::serializeFrom( QDataStream& s) |
113 | { | 114 | { |
114 | qDebug( "serializing MScanListView" ); | 115 | qDebug( "serializing MScanListView" ); |
115 | OListView::serializeFrom( s ); | 116 | OListView::serializeFrom( s ); |
116 | } | 117 | } |
117 | 118 | ||
118 | 119 | ||
119 | void MScanListView::addNewItem( const QString& type, | 120 | void MScanListView::addNewItem( const QString& type, |
120 | const QString& essid, | 121 | const QString& essid, |
121 | const OMacAddress& mac, | 122 | const OMacAddress& mac, |
122 | bool wep, | 123 | bool wep, |
123 | int channel, | 124 | int channel, |
124 | int signal, | 125 | int signal, |
125 | const GpsLocation& loc ) | 126 | const GpsLocation& loc ) |
126 | { | 127 | { |
127 | QString macaddr = mac.toString(true); | 128 | QString macaddr = mac.toString(true); |
128 | 129 | ||
129 | #ifdef DEBUG | 130 | #ifdef DEBUG |
130 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, | 131 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, |
131 | (const char*) essid, (const char*) macaddr, channel ); | 132 | (const char*) essid, (const char*) macaddr, channel ); |
132 | #endif | 133 | #endif |
133 | 134 | ||
134 | // search, if we already have seen this net | 135 | // search, if we already have seen this net |
135 | 136 | ||
136 | QString s; | 137 | QString s; |
137 | MScanListItem* network; | 138 | MScanListItem* network; |
138 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 139 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
139 | 140 | ||
140 | while ( item && ( item->text( col_essid ) != essid ) ) | 141 | while ( item && ( item->text( col_essid ) != essid ) ) |
141 | { | 142 | { |
142 | #ifdef DEBUG | 143 | #ifdef DEBUG |
143 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); | 144 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); |
144 | #endif | 145 | #endif |
145 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 146 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
146 | } | 147 | } |
147 | if ( item ) | 148 | if ( item ) |
148 | { | 149 | { |
149 | // we have already seen this net, check all childs if MAC exists | 150 | // we have already seen this net, check all childs if MAC exists |
150 | 151 | ||
151 | network = item; | 152 | network = item; |
152 | 153 | ||
153 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 154 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
154 | assert( item ); // this shouldn't fail | 155 | assert( item ); // this shouldn't fail |
155 | 156 | ||
156 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 157 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
157 | { | 158 | { |
158 | #ifdef DEBUG | 159 | #ifdef DEBUG |
159 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 160 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); |
160 | #endif | 161 | #endif |
161 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 162 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
162 | } | 163 | } |
163 | 164 | ||
164 | if ( item ) | 165 | if ( item ) |
165 | { | 166 | { |
166 | // we have already seen this item, it's a dupe | 167 | // we have already seen this item, it's a dupe |
167 | #ifdef DEBUG | 168 | #ifdef DEBUG |
168 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 169 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
169 | #endif | 170 | #endif |
170 | item->receivedBeacon(); | 171 | item->receivedBeacon(); |
171 | return; | 172 | return; |
172 | } | 173 | } |
173 | } | 174 | } |
174 | else | 175 | else |
175 | { | 176 | { |
176 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 177 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); |
177 | MLogWindow::logwindow()->log( s ); | 178 | MLogWindow::logwindow()->log( s ); |
178 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); | 179 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); |
179 | } | 180 | } |
180 | 181 | ||
181 | 182 | ||
182 | // insert new station as child from network | 183 | // insert new station as child from network |
183 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 184 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
184 | 185 | ||
185 | #ifdef DEBUG | 186 | #ifdef DEBUG |
186 | qDebug( "inserting new station %s", (const char*) macaddr ); | 187 | qDebug( "inserting new station %s", (const char*) macaddr ); |
187 | #endif | 188 | #endif |
188 | 189 | ||
189 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 190 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
190 | station->setManufacturer( mac.manufacturer() ); | 191 | station->setManufacturer( mac.manufacturer() ); |
191 | station->setLocation( loc.latitude, loc.longitude ); | 192 | station->setLocation( loc.latitude, loc.longitude ); |
192 | 193 | ||
193 | if ( type == "managed" ) | 194 | if ( type == "managed" ) |
194 | { | 195 | { |
195 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 196 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
196 | } | 197 | } |
197 | else | 198 | else |
198 | { | 199 | { |
199 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); | 200 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); |
200 | } | 201 | } |
201 | MLogWindow::logwindow()->log( s ); | 202 | MLogWindow::logwindow()->log( s ); |
202 | 203 | ||
203 | } | 204 | } |
204 | 205 | ||
205 | 206 | ||
206 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 207 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
207 | { | 208 | { |
208 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 209 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
209 | 210 | ||
210 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 211 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
211 | { | 212 | { |
212 | #ifdef DEBUG | 213 | #ifdef DEBUG |
213 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 214 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
214 | #endif | 215 | #endif |
215 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 216 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
216 | } | 217 | } |
@@ -280,235 +281,241 @@ void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, | |||
280 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 281 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
281 | { | 282 | { |
282 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 283 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
283 | } | 284 | } |
284 | else | 285 | else |
285 | { | 286 | { |
286 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 287 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
287 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 288 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
288 | 289 | ||
289 | } | 290 | } |
290 | } | 291 | } |
291 | 292 | ||
292 | 293 | ||
293 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 294 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
294 | { | 295 | { |
295 | QString s; | 296 | QString s; |
296 | MScanListItem* network; | 297 | MScanListItem* network; |
297 | 298 | ||
298 | QListViewItemIterator it( this ); | 299 | QListViewItemIterator it( this ); |
299 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 300 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
300 | 301 | ||
301 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 302 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
302 | 303 | ||
303 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 304 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
304 | { | 305 | { |
305 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 306 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
306 | } | 307 | } |
307 | else | 308 | else |
308 | { | 309 | { |
309 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 310 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
310 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 311 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
311 | } | 312 | } |
312 | } | 313 | } |
313 | 314 | ||
314 | 315 | ||
315 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 316 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
316 | { | 317 | { |
317 | qWarning( "D'oh! Not yet implemented..." ); | 318 | qWarning( "D'oh! Not yet implemented..." ); |
318 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 319 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
319 | } | 320 | } |
320 | 321 | ||
321 | 322 | ||
322 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 323 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
323 | { | 324 | { |
324 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); | 325 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); |
325 | 326 | ||
326 | QListViewItemIterator it( this ); | 327 | QListViewItemIterator it( this ); |
327 | for ( ; it.current(); ++it ) | 328 | for ( ; it.current(); ++it ) |
328 | { | 329 | { |
329 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 330 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
330 | { | 331 | { |
331 | it.current()->setText( col_ip, ip ); | 332 | it.current()->setText( col_ip, ip ); |
332 | return; | 333 | return; |
333 | } | 334 | } |
334 | } | 335 | } |
335 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 336 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
336 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", | 337 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
337 | (const char*) macaddr.toString(), (const char*) ip ) ); | 338 | (const char*) macaddr.toString(), (const char*) ip ) ); |
338 | } | 339 | } |
339 | 340 | ||
340 | 341 | ||
341 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 342 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
342 | { | 343 | { |
343 | if ( !item ) return; | 344 | if ( !item ) return; |
344 | 345 | ||
345 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 346 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
346 | 347 | ||
347 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 348 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
348 | (const char*) itm->text(0), (const char*) itm->type, col ); | 349 | (const char*) itm->text(0), (const char*) itm->type, col ); |
349 | 350 | ||
350 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 351 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
351 | { | 352 | { |
352 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | 353 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); |
353 | 354 | ||
354 | QPopupMenu m( this ); | 355 | QPopupMenu m( this ); |
355 | m.insertItem( entry, 37773, 0 ); | 356 | m.insertItem( entry, 37773, 0 ); |
356 | int result = m.exec( QCursor::pos() ); | 357 | int result = m.exec( QCursor::pos() ); |
357 | if ( result == 37773 ) | 358 | if ( result == 37773 ) |
358 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 359 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
359 | } | 360 | } |
360 | } | 361 | } |
361 | 362 | ||
362 | //============================================================ | 363 | //============================================================ |
363 | // MScanListItem | 364 | // MScanListItem |
364 | //============================================================ | 365 | //============================================================ |
365 | 366 | ||
366 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 367 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, |
367 | bool wep, int channel, int signal ) | 368 | bool wep, int channel, int signal ) |
368 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 369 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
369 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 370 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
370 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 371 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
371 | { | 372 | { |
372 | #ifdef DEBUG | 373 | #ifdef DEBUG |
373 | qDebug( "creating scanlist item" ); | 374 | qDebug( "creating scanlist item" ); |
374 | #endif | 375 | #endif |
375 | if ( WellenreiterConfigWindow::instance() && type == "network" ) | 376 | if ( WellenreiterConfigWindow::instance() && type == "network" ) |
376 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); | 377 | playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); |
377 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 378 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
378 | } | 379 | } |
379 | 380 | ||
380 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 381 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, |
381 | bool wep, int channel, int signal ) | 382 | bool wep, int channel, int signal ) |
382 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 383 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
383 | { | 384 | { |
384 | #ifdef DEBUG | 385 | #ifdef DEBUG |
385 | qDebug( "creating scanlist item" ); | 386 | qDebug( "creating scanlist item" ); |
386 | #endif | 387 | #endif |
387 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 388 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
388 | } | 389 | } |
389 | 390 | ||
390 | const QString& MScanListItem::essid() const | 391 | const QString& MScanListItem::essid() const |
391 | { | 392 | { |
392 | if ( type == "network" ) | 393 | if ( type == "network" ) |
393 | return _essid; | 394 | return _essid; |
394 | else | 395 | else |
395 | return ( (MScanListItem*) parent() )->essid(); | 396 | return ( (MScanListItem*) parent() )->essid(); |
396 | } | 397 | } |
397 | 398 | ||
398 | OListViewItem* MScanListItem::childFactory() | 399 | OListViewItem* MScanListItem::childFactory() |
399 | { | 400 | { |
400 | return new MScanListItem( this ); | 401 | return new MScanListItem( this ); |
401 | } | 402 | } |
402 | 403 | ||
403 | void MScanListItem::serializeTo( QDataStream& s ) const | 404 | void MScanListItem::serializeTo( QDataStream& s ) const |
404 | { | 405 | { |
405 | #ifdef DEBUG | 406 | #ifdef DEBUG |
406 | qDebug( "serializing MScanListItem" ); | 407 | qDebug( "serializing MScanListItem" ); |
407 | #endif | 408 | #endif |
408 | OListViewItem::serializeTo( s ); | 409 | OListViewItem::serializeTo( s ); |
409 | 410 | ||
410 | s << _type; | 411 | s << _type; |
411 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 412 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
412 | } | 413 | } |
413 | 414 | ||
414 | void MScanListItem::serializeFrom( QDataStream& s ) | 415 | void MScanListItem::serializeFrom( QDataStream& s ) |
415 | { | 416 | { |
416 | #ifdef DEBUG | 417 | #ifdef DEBUG |
417 | qDebug( "serializing MScanListItem" ); | 418 | qDebug( "serializing MScanListItem" ); |
418 | #endif | 419 | #endif |
419 | OListViewItem::serializeFrom( s ); | 420 | OListViewItem::serializeFrom( s ); |
420 | 421 | ||
421 | char wep; | 422 | char wep; |
422 | s >> _type; | 423 | s >> _type; |
423 | s >> (Q_UINT8) wep; | 424 | s >> (Q_UINT8) wep; |
424 | _wep = (wep == 'y'); | 425 | _wep = (wep == 'y'); |
425 | 426 | ||
426 | QString name; | 427 | QString name; |
427 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 428 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
428 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 429 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
429 | if ( _wep ) | 430 | if ( _wep ) |
430 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 431 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
431 | listView()->triggerUpdate(); | 432 | listView()->triggerUpdate(); |
432 | } | 433 | } |
433 | 434 | ||
434 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 435 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
435 | { | 436 | { |
436 | #ifdef DEBUG | 437 | #ifdef DEBUG |
437 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 438 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
438 | (const char*) type, | 439 | (const char*) type, |
439 | (const char*) essid, | 440 | (const char*) essid, |
440 | (const char*) macaddr, | 441 | (const char*) macaddr, |
441 | channel ); | 442 | channel ); |
442 | #endif | 443 | #endif |
443 | 444 | ||
444 | // set icon for managed or adhoc mode | 445 | // set icon for managed or adhoc mode |
445 | QString name; | 446 | QString name; |
446 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 447 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
447 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 448 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
448 | 449 | ||
449 | // set icon for wep (wireless encryption protocol) | 450 | // set icon for wep (wireless encryption protocol) |
450 | if ( wep ) | 451 | if ( wep ) |
451 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 452 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
452 | 453 | ||
453 | // set channel and signal text | 454 | // set channel and signal text |
454 | 455 | ||
455 | if ( signal != -1 ) | 456 | if ( signal != -1 ) |
456 | setText( col_sig, QString::number( signal ) ); | 457 | setText( col_sig, QString::number( signal ) ); |
457 | if ( channel != -1 ) | 458 | if ( channel != -1 ) |
458 | setText( col_channel, QString::number( channel ) ); | 459 | setText( col_channel, QString::number( channel ) ); |
459 | 460 | ||
460 | setText( col_firstseen, QTime::currentTime().toString() ); | 461 | setText( col_firstseen, QTime::currentTime().toString() ); |
461 | //setText( col_lastseen, QTime::currentTime().toString() ); | 462 | //setText( col_lastseen, QTime::currentTime().toString() ); |
462 | 463 | ||
463 | listView()->triggerUpdate(); | 464 | listView()->triggerUpdate(); |
464 | 465 | ||
465 | this->type = type; | 466 | this->type = type; |
466 | _type = type; | 467 | _type = type; |
467 | _essid = essid; | 468 | _essid = essid; |
468 | _macaddr = macaddr; | 469 | _macaddr = macaddr; |
469 | _channel = channel; | 470 | _channel = channel; |
470 | _beacons = 1; | 471 | _beacons = 1; |
471 | _signal = 0; | 472 | _signal = 0; |
473 | |||
474 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) | ||
475 | { | ||
476 | listView()->ensureItemVisible( this ); | ||
477 | } | ||
478 | |||
472 | } | 479 | } |
473 | 480 | ||
474 | 481 | ||
475 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 482 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
476 | { | 483 | { |
477 | setText( col_manuf, manufacturer ); | 484 | setText( col_manuf, manufacturer ); |
478 | } | 485 | } |
479 | 486 | ||
480 | 487 | ||
481 | void MScanListItem::setLocation( const float& latitude, const float& longitude ) | 488 | void MScanListItem::setLocation( const float& latitude, const float& longitude ) |
482 | { | 489 | { |
483 | if ( latitude == 0.0 || longitude == 0.0 ) | 490 | if ( latitude == 0.0 || longitude == 0.0 ) |
484 | setText( col_location, "N/A" ); | 491 | setText( col_location, "N/A" ); |
485 | else | 492 | else |
486 | setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) ); | 493 | setText( col_location, QString().sprintf( "%.2f / %.2f", latitude, longitude ) ); |
487 | } | 494 | } |
488 | 495 | ||
489 | 496 | ||
490 | void MScanListItem::playSound( const QString& sound ) const | 497 | void MScanListItem::playSound( const QString& sound ) const |
491 | { | 498 | { |
492 | #ifdef QWS | 499 | #ifdef QWS |
493 | if ( sound == "Ignore" ) return; | 500 | if ( sound == "Ignore" ) return; |
494 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); | 501 | else if ( sound == "Touch" ) ODevice::inst()->touchSound(); |
495 | else if ( sound == "Key" ) ODevice::inst()->keySound(); | 502 | else if ( sound == "Key" ) ODevice::inst()->keySound(); |
496 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); | 503 | else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); |
497 | #endif | 504 | #endif |
498 | } | 505 | } |
499 | 506 | ||
500 | 507 | ||
501 | void MScanListItem::receivedBeacon() | 508 | void MScanListItem::receivedBeacon() |
502 | { | 509 | { |
503 | _beacons++; | 510 | _beacons++; |
504 | #ifdef DEBUG | 511 | #ifdef DEBUG |
505 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 512 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); |
506 | #endif | 513 | #endif |
507 | setText( col_sig, QString::number( _beacons ) ); | 514 | setText( col_sig, QString::number( _beacons ) ); |
508 | setText( col_lastseen, QTime::currentTime().toString() ); | 515 | setText( col_lastseen, QTime::currentTime().toString() ); |
509 | 516 | ||
510 | MScanListItem* p = (MScanListItem*) parent(); | 517 | MScanListItem* p = (MScanListItem*) parent(); |
511 | if ( p ) p->receivedBeacon(); | 518 | if ( p ) p->receivedBeacon(); |
512 | 519 | ||
513 | } | 520 | } |
514 | 521 | ||