Diffstat (limited to 'noncore/net/wellenreiter/gui/scanlist.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 3b7120a..a2be782 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -8,59 +8,58 @@ | |||
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 | /* OPIE */ |
21 | #include <qcursor.h> | ||
22 | #include <qdatetime.h> | ||
23 | #include <qpopupmenu.h> | ||
24 | #include <qcheckbox.h> | ||
25 | |||
26 | #ifdef QWS | 21 | #ifdef QWS |
22 | #include <opie2/odebug.h> | ||
27 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
28 | #endif | ||
29 | |||
30 | #ifdef QWS | ||
31 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
32 | #else | 25 | #else |
33 | #include "resource.h" | 26 | #include "resource.h" |
34 | #endif | 27 | #endif |
28 | using namespace Opie::Core; | ||
29 | using namespace Opie::Ui; | ||
30 | using namespace Opie::Net; | ||
31 | |||
32 | /* QT */ | ||
33 | #include <qcursor.h> | ||
34 | #include <qdatetime.h> | ||
35 | #include <qpopupmenu.h> | ||
36 | #include <qcheckbox.h> | ||
37 | |||
38 | /* STD */ | ||
39 | #include <assert.h> | ||
35 | 40 | ||
36 | const int col_type = 0; | 41 | const int col_type = 0; |
37 | const int col_essid = 0; | 42 | const int col_essid = 0; |
38 | const int col_sig = 1; | 43 | const int col_sig = 1; |
39 | const int col_ap = 2; | 44 | const int col_ap = 2; |
40 | const int col_channel = 3; | 45 | const int col_channel = 3; |
41 | const int col_wep = 4; | 46 | const int col_wep = 4; |
42 | const int col_traffic = 5; | 47 | const int col_traffic = 5; |
43 | const int col_ip = 6; | 48 | const int col_ip = 6; |
44 | const int col_manuf = 7; | 49 | const int col_manuf = 7; |
45 | const int col_firstseen = 8; | 50 | const int col_firstseen = 8; |
46 | const int col_lastseen = 9; | 51 | const int col_lastseen = 9; |
47 | const int col_location = 10; | 52 | const int col_location = 10; |
48 | 53 | ||
49 | using namespace Opie::Net; | ||
50 | using namespace Opie::Ui; | ||
51 | using namespace Opie::Net; | ||
52 | using namespace Opie::Ui; | ||
53 | using namespace Opie::Ui; | ||
54 | using namespace Opie::Net; | ||
55 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 54 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
56 | :OListView( parent, name ) | 55 | :OListView( parent, name ) |
57 | { | 56 | { |
58 | setFrameShape( QListView::StyledPanel ); | 57 | setFrameShape( QListView::StyledPanel ); |
59 | setFrameShadow( QListView::Sunken ); | 58 | setFrameShadow( QListView::Sunken ); |
60 | 59 | ||
61 | addColumn( tr( "Net/Station" ) ); | 60 | addColumn( tr( "Net/Station" ) ); |
62 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); | 61 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); |
63 | addColumn( tr( "#" ) ); | 62 | addColumn( tr( "#" ) ); |
64 | setColumnAlignment( col_sig, AlignCenter ); | 63 | setColumnAlignment( col_sig, AlignCenter ); |
65 | addColumn( tr( "MAC" ) ); | 64 | addColumn( tr( "MAC" ) ); |
66 | setColumnAlignment( col_ap, AlignCenter ); | 65 | setColumnAlignment( col_ap, AlignCenter ); |
@@ -97,32 +96,32 @@ MScanListView::~MScanListView() | |||
97 | { | 96 | { |
98 | }; | 97 | }; |
99 | 98 | ||
100 | 99 | ||
101 | OListViewItem* MScanListView::childFactory() | 100 | OListViewItem* MScanListView::childFactory() |
102 | { | 101 | { |
103 | return new MScanListItem( this ); | 102 | return new MScanListItem( this ); |
104 | } | 103 | } |
105 | 104 | ||
106 | 105 | ||
107 | void MScanListView::serializeTo( QDataStream& s) const | 106 | void MScanListView::serializeTo( QDataStream& s) const |
108 | { | 107 | { |
109 | qDebug( "serializing MScanListView" ); | 108 | odebug << "serializing MScanListView" << oendl; |
110 | OListView::serializeTo( s ); | 109 | OListView::serializeTo( s ); |
111 | } | 110 | } |
112 | 111 | ||
113 | 112 | ||
114 | void MScanListView::serializeFrom( QDataStream& s) | 113 | void MScanListView::serializeFrom( QDataStream& s) |
115 | { | 114 | { |
116 | qDebug( "serializing MScanListView" ); | 115 | odebug << "serializing MScanListView" << oendl; |
117 | OListView::serializeFrom( s ); | 116 | OListView::serializeFrom( s ); |
118 | } | 117 | } |
119 | 118 | ||
120 | 119 | ||
121 | void MScanListView::addNewItem( const QString& type, | 120 | void MScanListView::addNewItem( const QString& type, |
122 | const QString& essid, | 121 | const QString& essid, |
123 | const OMacAddress& mac, | 122 | const OMacAddress& mac, |
124 | bool wep, | 123 | bool wep, |
125 | int channel, | 124 | int channel, |
126 | int signal, | 125 | int signal, |
127 | const GpsLocation& loc, | 126 | const GpsLocation& loc, |
128 | bool probe ) | 127 | bool probe ) |
@@ -134,68 +133,68 @@ void MScanListView::addNewItem( const QString& type, | |||
134 | (const char*) essid, (const char*) macaddr, channel ); | 133 | (const char*) essid, (const char*) macaddr, channel ); |
135 | #endif | 134 | #endif |
136 | 135 | ||
137 | // search, if we already have seen this net | 136 | // search, if we already have seen this net |
138 | 137 | ||
139 | QString s; | 138 | QString s; |
140 | MScanListItem* network; | 139 | MScanListItem* network; |
141 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 140 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
142 | 141 | ||
143 | while ( item && ( item->text( col_essid ) != essid ) ) | 142 | while ( item && ( item->text( col_essid ) != essid ) ) |
144 | { | 143 | { |
145 | #ifdef DEBUG | 144 | #ifdef DEBUG |
146 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); | 145 | odebug << "itemtext: " << (const char*) item->text( col_essid ) << "" << oendl; |
147 | #endif | 146 | #endif |
148 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 147 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
149 | } | 148 | } |
150 | if ( item ) | 149 | if ( item ) |
151 | { | 150 | { |
152 | // we have already seen this net, check all childs if MAC exists | 151 | // we have already seen this net, check all childs if MAC exists |
153 | 152 | ||
154 | network = item; | 153 | network = item; |
155 | 154 | ||
156 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 155 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
157 | assert( item ); // this shouldn't fail | 156 | assert( item ); // this shouldn't fail |
158 | 157 | ||
159 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 158 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
160 | { | 159 | { |
161 | #ifdef DEBUG | 160 | #ifdef DEBUG |
162 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 161 | odebug << "subitemtext: " << (const char*) item->text( col_ap ) << "" << oendl; |
163 | #endif | 162 | #endif |
164 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 163 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
165 | } | 164 | } |
166 | 165 | ||
167 | if ( item ) | 166 | if ( item ) |
168 | { | 167 | { |
169 | // we have already seen this item, it's a dupe | 168 | // we have already seen this item, it's a dupe |
170 | #ifdef DEBUG | 169 | #ifdef DEBUG |
171 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 170 | odebug << "" << (const char*) macaddr << " is a dupe - ignoring..." << oendl; |
172 | #endif | 171 | #endif |
173 | item->receivedBeacon(); | 172 | item->receivedBeacon(); |
174 | return; | 173 | return; |
175 | } | 174 | } |
176 | } | 175 | } |
177 | else | 176 | else |
178 | { | 177 | { |
179 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 178 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); |
180 | MLogWindow::logwindow()->log( s ); | 179 | MLogWindow::logwindow()->log( s ); |
181 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); | 180 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); |
182 | } | 181 | } |
183 | 182 | ||
184 | 183 | ||
185 | // insert new station as child from network | 184 | // insert new station as child from network |
186 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 185 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
187 | 186 | ||
188 | #ifdef DEBUG | 187 | #ifdef DEBUG |
189 | qDebug( "inserting new station %s", (const char*) macaddr ); | 188 | odebug << "inserting new station " << (const char*) macaddr << "" << oendl; |
190 | #endif | 189 | #endif |
191 | 190 | ||
192 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 191 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
193 | station->setManufacturer( mac.manufacturer() ); | 192 | station->setManufacturer( mac.manufacturer() ); |
194 | station->setLocation( loc.dmsPosition() ); | 193 | station->setLocation( loc.dmsPosition() ); |
195 | 194 | ||
196 | if ( type == "managed" ) | 195 | if ( type == "managed" ) |
197 | { | 196 | { |
198 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 197 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
199 | } | 198 | } |
200 | else | 199 | else |
201 | { | 200 | { |
@@ -203,196 +202,196 @@ void MScanListView::addNewItem( const QString& type, | |||
203 | } | 202 | } |
204 | MLogWindow::logwindow()->log( s ); | 203 | MLogWindow::logwindow()->log( s ); |
205 | } | 204 | } |
206 | 205 | ||
207 | 206 | ||
208 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 207 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
209 | { | 208 | { |
210 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 209 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
211 | 210 | ||
212 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 211 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
213 | { | 212 | { |
214 | #ifdef DEBUG | 213 | #ifdef DEBUG |
215 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 214 | odebug << "subitemtext: " << (const char*) subitem->text( col_ap ) << "" << oendl; |
216 | #endif | 215 | #endif |
217 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 216 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
218 | } | 217 | } |
219 | 218 | ||
220 | if ( subitem ) | 219 | if ( subitem ) |
221 | { | 220 | { |
222 | // we have already seen this item, it's a dupe | 221 | // we have already seen this item, it's a dupe |
223 | #ifdef DEBUG | 222 | #ifdef DEBUG |
224 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); | 223 | odebug << "" << (const char*) addr.toString(true) << " is a dupe - ignoring..." << oendl; |
225 | #endif | 224 | #endif |
226 | subitem->receivedBeacon(); //FIXME: sent data bit | 225 | subitem->receivedBeacon(); //FIXME: sent data bit |
227 | return; | 226 | return; |
228 | } | 227 | } |
229 | 228 | ||
230 | // Hey, it seems to be a new item :-D | 229 | // 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 ); | 230 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); |
232 | station->setManufacturer( addr.manufacturer() ); | 231 | station->setManufacturer( addr.manufacturer() ); |
233 | 232 | ||
234 | QString s; | 233 | QString s; |
235 | if ( type == "station" ) | 234 | if ( type == "station" ) |
236 | { | 235 | { |
237 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 236 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
238 | } | 237 | } |
239 | else | 238 | else |
240 | { | 239 | { |
241 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 240 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
242 | } | 241 | } |
243 | MLogWindow::logwindow()->log( s ); | 242 | MLogWindow::logwindow()->log( s ); |
244 | } | 243 | } |
245 | 244 | ||
246 | 245 | ||
247 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 246 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
248 | { | 247 | { |
249 | qDebug( "WDSTraffic: %s and %s seem to form a WDS", (const char*) viaFrom.toString(), (const char*) viaTo.toString() ); | 248 | odebug << "WDSTraffic: " << (const char*) viaFrom.toString() << " and " << (const char*) viaTo.toString() << " seem to form a WDS" << oendl; |
250 | QString s; | 249 | QString s; |
251 | MScanListItem* network; | 250 | MScanListItem* network; |
252 | 251 | ||
253 | QListViewItemIterator it( this ); | 252 | QListViewItemIterator it( this ); |
254 | while ( it.current() && | 253 | while ( it.current() && |
255 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 254 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
256 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 255 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
257 | 256 | ||
258 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 257 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
259 | 258 | ||
260 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 259 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
261 | { | 260 | { |
262 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 261 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
263 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 262 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
264 | } | 263 | } |
265 | else | 264 | else |
266 | { | 265 | { |
267 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 266 | 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!" ); | 267 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
269 | } | 268 | } |
270 | } | 269 | } |
271 | 270 | ||
272 | 271 | ||
273 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 272 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
274 | { | 273 | { |
275 | QString s; | 274 | QString s; |
276 | MScanListItem* network; | 275 | MScanListItem* network; |
277 | 276 | ||
278 | QListViewItemIterator it( this ); | 277 | QListViewItemIterator it( this ); |
279 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 278 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
280 | 279 | ||
281 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 280 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
282 | 281 | ||
283 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 282 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
284 | { | 283 | { |
285 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 284 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
286 | } | 285 | } |
287 | else | 286 | else |
288 | { | 287 | { |
289 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 288 | 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!" ); | 289 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
291 | 290 | ||
292 | } | 291 | } |
293 | } | 292 | } |
294 | 293 | ||
295 | 294 | ||
296 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 295 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
297 | { | 296 | { |
298 | QString s; | 297 | QString s; |
299 | MScanListItem* network; | 298 | MScanListItem* network; |
300 | 299 | ||
301 | QListViewItemIterator it( this ); | 300 | QListViewItemIterator it( this ); |
302 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 301 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
303 | 302 | ||
304 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 303 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
305 | 304 | ||
306 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 305 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
307 | { | 306 | { |
308 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 307 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
309 | } | 308 | } |
310 | else | 309 | else |
311 | { | 310 | { |
312 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 311 | 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!" ); | 312 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
314 | } | 313 | } |
315 | } | 314 | } |
316 | 315 | ||
317 | 316 | ||
318 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 317 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
319 | { | 318 | { |
320 | qWarning( "D'oh! Not yet implemented..." ); | 319 | owarn << "D'oh! Not yet implemented..." << oendl; |
321 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 320 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
322 | } | 321 | } |
323 | 322 | ||
324 | 323 | ||
325 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 324 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
326 | { | 325 | { |
327 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); | 326 | odebug << "identify " << (const char*) macaddr.toString() << " = " << (const char*) ip << "" << oendl; |
328 | 327 | ||
329 | QListViewItemIterator it( this ); | 328 | QListViewItemIterator it( this ); |
330 | for ( ; it.current(); ++it ) | 329 | for ( ; it.current(); ++it ) |
331 | { | 330 | { |
332 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 331 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
333 | { | 332 | { |
334 | it.current()->setText( col_ip, ip ); | 333 | it.current()->setText( col_ip, ip ); |
335 | return; | 334 | return; |
336 | } | 335 | } |
337 | } | 336 | } |
338 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 337 | 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!", | 338 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
340 | (const char*) macaddr.toString(), (const char*) ip ) ); | 339 | (const char*) macaddr.toString(), (const char*) ip ) ); |
341 | } | 340 | } |
342 | 341 | ||
343 | 342 | ||
344 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 343 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
345 | { | 344 | { |
346 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); | 345 | odebug << "addService '" << (const char*) name << "', Server = " << (const char*) macaddr.toString() << " = " << (const char*) ip << "" << oendl; |
347 | 346 | ||
348 | //TODO: Refactor that out, we need it all over the place. | 347 | //TODO: Refactor that out, we need it all over the place. |
349 | // Best to do it in a more comfortable abstraction in OListView | 348 | // Best to do it in a more comfortable abstraction in OListView |
350 | // (Hmm, didn't I already start something in this direction?) | 349 | // (Hmm, didn't I already start something in this direction?) |
351 | 350 | ||
352 | QListViewItemIterator it( this ); | 351 | QListViewItemIterator it( this ); |
353 | for ( ; it.current(); ++it ) | 352 | for ( ; it.current(); ++it ) |
354 | { | 353 | { |
355 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 354 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
356 | { | 355 | { |
357 | 356 | ||
358 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); | 357 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); |
359 | 358 | ||
360 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | 359 | while ( subitem && ( subitem->text( col_essid ) != name ) ) |
361 | { | 360 | { |
362 | #ifdef DEBUG | 361 | #ifdef DEBUG |
363 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); | 362 | odebug << "subitemtext: " << (const char*) subitem->text( col_essid ) << "" << oendl; |
364 | #endif | 363 | #endif |
365 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 364 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
366 | } | 365 | } |
367 | 366 | ||
368 | if ( subitem ) | 367 | if ( subitem ) |
369 | { | 368 | { |
370 | // we have already seen this item, it's a dupe | 369 | // we have already seen this item, it's a dupe |
371 | #ifdef DEBUG | 370 | #ifdef DEBUG |
372 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); | 371 | odebug << "" << (const char*) name << " is a dupe - ignoring..." << oendl; |
373 | #endif | 372 | #endif |
374 | subitem->receivedBeacon(); //FIXME: sent data bit | 373 | subitem->receivedBeacon(); //FIXME: sent data bit |
375 | return; | 374 | return; |
376 | } | 375 | } |
377 | 376 | ||
378 | // never seen that - add new item | 377 | // never seen that - add new item |
379 | 378 | ||
380 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); | 379 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); |
381 | item->setText( col_essid, name ); | 380 | item->setText( col_essid, name ); |
382 | 381 | ||
383 | return; | 382 | return; |
384 | } | 383 | } |
385 | } | 384 | } |
386 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 385 | 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!", | 386 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", |
388 | (const char*) macaddr.toString(), (const char*) ip ) ); | 387 | (const char*) macaddr.toString(), (const char*) ip ) ); |
389 | } | 388 | } |
390 | 389 | ||
391 | 390 | ||
392 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 391 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
393 | { | 392 | { |
394 | if ( !item ) return; | 393 | if ( !item ) return; |
395 | 394 | ||
396 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 395 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
397 | 396 | ||
398 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 397 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
@@ -412,74 +411,74 @@ void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, in | |||
412 | 411 | ||
413 | //============================================================ | 412 | //============================================================ |
414 | // MScanListItem | 413 | // MScanListItem |
415 | //============================================================ | 414 | //============================================================ |
416 | 415 | ||
417 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, | 416 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, |
418 | bool wep, int channel, int signal, bool probed ) | 417 | bool wep, int channel, int signal, bool probed ) |
419 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 418 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
420 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 419 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
421 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 420 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
422 | { | 421 | { |
423 | #ifdef DEBUG | 422 | #ifdef DEBUG |
424 | qDebug( "creating scanlist item" ); | 423 | odebug << "creating scanlist item" << oendl; |
425 | #endif | 424 | #endif |
426 | 425 | ||
427 | if ( WellenreiterConfigWindow::instance() ) | 426 | if ( WellenreiterConfigWindow::instance() ) |
428 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 427 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
429 | 428 | ||
430 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); | 429 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); |
431 | } | 430 | } |
432 | 431 | ||
433 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, | 432 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, |
434 | bool wep, int channel, int signal ) | 433 | bool wep, int channel, int signal ) |
435 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 434 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
436 | { | 435 | { |
437 | #ifdef DEBUG | 436 | #ifdef DEBUG |
438 | qDebug( "creating scanlist item" ); | 437 | odebug << "creating scanlist item" << oendl; |
439 | #endif | 438 | #endif |
440 | if ( WellenreiterConfigWindow::instance() ) | 439 | if ( WellenreiterConfigWindow::instance() ) |
441 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 440 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
442 | 441 | ||
443 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); | 442 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); |
444 | } | 443 | } |
445 | 444 | ||
446 | const QString& MScanListItem::essid() const | 445 | const QString& MScanListItem::essid() const |
447 | { | 446 | { |
448 | if ( type == "network" ) | 447 | if ( type == "network" ) |
449 | return _essid; | 448 | return _essid; |
450 | else | 449 | else |
451 | return ( (MScanListItem*) parent() )->essid(); | 450 | return ( (MScanListItem*) parent() )->essid(); |
452 | } | 451 | } |
453 | 452 | ||
454 | OListViewItem* MScanListItem::childFactory() | 453 | OListViewItem* MScanListItem::childFactory() |
455 | { | 454 | { |
456 | return new MScanListItem( this ); | 455 | return new MScanListItem( this ); |
457 | } | 456 | } |
458 | 457 | ||
459 | void MScanListItem::serializeTo( QDataStream& s ) const | 458 | void MScanListItem::serializeTo( QDataStream& s ) const |
460 | { | 459 | { |
461 | #ifdef DEBUG | 460 | #ifdef DEBUG |
462 | qDebug( "serializing MScanListItem" ); | 461 | odebug << "serializing MScanListItem" << oendl; |
463 | #endif | 462 | #endif |
464 | OListViewItem::serializeTo( s ); | 463 | OListViewItem::serializeTo( s ); |
465 | 464 | ||
466 | s << _type; | 465 | s << _type; |
467 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 466 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
468 | } | 467 | } |
469 | 468 | ||
470 | void MScanListItem::serializeFrom( QDataStream& s ) | 469 | void MScanListItem::serializeFrom( QDataStream& s ) |
471 | { | 470 | { |
472 | #ifdef DEBUG | 471 | #ifdef DEBUG |
473 | qDebug( "serializing MScanListItem" ); | 472 | odebug << "serializing MScanListItem" << oendl; |
474 | #endif | 473 | #endif |
475 | OListViewItem::serializeFrom( s ); | 474 | OListViewItem::serializeFrom( s ); |
476 | 475 | ||
477 | char wep; | 476 | char wep; |
478 | s >> _type; | 477 | s >> _type; |
479 | s >> (Q_UINT8) wep; | 478 | s >> (Q_UINT8) wep; |
480 | _wep = (wep == 'y'); | 479 | _wep = (wep == 'y'); |
481 | 480 | ||
482 | QString name; | 481 | QString name; |
483 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 482 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
484 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 483 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
485 | if ( _wep ) | 484 | if ( _wep ) |
@@ -547,22 +546,22 @@ void MScanListItem::setManufacturer( const QString& manufacturer ) | |||
547 | 546 | ||
548 | 547 | ||
549 | void MScanListItem::setLocation( const QString& location ) | 548 | void MScanListItem::setLocation( const QString& location ) |
550 | { | 549 | { |
551 | setText( col_location, location ); | 550 | setText( col_location, location ); |
552 | } | 551 | } |
553 | 552 | ||
554 | 553 | ||
555 | void MScanListItem::receivedBeacon() | 554 | void MScanListItem::receivedBeacon() |
556 | { | 555 | { |
557 | _beacons++; | 556 | _beacons++; |
558 | #ifdef DEBUG | 557 | #ifdef DEBUG |
559 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 558 | odebug << "MScanListItem " << (const char*) _macaddr << ": received beacon #" << _beacons << "" << oendl; |
560 | #endif | 559 | #endif |
561 | setText( col_sig, QString::number( _beacons ) ); | 560 | setText( col_sig, QString::number( _beacons ) ); |
562 | setText( col_lastseen, QTime::currentTime().toString() ); | 561 | setText( col_lastseen, QTime::currentTime().toString() ); |
563 | 562 | ||
564 | MScanListItem* p = (MScanListItem*) parent(); | 563 | MScanListItem* p = (MScanListItem*) parent(); |
565 | if ( p ) p->receivedBeacon(); | 564 | if ( p ) p->receivedBeacon(); |
566 | 565 | ||
567 | } | 566 | } |
568 | 567 | ||