summaryrefslogtreecommitdiff
authorzecke <zecke>2004-05-18 20:57:35 (UTC)
committer zecke <zecke>2004-05-18 20:57:35 (UTC)
commit59c6451a16405f19b1d4bc97906bd5778b5b0cd3 (patch) (unidiff)
tree325a5e496a03304a99f224fa258b0cd2dabf2db9
parenteb5a5432d79083fdfefb7b9b0c0907abe8807a52 (diff)
downloadopie-59c6451a16405f19b1d4bc97906bd5778b5b0cd3.zip
opie-59c6451a16405f19b1d4bc97906bd5778b5b0cd3.tar.gz
opie-59c6451a16405f19b1d4bc97906bd5778b5b0cd3.tar.bz2
Aye no (const char*)str where type(str) == QString please...
Now I can even scan non latin access points and don't need to reset stdout/stderr
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 9e8aa72..9e907d8 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -1,566 +1,566 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
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/* OPIE */ 20/* OPIE */
21#ifdef QWS 21#ifdef QWS
22#include <opie2/odebug.h> 22#include <opie2/odebug.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#else 25#else
26#include "resource.h" 26#include "resource.h"
27#endif 27#endif
28using namespace Opie::Core; 28using namespace Opie::Core;
29using namespace Opie::Ui; 29using namespace Opie::Ui;
30using namespace Opie::Net; 30using namespace Opie::Net;
31 31
32/* QT */ 32/* QT */
33#include <qcursor.h> 33#include <qcursor.h>
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcheckbox.h> 36#include <qcheckbox.h>
37 37
38/* STD */ 38/* STD */
39#include <assert.h> 39#include <assert.h>
40 40
41const int col_type = 0; 41const int col_type = 0;
42const int col_essid = 0; 42const int col_essid = 0;
43const int col_sig = 1; 43const int col_sig = 1;
44const int col_ap = 2; 44const int col_ap = 2;
45const int col_channel = 3; 45const int col_channel = 3;
46const int col_wep = 4; 46const int col_wep = 4;
47const int col_traffic = 5; 47const int col_traffic = 5;
48const int col_ip = 6; 48const int col_ip = 6;
49const int col_manuf = 7; 49const int col_manuf = 7;
50const int col_firstseen = 8; 50const int col_firstseen = 8;
51const int col_lastseen = 9; 51const int col_lastseen = 9;
52const int col_location = 10; 52const int col_location = 10;
53 53
54MScanListView::MScanListView( QWidget* parent, const char* name ) 54MScanListView::MScanListView( QWidget* parent, const char* name )
55 :OListView( parent, name ) 55 :OListView( parent, name )
56{ 56{
57 setFrameShape( QListView::StyledPanel ); 57 setFrameShape( QListView::StyledPanel );
58 setFrameShadow( QListView::Sunken ); 58 setFrameShadow( QListView::Sunken );
59 59
60 addColumn( tr( "Net/Station" ) ); 60 addColumn( tr( "Net/Station" ) );
61 setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); 61 setColumnAlignment( col_essid, AlignLeft || AlignVCenter );
62 addColumn( tr( "#" ) ); 62 addColumn( tr( "#" ) );
63 setColumnAlignment( col_sig, AlignCenter ); 63 setColumnAlignment( col_sig, AlignCenter );
64 addColumn( tr( "MAC" ) ); 64 addColumn( tr( "MAC" ) );
65 setColumnAlignment( col_ap, AlignCenter ); 65 setColumnAlignment( col_ap, AlignCenter );
66 addColumn( tr( "Chn" ) ); 66 addColumn( tr( "Chn" ) );
67 setColumnAlignment( col_channel, AlignCenter ); 67 setColumnAlignment( col_channel, AlignCenter );
68 addColumn( tr( "W" ) ); 68 addColumn( tr( "W" ) );
69 setColumnAlignment( col_wep, AlignCenter ); 69 setColumnAlignment( col_wep, AlignCenter );
70 addColumn( tr( "T" ) ); 70 addColumn( tr( "T" ) );
71 setColumnAlignment( col_traffic, AlignCenter ); 71 setColumnAlignment( col_traffic, AlignCenter );
72 addColumn( tr( "IP" ) ); 72 addColumn( tr( "IP" ) );
73 setColumnAlignment( col_ip, AlignCenter ); 73 setColumnAlignment( col_ip, AlignCenter );
74 addColumn( tr( "Manufacturer" ) ); 74 addColumn( tr( "Manufacturer" ) );
75 setColumnAlignment( col_manuf, AlignCenter ); 75 setColumnAlignment( col_manuf, AlignCenter );
76 addColumn( tr( "First Seen" ) ); 76 addColumn( tr( "First Seen" ) );
77 setColumnAlignment( col_firstseen, AlignCenter ); 77 setColumnAlignment( col_firstseen, AlignCenter );
78 addColumn( tr( "Last Seen" ) ); 78 addColumn( tr( "Last Seen" ) );
79 setColumnAlignment( col_lastseen, AlignCenter ); 79 setColumnAlignment( col_lastseen, AlignCenter );
80 addColumn( tr( "Location" ) ); 80 addColumn( tr( "Location" ) );
81 setColumnAlignment( col_location, AlignCenter ); 81 setColumnAlignment( col_location, AlignCenter );
82 setRootIsDecorated( true ); 82 setRootIsDecorated( true );
83 setAllColumnsShowFocus( true ); 83 setAllColumnsShowFocus( true );
84 84
85 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), 85 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ),
86 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); 86 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
87 87
88 #ifdef QWS 88 #ifdef QWS
89 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 89 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
90 #endif 90 #endif
91 91
92}; 92};
93 93
94 94
95MScanListView::~MScanListView() 95MScanListView::~MScanListView()
96{ 96{
97}; 97};
98 98
99 99
100OListViewItem* MScanListView::childFactory() 100OListViewItem* MScanListView::childFactory()
101{ 101{
102 return new MScanListItem( this ); 102 return new MScanListItem( this );
103} 103}
104 104
105 105
106void MScanListView::serializeTo( QDataStream& s) const 106void MScanListView::serializeTo( QDataStream& s) const
107{ 107{
108 odebug << "serializing MScanListView" << oendl; 108 odebug << "serializing MScanListView" << oendl;
109 OListView::serializeTo( s ); 109 OListView::serializeTo( s );
110} 110}
111 111
112 112
113void MScanListView::serializeFrom( QDataStream& s) 113void MScanListView::serializeFrom( QDataStream& s)
114{ 114{
115 odebug << "serializing MScanListView" << oendl; 115 odebug << "serializing MScanListView" << oendl;
116 OListView::serializeFrom( s ); 116 OListView::serializeFrom( s );
117} 117}
118 118
119 119
120void MScanListView::addNewItem( const QString& type, 120void MScanListView::addNewItem( const QString& type,
121 const QString& essid, 121 const QString& essid,
122 const OMacAddress& mac, 122 const OMacAddress& mac,
123 bool wep, 123 bool wep,
124 int channel, 124 int channel,
125 int signal, 125 int signal,
126 const GpsLocation& loc, 126 const GpsLocation& loc,
127 bool probe ) 127 bool probe )
128{ 128{
129 QString macaddr = mac.toString(true); 129 QString macaddr = mac.toString(true);
130 130
131 #ifdef DEBUG 131 #ifdef DEBUG
132 odebug << "MScanList::addNewItem( " << (const char*) type << " / " 132 odebug << "MScanList::addNewItem( " << type << " / "
133 << (const char*) essid << " / " << (const char*) macaddr 133 << essid << " / " << macaddr
134 << " [" << channel << "]" << oendl; 134 << " [" << channel << "]" << oendl;
135 #endif 135 #endif
136 136
137 // search, if we already have seen this net 137 // search, if we already have seen this net
138 138
139 QString s; 139 QString s;
140 MScanListItem* network; 140 MScanListItem* network;
141 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 141 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
142 142
143 while ( item && ( item->text( col_essid ) != essid ) ) 143 while ( item && ( item->text( col_essid ) != essid ) )
144 { 144 {
145 #ifdef DEBUG 145 #ifdef DEBUG
146 odebug << "itemtext: " << item->text( col_essid ) << "" << oendl; 146 odebug << "itemtext: " << item->text( col_essid ) << "" << oendl;
147 #endif 147 #endif
148 item = static_cast<MScanListItem*> ( item->nextSibling() ); 148 item = static_cast<MScanListItem*> ( item->nextSibling() );
149 } 149 }
150 if ( item ) 150 if ( item )
151 { 151 {
152 // we have already seen this net, check all childs if MAC exists 152 // we have already seen this net, check all childs if MAC exists
153 153
154 network = item; 154 network = item;
155 155
156 item = static_cast<MScanListItem*> ( item->firstChild() ); 156 item = static_cast<MScanListItem*> ( item->firstChild() );
157 assert( item ); // this shouldn't fail 157 assert( item ); // this shouldn't fail
158 158
159 while ( item && ( item->text( col_ap ) != macaddr ) ) 159 while ( item && ( item->text( col_ap ) != macaddr ) )
160 { 160 {
161 #ifdef DEBUG 161 #ifdef DEBUG
162 odebug << "subitemtext: " << item->text( col_ap ) << "" << oendl; 162 odebug << "subitemtext: " << item->text( col_ap ) << "" << oendl;
163 #endif 163 #endif
164 item = static_cast<MScanListItem*> ( item->nextSibling() ); 164 item = static_cast<MScanListItem*> ( item->nextSibling() );
165 } 165 }
166 166
167 if ( item ) 167 if ( item )
168 { 168 {
169 // we have already seen this item, it's a dupe 169 // we have already seen this item, it's a dupe
170 #ifdef DEBUG 170 #ifdef DEBUG
171 odebug << "" << macaddr << " is a dupe - ignoring..." << oendl; 171 odebug << "" << macaddr << " is a dupe - ignoring..." << oendl;
172 #endif 172 #endif
173 item->receivedBeacon(); 173 item->receivedBeacon();
174 return; 174 return;
175 } 175 }
176 } 176 }
177 else 177 else
178 { 178 {
179 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); 179 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid );
180 MLogWindow::logwindow()->log( s ); 180 MLogWindow::logwindow()->log( s );
181 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); 181 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe );
182 } 182 }
183 183
184 184
185 // insert new station as child from network 185 // insert new station as child from network
186 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 186 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
187 187
188 #ifdef DEBUG 188 #ifdef DEBUG
189 odebug << "inserting new station " << macaddr << "" << oendl; 189 odebug << "inserting new station " << macaddr << "" << oendl;
190 #endif 190 #endif
191 191
192 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 192 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
193 station->setManufacturer( mac.manufacturer() ); 193 station->setManufacturer( mac.manufacturer() );
194 station->setLocation( loc.dmsPosition() ); 194 station->setLocation( loc.dmsPosition() );
195 195
196 if ( type == "managed" ) 196 if ( type == "managed" )
197 { 197 {
198 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); 198 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel );
199 } 199 }
200 else 200 else
201 { 201 {
202 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); 202 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel );
203 } 203 }
204 MLogWindow::logwindow()->log( s ); 204 MLogWindow::logwindow()->log( s );
205} 205}
206 206
207 207
208void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) 208void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type )
209{ 209{
210 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); 210 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() );
211 211
212 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) 212 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) )
213 { 213 {
214 #ifdef DEBUG 214 #ifdef DEBUG
215 odebug << "subitemtext: " << subitem->text( col_ap ) << "" << oendl; 215 odebug << "subitemtext: " << subitem->text( col_ap ) << "" << oendl;
216 #endif 216 #endif
217 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 217 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
218 } 218 }
219 219
220 if ( subitem ) 220 if ( subitem )
221 { 221 {
222 // we have already seen this item, it's a dupe 222 // we have already seen this item, it's a dupe
223 #ifdef DEBUG 223 #ifdef DEBUG
224 odebug << "" << addr.toString(true) << " is a dupe - ignoring..." << oendl; 224 odebug << "" << addr.toString(true) << " is a dupe - ignoring..." << oendl;
225 #endif 225 #endif
226 subitem->receivedBeacon(); //FIXME: sent data bit 226 subitem->receivedBeacon(); //FIXME: sent data bit
227 return; 227 return;
228 } 228 }
229 229
230 // Hey, it seems to be a new item :-D 230 // Hey, it seems to be a new item :-D
231 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); 231 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 );
232 station->setManufacturer( addr.manufacturer() ); 232 station->setManufacturer( addr.manufacturer() );
233 233
234 QString s; 234 QString s;
235 if ( type == "station" ) 235 if ( type == "station" )
236 { 236 {
237 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 237 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) );
238 } 238 }
239 else 239 else
240 { 240 {
241 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 241 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) );
242 } 242 }
243 MLogWindow::logwindow()->log( s ); 243 MLogWindow::logwindow()->log( s );
244} 244}
245 245
246 246
247void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) 247void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo )
248{ 248{
249 odebug << "WDSTraffic: " << (const char*) viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl; 249 odebug << "WDSTraffic: " << (const char*) viaFrom.toString() << " and " << viaTo.toString() << " seem to form a WDS" << oendl;
250 QString s; 250 QString s;
251 MScanListItem* network; 251 MScanListItem* network;
252 252
253 QListViewItemIterator it( this ); 253 QListViewItemIterator it( this );
254 while ( it.current() && 254 while ( it.current() &&
255 it.current()->text( col_ap ) != viaFrom.toString(true) && 255 it.current()->text( col_ap ) != viaFrom.toString(true) &&
256 it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; 256 it.current()->text( col_ap ) != viaTo.toString(true) ) ++it;
257 257
258 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 258 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
259 259
260 if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations 260 if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations
261 { 261 {
262 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); 262 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from );
263 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); 263 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to );
264 } 264 }
265 else 265 else
266 { 266 {
267 odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl; 267 odebug << "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" << oendl;
268 MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); 268 MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" );
269 } 269 }
270} 270}
271 271
272 272
273void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 273void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
274{ 274{
275 QString s; 275 QString s;
276 MScanListItem* network; 276 MScanListItem* network;
277 277
278 QListViewItemIterator it( this ); 278 QListViewItemIterator it( this );
279 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; 279 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
280 280
281 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 281 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
282 282
283 if ( item ) // AP has shown up yet, so just add our new "from" - station 283 if ( item ) // AP has shown up yet, so just add our new "from" - station
284 { 284 {
285 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); 285 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" );
286 } 286 }
287 else 287 else
288 { 288 {
289 odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; 289 odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl;
290 MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); 290 MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" );
291 291
292 } 292 }
293} 293}
294 294
295 295
296void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 296void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
297{ 297{
298 QString s; 298 QString s;
299 MScanListItem* network; 299 MScanListItem* network;
300 300
301 QListViewItemIterator it( this ); 301 QListViewItemIterator it( this );
302 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; 302 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
303 303
304 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 304 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
305 305
306 if ( item ) // AP has shown up yet, so just add our new "from" - station 306 if ( item ) // AP has shown up yet, so just add our new "from" - station
307 { 307 {
308 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); 308 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" );
309 } 309 }
310 else 310 else
311 { 311 {
312 odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl; 312 odebug << "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" << oendl;
313 MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); 313 MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" );
314 } 314 }
315} 315}
316 316
317 317
318void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 318void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
319{ 319{
320 owarn << "D'oh! Not yet implemented..." << oendl; 320 owarn << "D'oh! Not yet implemented..." << oendl;
321 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); 321 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" );
322} 322}
323 323
324 324
325void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) 325void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
326{ 326{
327 odebug << "identify " << (const char*) macaddr.toString() << " = " << ip << "" << oendl; 327 odebug << "identify " << (const char*) macaddr.toString() << " = " << ip << "" << oendl;
328 328
329 QListViewItemIterator it( this ); 329 QListViewItemIterator it( this );
330 for ( ; it.current(); ++it ) 330 for ( ; it.current(); ++it )
331 { 331 {
332 if ( it.current()->text( col_ap ) == macaddr.toString(true) ) 332 if ( it.current()->text( col_ap ) == macaddr.toString(true) )
333 { 333 {
334 it.current()->setText( col_ip, ip ); 334 it.current()->setText( col_ip, ip );
335 return; 335 return;
336 } 336 }
337 } 337 }
338 odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; 338 odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl;
339 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", 339 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!",
340 (const char*) macaddr.toString(), (const char*) ip ) ); 340 (const char*) macaddr.toString(), (const char*) ip ) );
341} 341}
342 342
343 343
344void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) 344void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip )
345{ 345{
346 odebug << "addService '" << (const char*) name << "', Server = " << (const char*) macaddr.toString() << " = " << ip << "" << oendl; 346 odebug << "addService '" << (const char*) name << "', Server = " << (const char*) macaddr.toString() << " = " << ip << "" << oendl;
347 347
348 //TODO: Refactor that out, we need it all over the place. 348 //TODO: Refactor that out, we need it all over the place.
349 // Best to do it in a more comfortable abstraction in OListView 349 // Best to do it in a more comfortable abstraction in OListView
350 // (Hmm, didn't I already start something in this direction?) 350 // (Hmm, didn't I already start something in this direction?)
351 351
352 QListViewItemIterator it( this ); 352 QListViewItemIterator it( this );
353 for ( ; it.current(); ++it ) 353 for ( ; it.current(); ++it )
354 { 354 {
355 if ( it.current()->text( col_ap ) == macaddr.toString(true) ) 355 if ( it.current()->text( col_ap ) == macaddr.toString(true) )
356 { 356 {
357 357
358 MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); 358 MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() );
359 359
360 while ( subitem && ( subitem->text( col_essid ) != name ) ) 360 while ( subitem && ( subitem->text( col_essid ) != name ) )
361 { 361 {
362 #ifdef DEBUG 362 #ifdef DEBUG
363 odebug << "subitemtext: " << subitem->text( col_essid ) << "" << oendl; 363 odebug << "subitemtext: " << subitem->text( col_essid ) << "" << oendl;
364 #endif 364 #endif
365 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 365 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
366 } 366 }
367 367
368 if ( subitem ) 368 if ( subitem )
369 { 369 {
370 // we have already seen this item, it's a dupe 370 // we have already seen this item, it's a dupe
371 #ifdef DEBUG 371 #ifdef DEBUG
372 odebug << "" << name << " is a dupe - ignoring..." << oendl; 372 odebug << "" << name << " is a dupe - ignoring..." << oendl;
373 #endif 373 #endif
374 subitem->receivedBeacon(); //FIXME: sent data bit 374 subitem->receivedBeacon(); //FIXME: sent data bit
375 return; 375 return;
376 } 376 }
377 377
378 // never seen that - add new item 378 // never seen that - add new item
379 379
380 MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); 380 MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 );
381 item->setText( col_essid, name ); 381 item->setText( col_essid, name );
382 382
383 return; 383 return;
384 } 384 }
385 } 385 }
386 odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl; 386 odebug << "D'oh! Received identification, but item not yet in list... ==> Handle this!" << oendl;
387 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", 387 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!",
388 (const char*) macaddr.toString(), (const char*) ip ) ); 388 (const char*) macaddr.toString(), (const char*) ip ) );
389} 389}
390 390
391 391
392void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) 392void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col )
393{ 393{
394 if ( !item ) return; 394 if ( !item ) return;
395 395
396 MScanListItem* itm = static_cast<MScanListItem*>( item ); 396 MScanListItem* itm = static_cast<MScanListItem*>( item );
397 397
398 odebug << "contextMenuRequested on item '" << (const char*) itm->text(0) << "' (" 398 odebug << "contextMenuRequested on item '" << (const char*) itm->text(0) << "' ("
399 << (const char*) itm->type << ") in column: '" << col << "'" << oendl; 399 << (const char*) itm->type << ") in column: '" << col << "'" << oendl;
400 400
401 if ( itm->type == "adhoc" || itm->type == "managed" ) 401 if ( itm->type == "adhoc" || itm->type == "managed" )
402 { 402 {
403 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); 403 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() );
404 404
405 QPopupMenu m( this ); 405 QPopupMenu m( this );
406 m.insertItem( entry, 37773, 0 ); 406 m.insertItem( entry, 37773, 0 );
407 int result = m.exec( QCursor::pos() ); 407 int result = m.exec( QCursor::pos() );
408 if ( result == 37773 ) 408 if ( result == 37773 )
409 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); 409 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() );
410 } 410 }
411} 411}
412 412
413//============================================================ 413//============================================================
414// MScanListItem 414// MScanListItem
415//============================================================ 415//============================================================
416 416
417MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, 417MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr,
418 bool wep, int channel, int signal, bool probed ) 418 bool wep, int channel, int signal, bool probed )
419 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 419 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
420 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 420 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
421 _channel( channel ), _signal( signal ), _beacons( 1 ) 421 _channel( channel ), _signal( signal ), _beacons( 1 )
422{ 422{
423 #ifdef DEBUG 423 #ifdef DEBUG
424 odebug << "creating scanlist item" << oendl; 424 odebug << "creating scanlist item" << oendl;
425 #endif 425 #endif
426 426
427 if ( WellenreiterConfigWindow::instance() ) 427 if ( WellenreiterConfigWindow::instance() )
428 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here 428 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here
429 429
430 decorateItem( type, essid, macaddr, wep, channel, signal, probed ); 430 decorateItem( type, essid, macaddr, wep, channel, signal, probed );
431} 431}
432 432
433MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, 433MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr,
434 bool wep, int channel, int signal ) 434 bool wep, int channel, int signal )
435 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 435 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
436{ 436{
437 #ifdef DEBUG 437 #ifdef DEBUG
438 odebug << "creating scanlist item" << oendl; 438 odebug << "creating scanlist item" << oendl;
439 #endif 439 #endif
440 if ( WellenreiterConfigWindow::instance() ) 440 if ( WellenreiterConfigWindow::instance() )
441 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here 441 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here
442 442
443 decorateItem( type, essid, macaddr, wep, channel, signal, false ); 443 decorateItem( type, essid, macaddr, wep, channel, signal, false );
444} 444}
445 445
446const QString& MScanListItem::essid() const 446const QString& MScanListItem::essid() const
447{ 447{
448 if ( type == "network" ) 448 if ( type == "network" )
449 return _essid; 449 return _essid;
450 else 450 else
451 return ( (MScanListItem*) parent() )->essid(); 451 return ( (MScanListItem*) parent() )->essid();
452} 452}
453 453
454OListViewItem* MScanListItem::childFactory() 454OListViewItem* MScanListItem::childFactory()
455{ 455{
456 return new MScanListItem( this ); 456 return new MScanListItem( this );
457} 457}
458 458
459void MScanListItem::serializeTo( QDataStream& s ) const 459void MScanListItem::serializeTo( QDataStream& s ) const
460{ 460{
461 #ifdef DEBUG 461 #ifdef DEBUG
462 odebug << "serializing MScanListItem" << oendl; 462 odebug << "serializing MScanListItem" << oendl;
463 #endif 463 #endif
464 OListViewItem::serializeTo( s ); 464 OListViewItem::serializeTo( s );
465 465
466 s << _type; 466 s << _type;
467 s << (Q_UINT8) ( _wep ? 'y' : 'n' ); 467 s << (Q_UINT8) ( _wep ? 'y' : 'n' );
468} 468}
469 469
470void MScanListItem::serializeFrom( QDataStream& s ) 470void MScanListItem::serializeFrom( QDataStream& s )
471{ 471{
472 #ifdef DEBUG 472 #ifdef DEBUG
473 odebug << "serializing MScanListItem" << oendl; 473 odebug << "serializing MScanListItem" << oendl;
474 #endif 474 #endif
475 OListViewItem::serializeFrom( s ); 475 OListViewItem::serializeFrom( s );
476 476
477 Q_UINT8 wep; 477 Q_UINT8 wep;
478 s >> _type; 478 s >> _type;
479 s >> wep; 479 s >> wep;
480 _wep = (wep == 'y'); 480 _wep = (wep == 'y');
481 481
482 QString name; 482 QString name;
483 name.sprintf( "wellenreiter/%s", (const char*) _type ); 483 name.sprintf( "wellenreiter/%s", (const char*) _type );
484 setPixmap( col_type, Resource::loadPixmap( name ) ); 484 setPixmap( col_type, Resource::loadPixmap( name ) );
485 if ( _wep ) 485 if ( _wep )
486 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 486 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
487 listView()->triggerUpdate(); 487 listView()->triggerUpdate();
488} 488}
489 489
490void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) 490void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed )
491{ 491{
492 #ifdef DEBUG 492 #ifdef DEBUG
493 odebug << "decorating scanlist item " << (const char*) type << " / " 493 odebug << "decorating scanlist item " << (const char*) type << " / "
494 << (const char*) essid << " / " << (const char*) macaddr 494 << (const char*) essid << " / " << (const char*) macaddr
495 << "[" << channel << "]" << oendl; 495 << "[" << channel << "]" << oendl;
496 #endif 496 #endif
497 497
498 // set icon for managed or adhoc mode 498 // set icon for managed or adhoc mode
499 QString name; 499 QString name;
500 name.sprintf( "wellenreiter/%s", (const char*) type ); 500 name.sprintf( "wellenreiter/%s", (const char*) type );
501 setPixmap( col_type, Resource::loadPixmap( name ) ); 501 setPixmap( col_type, Resource::loadPixmap( name ) );
502 502
503 // special case for probed networks FIXME: This is ugly at present 503 // special case for probed networks FIXME: This is ugly at present
504 if ( type == "network" && probed ) 504 if ( type == "network" && probed )
505 { 505 {
506 setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); 506 setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) );
507 } 507 }
508 508
509 // set icon for wep (wireless encryption protocol) 509 // set icon for wep (wireless encryption protocol)
510 if ( wep ) 510 if ( wep )
511 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 511 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
512 512
513 // set channel and signal text 513 // set channel and signal text
514 514
515 if ( signal != -1 ) 515 if ( signal != -1 )
516 setText( col_sig, QString::number( signal ) ); 516 setText( col_sig, QString::number( signal ) );
517 if ( channel != -1 ) 517 if ( channel != -1 )
518 setText( col_channel, QString::number( channel ) ); 518 setText( col_channel, QString::number( channel ) );
519 519
520 setText( col_firstseen, QTime::currentTime().toString() ); 520 setText( col_firstseen, QTime::currentTime().toString() );
521 //setText( col_lastseen, QTime::currentTime().toString() ); 521 //setText( col_lastseen, QTime::currentTime().toString() );
522 522
523 listView()->triggerUpdate(); 523 listView()->triggerUpdate();
524 524
525 this->type = type; 525 this->type = type;
526 _type = type; 526 _type = type;
527 _essid = essid; 527 _essid = essid;
528 _macaddr = macaddr; 528 _macaddr = macaddr;
529 _channel = channel; 529 _channel = channel;
530 _beacons = 1; 530 _beacons = 1;
531 _signal = 0; 531 _signal = 0;
532 532
533 if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) 533 if ( WellenreiterConfigWindow::instance()->openTree->isChecked() )
534 { 534 {
535 listView()->ensureItemVisible( this ); 535 listView()->ensureItemVisible( this );
536 } 536 }
537 537
538} 538}
539 539
540 540
541void MScanListItem::setManufacturer( const QString& manufacturer ) 541void MScanListItem::setManufacturer( const QString& manufacturer )
542{ 542{
543 setText( col_manuf, manufacturer ); 543 setText( col_manuf, manufacturer );
544} 544}
545 545
546 546
547void MScanListItem::setLocation( const QString& location ) 547void MScanListItem::setLocation( const QString& location )
548{ 548{
549 setText( col_location, location ); 549 setText( col_location, location );
550} 550}
551 551
552 552
553void MScanListItem::receivedBeacon() 553void MScanListItem::receivedBeacon()
554{ 554{
555 _beacons++; 555 _beacons++;
556 #ifdef DEBUG 556 #ifdef DEBUG
557 odebug << "MScanListItem " << _macaddr << ": received beacon #" << _beacons << "" << oendl; 557 odebug << "MScanListItem " << _macaddr << ": received beacon #" << _beacons << "" << oendl;
558 #endif 558 #endif
559 setText( col_sig, QString::number( _beacons ) ); 559 setText( col_sig, QString::number( _beacons ) );
560 setText( col_lastseen, QTime::currentTime().toString() ); 560 setText( col_lastseen, QTime::currentTime().toString() );
561 561
562 MScanListItem* p = (MScanListItem*) parent(); 562 MScanListItem* p = (MScanListItem*) parent();
563 if ( p ) p->receivedBeacon(); 563 if ( p ) p->receivedBeacon();
564 564
565} 565}
566 566