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,325 +1,325 @@
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 )